@galacean/engine 1.2.0-beta.6 → 1.2.0

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.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}e.ContainmentType=void 0,(lX=e.ContainmentType||(e.ContainmentType={}))[lX.Disjoint=0]="Disjoint",lX[lX.Contains=1]="Contains",lX[lX.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(lq=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[lq.Back=0]="Back",lq[lq.Front=1]="Front",lq[lq.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(lY=e.FrustumFace||(e.FrustumFace={}))[lY.Near=0]="Near",lY[lY.Far=1]="Far",lY[lY.Left=2]="Left",lY[lY.Right=3]="Right",lY[lY.Bottom=4]="Bottom",lY[lY.Top=5]="Top";var a,i,o,s,l,c,d,u,h,_,f,p,m,g,v,y,x,b,S,T,C,A,E,M,R,w,P,F,L,D,B,I,V,O,N,k,z,U,G,H,W,K,j,X,q,Y,Q,J,Z,$,ee,et,er,en,ea,ei,eo,es,el,ec,ed,eu,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eS,eT,eC,eA,eE,eM,eR,ew,eP,eF,eL,eD,eB,eI,eV,eO,eN,ek,ez,eU,eG,eH,eW,eK,ej,eX,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tr,tn,ta,ti,to,ts,tl,tc,td,tu,th,t_,tf,tp,tm,tg,tv,ty,tx,tb,tS,tT,tC,tA,tE,tM,tR,tw,tP,tF,tL,tD,tB,tI,tV,tO,tN,tk,tz,tU,tG,tH,tW,tK,tj,tX,tq,tY,tQ,tJ,tZ,t$,t0,t1,t2,t3,t4,t8,t5,t9,t6,t7,re,rt,rr,rn,ra,ri,ro,rs,rl,rc,rd,ru,rh,r_,rf,rp,rm,rg,rv,ry,rx,rb,rS,rT,rC,rA,rE,rM,rR,rw,rP,rF,rL,rD,rB,rI,rV,rO,rN,rk,rz,rU,rG,rH,rW,rK,rj,rX,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r8,r5,r9,r6,r7,ne,nt,nr,nn,na,ni,no,ns,nl,nc,nd,nu,nh,n_,nf,np,nm,ng,nv,ny,nx,nb,nS,nT,nC,nA,nE,nM,nR,nw,nP,nF,nL,nD,nB,nI,nV,nO,nN,nk,nz,nU,nG,nH,nW,nK,nj,nX,nq,nY,nQ,nJ,nZ,n$,n0,n1,n2,n3,n4,n8,n5,n9,n6,n7,ae,at,ar,an,aa,ai,ao,as,al,ac,ad,au,ah,a_,af,ap,am,ag,av,ay,ax,ab,aS,aT,aC,aA,aE,aM,aR,aw,aP,aF,aL,aD,aB,aI,aV,aO,aN,ak,az,aU,aG,aH,aW,aK,aj,aX,aq,aY,aQ,aJ,aZ,a$,a0,a1,a2,a3,a4,a8,a5,a9,a6,a7,ie,it,ir,ia,ii,io,is,il,ic,id,iu,ih,i_,ip,im,ig,iv,iy,ix,ib,iS,iT,iC,iA,iE,iM,iR,iw,iP,iF,iL,iD,iB,iI,iV,iO,iN,ik,iz,iU,iG,iH,iW,iK,ij,iX,iq,iY,iQ,iJ,iZ,i$,i0,i1,i2,i3,i4,i8,i5,i9,i6,i7,oe,ot,or,on,oa,oi,oo,os,ol,oc,od,ou,oh,o_,of,op,om,og,ov,oy,ox,ob,oS,oT,oC,oA,oE,oM,oR,ow,oP,oF,oL,oD,oB,oI,oV,oO,oN,ok,oz,oU,oG,oH,oW,oK,oj,oX,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o8,o5,o9,o6,o7,se,st,sr,sn,sa,si,so,ss,sl,sc,sd,su,sh,s_,sf,sp,sm,sg,sv,sy,sx,sb,sS,sT,sC,sA,sE,sM,sR,sw,sP,sF,sL,sD,sB,sI,sV,sO,sN,sk,sz,sU,sG,sH,sW,sK,sj,sX,sq,sY,sQ,sJ,sZ,s$,s0,s1,s2,s3,s4,s8,s5,s9,s6,s7,le,lt,lr,ln,la,li,lo,ls,ll,lc,ld,lu,lh,l_,lf,lp,lm,lg,lv,ly,lx,lb,lS,lT,lC,lA,lE,lM,lR,lw,lP,lF,lL,lD,lB,lI,lV,lO,lN,lk,lz,lU,lG,lH,lW,lK,lj,lX,lq,lY,lQ,lJ,lZ,l$,l0,l1,l2,l3,l4,l8,l5,l9,l6,l7,ce,ct,cr,cn,ca,ci,co,cs,cl,cc,cd,cu,ch,c_,cf,cp,cm,cg,cv,cy,cx,cb,cS,cT,cC,cA,cE,cM,cR,cw,cP,cF,cL,cD=((lQ=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},lQ.equals=function(e,t){return Math.abs(e-t)<=lQ.zeroTolerance},lQ.isPowerOf2=function(e){return(e&e-1)==0},lQ.radianToDegree=function(e){return e*lQ.radToDegreeFactor},lQ.degreeToRadian=function(e){return e*lQ.degreeToRadFactor},lQ);cD.zeroTolerance=1e-6,cD.radToDegreeFactor=180/Math.PI,cD.degreeToRadFactor=Math.PI/180;var cB=((i=(a=function(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r}).prototype).set=function(e,t,r){return this._x=e,this._y=t,this._z=r,this._onValueChanged&&this._onValueChanged(),this},i.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},i.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},i.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},i.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},i.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},i.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},i.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},i.normalize=function(){return a.normalize(this,this),this},i.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},i.transformNormal=function(e){return a.transformNormal(this,e,this),this},i.transformToVec3=function(e){return a.transformToVec3(this,e,this),this},i.transformCoordinate=function(e){return a.transformCoordinate(this,e,this),this},i.transformByQuat=function(e){return a.transformByQuat(this,e,this),this},i.clone=function(){return new a(this._x,this._y,this._z)},i.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},i.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},i.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},i.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},a.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._onValueChanged&&r._onValueChanged()},a.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._onValueChanged&&r._onValueChanged()},a.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._onValueChanged&&r._onValueChanged()},a.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._onValueChanged&&r._onValueChanged()},a.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},a.cross=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;r.set(a*l-i*s,i*o-n*l,n*s-a*o)},a.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return Math.sqrt(r*r+n*n+a*a)},a.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return r*r+n*n+a*a},a.equals=function(e,t){return cD.equals(e._x,t._x)&&cD.equals(e._y,t._y)&&cD.equals(e._z,t._z)},a.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},a.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},a.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=Math.sqrt(r*r+n*n+a*a);i>cD.zeroTolerance&&(i=1/i,t.set(r*i,n*i,a*i))},a.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},a.transformNormal=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8],r._y=n*o[1]+a*o[5]+i*o[9],r._z=n*o[2]+a*o[6]+i*o[10],r._onValueChanged&&r._onValueChanged()},a.transformToVec3=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},a.transformToVec4=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._w=n*o[3]+a*o[7]+i*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},a.transformCoordinate=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements,s=n*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,r._x=(n*o[0]+a*o[4]+i*o[8]+o[12])*s,r._y=(n*o[1]+a*o[5]+i*o[9]+o[13])*s,r._z=(n*o[2]+a*o[6]+i*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},a.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,d=c*n+s*i-l*a,u=c*a+l*n-o*i,h=c*i+o*a-s*n,_=-o*n-s*a-l*i;r._x=d*c-_*o-u*l+h*s,r._y=u*c-_*s-h*o+d*l,r._z=h*c-_*l-d*s+u*o,r._onValueChanged&&r._onValueChanged()},n(a,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),a);cB._zero=new cB(0,0,0),cB._one=new cB(1,1,1);var cI=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new cB,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}).prototype).clone=function(){return new o(this.center,this.radius)},s.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},o.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=e.length,n=o._tempVec30;n.x=n.y=n.z=0;for(var a=0;a<r;++a)cB.add(e[a],n,n);cB.scale(n,1/r,t.center);for(var i=0,s=0;s<r;++s){var l=cB.distanceSquared(n,e[s]);l>i&&(i=l)}t.radius=Math.sqrt(i)},o.fromBox=function(e,t){var r=t.center,n=e.min,a=e.max;r.x=(n.x+a.x)*.5,r.y=(n.y+a.y)*.5,r.z=(n.z+a.z)*.5,t.radius=cB.distance(r,a)},o);cI._tempVec30=new cB;var cV=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new cB,this.max=new cB,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){var t=this.min,r=this.max,n=r._x+t._x,a=r._y+t._y,i=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,a=r._y-t._y,i=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,a=t.y,i=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var d=0,u=8-c;d<u;++d)e[c+d]=new cB;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(n,a,l),e[4].set(n,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(n,a,i),e},c.transform=function(e){return l.transform(this,e,this),this},c.clone=function(){return new l(this.min,this.max)},c.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,r){cB.subtract(e,t,r.min),cB.add(e,t,r.max)},l.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=t.min,n=t.max;r.x=r.y=r.z=Number.MAX_VALUE,n.x=n.y=n.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];cB.min(r,o,r),cB.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,a=t.min,i=t.max;a.x=r.x-n,a.y=r.y-n,a.z=r.z-n,i.x=r.x+n,i.y=r.y+n,i.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,a=l._tempVec31;e.getCenter(n),e.getExtent(a),cB.transformCoordinate(n,t,n);var i=a.x,o=a.y,s=a.z,c=t.elements,d=c[0],u=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];a.set((0===d?0:Math.abs(i*d))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===u?0:Math.abs(i*u))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(i*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),cB.subtract(n,a,r.min),cB.add(n,a,r.max)},l.merge=function(e,t,r){return cB.min(e.min,t.min,r.min),cB.max(e.max,t.max,r.max),r},l);cV._tempVec30=new cB,cV._tempVec31=new cB;var cO=((d=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var a=e.normal,i=t.normal,o=r.normal;cB.cross(i,o,d._tempVec30),cB.cross(o,a,d._tempVec31),cB.cross(a,i,d._tempVec32);var s=-cB.dot(a,d._tempVec30),l=-cB.dot(i,d._tempVec31),c=-cB.dot(o,d._tempVec32);cB.scale(d._tempVec30,e.distance/s,d._tempVec30),cB.scale(d._tempVec31,t.distance/l,d._tempVec31),cB.scale(d._tempVec32,r.distance/c,d._tempVec32),cB.add(d._tempVec30,d._tempVec31,n),cB.add(n,d._tempVec32,n)},d.distancePlaneAndPoint=function(e,t){return cB.dot(e.normal,t)+e.distance},d.intersectsPlaneAndPoint=function(t,r){var n=d.distancePlaneAndPoint(t,r);return n>0?e.PlaneIntersectionType.Front:n<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},d.intersectsPlaneAndBox=function(t,r){var n=r.min,a=r.max,i=t.normal,o=d._tempVec30,s=d._tempVec31;return(i.x>=0?(o.x=a.x,s.x=n.x):(o.x=n.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=n.y):(o.y=n.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=n.z):(o.z=n.z,s.z=a.z),0>d.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:d.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},d.intersectsPlaneAndSphere=function(t,r){var n=r.center,a=r.radius,i=d.distancePlaneAndPoint(t,n);return i>a?e.PlaneIntersectionType.Front:i<-a?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},d.intersectsRayAndPlane=function(e,t){var r=t.normal,n=cD.zeroTolerance,a=cB.dot(r,e.direction);if(Math.abs(a)<n)return -1;var i=cB.dot(r,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-n)return -1;o=0}return o},d.intersectsRayAndBox=function(e,t){var r=cD.zeroTolerance,n=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,d=n.x,u=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(d<i.x||d>o.x)return -1}else{var p=1/s,m=(i.x-d)*p,g=(o.x-d)*p;if(m>g){var v=m;m=g,g=v}if((_=Math.max(m,_))>(f=Math.min(g,f)))return -1}if(Math.abs(l)<r){if(u<i.y||u>o.y)return -1}else{var y=1/l,x=(i.y-u)*y,b=(o.y-u)*y;if(x>b){var S=x;x=b,b=S}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<r){if(h<i.z||h>o.z)return -1}else{var T=1/c,C=(i.z-h)*T,A=(o.z-h)*T;if(C>A){var E=C;C=A,A=E}if((_=Math.max(C,_))>(f=Math.min(A,f)))return -1}return _},d.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,a=t.center,i=t.radius,o=d._tempVec30;cB.subtract(r,a,o);var s=cB.dot(o,n),l=cB.dot(o,o)-i*i;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var u=-s-Math.sqrt(c);return u<0&&(u=0),u},d.intersectsBoxAndBox=function(e,t){return!(e.min.x>t.max.x)&&!(t.min.x>e.max.x)&&!(e.min.y>t.max.y)&&!(t.min.y>e.max.y)&&!(e.min.z>t.max.z||t.min.z>e.max.z)},d.intersectsSphereAndSphere=function(e,t){var r=e.radius+t.radius;return cB.distanceSquared(e.center,t.center)<r*r},d.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,a=t.min,i=d._tempVec30;return i.set(Math.max(a.x,Math.min(r.x,n.x)),Math.max(a.y,Math.min(r.y,n.y)),Math.max(a.z,Math.min(r.z,n.z))),cB.distanceSquared(r,i)<=e.radius*e.radius},d.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,a=d._tempVec30,i=0;i<6;++i){var o=e.getPlane(i),s=o.normal;if(a.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),cB.dot(s,a)<-o.distance)return!1}return!0},d.frustumContainsPoint=function(t,r){var n=d.distancePlaneAndPoint(t.near,r);return Math.abs(n)<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.far,r))<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.left,r))<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.right,r))<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.top,r))<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.bottom,r))<cD.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},d.frustumContainsBox=function(t,r){for(var n=r.min,a=r.max,i=d._tempVec30,o=d._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(i.x=a.x,o.x=n.x):(i.x=n.x,o.x=a.x),u.y>=0?(i.y=a.y,o.y=n.y):(i.y=n.y,o.y=a.y),u.z>=0?(i.z=a.z,o.z=n.z):(i.z=n.z,o.z=a.z),d.intersectsPlaneAndPoint(c,i)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;d.intersectsPlaneAndPoint(c,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},d.frustumContainsSphere=function(t,r){for(var n=e.ContainmentType.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=d.intersectsPlaneAndSphere(i,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},d);cO._tempVec30=new cB,cO._tempVec31=new cB,cO._tempVec32=new cB;var cN=((h=(u=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new cB,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return u.normalize(this,this),this},h.clone=function(){var e=new u;return e.copyFrom(this),e},h.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},u.normalize=function(e,t){var r=e.normal,n=1/r.length();cB.scale(r,n,t.normal),t.distance=e.distance*n},u.fromPoints=function(e,t,r,n){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,d=r.x-a,u=r.y-i,h=r.z-o,_=l*h-c*u,f=c*d-s*h,p=s*u-l*d,m=1/Math.sqrt(_*_+f*f+p*p),g=_*m,v=f*m,y=p*m,x=n.normal;x.x=g,x.y=v,x.z=y,n.distance=-(g*a+v*i+y*o)},u),ck=((f=(_=function(e){void 0===e&&(e=null),this.near=new cN,this.far=new cN,this.left=new cN,this.right=new cN,this.top=new cN,this.bottom=new cN,e&&this.calculateFromMatrix(e)}).prototype).getPlane=function(t){switch(t){case e.FrustumFace.Near:return this.near;case e.FrustumFace.Far:return this.far;case e.FrustumFace.Left:return this.left;case e.FrustumFace.Right:return this.right;case e.FrustumFace.Bottom:return this.bottom;case e.FrustumFace.Top:return this.top;default:return null}},f.calculateFromMatrix=function(e){var t=e.elements,r=t[0],n=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],d=t[8],u=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+r,c+o,_+d),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-r,c-o,_-d),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+n,c+s,_+u),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-n,c-s,_-u),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return cO.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return cO.frustumContainsSphere(this,t)!==e.ContainmentType.Disjoint},f.clone=function(){var e=new _;return e.copyFrom(this),e},f.copyFrom=function(e){return this.near.copyFrom(e.near),this.far.copyFrom(e.far),this.left.copyFrom(e.left),this.right.copyFrom(e.right),this.bottom.copyFrom(e.bottom),this.top.copyFrom(e.top),this},_),cz=((m=(p=function(e,t,r,n,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},m.add=function(e){return p.add(this,e,this),this},m.subtract=function(e){return p.subtract(this,e,this),this},m.multiply=function(e){return p.multiply(this,e,this),this},m.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*a+o*s)+n*(l*a-i*s)},m.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},m.invert=function(){return p.invert(this,this),this},m.rotate=function(e){return p.rotate(this,e,this),this},m.scale=function(e){return p.scale(this,e,this),this},m.translate=function(e){return p.translate(this,e,this),this},m.transpose=function(){return p.transpose(this,this),this},m.clone=function(){var e=this.elements;return new p(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},m.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},m.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<12;n++)r[n]=e[n+t];return this},m.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=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]},m.copyFromMatrix=function(e){var t=e.elements,r=this.elements;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[4],r[4]=t[5],r[5]=t[6],r[6]=t[8],r[7]=t[9],r[8]=t[10],this},p.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8]},p.subtract=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3],i[4]=n[4]-a[4],i[5]=n[5]-a[5],i[6]=n[6]-a[6],i[7]=n[7]-a[7],i[8]=n[8]-a[8]},p.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],d=n[4],u=n[5],h=n[6],_=n[7],f=n[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],S=a[7],T=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+d*m+_*g,i[2]=l*p+u*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+d*y+_*x,i[5]=l*v+u*y+f*x,i[6]=o*b+c*S+h*T,i[7]=s*b+d*S+_*T,i[8]=l*b+u*S+f*T},p.equals=function(e,t){var r=e.elements,n=t.elements;return cD.equals(r[0],n[0])&&cD.equals(r[1],n[1])&&cD.equals(r[2],n[2])&&cD.equals(r[3],n[3])&&cD.equals(r[4],n[4])&&cD.equals(r[5],n[5])&&cD.equals(r[6],n[6])&&cD.equals(r[7],n[7])&&cD.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,d=n*s,u=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=u-v,r[6]=_+g,r[1]=u+v,r[4]=1-d-p,r[7]=f-m,r[2]=_-g,r[5]=f+m,r[8]=1-d-h},p.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=e._y,r[5]=0,r[6]=0,r[7]=0,r[8]=1},p.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=e._x,r[7]=e._y,r[8]=1},p.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=h*l-c*u,f=-h*s+c*d,p=u*s-l*d,m=a*_+i*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*i+o*u)*m,n[2]=(c*i-o*l)*m,n[3]=f*m,n[4]=(h*a-o*d)*m,n[5]=(-c*a+o*s)*m,n[6]=p*m,n[7]=(-u*a+i*d)*m,n[8]=(l*a-i*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15],x=a*c-i*l,b=a*d-o*l,S=a*u-s*l,T=i*d-o*c,C=i*u-s*c,A=o*u-s*d,E=h*g-_*m,M=h*v-f*m,R=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+T*R-C*M+A*E;if(!L)return null;L=1/L,n[0]=(c*F-d*P+u*w)*L,n[1]=(d*R-l*F-u*M)*L,n[2]=(l*P-c*R+u*E)*L,n[3]=(o*P-i*F-s*w)*L,n[4]=(a*F-o*R+s*M)*L,n[5]=(i*R-a*P-s*E)*L,n[6]=(g*A-v*C+y*T)*L,n[7]=(v*S-m*A-y*b)*L,n[8]=(m*C-g*S+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,a=r.elements,i=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],d=n[3],u=n[4],h=n[5],_=n[6],f=n[7],p=n[8];a[0]=o*s+i*d,a[1]=o*l+i*u,a[2]=o*c+i*h,a[3]=o*d-i*s,a[4]=o*u-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},p.scale=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements;o[0]=n*i[0],o[1]=n*i[1],o[2]=n*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},p.translate=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements,s=i[0],l=i[1],c=i[2],d=i[3],u=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=d,o[4]=u,o[5]=h,o[6]=n*s+a*d+_,o[7]=n*l+a*u+f,o[8]=n*c+a*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=a,n[5]=r[7],n[6]=i,n[7]=o}else n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8]},p),cU=((v=(g=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},v.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},v.getAxisAngle=function(e){var t=this._x,r=this._y,n=this._z,a=t*t+r*r+n*n;if(a<cD.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},v.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},v.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},v.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},v.normalize=function(){return g.normalize(this,this),this},v.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},v.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},v.rotateX=function(e){return g.rotateX(this,e,this),this},v.rotateY=function(e){return g.rotateY(this,e,this),this},v.rotateZ=function(e){return g.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return g.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return g.multiply(this,e,this),this},v.invert=function(){return g.invert(this,this),this},v.dot=function(e){return g.dot(this,e)},v.lerp=function(e,t){return g.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return g._tempQuat1.rotationAxisAngle(e,t),this.multiply(g._tempQuat1),this},v.clone=function(){return new g(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,r=this._y,n=this._z,a=this._w,i=t*t,o=r*r,s=n*n,l=a*a,c=i+o+s+l,d=2*(t*a-r*n);d>(1-cD.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=Math.PI/2,e._z=0):d<-(1-cD.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*a),s+l-o-i),e._y=Math.asin(d/c),e._z=Math.atan2(2*(t*r+n*a),o+l-s-i))},g.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},g.multiply=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,d=t._w;r._x=n*d+o*s+a*c-i*l,r._y=a*d+o*l+i*s-n*c,r._z=i*d+o*c+n*l-a*s,r._w=o*d-n*s-a*l-i*c,r._onValueChanged&&r._onValueChanged()},g.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},g.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},g.equals=function(e,t){return cD.equals(e._x,t._x)&&cD.equals(e._y,t._y)&&cD.equals(e._z,t._z)&&cD.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;cB.normalize(e,n);var a=Math.sin(t*=.5);r._x=n._x*a,r._y=n._y*a,r._z=n._z*a,r._w=Math.cos(t),r._onValueChanged&&r._onValueChanged()},g.rotationEuler=function(e,t,r,n){g.rotationYawPitchRoll(t,e,r,n)},g.rotationYawPitchRoll=function(e,t,r,n){var a=.5*r,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),d=Math.cos(i),u=Math.sin(o),h=Math.cos(o),_=h*d,f=u*c;n._x=h*c*l+u*d*s,n._y=u*d*l-h*c*s,n._z=_*s-f*l,n._w=_*l+f*s,n._onValueChanged&&n._onValueChanged()},g.rotationMatrix3x3=function(e,t){var r,n,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],d=a[5],u=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(d-h)*r,t._y=(u-s)*r,t._z=(o-l)*r):i>=c&&i>=_?(n=.5/(r=Math.sqrt(1+i-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+u)*n,t._w=(d-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-i-_)),t._x=(l+o)*n,t._y=.5*r,t._z=(h+d)*n,t._w=(u-s)*n):(n=.5/(r=Math.sqrt(1+_-i-c)),t._x=(s+u)*n,t._y=(d+h)*n,t._z=.5*r,t._w=(o-l)*n),t._onValueChanged&&t._onValueChanged()},g.invert=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=r*r+n*n+a*a+i*i;if(o>cD.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var a=1-r;g.dot(e,t)>=0?(n._x=e._x*a+t._x*r,n._y=e._y*a+t._y*r,n._z=e._z*a+t._z*r,n._w=e._w*a+t._w*r):(n._x=e._x*a-t._x*r,n._y=e._y*a-t._y*r,n._z=e._z*a-t._z*r,n._w=e._w*a-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var a,i,o=g.dot(e,t);if(Math.abs(o)>1-cD.zeroTolerance)i=1-r,a=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);i=Math.sin((1-r)*s)*l,a=Math.sin(r*s)*l*Math.sign(o)}n.x=i*e.x+a*t.x,n.y=i*e.y+a*t.y,n.z=i*e.z+a*t.z,n.w=i*e.w+a*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cD.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},g.rotationX=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=r,t._y=0,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationY=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=r,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationZ=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=0,t._z=r,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotateX=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=a*l+i*s,r._z=i*l-a*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-i*s,r._y=a*l+o*s,r._z=i*l+n*s,r._w=o*l-a*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+a*s,r._y=a*l-n*s,r._z=i*l+o*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},n(g,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<cD.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);cU._tempVector3=new cB,cU._tempQuat1=new cU;var cG=((x=(y=function(e,t,r,n,a,i,o,s,l,c,d,u,h,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===u&&(u=0),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var m=this.elements;m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=d,m[11]=u,m[12]=h,m[13]=_,m[14]=f,m[15]=p}).prototype).set=function(e,t,r,n,a,i,o,s,l,c,d,u,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=d,m[11]=u,m[12]=h,m[13]=_,m[14]=f,m[15]=p,this},x.multiply=function(e){return y.multiply(this,e,this),this},x.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8],d=e[9],u=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-r*i)*(u*m-h*p)-(t*s-n*i)*(d*m-h*f)+(t*l-a*i)*(d*p-u*f)+(r*s-n*o)*(c*m-h*_)-(r*l-a*o)*(c*p-u*_)+(n*l-a*s)*(c*f-d*_)},x.decompose=function(e,t,r){var n=y._tempMat30,a=this.elements,i=n.elements,o=a[0],s=a[1],l=a[2],c=a[4],d=a[5],u=a[6],h=a[8],_=a[9],f=a[10];e.set(a[12],a[13],a[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+d*d+u*u),g=Math.sqrt(h*h+_*_+f*f);if(0>this.determinant()&&(p=-p),r.set(p,m,g),Math.abs(p)<cD.zeroTolerance||Math.abs(m)<cD.zeroTolerance||Math.abs(g)<cD.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,b=1/g;return i[0]=o*v,i[1]=s*v,i[2]=l*v,i[3]=c*x,i[4]=d*x,i[5]=u*x,i[6]=h*b,i[7]=_*b,i[8]=f*b,cU.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>cD.zeroTolerance){var n=2*Math.sqrt(r+1);e._w=.25*n,e._x=(t[6]-t[9])/n,e._y=(t[8]-t[2])/n,e._z=(t[1]-t[4])/n}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},x.getScaling=function(e){var t=this.elements,r=t[0],n=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],d=t[10];return e.set(Math.sqrt(r*r+n*n+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+d*d)),e},x.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},x.identity=function(){var e=this.elements;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,this},x.invert=function(){return y.invert(this,this),this},x.rotateAxisAngle=function(e,t){return y.rotateAxisAngle(this,e,t,this),this},x.scale=function(e){return y.scale(this,e,this),this},x.translate=function(e){return y.translate(this,e,this),this},x.transpose=function(){return y.transpose(this,this),this},x.clone=function(){var e=this.elements;return new y(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])},x.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},x.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<16;n++)r[n]=e[n+t];return this},x.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=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]},y.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],d=n[4],u=n[5],h=n[6],_=n[7],f=n[8],p=n[9],m=n[10],g=n[11],v=n[12],y=n[13],x=n[14],b=n[15],S=a[0],T=a[1],C=a[2],A=a[3],E=a[4],M=a[5],R=a[6],w=a[7],P=a[8],F=a[9],L=a[10],D=a[11],B=a[12],I=a[13],V=a[14],O=a[15];i[0]=o*S+d*T+f*C+v*A,i[1]=s*S+u*T+p*C+y*A,i[2]=l*S+h*T+m*C+x*A,i[3]=c*S+_*T+g*C+b*A,i[4]=o*E+d*M+f*R+v*w,i[5]=s*E+u*M+p*R+y*w,i[6]=l*E+h*M+m*R+x*w,i[7]=c*E+_*M+g*R+b*w,i[8]=o*P+d*F+f*L+v*D,i[9]=s*P+u*F+p*L+y*D,i[10]=l*P+h*F+m*L+x*D,i[11]=c*P+_*F+g*L+b*D,i[12]=o*B+d*I+f*V+v*O,i[13]=s*B+u*I+p*V+y*O,i[14]=l*B+h*I+m*V+x*O,i[15]=c*B+_*I+g*V+b*O},y.equals=function(e,t){var r=e.elements,n=t.elements;return cD.equals(r[0],n[0])&&cD.equals(r[1],n[1])&&cD.equals(r[2],n[2])&&cD.equals(r[3],n[3])&&cD.equals(r[4],n[4])&&cD.equals(r[5],n[5])&&cD.equals(r[6],n[6])&&cD.equals(r[7],n[7])&&cD.equals(r[8],n[8])&&cD.equals(r[9],n[9])&&cD.equals(r[10],n[10])&&cD.equals(r[11],n[11])&&cD.equals(r[12],n[12])&&cD.equals(r[13],n[13])&&cD.equals(r[14],n[14])&&cD.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r,o[9]=a[9]*s+i[9]*r,o[10]=a[10]*s+i[10]*r,o[11]=a[11]*s+i[11]*r,o[12]=a[12]*s+i[12]*r,o[13]=a[13]*s+i[13]*r,o[14]=a[14]*s+i[14]*r,o[15]=a[15]*s+i[15]*r},y.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8],i[9]=n[9]+a[9],i[10]=n[10]+a[10],i[11]=n[11]+a[11],i[12]=n[12]+a[12],i[13]=n[13]+a[13],i[14]=n[14]+a[14],i[15]=n[15]+a[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,a=r.elements;a[0]=n[0]*t,a[1]=n[1]*t,a[2]=n[2]*t,a[3]=n[3]*t,a[4]=n[4]*t,a[5]=n[5]*t,a[6]=n[6]*t,a[7]=n[7]*t,a[8]=n[8]*t,a[9]=n[9]*t,a[10]=n[10]*t,a[11]=n[11]*t,a[12]=n[12]*t,a[13]=n[13]*t,a[14]=n[14]*t,a[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,d=n*s,u=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=u+v,r[2]=_-g,r[3]=0,r[4]=u-v,r[5]=1-d-p,r[6]=f+m,r[7]=0,r[8]=_+g,r[9]=f-m,r[10]=1-d-h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.rotationAxisAngle=function(e,t,r){var n,a,i,o=r.elements,s=e._x,l=e._y,c=e._z,d=Math.sqrt(s*s+l*l+c*c);Math.abs(d)<cD.zeroTolerance||(s*=d=1/d,l*=d,c*=d,n=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*n,o[2]=c*s*i-l*n,o[3]=0,o[4]=s*l*i-c*n,o[5]=l*l*i+a,o[6]=c*l*i+s*n,o[7]=0,o[8]=s*c*i+l*n,o[9]=l*c*i-s*n,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},y.rotationTranslation=function(e,t,r){y.rotationQuaternion(e,r);var n=r.elements;n[12]=t._x,n[13]=t._y,n[14]=t._z},y.affineTransformation=function(e,t,r,n){var a=n.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,d=o+o,u=s+s,h=i*c,_=i*d,f=i*u,p=o*d,m=o*u,g=s*u,v=l*c,y=l*d,x=l*u,b=e._x,S=e._y,T=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*S,a[5]=(1-(h+g))*S,a[6]=(m+v)*S,a[7]=0,a[8]=(f+y)*T,a[9]=(m-v)*T,a[10]=(1-(h+p))*T,a[11]=0,a[12]=r._x,a[13]=r._y,a[14]=r._z,a[15]=1},y.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e._y,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e._z,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e._x,r[13]=e._y,r[14]=e._z,r[15]=1},y.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15],x=a*c-i*l,b=a*d-o*l,S=a*u-s*l,T=i*d-o*c,C=i*u-s*c,A=o*u-s*d,E=h*g-_*m,M=h*v-f*m,R=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+T*R-C*M+A*E;if(!L)return null;L=1/L,n[0]=(c*F-d*P+u*w)*L,n[1]=(o*P-i*F-s*w)*L,n[2]=(g*A-v*C+y*T)*L,n[3]=(f*C-_*A-p*T)*L,n[4]=(d*R-l*F-u*M)*L,n[5]=(a*F-o*R+s*M)*L,n[6]=(v*S-m*A-y*b)*L,n[7]=(h*A-f*S+p*b)*L,n[8]=(l*P-c*R+u*E)*L,n[9]=(i*R-a*P-s*E)*L,n[10]=(m*C-g*S+y*x)*L,n[11]=(_*S-h*C-p*x)*L,n[12]=(c*M-l*w-d*E)*L,n[13]=(a*w-i*M+o*E)*L,n[14]=(g*b-m*T-v*x)*L,n[15]=(h*T-_*b+f*x)*L},y.lookAt=function(e,t,r,n){var a=n.elements,i=y._tempVec30,o=y._tempVec31,s=y._tempVec32;cB.subtract(e,t,s),s.normalize(),cB.cross(r,s,i),i.normalize(),cB.cross(s,i,o),a[0]=i._x,a[1]=o._x,a[2]=s._x,a[3]=0,a[4]=i._y,a[5]=o._y,a[6]=s._y,a[7]=0,a[8]=i._z,a[9]=o._z,a[10]=s._z,a[11]=0,a[12]=-cB.dot(i,e),a[13]=-cB.dot(o,e),a[14]=-cB.dot(s,e),a[15]=1},y.ortho=function(e,t,r,n,a,i,o){var s=o.elements,l=1/(e-t),c=1/(r-n),d=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*d,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(i+a)*d,s[15]=1},y.perspective=function(e,t,r,n,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(r-n);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(n+r)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*n*r*s,i[15]=0},y.rotateAxisAngle=function(e,t,r,n){var a,i,o,s=t._x,l=t._y,c=t._z,d=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(d)<cD.zeroTolerance)){var u=e.elements,h=n.elements;s*=d=1/d,l*=d,c*=d,a=Math.sin(r),o=1-(i=Math.cos(r));var _=u[0],f=u[1],p=u[2],m=u[3],g=u[4],v=u[5],y=u[6],x=u[7],b=u[8],S=u[9],T=u[10],C=u[11],A=s*s*o+i,E=l*s*o+c*a,M=c*s*o-l*a,R=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;h[0]=_*A+g*E+b*M,h[1]=f*A+v*E+S*M,h[2]=p*A+y*E+T*M,h[3]=m*A+x*E+C*M,h[4]=_*R+g*w+b*P,h[5]=f*R+v*w+S*P,h[6]=p*R+y*w+T*P,h[7]=m*R+x*w+C*P,h[8]=_*F+g*L+b*D,h[9]=f*F+v*L+S*D,h[10]=p*F+y*L+T*D,h[11]=m*F+x*L+C*D,e!==n&&(h[12]=u[12],h[13]=u[13],h[14]=u[14],h[15]=u[15])}},y.scale=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;a[0]=n[0]*i,a[1]=n[1]*i,a[2]=n[2]*i,a[3]=n[3]*i,a[4]=n[4]*o,a[5]=n[5]*o,a[6]=n[6]*o,a[7]=n[7]*o,a[8]=n[8]*s,a[9]=n[9]*s,a[10]=n[10]*s,a[11]=n[11]*s,a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;if(e===r)a[12]=n[0]*i+n[4]*o+n[8]*s+n[12],a[13]=n[1]*i+n[5]*o+n[9]*s+n[13],a[14]=n[2]*i+n[6]*o+n[10]*s+n[14],a[15]=n[3]*i+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],d=n[2],u=n[3],h=n[4],_=n[5],f=n[6],p=n[7],m=n[8],g=n[9],v=n[10],y=n[11];a[0]=l,a[1]=c,a[2]=d,a[3]=u,a[4]=h,a[5]=_,a[6]=f,a[7]=p,a[8]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+n[12],a[13]=c*i+_*o+g*s+n[13],a[14]=d*i+f*o+v*s+n[14],a[15]=u*i+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[3],s=r[6],l=r[7],c=r[11];n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=a,n[6]=r[9],n[7]=r[13],n[8]=i,n[9]=s,n[11]=r[14],n[12]=o,n[13]=l,n[14]=c}else n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15]},y);cG._tempVec30=new cB,cG._tempVec31=new cB,cG._tempVec32=new cB,cG._tempMat30=new cz,cG._identity=new cG(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var cH=((S=(b=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new cB,this.direction=new cB,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return cO.intersectsRayAndPlane(this,e)},S.intersectSphere=function(e){return cO.intersectsRayAndSphere(this,e)},S.intersectBox=function(e){return cO.intersectsRayAndBox(this,e)},S.getPoint=function(e,t){return cB.scale(this.direction,e,t),t.add(this.origin)},b),cW=((C=(T=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}).prototype).set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},C.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},C.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},C.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},C.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},C.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},C.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},C.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},C.normalize=function(){return T.normalize(this,this),this},C.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},C.clone=function(){return new T(this._x,this._y)},C.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},C.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},C.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},C.toJSON=function(){return{x:this._x,y:this._y}},T.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._onValueChanged&&r._onValueChanged()},T.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._onValueChanged&&r._onValueChanged()},T.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._onValueChanged&&r._onValueChanged()},T.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._onValueChanged&&r._onValueChanged()},T.dot=function(e,t){return e._x*t._x+e._y*t._y},T.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y;return Math.sqrt(r*r+n*n)},T.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y;return r*r+n*n},T.equals=function(e,t){return cD.equals(e._x,t._x)&&cD.equals(e._y,t._y)},T.lerp=function(e,t,r,n){var a=e._x,i=e._y;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._onValueChanged&&n._onValueChanged()},T.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._onValueChanged&&r._onValueChanged()},T.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._onValueChanged&&r._onValueChanged()},T.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},T.normalize=function(e,t){var r=e._x,n=e._y,a=Math.sqrt(r*r+n*n);a>cD.zeroTolerance&&(a=1/a,t._x=r*a,t._y=n*a,t._onValueChanged&&t._onValueChanged())},T.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._onValueChanged&&r._onValueChanged()},n(T,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),T);cW._zero=new cW(0,0),cW._one=new cW(1,1);var cK=((E=(A=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},E.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},E.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},E.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},E.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},E.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},E.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},E.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},E.normalize=function(){return A.normalize(this,this),this},E.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new A(this._x,this._y,this._z,this._w)},E.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},E.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},E.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},E.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},A.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._w=e._w-t._w,r._onValueChanged&&r._onValueChanged()},A.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._w=e._w*t._w,r._onValueChanged&&r._onValueChanged()},A.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._w=e._w/t._w,r._onValueChanged&&r._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(r*r+n*n+a*a+i*i)},A.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return r*r+n*n+a*a+i*i},A.equals=function(e,t){return cD.equals(e._x,t._x)&&cD.equals(e._y,t._y)&&cD.equals(e._z,t._z)&&cD.equals(e._w,t._w)},A.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z,s=e._w;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},A.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._w=Math.max(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._w=Math.min(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cD.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},A.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},A.transform=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;r._x=n*s[0]+a*s[4]+i*s[8]+o*s[12],r._y=n*s[1]+a*s[5]+i*s[9]+o*s[13],r._z=n*s[2]+a*s[6]+i*s[10]+o*s[14],r._w=n*s[3]+a*s[7]+i*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},A.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,d=t._w,u=d*n+l*i-c*a,h=d*a+c*n-s*i,_=d*i+s*a-l*n,f=-s*n-l*a-c*i;r._x=u*d-f*s-h*c+_*l,r._y=h*d-f*l-_*s+u*c,r._z=_*d-f*c-u*l+h*s,r._w=o,r._onValueChanged&&r._onValueChanged()},n(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);cK._zero=new cK(0,0,0,0),cK._one=new cK(1,1,1,1);var cj=((R=(M=function(e,t,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=r,this._a=n}).prototype).set=function(e,t,r,n){return this._r=e,this._g=t,this._b=r,this._a=n,this._onValueChanged&&this._onValueChanged(),this},R.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this._onValueChanged&&this._onValueChanged(),this},R.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},R.clone=function(){return new M(this._r,this._g,this._b,this._a)},R.copyFrom=function(e){return this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._onValueChanged&&this._onValueChanged(),this},R.copyFromArray=function(e,t){return void 0===t&&(t=0),this._r=e[t],this._g=e[t+1],this._b=e[t+2],this._a=e[t+3],this._onValueChanged&&this._onValueChanged(),this},R.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._r,e[t+1]=this._g,e[t+2]=this._b,e[t+3]=this._a},R.toLinear=function(e){return e._r=M.gammaToLinearSpace(this._r),e._g=M.gammaToLinearSpace(this._g),e._b=M.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},R.toGamma=function(e){return e._r=M.linearToGammaSpace(this._r),e._g=M.linearToGammaSpace(this._g),e._b=M.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},R.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,a=e;return t>n&&(n=t),r>n&&(n=r),t<a&&(a=t),r<a&&(a=r),(n+a)/2},R.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},M.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},M.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},M.equals=function(e,t){return cD.equals(e._r,t._r)&&cD.equals(e._g,t._g)&&cD.equals(e._b,t._b)&&cD.equals(e._a,t._a)},M.add=function(e,t,r){return r._r=e._r+t._r,r._g=e._g+t._g,r._b=e._b+t._b,r._a=e._a+t._a,r._onValueChanged&&r._onValueChanged(),r},M.subtract=function(e,t,r){r._r=e._r-t._r,r._g=e._g-t._g,r._b=e._b-t._b,r._a=e._a-t._a,r._onValueChanged&&r._onValueChanged()},M.scale=function(e,t,r){return r._r=e._r*t,r._g=e._g*t,r._b=e._b*t,r._a=e._a*t,r._onValueChanged&&r._onValueChanged(),r},M.lerp=function(e,t,r,n){var a=e._r,i=e._g,o=e._b,s=e._a;return n._r=a+(t._r-a)*r,n._g=i+(t._g-i)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(M,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),M),cX=((P=(w=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=r,this._height=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._width=r,this._height=n,this._onValueChanged&&this._onValueChanged(),this},P.clone=function(){return new w(this.x,this.y,this.width,this.height)},P.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},n(w,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),w),cq=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,d=-.488603*i,u=.488603*o,h=-.488603*a,_=1.092548*(a*i),f=-1.092548*(i*o),p=.315392*(3*o*o-1),m=-1.092548*(a*o),g=.546274*(a*a-i*i);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*d,n[4]+=l*d,n[5]+=c*d,n[6]+=s*u,n[7]+=l*u,n[8]+=c*u,n[9]+=s*h,n[10]+=l*h,n[11]+=c*h,n[12]+=s*_,n[13]+=l*_,n[14]+=c*_,n[15]+=s*f,n[16]+=l*f,n[17]+=c*f,n[18]+=s*p,n[19]+=l*p,n[20]+=c*p,n[21]+=s*m,n[22]+=l*m,n[23]+=c*m,n[24]+=s*g,n[25]+=l*g,n[26]+=c*g},L.evaluate=function(e,t){var r=this.coefficients,n=e._x,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*n,c=.858086*a*n,d=-.858086*a*i,u=.247708*(3*i*i-1),h=-.858086*i*n,_=.429042*(n*n-a*a),f=.886227*r[0],p=.886227*r[1],m=.886227*r[2];return f+=r[3]*o+r[6]*s+r[9]*l,p+=r[4]*o+r[7]*s+r[10]*l,m+=r[5]*o+r[8]*s+r[11]*l,f+=r[12]*c+r[15]*d+r[18]*u+r[21]*h+r[24]*_,p+=r[13]*c+r[16]*d+r[19]*u+r[22]*h+r[25]*_,m+=r[14]*c+r[17]*d+r[20]*u+r[23]*h+r[26]*_,t.set(f,p,m,1),t},L.scale=function(e){var t=this.coefficients;t[0]*=e,t[1]*=e,t[2]*=e,t[3]*=e,t[4]*=e,t[5]*=e,t[6]*=e,t[7]*=e,t[8]*=e,t[9]*=e,t[10]*=e,t[11]*=e,t[12]*=e,t[13]*=e,t[14]*=e,t[15]*=e,t[16]*=e,t[17]*=e,t[18]*=e,t[19]*=e,t[20]*=e,t[21]*=e,t[22]*=e,t[23]*=e,t[24]*=e,t[25]*=e,t[26]*=e},L.clone=function(){var e=new F;return e.copyFrom(this),e},L.copyFrom=function(e){return e.copyToArray(this.coefficients),this},L.copyFromArray=function(e,t){void 0===t&&(t=0);var r=this.coefficients;r[0]=e[t],r[1]=e[1+t],r[2]=e[2+t],r[3]=e[3+t],r[4]=e[4+t],r[5]=e[5+t],r[6]=e[6+t],r[7]=e[7+t],r[8]=e[8+t],r[9]=e[9+t],r[10]=e[10+t],r[11]=e[11+t],r[12]=e[12+t],r[13]=e[13+t],r[14]=e[14+t],r[15]=e[15+t],r[16]=e[16+t],r[17]=e[17+t],r[18]=e[18+t],r[19]=e[19+t],r[20]=e[20+t],r[21]=e[21+t],r[22]=e[22+t],r[23]=e[23+t],r[24]=e[24+t],r[25]=e[25+t],r[26]=e[26+t]},L.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.coefficients;e[0+t]=r[0],e[1+t]=r[1],e[2+t]=r[2],e[3+t]=r[3],e[4+t]=r[4],e[5+t]=r[5],e[6+t]=r[6],e[7+t]=r[7],e[8+t]=r[8],e[9+t]=r[9],e[10+t]=r[10],e[11+t]=r[11],e[12+t]=r[12],e[13+t]=r[13],e[14+t]=r[14],e[15+t]=r[15],e[16+t]=r[16],e[17+t]=r[17],e[18+t]=r[18],e[19+t]=r[19],e[20+t]=r[20],e[21+t]=r[21],e[22+t]=r[22],e[23+t]=r[23],e[24+t]=r[24],e[25+t]=r[25],e[26+t]=r[26]},F),cY=((B=(D=function(e,t){this.reset(e,t)}).prototype).randomInt32=function(){var e=this._state0,t=this._state1;return this._state0=t,e^=e<<23,e^=e>>>17,e^=t^t>>>26,this._state1=e,this._state0+this._state1>>>0},B.random=function(){return this.randomInt32()/4294967295},B.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},D);function cQ(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cJ(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function cZ(e,t,r){return t&&cJ(e.prototype,t),r&&cJ(e,r),e}function c$(e,t){return(c$=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c0(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c$(e,t)}function c1(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function c2(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function c3(e,t){c9.registerCloneMode(e,t,lJ.Ignore)}function c4(e,t){c9.registerCloneMode(e,t,lJ.Assignment)}function c8(e,t){c9.registerCloneMode(e,t,lJ.Shallow)}function c5(e,t){c9.registerCloneMode(e,t,lJ.Deep)}e.Platform=void 0,(I=e.Platform||(e.Platform={}))[I.Android=0]="Android",I[I.IPhone=1]="IPhone",I[I.IPad=2]="IPad",I[I.Mac=3]="Mac",I[I.Unknown=4]="Unknown",e.SpriteMaskInteraction=void 0,(V=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[V.None=0]="None",V[V.VisibleInsideMask=1]="VisibleInsideMask",V[V.VisibleOutsideMask=2]="VisibleOutsideMask",e.SpriteMaskLayer=void 0,(O=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[O.Layer0=1]="Layer0",O[O.Layer1=2]="Layer1",O[O.Layer2=4]="Layer2",O[O.Layer3=8]="Layer3",O[O.Layer4=16]="Layer4",O[O.Layer5=32]="Layer5",O[O.Layer6=64]="Layer6",O[O.Layer7=128]="Layer7",O[O.Layer8=256]="Layer8",O[O.Layer9=512]="Layer9",O[O.Layer10=1024]="Layer10",O[O.Layer11=2048]="Layer11",O[O.Layer12=4096]="Layer12",O[O.Layer13=8192]="Layer13",O[O.Layer14=16384]="Layer14",O[O.Layer15=32768]="Layer15",O[O.Layer16=65536]="Layer16",O[O.Layer17=131072]="Layer17",O[O.Layer18=262144]="Layer18",O[O.Layer19=524288]="Layer19",O[O.Layer20=1048576]="Layer20",O[O.Layer21=2097152]="Layer21",O[O.Layer22=4194304]="Layer22",O[O.Layer23=8388608]="Layer23",O[O.Layer24=16777216]="Layer24",O[O.Layer25=33554432]="Layer25",O[O.Layer26=67108864]="Layer26",O[O.Layer27=134217728]="Layer27",O[O.Layer28=268435456]="Layer28",O[O.Layer29=536870912]="Layer29",O[O.Layer30=1073741824]="Layer30",O[O.Layer31=2147483648]="Layer31",O[O.Everything=4294967295]="Everything",e.TextHorizontalAlignment=void 0,(N=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[N.Left=0]="Left",N[N.Center=1]="Center",N[N.Right=2]="Right",e.TextVerticalAlignment=void 0,(k=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[k.Top=0]="Top",k[k.Center=1]="Center",k[k.Bottom=2]="Bottom",e.OverflowMode=void 0,(z=e.OverflowMode||(e.OverflowMode={}))[z.Overflow=0]="Overflow",z[z.Truncate=1]="Truncate",e.FontStyle=void 0,(U=e.FontStyle||(e.FontStyle={}))[U.None=0]="None",U[U.Bold=1]="Bold",U[U.Italic=2]="Italic","function"==typeof SuppressedError&&SuppressedError,(G=lJ||(lJ={}))[G.Ignore=0]="Ignore",G[G.Assignment=1]="Assignment",G[G.Shallow=2]="Shallow",G[G.Deep=3]="Deep";var c9=((H=function(){}).registerCloneMode=function(e,t,r){var n=H._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),H._subCloneModeMap.set(e.constructor,n)),n[t]=r},H.getCloneMode=function(e){var t=H._cloneModeMap.get(e);if(!t){t=Object.create(null),H._cloneModeMap.set(e,t);for(var r=H._objectType,n=H._subCloneModeMap;e!==r;){var a=n.get(e);a&&Object.assign(t,a),e=Object.getPrototypeOf(e)}}return t},H.cloneProperty=function(e,t,r,n,a,i,o){if(n!==lJ.Ignore){var s=e[r];if(c2(s,Object)){if(void 0===n||n===lJ.Assignment){t[r]=s;return}switch(s.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var l=t[r];null==l||l.length!==s.length?t[r]=s.slice():l.set(s);break;case Array:var c=t[r],d=s.length;null==c?t[r]=c=Array(d):c.length=d;for(var u=0;u<d;u++)H.cloneProperty(s,c,u,n,a,i,o);break;default:var h=t[r];if(h||((h=o.get(s))||(h=new s.constructor,o.set(s,h)),t[r]=h),s.copyFrom)h.copyFrom(s);else{var _=H.getCloneMode(s.constructor);for(var f in s)H.cloneProperty(s,h,f,_[f],a,i,o);s._cloneTo&&s._cloneTo(h,a,i)}}}else t[r]=s}},H.deepCloneObject=function(e,t,r){for(var n in e)H.cloneProperty(e,t,n,lJ.Deep,null,null,r)},H);c9._subCloneModeMap=new Map,c9._cloneModeMap=new Map,c9._objectType=Object.getPrototypeOf(Object);var c6=function(){function e(t){this.instanceId=++e._instanceIdCounter,this._destroyed=!1,this._engine=t}var t=e.prototype;return t.destroy=function(){this._destroyed||(this._onDestroy(),this._destroyed=!0)},t._onDestroy=function(){var e=this._engine.resourceManager;e._deleteAsset(this),e._deleteContentRestorer(this)},cZ(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();c6._instanceIdCounter=0,c1([c3],c6.prototype,"instanceId",void 0),c1([c3],c6.prototype,"_engine",void 0);var c7=(c0(W=function(e){var t;return(t=c6.call(this,e)||this).isGCIgnored=!1,t._refCount=0,t._superResources=null,e.resourceManager._addReferResource(cQ(t)),t},c6),(K=W.prototype).destroy=function(e,t){if(void 0===e&&(e=!1),!e){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!t)return!1;for(var n=0,a=r.length;n<a;n++)if(r[n].refCount>0)return!1}}return c6.prototype.destroy.call(this),!0},K._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},K._disassociationSuperResource=function(e){var t=this._superResources,r=t.indexOf(e);t.splice(r,1)},K._getReferCount=function(){return this._refCount},K._addReferCount=function(e){this._refCount+=e},K._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},K._onDestroy=function(){c6.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},cZ(W,[{key:"refCount",get:function(){return this._refCount}}]),W),de=(c0(j=function(e){var t;return(t=c7.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},c7),(X=j.prototype).getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},X.getSprites=function(e,t){t.length=0;var r=this._spriteNamesToIndex[e];if(void 0!==r)for(var n=this._sprites;r>=0;r--){var a=n[r];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},X._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},X._onDestroy=function(){c7.prototype._onDestroy.call(this);for(var e=this._sprites,t=0,r=e.length;t<r;t++)e[t].destroy();e.length=0,this._sprites=null,this._spriteNamesToIndex=null},cZ(j,[{key:"sprites",get:function(){return this._sprites}}]),j);e.SpriteDrawMode=void 0,(q=e.SpriteDrawMode||(e.SpriteDrawMode={}))[q.Simple=0]="Simple",q[q.Sliced=1]="Sliced",q[q.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(Y=e.SpriteTileMode||(e.SpriteTileMode={}))[Y.Continuous=0]="Continuous",Y[Y.Adaptive=1]="Adaptive";var dt=((Q=function(){}).removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var a=e[n];e[r]=a}return e.length--,!0},Q.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",r=0,n=e.length;r<n;r++)t+=String.fromCharCode(e[r]);return decodeURIComponent(encodeURIComponent(t))},Q.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Q.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},Q.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},Q.resolveAbsoluteUrl=function(e,t){return Q.isAbsoluteUrl(t)||Q.isBase64Url(t)?t:t?new URL(t,e).href:e},Q._floatMatrixMultiply=function(e,t,r,n,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],d=i[4],u=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],S=t[r],T=t[r+1],C=t[r+2],A=t[r+3],E=t[r+4],M=t[r+5],R=t[r+6],w=t[r+7],P=t[r+8],F=t[r+9],L=t[r+10],D=t[r+11],B=t[r+12],I=t[r+13],V=t[r+14],O=t[r+15];n[a]=o*S+d*T+f*C+v*A,n[a+1]=s*S+u*T+p*C+y*A,n[a+2]=l*S+h*T+m*C+x*A,n[a+3]=c*S+_*T+g*C+b*A,n[a+4]=o*E+d*M+f*R+v*w,n[a+5]=s*E+u*M+p*R+y*w,n[a+6]=l*E+h*M+m*R+x*w,n[a+7]=c*E+_*M+g*R+b*w,n[a+8]=o*P+d*F+f*L+v*D,n[a+9]=s*P+u*F+p*L+y*D,n[a+10]=l*P+h*F+m*L+x*D,n[a+11]=c*P+_*F+g*L+b*D,n[a+12]=o*B+d*I+f*V+v*O,n[a+13]=s*B+u*I+p*V+y*O,n[a+14]=l*B+h*I+m*V+x*O,n[a+15]=c*B+_*I+g*V+b*O},Q._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,a=0,i=r.length;null!=n&&a<i;)n=n[r[a++]];return a&&a==i?n:void 0},Q._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var a=t+r>>1,i=e[t],o=e[r-1],s=e[a];if(n(i,o)>0){var l=i;i=o,o=l}if(n(i,s)>=0){var c=i;i=s,s=o,o=c}else if(n(o,s)>0){var d=o;o=s,s=d}e[t]=i,e[r-1]=s;var u=o,h=t+1,_=r-1;e[a]=e[h],e[h]=u;e:for(var f=h+1;f<_;f++){var p=e[f],m=n(p,u);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=n(e[_],u)}while(m>0);e[f]=e[_],e[_]=p,m<0&&(p=e[f],e[f]=e[h],e[h]=p,h++)}}r-_<h-t?(this._quickSort(e,_,r,n),r=h):(this._quickSort(e,t,h,n),t=_)}},Q._stringToPath=function(e){var t=[];return e.charCodeAt(0)===dr&&t.push(""),e.replace(da,function(e,r,n,a){var i=e;n?i=a.replace(dn,"$1"):r&&(i=r.trim()),t.push(i)}),t},Q._insertionSort=function(e,t,r,n){for(var a=t+1;a<r;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(n(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},Q),dr=46,dn=/\\(\\)?/g,da=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),di=((Z=(J=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},Z.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},Z.removeFlag=function(e){dt.removeFromArray(this._updateFlags,e)&&dt.removeFromArray(e._flagManagers,this)},Z.addListener=function(e){this._listeners.push(e)},Z.removeListener=function(e){dt.removeFromArray(this._listeners,e)},Z.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},J);($=lZ||(lZ={}))[$.texture=1]="texture",$[$.size=2]="size",$[$.atlasRotate=4]="atlasRotate",$[$.atlasRegion=8]="atlasRegion",$[$.atlasRegionOffset=16]="atlasRegionOffset",$[$.region=32]="region",$[$.pivot=64]="pivot",$[$.border=128]="border",$[$.destroy=256]="destroy";var ds=(c0(ee=function(e,t,r,n,a,i){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===a&&(a=null),void 0===i&&(i=null),(o=c7.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new cW,new cW,new cW,new cW],o._uvs=[new cW,new cW,new cW,new cW],o._bounds=new cV,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new cX(0,0,1,1),o._atlasRegionOffset=new cK(0,0,0,0),o._region=new cX(0,0,1,1),o._pivot=new cW(.5,.5),o._border=new cK(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new di,o._texture=t,o._onRegionChange=o._onRegionChange.bind(cQ(o)),o._onPivotChange=o._onPivotChange.bind(cQ(o)),o._onBorderChange=o._onBorderChange.bind(cQ(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,r&&o._region.copyFrom(r),n&&o._pivot.copyFrom(n),a&&o._border.copyFrom(a),o.name=i,o},c7),(et=ee.prototype).clone=function(){var e=new ee(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},et._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},et._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},et._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},et._addReferCount=function(e){var t;c7.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},et._onDestroy=function(){this._dispatchSpriteChange(lZ.destroy),c7.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},et._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,a=1/hS._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*a,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},et._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,a=t.width,i=t.height,o=Math.max(e.x-r,0)/a,s=Math.max(e.w-n,0)/i,l=1-Math.max(e.z-(1-r-a),0)/a,c=1-Math.max(e.y-(1-n-i),0)/i,d=this._positions;d[0].set(o,s),d[1].set(l,s),d[2].set(o,c),d[3].set(l,c);var u=this._bounds,h=u.min,_=u.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},et._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,a=r.y,i=r.width,o=r.height,s=1-n-i,l=1-a-o,c=this._atlasRegion,d=c.x,u=c.y,h=c.width,_=c.height,f=t.x,p=t.y,m=t.z,g=t.w,v=h/(1-f-m),y=_/(1-p-g),x=Math.max(n-f,0)*v+d,b=Math.max(l-p,0)*y+u,S=h+d-Math.max(s-m,0)*v,T=_+u-Math.max(a-g,0)*y,C=this._border,A=C.x,E=C.y,M=C.z,R=C.w;e[0].set(x,T),e[1].set((n-f+A*i)*v+d,_+u-(a-g+E*o)*y),e[2].set(h+d-(s-m+M*i)*v,(l-p+R*o)*y+u),e[3].set(S,b),this._dirtyUpdateFlag&=-3},et._dispatchSpriteChange=function(e){switch(e){case lZ.texture:this._dirtyUpdateFlag|=4;break;case lZ.atlasRegionOffset:case lZ.region:this._dirtyUpdateFlag|=7;break;case lZ.atlasRegion:this._dirtyUpdateFlag|=6;break;case lZ.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},et._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=cD.clamp(e.x,0,1),r=cD.clamp(e.y,0,1);e.set(t,r,cD.clamp(e.width,0,1-t),cD.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lZ.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lZ.size),e._onValueChanged=this._onRegionChange},et._onPivotChange=function(){this._dispatchSpriteChange(lZ.pivot)},et._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=cD.clamp(e.x,0,1),r=cD.clamp(e.y,0,1);e.set(t,r,cD.clamp(e.z,0,1-t),cD.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lZ.border),e._onValueChanged=this._onBorderChange},cZ(ee,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(lZ.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lZ.size))}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(lZ.size))}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(lZ.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var t=cD.clamp(e.x,0,1),r=cD.clamp(e.y,0,1);this._atlasRegion.set(t,r,cD.clamp(e.width,0,1-t),cD.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lZ.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lZ.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=cD.clamp(e.x,0,1),r=cD.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,cD.clamp(e.z,0,1-t),cD.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lZ.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lZ.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),ee);(er=l$||(l$={}))[er.positions=1]="positions",er[er.uvs=2]="uvs",er[er.automaticSize=4]="automaticSize",er[er.all=7]="all";var dl=((ea=(en=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},ea.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ea.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ea.dispatch=function(e,t){if(!this._events[e])return!1;var r=this._events[e];if(Array.isArray(r)){var n=r.length,a=en._dispatchingListenersPool,i=a.length>0?a.pop():[];i.length=n;for(var o=0;o<n;o++)i[o]=r[o];for(var s=0;s<n;s++){var l=i[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}i.length=0,a.push(i)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},ea.on=function(e,t){return this._addEventListener(e,t)},ea.once=function(e,t){return this._addEventListener(e,t,!0)},ea.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var r=this._events[e],n=Array.isArray(r);if(n||r.fn!==t){if(n){for(var a=r.length-1;a>=0;a--)r[a].fn===t&&(r[a].destroyed=!0,r.splice(a,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},ea.removeEventListener=function(e,t){return this.off(e,t)},ea.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ea._addEventListener=function(e,t,r){var n={fn:t,once:r},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(n):a[e]=[i,n]:(a[e]=n,this._eventCount++),this},ea._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},en);dl._dispatchingListenersPool=[];var dc=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},dd=console.log.bind(console),du=console.info.bind(console),dh=console.warn.bind(console),d_=console.error.bind(console),df={debug:dc,info:dc,warn:dc,error:dc,isEnabled:!1,enable:function(){this.debug=dd,this.info=du,this.warn=dh,this.error=d_,this.isEnabled=!0},disable:function(){this.debug=dc,this.info=dc,this.warn=dc,this.error=dc,this.isEnabled=!1}},dp=function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return e.getByName=function(t){var r=e._propertyNameMap;if(null!=r[t])return r[t];var n=new e(t);return r[t]=n,e._propertyIdMap[n._uniqueId]=n,n},e._getShaderPropertyGroup=function(t){var r=e._propertyNameMap[t];return null==r?void 0:r._group},cZ(e,[{key:"type",get:function(){return this._type}}]),e}();dp._propertyIdMap=Object.create(null),dp._propertyNameCounter=0,dp._propertyNameMap=Object.create(null);var dm=((eo=(ei=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new cK,this._deltaTimeValue=new cK,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},eo._update=function(){var e=performance.now()/1e3,t=e-this._lastSystemTime;this._actualDeltaTime=t,this._actualElapsedTime+=t;var r=Math.min(t,this.maximumDeltaTime)*this.timeScale;this._deltaTime=r,this._elapsedTime+=r,this._frameCount++,this._lastSystemTime=e},eo._updateSceneShaderData=function(e){var t=this._elapsedTimeValue,r=this._deltaTimeValue,n=this._elapsedTime;t.set(n,Math.sin(n),Math.cos(n),0),e.setVector4(ei._elapsedTimeProperty,t),r.set(this._deltaTime,0,0,0),e.setVector4(ei._deltaTimeProperty,r)},cZ(ei,[{key:"frameCount",get:function(){return this._frameCount}},{key:"deltaTime",get:function(){return this._deltaTime}},{key:"elapsedTime",get:function(){return this._elapsedTime}},{key:"actualDeltaTime",get:function(){return this._actualDeltaTime}},{key:"actualElapsedTime",get:function(){return this._actualElapsedTime}}]),ei);dm._elapsedTimeProperty=dp.getByName("scene_ElapsedTime"),dm._deltaTimeProperty=dp.getByName("scene_DeltaTime"),e.DataType=void 0,(es=e.DataType||(e.DataType={}))[es.FLOAT=5126]="FLOAT",es[es.FLOAT_VEC2=35664]="FLOAT_VEC2",es[es.FLOAT_VEC3=35665]="FLOAT_VEC3",es[es.FLOAT_VEC4=35666]="FLOAT_VEC4",es[es.INT=5124]="INT",es[es.INT_VEC2=35667]="INT_VEC2",es[es.INT_VEC3=35668]="INT_VEC3",es[es.INT_VEC4=35669]="INT_VEC4",es[es.BOOL=35670]="BOOL",es[es.BOOL_VEC2=35671]="BOOL_VEC2",es[es.BOOL_VEC3=35672]="BOOL_VEC3",es[es.BOOL_VEC4=35673]="BOOL_VEC4",es[es.FLOAT_MAT2=35674]="FLOAT_MAT2",es[es.FLOAT_MAT3=35675]="FLOAT_MAT3",es[es.FLOAT_MAT4=35676]="FLOAT_MAT4",es[es.FLOAT_ARRAY=35677]="FLOAT_ARRAY",es[es.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",es[es.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",es[es.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",es[es.INT_ARRAY=100003]="INT_ARRAY",es[es.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",es[es.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",es[es.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",es[es.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",es[es.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",es[es.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",es[es.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",es[es.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",es[es.SAMPLER_2D=35678]="SAMPLER_2D",es[es.SAMPLER_CUBE=35680]="SAMPLER_CUBE",es[es.BYTE=5120]="BYTE",es[es.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",es[es.SHORT=5122]="SHORT",es[es.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",es[es.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(el=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",el.standardDerivatives="OES_standard_derivatives",el.shaderTextureLod="EXT_shader_texture_lod",el.elementIndexUint="OES_element_index_uint",el.depthTexture="WEBGL_depth_texture",el.drawBuffers="WEBGL_draw_buffers",el.vertexArrayObject="OES_vertex_array_object",el.instancedArrays="ANGLE_instanced_arrays",el.multipleSample="multipleSampleOnlySupportedInWebGL2",el.textureFloat="OES_texture_float",el.textureFloatLinear="OES_texture_float_linear",el.textureHalfFloat="OES_texture_half_float",el.textureHalfFloatLinear="OES_texture_half_float_linear",el.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",el.colorBufferFloat="EXT_color_buffer_float",el.colorBufferHalfFloat="EXT_color_buffer_half_float",el.textureFilterAnisotropic="EXT_texture_filter_anisotropic",el.blendMinMax="EXT_blend_minmax",el.fragDepth="EXT_frag_depth",el.astc="WEBGL_compressed_texture_astc",el.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",el.etc="WEBGL_compressed_texture_etc",el.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",el.etc1="WEBGL_compressed_texture_etc1",el.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",el.pvrtc="WEBGL_compressed_texture_pvrtc",el.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",el.s3tc="WEBGL_compressed_texture_s3tc",el.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",el.bptc="EXT_texture_compression_bptc",el.WEBGL_lose_context="WEBGL_lose_context",(ec=l0||(l0={}))[ec.None=0]="None",ec[ec.Scene=1]="Scene",ec[ec.Hierarchy=2]="Hierarchy",ec[ec.All=3]="All";var dg=(c0(ed=function(e){var t;return(t=c6.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},c6),(eu=ed.prototype)._onAwake=function(){},eu._onEnable=function(){},eu._onDisable=function(){},eu._onEnableInScene=function(){},eu._onDisableInScene=function(){},eu._setActive=function(e,t){var r=this._entity;t&l0.Scene&&(e?!this._phasedActiveInScene&&r._isActiveInScene&&this._enabled&&(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&!(r._isActiveInScene&&this._enabled)&&(this._phasedActiveInScene=!1,this._onDisableInScene())),t&l0.Hierarchy&&(e?(!this._awoken&&r._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&r._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(r._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},eu._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},eu._onDestroy=function(){c6.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},cZ(ed,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?this._phasedActiveInScene||(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?this._phasedActive||(this._phasedActive=!0,this._onEnable()):this._phasedActive&&(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),ed);c1([c3],dg.prototype,"_entity",void 0),c1([c3],dg.prototype,"_awoken",void 0),c1([c3],dg.prototype,"_phasedActiveInScene",void 0),c1([c3],dg.prototype,"_phasedActive",void 0),c1([c4],dg.prototype,"_enabled",void 0);var dv=((eh=function(){})._addCheck=function(e,t){for(;t!==dg;){var r=eh._dependenciesMap.get(t);if(r)for(var n=r.components,a=r.mode,i=0,o=n.length;i<o;i++){var s=n[i];if(!e.getComponent(s)){if(1===a)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},eh._removeCheck=function(e,t){for(;t!==dg;){var r=eh._invDependenciesMap.get(t);if(r){for(var n=0,a=r.length;n<a;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eh._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eh._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eh);function dy(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){dv._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return dv._addInvDependency(t,e)})}}dv._invDependenciesMap=new Map,dv._dependenciesMap=new Map,e.DependentMode=void 0,(e_=e.DependentMode||(e.DependentMode={}))[e_.CheckOnly=0]="CheckOnly",e_[e_.AutoAdd=1]="AutoAdd";var dx=((ep=(ef=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},ep.destroy=function(){this._removeFromManagers(),this._flagManagers=null},ep._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)dt.removeFromArray(e[t]._updateFlags,this)},c0(em=function(){var e;return e=ef.apply(this,arguments)||this,e.flag=!0,e},ef),em.prototype.dispatch=function(){this.flag=!0},em),db=(c0(eg=function(e){var t;return(t=dg.call(this,e)||this)._position=new cB,t._rotation=new cB,t._rotationQuaternion=new cU,t._scale=new cB(1,1,1),t._worldPosition=new cB,t._worldRotation=new cB,t._worldRotationQuaternion=new cU,t._lossyWorldScale=new cB(1,1,1),t._localMatrix=new cG,t._worldMatrix=new cG,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new di,t._onPositionChanged=t._onPositionChanged.bind(cQ(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(cQ(t)),t._onRotationChanged=t._onRotationChanged.bind(cQ(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(cQ(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(cQ(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(cQ(t)),t._onScaleChanged=t._onScaleChanged.bind(cQ(t)),t._position._onValueChanged=t._onPositionChanged,t._worldPosition._onValueChanged=t._onWorldPositionChanged,t._rotation._onValueChanged=t._onRotationChanged,t._worldRotation._onValueChanged=t._onWorldRotationChanged,t._rotationQuaternion._onValueChanged=t._onRotationQuaternionChanged,t._worldRotationQuaternion._onValueChanged=t._onWorldRotationQuaternionChanged,t._scale._onValueChanged=t._onScaleChanged,t},dg),(ev=eg.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},ev.setRotation=function(e,t,r){this._rotation.set(e,t,r)},ev.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},ev.setScale=function(e,t,r){this._scale.set(e,t,r)},ev.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},ev.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},ev.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},ev.translate=function(e,t,r,n){if("number"==typeof e){var a=eg._tempVec30;a.set(e,t,r),this._translate(a,n)}else this._translate(e,t)},ev.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},ev.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*cD.degreeToRadFactor;cU.rotationAxisAngle(e,n,eg._tempQuat0),this._rotateByQuat(eg._tempQuat0,r)},ev.lookAt=function(e,t){var r=eg._tempVec30;cB.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=cD.zeroTolerance)){r.scale(1/n);var a=eg._tempVec31;if(t?cB.cross(t,r,a):a.set(r.z,0,-r.x),!((n=a.length())<=cD.zeroTolerance)){a.scale(1/n);var i=eg._tempVec32;cB.cross(r,a,i);var o=eg._tempMat41,s=o.elements;s[0]=a.x,s[1]=a.y,s[2]=a.z,s[4]=i.x,s[5]=i.y,s[6]=i.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},ev.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(dx)},ev._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},ev._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},ev._onDestroy=function(){dg.prototype._onDestroy.call(this),this._worldPosition._onValueChanged=null,this._rotation._onValueChanged=null,this._worldRotation._onValueChanged=null,this._rotationQuaternion._onValueChanged=null,this._worldRotationQuaternion._onValueChanged=null,this._position._onValueChanged=null,this._scale._onValueChanged=null},ev._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)){this._worldAssociatedChange(132);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionFlag()}},ev._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)){this._worldAssociatedChange(152);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndRotationFlag()}},ev._updateWorldPositionAndRotationFlag=function(){if(!this._isContainDirtyFlags(156)){this._worldAssociatedChange(156);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndRotationFlag()}},ev._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)){this._worldAssociatedChange(160);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndScaleFlag()}},ev._updateWorldPositionAndScaleFlag=function(){if(!this._isContainDirtyFlags(164)){this._worldAssociatedChange(164);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndScaleFlag()}},ev._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)){this._worldAssociatedChange(188);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateAllWorldFlag()}},ev._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;for(var e=null,t=this._entity.parent;t;){var r=t.transform;if(r){e=r;break}t=t.parent}return this._parentTransformCache=e,this._isParentDirty=!1,e},ev._getScaleMatrix=function(){var e=eg._tempQuat0,t=eg._tempMat30,r=eg._tempMat31,n=eg._tempMat32;return r.copyFromMatrix(this.worldMatrix),cU.invert(this.worldRotationQuaternion,e),cz.rotationQuaternion(e,t),cz.multiply(t,r,n),n},ev._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},ev._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ev._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ev._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ev._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},ev._rotateByQuat=function(e,t){t?cU.multiply(this.rotationQuaternion,e,this._rotationQuaternion):cU.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},ev._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=eg._tempVec30;cB.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},ev._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var a=cD.degreeToRadFactor,i=eg._tempQuat0;cU.rotationEuler(e*a,t*a,r*a,i),this._rotateByQuat(i,n)},ev._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},ev._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(cG.invert(t.worldMatrix,eg._tempMat41),cB.transformCoordinate(e,eg._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},ev._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},ev._onWorldRotationChanged=function(){var e=this._worldRotation;cU.rotationEuler(cD.degreeToRadian(e.x),cD.degreeToRadian(e.y),cD.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},ev._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},ev._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=eg._tempQuat0;cU.invert(t.worldRotationQuaternion,r),cU.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},ev._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},cZ(eg,[{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"worldPosition",get:function(){var e=this._worldPosition;return this._isContainDirtyFlag(4)&&(e._onValueChanged=null,this._getParentTransform()?this.worldMatrix.getTranslation(e):e.copyFrom(this._position),e._onValueChanged=this._onWorldPositionChanged,this._setDirtyFlagFalse(4)),e},set:function(e){this._worldPosition!==e&&this._worldPosition.copyFrom(e)}},{key:"rotation",get:function(){var e=this._rotation;return this._isContainDirtyFlag(1)&&(e._onValueChanged=null,this._rotationQuaternion.toEuler(e),e.scale(cD.radToDegreeFactor),e._onValueChanged=this._onRotationChanged,this._setDirtyFlagFalse(1)),e},set:function(e){this._rotation!==e&&this._rotation.copyFrom(e)}},{key:"worldRotation",get:function(){var e=this._worldRotation;return this._isContainDirtyFlag(8)&&(e._onValueChanged=null,this.worldRotationQuaternion.toEuler(e),e.scale(cD.radToDegreeFactor),e._onValueChanged=this._onWorldRotationChanged,this._setDirtyFlagFalse(8)),e},set:function(e){this._worldRotation!==e&&this._worldRotation.copyFrom(e)}},{key:"rotationQuaternion",get:function(){var e=this._rotationQuaternion;return this._isContainDirtyFlag(2)&&(e._onValueChanged=null,cU.rotationEuler(cD.degreeToRadian(this._rotation.x),cD.degreeToRadian(this._rotation.y),cD.degreeToRadian(this._rotation.z),e),e._onValueChanged=this._onRotationQuaternionChanged,this._setDirtyFlagFalse(2)),e},set:function(e){this._rotationQuaternion!==e?e.normalized?this._rotationQuaternion.copyFrom(e):cU.normalize(e,this._rotationQuaternion):e.normalized||e.normalize()}},{key:"worldRotationQuaternion",get:function(){var e=this._worldRotationQuaternion;if(this._isContainDirtyFlag(16)){e._onValueChanged=null;var t=this._getParentTransform();null!=t?cU.multiply(t.worldRotationQuaternion,this.rotationQuaternion,e):e.copyFrom(this.rotationQuaternion),e._onValueChanged=this._onWorldRotationQuaternionChanged,this._setDirtyFlagFalse(16)}return e},set:function(e){this._worldRotationQuaternion!==e&&(e.normalized?this._worldRotationQuaternion.copyFrom(e):cU.normalize(e,this._worldRotationQuaternion)),e.normalized||e.normalize()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale!==e&&this._scale.copyFrom(e)}},{key:"lossyWorldScale",get:function(){if(this._isContainDirtyFlag(32)){if(this._getParentTransform()){var e=this._getScaleMatrix().elements;this._lossyWorldScale.set(e[0],e[4],e[8])}else this._lossyWorldScale.copyFrom(this._scale);this._setDirtyFlagFalse(32)}return this._lossyWorldScale}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(cG.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(e){this._localMatrix!==e&&this._localMatrix.copyFrom(e),this._position._onValueChanged=this._rotationQuaternion._onValueChanged=this._scale._onValueChanged=null,this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._position._onValueChanged=this._onPositionChanged,this._rotationQuaternion._onValueChanged=this._onRotationQuaternionChanged,this._scale._onValueChanged=this._onScaleChanged,this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(66),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var e=this._getParentTransform();e?cG.multiply(e.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var t=this._getParentTransform();t?(cG.invert(t.worldMatrix,eg._tempMat42),cG.multiply(eg._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new cB),t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()}},{key:"worldRight",get:function(){var e=this._worldRight||(this._worldRight=new cB),t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()}},{key:"worldUp",get:function(){var e=this._worldUp||(this._worldUp=new cB),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eg);db._tempQuat0=new cU,db._tempVec30=new cB,db._tempVec31=new cB,db._tempVec32=new cB,db._tempMat30=new cz,db._tempMat31=new cz,db._tempMat32=new cz,db._tempMat41=new cG,db._tempMat42=new cG,c1([c5],db.prototype,"_position",void 0),c1([c5],db.prototype,"_rotation",void 0),c1([c5],db.prototype,"_rotationQuaternion",void 0),c1([c5],db.prototype,"_scale",void 0),c1([c5],db.prototype,"_worldPosition",void 0),c1([c5],db.prototype,"_worldRotation",void 0),c1([c5],db.prototype,"_worldRotationQuaternion",void 0),c1([c5],db.prototype,"_lossyWorldScale",void 0),c1([c5],db.prototype,"_localMatrix",void 0),c1([c5],db.prototype,"_worldMatrix",void 0),c1([c3],db.prototype,"_worldForward",void 0),c1([c3],db.prototype,"_worldRight",void 0),c1([c3],db.prototype,"_worldUp",void 0),c1([c3],db.prototype,"_isParentDirty",void 0),c1([c3],db.prototype,"_parentTransformCache",void 0),c1([c3],db.prototype,"_updateFlagManager",void 0),c1([c3],db.prototype,"_onPositionChanged",null),c1([c3],db.prototype,"_onWorldPositionChanged",null),c1([c3],db.prototype,"_onRotationChanged",null),c1([c3],db.prototype,"_onWorldRotationChanged",null),c1([c3],db.prototype,"_onRotationQuaternionChanged",null),c1([c3],db.prototype,"_onWorldRotationQuaternionChanged",null),c1([c3],db.prototype,"_onScaleChanged",null),(ey=l1||(l1={}))[ey.LocalEuler=1]="LocalEuler",ey[ey.LocalQuat=2]="LocalQuat",ey[ey.WorldPosition=4]="WorldPosition",ey[ey.WorldEuler=8]="WorldEuler",ey[ey.WorldQuat=16]="WorldQuat",ey[ey.WorldScale=32]="WorldScale",ey[ey.LocalMatrix=64]="LocalMatrix",ey[ey.WorldMatrix=128]="WorldMatrix",ey[ey.WmWp=132]="WmWp",ey[ey.WmWeWq=152]="WmWeWq",ey[ey.WmWpWeWq=156]="WmWpWeWq",ey[ey.WmWs=160]="WmWs",ey[ey.WmWpWs=164]="WmWpWs",ey[ey.WmWpWeWqWs=188]="WmWpWeWqWs",e.BlendFactor=void 0,(ex=e.BlendFactor||(e.BlendFactor={}))[ex.Zero=0]="Zero",ex[ex.One=1]="One",ex[ex.SourceColor=2]="SourceColor",ex[ex.OneMinusSourceColor=3]="OneMinusSourceColor",ex[ex.DestinationColor=4]="DestinationColor",ex[ex.OneMinusDestinationColor=5]="OneMinusDestinationColor",ex[ex.SourceAlpha=6]="SourceAlpha",ex[ex.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",ex[ex.DestinationAlpha=8]="DestinationAlpha",ex[ex.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",ex[ex.SourceAlphaSaturate=10]="SourceAlphaSaturate",ex[ex.BlendColor=11]="BlendColor",ex[ex.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eb=e.BlendOperation||(e.BlendOperation={}))[eb.Add=0]="Add",eb[eb.Subtract=1]="Subtract",eb[eb.ReverseSubtract=2]="ReverseSubtract",eb[eb.Min=3]="Min",eb[eb.Max=4]="Max",e.ColorWriteMask=void 0,(eS=e.ColorWriteMask||(e.ColorWriteMask={}))[eS.None=0]="None",eS[eS.Red=1]="Red",eS[eS.Green=2]="Green",eS[eS.Blue=4]="Blue",eS[eS.Alpha=8]="Alpha",eS[eS.All=15]="All",e.CompareFunction=void 0,(eT=e.CompareFunction||(e.CompareFunction={}))[eT.Never=0]="Never",eT[eT.Less=1]="Less",eT[eT.Equal=2]="Equal",eT[eT.LessEqual=3]="LessEqual",eT[eT.Greater=4]="Greater",eT[eT.NotEqual=5]="NotEqual",eT[eT.GreaterEqual=6]="GreaterEqual",eT[eT.Always=7]="Always",e.CullMode=void 0,(eC=e.CullMode||(e.CullMode={}))[eC.Off=0]="Off",eC[eC.Front=1]="Front",eC[eC.Back=2]="Back",e.RenderStateDataKey=void 0,(eA=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eA.BlendStateEnabled0=0]="BlendStateEnabled0",eA[eA.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eA[eA.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eA[eA.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eA[eA.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eA[eA.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eA[eA.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eA[eA.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eA[eA.BlendStateBlendColor=8]="BlendStateBlendColor",eA[eA.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eA[eA.DepthStateEnabled=10]="DepthStateEnabled",eA[eA.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eA[eA.DepthStateCompareFunction=12]="DepthStateCompareFunction",eA[eA.StencilStateEnabled=13]="StencilStateEnabled",eA[eA.StencilStateReferenceValue=14]="StencilStateReferenceValue",eA[eA.StencilStateMask=15]="StencilStateMask",eA[eA.StencilStateWriteMask=16]="StencilStateWriteMask",eA[eA.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eA[eA.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eA[eA.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eA[eA.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eA[eA.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eA[eA.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eA[eA.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eA[eA.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eA[eA.RasterStateCullMode=25]="RasterStateCullMode",eA[eA.RasterStateDepthBias=26]="RasterStateDepthBias",eA[eA.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",eA[eA.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(eE=e.RenderQueueType||(e.RenderQueueType={}))[eE.Opaque=0]="Opaque",eE[eE.AlphaTest=1]="AlphaTest",eE[eE.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eM=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eM.Float=0]="Float",eM[eM.Int=1]="Int",eM[eM.Vector2=2]="Vector2",eM[eM.Vector3=3]="Vector3",eM[eM.Vector4=4]="Vector4",eM[eM.Matrix=5]="Matrix",eM[eM.Color=6]="Color",eM[eM.Texture=7]="Texture",eM[eM.FloatArray=8]="FloatArray",eM[eM.IntArray=9]="IntArray",eM[eM.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eR=e.StencilOperation||(e.StencilOperation={}))[eR.Keep=0]="Keep",eR[eR.Zero=1]="Zero",eR[eR.Replace=2]="Replace",eR[eR.IncrementSaturate=3]="IncrementSaturate",eR[eR.DecrementSaturate=4]="DecrementSaturate",eR[eR.Invert=5]="Invert",eR[eR.IncrementWrap=6]="IncrementWrap",eR[eR.DecrementWrap=7]="DecrementWrap";var dS=function(){function e(t,r,n,a){this.name=t,this._maskIndex=n,this._maskValue=a,this.value=r;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,a=e._macroMap[n];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,r,s,1<<l),e._macroMap[n]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=n,e._macroCounter++}return a},e._getNamesByMacros=function(t,r){var n=e._macroMaskMap,a=t._mask;r.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=n[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,d=0;d<c;d++)l&1<<d&&r.push(s[d])},e}();dS._macroMaskMap=[],dS._macroNameIdMap=Object.create(null),dS._macroNameCounter=0,dS._macroCounter=0,dS._macroMap=Object.create(null);var dT=((eP=(ew=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,a=this._length;if(a<r){for(n.length<r&&(n.length=r);a<t;a++)n[a]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},eP.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var a=r[t]&~e._maskValue;t==n&&0===a?this._length--:r[t]=a}},eP.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,a=this._length;if(a<r){n.length<r&&(n.length=r);for(var i=0;i<a;i++)n[i]|=t[i];for(;i<r;i++)n[i]=t[i];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},eP.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,a=Math.min(e._length-1,n);a>=0;a--){var i=r[a]&~t[a];a==n&&0===i?(n--,this._length--):r[a]=i}},eP.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var a=r[n]&t[n];0==a&&n==this._length-1?this._length--:r[n]=a}},eP.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},eP.clear=function(){this._length=0},ew.unionCollection=function(e,t,r){var n,a,i,o,s=r._mask;e._length<t._length?(n=e._length,a=t._length,i=e._mask,o=t._mask):(n=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<n;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];r._length=a},ew);function dC(){return(dC=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}e.PipelineStage=void 0,(eF=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",eF.ShadowCaster="ShadowCaster",eF.Forward="Forward";var dA=dC({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge)evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=colorKeys[0].y;}else{vec2 lastKey=alphaKeys[i-1];float lastTime=lastKey.x;float age=(alphaAge-lastTime)/(time-lastTime);value.a=mix(lastKey.y,key.y,age);}break;}}float colorAge=min(normalizedAge,colorKeysMaxTime);for(int i=0;i<4;i++){vec4 key=colorKeys[i];float time=key.x;if(colorAge<=time){if(i==0){value.rgb=colorKeys[0].yzw;}else{vec4 lastKey=colorKeys[i-1];float lastTime=lastKey.x;float age=(colorAge-lastTime)/(time-lastTime);value.rgb=mix(lastKey.yzw,key.yzw,age);}break;}}return value;}\n#endif\nvec4 computeParticleColor(in vec4 color,in float normalizedAge){\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 gradientColor=evaluateParticleGradient(renderer_COLMaxGradientColor,renderer_COLGradientKeysMaxTime.z,renderer_COLMaxGradientAlpha,renderer_COLGradientKeysMaxTime.w,normalizedAge);\n#endif\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\ngradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x,renderer_COLMinGradientAlpha,renderer_COLGradientKeysMaxTime.y,normalizedAge),gradientColor,a_Random0.y);\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\ncolor*=gradientColor;\n#endif\nreturn color;}",texture_sheet_animation_module:"#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#endif\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float totalULength=frame*renderer_TSATillingParams.x;float floorTotalULength=floor(totalULength);uv.x+=totalULength-floorTotalULength;uv.y+=floorTotalULength*renderer_TSATillingParams.y;\n#endif\nreturn uv;}",sphere_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);}else{float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#else\nif(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#endif\n#endif\n",stretched_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nif(renderer_VOLSpace==0){velocity=rotationByQuaternions(renderer_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;}else{velocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;}\n#else\nvelocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n#endif\nvec3 cameraUpVector=normalize(velocity);vec3 direction=normalize(center-camera_Position);vec3 sideVector=normalize(cross(direction,normalize(velocity)));sideVector=renderer_SizeScale.xzy*sideVector;cameraUpVector=length(vec3(renderer_SizeScale.x,0.0,0.0))*cameraUpVector;vec2 size=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);const mat2 rotationZHalfPI=mat2(0.0,-1.0,1.0,0.0);corner=rotationZHalfPI*corner;corner.y=corner.y-abs(corner.y);float speed=length(velocity);center+=sign(renderer_SizeScale.x)*(sign(renderer_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*renderer_StretchedBillboardSpeedScale+size.y*renderer_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n#endif\n",vertical_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,1.0,0.0);vec3 sideVector=normalize(cross(camera_Forward,cameraUpVector));float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",horizontal_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,0.0,1.0);const vec3 sideVector=vec3(-1.0,0.0,0.0);float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",particle_mesh:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\nvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);}else{\n#ifdef RENDERER_ROL_IS_SEPARATE\nfloat angle=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){center+=(rotationByQuaternions(rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));}else{\n#ifdef SHAPE\ncenter+=renderer_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);\n#endif\n}\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\nvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x),age,normalizedAge);center+=(rotationByQuaternions(rotationByEuler(renderer_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));\n#endif\n}\n#else\nif(renderer_ThreeDStartRotation){center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);}else{if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){if(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=(rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));}else{\n#ifdef SHAPE\nif(renderer_SimulationSpace==1)center+=renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);\n#endif\n}}\n#endif\nv_MeshColor=a_MeshColor;\n#endif\n"}),dE=((eL=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},eL.registerInclude=function(e,t){if(dA[e])throw'The "'+e+'" shader include already exist';dA[e]=t},eL.unRegisterInclude=function(e){delete dA[e]},eL.parseIncludes=function(e,t){return void 0===t&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm),e.replace(t,function(e,r){var n=dA[r];return void 0===n?(df.error('Shader slice "'+e.trim()+'" not founded.'),""):eL.parseIncludes(n,t)})},eL.convertTo300=function(e,t){if(e=(e=(e=e.replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),t){if(e=(e=(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!eL._has300Output(e)){if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,r)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else e=e.replace(/\battribute\b/g,"in");return e},eL._has300Output=function(e){return eL._has300OutInFragReg.test(e)},eL._replaceMRTShader=function(e,t){for(var r="",n=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);n.add(i[1])}return n.forEach(function(e){r+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),r+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},eL);dE._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),dE._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var dM=function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var r=e._nameMap;return r[t]||(r[t]=new e(t))},e}();dM._nameCounter=0,dM._nameMap=Object.create(null);var dR=((eB=(eD=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?dM.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&df.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},eB.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?dM.getByName(e):e)._uniqueId]},eB.getTagValue=function(e){return this._tagsMap["string"==typeof e?dM.getByName(e)._uniqueId:e._uniqueId]},cZ(eD,[{key:"name",get:function(){return this._name}}]),eD);e.ColorSpace=void 0,(eI=e.ColorSpace||(e.ColorSpace={}))[eI.Linear=0]="Linear",eI[eI.Gamma=1]="Gamma";var dw=((eO=(eV=function(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}).prototype).upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},eO.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},eO.upload2f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform2f(t.location,cj.gammaToLinearSpace(r.r),cj.gammaToLinearSpace(r.g)):this._gl.uniform2f(t.location,r.r,r.g),n.x=r.r,n.y=r.g):(n.x!==r.x||n.y!==r.y)&&(this._gl.uniform2f(t.location,r.x,r.y),n.x=r.x,n.y=r.y)},eO.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},eO.upload3f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g||n.z!==r.b)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform3f(t.location,cj.gammaToLinearSpace(r.r),cj.gammaToLinearSpace(r.g),cj.gammaToLinearSpace(r.b)):this._gl.uniform3f(t.location,r.r,r.g,r.b),n.x=r.r,n.y=r.g,n.z=r.b):(n.x!==r.x||n.y!==r.y||n.z!==r.z)&&(this._gl.uniform3f(t.location,r.x,r.y,r.z),n.x=r.x,n.y=r.y,n.z=r.z)},eO.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},eO.upload4f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g||n.z!==r.b||n.w!==r.a)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform4f(t.location,cj.gammaToLinearSpace(r.r),cj.gammaToLinearSpace(r.g),cj.gammaToLinearSpace(r.b),r.a):this._gl.uniform4f(t.location,r.r,r.g,r.b,r.a),n.x=r.r,n.y=r.g,n.z=r.b,n.w=r.a):(n.x!==r.x||n.y!==r.y||n.z!==r.z||n.w!==r.w)&&(this._gl.uniform4f(t.location,r.x,r.y,r.z,r.w),n.x=r.x,n.y=r.y,n.z=r.z,n.w=r.w)},eO.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},eO.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},eO.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},eO.upload2i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),r.x=t.r,r.y=t.g):(r.x!==t.x||r.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),r.x=t.x,r.y=t.y)},eO.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},eO.upload3i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g||r.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),r.x=t.r,r.y=t.g,r.z=t.b):(r.x!==t.x||r.y!==t.y||r.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),r.x=t.x,r.y=t.y,r.z=t.z)},eO.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},eO.upload4i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g||r.z!==t.b||r.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),r.x=t.r,r.y=t.g,r.z=t.b,r.w=t.a):(r.x!==t.x||r.y!==t.y||r.z!==t.z||r.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),r.x=t.x,r.y=t.y,r.z=t.z,r.w=t.w)},eO.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},eO.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},eO.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},eO.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},eO.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,a=0;a<t.length;a++){var i=t[a];r.activeTexture(n[a]),r.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},eV),dP=function(){this.constUniforms=[],this.textureUniforms=[]};(eN=l2||(l2={}))[eN.Scene=0]="Scene",eN[eN.Camera=1]="Camera",eN[eN.Renderer=2]="Renderer",eN[eN.Material=3]="Material";var dF=function(){function e(t,r,n){this.sceneUniformBlock=new dP,this.cameraUniformBlock=new dP,this.rendererUniformBlock=new dP,this.materialUniformBlock=new dP,this.otherUniformBlock=new dP,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(r,n),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var r=t._propertyValueMap,n=e.constUniforms,a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var r=t._propertyValueMap,n=e.textureUniforms;if(n)for(var a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,r=e.length;t<r;t++){var n=e[t];n.applyFunc(n,n.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,r=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r],a=dp._getShaderPropertyGroup(n.name);void 0!==a&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,a,t))}},t._groupingUniform=function(e,t,r){switch(t){case l2.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case l2.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case l2.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case l2.Material:r?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;default:r?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var r=this._gl,n=this._createShader(r.VERTEX_SHADER,e);if(!n)return null;var a=this._createShader(r.FRAGMENT_SHADER,t);if(!a)return null;var i=r.createProgram();return i?(r.attachShader(i,n),r.attachShader(i,a),r.linkProgram(i),r.validateProgram(i),r.deleteShader(n),r.deleteShader(a),!df.isEnabled||r.getProgramParameter(i,r.LINK_STATUS)||r.isContextLost())?i:(df.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(i,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(i)),r.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,a=n.createShader(t);return a?(n.shaderSource(a,r),n.compileShader(a),!df.isEnabled||n.getShaderParameter(a,n.COMPILE_STATUS)||n.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;n.forEach(function(n){var a,o=n.name,s=n.size,l=n.type,c=new dw(e._engine),d=!1,u=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),d=!0);var h=t.getUniformLocation(r,o);switch(c.name=o,c.propertyId=dp.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:d?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:d?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new cW(0,0));break;case t.FLOAT_VEC3:d?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new cB(0,0,0));break;case t.FLOAT_VEC4:d?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new cK(0,0,0,0));break;case t.BOOL:case t.INT:d?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:d?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new cW(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:d?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new cB(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:d?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new cK(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=d?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(u=!0,d){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=dp._getShaderPropertyGroup(o);e._groupingUniform(c,v,u)}),a.forEach(function(n){var a=n.name;e.attributeLocation[a]=t.getAttribLocation(r,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),a=0;a<r;++a){var i=e.getActiveUniform(t,a);n[a]=i}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<n;++a){var i=e.getActiveAttrib(t,a);r[a]=i}return r},e._addLineNum=function(e){var t,r=e.split("\n"),n=(r.length+1).toString().length+6;return r.map(function(e,r){if((t="0:"+(r+1)).length>=n)return t.substring(0,n)+e;for(var a=0;a<n-t.length;a++)t+=" ";return t+e}).join("\n")},cZ(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();dF._counter=0;var dL=function(t){function r(n,a,i,o){var s;for(var l in(s=t.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderProgramPools=[],s._shaderPassId=r._shaderPassCounter++,"string"==typeof i?(s._name=n,s._vertexSource=a,s._fragmentSource=i,o=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=a,o=null!=i?i:{pipelineStage:e.PipelineStage.Forward}),o)s.setTag(l,o[l]);return s}c0(r,t);var n=r.prototype;return n._getShaderProgram=function(t,r){var n=t._getShaderProgramPool(this),a=n.get(r);if(a)return a;var i=t._hardwareRenderer.isWebGL2,o=[];dS._getNamesByMacros(r,o);var s=dE.parseCustomMacros(o),l=i?"#version 300 es":"#version 100",c=i?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",d="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&(d+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(d+="#define HAS_DERIVATIVES\n");var u=" "+l+"\n "+c+"\n "+s+"\n "+dE.parseIncludes(this._vertexSource),h=" "+l+"\n "+c+"\n "+(i?"":dE._shaderExtension)+"\n "+d+"\n "+s+"\n "+dE.parseIncludes(this._fragmentSource);return i&&(u=dE.convertTo300(u),h=dE.convertTo300(h,!0)),a=new dF(t,u,h),n.cache(a),a},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,r=e.length;t<r;t++)e[t]._destroy();e.length=0},r}(dR);dL._shaderPassCounter=0;var dD=(c0(ek=function(e,t,r){var n;if((n=dR.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var a in n._passes=t.slice(),r)n.setTag(a,r[a]);return n},dR),cZ(ek,[{key:"passes",get:function(){return this._passes}}]),ek),dB=function(){this.enabled=!1,this.colorBlendOperation=e.BlendOperation.Add,this.alphaBlendOperation=e.BlendOperation.Add,this.sourceColorBlendFactor=e.BlendFactor.One,this.sourceAlphaBlendFactor=e.BlendFactor.One,this.destinationColorBlendFactor=e.BlendFactor.Zero,this.destinationAlphaBlendFactor=e.BlendFactor.Zero,this.colorWriteMask=e.ColorWriteMask.All},dI=((eU=(ez=function(){this.targetBlendState=new dB,this.blendColor=new cj(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,d=this.targetBlendState,u=t[e.RenderStateDataKey.BlendStateEnabled0];if(void 0!==u){var h=r.getFloat(u);d.enabled=void 0!==h&&!!h}var _=t[e.RenderStateDataKey.BlendStateColorBlendOperation0];void 0!==_&&(d.colorBlendOperation=null!=(n=r.getFloat(_))?n:e.BlendOperation.Add);var f=t[e.RenderStateDataKey.BlendStateAlphaBlendOperation0];void 0!==f&&(d.alphaBlendOperation=null!=(a=r.getFloat(f))?a:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(d.sourceColorBlendFactor=null!=(i=r.getFloat(p))?i:e.BlendFactor.One);var m=t[e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0];void 0!==m&&(d.sourceAlphaBlendFactor=null!=(o=r.getFloat(m))?o:e.BlendFactor.One);var g=t[e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0];void 0!==g&&(d.destinationColorBlendFactor=null!=(s=r.getFloat(g))?s:e.BlendFactor.Zero);var v=t[e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0];void 0!==v&&(d.destinationAlphaBlendFactor=null!=(l=r.getFloat(v))?l:e.BlendFactor.Zero);var y=t[e.RenderStateDataKey.BlendStateColorWriteMask0];void 0!==y&&(d.colorWriteMask=null!=(c=r.getFloat(y))?c:e.ColorWriteMask.All);var x=t[e.RenderStateDataKey.BlendStateBlendColor];if(void 0!==x){var b=r.getColor(x);void 0!==b&&this.blendColor.copyFrom(b)}var S=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==S){var T=r.getFloat(S);this.alphaToCoverage=void 0!==T&&!!T}},eU._apply=function(e,t){this._platformApply(e,t.blendState)},eU._platformApply=function(t,r){var n=t.gl,a=r.targetBlendState,i=this.targetBlendState,o=i.enabled,s=i.colorBlendOperation,l=i.alphaBlendOperation,c=i.sourceColorBlendFactor,d=i.destinationColorBlendFactor,u=i.sourceAlphaBlendFactor,h=i.destinationAlphaBlendFactor,_=i.colorWriteMask;if(o!==a.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),a.enabled=o),o){(c!==a.sourceColorBlendFactor||d!==a.destinationColorBlendFactor||u!==a.sourceAlphaBlendFactor||h!==a.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(ez._getGLBlendFactor(t,c),ez._getGLBlendFactor(t,d),ez._getGLBlendFactor(t,u),ez._getGLBlendFactor(t,h)),a.sourceColorBlendFactor=c,a.destinationColorBlendFactor=d,a.sourceAlphaBlendFactor=u,a.destinationAlphaBlendFactor=h),(s!==a.colorBlendOperation||l!==a.alphaBlendOperation)&&(n.blendEquationSeparate(ez._getGLBlendOperation(t,s),ez._getGLBlendOperation(t,l)),a.colorBlendOperation=s,a.alphaBlendOperation=l);var f=this.blendColor;cj.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==a.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),a.colorWriteMask=_);var p=this.alphaToCoverage;p!==r.alphaToCoverage&&(p?n.enable(n.SAMPLE_ALPHA_TO_COVERAGE):n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),r.alphaToCoverage=p)},ez._getGLBlendFactor=function(t,r){var n=t.gl;switch(r){case e.BlendFactor.Zero:return n.ZERO;case e.BlendFactor.One:return n.ONE;case e.BlendFactor.SourceColor:return n.SRC_COLOR;case e.BlendFactor.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case e.BlendFactor.DestinationColor:return n.DST_COLOR;case e.BlendFactor.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case e.BlendFactor.SourceAlpha:return n.SRC_ALPHA;case e.BlendFactor.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case e.BlendFactor.DestinationAlpha:return n.DST_ALPHA;case e.BlendFactor.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case e.BlendFactor.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case e.BlendFactor.BlendColor:return n.CONSTANT_COLOR;case e.BlendFactor.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},ez._getGLBlendOperation=function(t,r){var n=t.gl;switch(r){case e.BlendOperation.Add:return n.FUNC_ADD;case e.BlendOperation.Subtract:return n.FUNC_SUBTRACT;case e.BlendOperation.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case e.BlendOperation.Min:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case e.BlendOperation.Max:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},ez);c1([c5],dI.prototype,"targetBlendState",void 0),c1([c5],dI.prototype,"blendColor",void 0);var dV=((eH=(eG=function(){this.enabled=!0,this.compareFunction=e.CompareFunction.Less,this.writeEnabled=!0}).prototype)._applyShaderDataValue=function(t,r){var n,a=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==a){var i=r.getFloat(a);this.enabled=void 0!==i&&!!i}var o=t[e.RenderStateDataKey.DepthStateWriteEnabled];if(void 0!==o){var s=r.getFloat(o);this.writeEnabled=void 0!==s&&!!s}var l=t[e.RenderStateDataKey.DepthStateCompareFunction];void 0!==l&&(this.compareFunction=null!=(n=r.getFloat(l))?n:e.CompareFunction.Less)},eH._apply=function(e,t){this._platformApply(e,t.depthState)},eH._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.compareFunction,i=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&a!=t.compareFunction&&(r.depthFunc(eG._getGLCompareFunction(e,a)),t.compareFunction=a),i!=t.writeEnabled&&(r.depthMask(i),t.writeEnabled=i)},eG._getGLCompareFunction=function(t,r){var n=t.gl;switch(r){case e.CompareFunction.Never:return n.NEVER;case e.CompareFunction.Less:return n.LESS;case e.CompareFunction.Equal:return n.EQUAL;case e.CompareFunction.LessEqual:return n.LEQUAL;case e.CompareFunction.Greater:return n.GREATER;case e.CompareFunction.NotEqual:return n.NOTEQUAL;case e.CompareFunction.GreaterEqual:return n.GEQUAL;case e.CompareFunction.Always:return n.ALWAYS}},eG),dO=((eK=(eW=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o=t[e.RenderStateDataKey.RasterStateCullMode];void 0!==o&&(this.cullMode=null!=(n=r.getFloat(o))?n:e.CullMode.Back);var s=t[e.RenderStateDataKey.RasterStateDepthBias];void 0!==s&&(this.depthBias=null!=(a=r.getFloat(s))?a:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(i=r.getFloat(l))?i:0)},eK._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},eK._platformApply=function(t,r,n){var a=t.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=i!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),r._cullFaceEnable=l),l&&i!==r.cullMode&&(i==e.CullMode.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),r.cullMode=i),n!==r._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},eW),dN=((eX=(ej=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,d,u,h,_,f=t[e.RenderStateDataKey.StencilStateEnabled];if(void 0!==f){var p=r.getFloat(f);this.enabled=void 0!==p&&!!p}var m=t[e.RenderStateDataKey.StencilStateReferenceValue];void 0!==m&&(this.referenceValue=null!=(n=r.getFloat(m))?n:0);var g=t[e.RenderStateDataKey.StencilStateMask];void 0!==g&&(this.mask=null!=(a=r.getFloat(g))?a:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(i=r.getFloat(v))?i:255);var y=t[e.RenderStateDataKey.StencilStateCompareFunctionFront];void 0!==y&&(this.compareFunctionFront=null!=(o=r.getFloat(y))?o:e.CompareFunction.Always);var x=t[e.RenderStateDataKey.StencilStateCompareFunctionBack];void 0!==x&&(this.compareFunctionBack=null!=(s=r.getFloat(x))?s:e.CompareFunction.Always);var b=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==b&&(this.passOperationFront=null!=(l=r.getFloat(b))?l:e.StencilOperation.Keep);var S=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==S&&(this.passOperationBack=null!=(c=r.getFloat(S))?c:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==T&&(this.failOperationFront=null!=(d=r.getFloat(T))?d:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==C&&(this.failOperationBack=null!=(u=r.getFloat(C))?u:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==A&&(this.zFailOperationFront=null!=(h=r.getFloat(A))?h:e.StencilOperation.Keep);var E=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==E&&(this.zFailOperationBack=null!=(_=r.getFloat(E))?_:e.StencilOperation.Keep)},eX._apply=function(e,t){this._platformApply(e,t.stencilState)},eX._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.referenceValue,i=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,d=this.passOperationFront,u=this.failOperationBack,h=this.zFailOperationBack,_=this.passOperationBack,f=this.writeMask;if(n!=t.enabled&&(n?r.enable(r.STENCIL_TEST):r.disable(r.STENCIL_TEST),t.enabled=n),n){var p=a!==t.referenceValue||i!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,ej._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,ej._getGLCompareFunction(e,s),a,i),t.compareFunctionBack=this.compareFunctionBack),p&&(t.referenceValue=this.referenceValue,t.mask=this.mask),(l!==t.failOperationFront||c!==t.zFailOperationFront||d!==t.passOperationFront)&&(r.stencilOpSeparate(r.FRONT,ej._getGLStencilOperation(e,l),ej._getGLStencilOperation(e,c),ej._getGLStencilOperation(e,d)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=d),(u!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,ej._getGLStencilOperation(e,u),ej._getGLStencilOperation(e,h),ej._getGLStencilOperation(e,_)),t.failOperationBack=u,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},ej._getGLCompareFunction=function(t,r){var n=t.gl;switch(r){case e.CompareFunction.Never:return n.NEVER;case e.CompareFunction.Less:return n.LESS;case e.CompareFunction.Equal:return n.EQUAL;case e.CompareFunction.LessEqual:return n.LEQUAL;case e.CompareFunction.Greater:return n.GREATER;case e.CompareFunction.NotEqual:return n.NOTEQUAL;case e.CompareFunction.GreaterEqual:return n.GEQUAL;case e.CompareFunction.Always:return n.ALWAYS}},ej._getGLStencilOperation=function(t,r){var n=t.gl;switch(r){case e.StencilOperation.Keep:return n.KEEP;case e.StencilOperation.Zero:return n.ZERO;case e.StencilOperation.Replace:return n.REPLACE;case e.StencilOperation.IncrementSaturate:return n.INCR;case e.StencilOperation.DecrementSaturate:return n.DECR;case e.StencilOperation.Invert:return n.INVERT;case e.StencilOperation.IncrementWrap:return n.INCR_WRAP;case e.StencilOperation.DecrementWrap:return n.DECR_WRAP}},ej),dk=((eY=(eq=function(){this.blendState=new dI,this.depthState=new dV,this.stencilState=new dN,this.rasterState=new dO,this.renderQueueType=e.RenderQueueType.Opaque}).prototype)._applyShaderDataValue=function(t,r){this.blendState._applyShaderDataValue(t,r),this.depthState._applyShaderDataValue(t,r),this.stencilState._applyShaderDataValue(t,r),this.rasterState._applyShaderDataValue(t,r);var n,a=t[e.RenderStateDataKey.RenderQueueType];void 0!==a&&(this.renderQueueType=null!=(n=r.getFloat(a))?n:e.RenderQueueType.Opaque)},eY._apply=function(e,t,r,n){r&&this._applyShaderDataValue(r,n);var a=e._hardwareRenderer,i=e._lastRenderState,o=e._renderContext;this.blendState._apply(a,i),this.depthState._apply(a,i),this.stencilState._apply(a,i),this.rasterState._apply(a,i,o.flipProjection?!t:t)},eq);c1([c5],dk.prototype,"blendState",void 0),c1([c5],dk.prototype,"depthState",void 0),c1([c5],dk.prototype,"stencilState",void 0),c1([c5],dk.prototype,"rasterState",void 0);var dz=((eJ=(eQ=function(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}).prototype).compileVariant=function(e,t){var r=eQ._compileMacros;r.clear();for(var n=0,a=t.length;n<a;n++)r.enable(dS.getByName(t[n]));for(var i=!1,o=this._subShaders,s=0,l=o.length;s<l;s++)for(var c=o[s].passes,d=0,u=c.length;d<u;d++){var h=c[d]._getShaderProgram(e,r);i=0===d?h.isValid:i&&h.isValid}return i},eJ.destroy=function(e){if(void 0===e&&(e=!1),!e&&0!==this._refCount)return!1;for(var t=this._subShaders,r=0,n=t.length;r<n;r++)for(var a=t[r].passes,i=0,o=a.length;i<o;i++)a[i]._destroy();return delete eQ._shaderMap[this.name],this._destroyed=!0,!0},eJ._getReferCount=function(){return this._refCount},eJ._addReferCount=function(e){this._refCount+=e},eQ.create=function(e,t,r){var n,a=eQ._shaderMap;if(t){if(a[e]){console.error('Shader named "'+e+'" already exists.');return}if("string"==typeof t){var i=new dL(t,r);n=new eQ(e,[new dD("Default",[i])])}else if(t.length>0)n=t[0].constructor===dL?new eQ(e,[new dD("Default",t)]):new eQ(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!eQ._shaderLab)throw"ShaderLab has not been set up yet.";var o=eQ._shaderLab.parseShader(e);if(a[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(e){var t=e.passes.map(function(e){if("string"==typeof e){var t,r,n=e.split("/");return null==(r=eQ.find(n[0]))?void 0:null==(t=r.subShaders.find(function(e){return e.name===n[1]}))?void 0:t.passes.find(function(e){return e.name===n[2]})}var a=new dL(e.name,e.vertexSource,e.fragmentSource,e.tags),i=e.renderStates,o=new dk;a._renderState=o;var s=i[0];for(var l in s)eQ._applyConstRenderStates(o,parseInt(l),s[l]);var c=i[1],d={};for(var u in c)d[u]=dp.getByName(c[u]);return a._renderStateDataMap=d,a});return new dD(o.name,t,e.tags)});return n=new eQ(o.name,s),a[o.name]=n,n}return a[e]=n,n},eQ.find=function(e){return eQ._shaderMap[e]},eQ._applyConstRenderStates=function(t,r,n){switch(r){case e.RenderStateDataKey.BlendStateEnabled0:t.blendState.targetBlendState.enabled=n;break;case e.RenderStateDataKey.BlendStateColorBlendOperation0:t.blendState.targetBlendState.colorBlendOperation=n;break;case e.RenderStateDataKey.BlendStateAlphaBlendOperation0:t.blendState.targetBlendState.alphaBlendOperation=n;break;case e.RenderStateDataKey.BlendStateSourceColorBlendFactor0:t.blendState.targetBlendState.sourceColorBlendFactor=n;break;case e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0:t.blendState.targetBlendState.destinationColorBlendFactor=n;break;case e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0:t.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0:t.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case e.RenderStateDataKey.BlendStateColorWriteMask0:t.blendState.targetBlendState.colorWriteMask=n;break;case e.RenderStateDataKey.DepthStateEnabled:t.depthState.enabled=n;break;case e.RenderStateDataKey.DepthStateWriteEnabled:t.depthState.writeEnabled=n;break;case e.RenderStateDataKey.DepthStateCompareFunction:t.depthState.compareFunction=n;break;case e.RenderStateDataKey.StencilStateEnabled:t.stencilState.enabled=n;break;case e.RenderStateDataKey.StencilStateReferenceValue:t.stencilState.referenceValue=n;break;case e.RenderStateDataKey.StencilStateMask:t.stencilState.mask=n;break;case e.RenderStateDataKey.StencilStateWriteMask:t.stencilState.writeMask=n;break;case e.RenderStateDataKey.StencilStateCompareFunctionFront:t.stencilState.compareFunctionFront=n;break;case e.RenderStateDataKey.StencilStateCompareFunctionBack:t.stencilState.compareFunctionBack=n;break;case e.RenderStateDataKey.StencilStatePassOperationFront:t.stencilState.passOperationFront=n;break;case e.RenderStateDataKey.StencilStatePassOperationBack:t.stencilState.passOperationBack=n;break;case e.RenderStateDataKey.StencilStateFailOperationFront:t.stencilState.failOperationFront=n;break;case e.RenderStateDataKey.StencilStateFailOperationBack:t.stencilState.failOperationBack=n;break;case e.RenderStateDataKey.StencilStateZFailOperationFront:t.stencilState.zFailOperationFront=n;break;case e.RenderStateDataKey.StencilStateZFailOperationBack:t.stencilState.zFailOperationBack=n;break;case e.RenderStateDataKey.RasterStateCullMode:t.rasterState.cullMode=n;break;case e.RenderStateDataKey.RasterStateDepthBias:t.rasterState.depthBias=n;break;case e.RenderStateDataKey.RasterStateSlopeScaledDepthBias:t.rasterState.slopeScaledDepthBias=n;break;case e.RenderStateDataKey.RenderQueueType:t.renderQueueType=n}},eQ.getMacroByName=function(e,t){return dS.getByName(e,t)},eQ.getPropertyByName=function(e){return dp.getByName(e)},cZ(eQ,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),eQ);dz._compileMacros=new dT,dz._shaderMap=Object.create(null);var dU=(c0(eZ=function(e){var t;return(t=c7.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(cQ(t)),t},c7),eZ.prototype._onDestroy=function(){c7.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},cZ(eZ,[{key:"isContentLost",get:function(){return this._isContentLost}}]),eZ);e.TextureFilterMode=void 0,(e$=e.TextureFilterMode||(e.TextureFilterMode={}))[e$.Point=0]="Point",e$[e$.Bilinear=1]="Bilinear",e$[e$.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(e0=e.TextureFormat||(e.TextureFormat={}))[e0.R8G8B8=0]="R8G8B8",e0[e0.R8G8B8A8=1]="R8G8B8A8",e0[e0.R4G4B4A4=2]="R4G4B4A4",e0[e0.R5G5B5A1=3]="R5G5B5A1",e0[e0.R5G6B5=4]="R5G6B5",e0[e0.Alpha8=5]="Alpha8",e0[e0.LuminanceAlpha=6]="LuminanceAlpha",e0[e0.R16G16B16A16=7]="R16G16B16A16",e0[e0.R32G32B32A32=8]="R32G32B32A32",e0[e0.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",e0[e0.BC1=10]="BC1",e0[e0.BC3=11]="BC3",e0[e0.BC7=12]="BC7",e0[e0.ETC1_RGB=13]="ETC1_RGB",e0[e0.ETC2_RGB=14]="ETC2_RGB",e0[e0.ETC2_RGBA5=15]="ETC2_RGBA5",e0[e0.ETC2_RGBA8=16]="ETC2_RGBA8",e0[e0.PVRTC_RGB2=17]="PVRTC_RGB2",e0[e0.PVRTC_RGBA2=18]="PVRTC_RGBA2",e0[e0.PVRTC_RGB4=19]="PVRTC_RGB4",e0[e0.PVRTC_RGBA4=20]="PVRTC_RGBA4",e0[e0.ASTC_4x4=21]="ASTC_4x4",e0[e0.ASTC_5x5=22]="ASTC_5x5",e0[e0.ASTC_6x6=23]="ASTC_6x6",e0[e0.ASTC_8x8=24]="ASTC_8x8",e0[e0.ASTC_10x10=25]="ASTC_10x10",e0[e0.ASTC_12x12=26]="ASTC_12x12",e0[e0.Depth=27]="Depth",e0[e0.Stencil=28]="Stencil",e0[e0.DepthStencil=29]="DepthStencil",e0[e0.Depth16=30]="Depth16",e0[e0.Depth24=31]="Depth24",e0[e0.Depth32=32]="Depth32",e0[e0.Depth24Stencil8=33]="Depth24Stencil8",e0[e0.Depth32Stencil8=34]="Depth32Stencil8",e0[e0.DXT1=10]="DXT1",e0[e0.DXT5=11]="DXT5";var dG=(c0(e1=function(){var e;return e=dU.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},dU),(e2=e1.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},e2._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},e2._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},e2._onDestroy=function(){dU.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},e2._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},e2._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},e2._isIntFormat=function(){return e.TextureFormat.R32G32B32A32_UInt===this._format},cZ(e1,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(t){if(t!==this._filterMode){if(t!==e.TextureFilterMode.Point&&this._isIntFormat()){t=e.TextureFilterMode.Point,df.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=t,this._platformTexture.filterMode=t}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(df.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(df.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),e1),dH=((e4=(e3=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new dT,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},e4.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},e4.getInt=function(e){return this.getPropertyValue(e)},e4.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},e4.getFloatArray=function(e){return this.getPropertyValue(e)},e4.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},e4.getIntArray=function(e){return this.getPropertyValue(e)},e4.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},e4.getVector2=function(e){return this.getPropertyValue(e)},e4.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},e4.getVector3=function(e){return this.getPropertyValue(e)},e4.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},e4.getVector4=function(e){return this.getPropertyValue(e)},e4.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},e4.getMatrix=function(e){return this.getPropertyValue(e)},e4.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},e4.getColor=function(e){return this.getPropertyValue(e)},e4.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},e4.getTexture=function(e){return this.getPropertyValue(e)},e4.setTexture=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},e4.getTextureArray=function(e){return this.getPropertyValue(e)},e4.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);if(a)for(var i=0,o=a.length;i<o;i++)a[i]._addReferCount(-n);if(r)for(var s=0,l=r.length;s<l;s++)r[s]._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,r)},e4.getPropertyValue=function(e){return"string"==typeof e&&(e=dp.getByName(e)),this._propertyValueMap[e._uniqueId]},e4.enableMacro=function(e,t){"string"==typeof e&&(e=dS.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var a=this._macroCollection;n&&a.disable(n),a.enable(e),this._macroMap[r]=e}},e4.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=dS._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},e4.getMacros=function(e){if(!e)return Object.values(this._macroMap);var t=this._macroMap;for(var r in e.length=0,t)e.push(t[r])},e4.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=dp._propertyIdMap;for(var a in r)t.push(n[a]);if(!e)return t},e4.clone=function(){var e=new e3(this._group);return this.cloneTo(e),e},e4.cloneTo=function(e){c9.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,a=Object.keys(r),i=0,o=a.length;i<o;i++){var s=a[i],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(c2(l,dG))n[s]=l,t>0&&l._addReferCount(t);else if(c2(l,Array)||c2(l,Float32Array)||c2(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},e4._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=dp.getByName(t)),t._group!==this._group){if(void 0===t._group)t._group=this._group;else throw"Shader property "+t.name+" has been used as "+l2[t._group]+" group."}if(t._type!==r){if(void 0===t._type)t._type=r;else throw"Shader property "+t.name+" has been used as "+e.ShaderPropertyType[t._type]+" type."}this._propertyValueMap[t._uniqueId]=n},e4._getReferCount=function(){return this._refCount},e4._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&c2(n,dG)&&n._addReferCount(e)}},e3);function dW(){return function(e){}}c1([c3],dH.prototype,"_group",void 0),c1([c3],dH.prototype,"_propertyValueMap",void 0),c1([c3],dH.prototype,"_macroCollection",void 0),c1([c3],dH.prototype,"_macroMap",void 0),c1([c3],dH.prototype,"_refCount",void 0),e.Renderer=(c0(e8=function(t){(r=dg.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new dT,r._bounds=new cV,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._shaderData=new dH(l2.Renderer),r._mvMatrix=new cG,r._mvpMatrix=new cG,r._mvInvMatrix=new cG,r._normalMatrix=new cG,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r._rendererLayer=new cK,r.castShadows=!0;var r,n=e.Renderer.prototype,a=r.shaderData;return r._overrideUpdate=r.update!==n.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(cQ(r)),r._registerEntityTransformListener(),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},dg),(e5=e8.prototype).getInstanceMaterial=function(e){void 0===e&&(e=0);var t=this._materials;if(t.length>e){var r=t[e];if(r)return this._materialsInstanced[e]?r:this._createInstanceMaterial(r,e)}return null},e5.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},e5.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},e5.getInstanceMaterials=function(){for(var e=this._materials,t=this._materialsInstanced,r=0,n=e.length;r<n;r++)t[r]||this._createInstanceMaterial(this._materials[r],r);return e},e5.getMaterials=function(){return this._materials},e5.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,a=t,i=r.length;a<i;a++){var o=r[a];o&&this._addResourceReferCount(o,-1)}r.length!==t&&(r.length=t),0!==n.length&&(n.length=0);for(var s=0;s<t;s++){var l=r[s],c=e[s];l!==c&&(r[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},e5.update=function(e){},e5._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},e5._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},e5._prepareRender=function(t){var r=t.virtualCamera,n=r.position,a=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(cB.subtract(a,n,a),this._distanceForSort=cB.dot(a,r.forward)):this._distanceForSort=cB.distanceSquared(a,n),this._updateShaderData(t,!1),this._render(t),dT.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},e5._cloneTo=function(e,t,r){for(var n=this._materials,a=0,i=n.length;a<i;a++)e._setMaterial(a,n[a])},e5._onDestroy=function(){dg.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this._addResourceReferCount(this.shaderData,-1);for(var e=this._materials,t=0,r=e.length;t<r;t++){var n=e[t];n&&this._addResourceReferCount(n,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},e5._updateShaderData=function(e,t){var r=this.entity,n=r.transform.worldMatrix;if(t){this._updateMVPShaderData(e,n);return}this._updateTransformShaderData(e,n);var a=r.layer;this._rendererLayer.set(65535&a,a>>>16&65535,0,0)},e5._updateTransformShaderData=function(t,r){var n=this.shaderData,a=this._mvMatrix,i=this._mvInvMatrix,o=this._normalMatrix;cG.multiply(t.viewMatrix,r,a),cG.invert(a,i),cG.invert(r,o),o.transpose(),n.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),n.setMatrix(e.Renderer._worldMatrixProperty,r),n.setMatrix(e.Renderer._mvMatrixProperty,a),n.setMatrix(e.Renderer._mvInvMatrixProperty,i),n.setMatrix(e.Renderer._normalMatrixProperty,o),this._updateMVPShaderData(t,r)},e5._updateMVPShaderData=function(t,r){var n=this._mvpMatrix;cG.multiply(t.viewProjectionMatrix,r,n),this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,n)},e5._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},e5._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},e5._updateBounds=function(e){},e5._render=function(e){throw"not implement"},e5._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(r,1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},e5._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),n&&this._addResourceReferCount(n,-1),t&&this._addResourceReferCount(t,1),r[e]=t}},e5._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},cZ(e8,[{key:"shaderData",get:function(){return this._shaderData}},{key:"isCulled",get:function(){return!(void 0===this._renderFrameCount||this._renderFrameCount===this._engine.time.frameCount-1)}},{key:"receiveShadows",get:function(){return this._receiveShadows},set:function(t){this._receiveShadows!==t&&(t?this.shaderData.enableMacro(e.Renderer._receiveShadowMacro):this.shaderData.disableMacro(e.Renderer._receiveShadowMacro),this._receiveShadows=t)}},{key:"materialCount",get:function(){return this._materials.length},set:function(e){var t=this._materials,r=this._materialsInstanced;t.length!==e&&(t.length=e),r.length>e&&(r.length=e)}},{key:"bounds",get:function(){return 1&this._dirtyUpdateFlag&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),e8._tempVector0=new cB,e8._receiveShadowMacro=dS.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e8._localMatrixProperty=dp.getByName("renderer_LocalMat"),e8._worldMatrixProperty=dp.getByName("renderer_ModelMat"),e8._mvMatrixProperty=dp.getByName("renderer_MVMat"),e8._mvpMatrixProperty=dp.getByName("renderer_MVPMat"),e8._mvInvMatrixProperty=dp.getByName("renderer_MVInvMat"),e8._normalMatrixProperty=dp.getByName("renderer_NormalMat"),e8._rendererLayerProperty=dp.getByName("renderer_Layer"),e8),c1([c3],e.Renderer.prototype,"_distanceForSort",void 0),c1([c3],e.Renderer.prototype,"_onUpdateIndex",void 0),c1([c3],e.Renderer.prototype,"_rendererIndex",void 0),c1([c3],e.Renderer.prototype,"_globalShaderMacro",void 0),c1([c3],e.Renderer.prototype,"_bounds",void 0),c1([c3],e.Renderer.prototype,"_renderFrameCount",void 0),c1([c3],e.Renderer.prototype,"_overrideUpdate",void 0),c1([c3],e.Renderer.prototype,"_materials",void 0),c1([c3],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),c1([c5],e.Renderer.prototype,"_shaderData",void 0),c1([c3],e.Renderer.prototype,"_mvMatrix",void 0),c1([c3],e.Renderer.prototype,"_mvpMatrix",void 0),c1([c3],e.Renderer.prototype,"_mvInvMatrix",void 0),c1([c3],e.Renderer.prototype,"_normalMatrix",void 0),c1([c3],e.Renderer.prototype,"_materialsInstanced",void 0),c1([c4],e.Renderer.prototype,"_priority",void 0),c1([c4],e.Renderer.prototype,"_receiveShadows",void 0),c1([c3],e.Renderer.prototype,"_rendererLayer",void 0),c1([c3],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=c1([dy(db,e.DependentMode.CheckOnly)],e.Renderer),(e9=l3||(l3={}))[e9.WorldVolume=1]="WorldVolume";var dK=((e6=function(){}).resetData=function(e){var t,r,n=e._verticesData,a=n.positions,i=n.uvs;n.vertexCount=a.length=i.length=4;for(var o=0;o<4;o++)a[t=o]||(a[t]=new cB),i[r=o]||(i[r]=new cW);n.triangles=dK._rectangleTriangles},e6.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,a=n.pivot,i=a.x,o=a.y,s=dK._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,d=e.flipX?-t:t,u=e.flipY?-r:r;l[0]=c[0]*d,l[1]=c[1]*d,l[2]=c[2]*d,l[4]=c[4]*u,l[5]=c[5]*u,l[6]=c[6]*u,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-i*l[0]-o*l[4],l[13]=c[13]-i*l[1]-o*l[5],l[14]=c[14]-i*l[2]-o*l[6];for(var h=n._getPositions(),_=e._verticesData.positions,f=0;f<4;f++){var p=h[f],m=p.x,g=p.y;_[f].set(l[0]*m+l[4]*g+l[12],l[1]*m+l[5]*g+l[13],l[2]*m+l[6]*g+l[14])}cV.transform(n._getBounds(),s,e._bounds)},e6.updateUVs=function(e){var t=e.sprite._getUVs(),r=e._verticesData.uvs,n=t[0],a=n.x,i=n.y,o=t[3],s=o.x,l=o.y;r[0].set(a,i),r[1].set(s,i),r[2].set(a,l),r[3].set(s,l)},e6._rectangleTriangles=[0,1,2,2,1,3],e6._worldMatrix=new cG,e6);dK=c1([dW()],dK);var dj=((e7=function(){}).resetData=function(e){var t,r,n=e._verticesData,a=n.positions,i=n.uvs;n.vertexCount=a.length=i.length=16;for(var o=0;o<16;o++)a[t=o]||(a[t]=new cB),i[r=o]||(i[r]=new cW);n.triangles=dj._rectangleTriangles},e7.updatePositions=function(e){var t,r,n=e.width,a=e.height,i=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=i.border,d=i._getUVs(),u=i._getPositions(),h=u[0],_=h.x,f=h.y,p=u[3],m=p.x,g=p.y,v=i.width,y=i.height,x=v*c.x,b=y*c.y,S=v*c.z,T=y*c.w;if(x+S>n){var C=n/(x+S);t=[v*_*C,x*C,x*C,n-v*(1-m)*C]}else t=[v*_,x,n-S,n-v*(1-m)];if(T+b>a){var A=a/(T+b);r=[y*f*A,b*A,b*A,a-y*(1-g)*A]}else r=[y*f,b,a-T,a-y*(1-g)];var E=e.sprite.pivot,M=E.x,R=E.y,w=e.width*M,P=e.height*R,F=dj._worldMatrix,L=F.elements,D=e.entity.transform.worldMatrix.elements,B=e.flipX?-1:1,I=e.flipY?-1:1;L[0]=D[0]*B,L[1]=D[1]*B,L[2]=D[2]*B,L[4]=D[4]*I,L[5]=D[5]*I,L[6]=D[6]*I,L[8]=D[8],L[9]=D[9],L[10]=D[10],L[12]=D[12]-w*L[0]-P*L[4],L[13]=D[13]-w*L[1]-P*L[5],L[14]=D[14]-w*L[2]-P*L[6];for(var V=0;V<4;V++)for(var O=t[V],N=d[V].x,k=0;k<4;k++){var z=r[k],U=4*V+k;s[U].set(L[0]*O+L[4]*z+L[12],L[1]*O+L[5]*z+L[13],L[2]*O+L[6]*z+L[14]),l[U].set(N,d[k].y)}var G=e._bounds,H=G.min,W=G.max;H.set(t[0],r[0],0),W.set(t[3],r[3],0),e._bounds.transform(F)},e7.updateUVs=function(e){},e7._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14],e7._worldMatrix=new cG,e7);dj=c1([dW()],dj);var dX=((tt=(te=function(e){void 0===e&&(e=0),this.length=0,this._isLooping=!1,this._blankCount=0,this._elements=Array(e)}).prototype).add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},tt.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},tt.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},tt.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},tt.deleteByIndex=function(e){var t,r=this._elements;if(this._isLooping)this._elements[e]=null,this._blankCount++;else{var n=this.length-1;e!==n&&(t=r[n],r[e]=t),r[n]=null,this.length--}return t},tt.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0,a=this.length;n<a;n++){var i=r[n];i&&e(i)}this._endLoop(t)},tt.forEachAndClean=function(e,t){this._startLoop();for(var r=this.length,n=this._elements,a=0;a<r;a++){var i=n[a];i&&e(i)}this._endLoopAndClean(r,n,t)},tt.sort=function(e){dt._quickSort(this._elements,0,this.length,e)},tt.garbageCollection=function(){this._elements.length=this.length},tt._startLoop=function(){this._isLooping=!0},tt._endLoop=function(e){if(this._isLooping=!1,this._blankCount){var t=0,r=this.length-1,n=this._elements;e:do{for(;n[t];)if(++t>=r)break e;for(;!n[r];)if(t>=--r)break e;var a=n[r];e(a,t),n[t++]=a,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},tt._endLoopAndClean=function(e,t,r){for(var n=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[n]=o,r(o,n),n++)}this._isLooping=!1,this.length=n,this._blankCount=0},te);e.BufferUsage=void 0,(tr=e.BufferUsage||(e.BufferUsage={}))[tr.Static=0]="Static",tr[tr.Dynamic=1]="Dynamic",tr[tr.Stream=2]="Stream",e.SetDataOptions=void 0,(tn=e.SetDataOptions||(e.SetDataOptions={}))[tn.None=0]="None",tn[tn.Discard=1]="Discard";var dq=(c0(ta=function(t,r,n,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=dU.call(this,t)||this)._dataUpdateManager=new di,o._engine=t,o._type=r,o._bufferUsage=a,o._readable=i,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,a),i&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,a,n),i){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},dU),(ti=ta.prototype).bind=function(){this._platformBuffer.bind()},ti.setData=function(t,r,n,a,i){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,a,i),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=a?s*a:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,d=new Uint8Array(o,c,l);this._data.set(d,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},ti.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},ti.markAsUnreadable=function(){this._data=null,this._readable=!1},ti._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},ti._onDestroy=function(){dU.prototype._onDestroy.call(this),this._platformBuffer.destroy()},cZ(ta,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}},{key:"readable",get:function(){return this._readable}},{key:"data",get:function(){if(this._readable)return this._data;throw"Buffer is not readable."}}]),ta);e.IndexFormat=void 0,(to=e.IndexFormat||(e.IndexFormat={}))[to.UInt8=0]="UInt8",to[to.UInt16=1]="UInt16",to[to.UInt32=2]="UInt32",e.VertexElementFormat=void 0,(ts=e.VertexElementFormat||(e.VertexElementFormat={}))[ts.Float=0]="Float",ts[ts.Vector2=1]="Vector2",ts[ts.Vector3=2]="Vector3",ts[ts.Vector4=3]="Vector4",ts[ts.Byte4=4]="Byte4",ts[ts.UByte4=5]="UByte4",ts[ts.NormalizedByte4=6]="NormalizedByte4",ts[ts.NormalizedUByte4=7]="NormalizedUByte4",ts[ts.Short2=8]="Short2",ts[ts.UShort2=9]="UShort2",ts[ts.NormalizedShort2=10]="NormalizedShort2",ts[ts.NormalizedUShort2=11]="NormalizedUShort2",ts[ts.Short4=12]="Short4",ts[ts.UShort4=13]="UShort4",ts[ts.NormalizedShort4=14]="NormalizedShort4",ts[ts.NormalizedUShort4=15]="NormalizedUShort4";var dY=((tl=function(){})._getGLIndexType=function(t){switch(t){case e.IndexFormat.UInt8:return e.DataType.UNSIGNED_BYTE;case e.IndexFormat.UInt16:return e.DataType.UNSIGNED_SHORT;case e.IndexFormat.UInt32:return e.DataType.UNSIGNED_INT}},tl._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tl._getElementInfo=function(t){var r,n,a,i=!1;switch(t){case e.VertexElementFormat.Float:r=1,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:r=2,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:r=3,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:r=4,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:r=4,n=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:r=4,n=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:r=4,n=e.DataType.BYTE,i=!0,a=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,i=!0,a=1/255;break;case e.VertexElementFormat.Short2:r=2,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:r=2,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:r=2,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535;break;case e.VertexElementFormat.Short4:r=4,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:r=4,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:r=4,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535}return{size:r,type:n,normalized:i,normalizedScaleFactor:a}},tl);e.BufferBindFlag=void 0,(tc=e.BufferBindFlag||(e.BufferBindFlag={}))[tc.VertexBuffer=0]="VertexBuffer",tc[tc.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(td=e.MeshTopology||(e.MeshTopology={}))[td.Points=0]="Points",td[td.Lines=1]="Lines",td[td.LineLoop=2]="LineLoop",td[td.LineStrip=3]="LineStrip",td[td.Triangles=4]="Triangles",td[td.TriangleStrip=5]="TriangleStrip",td[td.TriangleFan=6]="TriangleFan";var dQ=(cZ(tu=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tu),dJ=((th=function(t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=e.MeshTopology.Triangles),this.start=t,this.count=r,this.topology=n}).prototype.dispose=function(){},th),dZ=(c0(t_=function(e){var t;return(t=dU.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(cQ(t)),t},dU),(tf=t_.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,a=t[n];a&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(a),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},tf.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},tf.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},tf.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,a=n[e];a&&delete r[a.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},tf.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,a=r.length;n<a;n++){var i=r[n];delete t[i.attribute]}r.length=e},tf.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),a=this.vertexBufferBindings;n>0&&(null==(r=a[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),a[e]=t,this._bufferStructChanged=!0},tf.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this.setVertexBufferBinding(t+i,e[i])},tf.setIndexBufferBinding=function(e){var t=this.indexBufferBinding,r=this._getReferCount();t!==e&&(this._indexBufferBinding=e,r>0&&(null==t||t.buffer._addReferCount(-r)),e?(r>0&&e.buffer._addReferCount(r),this._glIndexType=dY._getGLIndexType(e.format),this._glIndexByteCount=dY._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},tf.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tf._addReferCount=function(e){dU.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,a=0,i=n.length;a<i;a++)null==(r=n[a])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},tf._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},tf._onDestroy=function(){dU.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},cZ(t_,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t_),d$=(c0(tp=function(e,t){(r=c7.call(this,e)||this)._updateFlagManager=new di,r._bounds=new cV,r._subMeshes=[],r.name=t,r._primitive=new dZ(e),r._onBoundsChanged=r._onBoundsChanged.bind(cQ(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},c7),(tm=tp.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new dJ(t,r,n)),this._subMeshes.push(t),t},tm.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},tm.clearSubMesh=function(){this._subMeshes.length=0},tm._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},tm._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},tm._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},tm._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},tm._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},tm._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},tm._addReferCount=function(e){c7.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},tm._onDestroy=function(){c7.prototype._onDestroy.call(this),this._primitive.destroy()},tm._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},tm._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},tm._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},cZ(tp,[{key:"bounds",get:function(){return this._bounds},set:function(e){this._bounds!==e&&this._bounds.copyFrom(e)}},{key:"subMesh",get:function(){return this._subMeshes[0]||null}},{key:"subMeshes",get:function(){return this._subMeshes}}]),tp);(tg=l4||(l4={}))[tg.Bounds=1]="Bounds",tg[tg.VertexElements=2]="VertexElements";var d0=(cZ(tv=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tv),d1=(cZ(ty=function(e,t,r,n,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=dY._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)},[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),ty),d2=((tx=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new di,this._dirty=7,r&&r.length!==t.length)throw"deltaNormals length must same with deltaPositions length.";if(n&&n.length!==t.length)throw"deltaTangents length must same with deltaPositions length.";this.weight=e,this._deltaPositions=t,this._deltaNormals=r,this._deltaTangents=n}).prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},cZ(tx,[{key:"deltaPositions",get:function(){return this._deltaPositions},set:function(e){this._deltaPositions=e,this._dirty|=1,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaNormals",get:function(){return this._deltaNormals},set:function(e){this._deltaNormals=e,this._dirty|=2,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaTangents",get:function(){return this._deltaTangents},set:function(e){this._deltaTangents=e,this._dirty|=4,this._dataChangeManager.dispatch(this._dirty,this)}}]),tx);(tb=l8||(l8={}))[tb.Position=1]="Position",tb[tb.Normal=2]="Normal",tb[tb.Tangent=4]="Tangent",tb[tb.All=7]="All";var d3=((tT=(tS=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new di,this._dataChangeManager=new di,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var a=new d2(e,t,r,n);return this._addFrame(a),a}this._addFrame(e)},tT.clearFrames=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._dataChangeManager.removeListener(this._frameDataChangeListener);e.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},tT._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},tT._addFrame=function(e){var t=this._frames,r=t.length;if(r>0&&e.deltaPositions.length!==t[r-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(e),this._frameDataChangeListener(l8.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},tT._updateUseNormalAndTangent=function(e,t){var r=this._useBlendShapeNormal&&e,n=this._useBlendShapeTangent&&t;(this._useBlendShapeNormal!==r||this._useBlendShapeTangent!==n)&&(this._useBlendShapeNormal=r,this._useBlendShapeTangent=n,this._layoutChangeManager.dispatch(0,this))},tT._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},cZ(tS,[{key:"frames",get:function(){return this._frames}}]),tS),d4=(c0(tC=function(){return d$.apply(this,arguments)},d$),(tA=tC.prototype).setVertexElements=function(e){this._setVertexElements(e)},tA.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new d0(e,t));var i=this._primitive.vertexBufferBindings;i.length<=r&&(i.length=r+1),this._setVertexBufferBinding(a?t:r,n)},tA.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this._setVertexBufferBinding(t+i,e[i])},tA.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new dQ(e,t))),this._setIndexBufferBinding(r)},cZ(tC,[{key:"instanceCount",get:function(){return this._primitive.instanceCount},set:function(e){this._primitive.instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._primitive.indexBufferBinding}},{key:"vertexElements",get:function(){return this._primitive.vertexElements}}]),tC),d8=(tE=e.Renderer,c0(tM=function(e){var t;return(t=tE.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(cQ(t)),t},tE),(tR=tM.prototype)._onDestroy=function(){var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),tE.prototype._onDestroy.call(this)},tR._cloneTo=function(e,t,r){tE.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},tR._prepareRender=function(e){if(!this._mesh){df.error("mesh is null.");return}if(this._mesh.destroyed){df.error("mesh is destroyed.");return}tE.prototype._prepareRender.call(this,e)},tR._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;cV.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tR._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(tM._uvMacro),r.disableMacro(tM._uv1Macro),r.disableMacro(tM._normalMacro),r.disableMacro(tM._tangentMacro),r.disableMacro(tM._enableVertexColorMacro);for(var a=0,i=n.length;a<i;a++)switch(n[a].attribute){case"TEXCOORD_0":r.enableMacro(tM._uvMacro);break;case"TEXCOORD_1":r.enableMacro(tM._uv1Macro);break;case"NORMAL":r.enableMacro(tM._normalMacro);break;case"TANGENT":r.enableMacro(tM._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(tM._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._renderDataPool,d=0,u=s.length;d<u;d++){var h=o[d];if(h){(h.destroyed||h.shader.destroyed)&&(h=this.engine._meshMagentaMaterial);var _=c.getFromPool();_.setX(this,h,t._primitive,s[d]),l.pushRenderData(e,_)}}},tR._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tR._onMeshChanged=function(e){e&l4.Bounds&&(this._dirtyUpdateFlag|=l3.WorldVolume),e&l4.VertexElements&&(this._dirtyUpdateFlag|=2)},cZ(tM,[{key:"mesh",get:function(){return this._mesh},set:function(e){this._mesh!==e&&this._setMesh(e)}},{key:"enableVertexColor",get:function(){return this._enableVertexColor},set:function(e){e!==this._enableVertexColor&&(this._dirtyUpdateFlag|=2,this._enableVertexColor=e)}}]),tM);d8._uvMacro=dS.getByName("RENDERER_HAS_UV"),d8._uv1Macro=dS.getByName("RENDERER_HAS_UV1"),d8._normalMacro=dS.getByName("RENDERER_HAS_NORMAL"),d8._tangentMacro=dS.getByName("RENDERER_HAS_TANGENT"),d8._enableVertexColorMacro=dS.getByName("RENDERER_ENABLE_VERTEXCOLOR"),c1([c3],d8.prototype,"_mesh",void 0),c1([c3],d8.prototype,"_onMeshChanged",null),(tw=l5||(l5={}))[tw.VertexElementMacro=2]="VertexElementMacro",tw[tw.All=3]="All",e.RenderBufferDepthFormat=void 0,(tP=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[tP.Depth=27]="Depth",tP[tP.Stencil=28]="Stencil",tP[tP.DepthStencil=29]="DepthStencil",tP[tP.Depth16=30]="Depth16",tP[tP.Depth24=31]="Depth24",tP[tP.Depth32=32]="Depth32",tP[tP.Depth24Stencil8=33]="Depth24Stencil8",tP[tP.Depth32Stencil8=34]="Depth32Stencil8",e.TextureCubeFace=void 0,(tF=e.TextureCubeFace||(e.TextureCubeFace={}))[tF.PositiveX=0]="PositiveX",tF[tF.NegativeX=1]="NegativeX",tF[tF.PositiveY=2]="PositiveY",tF[tF.NegativeY=3]="NegativeY",tF[tF.PositiveZ=4]="PositiveZ",tF[tF.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(tL=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[tL.Never=0]="Never",tL[tL.Less=1]="Less",tL[tL.Equal=2]="Equal",tL[tL.LessEqual=3]="LessEqual",tL[tL.Greater=4]="Greater",tL[tL.NotEqual=5]="NotEqual",tL[tL.GreaterEqual=6]="GreaterEqual",tL[tL.Always=7]="Always",e.TextureUsage=void 0,(tD=e.TextureUsage||(e.TextureUsage={}))[tD.Static=0]="Static",tD[tD.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(tB=e.TextureWrapMode||(e.TextureWrapMode={}))[tB.Clamp=0]="Clamp",tB[tB.Repeat=1]="Repeat",tB[tB.Mirror=2]="Mirror";var d5=(c0(tI=function(t,r,n,a,i,o){if(void 0===i&&(i=e.TextureFormat.Depth),void 0===o&&(o=1),(s=dU.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=r,s._height=n,s._antiAliasing=o,s._depth=i,a){for(var s,l=c2(a,Array)?a.slice():[a],c=0,d=l.length;c<d;c++){var u=l[c];if(u._isDepthTexture)throw"Render texture can't use depth format.";u._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(c2(i,dG)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(cQ(s)),s},dU),(tV=tI.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},tV.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,r=e.length;t<r;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},tV._onDestroy=function(){dU.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,r=0,n=t.length;r<n;r++)t[r]._addReferCount(-1);t.length=0,null==(e=this._depthTexture)||e._addReferCount(-1),this._depthTexture=null,this._depth=null},tV._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},tV._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},cZ(tI,[{key:"autoGenerateMipmaps",get:function(){return this._autoGenerateMipmaps},set:function(e){this._autoGenerateMipmaps=e}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),tI),d9=(c0(tO=function(t,r,n,a,i,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=e.TextureUsage.Static),(s=dG.call(this,t)||this)._mipmap=i,s._width=r,s._height=n,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==e.TextureFormat.Depth||a==e.TextureFormat.DepthStencil||a==e.TextureFormat.Depth16||a==e.TextureFormat.Depth24||a==e.TextureFormat.Depth32||a==e.TextureFormat.Depth24Stencil8||a==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(cQ(s)),s.filterMode=s._isIntFormat()?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},dG),(tN=tO.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i),this._isContentLost=!1},tN.setImageSource=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,r,n,a,i),this._isContentLost=!1},tN.getPixelBuffer=function(e,t,r,n,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,r,n,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i)},tN._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),dG.prototype._rebuild.call(this)},tO),d6=(c0(tk=function(t,r,n,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=dG.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(cQ(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},dG),(tz=tk.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o,s),this._isContentLost=!1},tz.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tz.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):5===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tz._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),dG.prototype._rebuild.call(this)},cZ(tk,[{key:"length",get:function(){return this._length}}]),tk),d7=(c0(tU=function(t,r,n,a){var i;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=dG.call(this,t)||this)._mipmap=a,i._width=r,i._height=r,i._format=n,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(cQ(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},dG),(tG=tU.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o),this._isContentLost=!1},tG.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tG.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):6===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tG._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),dG.prototype._rebuild.call(this)},tU),ue=((tW=(tH=function(e,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new cK,this._canUseTextureStoreData=!0,this._dataTextureInfo=new cB,this._engine=e,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}).prototype)._addBlendShape=function(e){this._blendShapes.push(e),this._blendShapeCount++,e._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,e),this._subDataDirtyFlags.push(e._dataChangeManager.createFlag(dx))},tW._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var n=this._subDataDirtyFlags,a=0,i=n.length;a<i;a++)n[a].destroy();n.length=0},tW._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(tH._blendShapeMacro),this._useTextureMode())e.enableMacro(tH._blendShapeTextureMacro),e.setTexture(tH._blendShapeTextureProperty,this._vertexTexture),e.setVector3(tH._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(tH._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var a=t._condensedBlendShapeWeights;a||(a=new Float32Array(n),t._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,a),e.setFloatArray(tH._blendShapeWeightsProperty,a),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(tH._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(tH._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(tH._blendShapeNormalMacro):e.disableMacro(tH._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(tH._blendShapeTangentMacro):e.disableMacro(tH._blendShapeTangentMacro)}else e.disableMacro(tH._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},tW._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},tW._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},tW._vertexElementsNeedUpdate=function(){var e=this._getVertexBufferModeSupportCount(),t=this._lastHostCreatedInfo;return Math.min(t.x,e)!==Math.min(this._blendShapeCount,e)||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent},tW._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},tW._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,a=Math.max(r.length,t+1);n<a&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},tW._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,a=0,i=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<o;i++)t._setVertexElement(r++,new d1("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12,this._useBlendNormal&&(t._setVertexElement(r++,new d1("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12),this._useBlendTangent&&(t._setVertexElement(r++,new d1("TANGENT_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12);return r},tW._update=function(e){var t=this._modelMesh.vertexCount,r=this._useTextureMode(),n=this._isCreateHost(t);n&&(r?this._createTextureArray(t):this._createVertexBuffers(t,e),this._lastHostCreatedInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent,t)),this._needUpdateData()&&(r?this._updateTextureArray(t,n):this._updateVertexBuffers(t,n))},tW._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},tW._createVertexBuffers=function(t,r){var n=this._engine,a=this._modelMesh,i=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),d=Math.ceil(i/c),u=s*t*Math.min(c,i);o.length=d,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=i;for(var h=this._bufferBindingOffset,_=0;_<d;_++){var f=d-1,p=(_===f?i-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new dq(n,e.BufferBindFlag.VertexBuffer,m,g);a._setVertexBufferBinding(h+_,new d0(v,p)),o[_]=v}},tW._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,a=n*t,i=1;a>r&&(i=Math.ceil(a/r),a=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new d6(this._engine,a,i,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*a*i*4),this._vertexTexture=o,this._dataTextureInfo.set(n,a,i)},tW._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,d=this._bufferBindingOffset,u=0,h=r.length;u<h;u++){var _=s[u];if(t||_.flag){var f=r[u].frames,p=f.length,m=f[p-1];if(p>0&&m.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(u/n),v=u%n,y=i[g],x=y.byteLength/(4*e),b=v*l,S=o[u];S||(o[u]=S=new cW),S.set(d+g,v*c);for(var T=m.deltaPositions,C=0;C<e;C++){var A=b+x*C,E=T[C];E&&(a[A]=E.x,a[A+1]=E.y,a[A+2]=E.z)}if(b+=3,this._useBlendNormal){var M=m.deltaNormals;if(M)for(var R=0;R<e;R++){var w=b+x*R,P=M[R];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=b+x*L,B=F[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}b+=3}(v===n-1||u===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},tW._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=i[o],c=n.width*n.height*4;if(t||l.flag){var d=r[o].frames,u=d.length,h=d[u-1];if(u>0&&h.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=h.deltaPositions,f=h.deltaNormals,p=h.deltaTangents,m=o*c,g=0;g<e;g++){var v=_[g];if(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,a)},tW._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;r&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&n++,i&&n++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=n},tW._attributeModeUpdateVertexElement=function(e,t,r,n){var a=this._vertexElementOffset+this._vertexElementCount*n,i=t[r],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var d=e[++a];s+=12,d.bindingIndex=o,d.offset=s}},tW._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},tW._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<n)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var d=0;d<n;d++){var u=t[d];u<o&&(o=u,r=d)}}}},tH);ue._blendShapeMacro=dS.getByName("RENDERER_HAS_BLENDSHAPE"),ue._blendShapeTextureMacro=dS.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),ue._blendShapeNormalMacro=dS.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),ue._blendShapeTangentMacro=dS.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),ue._blendShapeWeightsProperty=dp.getByName("renderer_BlendShapeWeights"),ue._blendShapeTextureProperty=dp.getByName("renderer_BlendShapeTexture"),ue._blendShapeTextureInfoProperty=dp.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(tK=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",tK.Normal="NORMAL",tK.Color="COLOR_0",tK.Tangent="TANGENT",tK.BoneWeight="WEIGHTS_0",tK.BoneIndex="JOINTS_0",tK.UV="TEXCOORD_0",tK.UV1="TEXCOORD_1",tK.UV2="TEXCOORD_2",tK.UV3="TEXCOORD_3",tK.UV4="TEXCOORD_4",tK.UV5="TEXCOORD_5",tK.UV6="TEXCOORD_6",tK.UV7="TEXCOORD_7";var ut=(c0(tj=function(e,t){var r;return(r=d$.call(this,e)||this)._internalVertexBufferIndex=-1,r._vertexCount=0,r._vertexCountDirty=!1,r._dataVersionCounter=0,r._positions=null,r._normals=null,r._colors=null,r._tangents=null,r._uv=null,r._uv1=null,r._uv2=null,r._uv3=null,r._uv4=null,r._uv5=null,r._uv6=null,r._uv7=null,r._boneWeights=null,r._boneIndices=null,r._advancedElementUpdateFlag=0,r._advancedDataUpdateFlag=0,r._advancedVertexDataVersions=Array(14),r._advancedDataSyncToBuffer=!1,r._internalVertexBufferStride=0,r._internalVertexBufferCreatedInfo=new cB(0,0,-1),r._internalVertexElementsOffset=0,r._internalVertexElementsFlags=0,r._vertexBufferInfos=[],r._indices=null,r._indicesFormat=null,r._indicesChangeFlag=!1,r._accessible=!0,r.name=t,r._blendShapeManager=new ue(e,cQ(r)),r},d$),(tX=tj.prototype).setPositions=function(e){var t;(this._positions||e)&&(this._updateAdvancedVertexDataMarks(1,0),this._positions=e,this._vertexCount=null!=(t=null==e?void 0:e.length)?t:0,this._vertexCountDirty=!1)},tX.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},tX.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},tX.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},tX.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},tX.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},tX.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},tX.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},tX.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},tX.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},tX.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},tX.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},tX.setUVs=function(e,t){switch(t=null!=t?t:0){case 0:this._beforeSetAdvancedVertexData(e,64,6),this._uv=e;break;case 1:this._beforeSetAdvancedVertexData(e,128,7),this._uv1=e;break;case 2:this._beforeSetAdvancedVertexData(e,256,8),this._uv2=e;break;case 3:this._beforeSetAdvancedVertexData(e,512,9),this._uv3=e;break;case 4:this._beforeSetAdvancedVertexData(e,1024,10),this._uv4=e;break;case 5:this._beforeSetAdvancedVertexData(e,2048,11),this._uv5=e;break;case 6:this._beforeSetAdvancedVertexData(e,4096,12),this._uv6=e;break;case 7:this._beforeSetAdvancedVertexData(e,8192,13),this._uv7=e;break;default:throw"The index of channel needs to be in range [0 - 7]."}},tX.getUVs=function(t){switch(t=null!=t?t:0){case 0:var r=this._getVertexElementData(this._uv,e.VertexAttribute.UV,6,this._readVector2VertexData);return this._uv=r,r;case 1:var n=this._getVertexElementData(this._uv1,e.VertexAttribute.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var a=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=a,a;case 3:var i=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var o=this._getVertexElementData(this._uv4,e.VertexAttribute.UV4,10,this._readVector2VertexData);return this._uv4=o,o;case 5:var s=this._getVertexElementData(this._uv5,e.VertexAttribute.UV5,11,this._readVector2VertexData);return this._uv5=s,s;case 6:var l=this._getVertexElementData(this._uv6,e.VertexAttribute.UV6,12,this._readVector2VertexData);return this._uv6=l,l;case 7:var c=this._getVertexElementData(this._uv7,e.VertexAttribute.UV7,13,this._readVector2VertexData);return this._uv7=c,c}throw"The index of channel needs to be in range [0 - 7]."},tX.setIndices=function(t){this._indices!==t&&(this._indices=t,c2(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:c2(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:c2(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},tX.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},tX.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,a=0;a<n;a++)this._addVertexElement(t[a]);var i=this._primitive._vertexElementMap;i[e.VertexAttribute.Position]||this.setPositions(null),i[e.VertexAttribute.Normal]||this.setNormals(null),i[e.VertexAttribute.Color]||this.setColors(null),i[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),i[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),i[e.VertexAttribute.Tangent]||this.setTangents(null),i[e.VertexAttribute.UV]||this.setUVs(null,0),i[e.VertexAttribute.UV1]||this.setUVs(null,1),i[e.VertexAttribute.UV2]||this.setUVs(null,2),i[e.VertexAttribute.UV3]||this.setUVs(null,3),i[e.VertexAttribute.UV4]||this.setUVs(null,4),i[e.VertexAttribute.UV5]||this.setUVs(null,5),i[e.VertexAttribute.UV6]||this.setUVs(null,6),i[e.VertexAttribute.UV7]||this.setUVs(null,7);var o=this._internalVertexBufferCreatedInfo.z;-1!==o&&(null==(r=this._primitive.vertexBufferBindings[o])||r.buffer.destroy(),this._setVertexBufferBinding(o,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},tX.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new d0(e,t));var i=a?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,n),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},tX.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+r;n.length<i&&(n.length=i,a.length=i);for(var o=0;o<r;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},tX.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},tX.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},tX.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},tX.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},tX.uploadData=function(t){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(t),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var r=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,a=0,i=n.length;a<i;a++){var o=r[a];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[a])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,d=null==(u=this._primitive.indexBufferBinding)?void 0:u._buffer;if(c){if(d&&c.byteLength==d.byteLength)d.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new dQ(d,this._indicesFormat));else{null==d||d.destroy();var u,h=new dq(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new dQ(h,this._indicesFormat))}}else d&&(d.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var _=this._blendShapeManager;_._blendShapeCount>0&&_._update(t),t&&(this._accessible=!1,this._releaseCache(!1))},tX.calculateTangents=function(){var e=this.getPositions(),t=this.getNormals(),r=this.getUVs();if(!t||!r)throw"Set normal and uv before calculation.";for(var n=this._indices,a=this.vertexCount,i=tj._tempVec0,o=tj._tempVec1,s=tj._tempVec2,l=tj._tempVec3,c=tj._tempVec4,d=n?n.length/3:e.length/3,u=Array(a),h=Array(a),_=0;_<a;_++)u[_]=new cK,h[_]=new cB;for(var f=0;f<d;f++){var p=3*f,m=3*f+1,g=3*f+2;n&&(p=n[p],m=n[m],g=n[g]);var v=e[p],y=e[m],x=e[g],b=r[p],S=r[m],T=r[g];cB.subtract(y,v,i),cB.subtract(x,v,o);var C=S.x-b.x,A=T.x-b.x,E=S.y-b.y,M=T.y-b.y,R=1/(C*M-A*E);cB.scale(i,M*R,s),cB.scale(o,E*R,c),cB.subtract(s,c,s),cB.scale(o,C*R,l),cB.scale(i,A*R,c),cB.subtract(l,c,l);var w=u[p];w.set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=u[m]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=u[g]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<a;P++){var F=t[P],L=h[P],D=u[P];s.set(D.x,D.y,D.z),cB.cross(s,L,c);var B=cB.dot(c,F)>0?1:-1;cB.scale(F,cB.dot(s,F),c),cB.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,B)}this.setTangents(u)},tX._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=function(){r._advancedDataSyncToBuffer||(a[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(i),d$.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(i),(a[e]||(a[e]=new ur)).reset(),i()):e+1==n.length&&n.length--},tX._getVertexTypedArray=function(t,r){switch(r){case e.DataType.BYTE:return new Int8Array(t);case e.DataType.UNSIGNED_BYTE:return new Uint8Array(t);case e.DataType.SHORT:return new Int16Array(t);case e.DataType.UNSIGNED_SHORT:return new Uint16Array(t);case e.DataType.FLOAT:return new Float32Array(t)}},tX._onDestroy=function(){d$.prototype._onDestroy.call(this),this._releaseCache(!0)},tX._getVertexElementData=function(e,t,r,n){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[r])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[r]=l,n.call(this,t))},tX._beforeSetAdvancedVertexData=function(e,t,r){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(t,r)},tX._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},tX._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,a=this._internalVertexBufferCreatedInfo,i=r*n;if(a.x*a.y!==i){var o,s=a.z;-1!==s&&(null==(o=this._primitive.vertexBufferBindings[s])||o.buffer.destroy(),this._setVertexBufferBinding(s,null));var l=this._internalVertexBufferIndex,c=r*this.vertexCount>0;if(c){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var d=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,u=new dq(this._engine,e.BufferBindFlag.VertexBuffer,i,d,!0);this._setVertexBufferBinding(l,new d0(u,r))}a.set(r,n,c?l:-1)}},tX._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new cW(e[t],e[t+1])})},tX._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new cB(e[t],e[t+1],e[t+2])})},tX._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new cK(e[t],e[t+1],e[t+2],e[t+3])})},tX._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new cj(e[t],e[t+1],e[t+2],e[t+3])})},tX._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var a=r.vertexBufferBindings[n.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=n._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),d=n.offset,u=a.stride,h=0;h<o;h++){var _=(h*u+d)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},tX._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new d1(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=r,this._blendShapeManager._vertexElementOffset++}}else{var s=n[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~r):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},tX._updateAdvancedVertexElements=function(){var t=this._advancedElementUpdateFlag;1&t&&this._updateAdvancedVertexElement(this._positions,e.VertexAttribute.Position,1),2&t&&this._updateAdvancedVertexElement(this._normals,e.VertexAttribute.Normal,2),4&t&&this._updateAdvancedVertexElement(this._colors,e.VertexAttribute.Color,4),16&t&&this._updateAdvancedVertexElement(this._boneWeights,e.VertexAttribute.BoneWeight,16),32&t&&this._updateAdvancedVertexElement(this._boneIndices,e.VertexAttribute.BoneIndex,32),8&t&&this._updateAdvancedVertexElement(this._tangents,e.VertexAttribute.Tangent,8),64&t&&this._updateAdvancedVertexElement(this._uv,e.VertexAttribute.UV,64),128&t&&this._updateAdvancedVertexElement(this._uv1,e.VertexAttribute.UV1,128),256&t&&this._updateAdvancedVertexElement(this._uv2,e.VertexAttribute.UV2,256),512&t&&this._updateAdvancedVertexElement(this._uv3,e.VertexAttribute.UV3,512),1024&t&&this._updateAdvancedVertexElement(this._uv4,e.VertexAttribute.UV4,1024),2048&t&&this._updateAdvancedVertexElement(this._uv5,e.VertexAttribute.UV5,2048),4096&t&&this._updateAdvancedVertexElement(this._uv6,e.VertexAttribute.UV6,4096),8192&t&&this._updateAdvancedVertexElement(this._uv7,e.VertexAttribute.UV7,8192)},tX._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,r=e.length,n=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<r&&this._setVertexElementsLength(i)}},tX._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y)})},tX._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},tX._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},tX._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},tX._writeAdvancedVertexData=function(e,t,r){var n,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(n=this._advancedVertexDataVersions[t])?n:-1,d=this._vertexBufferInfos[o];if(c>d.dataVersion){for(var u=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,u.type),_=i.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=u.normalized,g=u.size,v=u.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var b=(y*f+_)/p;if(r(h,b,y),m)for(var S=0;S<g;S++)h[b+S]/=v}d.uploadAdvancedData=!0}}},tX._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,a=this._advancedDataUpdateFlag,i=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,d=this._uv2,u=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&a&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),i&&16&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,i),o&&32&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),d&&256&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,d),u&&512&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,u),h&&1024&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},tX._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,r=this._primitive.vertexBufferBindings,n=r.length;t<n&&r[t];t++);return this._internalVertexBufferIndex=t,t},tX._getAttributeFormat=function(t){switch(t){case e.VertexAttribute.Position:case e.VertexAttribute.Normal:return e.VertexElementFormat.Vector3;case e.VertexAttribute.Color:case e.VertexAttribute.BoneWeight:case e.VertexAttribute.Tangent:return e.VertexElementFormat.Vector4;case e.VertexAttribute.BoneIndex:return e.VertexElementFormat.UByte4;case e.VertexAttribute.UV:case e.VertexAttribute.UV1:case e.VertexAttribute.UV2:case e.VertexAttribute.UV3:case e.VertexAttribute.UV4:case e.VertexAttribute.UV5:case e.VertexAttribute.UV6:case e.VertexAttribute.UV7:return e.VertexElementFormat.Vector2}},tX._getAttributeByteLength=function(t){switch(t){case e.VertexAttribute.Position:case e.VertexAttribute.Normal:return 12;case e.VertexAttribute.Color:case e.VertexAttribute.BoneWeight:case e.VertexAttribute.Tangent:return 16;case e.VertexAttribute.BoneIndex:return 4;case e.VertexAttribute.UV:case e.VertexAttribute.UV1:case e.VertexAttribute.UV2:case e.VertexAttribute.UV3:case e.VertexAttribute.UV4:case e.VertexAttribute.UV5:case e.VertexAttribute.UV6:case e.VertexAttribute.UV7:return 8}},tX._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,r=this._dataVersionCounter++,n=this._vertexBufferInfos,a=0,i=n.length;a<i;a++){var o=n[a];o&&(o.dataVersion=r)}}},cZ(tj,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var t=0,r=this._primitive._vertexElementMap[e.VertexAttribute.Position];if(r){var n=this._primitive.vertexBufferBindings[r.bindingIndex];n&&(t=n.buffer.byteLength/n.stride)}this._vertexCount=t,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._primitive.vertexElements}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}},{key:"accessible",get:function(){return this._accessible}}]),tj);ut._tempVec0=new cB,ut._tempVec1=new cB,ut._tempVec2=new cB,ut._tempVec3=new cB,ut._tempVec4=new cB;var ur=((tq=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},tq);(tY=l9||(l9={}))[tY.None=0]="None",tY[tY.Position=1]="Position",tY[tY.Normal=2]="Normal",tY[tY.Color=4]="Color",tY[tY.Tangent=8]="Tangent",tY[tY.BoneWeight=16]="BoneWeight",tY[tY.BoneIndex=32]="BoneIndex",tY[tY.UV=64]="UV",tY[tY.UV1=128]="UV1",tY[tY.UV2=256]="UV2",tY[tY.UV3=512]="UV3",tY[tY.UV4=1024]="UV4",tY[tY.UV5=2048]="UV5",tY[tY.UV6=4096]="UV6",tY[tY.UV7=8192]="UV7",tY[tY.All=65535]="All",(tQ=l6||(l6={}))[tQ.Position=0]="Position",tQ[tQ.Normal=1]="Normal",tQ[tQ.Color=2]="Color",tQ[tQ.Tangent=3]="Tangent",tQ[tQ.BoneWeight=4]="BoneWeight",tQ[tQ.BoneIndex=5]="BoneIndex",tQ[tQ.UV=6]="UV",tQ[tQ.UV1=7]="UV1",tQ[tQ.UV2=8]="UV2",tQ[tQ.UV3=9]="UV3",tQ[tQ.UV4=10]="UV4",tQ[tQ.UV5=11]="UV5",tQ[tQ.UV6=12]="UV6",tQ[tQ.UV7=13]="UV7";var un=function(e){this.resource=e},ua=(c0(tJ=function(e,t){var r;return(r=un.call(this,e)||this).primitiveInfo=t,r},un),tJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:uf._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:uf._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:uf._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:uf._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:uf._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:uf._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:uf._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:uf._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},tJ);(tZ=l7||(l7={}))[tZ.Sphere=0]="Sphere",tZ[tZ.Cuboid=1]="Cuboid",tZ[tZ.Plane=2]="Plane",tZ[tZ.Cylinder=3]="Cylinder",tZ[tZ.Torus=4]="Torus",tZ[tZ.Cone=5]="Cone",tZ[tZ.Capsule=6]="Capsule",tZ[tZ.CCSphere=7]="CCSphere";var ui=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},uo=(c0(t$=function(e,t,r,n){var a;return(a=ui.call(this,0,r,n)||this).radius=e,a.segments=t,a},ui),t$),us=(c0(t0=function(e,t,r,n){var a;return(a=ui.call(this,7,r,n)||this).radius=e,a.step=t,a},ui),t0),ul=(c0(t1=function(e,t,r,n,a){var i;return(i=ui.call(this,1,n,a)||this).width=e,i.height=t,i.depth=r,i},ui),t1),uc=(c0(t2=function(e,t,r,n,a,i){var o;return(o=ui.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},ui),t2),ud=(c0(t3=function(e,t,r,n,a,i,o){var s;return(s=ui.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=a,s},ui),t3),uu=(c0(t4=function(e,t,r,n,a,i,o){var s;return(s=ui.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=a,s},ui),t4),uh=(c0(t8=function(e,t,r,n,a,i){var o;return(o=ui.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},ui),t8),u_=(c0(t5=function(e,t,r,n,a,i){var o;return(o=ui.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},ui),t5),uf=((t9=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var a=new ut(e);t9._setSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(a,new uo(t,r,i,n))),a},t9.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var a=new ut(e);t9._setSubdivisionSurfaceSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(a,new us(t,r,i,n))),a},t9.createCuboid=function(e,t,r,n,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=!0);var i=new ut(e);t9._setCuboidData(i,t,r,n,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(i,new ul(t,r,n,o,a))),i},t9.createPlane=function(e,t,r,n,a,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new ut(e);t9._setPlaneData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(o,new uc(t,r,n,a,s,i))),o},t9.createCylinder=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new ut(e);t9._setCylinderData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(s,new ud(t,r,n,a,i,l,o))),s},t9.createTorus=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===a&&(a=30),void 0===i&&(i=360),void 0===o&&(o=!0);var s=new ut(e);t9._setTorusData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(s,new uu(t,r,n,a,i,l,o))),s},t9.createCone=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new ut(e);t9._setConeData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(o,new uh(t,r,n,a,s,i))),o},t9.createCapsule=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new ut(e);t9._setCapsuleData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ua(o,new u_(t,r,n,a,s,i))),o},t9._setSubdivisionSurfaceSphereData=function(e,t,r,n,a,i){r=cD.clamp(Math.floor(r),1,6);var o=new Float32Array(3*(6*Math.pow(4,r)+2)),s=new Float32Array(24*Math.pow(4,r));t9._subdiveCatmullClark(r,o,s);for(var l=o.length/3,c=s.length/4,d=l+Math.pow(2,r+1)-1,u=d+16,h=new Float32Array(8*u),_=t9._generateIndices(e.engine,l,6*c),f=0,p={},m=0;m<l;m++){var g=3*m,v=o[g],y=o[g+1],x=o[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*t,h[g+1]=y*t,h[g+2]=x*t,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var S=8*(l+f++);h.set(h.subarray(g,g+8),S),h[S+6]=1,p[g/8]=S/8}}var T=0;this._spherePoleIdx=0;for(var C=0;C<c;C++){var A=4*C,E=s[A],M=s[A+1],R=s[A+2],w=s[A+3],P=8*E,F=8*M,L=8*R,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(E=p[E]),0===h[F+6]&&(M=p[M]),0===h[L+6]&&(R=p[R]),0===h[D+6]&&(w=p[w])),_[T]=E,_[T+1]=M,_[T+2]=R,this._generateAndReplacePoleUV(_,h,T,d),_[T+3]=E,_[T+4]=R,_[T+5]=w,this._generateAndReplacePoleUV(_,h,T+3,d),T+=6}if(!a){var B=e.bounds;B.min.set(-t,-t,-t),B.max.set(t,t,t)}t9._initialize(e,h,_,n,a,i)},t9._setSphereData=function(e,t,r,n,a,i){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=t9._generateIndices(e.engine,s,6*l),d=Math.PI,u=2*d,h=1/o,_=1/r,f=new Float32Array(8*s),p=0;p<s;++p){var m=p%o*_,g=(p*h|0)*_,v=m*u,y=g*d,x=Math.sin(y),b=-t*Math.cos(v)*x,S=t*Math.cos(y),T=t*Math.sin(v)*x,C=8*p;f[C++]=b,f[C++]=S,f[C++]=T,f[C++]=b,f[C++]=S,f[C++]=T,f[C++]=m,f[C++]=g}for(var A=0,E=0;E<l;++E){var M=E%r,R=(E*_|0)*o+M,w=R+1,P=R+o,F=P+1;c[A++]=w,c[A++]=R,c[A++]=F,c[A++]=R,c[A++]=P,c[A++]=F}if(!a){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}t9._initialize(e,f,c,n,a,i)},t9._subdiveCatmullClark=function(e,t,r){var n=new Map,a=[];t.set(t9._sphereSeedPositions),r.set(t9._sphereSeedCells);for(var i=0;i<e;i++){var o=6*Math.pow(4,i),s=4*o+2;n.clear(),a.length=0;for(var l=0;l<o;l++){for(var c=a[l]={facePoint:new cB,adjacentEdges:[,,,,]},d=0;d<4;d++){var u=3*r[4*l+d];c.facePoint.x+=.25*t[u],c.facePoint.y+=.25*t[u+1],c.facePoint.z+=.25*t[u+2]}for(var h=0;h<4;h++){var _=r[4*l+h],f=r[4*l+(h+1)%4],p=Math.min(_,f)*s+Math.max(_,f);if(!n.has(p)){var m={edgePoint:new cB,edgePointIndex:void 0},g=3*_,v=3*f;m.edgePoint.set(.25*(t[g]+t[v]),.25*(t[g+1]+t[v+1]),.25*(t[g+2]+t[v+2])),n.set(p,m)}var y=n.get(p);c.adjacentEdges[h]=y;var x=y.edgePoint,b=c.facePoint;x.x+=.25*b.x,x.y+=.25*b.y,x.z+=.25*b.z}}var S=o+2,T=S+o,C=0;this._sphereEdgeIdx=0;for(var A=r.slice(0,4*o),E=0;E<o;E++){var M=a[E];M.facePoint.copyToArray(t,3*(S+E));for(var R=S+E,w=void 0,P=void 0,F=void 0,L=0;L<4;L++){var D=A[C++];switch(L){case 0:var B=M.adjacentEdges[L%4],I=M.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,B,T),F=w=this._calculateEdgeIndex(t,I,T);break;case 1:case 2:var V=M.adjacentEdges[L%4];w=P,P=this._calculateEdgeIndex(t,V,T);break;case 3:w=P,P=F}var O=4*(4*E+L);r[O]=D,r[O+1]=P,r[O+2]=R,r[O+3]=w}}}},t9._generateAndReplacePoleUV=function(e,t,r,n){var a=t[8*e[r]+7];if(0===a||1===a){var i=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},t9._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+t9._sphereEdgeIdx));var n=r+t9._sphereEdgeIdx++;return t.edgePointIndex=n,n},t9._setCuboidData=function(e,t,r,n,a,i,o){var s=t/2,l=r/2,c=n/2,d=new Float32Array(192);d[0]=-s,d[1]=l,d[2]=-c,d[6]=0,d[7]=0,d[8]=s,d[9]=l,d[10]=-c,d[14]=1,d[15]=0,d[16]=s,d[17]=l,d[18]=c,d[22]=1,d[23]=1,d[24]=-s,d[25]=l,d[26]=c,d[30]=0,d[31]=1;for(var u=0;u<4;u++){var h=8*u+3;d[h++]=0,d[h++]=1,d[h++]=0}d[32]=-s,d[33]=-l,d[34]=-c,d[38]=0,d[39]=1,d[40]=s,d[41]=-l,d[42]=-c,d[46]=1,d[47]=1,d[48]=s,d[49]=-l,d[50]=c,d[54]=1,d[55]=0,d[56]=-s,d[57]=-l,d[58]=c,d[62]=0,d[63]=0;for(var _=0;_<4;_++){var f=8*_+35;d[f++]=0,d[f++]=-1,d[f++]=0}d[64]=-s,d[65]=l,d[66]=-c,d[70]=0,d[71]=0,d[72]=-s,d[73]=l,d[74]=c,d[78]=1,d[79]=0,d[80]=-s,d[81]=-l,d[82]=c,d[86]=1,d[87]=1,d[88]=-s,d[89]=-l,d[90]=-c,d[94]=0,d[95]=1;for(var p=0;p<4;p++){var m=8*p+67;d[m++]=-1,d[m++]=0,d[m++]=0}d[96]=s,d[97]=l,d[98]=-c,d[102]=1,d[103]=0,d[104]=s,d[105]=l,d[106]=c,d[110]=0,d[111]=0,d[112]=s,d[113]=-l,d[114]=c,d[118]=0,d[119]=1,d[120]=s,d[121]=-l,d[122]=-c,d[126]=1,d[127]=1;for(var g=0;g<4;g++){var v=8*g+99;d[v++]=1,d[v++]=0,d[v++]=0}d[128]=-s,d[129]=l,d[130]=c,d[134]=0,d[135]=0,d[136]=s,d[137]=l,d[138]=c,d[142]=1,d[143]=0,d[144]=s,d[145]=-l,d[146]=c,d[150]=1,d[151]=1,d[152]=-s,d[153]=-l,d[154]=c,d[158]=0,d[159]=1;for(var y=0;y<4;y++){var x=8*y+131;d[x++]=0,d[x++]=0,d[x++]=1}d[160]=-s,d[161]=l,d[162]=-c,d[166]=1,d[167]=0,d[168]=s,d[169]=l,d[170]=-c,d[174]=0,d[175]=0,d[176]=s,d[177]=-l,d[178]=-c,d[182]=0,d[183]=1,d[184]=-s,d[185]=-l,d[186]=-c,d[190]=1,d[191]=1;for(var b=0;b<4;b++){var S=8*b+163;d[S++]=0,d[S++]=0,d[S++]=-1}var T=new Uint16Array(36);if(T[0]=0,T[1]=2,T[2]=1,T[3]=2,T[4]=0,T[5]=3,T[6]=4,T[7]=6,T[8]=7,T[9]=6,T[10]=4,T[11]=5,T[12]=8,T[13]=10,T[14]=9,T[15]=10,T[16]=8,T[17]=11,T[18]=12,T[19]=14,T[20]=15,T[21]=14,T[22]=12,T[23]=13,T[24]=16,T[25]=18,T[26]=17,T[27]=18,T[28]=16,T[29]=19,T[30]=20,T[31]=22,T[32]=23,T[33]=22,T[34]=20,T[35]=21,!i){var C=e.bounds;C.min.set(-s,-l,-c),C.max.set(s,l,c)}t9._initialize(e,d,T,a,i,o)},t9._setPlaneData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(a=Math.max(1,Math.floor(a)))+1,d=t/2,u=r/2,h=t/n,_=r/a,f=l*c,p=a*n,m=t9._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/a,x=new Float32Array(8*f),b=0;b<f;++b){var S=b%l,T=b*g|0,C=8*b;x[C++]=S*h-d,x[C++]=0,x[C++]=T*_-u,x[C++]=0,x[C++]=1,x[C++]=0,x[C++]=S*v,x[C++]=T*y}for(var A=0,E=0;E<p;++E){var M=E%n,R=(E*v|0)*l+M,w=R+1,P=R+l,F=P+1;m[A++]=R,m[A++]=P,m[A++]=w,m[A++]=P,m[A++]=F,m[A++]=w}if(!o){var L=e.bounds;L.min.set(-d,0,-u),L.max.set(d,0,u)}t9._initialize(e,x,m,i,o,s)},t9._setCylinderData=function(e,t,r,n,a,i,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1);for(var c=(a=Math.floor(a))+1,d=(i=Math.floor(i))+1,u=.5*n,h=n/i,_=c*d,f=a*i,p=2*a,m=_+2+p,g=t9._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*m),S=0,T=Math.PI,C=2*Math.PI,A=r-t,E=A/n,M=A/i,R=0;R<_;++R){var w=R%c,P=R*v|0,F=w*y,L=P*x,D=T+F*C,B=Math.sin(D),I=Math.cos(D),V=r-P*M,O=V*B,N=P*h-u,k=V*I,z=8*R;b[z++]=O,b[z++]=N,b[z++]=k,b[z++]=B,b[z++]=E,b[z++]=I,b[z++]=F,b[z++]=1-L}for(var U=0;U<f;++U){var G=U%a,H=(U*y|0)*c+G,W=H+1,K=H+c,j=K+1;g[S++]=W,g[S++]=K,g[S++]=H,g[S++]=W,g[S++]=j,g[S++]=K}var X=8*_;b[X++]=0,b[X++]=-u,b[X++]=0,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=.5,b[X++]=.5,b[X++]=0,b[X++]=u,b[X++]=0,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=.5,b[X++]=.5,X=(_+2)*8;for(var q=1/(2*t),Y=1/(2*r),Q=c*i,J=0;J<a;++J){var Z=8*J,$=b[Z],ee=b[Z+2];b[X++]=$,b[X++]=-u,b[X++]=ee,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=$*Y+.5,b[X++]=.5-ee*Y;var et=(J+Q)*8;$=b[et],ee=b[et+2],b[X++]=$,b[X++]=u,b[X++]=ee,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=$*q+.5,b[X++]=.5-ee*q}for(var er=_+1,en=_+2,ea=en+1,ei=0;ei<a;++ei){var eo=2*ei,es=ei===a-1?0:eo+2;g[S++]=_,g[S++]=en+es,g[S++]=en+eo,g[S++]=er,g[S++]=ea+eo,g[S++]=ea+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-u,-ec),el.max.set(ec,u,ec)}t9._initialize(e,b,g,o,s,l)},t9._setTorusData=function(e,t,r,n,a,i,o,s,l){var c=((n=Math.floor(n))+1)*((a=Math.floor(a))+1),d=n*a,u=t9._generateIndices(e.engine,c,6*d),h=new Float32Array(8*c);i=i/180*Math.PI;for(var _=0,f=t9._tempVec30,p=0;p<=n;p++)for(var m=0;m<=a;m++){var g=m/a*i,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),b=Math.sin(g),S=(t+r*y)*x,T=(t+r*y)*b,C=r*Math.sin(v);h[_++]=S,h[_++]=T,h[_++]=C;var A=t*x,E=t*b;f.set(S-A,T-E,C).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/a,h[_++]=p/n}_=0;for(var M=1;M<=n;M++)for(var R=1;R<=a;R++){var w=(a+1)*M+R-1,P=(a+1)*(M-1)+R-1,F=(a+1)*(M-1)+R,L=(a+1)*M+R;u[_++]=w,u[_++]=P,u[_++]=L,u[_++]=P,u[_++]=F,u[_++]=L}if(!s){var D=e.bounds,B=t+r;D.min.set(-B,-B,-r),D.max.set(B,B,r)}t9._initialize(e,h,u,o,s,l)},t9._setConeData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.floor(n))+1,c=(a=Math.floor(a))+1,d=.5*r,u=r/a,h=l*c,_=n*a,f=h+1+n,p=t9._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/a,y=new Float32Array(8*f),x=0,b=Math.PI,S=2*Math.PI,T=t/r,C=0;C<h;++C){var A=C%l,E=C*m|0,M=A*g,R=E*v,w=b+M*S,P=Math.sin(w),F=Math.cos(w),L=t-R*t,D=L*P,B=E*u-d,I=L*F,V=8*C;y[V++]=D,y[V++]=B,y[V++]=I,y[V++]=P,y[V++]=T,y[V++]=F,y[V++]=M,y[V++]=1-R}for(var O=0;O<_;++O){var N=O%n,k=(O*g|0)*l+N,z=k+1,U=k+l,G=U+1;p[x++]=z,p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=G,p[x++]=U}var H=8*h;y[H++]=0,y[H++]=-d,y[H++]=0,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=.5,y[H++]=.5,H=(h+1)*8;for(var W=1/(2*t),K=0;K<n;++K){var j=y[8*K],X=y[8*K+2];y[H++]=j,y[H++]=-d,y[H++]=X,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=j*W+.5,y[H++]=.5-X*W}for(var q=h+1,Y=0;Y<n;++Y){var Q=Y,J=Y===n-1?0:Q+1;p[x++]=h,p[x++]=q+J,p[x++]=q+Q}if(!o){var Z=e.bounds;Z.min.set(-t,-d,-t),Z.max.set(t,d,t)}t9._initialize(e,y,p,i,o,s)},t9._setCapsuleData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(a=Math.floor(a))+1,d=.5*r,u=r/a,h=l*c,_=n*a,f=l*l,p=n*n,m=h+2*f,g=t9._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/a,b=Math.PI,S=2*Math.PI,T=new Float32Array(8*m),C=0,A=0;A<h;++A){var E=A%l,M=A*v|0,R=E*y,w=M*x,P=b+R*S,F=Math.sin(P),L=Math.cos(P),D=8*A;T[D++]=t*F,T[D++]=M*u-d,T[D++]=t*L,T[D++]=F,T[D++]=0,T[D++]=L,T[D++]=R,T[D++]=1-w}for(var B=0;B<_;++B){var I=B%n,V=(B*y|0)*l+I,O=V+1,N=V+l,k=N+1;g[C++]=O,g[C++]=N,g[C++]=V,g[C++]=O,g[C++]=k,g[C++]=N}if(t9._createCapsuleCap(t,r,n,b,S,h,1,T,g,C),t9._createCapsuleCap(t,r,n,b,-S,h+f,-1,T,g,C+6*p),!o){var z=e.bounds;z.min.set(-t,-t-d,-t),z.max.set(t,t+d,t)}t9._initialize(e,T,g,i,o,s)},t9._initialize=function(t,r,n,a,i,o){if(i)o.setData(r),t.setIndices(n),t.uploadData(a);else{var s=[new d1(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new d1(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new d1(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new dq(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(a),t.addSubMesh(0,n.length)}},t9._generateIndices=function(t,r,n){var a=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))a=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(n);return a},t9._createCapsuleCap=function(e,t,r,n,a,i,o,s,l,c){for(var d=r+1,u=.5*t*o,h=d*d,_=r*r,f=1/d,p=1/r,m=0;m<h;++m){var g=m%d*p,v=(m*f|0)*p,y=n+g*a,x=v*Math.PI*.5,b=Math.sin(x),S=e*Math.sin(y)*b,T=e*Math.cos(x)*o+u,C=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=S,s[A++]=T,s[A++]=C,s[A++]=S,s[A++]=T-u,s[A++]=C,s[A++]=g,s[A++]=v}for(var E=0;E<_;++E){var M=E%r,R=(E*p|0)*d+M+i,w=R+1,P=R+d,F=P+1;l[c++]=w,l[c++]=R,l[c++]=F,l[c++]=R,l[c++]=P,l[c++]=F}},t9);uf._tempVec30=new cB,uf._sphereSeedPositions=new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1]),uf._sphereSeedCells=new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1]),uf._sphereEdgeIdx=0,uf._spherePoleIdx=0,e.Layer=void 0,(t6=e.Layer||(e.Layer={}))[t6.Layer0=1]="Layer0",t6[t6.Layer1=2]="Layer1",t6[t6.Layer2=4]="Layer2",t6[t6.Layer3=8]="Layer3",t6[t6.Layer4=16]="Layer4",t6[t6.Layer5=32]="Layer5",t6[t6.Layer6=64]="Layer6",t6[t6.Layer7=128]="Layer7",t6[t6.Layer8=256]="Layer8",t6[t6.Layer9=512]="Layer9",t6[t6.Layer10=1024]="Layer10",t6[t6.Layer11=2048]="Layer11",t6[t6.Layer12=4096]="Layer12",t6[t6.Layer13=8192]="Layer13",t6[t6.Layer14=16384]="Layer14",t6[t6.Layer15=32768]="Layer15",t6[t6.Layer16=65536]="Layer16",t6[t6.Layer17=131072]="Layer17",t6[t6.Layer18=262144]="Layer18",t6[t6.Layer19=524288]="Layer19",t6[t6.Layer20=1048576]="Layer20",t6[t6.Layer21=2097152]="Layer21",t6[t6.Layer22=4194304]="Layer22",t6[t6.Layer23=8388608]="Layer23",t6[t6.Layer24=16777216]="Layer24",t6[t6.Layer25=33554432]="Layer25",t6[t6.Layer26=67108864]="Layer26",t6[t6.Layer27=134217728]="Layer27",t6[t6.Layer28=268435456]="Layer28",t6[t6.Layer29=536870912]="Layer29",t6[t6.Layer30=1073741824]="Layer30",t6[t6.Layer31=2147483648]="Layer31",t6[t6.Everything=4294967295]="Everything",t6[t6.Nothing=0]="Nothing";var up=((t7=function(){}).cloneComponent=function(e,t,r,n,a){var i=c9.getCloneMode(e.constructor);for(var o in e)c9.cloneProperty(e,t,o,i[o],r,n,a);e._cloneTo&&e._cloneTo(t,r,n)},t7),um=(c0(re=function(t,r){var n;return(n=c6.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new dX,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._isTemplate=!1,n._parent=null,n._invModelMatrix=new cG,n.name=r,n.transform=n.addComponent(db),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},c6),(rt=re.prototype).addComponent=function(e){dv._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0,l0.All),t},rt.getComponent=function(e){for(var t=this._components,r=0,n=t.length;r<n;r++){var a=t[r];if(c2(a,e))return a}return null},rt.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];c2(i,e)&&t.push(i)}return t},rt.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},rt.addChild=function(e,t){var r;if("number"==typeof e?r=e:(r=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(r,t),t._parent=this;var n=t._scene,a=this._scene,i=l0.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=l0.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==a&&(i|=l0.Scene):i|=l0.Scene),i&&t._processInActive(i),t._scene!==a&&re._traverseSetOwnerScene(t,a);var o=l0.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=l0.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===a||(o|=l0.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},rt.removeChild=function(e){e._setParent(null)},rt.getChild=function(e){return this._children[e]},rt.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},rt.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,a=t.length;n<a;++n){var i=t[n];if(i&&!(r=re._findChildByName(r,i)))return null}return r},rt.createChild=function(e){var t=new re(this.engine,e);return t.layer=this.layer,t.parent=this,t},rt.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=l0.None;r._isActiveInHierarchy&&(n|=l0.Hierarchy),r._isActiveInScene&&(n|=l0.Scene),n&&r._processInActive(n),re._traverseSetOwnerScene(r,null)}e.length=0},rt.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e,new Map),e},rt._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},rt._createCloneEntity=function(e){var t=new re(e._engine,e.name),r=this._templateResource;r&&(t._templateResource=r,r._addReferCount(1)),t.layer=e.layer,t._isActive=e._isActive;var n=t.transform,a=e.transform;n.position=a.position,n.rotation=a.rotation,n.scale=a.scale;for(var i=e._children,o=0,s=e._children.length;o<s;o++)t.addChild(this._createCloneEntity(i[o]));return t},rt._parseCloneEntity=function(e,t,r,n,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],r,n,a);for(var c=e._components,d=0,u=c.length;d<u;d++){var h=c[d];if(!c2(h,db)){var _=t.addComponent(h.constructor);up.cloneComponent(h,_,r,n,a)}}},rt.destroy=function(){if(!this._destroyed){c6.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},rt._removeComponent=function(e){dv._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},rt._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},rt._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},rt._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,r=this._siblingIndex;t.splice(r,1);for(var n=t.length;r<n;r++)t[r]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},rt._processActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!0,e)},rt._processInActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!1,e)},rt._addToChildrenList=function(e,t){var r=this._children,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},rt._setParent=function(e,t){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var n=this._scene,a=e._scene,i=l0.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=l0.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==a&&(i|=l0.Scene):this._isActiveInScene&&(i|=l0.Scene),i&&this._processInActive(i),n!==a&&re._traverseSetOwnerScene(this,a);var o=l0.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=l0.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===a||(o|=l0.Scene))),o&&this._processActive(o)}else{var s=l0.None;this._isActiveInHierarchy&&(s|=l0.Hierarchy),this._isActiveInScene&&(s|=l0.Scene),s&&this._processInActive(s),r&&re._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},rt._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];c2(n,e)&&t.push(n)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},rt._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,a=r.length;n<a;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},rt._setActiveInHierarchy=function(e,t){t&l0.Hierarchy&&(this._isActiveInHierarchy=!0),t&l0.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},rt._setInActiveInHierarchy=function(e,t){t&l0.Hierarchy&&(this._isActiveInHierarchy=!1),t&l0.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},rt._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},rt._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var r=this._siblingIndex;if(t<r)for(var n=r;n>=t;n--){var a=n==t?this:e[n-1];e[n]=a,a._siblingIndex=n}else for(var i=r;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},rt.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(cG.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},re._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var a=r[n];if(a.name===t)return a}return null},re._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},re._getEntityHierarchyPath=function(e,t,r){for(r.length=0;t!==e;){var n=t.parent;if(!n)return!1;r.push(t.siblingIndex),t=n}return!0},re._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},cZ(re,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=l0.None;this._isRoot&&this._scene._isActiveInEngine?r|=l0.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=l0.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=l0.Scene)),r&&this._processActive(r)}else{var n=l0.None;this._isActiveInHierarchy&&(n|=l0.Hierarchy),this._isActiveInScene&&(n|=l0.Scene),n&&this._processInActive(n)}}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(-1===this._siblingIndex)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),re),ug=(c0(rr=function(e){var t;return(t=c6.call(this,null)||this).name=e,t.inverseBindMatrices=[],t._updatedManager=new di,t._bones=[],t._updateMark=-1,t.joints=[],t},c6),(rn=rr.prototype)._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,r=this.bones,n=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=r.length-1;o>=0;o--){var s=r[o],l=16*o;s?dt._floatMatrixMultiply(s.transform.worldMatrix,n[o].elements,0,a,l):a.set(n[o].elements,l),dt._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},rn._cloneTo=function(e,t,r){var n=[],a=this.rootBone;if(a){var i=um._getEntityHierarchyPath(t,a,n);e.rootBone=i?um._getEntityByHierarchyPath(r,n):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var d=o[c],u=um._getEntityHierarchyPath(t,d,n);l[c]=u?um._getEntityByHierarchyPath(r,n):d}e.bones=l}},cZ(rr,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,r=this._bones,n=null!=(t=null==e?void 0:e.length)?t:0,a=r.length;r.length=n;for(var i=0;i<n;i++)r[i]=e[i];a!==n&&(this._skinMatrices=new Float32Array(16*n),this._updatedManager.dispatch(0,n))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),rr);c1([c5],ug.prototype,"inverseBindMatrices",void 0),c1([c3],ug.prototype,"_skinMatrices",void 0),c1([c3],ug.prototype,"_updatedManager",void 0),c1([c3],ug.prototype,"_rootBone",void 0),c1([c3],ug.prototype,"_bones",void 0),c1([c3],ug.prototype,"_updateMark",void 0),(ra=ce||(ce={}))[ra.BoneCountChanged=0]="BoneCountChanged",ra[ra.RootBoneChanged=1]="RootBoneChanged";var uv=(c0(ri=function(e){(t=d8.call(this,e)||this)._localBounds=new cV,t._jointDataCreateCache=new cW(-1,-1),t._skin=null;var t,r=t.entity.engine._hardwareRenderer,n=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);n=Math.min(n,r._options._maxAllowSkinUniformVectorCount),t._maxVertexUniformVectors=n,t._onLocalBoundsChanged=t._onLocalBoundsChanged.bind(cQ(t)),t._onSkinUpdated=t._onSkinUpdated.bind(cQ(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},d8),(ro=ri.prototype).update=function(){var e=this._skin;(null==e?void 0:e.bones.length)>0&&e._updateSkinMatrices(this)},ro._updateShaderData=function(t,r){var n=this.entity,a=this.skin,i=(null!=(_=null==a?void 0:a.rootBone)?_:n).transform.worldMatrix;if(r){this._updateMVPShaderData(t,i);return}this._updateTransformShaderData(t,i);var o=this.shaderData,s=this.mesh._blendShapeManager;s._updateShaderData(o,this);var l=null==a?void 0:a.bones;if(l){var c=s._uniformOccupiesCount,d=l.length,u=this._jointDataCreateCache,h=d!==u.x;if(h||c!==u.y){var _,f,p=Math.ceil((this._maxVertexUniformVectors-(44+c))/4);if(d>p){var m,g=this.engine;g._hardwareRenderer.canIUseMoreJoints?(h&&(null==(m=this._jointTexture)||m.destroy(),this._jointTexture=new d9(g,4,d,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),o.disableMacro("RENDERER_JOINTS_NUM"),o.enableMacro("RENDERER_USE_JOINT_TEXTURE"),o.setTexture(ri._jointSamplerProperty,this._jointTexture)):df.error("component's joints count("+d+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+p+".",this)}else null==(f=this._jointTexture)||f.destroy(),o.disableMacro("RENDERER_USE_JOINT_TEXTURE"),o.enableMacro("RENDERER_JOINTS_NUM",p.toString()),o.setFloatArray(ri._jointMatrixProperty,a._skinMatrices);u.set(d,c)}this._jointTexture&&this._jointTexture.setPixelBuffer(a._skinMatrices)}var v=n.layer;this._rendererLayer.set(65535&v,v>>>16&65535,0,0)},ro._onDestroy=function(){var e;d8.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null},ro._cloneTo=function(e,t,r){d8.prototype._cloneTo.call(this,e,t,r),this.skin&&e._applySkin(null,e.skin),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},ro._updateBounds=function(e){var t,r=null==(t=this.skin)?void 0:t.rootBone;r?cV.transform(this._localBounds,r.transform.worldMatrix,e):d8.prototype._updateBounds.call(this,e)},ro._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var a=new Float32Array(t);if(t>n)a.set(r);else for(var i=0;i<t;i++)a[i]=r[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},ro._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=l3.WorldVolume},ro._onSkinUpdated=function(e,t){switch(e){case ce.BoneCountChanged:var r=this.shaderData;t>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(ri._jointCountProperty,t)):r.disableMacro("RENDERER_HAS_SKIN");break;case ce.RootBoneChanged:this._dirtyUpdateFlag|=l3.WorldVolume}},ro._applySkin=function(e,t){var r,n,a,i,o,s,l=null!=(a=null==e?void 0:null==(r=e.bones)?void 0:r.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var d=null!=(o=null==t?void 0:null==(n=t.bones)?void 0:n.length)?o:0,u=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==d&&this._onSkinUpdated(ce.BoneCountChanged,d),c!==u&&this._onSkinUpdated(ce.RootBoneChanged,u)},cZ(ri,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var r=0,n=t.length;r<n;r++)t[r]=e[r]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),ri);uv._jointCountProperty=dp.getByName("renderer_JointCount"),uv._jointSamplerProperty=dp.getByName("renderer_JointSampler"),uv._jointMatrixProperty=dp.getByName("renderer_JointMatrix"),c1([c3],uv.prototype,"_condensedBlendShapeWeights",void 0),c1([c5],uv.prototype,"_localBounds",void 0),c1([c3],uv.prototype,"_jointDataCreateCache",void 0),c1([c3],uv.prototype,"_blendShapeWeights",void 0),c1([c3],uv.prototype,"_maxVertexUniformVectors",void 0),c1([c3],uv.prototype,"_jointTexture",void 0),c1([c5],uv.prototype,"_skin",void 0),c1([c3],uv.prototype,"_onLocalBoundsChanged",null),c1([c3],uv.prototype,"_onSkinUpdated",null);var uy=((rl=(rs=function(e){this._elementPoolIndex=0,this._elementPool=[],this._type=e}).prototype).getFromPool=function(){var e=this._elementPoolIndex,t=this._elementPool;if(this._elementPoolIndex++,t.length!==e)return t[e];var r=new this._type;return t.push(r),r},rl.resetPool=function(){this._elementPoolIndex=0},rl.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},rs),ux=((rd=(rc=function(e){this._subMeshPool=new uy(dJ),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=e,this._initMeshes(e)}).prototype).drawElement=function(e,t){var r=e.data;if(r.multiRenderData)for(var n=r.charsData,a=t.engine._renderElementPool,i=0,o=n.length;i<o;++i){var s=a.getFromPool();s.set(n[i],e.shaderPasses),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},rd._initMeshes=function(e){var t=rc.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var r=this._meshes,n=this._meshCount,a=0;a<n;a++)r[a]=this._createMesh(e,a)},rd.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rc._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},rd.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},rd.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,a=e.length;n<a;++n){var i=e[n];i._addReferCount(-1),i.destroy()}this._meshes=null;for(var o=0,s=t.length;o<s;++o)t[o].destroy();this._vertexBuffers=null;for(var l=0,c=r.length;l<c;++l)r[l].destroy();this._indiceBuffers=null},rd._drawSubElement=function(e,t){var r=e.data.verticesData.vertexCount;this._vertexCount+r>rc.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=e},rd._createMesh=function(t,r){var n=rc.MAX_VERTEX_COUNT,a=new d4(t,"BufferMesh"+r);a._addReferCount(1);var i=[],o=this.createVertexElements(i),s=this._vertexBuffers[r]=new dq(t,e.BufferBindFlag.VertexBuffer,n*o,e.BufferUsage.Dynamic),l=this._indiceBuffers[r]=new dq(t,e.BufferBindFlag.IndexBuffer,6*n,e.BufferUsage.Dynamic);return a.setVertexBufferBinding(s,o),a.setIndexBufferBinding(l,e.IndexFormat.UInt16),a.setVertexElements(i),a},rd._updateData=function(t){var r=this._meshes,n=this._flushId;!rc._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,r[n]=this._createMesh(t,n));var a=this._batchedQueue,i=this._vertices,o=this._indices,s=r[n];s.clearSubMesh();for(var l=0,c=0,d=0,u=0,h=0,_=0,f=null,p=0,m=a.length;p<m;p++){var g=a[p],v=g.data;l=this.updateVertices(v,i,l);for(var y=v.verticesData.triangles,x=y.length,b=0;b<x;b++)o[c++]=y[b]+h;h+=v.verticesData.vertexCount,null===f?u+=x:this.canBatch(f,g)?u+=x:(s.addSubMesh(this._getSubMeshFromPool(d,u)),d+=u,u=x,a[_++]=f),f=g}s.addSubMesh(this._getSubMeshFromPool(d,u)),a[_]=f,this._vertexBuffers[n].setData(i,0,0,l,e.SetDataOptions.Discard),this._indiceBuffers[n].setData(o,0,0,c,e.SetDataOptions.Discard)},rd._getSubMeshFromPool=function(t,r){var n=this._subMeshPool.getFromPool();return n.start=t,n.count=r,n.topology=e.MeshTopology.Triangles,n},rc);ux._disableBatchTag=dM.getByName("spriteDisableBatching"),ux.MAX_VERTEX_COUNT=4096,ux._canUploadSameBuffer=!0;var ub=((ru=function(){}).resetData=function(e){e._verticesData.triangles=[]},ru.updatePositions=function(t){var r,n,a,i,o,s,l=t.width,c=t.height,d=t.sprite,u=t.tileMode,h=t.tiledAdaptiveThreshold,_=t._verticesData,f=_.positions,p=_.uvs,m=_.triangles,g=this._posRow,v=this._posColumn,y=this._uvRow,x=this._uvColumn;g.length=v.length=y.length=x.length=0,u===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(d,l,c,h,g,v,y,x):this._calculateContinuousDividing(d,l,c,g,v,y,x);var b=t.sprite.pivot,S=b.x,T=b.y,C=t.width*S,A=t.height*T,E=ub._worldMatrix,M=E.elements,R=t.entity.transform.worldMatrix.elements,w=t.flipX?-1:1,P=t.flipY?-1:1;r=M[0]=R[0]*w,n=M[1]=R[1]*w,a=M[2]=R[2]*w,i=M[4]=R[4]*P,o=M[5]=R[5]*P,s=M[6]=R[6]*P,M[8]=R[8],M[9]=R[9],M[10]=R[10];for(var F=M[12]=R[12]-C*M[0]-A*M[4],L=M[13]=R[13]-C*M[1]-A*M[5],D=M[14]=R[14]-C*M[2]-A*M[6],B=g.length-1,I=v.length-1,V=0,O=0,N=0;N<I;N++)for(var k=2*N,z=0;z<B;z++){var U=y.get(2*z),G=x.get(k),H=y.get(2*z+1),W=x.get(k+1);if(!(isNaN(U)||isNaN(U)||isNaN(H)||isNaN(W))){m[O++]=V,m[O++]=V+1,m[O++]=V+2,m[O++]=V+2,m[O++]=V+1,m[O++]=V+3;var K=g.get(z),j=v.get(N),X=g.get(z+1),q=v.get(N+1);p[V]?p[V].set(U,G):p[V]=new cW(U,G);var Y=f[V];Y?Y.set(r*K+i*j+F,n*K+o*j+L,a*K+s*j+D):f[V]=new cB(r*K+i*j+F,n*K+o*j+L,a*K+s*j+D),p[++V]?p[V].set(H,G):p[V]=new cW(H,G),(Y=f[V])?Y.set(r*X+i*j+F,n*X+o*j+L,a*X+s*j+D):f[V]=new cB(r*X+i*j+F,n*X+o*j+L,a*X+s*j+D),p[++V]?p[V].set(U,W):p[V]=new cW(U,W),(Y=f[V])?Y.set(r*K+i*q+F,n*K+o*q+L,a*K+s*q+D):f[V]=new cB(r*K+i*q+F,n*K+o*q+L,a*K+s*q+D),p[++V]?p[V].set(H,W):p[V]=new cW(H,W),(Y=f[V])?Y.set(r*X+i*q+F,n*X+o*q+L,a*X+s*q+D):f[V]=new cB(r*X+i*q+F,n*X+o*q+L,a*X+s*q+D),V++}}t._verticesData.vertexCount=V,m.length=O;var Q=t._bounds,J=Q.min,Z=Q.max;J.set(g.get(0),v.get(0),0),Z.set(g.get(B),v.get(I),0),t._bounds.transform(E)},ru.updateUVs=function(e){},ru._calculateAdaptiveDividing=function(e,t,r,n,a,i,o,s){var l,c,d,u,h,_,f,p=e.border,m=e._getPositions(),g=m[0],v=g.x,y=g.y,x=m[3],b=x.x,S=x.y,T=e._getUVs(),C=T[0],A=T[1],E=T[2],M=T[3],R=e.width,w=e.height,P=R*p.x,F=R*p.z,L=P+F,D=R-L,B=w*p.w,I=w*p.y,V=B+I,O=w-V;if(L>=t?(u=3,c=0):D>cD.zeroTolerance?(u=4+(_=(_=(t-L)/D)%1>=n?Math.ceil(_):Math.floor(_))-1,c=2):(u=4,c=1),V>=r?(h=3,d=0):O>cD.zeroTolerance?(h=4+(f=(f=(r-V)/O)%1>=n?Math.ceil(f):Math.floor(f))-1,d=2):(h=4,d=1),(u-1)*(h-1)*4>ux.MAX_VERTEX_COUNT){a.add(t*v),a.add(t*b),i.add(r*y),i.add(r*S),o.add(C.x),o.add(M.x),s.add(C.y),s.add(M.y),df.warn("The number of vertices exceeds the upper limit("+ux.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,a.add(R*v*l),a.add(P*l),a.add(t-R*(1-b)*l),o.add(C.x),o.add(A.x),o.add(E.x),o.add(M.x);break;case 1:a.add(R*v),a.add(P),a.add(t-F),a.add(t-R*(1-b)),o.add(C.x),o.add(A.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(M.x);break;case 2:l=t/(L+_*D),a.add(R*v*l),a.add(P*l),o.add(C.x),o.add(A.x),o.add(A.x);for(var N=0,k=_-1;N<k;N++)a.add(P+(N+1)*D*l),o.add(E.x),o.add(A.x);a.add(t-F*l),a.add(t-R*(1-b)*l),o.add(E.x),o.add(E.x),o.add(M.x)}switch(d){case 0:l=r/V,i.add(w*y*l),i.add(I*l),i.add(r-w*(1-S)*l),s.add(C.y),s.add(A.y),s.add(E.y),s.add(M.y);break;case 1:i.add(w*y),i.add(I),i.add(r-B),i.add(r-w*(1-S)),s.add(C.y),s.add(A.y),s.add(NaN),s.add(NaN),s.add(E.y),s.add(M.y);break;case 2:l=r/(V+f*O),i.add(w*y*l),i.add(I*l),s.add(C.y),s.add(A.y),s.add(A.y);for(var z=0,U=f-1;z<U;z++)i.add(I+(z+1)*O*l),s.add(E.y),s.add(A.y);i.add(r-B*l),i.add(r-w*(1-S)*l),s.add(E.y),s.add(E.y),s.add(M.y)}},ru._calculateContinuousDividing=function(e,t,r,n,a,i,o){var s,l,c,d,u,h,_=e.border,f=e._getPositions(),p=f[0],m=p.x,g=p.y,v=f[3],y=v.x,x=v.y,b=e._getUVs(),S=b[0],T=b[1],C=b[2],A=b[3],E=e.width,M=e.height,R=E*_.x,w=E*_.z,P=R+w,F=E-P,L=M*_.w,D=M*_.y,B=L+D,I=M-B;if(P>=t?(c=3,s=0):F>cD.zeroTolerance?(c=4+(0|(u=(t-P)/F)),s=2):(c=4,s=1),B>=r?(d=3,l=0):I>cD.zeroTolerance?(d=4+(0|(h=(r-B)/I)),l=2):(d=4,l=1),(c-1)*(d-1)*4>ux.MAX_VERTEX_COUNT){n.add(t*m),n.add(t*y),a.add(r*g),a.add(r*x),i.add(S.x),i.add(A.x),o.add(S.y),o.add(A.y),df.warn("The number of vertices exceeds the upper limit("+ux.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var V=t/P;n.add(E*m*V),n.add(R*V),n.add(t-E*(1-y)*V),i.add(S.x),i.add(T.x),i.add(C.x),i.add(A.x);break;case 1:n.add(E*m),n.add(R),n.add(t-w),n.add(t-E*(1-y)),i.add(S.x),i.add(T.x),i.add(NaN),i.add(NaN),i.add(C.x),i.add(A.x);break;case 2:n.add(E*m),n.add(R),i.add(S.x),i.add(T.x),i.add(T.x);for(var O=0|u,N=0;N<O;N++)n.add(R+(N+1)*F),i.add(C.x),i.add(T.x);n.add(t-w),n.add(t-E*(1-y)),i.add((C.x-T.x)*(u-O)+T.x),i.add(C.x),i.add(A.x)}switch(l){case 0:var k=r/B;a.add(M*g*k),a.add(D*k),a.add(r-M*(1-x)*k),o.add(S.y),o.add(T.y),o.add(C.y),o.add(A.y);break;case 1:a.add(M*g),a.add(D),a.add(r-L),a.add(r-M*(1-x)),o.add(S.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(C.y),o.add(A.y);break;case 2:a.add(M*g),a.add(D),o.add(S.y),o.add(T.y),o.add(T.y);for(var z=0|h,U=0;U<z;U++)a.add(D+(U+1)*I),o.add(C.y),o.add(T.y);a.add(r-L),a.add(r-M*(1-x)),o.add((C.y-T.y)*(h-z)+T.y),o.add(C.y),o.add(A.y)}},ru._worldMatrix=new cG,ru._posRow=new dX,ru._posColumn=new dX,ru._uvRow=new dX,ru._uvColumn=new dX,ru);ub=c1([dW()],ub),(rh=ct||(ct={}))[rh.Compressed=0]="Compressed",rh[rh.WithoutTiled=1]="WithoutTiled",rh[rh.WithTiled=2]="WithTiled";var uS=function(e,t,r,n,a){void 0===n&&(n=null),void 0===a&&(a=null),this.vertexCount=e,this.positions=t,this.uvs=r,this.triangles=n,this.color=a},uT=(r_=e.Renderer,c0(rf=function(t){var r;return(r=r_.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new cj(1,1,1,1),r._sprite=null,r._automaticWidth=0,r._automaticHeight=0,r._customWidth=void 0,r._customHeight=void 0,r._flipX=!1,r._flipY=!1,r._maskLayer=e.SpriteMaskLayer.Layer0,r._maskInteraction=e.SpriteMaskInteraction.None,r._verticesData=new uS(4,[],[],null,r._color),r.drawMode=e.SpriteDrawMode.Simple,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(cQ(r)),r},r_),(rp=rf.prototype)._cloneTo=function(e,t,r){r_.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},rp._updateShaderData=function(e,t){if(t){this._updateMVPShaderData(e,cG._identity);return}this._updateTransformShaderData(e,cG._identity)},rp._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},rp._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,r=this.getMaterial();if(r){r.destroyed&&(r=this._engine._spriteDefaultMaterials[this._maskInteraction]),this._dirtyUpdateFlag&l3.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~l3.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var n=this.sprite.texture,a=this._engine._spriteRenderDataPool.getFromPool();a.set(this,r,this._verticesData,n),e.camera._renderPipeline.pushRenderData(e,a)}}},rp._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),r_.prototype._onDestroy.call(this),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},rp._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},rp._updateStencilState=function(t,r){var n=this.getMaterial(),a=this._engine._spriteDefaultMaterials;if(n===a[t])this.setMaterial(a[r]);else{var i=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(i.enabled=!1,i.writeMask=255,i.referenceValue=0,i.compareFunctionFront=i.compareFunctionBack=e.CompareFunction.Always):(i.enabled=!0,i.writeMask=0,i.referenceValue=1,i.compareFunctionFront=i.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},rp._onSpriteChange=function(t){switch(t){case lZ.texture:this.shaderData.setTexture(rf._textureProperty,this.sprite.texture);break;case lZ.size:var r=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=l3.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=l3.WorldVolume);break;case lZ.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case lZ.region:case lZ.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lZ.atlasRegion:this._dirtyUpdateFlag|=2;break;case lZ.pivot:this._dirtyUpdateFlag|=l3.WorldVolume;break;case lZ.destroy:this.sprite=null}},cZ(rf,[{key:"drawMode",get:function(){return this._drawMode},set:function(t){if(this._drawMode!==t){switch(this._drawMode=t,t){case e.SpriteDrawMode.Simple:this._assembler=dK;break;case e.SpriteDrawMode.Sliced:this._assembler=dj;break;case e.SpriteDrawMode.Tiled:this._assembler=ub}this._assembler.resetData(this),this._dirtyUpdateFlag|=3}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=cD.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(rf._textureProperty,e.texture)):this.shaderData.setTexture(rf._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._updateStencilState(this._maskInteraction,e),this._maskInteraction=e)}}]),rf);uT._textureProperty=dp.getByName("renderer_SpriteTexture"),c1([c3],uT.prototype,"_verticesData",void 0),c1([c3],uT.prototype,"_drawMode",void 0),c1([c4],uT.prototype,"_assembler",void 0),c1([c4],uT.prototype,"_tileMode",void 0),c1([c4],uT.prototype,"_tiledAdaptiveThreshold",void 0),c1([c5],uT.prototype,"_color",void 0),c1([c3],uT.prototype,"_sprite",void 0),c1([c3],uT.prototype,"_automaticWidth",void 0),c1([c3],uT.prototype,"_automaticHeight",void 0),c1([c4],uT.prototype,"_customWidth",void 0),c1([c4],uT.prototype,"_customHeight",void 0),c1([c4],uT.prototype,"_flipX",void 0),c1([c4],uT.prototype,"_flipY",void 0),c1([c4],uT.prototype,"_maskLayer",void 0),c1([c4],uT.prototype,"_maskInteraction",void 0),c1([c3],uT.prototype,"_onSpriteChange",null),(rm=cr||(cr={}))[rm.UV=2]="UV",rm[rm.RenderData=3]="RenderData",rm[rm.AutomaticSize=4]="AutomaticSize",rm[rm.All=7]="All";var uC=function(t){function r(n){var a;return(a=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,a._sprite=null,a._automaticWidth=0,a._automaticHeight=0,a._customWidth=void 0,a._customHeight=void 0,a._flipX=!1,a._flipY=!1,a._alphaCutoff=.5,a._verticesData=new uS(4,[],[]),dK.resetData(cQ(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(r._alphaCutoffProperty,a._alphaCutoff),a._onSpriteChange=a._onSpriteChange.bind(cQ(a)),a}c0(r,t);var n=r.prototype;return n._cloneTo=function(e,r,n){t.prototype._cloneTo.call(this,e,r,n),e.sprite=this._sprite},n._updateBounds=function(e){this.sprite?dK.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,r=this.getMaterial();if(r){var n=this._engine;r.destroyed&&(r=n._spriteMaskDefaultMaterial),this._dirtyUpdateFlag&l3.WorldVolume&&(dK.updatePositions(this),this._dirtyUpdateFlag&=~l3.WorldVolume),2&this._dirtyUpdateFlag&&(dK.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var a=n._spriteMaskRenderDataPool.getFromPool();a.set(this,r,this._verticesData);var i=n._renderElementPool.getFromPool();i.set(a,r.shader.subShaders[0].passes),this._maskElement=i}}},n._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),t.prototype._onDestroy.call(this),this._sprite=null,this._verticesData=null},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},n._onSpriteChange=function(e){switch(e){case lZ.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case lZ.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=l3.WorldVolume);break;case lZ.region:case lZ.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lZ.atlasRegion:this._dirtyUpdateFlag|=2;break;case lZ.pivot:this._dirtyUpdateFlag|=l3.WorldVolume;break;case lZ.destroy:this.sprite=null}},cZ(r,[{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=l3.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(r._textureProperty,e.texture)):this.shaderData.setTexture(r._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(r._alphaCutoffProperty,e))}}]),r}(e.Renderer);uC._textureProperty=dp.getByName("renderer_MaskTexture"),uC._alphaCutoffProperty=dp.getByName("renderer_MaskAlphaCutoff"),c1([c4],uC.prototype,"influenceLayers",void 0),c1([c3],uC.prototype,"_verticesData",void 0),c1([c3],uC.prototype,"_sprite",void 0),c1([c3],uC.prototype,"_automaticWidth",void 0),c1([c3],uC.prototype,"_automaticHeight",void 0),c1([c4],uC.prototype,"_customWidth",void 0),c1([c4],uC.prototype,"_customHeight",void 0),c1([c4],uC.prototype,"_flipX",void 0),c1([c4],uC.prototype,"_flipY",void 0),c1([c4],uC.prototype,"_alphaCutoff",void 0),c1([c3],uC.prototype,"_onSpriteChange",null),(rg=cn||(cn={}))[rg.UV=2]="UV",rg[rg.RenderData=3]="RenderData",rg[rg.AutomaticSize=4]="AutomaticSize",rg[rg.All=7]="All";var uA=(c0(rv=function(e){var t;return(t=c7.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},c7),(ry=rv.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=r+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new cW(this._curX,this._curY),i.setPixelBuffer(n,0,this._curX,this._curY,t,r),i.generateMipmaps());var d=1/o,u=this._curX,h=this._curY,_=u*d,f=(u+t)*d,p=h*d,m=(h+r)*d;e.x=u,e.y=h;var g=e.uvs;return g[0].set(_,p),g[1].set(f,p),g[2].set(f,m),g[3].set(_,m),this._curX+=s+a,!0},ry.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},ry.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},ry._onDestroy=function(){c7.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},rv),uE=((rx=function(){}).textContext=function(){var e=rx._textContext;if(!e){try{t=new OffscreenCanvas(0,0)}catch(e){t=document.createElement("canvas")}var t,r=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,context:r},rx._textContext=e}return e},rx.measureFont=function(e){var t=rx._fontSizeInfoCache,r=t[e];return r||(r=rx._measureFontOrChar(e),t[e]=r),r},rx.getNativeFontString=function(t,r,n){var a=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rx._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=r+"px "+t},rx.measureChar=function(e,t){return rx._measureFontOrChar(t,e)},rx.measureTextWithWrap=function(t){var r=t._subFont,n=r.nativeFontString,a=rx.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=hS._pixelsPerUnit,d=a.size+t.lineSpacing*c,u=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,S=0,T=0,C=!1,A=0,E=p.length;A<E;++A){var M=p[A],R=rx._getCharInfo(M,n,r),w=M.charCodeAt(0),P=32===w;if(!P||!C||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=R.w,D=R.offsetY,B=.5*R.h,I=B+D,V=B-D;F?(m.length>0&&(b+g>u?(b>0&&this._pushLine(o,s,l,x,b,S,T),h=Math.max(h,b),C=!0,x=m,b=g,S=v,T=y):(x+=m,b+=g,S=Math.max(S,v),T=Math.max(T,y)),m="",g=v=y=0),b+L>u&&b>0?(this._pushLine(o,s,l,x,b,S,T),h=Math.max(h,b),C=!0,P?(x="",b=S=T=0):(x=M,b=R.xAdvance,S=I,T=V)):(x+=M,b+=R.xAdvance,S=Math.max(S,I),T=Math.max(T,V))):g+R.w>u?(b>0&&(this._pushLine(o,s,l,x,b,S,T),h=Math.max(h,b),x="",b=S=T=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),C=!0,m=M,g=R.xAdvance,v=I,y=V):(m+=M,g+=R.xAdvance,v=Math.max(v,I),y=Math.max(y,V))}}g>0&&(b+g>u?(b>0&&this._pushLine(o,s,l,x,b,S,T),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,S=Math.max(S,v),T=Math.max(T,y))),b>0&&(this._pushLine(o,s,l,x,b,S,T),h=Math.max(h,b))}var O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=d*o.length),{width:h,height:O,lines:o,lineWidths:s,lineHeight:d,lineMaxSizes:l}},rx.measureTextWithoutWrap=function(t){var r=t._subFont,n=r.nativeFontString,a=rx.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],d=hS._pixelsPerUnit,u=a.size+t.lineSpacing*d,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=rx._getCharInfo(f[v],n,r);p+=x.xAdvance;var b=x.offsetY,S=.5*x.h,T=S+b,C=S-b;m<T&&(m=T),g<C&&(g=C)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*d;return t.overflowMode===e.OverflowMode.Overflow&&(A=u*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:u,lineMaxSizes:c}},rx.getNativeFontHash=function(t,r,n){var a=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rx._genericFontFamilies.indexOf(t)||(t=""+t),a+=r+"px"+t},rx._measureFontOrChar=function(e,t){void 0===t&&(t="");var r,n=rx.textContext(),a=n.canvas,i=n.context;i.font=e;var o=t||rx._measureString,s=Math.max(1,Math.round(i.measureText(o).width)),l=Math.ceil(i.measureText(rx._measureBaseline).width),c=l*rx._heightMultiplier;l=rx._baselineMultiplier*l|0;var d=rx._extendHeight;c+=d,l+=.5*d,a.width=s,a.height=c,i.font=e,i.fillStyle="#000",i.clearRect(0,0,s,c),i.textBaseline="middle",i.fillStyle="#fff",i.fillText(o,0,l);for(var u=i.getImageData(0,0,s,c).data,h=u.length,_=-1,f=-1,p=0,m=0,g=0,v=a.width,y=1/v,x=0;x<h;x+=4)0!==u[x+3]?(r=~~(.25*x*y),-1===_&&(_=r),r>f&&(f=r)):u[x]=u[x+1]=u[x+2]=255;-1!==_&&-1!==f&&(g=(p=l-_)+(m=f-l+1));var b={ascent:p,descent:m,size:g};if(!t)return b;var S=null;if(g>0){var T=4*v;S=new Uint8Array(u.buffer,_*T,g*T)}return{char:t,x:0,y:0,w:s,h:g,offsetX:0,offsetY:(p-m)*.5,xAdvance:s,uvs:[new cW,new cW,new cW,new cW],ascent:p,descent:m,index:0,data:S}},rx._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=rx.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},rx._pushLine=function(e,t,r,n,a,i,o){e.push(n),t.push(a),r.push({ascent:i,descent:o,size:i+o})},rx);uE._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],uE._extendHeight=0,uE._measureString="|\xc9q\xc5",uE._measureBaseline="M",uE._heightMultiplier=2,uE._baselineMultiplier=1.4,uE._fontSizeInfoCache={},uE._textContext=null;var uM=((rS=(rb=function(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}).prototype).destroy=function(){for(var e=this._fontAtlases,t=0,r=e.length;t<r;++t)e[t].destroy(!0);e.length=0},rS._uploadCharTexture=function(e){var t=this._lastIndex;-1===t&&(this._createFontAtlas(),t++);var r=this._fontAtlases[t];!r.uploadCharTexture(e)&&((r=this._createFontAtlas()).uploadCharTexture(e),t++),this._lastIndex=t,e.data=null},rS._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},rS._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var a=t[r].getCharInfo(e);if(a)return a}return null},rS._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},rS._getLastIndex=function(){return this._lastIndex},rS._createFontAtlas=function(){var t,r=this._engine,n=new uA(r),a=new d9(r,256,256,e.TextureFormat.R8G8B8A8,!1);a.filterMode=e.TextureFilterMode.Bilinear,n.texture=a,n.isGCIgnored=a.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return r.resourceManager.addContentRestorer(new(c0(t=function(){return un.call(this,n)},un),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var a=t[n],o=uE.measureChar(a.char,i).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}r.generateMipmaps()},t)),n},rb),uR=(c0(rT=function(e,t){var r;return void 0===t&&(t=""),(r=c7.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},c7),(rC=rT.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,a=n[r];return a||(a=new uM(this.engine),n[r]=a),a},rC._onDestroy=function(){c7.prototype._onDestroy.call(this);var e=this._subFontMap;for(var t in e)e[t].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},rT.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new rT(e,t),r[t]=n),n}return null},cZ(rT,[{key:"name",get:function(){return this._name}}]),rT),uw=function e(){this.localPositions=new cK;var t=[new cB,new cB,new cB,new cB];this.renderData=new uS(4,t,null,e.triangles,null)};uw.triangles=[0,2,1,2,0,3];var uP=((rE=(rA=function(e,t){this._elements=[],this._type=e;for(var r=this._elements,n=0;n<t;++n)r[n]=new e}).prototype).get=function(){return this._elements.length>0?this._elements.pop():new this._type},rE.put=function(e){this._elements.push(e)},rA),uF=(rM=e.Renderer,c0(rR=function(t){var r;return(r=rM.call(this,t)||this)._subFont=null,r._charRenderDatas=[],r._dirtyFlag=15,r._color=new cj(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new cV,r._font=null,r._fontSize=24,r._fontStyle=e.FontStyle.None,r._lineSpacing=0,r._horizontalAlignment=e.TextHorizontalAlignment.Center,r._verticalAlignment=e.TextVerticalAlignment.Center,r._enableWrapping=!1,r._overflowMode=e.OverflowMode.Overflow,r._maskInteraction=e.SpriteMaskInteraction.None,r._maskLayer=e.SpriteMaskLayer.Layer0,r._init(),r},rM),(rw=rR.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._addResourceReferCount(this._font,1),this.setMaterial(e._spriteDefaultMaterial)},rw._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),rM.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,r=e.length;t<r;++t)rR._charRenderDataPool.put(e[t]);e.length=0,this._subFont&&(this._subFont=null)},rw._cloneTo=function(e,t,r){rM.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},rw._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rw._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rw._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rw._updateShaderData=function(e,t){if(t){this._updateMVPShaderData(e,cG._identity);return}this._updateTransformShaderData(e,cG._identity)},rw._updateBounds=function(e){cV.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rw._render=function(e){if(!this._isTextNoVisible()){this._isContainDirtyFlag(16)&&(this._updateStencilState(),this._setDirtyFlagFalse(16)),this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4));var t=this._engine._spriteRenderDataPool,r=this._engine._textRenderDataPool.getFromPool(),n=r.charsData,a=this.getMaterial(),i=this._charRenderDatas,o=i.length;r.component=this,r.material=a,n.length=o;for(var s=0;s<o;++s){var l=i[s],c=t.getFromPool();c.set(this,a,l.renderData,l.texture,s),n[s]=c}e.camera._renderPipeline.pushRenderData(e,r)}},rw._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,r=this._maskInteraction;if(r===e.SpriteMaskInteraction.None)t.enabled=!1,t.writeMask=255,t.referenceValue=0,t.compareFunctionFront=t.compareFunctionBack=e.CompareFunction.Always;else{t.enabled=!0,t.writeMask=0,t.referenceValue=1;var n=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=n,t.compareFunctionBack=n}},rw._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=uE.getNativeFontString(e.name,this.fontSize,this.fontStyle)},rw._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,r=e[0],n=e[1],a=e[2],i=e[4],o=e[5],s=e[6],l=e[12],c=e[13],d=e[14],u=rR._tempVec31.set(i,o,s),h=rR._tempVec30.set(r,n,a),_=0,f=t.length;_<f;++_){var p=t[_],m=p.localPositions,g=p.renderData.positions,v=m.x,y=m.y,x=g[0];x.x=v*r+y*i+l,x.y=v*n+y*o+c,x.z=v*a+y*s+d;var b=g[1];cB.scale(h,m.z-v,b),cB.add(x,b,b);var S=g[2];cB.scale(u,m.w-y,S),cB.add(x,S,g[3]),cB.add(b,S,S)}},rw._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,a=this.color,i=this._charRenderDatas,o=this._subFont,s=this.enableWrapping?uE.measureTextWithWrap(this):uE.measureTextWithoutWrap(this),l=s.height,c=s.lines,d=s.lineWidths,u=s.lineHeight,h=s.lineMaxSizes,_=rR._charRenderDataPool,f=c.length,p=0;if(f>0){var m=hS._pixelsPerUnit,g=this.horizontalAlignment,v=1/m,y=.5*(this.width*m),x=this.height*m,b=.5*u,S=0,T=.5*u-h[0].ascent,C=.5*u-h[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:S=.5*x-b+T;break;case e.TextVerticalAlignment.Center:S=.5*l-b-(C-T)*.5;break;case e.TextVerticalAlignment.Bottom:S=l-.5*x-b-C}for(var A=-1,E=Number.MAX_SAFE_INTEGER,M=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,w=Number.MIN_SAFE_INTEGER,P=0;P<f;++P){var F=d[P];if(F>0){var L=c[P],D=0,B=-1;switch(A<0&&(A=P),g){case e.TextHorizontalAlignment.Left:D=-y;break;case e.TextHorizontalAlignment.Center:D=-(.5*F);break;case e.TextHorizontalAlignment.Right:D=y-F}for(var I=0,V=L.length;I<V;++I){var O=L[I],N=o._getCharInfo(O);if(N.h>0){B<0&&(B=I);var k,z=i[k=p++]||(i[k]=_.get()),U=z.renderData,G=z.localPositions;z.texture=o._getTextureByIndex(N.index),U.color=a,U.uvs=N.uvs;var H=N.w,W=N.ascent,K=N.descent,j=D*v,X=(D+H)*v,q=(S+W)*v,Y=(S-K)*v;G.set(j,q,X,Y),P===A&&(w=Math.max(w,q)),M=Math.min(M,Y),I===B&&(E=Math.min(E,j)),R=Math.max(R,X)}D+=N.xAdvance}}S-=u}A<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(E,M,0),n.set(R,w,0))}else r.set(0,0,0),n.set(0,0,0);var Q=i.length;if(Q>p){for(var J=p;J<Q;++J)_.put(i[J]);i.length=p}o._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},rw._onTransformChanged=function(e){rM.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},rw._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},cZ(rR,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),rR);uF._charRenderDataPool=new uP(uw,50),uF._tempVec30=new cB,uF._tempVec31=new cB,c1([c4],uF.prototype,"_subFont",void 0),c1([c3],uF.prototype,"_charRenderDatas",void 0),c1([c3],uF.prototype,"_dirtyFlag",void 0),c1([c5],uF.prototype,"_color",void 0),c1([c4],uF.prototype,"_text",void 0),c1([c4],uF.prototype,"_width",void 0),c1([c4],uF.prototype,"_height",void 0),c1([c3],uF.prototype,"_localBounds",void 0),c1([c4],uF.prototype,"_font",void 0),c1([c4],uF.prototype,"_fontSize",void 0),c1([c4],uF.prototype,"_fontStyle",void 0),c1([c4],uF.prototype,"_lineSpacing",void 0),c1([c4],uF.prototype,"_horizontalAlignment",void 0),c1([c4],uF.prototype,"_verticalAlignment",void 0),c1([c4],uF.prototype,"_enableWrapping",void 0),c1([c4],uF.prototype,"_overflowMode",void 0),c1([c4],uF.prototype,"_maskInteraction",void 0),c1([c4],uF.prototype,"_maskLayer",void 0),(rP=ca||(ca={}))[rP.SubFont=1]="SubFont",rP[rP.LocalPositionBounds=2]="LocalPositionBounds",rP[rP.WorldPosition=4]="WorldPosition",rP[rP.WorldBounds=8]="WorldBounds",rP[rP.MaskInteraction=16]="MaskInteraction",rP[rP.Position=14]="Position",rP[rP.Font=15]="Font",e.BlendMode=void 0,(rF=e.BlendMode||(e.BlendMode={}))[rF.Normal=0]="Normal",rF[rF.Additive=1]="Additive",e.RenderFace=void 0,(rL=e.RenderFace||(e.RenderFace={}))[rL.Front=0]="Front",rL[rL.Back=1]="Back",rL[rL.Double=2]="Double";var uL=(c0(rD=function(e,t){var r;return(r=c7.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new dH(l2.Material),r.shader=t,r},c7),(rB=rD.prototype).clone=function(){var e=new rD(this._engine,this.shader);return this.cloneTo(e),e},rB.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),c9.deepCloneObject(this.renderStates,e.renderStates,new Map)},rB._addReferCount=function(e){this._destroyed||(c7.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},rB._onDestroy=function(){c7.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},cZ(rD,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,r=this._getReferCount();r>0&&(null==(t=this._shader)||t._addReferCount(-r),e._addReferCount(r)),this._shader=e;for(var n=this._renderStates,a=n.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)n.push(new dk);else n.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rD),uD=function(t){function r(n,a){var i;return(i=t.call(this,n,a)||this)._renderFace=e.RenderFace.Front,i._isTransparent=!1,i._blendMode=e.BlendMode.Normal,i.shaderData.setFloat(r._alphaCutoffProp,0),i}c0(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var a=this.renderStates;if(a.length<t)throw"Pass should less than pass count.";var i=a[t];n?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(r._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=this.shaderData.getFloat(r._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,this.shaderData.disableMacro(r._transparentMacro))},n.setBlendMode=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";var a=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.One,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add}},n.setRenderFace=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";switch(r){case e.RenderFace.Front:n[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:n[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:n[t].rasterState.cullMode=e.CullMode.Off}},n.clone=function(){var e=new r(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},cZ(r,[{key:"shader",get:function(){return this._shader},set:function(t){var r,n=this._getReferCount();n>0&&(null==(r=this._shader)||r._addReferCount(-n),t._addReferCount(n)),this._shader=t;for(var a=this._renderStates,i=a.length,o=0,s=t.subShaders,l=0;l<s.length;l++)o=Math.max(s[l].passes.length,o);if(i<o)for(var c=i;c<o;c++)a.push(new dk),this.setBlendMode(c,e.BlendMode.Normal);else a.length=o}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){e!==this._isTransparent&&(this.setIsTransparent(0,e),this._isTransparent=e)}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(r._alphaCutoffProp)},set:function(t){var n=this.shaderData;if(n.getFloat(r._alphaCutoffProp)!==t){t?n.enableMacro(r._alphaCutoffMacro):n.disableMacro(r._alphaCutoffMacro);for(var a=this.renderStates,i=0,o=a.length;i<o;i++){var s=a[i];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}n.setFloat(r._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),r}(uL);uD._baseTextureMacro=dS.getByName("MATERIAL_HAS_BASETEXTURE"),uD._normalTextureMacro=dS.getByName("MATERIAL_HAS_NORMALTEXTURE"),uD._emissiveTextureMacro=dS.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uD._transparentMacro=dS.getByName("MATERIAL_IS_TRANSPARENT"),uD._baseColorProp=dp.getByName("material_BaseColor"),uD._baseTextureProp=dp.getByName("material_BaseTexture"),uD._tilingOffsetProp=dp.getByName("material_TilingOffset"),uD._normalTextureProp=dp.getByName("material_NormalTexture"),uD._normalIntensityProp=dp.getByName("material_NormalIntensity"),uD._emissiveColorProp=dp.getByName("material_EmissiveColor"),uD._emissiveTextureProp=dp.getByName("material_EmissiveTexture"),uD._alphaCutoffProp=dp.getByName("material_AlphaCutoff"),uD._alphaCutoffMacro=dS.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uB=function(e){function t(r){var n,a=(n=e.call(this,r,dz.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new cj(1,1,1,1)),a.setColor(t._specularColorProp,new cj(1,1,1,1)),a.setColor(t._emissiveColorProp,new cj(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new cK(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),n}return c0(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cZ(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var r=this.shaderData.getColor(t._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var r=this.shaderData.getColor(t._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(t._specularTextureProp)},set:function(e){this.shaderData.setTexture(t._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var r=this.shaderData.getColor(t._emissiveColorProp);e!==r&&r.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(t._shininessProp)},set:function(e){this.shaderData.setFloat(t._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(t._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),t}(uD);uB._specularColorProp=dp.getByName("material_SpecularColor"),uB._shininessProp=dp.getByName("material_Shininess"),uB._specularTextureProp=dp.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rI=e.TextureCoordinate||(e.TextureCoordinate={}))[rI.UV0=0]="UV0",rI[rI.UV1=1]="UV1",rI[rI.UV2=2]="UV2",rI[rI.UV3=3]="UV3",rI[rI.UV4=4]="UV4",rI[rI.UV5=5]="UV5",rI[rI.UV6=6]="UV6",rI[rI.UV7=7]="UV7";var uI=function(t){function r(n,a){var i,o=(i=t.call(this,n,a)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new cj(1,1,1,1)),o.setColor(r._emissiveColorProp,new cj(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new cK(1,1,0,0)),o.setFloat(r._normalIntensityProp,1),o.setFloat(r._occlusionTextureIntensityProp,1),o.setFloat(r._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(r._clearCoatProp,0),o.setFloat(r._clearCoatRoughnessProp,0),i}return c0(r,t),cZ(r,[{key:"baseColor",get:function(){return this.shaderData.getColor(r._baseColorProp)},set:function(e){var t=this.shaderData.getColor(r._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(r._baseTextureProp)},set:function(e){this.shaderData.setTexture(r._baseTextureProp,e),e?this.shaderData.enableMacro(r._baseTextureMacro):this.shaderData.disableMacro(r._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(r._normalTextureProp)},set:function(e){this.shaderData.setTexture(r._normalTextureProp,e),e?this.shaderData.enableMacro(r._normalTextureMacro):this.shaderData.disableMacro(r._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(r._normalIntensityProp)},set:function(e){this.shaderData.setFloat(r._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(r._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(r._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(r._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(r._emissiveTextureProp,e),e?this.shaderData.enableMacro(r._emissiveTextureMacro):this.shaderData.disableMacro(r._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(r._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(r._occlusionTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(r._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(r._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(r._occlusionTextureCoordProp)},set:function(t){t>e.TextureCoordinate.UV1&&df.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(r._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(r._tilingOffsetProp)},set:function(e){var t=this.shaderData.getVector4(r._tilingOffsetProp);e!==t&&t.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(r._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(r._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(r._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(r._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(r._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(r._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(r._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(r._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),r}(uD);uI._occlusionTextureIntensityProp=dp.getByName("material_OcclusionIntensity"),uI._occlusionTextureCoordProp=dp.getByName("material_OcclusionTextureCoord"),uI._occlusionTextureProp=dp.getByName("material_OcclusionTexture"),uI._clearCoatProp=dp.getByName("material_ClearCoat"),uI._clearCoatTextureProp=dp.getByName("material_ClearCoatTexture"),uI._clearCoatRoughnessProp=dp.getByName("material_ClearCoatRoughness"),uI._clearCoatRoughnessTextureProp=dp.getByName("material_ClearCoatRoughnessTexture"),uI._clearCoatNormalTextureProp=dp.getByName("material_ClearCoatNormalTexture");var uV=function(e){function t(r){(n=e.call(this,r,dz.find("pbr"))||this)._anisotropyRotation=0;var n,a=n.shaderData;return a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new cB(1,0,0)),n}return c0(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cZ(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(t._anisotropyInfoProp);!!r.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(t._anisotropyInfoProp),n=cD.degreeToRadFactor*e;r.x=Math.cos(n),r.y=Math.sin(n)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),t}(uI);uV._metallicProp=dp.getByName("material_Metal"),uV._roughnessProp=dp.getByName("material_Roughness"),uV._roughnessMetallicTextureProp=dp.getByName("material_RoughnessMetallicTexture"),uV._iorProp=dp.getByName("material_IOR"),uV._anisotropyInfoProp=dp.getByName("material_AnisotropyInfo"),uV._anisotropyTextureProp=dp.getByName("material_AnisotropyTexture");var uO=function(e){function t(r){var n;return(n=e.call(this,r,dz.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new cj(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return c0(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cZ(t,[{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var r=this.shaderData.getColor(t._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(t._glossinessProp)},set:function(e){this.shaderData.setFloat(t._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(t._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(t._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(t._specularGlossinessTextureMacro):this.shaderData.disableMacro(t._specularGlossinessTextureMacro)}}]),t}(uI);uO._specularColorProp=dp.getByName("material_PBRSpecularColor"),uO._glossinessProp=dp.getByName("material_Glossiness"),uO._specularGlossinessTextureProp=dp.getByName("material_SpecularGlossinessTexture"),uO._specularGlossinessTextureMacro=dS.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uN=function(e){function t(r){var n,a=(n=e.call(this,r,dz.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new cj(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new cK(1,1,0,0)),n}return c0(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cZ(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var r=this.shaderData.getColor(t._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(t._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),t}(uD),uk=((rO=(rV=function(t){var r=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),n=new Float32Array([1,-1,1,0,-1,-1,0,0,1,1,1,1,-1,1,0,1]),a=new uL(t,dz.find("blit"));a._addReferCount(1),a.renderState.depthState.enabled=!1,a.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(t,r),this.flipYBlitMesh=this._createBlitMesh(t,n),this.blitMaterial=a;var i=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R8G8B8A8,i),this.whiteTextureCube=this._create1x1Texture(t,1,e.TextureFormat.R8G8B8A8,i),t._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(t,2,e.TextureFormat.R8G8B8A8,i);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R32G32B32A32_UInt,o)}}).prototype)._createBlitMesh=function(t,r){var n=new ut(t);return n._addReferCount(1),n.setVertexElements([new d1("POSITION_UV",0,e.VertexElementFormat.Vector4,0)]),n.setVertexBufferBinding(new dq(t,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static),16),n.addSubMesh(0,4,e.MeshTopology.TriangleStrip),n},rO._create1x1Texture=function(t,r,n,a){switch(r){case 0:var i,o,s=new d9(t,1,1,n,!1);s.setPixelBuffer(a),i=s;break;case 2:var l=new d6(t,1,1,1,n,!1);l.setPixelBuffer(0,a),i=l;break;case 1:for(var c=new d7(t,1,n,!1),d=0;d<6;d++)c.setPixelBuffer(e.TextureCubeFace.PositiveX+d,a);i=c;break;default:throw"Invalid texture type"}return i.isGCIgnored=!0,t.resourceManager.addContentRestorer(new(c0(o=function(){return un.call(this,i)},un),o.prototype.restoreContent=function(){switch(r){case 0:this.resource.setPixelBuffer(a);break;case 2:this.resource.setPixelBuffer(0,a);break;case 1:for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,a)}},o)),i},rV);(rN=ci||(ci={}))[rN.Texture2D=0]="Texture2D",rN[rN.TextureCube=1]="TextureCube",rN[rN.Texture2DArray=2]="Texture2DArray";var uz=((rz=(rk=function(){this._projectionParams=new cK,this.flipProjection=!1}).prototype).applyVirtualCamera=function(e,t){this.virtualCamera=e,this.flipProjection=t;var r=this.camera.shaderData,n=e.viewMatrix,a=e.projectionMatrix,i=e.viewProjectionMatrix;t&&(cG.multiply(rk._flipYMatrix,a,rk._flipYProjectionMatrix),cG.multiply(rk._flipYProjectionMatrix,n,rk._flipYViewProjectionMatrix),a=rk._flipYProjectionMatrix,i=rk._flipYViewProjectionMatrix),this.viewMatrix=n,this.projectionMatrix=a,this.viewProjectionMatrix=i,r.setMatrix(rk._viewMatrixProperty,n),r.setMatrix(rk._projectionMatrixProperty,a),r.setMatrix(rk.vpMatrixProperty,i);var o=this._projectionParams;o.set(t?-1:1,e.nearClipPlane,e.farClipPlane,0),r.setVector4(rk._cameraProjectionProperty,o)},rz.garbageCollection=function(){this.camera=null},rk);uz.vpMatrixProperty=dp.getByName("camera_VPMat"),uz.pipelineStageKey=dM.getByName("pipelineStage"),uz._flipYMatrix=new cG(1,0,0,0,0,-1),uz._cameraProjectionProperty=dp.getByName("camera_ProjectionParams"),uz._viewMatrixProperty=dp.getByName("camera_ViewMat"),uz._projectionMatrixProperty=dp.getByName("camera_ProjMat"),uz._flipYProjectionMatrix=new cG,uz._flipYViewProjectionMatrix=new cG;var uU=((rG=(rU=function(){}).prototype).setX=function(e,t,r,n){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n},rG.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},rU),uG=((rW=(rH=function(){}).prototype).set=function(e,t){this.data=e,this.shaderPasses=t},rW.dispose=function(){this.data=this.shaderPasses=null},rH),uH=(c0(rK=function(){return ux.apply(this,arguments)},ux),(rj=rK.prototype).createVertexElements=function(t){return t[0]=new d1("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new d1("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},rj.canBatch=function(e,t){var r=e.data,n=t.data;if(r.isAdd!==n.isAdd)return!1;var a=r.component.shaderData,i=n.component.shaderData,o=uC._textureProperty,s=uC._alphaCutoffProperty;return a.getTexture(o)===i.getTexture(o)&&a.getTexture(s)===i.getTexture(s)},rj.updateVertices=function(e,t,r){for(var n=e.verticesData,a=n.positions,i=n.uvs,o=n.vertexCount,s=0;s<o;s++){var l=a[s],c=i[s];t[r++]=l.x,t[r++]=l.y,t[r++]=l.z,t[r++]=c.x,t[r++]=c.y}return r},rj.drawBatches=function(t){for(var r=this._engine,n=this._batchedQueue,a=this._meshes[this._flushId],i=a.subMeshes,o=a._primitive,s=t.scene.shaderData,l=t.shaderData,c=0,d=i.length;c<d;c++){var u=i[c],h=n[c],_=h.data;if(!u||!h)return;var f=_.component,p=_.material,m=dz._compileMacros;dT.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=p.renderState.stencilState,v=_.isAdd?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate;g.passOperationFront=v,g.passOperationBack=v;var y=p.shader.subShaders[0].passes[0],x=y._getShaderProgram(r,m);if(!x.isValid)return;x.bind(),x.groupingOtherUniformBlock(),x.uploadAll(x.sceneUniformBlock,s),x.uploadAll(x.cameraUniformBlock,l),x.uploadAll(x.rendererUniformBlock,f.shaderData),x.uploadAll(x.materialUniformBlock,p.shaderData),(y._renderState||p.renderState)._apply(r,!1,y._renderStateDataMap,p.shaderData),r._hardwareRenderer.drawPrimitive(o,u,x)}},rK),uW=((rq=(rX=function(e){this._preMaskLayer=0,this._batcher=new uH(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rq.preRender=function(t,r){r.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,r),this._batcher.flush(t))},rq.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rq.destroy=function(){this._batcher.destroy(),this._batcher=null},rq._processMasksDiff=function(e,t){var r=this._preMaskLayer,n=t.maskLayer;if(r!==n)for(var a=e._renderPipeline._allSpriteMasks,i=r&n,o=n&~r,s=r&~n,l=a._elements,c=0,d=a.length;c<d;c++){var u=l[c],h=u.influenceLayers;if(!(h&i)){if(h&o){var _=u._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(h&s){var f=u._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},rX),uK=(c0(rY=function(){var e;return(e=uU.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},uU),(rQ=rY.prototype).set=function(e,t,r){this.component=e,this.material=t,this.verticesData=r},rQ.dispose=function(){this.component=this.material=this.verticesData=null},rY),uj=(c0(rJ=function(){var e;return(e=uU.call(this)||this).multiRenderData=!1,e},uU),(rZ=rJ.prototype).set=function(e,t,r,n,a){void 0===a&&(a=0),this.component=e,this.material=t,this.verticesData=r,this.texture=n,this.dataIndex=a},rZ.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rJ),uX=(c0(r$=function(){var e;return(e=uU.call(this)||this).charsData=[],e.multiRenderData=!0,e},uU),r$.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},r$);e.AssetType=void 0,(r0=e.AssetType||(e.AssetType={})).Text="Text",r0.JSON="JSON",r0.Buffer="Buffer",r0.Texture2D="Texture2D",r0.TextureCube="TextureCube",r0.Material="Material",r0.Mesh="Mesh",r0.AnimationClip="AnimationClip",r0.AnimatorController="AnimatorController",r0.GLTF="GLTF",r0.KTX="KTX",r0.KTXCube="KTXCube",r0.KTX2="KTX2",r0.Sprite="Sprite",r0.PrimitiveMesh="PrimitiveMesh",r0.SpriteAtlas="SpriteAtlas",r0.Env="Environment",r0.Scene="Scene",r0.HDR="HDR",r0.Font="Font",r0.SourceFont="SourceFont",r0.Project="project";var uq=((r2=(r1=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},r2.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},r2.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},r2.indexOf=function(e){return this._array.indexOf(e)},r2.getArray=function(){return this._array},r2.getLoopArray=function(){var e=this._loopArray;if(this._loopArrayDirty){var t=this._array,r=t.length;e.length=r;for(var n=0;n<r;n++)e[n]=t[n];this._loopArrayDirty=!1}return e},cZ(r1,[{key:"length",get:function(){return this._array.length}}]),r1),uY=((r4=(r3=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new uq}).prototype).addScene=function(e,t){var r,n=this._scenes;if("number"==typeof e){if(e<0||e>n.length)throw"The index is out of range.";r=e}else r=n.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=n.indexOf(t);a!==r&&(n.removeByIndex(a),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},r4.removeScene=function(e){var t=this._scenes,r=t.indexOf(e);if(-1!==r){var n=t.getArray()[r];t.removeByIndex(r),e._sceneManager=null,n.isActive&&n._processActive(!1)}},r4.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,a=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return a.then(function(e){if(r)for(var t=n._scenes.getArray(),a=0,i=t.length;a<i;a++)t[a].destroy();n.addScene(e)}),a},r4.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},r4._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},cZ(r3,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(e){var t=this.scenes[0];t&&this.removeScene(t),e&&this.addScene(0,e)}}]),r3),uQ=((r5=(r8=function(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,r){if("pending"===t._state){var n=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:r});n.loaded=e,n.total=r,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,r)})}},function(e,r,n){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:r,total:n});i.loaded=r,i.total=n,t._onTaskDetailCallbacks.forEach(function(t){return t(e,r,n)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e,t){var r=this._taskCompleteProgress,n=this._taskDetailProgress;if(r&&e(r.loaded,r.total),n)for(var a in n){var i=n[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},r5.then=function(e,t){var r=this;return new r8(function(n,a){r._promise.then(e,t).then(n).catch(a)})},r5.catch=function(e){var t=this;return new r8(function(r,n){t._promise.catch(e).then(r).catch(n)})},r5.finally=function(e){return this._promise.finally(e)},r5.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},r8.all=function(e){return new r8(function(t,r,n){var a=function(e,r){l++,s[e]=r,n(l,o),l===o&&t(s)},i=function(e,t){c2(e,Promise)||c2(e,r8)?e.then(function(e){a(t,e)},r):Promise.resolve().then(function(){a(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)i(e[c],c)})},cZ(r8,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),r8);(r9=co||(co={})).Pending="pending",r9.Fulfilled="fulfilled",r9.Rejected="rejected",r9.Canceled="canceled";var uJ=((r7=(r6=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}).prototype).load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var r=e.map(function(e){return t._loadSingleItem(e)});return uQ.all(r)},r7.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},r7.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var a=r[n];c2(a,e)&&t.push(a)}return t},r7.getAssetPath=function(e){return this._assetPool[e]},r7.cancelNotLoaded=function(e){var t,r=this;e?"string"==typeof e?null==(t=this._loadingPromises[e])||t.cancel():e.forEach(function(e){var t;null==(t=r._loadingPromises[e])||t.cancel()}):dt.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},r7.gc=function(){this._gc(!1),this.engine._pendingGC()},r7.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},r7._onSubAssetSuccess=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.resolve(t),delete this._subAssetPromiseCallbacks[e]},r7._onSubAssetFail=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.reject(t),delete this._subAssetPromiseCallbacks[e]},r7._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},r7._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},r7._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},r7._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},r7._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},r7._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},r7._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},r7._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},r7._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},r7._restoreResourcesContent=function(){var e=this._contentRestorerPool,t=[];for(var r in e){var n=e[r].restoreContent();n&&t.push(n)}return Promise.all(t)},r7._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._referResourcePool=null,this._graphicResourcePool=null,this._contentRestorerPool=null,this._loadingPromises=null},r7._assignDefaultOptions=function(e){var t,r,n,a,i;if(e.type=null!=(t=e.type)?t:r6._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(r=e.retryCount)?r:this.retryCount,e.timeout=null!=(n=e.timeout)?n:this.timeout,e.retryInterval=null!=(a=e.retryInterval)?a:this.retryInterval,e.url=null!=(i=e.url)?i:e.urls.join(","),e},r7._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),a=n.url,i=this._virtualPathMap[a]?this._virtualPathMap[a]:a;!dt.isAbsoluteUrl(i)&&this.baseUrl&&(i=dt.resolveAbsoluteUrl(this.baseUrl,i));var o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],d=this._assetUrlPool[s];if(d)return new uQ(function(e){e(r._getResolveResource(d,c))});var u=s;if(l)for(u+="?q="+c.shift();t=c.shift();)u+="["+t+"]";var h=this._loadingPromises,_=h[u];if(_)return new uQ(function(e,t,r,n){_.onProgress(r,n).then(function(t){e(t)}).catch(function(e){t(e)})});var f=r6._loaders[n.type];if(!f)throw"loader not found: "+n.type;n.url=s;var p=f.load(n,this);if(h[s]=p,p.then(function(e){f.useCache&&r._addAsset(s,e),delete h[s]},function(){return delete h[s]}),l){var m=new uQ(function(e,t){r._pushSubAssetPromiseCallback(u,e,t)});return h[u]=m,m.then(function(){delete h[u]},function(){return delete h[u]}),p.catch(function(e){r._onSubAssetFail(u,e)}),m}return p},r7._pushSubAssetPromiseCallback=function(e,t,r){this._subAssetPromiseCallbacks[e]={resolve:t,reject:r}},r7._gc=function(e){for(var t=dt.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++){var a=t[r];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},r7._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,a=t.length;n<a;n++)r=r[t[n]];return r},r7._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],a=void 0,i=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:i,queryPath:a}},r7._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===u$&&t.push(""),e.replace(u1,function(e,r,n,a){var i=e;n?i=a.replace(u0,"$1"):r&&(i=r.trim()),t.push(i)}),t},r7.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,a=this._objectPool[t];if(a)i=Promise.resolve(a);else{var i,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return df.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,i=this.load({url:s,type:this._editorResourceConfig[t].type})}return i.then(function(e){return n?e.clone():e})},r7.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},r6._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,a=r.length;n<a;n++)this._extTypeMapping[r[n].toLowerCase()]=e},r6._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},r6);function uZ(e,t,r){return void 0===r&&(r=!0),function(n){var a=new n(r);uJ._addLoader(e,a,t)}}uJ._loaders={},uJ._extTypeMapping={};var u$=46,u0=/\\(\\)?/g,u1=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(ne=e.PointerPhase||(e.PointerPhase={}))[ne.Down=0]="Down",ne[ne.Move=1]="Move",ne[ne.Stationary=2]="Stationary",ne[ne.Up=3]="Up",ne[ne.Leave=4]="Leave";var u2=((nr=(nt=function(t){this.phase=e.PointerPhase.Leave,this.position=new cW,this.deltaPosition=new cW,this._events=[],this._upMap=[],this._downMap=[],this._upList=new dX,this._downList=new dX,this.id=t}).prototype)._firePointerExitAndEnter=function(e){var t=this;this._currentEnteredEntity!==e&&(this._currentEnteredEntity&&this._currentEnteredEntity._scripts.forEach(function(e){e.onPointerExit(t)},function(e,t){e._entityScriptsIndex=t}),e&&e._scripts.forEach(function(e){e.onPointerEnter(t)},function(e,t){e._entityScriptsIndex=t}),this._currentEnteredEntity=e)},nr._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},nr._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},nr._firePointerUpAndClick=function(e){var t=this,r=this._currentPressedEntity;if(r){var n=r===e;r._scripts.forEach(function(e){n&&e.onPointerClick(t),e.onPointerUp(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=null}},nt);e.PointerButton=void 0,(nn=e.PointerButton||(e.PointerButton={}))[nn.None=0]="None",nn[nn.Primary=1]="Primary",nn[nn.Secondary=2]="Secondary",nn[nn.Auxiliary=4]="Auxiliary",nn[nn.XButton1=8]="XButton1",nn[nn.XButton2=16]="XButton2",nn[nn.XButton3=32]="XButton3",nn[nn.XButton4=64]="XButton4",nn[nn.XButton5=128]="XButton5",nn[nn.XButton6=256]="XButton6",nn[nn.XButton7=512]="XButton7",nn[nn.XButton8=1024]="XButton8";var u3=[1,4,2,8,16,32,64,128,256,512,1024],u4={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},u8=((na=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?na.platform=e.Platform.IPhone:/iPad/i.test(r)?na.platform=e.Platform.IPad:/Android/i.test(r)?na.platform=e.Platform.Android:/Macintosh/i.test(r)&&(na.platform=e.Platform.Mac),na.platform){case e.Platform.IPhone:t=r.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case e.Platform.IPad:t=r.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case e.Platform.Android:t=r.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case e.Platform.Mac:t=r.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X"}}},na._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},cZ(na,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),na);u8.platform=e.Platform.Unknown,u8.operatingSystem="",u8._simdSupported=null,u8._initialize(),e.Keys=void 0,(ni=e.Keys||(e.Keys={}))[ni.Backquote=0]="Backquote",ni[ni.Backslash=1]="Backslash",ni[ni.Backspace=2]="Backspace",ni[ni.BracketLeft=3]="BracketLeft",ni[ni.BracketRight=4]="BracketRight",ni[ni.Comma=5]="Comma",ni[ni.Digit0=6]="Digit0",ni[ni.Digit1=7]="Digit1",ni[ni.Digit2=8]="Digit2",ni[ni.Digit3=9]="Digit3",ni[ni.Digit4=10]="Digit4",ni[ni.Digit5=11]="Digit5",ni[ni.Digit6=12]="Digit6",ni[ni.Digit7=13]="Digit7",ni[ni.Digit8=14]="Digit8",ni[ni.Digit9=15]="Digit9",ni[ni.Equal=16]="Equal",ni[ni.IntlBackslash=17]="IntlBackslash",ni[ni.IntlRo=18]="IntlRo",ni[ni.IntlYen=19]="IntlYen",ni[ni.KeyA=20]="KeyA",ni[ni.KeyB=21]="KeyB",ni[ni.KeyC=22]="KeyC",ni[ni.KeyD=23]="KeyD",ni[ni.KeyE=24]="KeyE",ni[ni.KeyF=25]="KeyF",ni[ni.KeyG=26]="KeyG",ni[ni.KeyH=27]="KeyH",ni[ni.KeyI=28]="KeyI",ni[ni.KeyJ=29]="KeyJ",ni[ni.KeyK=30]="KeyK",ni[ni.KeyL=31]="KeyL",ni[ni.KeyM=32]="KeyM",ni[ni.KeyN=33]="KeyN",ni[ni.KeyO=34]="KeyO",ni[ni.KeyP=35]="KeyP",ni[ni.KeyQ=36]="KeyQ",ni[ni.KeyR=37]="KeyR",ni[ni.KeyS=38]="KeyS",ni[ni.KeyT=39]="KeyT",ni[ni.KeyU=40]="KeyU",ni[ni.KeyV=41]="KeyV",ni[ni.KeyW=42]="KeyW",ni[ni.KeyX=43]="KeyX",ni[ni.KeyY=44]="KeyY",ni[ni.KeyZ=45]="KeyZ",ni[ni.Minus=46]="Minus",ni[ni.Period=47]="Period",ni[ni.Quote=48]="Quote",ni[ni.Semicolon=49]="Semicolon",ni[ni.Slash=50]="Slash",ni[ni.AltLeft=51]="AltLeft",ni[ni.AltRight=52]="AltRight",ni[ni.CapsLock=53]="CapsLock",ni[ni.ContextMenu=54]="ContextMenu",ni[ni.ControlLeft=55]="ControlLeft",ni[ni.ControlRight=56]="ControlRight",ni[ni.Enter=57]="Enter",ni[ni.MetaLeft=58]="MetaLeft",ni[ni.MetaRight=59]="MetaRight",ni[ni.ShiftLeft=60]="ShiftLeft",ni[ni.ShiftRight=61]="ShiftRight",ni[ni.Space=62]="Space",ni[ni.Tab=63]="Tab",ni[ni.Convert=64]="Convert",ni[ni.KanaMode=65]="KanaMode",ni[ni.Lang1=66]="Lang1",ni[ni.Lang2=67]="Lang2",ni[ni.Lang3=68]="Lang3",ni[ni.Lang4=69]="Lang4",ni[ni.Lang5=70]="Lang5",ni[ni.NonConvert=71]="NonConvert",ni[ni.Delete=72]="Delete",ni[ni.End=73]="End",ni[ni.Help=74]="Help",ni[ni.Home=75]="Home",ni[ni.Insert=76]="Insert",ni[ni.PageDown=77]="PageDown",ni[ni.PageUp=78]="PageUp",ni[ni.ArrowDown=79]="ArrowDown",ni[ni.ArrowLeft=80]="ArrowLeft",ni[ni.ArrowRight=81]="ArrowRight",ni[ni.ArrowUp=82]="ArrowUp",ni[ni.NumLock=83]="NumLock",ni[ni.Numpad0=84]="Numpad0",ni[ni.Numpad1=85]="Numpad1",ni[ni.Numpad2=86]="Numpad2",ni[ni.Numpad3=87]="Numpad3",ni[ni.Numpad4=88]="Numpad4",ni[ni.Numpad5=89]="Numpad5",ni[ni.Numpad6=90]="Numpad6",ni[ni.Numpad7=91]="Numpad7",ni[ni.Numpad8=92]="Numpad8",ni[ni.Numpad9=93]="Numpad9",ni[ni.NumpadAdd=94]="NumpadAdd",ni[ni.NumpadBackspace=95]="NumpadBackspace",ni[ni.NumpadClear=96]="NumpadClear",ni[ni.NumpadClearEntry=97]="NumpadClearEntry",ni[ni.NumpadComma=98]="NumpadComma",ni[ni.NumpadDecimal=99]="NumpadDecimal",ni[ni.NumpadDivide=100]="NumpadDivide",ni[ni.NumpadEnter=101]="NumpadEnter",ni[ni.NumpadEqual=102]="NumpadEqual",ni[ni.NumpadHash=103]="NumpadHash",ni[ni.NumpadMemoryAdd=104]="NumpadMemoryAdd",ni[ni.NumpadMemoryClear=105]="NumpadMemoryClear",ni[ni.NumpadMemoryRecall=106]="NumpadMemoryRecall",ni[ni.NumpadMemoryStore=107]="NumpadMemoryStore",ni[ni.NumpadMemorySubtract=108]="NumpadMemorySubtract",ni[ni.NumpadMultiply=109]="NumpadMultiply",ni[ni.NumpadParenLeft=110]="NumpadParenLeft",ni[ni.NumpadParenRight=111]="NumpadParenRight",ni[ni.NumpadStar=112]="NumpadStar",ni[ni.NumpadSubtract=113]="NumpadSubtract",ni[ni.Escape=114]="Escape",ni[ni.F1=115]="F1",ni[ni.F2=116]="F2",ni[ni.F3=117]="F3",ni[ni.F4=118]="F4",ni[ni.F5=119]="F5",ni[ni.F6=120]="F6",ni[ni.F7=121]="F7",ni[ni.F8=122]="F8",ni[ni.F9=123]="F9",ni[ni.F10=124]="F10",ni[ni.F11=125]="F11",ni[ni.F12=126]="F12",ni[ni.F13=127]="F13",ni[ni.F14=128]="F14",ni[ni.F15=129]="F15",ni[ni.Fn=130]="Fn",ni[ni.FnLock=131]="FnLock",ni[ni.PrintScreen=132]="PrintScreen",ni[ni.ScrollLock=133]="ScrollLock",ni[ni.Pause=134]="Pause",ni[ni.BrowserBack=135]="BrowserBack",ni[ni.BrowserFavorites=136]="BrowserFavorites",ni[ni.BrowserForward=137]="BrowserForward",ni[ni.BrowserHome=138]="BrowserHome",ni[ni.BrowserRefresh=139]="BrowserRefresh",ni[ni.BrowserSearch=140]="BrowserSearch",ni[ni.BrowserStop=141]="BrowserStop",ni[ni.Eject=142]="Eject",ni[ni.LaunchApp1=143]="LaunchApp1",ni[ni.LaunchApp2=144]="LaunchApp2",ni[ni.LaunchMail=145]="LaunchMail",ni[ni.MediaPlayPause=146]="MediaPlayPause",ni[ni.MediaSelect=147]="MediaSelect",ni[ni.MediaStop=148]="MediaStop",ni[ni.MediaTrackNext=149]="MediaTrackNext",ni[ni.MediaTrackPrevious=150]="MediaTrackPrevious",ni[ni.Power=151]="Power",ni[ni.Sleep=152]="Sleep",ni[ni.AudioVolumeDown=153]="AudioVolumeDown",ni[ni.AudioVolumeMute=154]="AudioVolumeMute",ni[ni.AudioVolumeUp=155]="AudioVolumeUp",ni[ni.WakeUp=156]="WakeUp",ni[ni.Hyper=157]="Hyper",ni[ni.Super=158]="Super",ni[ni.Turbo=159]="Turbo",ni[ni.Abort=160]="Abort",ni[ni.Resume=161]="Resume",ni[ni.Suspend=162]="Suspend",ni[ni.Again=163]="Again",ni[ni.Copy=164]="Copy",ni[ni.Cut=165]="Cut",ni[ni.Find=166]="Find",ni[ni.Open=167]="Open",ni[ni.Paste=168]="Paste",ni[ni.Props=169]="Props",ni[ni.Select=170]="Select",ni[ni.Undo=171]="Undo",ni[ni.Hiragana=172]="Hiragana",ni[ni.Katakana=173]="Katakana",ni[ni.Unidentified=174]="Unidentified";var u5=((ns=(no=function(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new dX,this._curFrameDownList=new dX,this._curFrameUpList=new dX,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var t=this._nativeEvents,r=this._curFrameDownList,n=this._curFrameUpList;if(r.length=0,n.length=0,t.length>0){for(var a=this._engine.time.frameCount,i=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,d=t.length;c<d;c++){var u=t[c],h=e.Keys[u.code];switch(u.type){case"keydown":null==i[h]&&(r.add(h),o.add(h),i[h]=o.length-1,s[h]=a);break;case"keyup":var _=i[h];if(null!=_){i[h]=null;var f=o.deleteByIndex(_);f&&(i[f]=_)}if(n.add(h),l[h]=a,u8.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)i[o.get(p)]=null;o.length=0}}}t.length=0}},ns._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},ns._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},ns._onKeyEvent=function(e){this._nativeEvents.push(e)},ns._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},ns._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},no);e.CameraClearFlags=void 0,(nl=e.CameraClearFlags||(e.CameraClearFlags={}))[nl.None=0]="None",nl[nl.Color=1]="Color",nl[nl.Depth=2]="Depth",nl[nl.Stencil=4]="Stencil",nl[nl.ColorDepth=3]="ColorDepth",nl[nl.ColorStencil=5]="ColorStencil",nl[nl.DepthStencil=6]="DepthStencil",nl[nl.All=7]="All",e.Collider=(c0(nc=function(e){var t;return(t=dg.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},dg),(nd=nc.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e))},nd.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._phasedActiveInScene&&this.scene.physics._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},nd.clearShapes=function(){for(var e=this._shapes,t=0,r=e.length;t<r;t++){var n=e[t];this._phasedActiveInScene&&this.scene.physics._removeColliderShape(n),n._destroy(),this._nativeCollider.removeShape(n._nativeShape)}e.length=0},nd._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform;this._nativeCollider.setWorldTransform(e.worldPosition,e.worldRotationQuaternion);for(var t=e.lossyWorldScale,r=0,n=this.shapes.length;r<n;r++)this.shapes[r]._nativeShape.setWorldScale(t);this._updateFlag.flag=!1}},nd._onLateUpdate=function(){},nd._onEnableInScene=function(){var e=this.scene.physics;e._addCollider(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._addColliderShape(t[r])},nd._onDisableInScene=function(){var e=this.scene.physics;e._removeCollider(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._removeColliderShape(t[r])},nd._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},nd._onDestroy=function(){dg.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nd._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},cZ(nc,[{key:"shapes",get:function(){return this._shapes}}]),nc),c1([c3],e.Collider.prototype,"_index",void 0),c1([c3],e.Collider.prototype,"_nativeCollider",void 0),c1([c3],e.Collider.prototype,"_updateFlag",void 0),c1([c5],e.Collider.prototype,"_shapes",void 0),e.Collider=c1([dy(db,e.DependentMode.CheckOnly)],e.Collider);var u9=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new dX,this._gravity=new cB(0,-9.81,0),this._onContactEnter=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t})},this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=e.engine;n._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var r=t.prototype;return r.raycast=function(t,r,n,a){var i,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(i=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(i=n),a&&(i=a);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==i?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var a=o._scene.engine._physicalObjectsMap[e];i.entity=a._collider.entity,i.shape=a,i.distance=t,i.normal.copyFrom(n),i.point.copyFrom(r)})||(i.entity=null,i.shape=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)n.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),r.update(t),this._callColliderOnLateUpdate()},r._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},r._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},r._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},r._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},r._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},r._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},r._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},r._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},r._gc=function(){this._colliders.garbageCollection()},r._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},cZ(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(e){this._fixedTimeStep=Math.max(e,cD.zeroTolerance)}}]),t}();u9._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nu=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nu.PreventClimbing=0]="PreventClimbing",nu[nu.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var u6=(nh=e.Collider,c0(n_=function(t){var r;return(r=nh.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new cB(0,1,0),r._slopeLimit=.707,r._nativeCollider=u9._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(cQ(r)),r._upDirection._onValueChanged=r._setUpDirection,r},nh),(nf=n_.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},nf.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nh.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nf.clearShapes=function(){this._shapes.length>0&&nh.prototype.removeShape.call(this,this._shapes[0])},nf._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var r=e.lossyWorldScale,n=0,a=t.length;n<a;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},nf._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},nf._onEnableInScene=function(){var e=this.scene.physics;e._addCharacterController(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._addColliderShape(t[r])},nf._onDisableInScene=function(){var e=this.scene.physics;e._removeCharacterController(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._removeColliderShape(t[r])},nf._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},cZ(n_,[{key:"stepOffset",get:function(){return this._stepOffset},set:function(e){this._stepOffset!==e&&(this._stepOffset=e,this._nativeCollider.setStepOffset(e))}},{key:"nonWalkableMode",get:function(){return this._nonWalkableMode},set:function(e){this._nonWalkableMode!==e&&(this._nonWalkableMode=e,this._nativeCollider.setNonWalkableMode(e))}},{key:"upDirection",get:function(){return this._upDirection},set:function(e){this._upDirection!==e&&this._upDirection.copyFrom(e)}},{key:"slopeLimit",get:function(){return this._slopeLimit},set:function(e){this._slopeLimit!==e&&(this._slopeLimit=e,this._nativeCollider.setSlopeLimit(e))}}]),n_),u7=(np=e.Collider,c0(nm=function(e){(t=np.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new cB,t._angularVelocity=new cB,t._mass=1,t._centerOfMass=new cB,t._inertiaTensor=new cB(1,1,1),t._maxAngularVelocity=100,t._maxDepenetrationVelocity=1e3,t._solverIterations=4,t._isKinematic=!1,t._constraints=0,t._collisionDetectionMode=0,t._sleepThreshold=.005;var t,r=t.entity.transform;return t._nativeCollider=u9._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(cQ(t)),t._setAngularVelocity=t._setAngularVelocity.bind(cQ(t)),t._setCenterOfMass=t._setCenterOfMass.bind(cQ(t)),t._setInertiaTensor=t._setInertiaTensor.bind(cQ(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},np),(ng=nm.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},ng.applyTorque=function(e){this._nativeCollider.addTorque(e)},ng.move=function(e,t){this._nativeCollider.move(e,t)},ng.sleep=function(){this._nativeCollider.sleep()},ng.wakeUp=function(){this._nativeCollider.wakeUp()},ng._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},ng._cloneTo=function(e){np.prototype._cloneTo.call(this,e),e.linearDamping=this.linearDamping,e.angularDamping=this.angularDamping,e.linearVelocity=this.linearVelocity,e.angularVelocity=this.angularVelocity,e.mass=this.mass,e.centerOfMass=this.centerOfMass,e.inertiaTensor=this.inertiaTensor,e.maxAngularVelocity=this.maxAngularVelocity,e.maxDepenetrationVelocity=this.maxDepenetrationVelocity,e.sleepThreshold=this.sleepThreshold,e.solverIterations=this.solverIterations,e.isKinematic=this.isKinematic,e.constraints=this.constraints,e.collisionDetectionMode=this.collisionDetectionMode},ng._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},ng._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},ng._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},ng._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},cZ(nm,[{key:"linearDamping",get:function(){return this._linearDamping},set:function(e){this._linearDamping!==e&&(this._linearDamping=e,this._nativeCollider.setLinearDamping(e))}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(e){this._angularDamping!==e&&(this._angularDamping=e,this._nativeCollider.setAngularDamping(e))}},{key:"linearVelocity",get:function(){return this._linearVelocity},set:function(e){this._linearVelocity!==e&&this._linearVelocity.copyFrom(e)}},{key:"angularVelocity",get:function(){return this._angularVelocity},set:function(e){this._angularVelocity!==e&&this._angularVelocity.copyFrom(e)}},{key:"mass",get:function(){return this._mass},set:function(e){this._mass!==e&&(this._mass=e,this._nativeCollider.setMass(e))}},{key:"centerOfMass",get:function(){return this._centerOfMass},set:function(e){this._centerOfMass!==e&&this._centerOfMass.copyFrom(e)}},{key:"inertiaTensor",get:function(){return this._inertiaTensor},set:function(e){this._inertiaTensor!==e&&this._inertiaTensor.copyFrom(e)}},{key:"maxAngularVelocity",get:function(){return this._maxAngularVelocity},set:function(e){this._maxAngularVelocity!==e&&(this._maxAngularVelocity=e,this._nativeCollider.setMaxAngularVelocity(e))}},{key:"maxDepenetrationVelocity",get:function(){return this._maxDepenetrationVelocity},set:function(e){this._maxDepenetrationVelocity!==e&&(this._maxDepenetrationVelocity=e,this._nativeCollider.setMaxDepenetrationVelocity(e))}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(e){e!==this._sleepThreshold&&(this._sleepThreshold=e,this._nativeCollider.setSleepThreshold(e))}},{key:"solverIterations",get:function(){return this._solverIterations},set:function(e){this._solverIterations!==e&&(this._solverIterations=e,this._nativeCollider.setSolverIterations(e))}},{key:"isKinematic",get:function(){return this._isKinematic},set:function(e){this._isKinematic!==e&&(this._isKinematic=e,this._nativeCollider.setIsKinematic(e))}},{key:"constraints",get:function(){return this._constraints},set:function(e){this._constraints!==e&&(this._constraints=e,this._nativeCollider.setConstraints(e))}},{key:"collisionDetectionMode",get:function(){return this._collisionDetectionMode},set:function(e){this._collisionDetectionMode!==e&&(this._collisionDetectionMode=e,this._nativeCollider.setCollisionDetectionMode(e))}}]),nm);c1([c3],u7.prototype,"_linearDamping",void 0),c1([c3],u7.prototype,"_angularDamping",void 0),c1([c3],u7.prototype,"_linearVelocity",void 0),c1([c3],u7.prototype,"_angularVelocity",void 0),c1([c3],u7.prototype,"_mass",void 0),c1([c3],u7.prototype,"_centerOfMass",void 0),c1([c3],u7.prototype,"_inertiaTensor",void 0),c1([c3],u7.prototype,"_maxAngularVelocity",void 0),c1([c3],u7.prototype,"_maxDepenetrationVelocity",void 0),c1([c3],u7.prototype,"_solverIterations",void 0),c1([c3],u7.prototype,"_isKinematic",void 0),c1([c3],u7.prototype,"_constraints",void 0),c1([c3],u7.prototype,"_collisionDetectionMode",void 0),c1([c3],u7.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(nv=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nv.Discrete=0]="Discrete",nv[nv.Continuous=1]="Continuous",nv[nv.ContinuousDynamic=2]="ContinuousDynamic",nv[nv.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(ny=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[ny.None=0]="None",ny[ny.FreezePositionX=1]="FreezePositionX",ny[ny.FreezePositionY=2]="FreezePositionY",ny[ny.FreezePositionZ=4]="FreezePositionZ",ny[ny.FreezeRotationX=8]="FreezeRotationX",ny[ny.FreezeRotationY=16]="FreezeRotationY",ny[ny.FreezeRotationZ=32]="FreezeRotationZ";var he=function(){this.entity=null,this.distance=0,this.point=new cB,this.normal=new cB,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(nx=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nx.Average=0]="Average",nx[nx.Minimum=1]="Minimum",nx[nx.Multiply=2]="Multiply",nx[nx.Maximum=3]="Maximum";var ht=((nb=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=u9._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},cZ(nb,[{key:"bounciness",get:function(){return this._bounciness},set:function(e){this._bounciness!==e&&(this._bounciness=e,this._nativeMaterial.setBounciness(e))}},{key:"dynamicFriction",get:function(){return this._dynamicFriction},set:function(e){this._dynamicFriction!==e&&(this._dynamicFriction=e,this._nativeMaterial.setDynamicFriction(e))}},{key:"staticFriction",get:function(){return this._staticFriction},set:function(e){this._staticFriction!==e&&(this._staticFriction=e,this._nativeMaterial.setStaticFriction(e))}},{key:"bounceCombine",get:function(){return this._bounceCombine},set:function(e){this._bounceCombine!==e&&(this._bounceCombine=e,this._nativeMaterial.setBounceCombine(e))}},{key:"frictionCombine",get:function(){return this._frictionCombine},set:function(e){this._frictionCombine!==e&&(this._frictionCombine=e,this._nativeMaterial.setFrictionCombine(e))}}]),nb),hr=(nS=e.Collider,c0(nT=function(e){var t,r=(t=nS.call(this,e)||this).entity.transform;return t._nativeCollider=u9._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},nS),nT);e.ColliderShapeUpAxis=void 0,(nC=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nC.X=0]="X",nC[nC.Y=1]="Y",nC[nC.Z=2]="Z",e.ControllerCollisionFlag=void 0,(nA=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[nA.Sides=1]="Sides",nA[nA.Up=2]="Up",nA[nA.Down=4]="Down",e.Joint=(c0(nE=function(e){var t;return(t=dg.call(this,e)||this)._colliderInfo=new hn,t._connectedColliderInfo=new hn,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new cB,t},dg),nE.prototype._cloneTo=function(e){e.connectedCollider=this.connectedCollider,e.connectedAnchor=this.connectedAnchor,e.connectedMassScale=this.connectedMassScale,e.connectedInertiaScale=this.connectedInertiaScale,e.massScale=this.massScale,e.inertiaScale=this.inertiaScale,e.breakForce=this.breakForce,e.breakTorque=this.breakTorque},cZ(nE,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){this._connectedColliderInfo.collider!==e&&(this._connectedColliderInfo.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){e!==this._connectedColliderInfo.massScale&&(this._connectedColliderInfo.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){e!==this._connectedColliderInfo.inertiaScale&&(this._connectedColliderInfo.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._colliderInfo.massScale},set:function(e){e!==this._colliderInfo.massScale&&(this._colliderInfo.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._colliderInfo.inertiaScale},set:function(e){e!==this._colliderInfo.inertiaScale&&(this._colliderInfo.inertiaScale=e,this._nativeJoint.setInertiaScale(e))}},{key:"breakForce",get:function(){return this._force},set:function(e){e!==this._force&&(this._force=e,this._nativeJoint.setBreakForce(e))}},{key:"breakTorque",get:function(){return this._torque},set:function(e){e!==this._torque&&(this._torque=e,this._nativeJoint.setBreakTorque(e))}}]),nE),c1([c3],e.Joint.prototype,"_colliderInfo",void 0),c1([c3],e.Joint.prototype,"_connectedColliderInfo",void 0),c1([c3],e.Joint.prototype,"_nativeJoint",void 0),c1([c3],e.Joint.prototype,"_force",void 0),c1([c3],e.Joint.prototype,"_torque",void 0),e.Joint=c1([dy(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var hn=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},ha=(nM=e.Joint,c0(nR=function(){return nM.apply(this,arguments)},nM),nR.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=u9._nativePhysics.createFixedJoint(t.collider._nativeCollider)},nR);(nw=cs||(cs={}))[nw.None=0]="None",nw[nw.LimitEnabled=1]="LimitEnabled",nw[nw.DriveEnabled=2]="DriveEnabled",nw[nw.DriveFreeSpin=4]="DriveFreeSpin";var hi=(nP=e.Joint,c0(nF=function(){var e;return e=nP.apply(this,arguments)||this,e._axis=new cB(1,0,0),e._hingeFlags=cs.None,e._useSpring=!1,e},nP),(nL=nF.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cB,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=u9._nativePhysics.createHingeJoint(t.collider._nativeCollider)},nL._cloneTo=function(e){e.axis=this.axis,e.swingOffset=this.swingOffset,e.useLimits=this.useLimits,e.useMotor=this.useMotor,e.useSpring=this.useSpring,e.motor=this.motor,e.limits=this.limits},cZ(nF,[{key:"axis",get:function(){return this._axis},set:function(e){var t=this._axis;e!==t&&t.copyFrom(e),this._nativeJoint.setAxis(t)}},{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(t)}},{key:"angle",get:function(){return this._nativeJoint.getAngle()}},{key:"velocity",get:function(){return this._nativeJoint.getVelocity()}},{key:"useLimits",get:function(){return(this._hingeFlags&cs.LimitEnabled)==cs.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=cs.LimitEnabled:this._hingeFlags&=~cs.LimitEnabled,this._nativeJoint.setHingeJointFlag(cs.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&cs.DriveEnabled)==cs.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=cs.DriveEnabled:this._hingeFlags&=~cs.DriveEnabled,this._nativeJoint.setHingeJointFlag(cs.DriveEnabled,e))}},{key:"useSpring",get:function(){return this._useSpring},set:function(e){this._useSpring!==e&&(this._useSpring=e,this.limits=this._limits)}},{key:"motor",get:function(){return this._jointMonitor},set:function(e){this._jointMonitor!==e&&(this._jointMonitor=e,this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRation),this._nativeJoint.setHingeJointFlag(cs.DriveFreeSpin,e.freeSpin))}},{key:"limits",get:function(){return this._limits},set:function(e){this._limits!==e&&(this._limits=e,this.useSpring?this._nativeJoint.setSoftLimit(e.min,e.max,e.stiffness,e.damping):this._nativeJoint.setHardLimit(e.min,e.max,e.contactDistance))}}]),nF);c1([c3],hi.prototype,"_axis",void 0),c1([c3],hi.prototype,"_hingeFlags",void 0),c1([c3],hi.prototype,"_useSpring",void 0),c1([c3],hi.prototype,"_jointMonitor",void 0),c1([c3],hi.prototype,"_limits",void 0);var ho=(nD=e.Joint,c0(nB=function(){var e;return e=nD.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},nD),(nI=nB.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cB,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=u9._nativePhysics.createSpringJoint(t.collider._nativeCollider)},nI._cloneTo=function(e){e.swingOffset=this.swingOffset,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.tolerance=this.tolerance,e.stiffness=this.stiffness,e.damping=this.damping},cZ(nB,[{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(e)}},{key:"minDistance",get:function(){return this._minDistance},set:function(e){this._minDistance!==e&&(this._minDistance=e,this._nativeJoint.setMinDistance(e))}},{key:"maxDistance",get:function(){return this._maxDistance},set:function(e){this._maxDistance!==e&&(this._maxDistance=e,this._nativeJoint.setMaxDistance(e))}},{key:"tolerance",get:function(){return this._tolerance},set:function(e){this._tolerance!==e&&(this._tolerance=e,this._nativeJoint.setTolerance(e))}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){this._stiffness!==e&&(this._stiffness=e,this._nativeJoint.setStiffness(e))}},{key:"damping",get:function(){return this._damping},set:function(e){this._damping!==e&&(this._damping=e,this._nativeJoint.setDamping(e))}}]),nB),hs=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},hl=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},hc=function(){function e(){this._isTrigger=!1,this._rotation=new cB,this._position=new cB,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new ht,this._id=e._idGenerator++,this._setRotation=this._setRotation.bind(this),this._setPosition=this._setPosition.bind(this),this._rotation._onValueChanged=this._setRotation,this._position._onValueChanged=this._setPosition}var t=e.prototype;return t._cloneTo=function(e){e.contactOffset=this.contactOffset,e.rotation=this.rotation,e.position=this.position,e.isTrigger=this.isTrigger,e.material=this.material},t._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},cZ(e,[{key:"collider",get:function(){return this._collider}},{key:"id",get:function(){return this._id}},{key:"contactOffset",get:function(){return this._contactOffset},set:function(e){this._contactOffset!==e&&(this._contactOffset=e,this._nativeShape.setContactOffset(e))}},{key:"material",get:function(){return this._material},set:function(e){this._material!==e&&(this._material=e,this._nativeShape.setMaterial(e._nativeMaterial))}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation!=e&&this._rotation.copyFrom(e)}},{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(e){this._isTrigger!==e&&(this._isTrigger=e,this._nativeShape.setIsTrigger(e))}}]),e}();hc._idGenerator=0,c1([c3],hc.prototype,"_collider",void 0),c1([c3],hc.prototype,"_nativeShape",void 0),c1([c3],hc.prototype,"_id",void 0),c1([c3],hc.prototype,"_material",void 0),c1([c3],hc.prototype,"_isTrigger",void 0),c1([c3],hc.prototype,"_rotation",void 0),c1([c3],hc.prototype,"_position",void 0),c1([c3],hc.prototype,"_contactOffset",void 0);var hd=(c0(nV=function(){var e;return(e=hc.call(this)||this)._size=new cB(1,1,1),e._nativeShape=u9._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(cQ(e)),e._size._onValueChanged=e._setSize,e},hc),(nO=nV.prototype)._cloneTo=function(e){hc.prototype._cloneTo.call(this,e),e.size=this.size},nO._setSize=function(){this._nativeShape.setSize(this._size)},cZ(nV,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),nV);c1([c3],hd.prototype,"_size",void 0);var hu=(c0(nN=function(){var e;return(e=hc.call(this)||this)._radius=1,e._nativeShape=u9._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},hc),nN.prototype._cloneTo=function(e){hc.prototype._cloneTo.call(this,e),e.radius=this.radius},cZ(nN,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),nN);c1([c3],hu.prototype,"_radius",void 0);var hh=(c0(nk=function(){var e;return(e=hc.call(this)||this)._nativeShape=u9._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},hc),nk),h_=(c0(nz=function(){var t;return(t=hc.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=u9._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},hc),nz.prototype._cloneTo=function(e){hc.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},cZ(nz,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._nativeShape.setHeight(e))}},{key:"upAxis",get:function(){return this._upAxis},set:function(e){this._upAxis!==e&&(this._upAxis=e,this._nativeShape.setUpAxis(e))}}]),nz);c1([c3],h_.prototype,"_radius",void 0),c1([c3],h_.prototype,"_height",void 0),c1([c3],h_.prototype,"_upAxis",void 0);var hf=((nG=(nU=function(t,r){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new dX,this._downList=new dX,this._nativeEvents=[],"undefined"!=typeof Window&&c2(r,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=t,this._target=r,this._canvas=t.canvas,this._htmlCanvas=t._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,a=this._canvas,i=a.width,o=a.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),d=c.left,u=c.top,h=i/s,_=o/l,f=t.length-1;f>=0;f--)t[f].phase===e.PointerPhase.Leave&&t.splice(f,1);for(var p=0,m=r.length;p<m;p++){var g=r[p],v=g.pointerId,y=this._getPointerByID(v);if(y)y._events.push(g);else{var x=t.length;if(0===x||this._multiPointerEnabled){for(var b,S=this._pointerPool,T=0;T<x&&!(t[T].id>T);T++);(y=S[b=T]||(S[b]=new u2(T)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-d)*h,(g.clientY-u)*_),t.splice(T,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var C=this._engine.time.frameCount,A=0,E=t.length;A<E;A++){var M=t[A];M._upList.length=M._downList.length=0,this._updatePointerInfo(C,M,d,u,h,_),this._buttons|=M.pressedButtons}},nG._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,a=0,i=r.length;a<i;a++){var o=r[a],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/n.width,l.y/n.height);o._firePointerExitAndEnter(c);var d=s.length;if(d>0){for(var u=0;u<d;u++)switch(s[u].type){case"pointerdown":o.phase=e.PointerPhase.Down,o._firePointerDown(c);break;case"pointerup":o.phase=e.PointerPhase.Up,o._firePointerUpAndClick(c);break;case"pointerleave":case"pointercancel":o.phase=e.PointerPhase.Leave,o._firePointerExitAndEnter(null)}s.length=0}}},nG._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},nG._onPointerEvent=function(e){this._nativeEvents.push(e)},nG._getPointerByID=function(e){for(var t=this._pointers,r=t.length-1;r>=0;r--)if(t[r]._uniqueID===e)return t[r];return null},nG._updatePointerInfo=function(t,r,n,a,i,o){var s=r._events,l=r.position,c=s.length;if(c>0){var d=this._upList,u=this._upMap,h=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-n)*i,m=(f.clientY-a)*o;r.deltaPosition.set(p-l.x,m-l.y),l.set(p,m);for(var g=0;g<c;g++){var v=s[g],y=v.button;switch(r.button=u3[y]||e.PointerButton.None,r.pressedButtons=v.buttons,v.type){case"pointerdown":h.add(y),_[y]=t,r._downList.add(y),r._downMap[y]=t,r.phase=e.PointerPhase.Down;break;case"pointerup":d.add(y),u[y]=t,r._upList.add(y),r._upMap[y]=t,r.phase=e.PointerPhase.Up;break;case"pointermove":r.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":r.phase=e.PointerPhase.Leave}}this._engine._physicsInitialized||(s.length=0)}else r.deltaPosition.set(0,0),r.phase=e.PointerPhase.Stationary},nG._pointerRayCast=function(t,r,n){for(var a=nU._tempPoint,i=nU._tempRay,o=nU._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,d=c._elements,u=c.length-1;u>=0;u--){var h=d[u];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(r>=f&&n>=p&&r-f<=m&&n-p<=g){if(a.set((r-f)/m,(n-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},nG._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},nG._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},nU);hf._tempRay=new cH,hf._tempPoint=new cW,hf._tempHitResult=new he;var hp=((nW=(nH=function(e,t){this._delta=new cB,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var r=t.length-1;r>=0;r--){var n=t[r];e.x+=n.deltaX,e.y+=n.deltaY,e.z+=n.deltaZ}t.length=0}},nW._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},nW._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},nW._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},nW._onWheelEvent=function(e){this._nativeEvents.push(e)},nH),hm=((nj=(nK=function(e,t){this._initialized=!1,this._engine=e;var r,n,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&c2(i,OffscreenCanvas)||(this._wheelManager=new hp(e,null!=(r=null==t?void 0:t.wheelTarget)?r:i),this._pointerManager=new hf(e,null!=(n=null==t?void 0:t.pointerTarget)?n:i),this._keyboardManager=new u5(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},nj.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},nj.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},nj.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},nj.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[u4[e]]===this._engine.time.frameCount)},nj.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[u4[e]]===this._engine.time.frameCount)},nj._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},nj._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},nj._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},cZ(nK,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return!!this._initialized&&this._pointerManager._multiPointerEnabled},set:function(e){this._initialized&&(this._pointerManager._multiPointerEnabled=e)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),nK);(cl||(cl={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(nX=cc||(cc={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",nX.DirectionTime="a_DirectionTime",nX.StartColor="a_StartColor",nX.StartSize="a_StartSize",nX.StartRotation0="a_StartRotation0",nX.StartSpeed="a_StartSpeed",nX.Random0="a_Random0",nX.Random1="a_Random1",nX.SimulationWorldPosition="a_SimulationWorldPosition",nX.SimulationWorldRotation="a_SimulationWorldRotation",nX.SimulationUV="a_SimulationUV";var hg=function(t){this.billboardVertexElement=new d1(cl.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new d1(cc.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new d1(cc.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new d1(cc.StartColor,32,e.VertexElementFormat.Vector4,1,1),new d1(cc.StartSize,48,e.VertexElementFormat.Vector3,1,1),new d1(cc.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new d1(cc.StartSpeed,72,e.VertexElementFormat.Float,1,1),new d1(cc.Random0,76,e.VertexElementFormat.Vector4,1,1),new d1(cc.Random1,92,e.VertexElementFormat.Vector4,1,1),new d1(cc.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new d1(cc.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new d1(cc.SimulationUV,136,e.VertexElementFormat.Vector4,1,1)],this.instanceVertexStride=152,this.instanceVertexFloatStride=this.instanceVertexStride/4,this.startLifeTimeOffset=3,this.timeOffset=7,this.simulationUVOffset=34,this.billboardIndexCount=6;var r,n,a=new dq(t,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);a.isGCIgnored=!0,this.billboardVertexBufferBinding=new d0(a,16);var i=new dq(t,e.BufferBindFlag.IndexBuffer,this.billboardIndexCount,e.BufferUsage.Static,!1);i.isGCIgnored=!0,this.billboardIndexBufferBinding=new dQ(i,e.IndexFormat.UInt8);var o=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),s=new Uint8Array([0,2,3,0,1,2]);a.setData(o),i.setData(s),t.resourceManager.addContentRestorer(new(c0(r=function(){return un.call(this,a)},un),r.prototype.restoreContent=function(){a.setData(o)},r)),t.resourceManager.addContentRestorer(new(c0(n=function(){return un.call(this,i)},un),n.prototype.restoreContent=function(){},n))},hv="#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}",hy=((nq=function(){}).init=function(){var t=new dL("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nvoid main(){\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",{pipelineStage:e.PipelineStage.ShadowCaster}),r=new dL("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:e.PipelineStage.DepthOnly}),n=[t,r],a={pipelineStage:e.PipelineStage.Forward};dz.create("blinn-phong",[].concat(new dL("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dz.create("pbr",[].concat(new dL("Forward",hv,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dz.create("pbr-specular",[].concat(new dL("Forward",hv,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dz.create("unlit",[].concat(new dL("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dz.create("blit",[new dL("Forward","#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}","#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}",a)]),dz.create("skybox",[new dL("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dz.create("SkyProcedural",[new dL("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dz.create("particle-shader",[new dL("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dz.create("SpriteMask",[new dL("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",a)]),dz.create("Sprite",[new dL("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),dz.create("background-texture",[new dL("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",a)])},nq),hx=((nQ=(nY=function(){this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,r=e._length,n=this._cacheHierarchyDepth;r>n&&(this._resizeCacheMapHierarchy(t,0,n,r-n),this._cacheHierarchyDepth=r);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var d=i<o?0:a[o],u=t[d];return u||(this._lastQueryKey=d,this._lastQueryMap=t),u},nQ.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},nQ._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},nQ._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var r in t)t[r].destroy();return}for(var n in++e,t)this._recursiveDestroy(e,t[n])},nQ._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var a in e){for(var i=e[a],o=e,s=0;s<n;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},nY),hb=((nZ=(nJ=function(){}).prototype)._initialize=function(e,t){},nZ._update=function(){},nZ._destroy=function(){},nZ._getRequestAnimationFrame=function(){return null},nZ._getCancelAnimationFrame=function(){return null},nZ._getCameraClearFlagsMask=function(t){return e.CameraClearFlags.None},nJ);hy.init();var hS=function(t){function r(n,a,i){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new dk,o._renderElementPool=new uy(uG),o._renderDataPool=new uy(uU),o._spriteRenderDataPool=new uy(uj),o._spriteMaskRenderDataPool=new uy(uK),o._textRenderDataPool=new uy(uX),o._spriteDefaultMaterials=[],o._renderContext=new uz,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new dT,o._settings={},o._resourceManager=new uJ(cQ(o)),o._sceneManager=new uY(cQ(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new dm,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){if(o._vSyncCount){var e,t=(null==(e=o.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;o._requestId=t(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)}else o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update()},o._hardwareRenderer=a,o._hardwareRenderer.init(n,o._onDeviceLost.bind(cQ(o)),o._onDeviceRestored.bind(cQ(o))),o._canvas=n,o._spriteMaskManager=new uW(cQ(o));var o,s=cQ(o)._spriteDefaultMaterials;o._spriteDefaultMaterial=s[e.SpriteMaskInteraction.None]=o._createSpriteMaterial(e.SpriteMaskInteraction.None),s[e.SpriteMaskInteraction.VisibleInsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleInsideMask),s[e.SpriteMaskInteraction.VisibleOutsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleOutsideMask),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=uR.createFromOS(cQ(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new hm(cQ(o),i.input);var l=i.xrDevice;if(l&&(o.xrManager=new hb,o.xrManager._initialize(cQ(o),l)),a.canIUse(e.GLCapabilityType.depthTexture)){var c=new d9(cQ(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(r._noDepthTextureMacro);var d=new uL(cQ(o),dz.find("unlit"));d.isGCIgnored=!0,d.shaderData.setColor("material_BaseColor",new cj(1,0,1.01,1)),o._meshMagentaMaterial=d;var u=new uL(cQ(o),dz.find("particle-shader"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new cj(1,0,1.01,1)),o._particleMagentaMaterial=u;var h=o._settings,_=i.colorSpace||e.ColorSpace.Linear;return _===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),h.colorSpace=_,o._basicResources=new uk(cQ(o)),o._particleBufferUtils=new hg(cQ(o)),o}c0(r,t);var n=r.prototype;return n.createEntity=function(e){return new um(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var r=t.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._renderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool(),null==(e=this.xrManager)||e._update();var n=this.inputManager,a=this._physicsInitialized;n._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var d=0;d<o;d++){var u=i[d];u.isActive&&!u.destroyed&&u.physics._update(r)}a&&n._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(r)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(r)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(r)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._spriteMaskManager.destroy(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,r=this._shaderProgramPools,n=r[t];if(!n){var a=t+1;a>r.length&&(r.length=a),r[t]=n=new hx,e._shaderProgramPools.push(n)}return n},n._render=function(e){for(var t=this,r=this.time.deltaTime,n=0,a=e.length;n<a;n++){var i=e[n];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(r),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(r,n){var a=e[r];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return df.debug("No active camera in scene.");i.forEach(function(e){var r=a._componentsManager;r.callCameraOnBeginRender(e),e.render(),r.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&(dz._shaderLab=r);var a=[];n&&a.push(n.initialize().then(function(){return u9._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=uJ._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new uL(this,dz.find("Sprite")),n=r.renderState,a=n.blendState.targetBlendState;if(a.enabled=!0,a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var i=n.stencilState;i.enabled=!0,i.writeMask=0,i.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;i.compareFunctionFront=o,i.compareFunctionBack=o}return n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,n.renderQueueType=e.RenderQueueType.Transparent,r.isGCIgnored=!0,r},n._createSpriteMaskMaterial=function(){var t=new uL(this,dz.find("SpriteMask")),r=t.renderState;return r.blendState.targetBlendState.colorWriteMask=e.ColorWriteMask.None,r.rasterState.cullMode=e.CullMode.Off,r.stencilState.enabled=!0,r.depthState.enabled=!1,t.isGCIgnored=!0,t},n._onDeviceLost=function(){this._isDeviceLost=!0,this.resourceManager._lostGraphicResources(),console.log("Device lost."),this.dispatch("devicelost",this)},n._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new dk,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._renderElementPool.garbageCollection(),this._renderDataPool.garbageCollection(),this._spriteRenderDataPool.garbageCollection(),this._spriteMaskRenderDataPool.garbageCollection(),this._textRenderDataPool.garbageCollection(),this._renderContext.garbageCollection()},cZ(r,[{key:"settings",get:function(){return this._settings}},{key:"canvas",get:function(){return this._canvas}},{key:"resourceManager",get:function(){return this._resourceManager}},{key:"sceneManager",get:function(){return this._sceneManager}},{key:"time",get:function(){return this._time}},{key:"isPaused",get:function(){return this._isPaused}},{key:"vSyncCount",get:function(){return this._vSyncCount},set:function(e){this._vSyncCount=Math.max(0,Math.floor(e))}},{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(e){e=Math.max(1e-6,e),this._targetFrameRate=e,this._targetFrameInterval=1e3/e}},{key:"destroyed",get:function(){return this._destroyed}},{key:"physicsManager",get:function(){var e;return null==(e=this.sceneManager.scenes[0])?void 0:e.physics}}]),r}(dl);hS._gammaMacro=dS.getByName("ENGINE_IS_COLORSPACE_GAMMA"),hS._noDepthTextureMacro=dS.getByName("ENGINE_NO_DEPTH_TEXTURE"),hS._pixelsPerUnit=100;var hT=(cZ(n$=function(){this._sizeUpdateFlagManager=new di},[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._onWidthChanged(e),this._sizeUpdateFlagManager.dispatch())}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._onHeightChange(e),this._sizeUpdateFlagManager.dispatch())}}]),n$);e.BackgroundMode=void 0,(n0=e.BackgroundMode||(e.BackgroundMode={}))[n0.SolidColor=0]="SolidColor",n0[n0.Sky=1]="Sky",n0[n0.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(n1=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[n1.AspectFitWidth=0]="AspectFitWidth",n1[n1.AspectFitHeight=1]="AspectFitHeight",n1[n1.Fill=2]="Fill";var hC=((n3=(n2=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},n3._render=function(e){var t=this.material,r=this.mesh;if(!t){df.warn("The material of sky is not defined.");return}if(t.destroyed){df.warn("The material of sky is destroyed.");return}if(!r){df.warn("The mesh of sky is not defined.");return}if(r.destroyed){df.warn("The mesh of sky is destroyed.");return}var n=e.camera,a=n.engine,i=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,d=i.shaderData,u=n2._viewProjMatrix,h=n2._projectionMatrix,_=a._hardwareRenderer,f=t.shaderData,p=t.shader,m=t.renderState;u.copyFrom(l);var g=u.elements;g[12]=g[13]=g[14]=0;var v=1/Math.tan(cD.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,cG.multiply(h,u,u);var y=c.getMatrix(uz.vpMatrixProperty);e.flipProjection&&cG.multiply(uz._flipYMatrix,u,u),c.setMatrix(uz.vpMatrixProperty,u);var x=dz._compileMacros;dT.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var b=p.subShaders[0].passes[0],S=b._getShaderProgram(a,x);S.bind(),S.groupingOtherUniformBlock(),S.uploadAll(S.sceneUniformBlock,d),S.uploadAll(S.cameraUniformBlock,c),S.uploadAll(S.materialUniformBlock,f),S.uploadUnGroupTextures(),m._apply(a,!1,b._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,S),c.setMatrix(uz.vpMatrixProperty,y)},cZ(n2,[{key:"material",get:function(){return this._material},set:function(e){if(this._material!==e){var t;null==e||e._addReferCount(1),null==(t=this._material)||t._addReferCount(-1),this._material=e}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==e||e._addReferCount(1),null==(t=this._mesh)||t._addReferCount(-1),this._mesh=e}}}]),n2);hC._epsilon=1e-6,hC._viewProjMatrix=new cG,hC._projectionMatrix=new cG(1,0,0,0,0,1,0,0,0,0,hC._epsilon-1,-1,0,0,0,0);var hA=((n8=(n4=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new cj(.25,.25,.25,1),this.sky=new hC,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._initMesh(t),this._initMaterial(t)}).prototype).destroy=function(){this.texture=null,this._mesh._addReferCount(-1),this._mesh=null,this._material._addReferCount(-1),this._material=null,this.solidColor=null,this.sky.destroy()},n8._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,a=n.width,i=n.height,o=r.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.Fill:o[0].set(-1,-1,1),o[1].set(1,-1,1),o[2].set(-1,1,1),o[3].set(1,1,1);break;case e.BackgroundTextureFillMode.AspectFitWidth:var s=t.height*a/t.width/i;o[0].set(-1,-s,1),o[1].set(1,-s,1),o[2].set(-1,s,1),o[3].set(1,s,1);break;case e.BackgroundTextureFillMode.AspectFitHeight:var l=t.width*i/t.height/a;o[0].set(-l,-1,1),o[1].set(l,-1,1),o[2].set(-l,1,1),o[3].set(l,1,1)}r.setPositions(o),r.uploadData(!1)}},n8._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},n8._initMaterial=function(t){var r=this._material=new uL(t,dz.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},n8._createPlane=function(e){for(var t=new ut(e),r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],a=[,,,,],i=0;i<4;++i)n[i]=new cB,a[i]=new cW(i%2,1-(.5*i|0));return t.setPositions(n),t.setUVs(a),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},cZ(n4,[{key:"texture",get:function(){return this._texture},set:function(e){if(this._texture!==e){var t;null==e||e._addReferCount(1),null==(t=this._texture)||t._addReferCount(-1),this._texture=e,this._material.shaderData.setTexture("material_BaseTexture",e),this._resizeBackgroundTexture()}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),n4),hE=((n9=(n5=function(){this._cameraNeedSorting=!1,this._activeCameras=new dX,this._renderers=new dX,this._onStartScripts=new dX,this._onUpdateScripts=new dX,this._onLateUpdateScripts=new dX,this._onPhysicsUpdateScripts=new dX,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new dX,this._onUpdateRenderers=new dX,this._componentsContainerPool=[]}).prototype).addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},n9.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},n9.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,r=e.length;t<r;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},n9.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},n9.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},n9.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},n9.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},n9.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},n9.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},n9.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},n9.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},n9.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},n9.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},n9.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},n9.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},n9.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},n9.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},n9.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},n9.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},n9.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.engine.time.frameCount>t._playFrameCount&&t.update(e)},function(e,t){e._onUpdateIndex=t})},n9.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},n9.handlingInvalidScripts=function(){var e=this._disposeDestroyScripts,t=this._pendingDestroyScripts;this._disposeDestroyScripts=t,this._pendingDestroyScripts=e;var r=t.length;if(r>0){for(var n=r-1;n>=0;n--)t[n].onDestroy();t.length=0}},n9.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},n9.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},n9.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},n9.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},n9._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},n5);e.FogMode=void 0,(n6=e.FogMode||(e.FogMode={}))[n6.None=0]="None",n6[n6.Linear=1]="Linear",n6[n6.Exponential=2]="Exponential",n6[n6.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n7=e.DiffuseMode||(e.DiffuseMode={}))[n7.SolidColor=0]="SolidColor",n7[n7.SphericalHarmonics=1]="SphericalHarmonics";var hM=(c0(ae=function(t){var r;return(r=c7.call(this,t)||this)._diffuseSolidColor=new cj(.212,.227,.259),r._diffuseIntensity=1,r._specularIntensity=1,r._diffuseMode=e.DiffuseMode.SolidColor,r._shArray=new Float32Array(27),r._scenes=[],r._specularTextureDecodeRGBM=!1,r},c7),(at=ae.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(ae._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(ae._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(ae._specularIntensityProperty,this._specularIntensity),t.setFloatArray(ae._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},at._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(ae._specularTextureProperty,null),n.disableMacro(ae._specularMacro)},at._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(ae._shMacro):t.disableMacro(ae._shMacro)},at._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(ae._specularTextureProperty,this._specularTexture),e.setFloat(ae._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(ae._specularMacro)):e.disableMacro(ae._specularMacro)},at._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(ae._decodeRGBMMacro):e.disableMacro(ae._decodeRGBMMacro)},at._preComputeSH=function(e,t){var r=e.coefficients;t[0]=.886227*r[0],t[1]=.886227*r[1],t[2]=.886227*r[2],t[3]=-1.023327*r[3],t[4]=-1.023327*r[4],t[5]=-1.023327*r[5],t[6]=1.023327*r[6],t[7]=1.023327*r[7],t[8]=1.023327*r[8],t[9]=-1.023327*r[9],t[10]=-1.023327*r[10],t[11]=-1.023327*r[11],t[12]=.858086*r[12],t[13]=.858086*r[13],t[14]=.858086*r[14],t[15]=-.858086*r[15],t[16]=-.858086*r[16],t[17]=-.858086*r[17],t[18]=.247708*r[18],t[19]=.247708*r[19],t[20]=.247708*r[20],t[21]=-.858086*r[21],t[22]=-.858086*r[22],t[23]=-.858086*r[23],t[24]=.429042*r[24],t[25]=.429042*r[25],t[26]=.429042*r[26]},cZ(ae,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTextureDecodeRGBM(t[r].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setDiffuseMode(t[r].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloatArray(ae._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloat(ae._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTexture(t[r].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var t=0,r=this._scenes.length;t<r;t++)this._scenes[t].shaderData.setFloat(ae._specularIntensityProperty,e)}}]),ae);hM._shMacro=dS.getByName("SCENE_USE_SH"),hM._specularMacro=dS.getByName("SCENE_USE_SPECULAR_ENV"),hM._decodeRGBMMacro=dS.getByName("SCENE_IS_DECODE_ENV_RGBM"),hM._diffuseColorProperty=dp.getByName("scene_EnvMapLight.diffuse"),hM._diffuseSHProperty=dp.getByName("scene_EnvSH"),hM._diffuseIntensityProperty=dp.getByName("scene_EnvMapLight.diffuseIntensity"),hM._specularTextureProperty=dp.getByName("scene_EnvSpecularSampler"),hM._specularIntensityProperty=dp.getByName("scene_EnvMapLight.specularIntensity"),hM._mipLevelProperty=dp.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(ar=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[ar.NoCascades=1]="NoCascades",ar[ar.TwoCascades=2]="TwoCascades",ar[ar.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(an=e.ShadowResolution||(e.ShadowResolution={}))[an.Low=0]="Low",an[an.Medium=1]="Medium",an[an.High=2]="High",an[an.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(aa=e.ShadowType||(e.ShadowType={}))[aa.None=0]="None",aa[aa.Hard=1]="Hard",aa[aa.SoftLow=2]="SoftLow",aa[aa.SoftHigh=3]="SoftHigh";var hR=(c0(ai=function(){var t;return t=dg.apply(this,arguments)||this,t.intensity=1,t.cullingMask=e.Layer.Everything,t.shadowType=e.ShadowType.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t.shadowStrength=1,t._lightIndex=-1,t._lightColor=new cj,t._color=new cj(1,1,1,1),t},dg),ai.prototype._getLightIntensityColor=function(){return this._lightColor.r=this.color.r*this.intensity,this._lightColor.g=this.color.g*this.intensity,this._lightColor.b=this.color.b*this.intensity,this._lightColor.a=this.color.a*this.intensity,this._lightColor},cZ(ai,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"viewMatrix",get:function(){return this._viewMat||(this._viewMat=new cG),cG.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new cG),cG.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),ai);c1([c3],hR.prototype,"_lightIndex",void 0);var hw=(c0(ao=function(){var e;return e=hR.apply(this,arguments)||this,e._reverseDirection=new cB,e},hR),(as=ao.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.direction,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cj.gammaToLinearSpace(o.r),r.color[a+1]=cj.gammaToLinearSpace(o.g),r.color[a+2]=cj.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.direction[i]=s.x,r.direction[i+1]=s.y,r.direction[i+2]=s.z},as._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},as._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},ao._updateShaderData=function(e,t){e.setIntArray(ao._cullingMaskProperty,t.cullingMask),e.setFloatArray(ao._colorProperty,t.color),e.setFloatArray(ao._directionProperty,t.direction)},cZ(ao,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cB.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),ao);hw._cullingMaskProperty=dp.getByName("scene_DirectLightCullingMask"),hw._colorProperty=dp.getByName("scene_DirectLightColor"),hw._directionProperty=dp.getByName("scene_DirectLightDirection");var hP=(c0(al=function(){var e;return e=hR.apply(this,arguments)||this,e.distance=100,e},hR),(ac=al.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cj.gammaToLinearSpace(o.r),r.color[a+1]=cj.gammaToLinearSpace(o.g),r.color[a+2]=cj.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.position[i]=s.x,r.position[i+1]=s.y,r.position[i+2]=s.z,r.distance[t]=this.distance},ac._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},ac._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},al._updateShaderData=function(e,t){e.setIntArray(al._cullingMaskProperty,t.cullingMask),e.setFloatArray(al._colorProperty,t.color),e.setFloatArray(al._positionProperty,t.position),e.setFloatArray(al._distanceProperty,t.distance)},cZ(al,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),al);hP._cullingMaskProperty=dp.getByName("scene_PointLightCullingMask"),hP._colorProperty=dp.getByName("scene_PointLightColor"),hP._positionProperty=dp.getByName("scene_PointLightPosition"),hP._distanceProperty=dp.getByName("scene_PointLightDistance");var hF=(c0(ad=function(){var e;return e=hR.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new cB,e._projectMatrix=new cG,e},hR),(au=ad.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,d=this.cullingMask;r.cullingMask[n]=65535&d,r.cullingMask[n+1]=d>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cj.gammaToLinearSpace(s.r),r.color[a+1]=cj.gammaToLinearSpace(s.g),r.color[a+2]=cj.gammaToLinearSpace(s.b)):(r.color[a]=s.r,r.color[a+1]=s.g,r.color[a+2]=s.b),r.position[i]=l.x,r.position[i+1]=l.y,r.position[i+2]=l.z,r.direction[o]=c.x,r.direction[o+1]=c.y,r.direction[o+2]=c.z,r.distance[t]=this.distance,r.angleCos[t]=Math.cos(this.angle),r.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},au._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},au._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},ad._updateShaderData=function(e,t){e.setIntArray(ad._cullingMaskProperty,t.cullingMask),e.setFloatArray(ad._colorProperty,t.color),e.setFloatArray(ad._positionProperty,t.position),e.setFloatArray(ad._directionProperty,t.direction),e.setFloatArray(ad._distanceProperty,t.distance),e.setFloatArray(ad._angleCosProperty,t.angleCos),e.setFloatArray(ad._penumbraCosProperty,t.penumbraCos)},cZ(ad,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cB.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}},{key:"_shadowProjectionMatrix",get:function(){var e=this._projectMatrix,t=Math.min(Math.PI/2,2*this.angle*Math.sqrt(2));return cG.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),ad);hF._cullingMaskProperty=dp.getByName("scene_SpotLightCullingMask"),hF._colorProperty=dp.getByName("scene_SpotLightColor"),hF._positionProperty=dp.getByName("scene_SpotLightPosition"),hF._directionProperty=dp.getByName("scene_SpotLightDirection"),hF._distanceProperty=dp.getByName("scene_SpotLightDistance"),hF._angleCosProperty=dp.getByName("scene_SpotLightAngleCos"),hF._penumbraCosProperty=dp.getByName("scene_SpotLightPenumbraCos");var hL=function(){function t(){this._spotLights=new dX,this._pointLights=new dX,this._directLights=new dX,this._directData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight)},this._pointData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight)},this._spotData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight),angleCos:new Float32Array(t._maxLight),penumbraCos:new Float32Array(t._maxLight)}}var r=t.prototype;return r._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},r._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},r._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},r._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._updateShaderData=function(e){for(var r=this._spotLights,n=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=t._maxLight,c=Math.min(r.length,l),d=Math.min(n.length,l),u=Math.min(a.length,l),h=0;h<c;h++)r.get(h)._appendData(h,i);for(var _=0;_<d;_++)n.get(_)._appendData(_,o);for(var f=0;f<u;f++)a.get(f)._appendData(f,s);u?(hw._updateShaderData(e,s),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",u.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),d?(hP._updateShaderData(e,o),e.enableMacro("SCENE_POINT_LIGHT_COUNT",d.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(hF._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._updateSunlightIndex=function(e){var t=this._directLights,r=e._lightIndex;if(r>0){var n=t.get(0),a=t.get(r);t.set(0,a),t.set(r,n),a._lightIndex=0,n._lightIndex=r}},r._getMaxBrightestSunlight=function(){for(var t=this._directLights,r=null,n=Number.NEGATIVE_INFINITY,a=!1,i=0,o=t.length;i<o;i++){var s=t.get(i);s.shadowType===e.ShadowType.None||a||(n=Number.NEGATIVE_INFINITY,a=!0);var l=s.intensity*s.color.getBrightness();a?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=s):n<l&&(n=l,r=s)}return r},t}();hL._sunlightColorProperty=dp.getByName("scene_SunlightColor"),hL._sunlightDirectionProperty=dp.getByName("scene_SunlightDirection"),hL._maxLight=10;var hD=function(t){function r(n,a){(i=t.call(this,n)||this).physics=new u9(cQ(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new cB(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i._lightManager=new hL,i._componentsManager=new hE,i._isActiveInEngine=!1,i._globalShaderMacro=new dT,i._rootEntities=[],i._background=new hA(i._engine),i._shaderData=new dH(l2.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new cj(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new cK,i._isActive=!0,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new hM(n),n.sceneManager._allCreatedScenes.push(cQ(i)),o.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),o.setColor(r._fogColorProperty,i._fogColor),o.setVector4(r._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}c0(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new um(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?r=e:(r=void 0,t=e);var r,n=t._isRoot;n||(t._isRoot=!0,t._removeFromParent());var a=t._scene;a!==this?(a&&n&&a._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var i=l0.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=l0.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=l0.Scene),i&&t._processInActive(i),a!==this&&um._traverseSetOwnerScene(t,this);var o=l0.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=l0.Hierarchy)),t._isActiveInScene&&a===this||(o|=l0.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=l0.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=l0.Hierarchy),e._isActiveInScene&&(t|=l0.Scene),t&&e._processInActive(t),um._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var a=this.getRootEntity(r);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=um._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,r=t.length-1;r>=0;r--){var n=t[r];n._isActive&&(e?n._processActive(l0.Hierarchy):n._processInActive(l0.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,r=this._engine,n=this._lightManager;r.time._updateSceneShaderData(t),n._updateShaderData(this.shaderData);var a=this._lightManager._sunlight=this._getSunlight();a?(n._updateSunlightIndex(a),t.setColor(hL._sunlightColorProperty,a._lightColor),t.setVector3(hL._sunlightDirectionProperty,a.direction)):t.setVector3(hL._sunlightDirectionProperty,cB._zero),this.castShadows&&a&&a.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",a.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),dT.unionCollection(this.engine._macroCollection,t._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,r=e._siblingIndex;t.splice(r,1);for(var n=t.length;r<n;r++)t[r]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._engine.sceneManager;for(e.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},n._addToRootEntityList=function(e,t){var r=this._rootEntities,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var r=t-e,n=this._fogParams;n.x=-1/r,n.y=t/r},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},cZ(r,[{key:"isActive",get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e?this._sceneManager&&this._processActive(!0):this._sceneManager&&this._processActive(!1))}},{key:"shaderData",get:function(){return this._shaderData}},{key:"background",get:function(){return this._background}},{key:"shadowCascades",get:function(){return this._shadowCascades},set:function(e){this._shadowCascades!==e&&(this.shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT",e.toString()),this._shadowCascades=e)}},{key:"ambientLight",get:function(){return this._ambientLight},set:function(e){if(!e){df.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}}]),r}(c6);hD._fogColorProperty=dp.getByName("scene_FogColor"),hD._fogParamsProperty=dp.getByName("scene_FogParams");var hB=(c0(ah=function(){var e;return e=dg.apply(this,arguments)||this,e._started=!1,e._onStartIndex=-1,e._onUpdateIndex=-1,e._onLateUpdateIndex=-1,e._onPhysicsUpdateIndex=-1,e._onPreRenderIndex=-1,e._onPostRenderIndex=-1,e._entityScriptsIndex=-1,e},dg),(a_=ah.prototype).onAwake=function(){},a_.onEnable=function(){},a_.onStart=function(){},a_.onUpdate=function(e){},a_.onLateUpdate=function(e){},a_.onBeginRender=function(e){},a_.onEndRender=function(e){},a_.onPhysicsUpdate=function(){},a_.onTriggerEnter=function(e){},a_.onTriggerExit=function(e){},a_.onTriggerStay=function(e){},a_.onCollisionEnter=function(e){},a_.onCollisionExit=function(e){},a_.onCollisionStay=function(e){},a_.onPointerDown=function(e){},a_.onPointerUp=function(e){},a_.onPointerClick=function(e){},a_.onPointerEnter=function(e){},a_.onPointerExit=function(e){},a_.onPointerDrag=function(e){},a_.onDisable=function(){},a_.onDestroy=function(){},a_._onAwake=function(){this.onAwake()},a_._onEnable=function(){this.onEnable()},a_._onDisable=function(){this.onDisable()},a_._onEnableInScene=function(){var e=this.scene._componentsManager,t=ah.prototype;this._started||e.addOnStartScript(this),this.onUpdate!==t.onUpdate&&e.addOnUpdateScript(this),this.onLateUpdate!==t.onLateUpdate&&e.addOnLateUpdateScript(this),this.onPhysicsUpdate!==t.onPhysicsUpdate&&e.addOnPhysicsUpdateScript(this),this._entity._addScript(this)},a_._onDisableInScene=function(){var e=this.scene._componentsManager,t=ah.prototype;this._started||e.removeOnStartScript(this),this.onUpdate!==t.onUpdate&&e.removeOnUpdateScript(this),this.onLateUpdate!==t.onLateUpdate&&e.removeOnLateUpdateScript(this),this.onPhysicsUpdate!==t.onPhysicsUpdate&&e.removeOnPhysicsUpdateScript(this),this._entity._removeScript(this)},a_._onDestroy=function(){dg.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},ah);c1([c3],hB.prototype,"_started",void 0),c1([c3],hB.prototype,"_onStartIndex",void 0),c1([c3],hB.prototype,"_onUpdateIndex",void 0),c1([c3],hB.prototype,"_onLateUpdateIndex",void 0),c1([c3],hB.prototype,"_onPhysicsUpdateIndex",void 0),c1([c3],hB.prototype,"_onPreRenderIndex",void 0),c1([c3],hB.prototype,"_onPostRenderIndex",void 0),c1([c3],hB.prototype,"_entityScriptsIndex",void 0),e.DepthTextureMode=void 0,(af=e.DepthTextureMode||(e.DepthTextureMode={}))[af.None=0]="None",af[af.PrePass=1]="PrePass";var hI=function(e){this._engine=e},hV=((ap=function(){}).recreateTextureIfNeeded=function(e,t,r,n,a,i){if(t){if(t.width===r&&t.height===n&&t.format===a&&t.mipmapCount>1===i)return t;t.destroy(!0);var o=new d9(e,r,n,a,i);return o.isGCIgnored=!0,o}var s=new d9(e,r,n,a,i);return s.isGCIgnored=!0,s},ap.recreateRenderTargetIfNeeded=function(e,t,r,n,a,i,o,s,l){var c,d,u=null==(_=t)?void 0:_.getColorTexture(0),h=a?ap.recreateTextureIfNeeded(e,u,r,n,a,s):null;if(o){var _,f,p,m=null==(f=t)?void 0:f.depthTexture,g=i?ap.recreateTextureIfNeeded(e,m,r,n,i,s):null;(u!==h||m!==g)&&(null==(p=t)||p.destroy(!0),(t=new d5(e,r,n,h,g,l)).isGCIgnored=!0)}else(u!==h||(null==(c=t)?void 0:c._depthFormat)!==i)&&(null==(d=t)||d.destroy(!0),(t=new d5(e,r,n,h,i,l)).isGCIgnored=!0);return t},ap.blitTexture=function(e,t,r,n,a){void 0===n&&(n=0);var i=e._basicResources,o=r?i.flipYBlitMesh:i.blitMesh,s=i.blitMaterial,l=e._hardwareRenderer,c=e._renderContext;c.flipProjection=!!r,l.activeRenderTarget(r,null!=a?a:ap.defaultViewport,c.flipProjection,0);var d=ap._rendererShaderData,u=s.shader.subShaders[0].passes[0],h=u._getShaderProgram(e,dz._compileMacros);d.setTexture(ap._blitTextureProperty,t),d.setFloat(ap._blitMipLevelProperty,n),h.bind(),h.groupingOtherUniformBlock(),h.uploadAll(h.rendererUniformBlock,d),h.uploadAll(h.materialUniformBlock,s.shaderData),h.uploadUnGroupTextures(),(u._renderState||s.renderState)._apply(e,!1,u._renderStateDataMap,s.shaderData),l.drawPrimitive(o._primitive,o.subMesh,h)},ap);hV._blitTextureProperty=dp.getByName("renderer_BlitTexture"),hV._blitMipLevelProperty=dp.getByName("renderer_BlitMipLevel"),hV._rendererShaderData=new dH(l2.Renderer),hV.defaultViewport=new cK(0,0,1,1);var hO=(c0(am=function(){return ux.apply(this,arguments)},ux),(ag=am.prototype).createVertexElements=function(t){return t[0]=new d1("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new d1("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new d1("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},ag.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPasses[0].getTagValue(ux._disableBatchTag))return!1;var r=e.data,n=t.data,a=r.component,i=n.component;return!!this.checkBatchWithMask(a,i)&&r.texture===n.texture&&r.material===n.material},ag.checkBatchWithMask=function(t,r){var n=t.maskInteraction;return n===r.maskInteraction&&(n===e.SpriteMaskInteraction.None||t.maskLayer===r.maskLayer)},ag.updateVertices=function(e,t,r){for(var n=e.verticesData,a=n.positions,i=n.uvs,o=n.color,s=n.vertexCount,l=0;l<s;l++){var c=a[l],d=i[l];t[r++]=c.x,t[r++]=c.y,t[r++]=c.z,t[r++]=d.x,t[r++]=d.y,t[r++]=o.r,t[r++]=o.g,t[r++]=o.b,t[r++]=o.a}return r},ag.drawBatches=function(e){for(var t=this._engine,r=this._batchedQueue,n=this._meshes[this._flushId],a=n.subMeshes,i=n._primitive,o=t._spriteMaskManager,s=e.scene.shaderData,l=e.shaderData,c=0,d=a.length;c<d;c++){var u=a[c],h=r[c],_=h.data;if(!u||!h)return;var f=_.component,p=_.material;o.preRender(e,f);var m=dz._compileMacros;dT.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=h.shaderPasses[0],v=g._getShaderProgram(t,m);if(!v.isValid)return;f.shaderData.setTexture(am._textureProperty,_.texture),v.bind(),v.groupingOtherUniformBlock(),v.uploadAll(v.sceneUniformBlock,s),v.uploadAll(v.cameraUniformBlock,l),v.uploadAll(v.rendererUniformBlock,f.shaderData),v.uploadAll(v.materialUniformBlock,p.shaderData),(g._renderState||p.renderState)._apply(t,!1,g._renderStateDataMap,p.shaderData),t._hardwareRenderer.drawPrimitive(i,u,v),o.postRender(f)}},am);hO._textureProperty=dp.getByName("renderer_SpriteTexture");var hN=((ay=(av=function(e,t){this.elements=[],this._initSpriteBatcher(e),this._renderQueueType=t}).prototype).pushRenderElement=function(e){this.elements.push(e)},ay.render=function(e,t){var r=this.elements;if(0!==r.length){for(var n=e.engine,a=e.instanceId,i=e.shaderData,o=e.scene,s=o.shaderData,l=o.instanceId,c=n._renderCount,d=n._hardwareRenderer,u=uz.pipelineStageKey,h=this._renderQueueType,_=0,f=r.length;_<f;_++){var p=r[_],m=p.data,g=p.shaderPasses;if(m.primitive){this._spriteBatcher.flush(e);var v=dz._compileMacros,y=m.primitive,x=m.component,b=m.material,S=x.shaderData,T=x.instanceId,C=b.shaderData,A=b.instanceId,E=b.renderStates;dT.unionCollection(x._globalShaderMacro,C._macroCollection,v);for(var M=0,R=g.length;M<R;M++){var w,P,F=g[M];if(F.getTagValue(u)===t&&(null!=(w=F._renderState)?w:E[M]).renderQueueType===h){var L=F._getShaderProgram(n,v);if(L.isValid){var D=L.bind();c!==L._uploadRenderCount?(L.groupingOtherUniformBlock(),L.uploadAll(L.sceneUniformBlock,s),L.uploadAll(L.cameraUniformBlock,i),L.uploadAll(L.rendererUniformBlock,S),L.uploadAll(L.materialUniformBlock,C),L.uploadUnGroupTextures(),L._uploadSceneId=l,L._uploadCameraId=a,L._uploadRendererId=T,L._uploadMaterialId=A,L._uploadRenderCount=c):(L._uploadSceneId!==l?(L.uploadAll(L.sceneUniformBlock,s),L._uploadSceneId=l):D&&L.uploadTextures(L.sceneUniformBlock,s),L._uploadCameraId!==a?(L.uploadAll(L.cameraUniformBlock,i),L._uploadCameraId=a):D&&L.uploadTextures(L.cameraUniformBlock,i),L._uploadRendererId!==T?(L.uploadAll(L.rendererUniformBlock,S),L._uploadRendererId=T):D&&L.uploadTextures(L.rendererUniformBlock,S),L._uploadMaterialId!==A?(L.uploadAll(L.materialUniformBlock,C),L._uploadMaterialId=A):D&&L.uploadTextures(L.materialUniformBlock,C),D&&L.uploadUnGroupTextures()),(null!=(P=F._renderState)?P:E[M])._apply(n,x.entity.transform._isFrontFaceInvert(),F._renderStateDataMap,b.shaderData),d.drawPrimitive(y,m.subPrimitive,L)}}}}else this._spriteBatcher.drawElement(p,e)}this._spriteBatcher.flush(e)}},ay.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},ay.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},ay.sort=function(e){dt._quickSort(this.elements,0,this.elements.length,e)},ay._initSpriteBatcher=function(e){this._spriteBatcher=new hO(e)},av._compareFromNearToFar=function(e,t){var r=e.data,n=t.data,a=r.component,i=n.component,o=a.priority-i.priority;if(0!==o)return o;if(a.instanceId===i.instanceId)return r.material._priority-n.material._priority;var s=a._distanceForSort-i._distanceForSort;return 0===s?a.instanceId-i.instanceId:s},av._compareFromFarToNear=function(e,t){var r=e.data,n=t.data,a=r.component,i=n.component,o=a.priority-i.priority;if(0!==o)return o;if(a.instanceId===i.instanceId)return r.material._priority-n.material._priority;var s=i._distanceForSort-a._distanceForSort;return 0===s?a.instanceId-i.instanceId:s},av),hk=function(){this.position=new cB,this.isOrthographic=!1,this.viewMatrix=new cG,this.projectionMatrix=new cG,this.viewProjectionMatrix=new cG,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new cB},hz=function(){this.virtualCamera=new hk,this.cullPlanes=[new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB),new cN(new cB)],this.splitBoundSphere=new cI(new cB,0)};(ax=cd||(cd={}))[ax.FarBottomLeft=0]="FarBottomLeft",ax[ax.FarTopLeft=1]="FarTopLeft",ax[ax.FarTopRight=2]="FarTopRight",ax[ax.FarBottomRight=3]="FarBottomRight",ax[ax.nearBottomLeft=4]="nearBottomLeft",ax[ax.nearTopLeft=5]="nearTopLeft",ax[ax.nearTopRight=6]="nearTopRight",ax[ax.nearBottomRight=7]="nearBottomRight",ax[ax.unknown=8]="unknown";var hU=((ab=function(){}).shadowResolution=function(t){switch(t){case e.ShadowResolution.Low:return 512;case e.ShadowResolution.Medium:return 1024;case e.ShadowResolution.High:return 2048;case e.ShadowResolution.VeryHigh:return 4096}},ab.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},ab.cullingRenderBounds=function(e,t,r){for(var n=e.min,a=e.max,i=0;i<t;i++){var o=r[i],s=o.normal;if(s.x*(s.x>=0?a.x:n.x)+s.y*(s.y>=0?a.y:n.y)+s.z*(s.z>=0?a.z:n.z)<-o.distance)return!1}return!0},ab.shadowCullFrustum=function(e,t,r,n){var a=r._entity.layer;e.camera.cullingMask&a&&t.cullingMask&a&&r.castShadows&&ab.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._renderFrameCount=r.engine.time.frameCount,r._prepareRender(e))},ab.getBoundSphereByFrustum=function(e,t,r,n,a){var i,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(cD.degreeToRadian(l)/2),d=c*c,u=t-e,h=t+e;d>u/h?(i=t,o=t*c):(i=.5*h*(1+d),o=.5*Math.sqrt(u*u+2*(t*t+e*e)*d+h*h*d*d));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,cB.scale(n,i,_),cB.add(r.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},ab.getDirectionLightShadowCullPlanes=function(t,r,n,a,i){var o=ab._frustumCorners,s=ab._backPlaneFaces,l=ab._frustumPlaneNeighbors,c=ab._frustumTwoPlaneCorners,d=ab._edgePlanePoint2,u=i.cullPlanes,h=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),m=t.getPlane(e.FrustumFace.Bottom),g=t.getPlane(e.FrustumFace.Top),v=ab._adjustNearPlane,y=ab._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),cO.intersectionPointThreePlanes(v,m,p,o[7]),cO.intersectionPointThreePlanes(v,g,p,o[6]),cO.intersectionPointThreePlanes(v,g,f,o[5]),cO.intersectionPointThreePlanes(v,m,f,o[4]),cO.intersectionPointThreePlanes(y,m,p,o[3]),cO.intersectionPointThreePlanes(y,g,p,o[2]),cO.intersectionPointThreePlanes(y,g,f,o[1]),cO.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var S=void 0;switch(b){case e.FrustumFace.Near:S=v;break;case e.FrustumFace.Far:S=y;break;default:S=t.getPlane(b)}0>cB.dot(S.normal,a)&&(u[x].copyFrom(S),s[x]=b,x++)}for(var T=x,C=0;C<x;C++)for(var A=s[C],E=l[A],M=0;M<4;M++){for(var R=E[M],w=!0,P=0;P<x;P++)if(R==s[P]){w=!1;break}if(w){var F=c[A][R],L=o[F[0]],D=o[F[1]];cB.add(L,a,d),cN.fromPoints(L,D,d,u[T++])}}i.cullPlaneCount=T},ab.getDirectionalLightMatrices=function(e,t,r,n,a,i,o,s){var l=o.splitBoundSphere;o.resolution=i;var c=l.center,d=l.radius,u=i/2,h=d*u/(u-ab.atlasBorderSize),_=2*h,f=i/_,p=_/i,m=Math.ceil(cB.dot(c,e)*f)*p,g=Math.ceil(cB.dot(c,t)*f)*p,v=cB.dot(c,r);c.x=e.x*m+t.x*g+r.x*v,c.y=e.y*m+t.y*g+r.y*v,c.z=e.z*m+t.z*g+r.z*v;var y=o.virtualCamera,x=y.position,b=y.viewMatrix,S=y.projectionMatrix;cB.scale(r,d+a,x),cB.subtract(c,x,x),cG.lookAt(x,c,e,b),cG.ortho(-h,h,-h,h,0,2*d+a,S);var T=y.viewProjectionMatrix;cG.multiply(S,b,T),dt._floatMatrixMultiply(ab._shadowMapCoordMatrix,T.elements,0,s,16*n)},ab.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),a=Math.floor(e/n)*Math.floor(t/n);a<r;)a=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},ab.getShadowBias=function(t,r,n,a){var i=2/r.elements[0]/n,o=-t.shadowBias*i,s=-t.shadowNormalBias*i;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),a.set(o,s)},ab.applySliceTransform=function(e,t,r,n,a,i){var o=ab._tempMatrix0,s=o.elements,l=1/t,c=1/r,d=a.x*l,u=a.y*c;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=d,s[13]=u,s[14]=0,s[15]=1;var h=16*n;dt._floatMatrixMultiply(o,i,h,i,h)},ab.getScaleAndBiasForLinearDistanceFade=function(e,t,r){if(t<1e-4){r.z=1e3,r.w=-(1e3*e);return}t=1-t;var n=(t*=t)*e,a=e-n;r.z=1/a,r.w=-n/a},ab);hU._tempMatrix0=new cG,hU._shadowMapCoordMatrix=new cG(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),hU._frustumCorners=[new cB,new cB,new cB,new cB,new cB,new cB,new cB,new cB],hU._adjustNearPlane=new cN(new cB),hU._adjustFarPlane=new cN(new cB),hU._backPlaneFaces=[,,,,,],hU._edgePlanePoint2=new cB,hU._frustumPlaneNeighbors=[[e.FrustumFace.Left,e.FrustumFace.Right,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Left,e.FrustumFace.Right,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Left,e.FrustumFace.Right],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Left,e.FrustumFace.Right]],hU._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]],hU.atlasBorderSize=4;var hG=function(t){function r(n){var a;return(a=t.call(this,n.engine)||this)._shadowMapSize=new cK,a._shadowBias=new cW,a._shadowSliceData=new hz,a._lightUp=new cB,a._lightSide=new cB,a._splitBoundSpheres=new Float32Array(4*r._maxCascades),a._shadowMatrices=new Float32Array((r._maxCascades+1)*16),a._shadowInfos=new cK,a._viewportOffsets=[new cW,new cW,new cW,new cW],a._camera=n,a._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}c0(r,t);var n=r.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(t,n){var a,i,o=this._engine,s=this._camera,l=this._viewportOffsets,c=this._shadowSliceData,d=this._splitBoundSpheres,u=this._shadowMatrices,h=s._renderPipeline._cullingResults,_=h.opaqueQueue,f=h.alphaTestQueue,p=h.transparentQueue,m=s.scene,g=m._componentsManager,v=o._hardwareRenderer,y=m.shadowCascades,x=r._cascadesSplitDistance,b=c.splitBoundSphere,S=r._tempMatrix0,T=S.elements,C=this._lightUp,A=this._lightSide,E=c.virtualCamera.forward,M=this._shadowMapSize,R=M.z,w=M.w,P=this._shadowMapFormat;(i=this._supportDepthTexture?(a=hV.recreateRenderTargetIfNeeded(o,this._renderTarget,R,w,null,P,!0,!1,1)).depthTexture:(a=hV.recreateRenderTargetIfNeeded(o,this._renderTarget,R,w,P,null,!1,!1,1)).getColorTexture(0)).wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,o._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=a,this._depthTexture=i,v.activeRenderTarget(a,r._viewport,t.flipProjection,0),this._supportDepthTexture?v.clearRenderTarget(o,e.CameraClearFlags.Depth,null):v.clearRenderTarget(o,e.CameraClearFlags.All,r._clearColor),cG.rotationQuaternion(n.entity.transform.worldRotationQuaternion,S),A.set(T[0],T[1],T[2]),C.set(T[4],T[5],T[6]),E.set(-T[8],-T[9],-T[10]);var F=r._tempVector;F.copyFrom(s.entity.transform.worldForward);for(var L=this._shadowTileResolution,D=0;D<y;D++){hU.getBoundSphereByFrustum(x[D],x[D+1],s,F,c),hU.getDirectionLightShadowCullPlanes(s._frustum,x[D],s.nearClipPlane,E,c),hU.getDirectionalLightMatrices(C,A,E,D,n.shadowNearPlane,L,c,u),y>1&&hU.applySliceTransform(L,R,w,D,this._viewportOffsets[D],u),this._updateSingleShadowCasterShaderData(n,c,t);var B=b.center,I=b.radius,V=4*D;d[V]=B.x,d[V+1]=B.y,d[V+2]=B.z,d[V+3]=I*I,_.clear(),f.clear(),p.clear();for(var O=g._renderers,N=O._elements,k=O.length-1;k>=0;--k)hU.shadowCullFrustum(t,n,N[k],c);if(_.elements.length||f.elements.length){_.sort(hN._compareFromNearToFar),f.sort(hN._compareFromNearToFar);var z=l[D],U=z.x,G=z.y;v.setGlobalDepthBias(1,1),v.viewport(U,G,L,L),v.scissor(U+1,G+1,L-2,L-2),o._renderCount++,_.render(s,e.PipelineStage.ShadowCaster),f.render(s,e.PipelineStage.ShadowCaster),v.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var t=this._camera,n=t.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=n.shadowCascades,s=Math.min(n.shadowDistance,t.farClipPlane);if(hU.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),n.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var d=16*o,u=i.length;d<u;d++)i[d]=0;var h=n.shaderData;h.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),h.setVector4(r._shadowInfosProperty,this._shadowInfos),h.setTexture(r._shadowMapsProperty,this._depthTexture),h.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,a=this._camera.scene,i=a.shadowTwoCascadeSplits,o=a.shadowFourCascadeSplits,s=a.shadowCascades,l=this._camera,c=l.nearClipPlane,d=l.aspectRatio,u=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*cD.degreeToRadian(u)),f=1+_*_*(d*d+1);switch(s){case e.ShadowCascadesMode.NoCascades:n[1]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.TwoCascades:n[1]=this._getFarWithRadius(c+h*i,f),n[2]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.FourCascades:n[1]=this._getFarWithRadius(c+h*o.x,f),n[2]=this._getFarWithRadius(c+h*o.y,f),n[3]=this._getFarWithRadius(c+h*o.z,f),n[4]=this._getFarWithRadius(t,f)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var t=this._camera,r=t.scene,n=hU.shadowDepthFormat(r.shadowResolution,this._supportDepthTexture),a=hU.shadowResolution(r.shadowResolution),i=r.shadowCascades,o=Math.min(r.shadowDistance,t.farClipPlane);if(this._getCascadesSplitDistance(o),n!==this._shadowMapFormat||a!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=a,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=a,this._shadowMapSize.set(1/a,1/a,a,a);else{var s=hU.getMaxTileResolutionInAtlas(a,a,i);this._shadowTileResolution=s;var l=2*s,c=i==e.ShadowCascadesMode.TwoCascades?s:2*s;this._shadowMapSize.set(1/l,1/c,l,c)}this._renderTarget=null;var d=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:d[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:d[0].set(0,0),d[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:d[0].set(0,0),d[1].set(u,0),d[2].set(0,u),d[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var a=t.virtualCamera;hU.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(r._lightShadowBiasProperty,this._shadowBias),i.setVector3(r._lightDirectionProperty,e.direction),n.applyVirtualCamera(a,!0)},r}(hI);hG._lightShadowBiasProperty=dp.getByName("scene_ShadowBias"),hG._lightDirectionProperty=dp.getByName("scene_LightDirection"),hG._shadowMatricesProperty=dp.getByName("scene_ShadowMatrices"),hG._shadowMapSize=dp.getByName("scene_ShadowMapSize"),hG._shadowInfosProperty=dp.getByName("scene_ShadowInfo"),hG._shadowMapsProperty=dp.getByName("scene_ShadowMap"),hG._shadowSplitSpheresProperty=dp.getByName("scene_ShadowSplitSpheres"),hG._maxCascades=4,hG._cascadesSplitDistance=Array(hG._maxCascades+1),hG._viewport=new cK(0,0,1,1),hG._clearColor=new cj(1,1,1,1),hG._tempVector=new cB,hG._tempMatrix0=new cG;var hH=((aT=(aS=function(t){this.opaqueQueue=new hN(t,e.RenderQueueType.Opaque),this.transparentQueue=new hN(t,e.RenderQueueType.Transparent),this.alphaTestQueue=new hN(t,e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},aT.sort=function(){this.opaqueQueue.sort(hN._compareFromNearToFar),this.alphaTestQueue.sort(hN._compareFromNearToFar),this.transparentQueue.sort(hN._compareFromFarToNear)},aT.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},aS),hW=(c0(aC=function(t){var r;return(r=hI.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},hI),(aA=aC.prototype).onConfig=function(t){var r=this._engine,n=t.pixelViewport,a=n.width,i=n.height,o=hV.recreateRenderTargetIfNeeded(r,this._renderTarget,a,i,null,e.TextureFormat.Depth16,!0,!1,1),s=o.depthTexture;s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Clamp,s.filterMode=e.TextureFilterMode.Point,this._renderTarget=o},aA.onRender=function(t,r){var n=this._engine,a=this._renderTarget,i=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(a,i.viewport,t.flipProjection,0),o.viewport(0,0,a.width,a.height),o.scissor(0,0,a.width,a.height),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),r.opaqueQueue.render(i,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(i,e.PipelineStage.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},aC);e.Downsampling=void 0,(aE=e.Downsampling||(e.Downsampling={}))[aE.None=1]="None",aE[aE.TwoX=2]="TwoX",aE[aE.FourX=4]="FourX";var hK=(c0(aM=function(e){return hI.call(this,e)},hI),(aR=aM.prototype).onConfig=function(t,r){this._cameraColorTexture=r;var n=t.opaqueTextureDownsampling,a=n===e.Downsampling.None,i=t.pixelViewport,o=a?1:n===e.Downsampling.TwoX?.5:.25,s=hV.recreateRenderTargetIfNeeded(this._engine,this._renderTarget,i.width*o,i.height*o,e.TextureFormat.R8G8B8A8,null,!1,!1,1),l=s.getColorTexture(0);l.wrapModeU=l.wrapModeV=e.TextureWrapMode.Clamp,l.filterMode=a?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,this._renderTarget=s},aR.onRender=function(t,r){hV.blitTexture(this._engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},aM),hj=((aP=(aw=function(e){this._allSpriteMasks=new dX,this._lastCanvasSize=new cW,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new hH(t),this._cascadedShadowCasterPass=new hG(e),this._depthOnlyPass=new hW(t),this._opaqueTexturePass=new hK(t)}).prototype).destroy=function(){this._cullingResults.destroy(),this._allSpriteMasks=null,this._camera=null},aP.render=function(t,r,n,a){var i=this._camera,o=i.scene,s=i.engine,l=this._cullingResults,c=o._lightManager._sunlight,d=this._depthOnlyPass,u=i.depthTextureMode===e.DepthTextureMode.PrePass&&d._supportDepthTexture;if(i.engine._spriteMaskManager.clear(),o.castShadows&&c&&c.shadowType!==e.ShadowType.None&&this._cascadedShadowCasterPass.onRender(t),l.reset(),this._allSpriteMasks.length=0,t.applyVirtualCamera(i._virtualCamera,u),this._prepareRender(t),l.sort(),u?(d.onConfig(i),d.onRender(t,l)):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var h=i.pixelViewport,_=hV.recreateRenderTargetIfNeeded(s,this._internalColorTarget,h.width,h.height,e.TextureFormat.R8G8B8A8,e.TextureFormat.Depth24Stencil8,!1,!1,i.msaaSamples),f=_.getColorTexture(0);f.wrapModeU=f.wrapModeV=e.TextureWrapMode.Clamp,this._internalColorTarget=_}else{var p,m=this._internalColorTarget;m&&(null==(p=m.getColorTexture(0))||p.destroy(!0),m.destroy(!0),this._internalColorTarget=null)}this._drawRenderPass(t,i,r,n,a)},aP._drawRenderPass=function(t,r,n,a,i){var o,s=this._cullingResults,l=s.opaqueQueue,c=s.alphaTestQueue,d=s.transparentQueue,u=r.engine,h=r.scene.background,_=this._internalColorTarget,f=u._hardwareRenderer,p=null!=(o=r.renderTarget)?o:_,m=_?hV.defaultViewport:r.viewport,g=r.renderTarget&&void 0==n||null!==_;t.flipProjection!==g&&(t.applyVirtualCamera(r._virtualCamera,g),this._updateMVPShaderData(t),u._renderCount++),f.activeRenderTarget(p,m,t.flipProjection,a,n);var v=r.clearFlags&~(null!=i?i:e.CameraClearFlags.None),y=h.solidColor;if(v!==e.CameraClearFlags.None&&f.clearRenderTarget(r.engine,v,y),l.render(r,e.PipelineStage.Forward),c.render(r,e.PipelineStage.Forward),v&e.CameraClearFlags.Color&&(h.mode===e.BackgroundMode.Sky?h.sky._render(t):h.mode===e.BackgroundMode.Texture&&h.texture&&this._drawBackgroundTexture(u,h)),r.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(r,p.getColorTexture(0)),x.onRender(t,s),f.activeRenderTarget(p,m,t.flipProjection,a,n)}else r.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);d.render(r,e.PipelineStage.Forward),null==p||p._blitRenderTarget(),null==p||p.generateMipmaps(),_&&hV.blitTexture(u,_.getColorTexture(0),null,0,r.viewport)},aP.pushRenderData=function(e,t){var r=t.material,n=r.renderStates,a=r.shader.subShaders[0],i=e.replacementShader;if(i){var o=i.subShaders,s=e.replacementTag;if(s)for(var l=0,c=o.length;l<c;l++){var d=o[l];if(d.getTagValue(s)===a.getTagValue(s)){this.pushRenderDataWithShader(e,t,d.passes,n);break}}else this.pushRenderDataWithShader(e,t,o[0].passes,n)}else this.pushRenderDataWithShader(e,t,a.passes,n)},aP.pushRenderDataWithShader=function(t,r,n,a){for(var i=this._cullingResults,o=i.opaqueQueue,s=i.alphaTestQueue,l=i.transparentQueue,c=t.camera.engine._renderElementPool,d=0,u=0,h=n.length;u<h;u++){var _,f=(null!=(_=n[u]._renderState)?_:a[u]).renderQueueType;if(!(d&1<<f)){var p=c.getFromPool();switch(p.set(r,n),f){case e.RenderQueueType.Opaque:o.pushRenderElement(p),d|=1;break;case e.RenderQueueType.AlphaTest:s.pushRenderElement(p),d|=2;break;case e.RenderQueueType.Transparent:l.pushRenderElement(p),d|=4}}}},aP._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,a=t.canvas,i=r._material,o=r._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(a.width,a.height),r._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,dz._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._apply(t,!1,s._renderStateDataMap,i.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},aP._prepareRender=function(e){for(var t=e.camera,r=t.engine,n=t.scene._componentsManager._renderers,a=n._elements,i=n.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=r.time.frameCount,o._prepareRender(e))}},aP._updateMVPShaderData=function(e){for(var t=e.camera.scene._componentsManager._renderers,r=t._elements,n=t.length-1;n>=0;--n)r[n]._updateShaderData(e,!0)},aw);(aF=cu||(cu={}))[aF.None=0]="None",aF[aF.Opaque=1]="Opaque",aF[aF.AlphaTest=2]="AlphaTest",aF[aF.Transparent=4]="Transparent",e.CameraType=void 0,(aL=e.CameraType||(e.CameraType={}))[aL.Normal=0]="Normal",aL[aL.XRCenterCamera=1]="XRCenterCamera",aL[aL.XRLeftCamera=2]="XRLeftCamera",aL[aL.XRRightCamera=4]="XRRightCamera",e.MSAASamples=void 0,(aD=e.MSAASamples||(e.MSAASamples={}))[aD.None=1]="None",aD[aD.TwoX=2]="TwoX",aD[aD.FourX=4]="FourX",aD[aD.EightX=8]="EightX";var hX=function(){};hX.tempVec4=new cK,hX.tempVec3=new cB,hX.tempVec2=new cW,e.Camera=(c0(aB=function(t){(r=dg.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r.opaqueTextureDownsampling=e.Downsampling.TwoX,r.msaaSamples=e.MSAASamples.None,r._cameraType=e.CameraType.Normal,r._globalShaderMacro=new dT,r._frustum=new ck,r._virtualCamera=new hk,r._replacementShader=null,r._replacementSubShaderTag=null,r._cameraIndex=-1,r._priority=0,r._shaderData=new dH(l2.Camera),r._isCustomViewMatrix=!1,r._isCustomProjectionMatrix=!1,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new cK,r._opaqueTextureEnabled=!1,r._viewport=new cK(0,0,1,1),r._pixelViewport=new cX(0,0,0,0),r._inverseProjectionMatrix=new cG,r._invViewProjMat=new cG;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new hj(cQ(r)),r._addResourceReferCount(r.shaderData,1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(cQ(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},dg),(aI=aB.prototype).resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},aI.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},aI.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},aI.worldToViewportPoint=function(e,t){var r=hX.tempVec3,n=hX.tempVec4;cB.transformCoordinate(e,this.viewMatrix,r),cB.transformToVec4(r,this.projectionMatrix,n);var a=n.w;return t.set((n.x/a+1)*.5,(1-n.y/a)*.5,-r.z),t},aI.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,a=this.farClipPlane,i=1/(n-a);if(this.isOrthographic)r=-(2*e.z)*i+(a+n)*i;else{var o=e.z;r=(-o*(n+a)*i+2*n*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},aI.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-cD.zeroTolerance,r,t.direction);return cB.subtract(a,n,a),a.normalize(),t},aI.screenToViewportPoint=function(e,t){var r=this.engine.canvas,n=this.viewport;return t.x=(e.x/r.width-n.x)/n.z,t.y=(e.y/r.height-n.y)/n.w,void 0!==e.z&&(t.z=e.z),t},aI.viewportToScreenPoint=function(e,t){var r=this.engine.canvas,n=this.viewport;return t.x=(n.x+e.x*n.z)*r.width,t.y=(n.y+e.y*n.w)*r.height,void 0!==e.z&&(t.z=e.z),t},aI.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},aI.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},aI.screenPointToRay=function(e,t){var r=hX.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},aI.render=function(t,r){void 0===r&&(r=0);var n,a=this.engine._renderContext,i=this._virtualCamera,o=this.entity.transform;cG.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),dT.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,df.error("mipLevel only take effect in WebGL2.0")),this._cameraType!==e.CameraType.Normal&&(n=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,t,r,n),this._engine._renderCount++},aI.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?dM.getByName(t):t},aI.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},aI._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},aI._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},aI._onDestroy=function(){var e;dg.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},aI._updatePixelViewport=function(){var e,t,r=this._renderTarget;if(r)e=r.width,t=r.height;else{var n=this.engine.canvas;e=n.width,t=n.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},aI._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},aI._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},aI._innerViewportToWorldPoint=function(e,t,r,n,a){var i=hX.tempVec3;return i.set(2*e-1,1-2*t,2*r-1),cB.transformCoordinate(i,n,a),a},aI._updateShaderData=function(){var t=this.shaderData,r=this._transform;t.setMatrix(e.Camera._inverseViewMatrixProperty,r.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,r.worldPosition),t.setVector3(e.Camera._cameraForwardProperty,r.worldForward),t.setVector3(e.Camera._cameraUpProperty,r.worldUp);var n=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;n.set(1-a,a,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},aI._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,cG.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},aI._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,cG.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},aI._forceUseInternalCanvas=function(){return this.opaqueTextureEnabled},aI._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},aI._checkMainCanvasAntialiasWaste=function(){this.independentCanvasEnabled&&cK.equals(this._viewport,hV.defaultViewport)&&console.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},cZ(aB,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return!this._renderTarget&&this._forceUseInternalCanvas()}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._transform;return cG.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,a=this._orthographicSize;cG.ortho(-n,n,-a,a,this.nearClipPlane,this.farClipPlane,t)}else cG.perspective(cD.degreeToRadian(this._fieldOfView),r,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged(),this._checkMainCanvasAntialiasWaste())}}]),aB._cameraDepthTextureProperty=dp.getByName("camera_DepthTexture"),aB._cameraOpaqueTextureProperty=dp.getByName("camera_OpaqueTexture"),aB._inverseViewMatrixProperty=dp.getByName("camera_ViewInvMat"),aB._cameraPositionProperty=dp.getByName("camera_Position"),aB._cameraForwardProperty=dp.getByName("camera_Forward"),aB._cameraUpProperty=dp.getByName("camera_Up"),aB._cameraDepthBufferParamsProperty=dp.getByName("camera_DepthBufferParams"),aB),c1([c5],e.Camera.prototype,"_frustum",void 0),c1([c3],e.Camera.prototype,"_renderPipeline",void 0),c1([c3],e.Camera.prototype,"_virtualCamera",void 0),c1([c3],e.Camera.prototype,"_cameraIndex",void 0),c1([c3],e.Camera.prototype,"_frustumChangeFlag",void 0),c1([c3],e.Camera.prototype,"_transform",void 0),c1([c3],e.Camera.prototype,"_isViewMatrixDirty",void 0),c1([c3],e.Camera.prototype,"_isInvViewProjDirty",void 0),c1([c5],e.Camera.prototype,"_viewport",void 0),c1([c5],e.Camera.prototype,"_pixelViewport",void 0),c1([c5],e.Camera.prototype,"_inverseProjectionMatrix",void 0),c1([c5],e.Camera.prototype,"_invViewProjMat",void 0),c1([c3],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=c1([dy(db,e.DependentMode.CheckOnly)],e.Camera);var hq={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hY=1/0;function hQ(e,t){return void 0===t&&(t={}),new uQ(function(r,n,a,i){var o,s,l,c,d=null!=(o=t.retryCount)?o:1,u=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:hY,t.type=null!=(c=t.type)?c:hq[e.substring(e.lastIndexOf(".")+1)],new hJ(function(){var r;return(r=t,new uQ(function(t,n,a,i){var o,s=new XMLHttpRequest,l="image"===r.type;s.timeout=r.timeout,r.method=null!=(o=r.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){n(Error("request failed from: "+e));return}var r,i=null!=(r=s.response)?r:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){n(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){n(Error("request failed from: "+e))},s.ontimeout=function(){n(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(r.method,e,!0),s.withCredentials="include"===r.credentials,s.responseType=l?"blob":r.type;var c=r.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(r.body)})).onProgress(a,i)},d,u).start().onError(n).onComplete(r)})}var hJ=((aO=(aV=function(e,t,r){this.execFunc=e,this.totalCount=t,this.interval=r,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}).prototype).start=function(){return this.exec(),this},aO.onComplete=function(e){return this._onComplete=e,this},aO.onError=function(e){return this._onError=e,this},aO.cancel=function(){window.clearTimeout(this._timeoutId)},aO.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(t){return e._onComplete&&e._onComplete(t)}).catch(function(t){e._error=t,e._timeoutId=window.setTimeout(e.exec,e.interval)})},aV),hZ=((aN=function(e){this.useCache=e,this.request=hQ}).registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},aN.getClass=function(e){return this._engineObjects[e]},aN.getClassName=function(e){return this._classNameMap.get(e)},aN);hZ._engineObjects={},hZ._classNameMap=new Map;var h$=((az=(ak=function(){}).prototype).initialize=function(e){var t=e.component,r=e.property.split(".");if(e.getProperty){var n=e.getProperty.split(".");this._initializeMounted(t,n,1),this._initializeMounted(t,r,2)}else this._initializeMounted(t,r,3)},az.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},az.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},az._initializeMounted=function(e,t,r){for(var n,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var d=c.indexOf("[");e=(e=e[c.slice(0,d)])[parseInt(c.slice(d+1,-1))]}else if(c.endsWith(")")){var u=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[u].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");n=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),n=1,2&r){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else n=0;2&r&&(this._setMounted=e,this._setType=n,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&r&&(this._getMounted=e,this._getType=n,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},ak);(aU=ch||(ch={}))[aU.Property=0]="Property",aU[aU.Method=1]="Method",aU[aU.Array=2]="Array",(aG=c_||(c_={}))[aG.Get=1]="Get",aG[aG.Set=2]="Set",aG[aG.Both=3]="Both";var h0=function(){function e(t,r,n,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=n,this.cureType=o;var s=e.getAssemblerType(r,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,r){return r?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,r,n,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?n?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):n?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,r)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,r){var n=this.cureType;if(r){var a=this._assembler;if(n._isCopyMode)n._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=n._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)n._isCopyMode?n._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(n._isCopyMode){var s=this.referenceTargetValue;n._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=n._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,r){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,r),this.baseEvaluateData.value)},e.registerAssembler=function(t,r,n){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),a=n?n[r]:void 0;return null!=a?a:h$},e}();h0._components=[],h0._assemblerMap=new Map;var h1=((aW=(aH=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aW.getTargetValue=function(){return this._transform.position},aW.setTargetValue=function(e){this._transform.position=e},aH);h0.registerAssembler(db,"position",h1);var h2=((aj=(aK=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aj.getTargetValue=function(){return this._transform.rotationQuaternion},aj.setTargetValue=function(e){this._transform.rotationQuaternion=e},aK);h0.registerAssembler(db,"rotationQuaternion",h2);var h3=((aq=(aX=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aq.getTargetValue=function(){return this._transform.scale},aq.setTargetValue=function(e){this._transform.scale=e},aX);h0.registerAssembler(db,"scale",h3);var h4=((aQ=(aY=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.component},aQ.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},aQ.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},aY);h0.registerAssembler(uv,"blendShapeWeights",h4);var h8=((aZ=(aJ=function(){this.crossCurveMark=0,this.isActive=!0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},aZ.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},aJ),h5=((a0=(a$=function(){this.typeIndex=0,this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new h0(e,this.type,t,this.property,this.getProperty,r);return r._initializeOwner(n),n.saveDefaultValue(),n},a0._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new h8;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},a0._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},a$),h9=function(){},h6=(c0(a1=function(e){var t;return(t=c6.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new di,t._length=0,t._events=[],t},c6),(a2=a1.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,a=new h9;a.functionName=e,a.time=t,a.parameter=r,n=a}else n=e;var i=this._events,o=i.length,s=n.time;if(s>=(o?i[o-1].time:0))i.push(n);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,n)}this._updateFlagManager.dispatch()},a2.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},a2.addCurveBinding=function(e,t,r,n,a,i){var o=new h5;o.relativePath=e,o.type=t,"number"==typeof r?(o.typeIndex=r,o.property=n,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=r,"string"==typeof n?(o.getProperty=n,o.curve=a):o.curve=n),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},a2.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},a2._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var a=r[n],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,h0._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},cZ(a1,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),a1);e.InterpolationType=void 0,(a3=e.InterpolationType||(e.InterpolationType={}))[a3.Linear=0]="Linear",a3[a3.CubicSpine=1]="CubicSpine",a3[a3.Step=2]="Step",a3[a3.Hermite=3]="Hermite";var h7=((a8=(a4=function(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var t=this.constructor;this._interpolation=t._supportInterpolationMode?e.InterpolationType.Linear:e.InterpolationType.Step,this._type=t}).prototype).addKey=function(e){var t=e.time,r=this.keys;if(t>=this._length)r.push(e),this._length=t;else{for(var n=r.length;--n>=0&&t<r[n].time;);r.splice(n+1,0,e)}},a8.evaluate=function(e){return this._evaluate(e,this._evaluateData)},a8.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var a=t[n];a.time>this._length&&(r=a.time)}this._length=r},a8._evaluate=function(t,r){var n,a=this.keys.length;if(!a){console.warn("This curve don't have any keyframes: ",this);return}var i=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=a||t<i[s].time)&&(s=-1);for(var l=s+1;l<a&&!(t<i[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(i[0].value,r.value);else if(l===a)n=this._type._setValue(i[s].value,r.value);else{var c=i[s],d=i[l],u=c.time,h=d.time-u,_=(t-u)/h;switch(o){case e.InterpolationType.Linear:n=this._type._lerpValue(c.value,d.value,_,r.value);break;case e.InterpolationType.Step:n=this._type._setValue(c.value,r.value);break;case e.InterpolationType.CubicSpine:case e.InterpolationType.Hermite:n=this._type._hermiteInterpolationValue(c,d,_,h,r.value)}}return r.value=n,n},a8._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},cZ(a4,[{key:"interpolation",get:function(){return this._interpolation},set:function(t){this._type._supportInterpolationMode||t===e.InterpolationType.Step?this._interpolation=t:(this._interpolation=e.InterpolationType.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),a4);e.AnimationArrayCurve=(c0(a5=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=[],e},h7),a5._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},a5._initializeLayerOwner=function(e){e.finalValue=[]},a5._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},a5._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},a5._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},a5._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},a5._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},a5._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=u*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},a5._isCopyMode=!0,a5._supportInterpolationMode=!0,a5),e.AnimationArrayCurve=c1([dW()],e.AnimationArrayCurve),e.AnimationBoolCurve=(c0(a9=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=!1,e},h7),a9._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},a9._initializeLayerOwner=function(e){e.finalValue=!1},a9._lerpValue=function(e,t){return e},a9._subtractValue=function(e,t,r){return e},a9._getZeroValue=function(){return!1},a9._additiveValue=function(e,t,r){return e},a9._setValue=function(e){return e},a9._hermiteInterpolationValue=function(e){return e.value},a9._isCopyMode=!1,a9._supportInterpolationMode=!1,a9),e.AnimationBoolCurve=c1([dW()],e.AnimationBoolCurve),e.AnimationColorCurve=(c0(a6=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cj,e},h7),a6._initializeOwner=function(e){e.defaultValue=new cj,e.fixedPoseValue=new cj,e.baseEvaluateData.value=new cj,e.crossEvaluateData.value=new cj},a6._initializeLayerOwner=function(e){e.finalValue=new cj},a6._lerpValue=function(e,t,r,n){return cj.lerp(e,t,r,n),n},a6._subtractValue=function(e,t,r){return cj.subtract(e,t,r),r},a6._getZeroValue=function(e){return e.set(0,0,0,0),e},a6._additiveValue=function(e,t,r){return cj.scale(e,t,e),cj.add(r,e,r),r},a6._setValue=function(e,t){return t.copyFrom(e),t},a6._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.r=u*i.r+h*p*n+_*m*n+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=u*i.g+h*p*n+_*m*n+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=u*i.b+h*p*n+_*m*n+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=u*i.a+h*p*n+_*m*n+f*s.a:a.a=i.a,a},a6._isCopyMode=!0,a6._supportInterpolationMode=!0,a6),e.AnimationColorCurve=c1([dW()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(c0(a7=function(){return h7.apply(this,arguments)},h7),a7.prototype.addKey=function(e){h7.prototype.addKey.call(this,e);var t=this._evaluateData;if(!t.value||t.value.length!==e.value.length){var r=e.value.length;t.value=new Float32Array(r)}},a7._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},a7._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},a7._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},a7._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},a7._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},a7._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},a7._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},a7._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=u*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},a7._isCopyMode=!0,a7._supportInterpolationMode=!0,a7),e.AnimationFloatArrayCurve=c1([dW()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(c0(ie=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=0,e},h7),ie._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},ie._initializeLayerOwner=function(e){e.finalValue=0},ie._lerpValue=function(e,t,r){return e+(t-e)*r},ie._additiveValue=function(e,t,r){return r+e*t},ie._subtractValue=function(e,t){return e-t},ie._getZeroValue=function(){return 0},ie._setValue=function(e){return e},ie._hermiteInterpolationValue=function(e,t,r,n){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*a*n+(s-o)*i*n+(-2*s+3*o)*t.value},ie._isCopyMode=!1,ie._supportInterpolationMode=!0,ie),e.AnimationFloatCurve=c1([dW()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(c0(it=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cU,e},h7),it._initializeOwner=function(e){e.defaultValue=new cU,e.fixedPoseValue=new cU,e.baseEvaluateData.value=new cU,e.crossEvaluateData.value=new cU},it._initializeLayerOwner=function(e){e.finalValue=new cU},it._lerpValue=function(e,t,r,n){return cU.slerp(e,t,r,n),n},it._additiveValue=function(e,t,r){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),r.multiply(e),r},it._subtractValue=function(t,r,n){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return cU.conjugate(r,a),cU.multiply(a,t,n),n},it._getZeroValue=function(e){return e.set(0,0,0,1),e},it._setValue=function(e,t){return t.copyFrom(e),t},it._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=u*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},it._supportInterpolationMode=!0,it._isCopyMode=!0,it._tempConjugateQuat=new cU,it),e.AnimationQuaternionCurve=c1([dW()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(c0(ir=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cW,e},h7),ir._initializeOwner=function(e){e.defaultValue=new cW,e.fixedPoseValue=new cW,e.baseEvaluateData.value=new cW,e.crossEvaluateData.value=new cW},ir._initializeLayerOwner=function(e){e.finalValue=new cW},ir._lerpValue=function(e,t,r,n){return cW.lerp(e,t,r,n),n},ir._additiveValue=function(e,t,r){return cW.scale(e,t,e),cW.add(r,e,r),r},ir._subtractValue=function(e,t,r){return cW.subtract(e,t,r),r},ir._getZeroValue=function(e){return e.set(0,0),e},ir._setValue=function(e,t){return t.copyFrom(e),t},ir._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,a},ir._isCopyMode=!0,ir._supportInterpolationMode=!0,ir),e.AnimationVector2Curve=c1([dW()],e.AnimationVector2Curve),e.AnimationVector3Curve=(c0(ia=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cB,e},h7),ia._initializeOwner=function(e){e.defaultValue=new cB,e.fixedPoseValue=new cB,e.baseEvaluateData.value=new cB,e.crossEvaluateData.value=new cB},ia._initializeLayerOwner=function(e){e.finalValue=new cB},ia._lerpValue=function(e,t,r,n){return cB.lerp(e,t,r,n),n},ia._relativeBaseValue=function(e,t){return cB.subtract(t,e,t),t},ia._additiveValue=function(e,t,r){return cB.scale(e,t,e),cB.add(r,e,r),r},ia._subtractValue=function(e,t,r){return cB.subtract(e,t,r),r},ia._getZeroValue=function(e){return e.set(0,0,0),e},ia._setValue=function(e,t){return t.copyFrom(e),t},ia._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,a},ia._isCopyMode=!0,ia._supportInterpolationMode=!0,ia),e.AnimationVector3Curve=c1([dW()],e.AnimationVector3Curve),e.AnimationVector4Curve=(c0(ii=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cK,e},h7),ii._initializeOwner=function(e){e.defaultValue=new cK,e.fixedPoseValue=new cK,e.baseEvaluateData.value=new cK,e.crossEvaluateData.value=new cK},ii._initializeLayerOwner=function(e){e.finalValue=new cK},ii._lerpValue=function(e,t,r,n){return cK.lerp(e,t,r,n),n},ii._additiveValue=function(e,t,r){return cK.scale(e,t,e),cK.add(r,e,r),r},ii._subtractValue=function(e,t,r){return cK.subtract(e,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0,0),e},ii._setValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=u*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},ii._isCopyMode=!0,ii._supportInterpolationMode=!0,ii),e.AnimationVector4Curve=c1([dW()],e.AnimationVector4Curve),e.AnimationRefCurve=(c0(io=function(){return h7.call(this)},h7),io._initializeOwner=function(e){},io._initializeLayerOwner=function(e){},io._setValue=function(e){return e},io._isCopyMode=!1,io._supportInterpolationMode=!1,io),e.AnimationRefCurve=c1([dW()],e.AnimationRefCurve),e.AnimationRectCurve=(c0(is=function(){var e;return(e=h7.call(this)||this)._evaluateData.value=new cX,e},h7),is._initializeOwner=function(e){e.defaultValue=new cX,e.fixedPoseValue=new cX,e.baseEvaluateData.value=new cX,e.crossEvaluateData.value=new cX},is._initializeLayerOwner=function(e){e.finalValue=new cX},is._setValue=function(e,t){return t.copyFrom(e),t},is._isCopyMode=!0,is._supportInterpolationMode=!1,is),e.AnimationRectCurve=c1([dW()],e.AnimationRectCurve),e.AnimationStringCurve=(c0(il=function(){var e;return(e=h7.call(this)||this)._evaluateData.value="",e},h7),il._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},il._initializeLayerOwner=function(e){e.finalValue=""},il._lerpValue=function(e,t){return e},il._subtractValue=function(e,t,r){return e},il._getZeroValue=function(){return""},il._additiveValue=function(e,t,r){return e},il._setValue=function(e){return e},il._hermiteInterpolationValue=function(e){return e.value},il._isCopyMode=!1,il._supportInterpolationMode=!1,il),e.AnimationStringCurve=c1([dW()],e.AnimationStringCurve),e.AnimatorCullingMode=void 0,(ic=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[ic.None=0]="None",ic[ic.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(id=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[id.Override=0]="Override",id[id.Additive=1]="Additive",(iu=cf||(cf={}))[iu.UnStarted=0]="UnStarted",iu[iu.Playing=1]="Playing",iu[iu.Finished=2]="Finished",(ih=cp||(cp={}))[ih.Standby=0]="Standby",ih[ih.Playing=1]="Playing",ih[ih.CrossFading=2]="CrossFading",ih[ih.FixedCrossFading=3]="FixedCrossFading",ih[ih.Finished=4]="Finished";var _e=((i_=function(){this.handlers=[]}).prototype.dispose=function(){},i_),_t=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(ip=e.WrapMode||(e.WrapMode={}))[ip.Once=0]="Once",ip[ip.Loop=1]="Loop";var _r=((ig=(im=function(){}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=cf.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0},ig.update=function(t){var r=this.state,n=this.frameTime,a=r._getDuration();this.playState=cf.Playing,r.wrapMode===e.WrapMode.Loop?n=a?n%a:0:Math.abs(n)>a&&(n=n<0?-a:a,this.playState=cf.Finished),t&&0===n?this.clipTime=r.clipEndTime*r.clip.length:(n<0&&(n+=a),this.clipTime=n+r.clipStartTime*r.clip.length)},im),_n=((iv=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new _r,this.destPlayData=new _r,this.layerState=cp.Standby,this.crossCurveMark=0,this.manuallyTransition=new _t,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iv),_a=function(){this.curveLayerOwner=[],this.eventHandlers=[]},_i=(c0(iy=function(t){var r;return(r=dg.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,r.speed=1,r._playFrameCount=-1,r._onUpdateIndex=-1,r._updateMark=0,r._animatorLayersData=[],r._curveOwnerPool=Object.create(null),r._animationEventHandlerPool=new uy(_e),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},dg),(ix=iy.prototype).play=function(e,t,r){void 0===t&&(t=-1),void 0===r&&(r=0),(null==(n=this._controllerUpdateFlag)?void 0:n.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var n,a=this._getAnimatorStateInfo(e,t),i=a.state,o=a.layerIndex;if(i){if(!i.clip){df.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,i,s,o);this._preparePlay(s,i),s.layerState=cp.Playing,s.srcPlayData.reset(i,l,i._getDuration()*r),this.update(0)}},ix.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var a,i=this._getAnimatorStateInfo(e,r),o=i.state,s=i.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._crossFadeByTransition(l,s)&&this.update(0)},ix.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,a=this._controlledRenderers,i=0,o=a.length;i<o;i++)if(!a[i].isCulled){n=!0;break}}else n=!0;var s=this._animatorController;if(s){if(null==(r=this._controllerUpdateFlag)?void 0:r.flag){this._checkAutoPlay();return}this._updateMark++;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==cp.Standby&&this._updateLayer(l,0===l,t,n)}},ix.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},ix.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},ix._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},ix._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},ix._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},ix._reset=function(){var e=this._curveOwnerPool;for(var t in e){var r=e[t];for(var n in r)r[n].revertDefaultValue()}this._animatorLayersData.length=0,this._curveOwnerPool={},this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},ix._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,a=null;if(r){var i=r.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=a,n},ix._getAnimatorStateData=function(e,t,r,n){var a=r.animatorStateDataMap,i=a[e];return i||(i=new _a,a[e]=i,this._saveAnimatorStateData(t,i,r,n),this._saveAnimatorEventHandlers(t,i)),i},ix._saveAnimatorStateData=function(e,t,r,n){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[n].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=r.curveOwnerPool,d=l.length-1;d>=0;d--){var u=l[d],h=u.relativePath,_=""===u.relativePath?a:a.findByPath(u.relativePath);if(_){var f,p,m=u.typeIndex>0?_.getComponents(u.type,h0._components)[u.typeIndex]:_.getComponent(u.type);if(!m)continue;var g=u.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=u._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),S=b[g]||(b[g]=u._createCurveLayerOwner(x));o&&o.pathMasks.length&&(S.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[d]=S}else s[d]=null,df.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},ix._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){r._entity.getComponents(hB,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],d=n.getFromPool(),u=c.functionName,h=d.handlers;d.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=a[_][u];f&&h.push(f)}i.push(d)}};o(),e._updateFlagManager.addListener(o)},ix._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},ix._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},ix._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},ix._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},ix._prepareFixedPoseCrossFading=function(e){for(var t=e.crossLayerOwnerCollection,r=t.length-1;r>=0;r--){var n=t[r];n&&(n.curveOwner.saveFixedPoseValue(),n.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},ix._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,n,-1))}},ix._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=n;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,n)}}}},ix._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new _n),t},ix._updateLayer=function(t,r,n,a){var i=this._animatorController.layers[t],o=i.blendingMode,s=i.weight,l=this._animatorLayersData[t],c=l.srcPlayData,d=l.destPlayData,u=o===e.AnimatorLayerBlendingMode.Additive;switch(r&&(s=1),l.layerState){case cp.Playing:this._updatePlayingState(c,l,t,s,n,u,a);break;case cp.FixedCrossFading:this._updateCrossFadeFromPose(d,l,t,s,n,u,a);break;case cp.CrossFading:this._updateCrossFade(c,d,l,t,s,n,u,a);break;case cp.Finished:this._updateFinishedState(c,s,u,a)}},ix._updatePlayingState=function(e,t,r,n,a,i,o){var s=e.stateData,l=s.curveLayerOwner,c=s.eventHandlers,d=e.state,u=e.playState,h=e.clipTime,_=d.transitions,f=d.clip._curveBindings,p=d.speed*this.speed;e.frameTime+=p*a,e.update(p<0);var m=e.clipTime,g=e.playState,v=g===cf.Finished;if(o||v)for(var y=f.length-1;y>=0;y--){var x=l[y],b=null==x?void 0:x.curveOwner;if(b&&x.isActive){var S=f[y].curve;if(S.keys.length){this._checkRevertOwner(b,i);var T=b.evaluateValue(S,m,i);o&&b.applyValue(T,n,i),v&&x.saveFinalValue()}}}if(g===cf.Finished&&(t.layerState=cp.Finished),c.length&&this._fireAnimationEvents(e,c,h,m),u===cf.UnStarted&&this._callAnimatorScriptOnEnter(d,r),g===cf.Finished?this._callAnimatorScriptOnExit(d,r):this._callAnimatorScriptOnUpdate(d,r),_.length){var C=t.layerState;C!==cp.CrossFading&&C!==cp.FixedCrossFading&&this._checkTransition(e,_,r,h,m)}},ix._updateCrossFade=function(e,t,r,n,a,i,o,s){var l=this.speed,c=r.crossLayerOwnerCollection,d=e.state.clip._curveBindings,u=e.state,h=e.stateData,_=e.playState,f=h.eventHandlers,p=t.state,m=t.stateData,g=t.playState,v=m.eventHandlers,y=p.clip._curveBindings,x=e.clipTime,b=t.clipTime,S=p._getDuration()*r.crossFadeTransition.duration,T=Math.abs(t.frameTime)/S;(T>=1||0===S)&&(T=1);var C=u.speed*l,A=p.speed*l;e.frameTime+=C*i,t.frameTime+=A*i,e.update(C<0),t.update(A<0);var E=e.clipTime,M=e.playState,R=t.clipTime,w=t.playState,P=t.playState===cf.Finished;if(s||P)for(var F=c.length-1;F>=0;F--){var L=c[F],D=null==L?void 0:L.curveOwner;if(D){var B=L.crossSrcCurveIndex,I=L.crossDestCurveIndex;this._checkRevertOwner(D,o);var V=D.evaluateCrossFadeValue(B>=0?d[B].curve:null,I>=0?y[I].curve:null,E,R,T,o);s&&D.applyValue(V,a,o),P&&L.saveFinalValue()}}this._updateCrossFadeData(r,T),f.length&&this._fireAnimationEvents(e,f,x,E),v.length&&this._fireAnimationEvents(t,v,b,R),_===cf.UnStarted&&this._callAnimatorScriptOnEnter(u,n),1===T||M===cf.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n),g===cf.UnStarted&&this._callAnimatorScriptOnEnter(p,n),w===cf.Finished?this._callAnimatorScriptOnExit(p,n):this._callAnimatorScriptOnUpdate(p,n)},ix._updateCrossFadeFromPose=function(e,t,r,n,a,i,o){var s=t.crossLayerOwnerCollection,l=e.state,c=e.stateData,d=e.playState,u=c.eventHandlers,h=l.clip._curveBindings,_=e.clipTime,f=l._getDuration()*t.crossFadeTransition.duration,p=Math.abs(e.frameTime)/f;(p>=1||0===f)&&(p=1);var m=l.speed*this.speed;e.frameTime+=m*a,e.update(m<0);var g=e.clipTime,v=e.playState,y=v===cf.Finished;if(o||y)for(var x=s.length-1;x>=0;x--){var b=s[x],S=null==b?void 0:b.curveOwner;if(S){var T=b.crossDestCurveIndex;this._checkRevertOwner(S,i);var C=b.curveOwner.crossFadeFromPoseAndApplyValue(T>=0?h[T].curve:null,g,p,i);o&&S.applyValue(C,n,i),y&&b.saveFinalValue()}}this._updateCrossFadeData(t,p),u.length&&this._fireAnimationEvents(e,u,_,g),d===cf.UnStarted&&this._callAnimatorScriptOnEnter(l,r),v===cf.Finished?this._callAnimatorScriptOnExit(l,r):this._callAnimatorScriptOnUpdate(l,r)},ix._updateFinishedState=function(e,t,r,n){if(n)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},ix._updateCrossFadeData=function(e,t){var r=e.destPlayData;1===t&&(r.playState===cf.Finished?e.layerState=cp.Finished:e.layerState=cp.Playing,e.switchPlayData(),e.crossFadeTransition=null)},ix._preparePlay=function(e,t){if(e.layerState===cp.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,a=r.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(n=a[i])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},ix._checkTransition=function(e,t,r,n,a){var i=e.state,o=i.clip.length;this.speed*i.speed>=0?a<n?(this._checkSubTransition(e,t,r,n,i.clipEndTime*o),e.currentTransitionIndex=0,this._checkSubTransition(e,t,r,i.clipStartTime*o,a)):this._checkSubTransition(e,t,r,n,a):a>n?(this._checkBackwardsSubTransition(e,t,r,n,i.clipStartTime*o),e.currentTransitionIndex=t.length-1,this._checkBackwardsSubTransition(e,t,r,a,i.clipEndTime*o)):this._checkBackwardsSubTransition(e,t,r,n,a)},ix._checkSubTransition=function(e,t,r,n,a){for(var i=e.currentTransitionIndex,o=e.state._getDuration(),s=t.length;i<s;i++){var l=t[i],c=l.exitTime*o;if(c>a)break;c>=n&&(this._crossFadeByTransition(l,r),e.currentTransitionIndex=Math.min(i+1,s-1))}},ix._checkBackwardsSubTransition=function(e,t,r,n,a){for(var i=e.currentTransitionIndex,o=e.state._getDuration();i>=0;i--){var s=t[i],l=s.exitTime*o;if(l<a)break;l<=n&&(this._crossFadeByTransition(s,r),e.currentTransitionIndex=Math.max(i-1,0))}},ix._crossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return df.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),a=n.layerState,i=n.destPlayData,o=this._getAnimatorStateData(r.name,r,n,t),s=r._getDuration()*e.offset;switch(i.reset(r,o,s),a){case cp.Standby:case cp.Finished:n.layerState=cp.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case cp.Playing:n.layerState=cp.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case cp.CrossFading:n.layerState=cp.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case cp.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},ix._fireAnimationEvents=function(e,t,r,n){var a=e.state,i=a.clip.length;this.speed*a.speed>=0?n<r?(this._fireSubAnimationEvents(e,t,r,a.clipEndTime*i),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,a.clipStartTime*i,n)):this._fireSubAnimationEvents(e,t,r,n):n>r?(this._fireBackwardSubAnimationEvents(e,t,r,a.clipStartTime*i),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,a.clipEndTime*i,n)):this._fireBackwardSubAnimationEvents(e,t,r,n)},ix._fireSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var d=o.handlers;if(l>=r){for(var u=d.length-1;u>=0;u--)d[u](c);e.currentEventIndex=Math.min(a+1,i-1)}}},ix._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=i.handlers,d=c.length-1;d>=0;d--)c[d](l);e.currentEventIndex=Math.max(a-1,0)}}},ix._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,a=r.length;n<a;n++)r[n].onStateEnter(this,e,t)},ix._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,a=r.length;n<a;n++)r[n].onStateUpdate(this,e,t)},ix._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,a=r.length;n<a;n++)r[n].onStateExit(this,e,t)},ix._checkAutoPlay=function(){for(var e=this._animatorController.layers,t=0,r=e.length;t<r;++t){var n=e[t].stateMachine;(null==n?void 0:n.defaultState)&&this.play(n.defaultState.name,t)}},ix._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},cZ(iy,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){e!==this._animatorController&&(this._reset(),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._controllerUpdateFlag=e&&e._registerChangeFlag(),this._animatorController=e)}}]),iy);c1([c4],_i.prototype,"speed",void 0),c1([c3],_i.prototype,"_controllerUpdateFlag",void 0),c1([c3],_i.prototype,"_updateMark",void 0),c1([c3],_i.prototype,"_animatorLayersData",void 0),c1([c3],_i.prototype,"_curveOwnerPool",void 0),c1([c3],_i.prototype,"_animationEventHandlerPool",void 0),c1([c3],_i.prototype,"_tempAnimatorStateInfo",void 0),c1([c3],_i.prototype,"_controlledRenderers",void 0);var _o=((iS=(ib=function(){this._updateFlagManager=new di,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iS.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iS.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iS.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iS._registerChangeFlag=function(){return this._updateFlagManager.createFlag(dx)},cZ(ib,[{key:"layers",get:function(){return this._layers}}]),ib),_s=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},_l=((iC=(iT=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},iC.onStateUpdate=function(e,t,r){},iC.onStateExit=function(e,t,r){},iC.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iT),_c=((iE=(iA=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new di,this._clipStartTime=0,this._clipEndTime=1,this._transitions=[],this._onClipChanged=this._onClipChanged.bind(this)}).prototype).addTransition=function(e){var t=this._transitions,r=t.length,n=e.exitTime;if(n>=(r?t[r-1].exitTime:0))t.push(e);else{for(var a=r;--a>=0&&n<t[a].exitTime;);t.splice(a+1,0,e)}},iE.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},iE.addStateMachineScript=function(e){var t=new e;t._state=this;var r=_l.prototype;return t.onStateEnter!==r.onStateEnter&&this._onStateEnterScripts.push(t),t.onStateUpdate!==r.onStateUpdate&&this._onStateUpdateScripts.push(t),t.onStateExit!==r.onStateExit&&this._onStateExitScripts.push(t),t},iE.clearTransitions=function(){this._transitions.length=0},iE._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iE._removeStateMachineScript=function(e){var t=_l.prototype;if(e.onStateEnter!==t.onStateEnter){var r=this._onStateEnterScripts.indexOf(e);-1!==r&&this._onStateEnterScripts.splice(r,1)}if(e.onStateUpdate!==t.onStateUpdate){var n=this._onStateUpdateScripts.indexOf(e);-1!==n&&this._onStateUpdateScripts.splice(n,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},iE._onClipChanged=function(){this._updateFlagManager.dispatch()},cZ(iA,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),iA),_d=((iR=(iM=function(){this.states=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new _c(e),this.states.push(t),this._statesMap[e]=t),t},iR.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},iR.findStateByName=function(e){return this._statesMap[e]},iR.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},iM);e.AnimatorConditionMode=void 0,(iw=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iw.If=0]="If",iw[iw.IfNot=1]="IfNot",iw[iw.Greater=2]="Greater",iw[iw.Less=3]="Less",iw[iw.Equals=4]="Equals",iw[iw.NotEquals=5]="NotEquals";var _u=function(){},_h=function(){},__=((iF=(iP=function(){this._pathMasks=[],this._pathMaskMap={}}).prototype).addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var r=new _h;return r.path=e,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[e]=r,r},iF.removePathMask=function(e){for(var t=this._pathMasks,r=0,n=this._pathMasks.length;r<n;++r)if(t[r].path===e){t.splice(r,1),delete this._pathMaskMap[e];break}},iF.getPathMask=function(e){return this._pathMaskMap[e]},iF.setPathMaskActive=function(e,t,r){void 0===r&&(r=!1);var n=this._pathMaskMap[e];if(n&&(n.active=t),r)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},iP.createByEntity=function(e){var t=new iP;return t.addPathMask(""),iP._addPathMaskWithChildren(t,e,""),t},iP._addPathMaskWithChildren=function(e,t,r){for(var n=t.children,a=0,i=n.length;a<i;++a){var o=n[a],s=r?r+"/"+o.name:o.name;e.addPathMask(s),iP._addPathMaskWithChildren(e,o,s)}},cZ(iP,[{key:"pathMasks",get:function(){return this._pathMasks}}]),iP),_f=function(t){function r(n){var a;return(a=t.call(this,n,dz.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new cj(1,1,1,1),a.renderState.rasterState.cullMode=e.CullMode.Off,a.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,a.shaderData.setFloat(r._rotationProp,0),a.shaderData.setFloat(r._exposureProp,1),a.shaderData.setColor(r._tintColorProp,a._tintColor),a}return c0(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},cZ(r,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(r._decodeSkyRGBMMacro):this.shaderData.disableMacro(r._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(r._textureCubeProp)},set:function(e){this.shaderData.setTexture(r._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(r._rotationProp)},set:function(e){this.shaderData.setFloat(r._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(r._exposureProp)},set:function(e){this.shaderData.setFloat(r._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),r}(uL);_f._tintColorProp=dp.getByName("material_TintColor"),_f._textureCubeProp=dp.getByName("material_CubeTexture"),_f._rotationProp=dp.getByName("material_Rotation"),_f._exposureProp=dp.getByName("material_Exposure"),_f._decodeSkyRGBMMacro=dS.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iL=e.SunMode||(e.SunMode={}))[iL.None=0]="None",iL[iL.Simple=1]="Simple",iL[iL.HighQuality=2]="HighQuality";var _p=(c0(iD=function(t){var r;return(r=uL.call(this,t,dz.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new cj(.5,.5,.5,1),r.groundTint=new cj(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},uL),iD.prototype.clone=function(){var e=new iD(this._engine);return this.cloneTo(e),e},cZ(iD,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iD._sunSimpleMacro),t.enableMacro(iD._sunHighQualityMacro);break;case 1:t.disableMacro(iD._sunHighQualityMacro),t.enableMacro(iD._sunSimpleMacro);break;case 0:t.disableMacro(iD._sunHighQualityMacro),t.disableMacro(iD._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iD._sunSizeProp)},set:function(e){this.shaderData.setFloat(iD._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iD._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iD._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iD._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iD._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iD._skyTintProp)},set:function(e){this.shaderData.setColor(iD._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iD._groundTintProp)},set:function(e){this.shaderData.setColor(iD._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iD._exposureProp)},set:function(e){this.shaderData.setFloat(iD._exposureProp,Math.min(Math.max(0,e),8))}}]),iD);_p._sunSizeProp=dp.getByName("material_SunSize"),_p._sunSizeConvergenceProp=dp.getByName("material_SunSizeConvergence"),_p._atmosphereThicknessProp=dp.getByName("material_AtmosphereThickness"),_p._skyTintProp=dp.getByName("material_SkyTint"),_p._groundTintProp=dp.getByName("material_GroundTint"),_p._exposureProp=dp.getByName("material_Exposure"),_p._sunHighQualityMacro=dS.getByName("MATERIAL_SUN_HIGH_QUALITY"),_p._sunSimpleMacro=dS.getByName("MATERIAL_SUN_SIMPLE");var _m=function(){};e.ParticleRenderMode=void 0,(iB=e.ParticleRenderMode||(e.ParticleRenderMode={}))[iB.Billboard=0]="Billboard",iB[iB.StretchBillboard=1]="StretchBillboard",iB[iB.HorizontalBillboard=2]="HorizontalBillboard",iB[iB.VerticalBillboard=3]="VerticalBillboard",iB[iB.Mesh=4]="Mesh",iB[iB.None=5]="None",e.ParticleStopMode=void 0,(iI=e.ParticleStopMode||(e.ParticleStopMode={}))[iI.StopEmittingAndClear=0]="StopEmittingAndClear",iI[iI.StopEmitting=1]="StopEmitting";var _g=function(t){function r(n){var a;return(a=t.call(this,n)||this).generator=new _D(cQ(a)),a.velocityScale=0,a.lengthScale=2,a.pivot=new cB,a._currentRenderModeMacro=r._billboardModeMacro,a.shaderData.enableMacro(r._billboardModeMacro),a._supportInstancedArrays=a.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),a._dirtyUpdateFlag|=l3.WorldVolume,a}c0(r,t);var n=r.prototype;return n._onEnable=function(){this.generator.main.playOnEnabled&&this.generator.play(!1)},n._onDisable=function(){this.generator.stop(!1,e.ParticleStopMode.StopEmittingAndClear)},n._prepareRender=function(e){if(this._supportInstancedArrays){var r=this.generator;r._update(this.engine.time.deltaTime),r._firstActiveElement!==r._firstFreeElement&&t.prototype._prepareRender.call(this,e)}},n._updateBounds=function(e){e.min.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),e.max.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},n._updateShaderData=function(e,t){var n=this.shaderData;n.setFloat(r._lengthScale,this.lengthScale),n.setFloat(r._speedScale,this.velocityScale),n.setFloat(r._currentTime,this.generator._playTime),n.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(n)},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var n=this._engine._renderDataPool.getFromPool();n.setX(this,r,t._primitive,t._subPrimitive),e.camera._renderPipeline.pushRenderData(e,n)}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1)),this.generator._destroy()},cZ(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var a=null,i=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:a=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:a=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==a&&(this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),a&&i.enableMacro(a),this._currentRenderModeMacro=a),n!==e.ParticleRenderMode.Mesh!=(t===e.ParticleRenderMode.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(t){var r=this._mesh;r!==t&&(this._mesh=t,r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);_g._billboardModeMacro=dS.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),_g._stretchedBillboardModeMacro=dS.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),_g._horizontalBillboardModeMacro=dS.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),_g._verticalBillboardModeMacro=dS.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),_g._renderModeMeshMacro=dS.getByName("RENDERER_MODE_MESH"),_g._pivotOffsetProperty=dp.getByName("renderer_PivotOffset"),_g._lengthScale=dp.getByName("renderer_StretchedBillboardLengthScale"),_g._speedScale=dp.getByName("renderer_StretchedBillboardSpeedScale"),_g._currentTime=dp.getByName("renderer_CurrentTime"),c1([c5],_g.prototype,"generator",void 0),c1([c8],_g.prototype,"pivot",void 0),e.ParticleCurveMode=void 0,(iV=e.ParticleCurveMode||(e.ParticleCurveMode={}))[iV.Constant=0]="Constant",iV[iV.TwoConstants=1]="TwoConstants",iV[iV.Curve=2]="Curve",iV[iV.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(iO=e.ParticleGradientMode||(e.ParticleGradientMode={}))[iO.Constant=0]="Constant",iO[iO.TwoConstants=1]="TwoConstants",iO[iO.Gradient=2]="Gradient",iO[iO.TwoGradients=3]="TwoGradients",e.ParticleSimulationSpace=void 0,(iN=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[iN.Local=0]="Local",iN[iN.World=1]="World",(ik=cm||(cm={}))[ik.Burst=592910910]="Burst",ik[ik.StartDelay=322376503]="StartDelay",ik[ik.StartColor=306581307]="StartColor",ik[ik.StartSize=1793934638]="StartSize",ik[ik.StartRotation=3737431713]="StartRotation",ik[ik.randomizeRotationDirection=2527743459]="randomizeRotationDirection",ik[ik.StartLifetime=2368504881]="StartLifetime",ik[ik.StartSpeed=4085612399]="StartSpeed",ik[ik.VelocityOverLifetime=3774601268]="VelocityOverLifetime",ik[ik.ColorOverLifetime=326370691]="ColorOverLifetime",ik[ik.SizeOverLifetime=1494990940]="SizeOverLifetime",ik[ik.RotationOverLifetime=1089181156]="RotationOverLifetime",ik[ik.TextureSheetAnimation=197469413]="TextureSheetAnimation",ik[ik.Shape=2941263940]="Shape",ik[ik.GravityModifier=2759560269]="GravityModifier";var _v=((iU=(iz=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var r=0,n=e.length;r<n;r++){var a=e[r];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}).prototype).addColorKey=function(e,t){var r=this._colorKeys;if(4===r.length)throw Error("Gradient can only have 4 color keys");var n="number"==typeof e?new _y(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},iU.addAlphaKey=function(e,t){var r=this._alphaKeys;if(4===r.length)throw Error("Gradient can only have 4 alpha keys");var n="number"==typeof e?new _x(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},iU.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},iU.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},iU.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,a=0,i=r.length;a<i;a++)r[a]._onValueChanged=null;for(var o=0,s=n.length;o<s;o++)n[o]._onValueChanged=null;r.length=0,n.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(r,e[l]);for(var d=0,u=t.length;d<u;d++)this._addKey(n,t[d]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},iU._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,a=0,i=Math.min(n.length,4);a<i;a++){var o=4*a,s=n[a];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=cj.gammaToLinearSpace(l.r),r[o+2]=cj.gammaToLinearSpace(l.g),r[o+3]=cj.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},iU._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},iU._addKey=function(e,t){var r=t.time,n=e.length;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},iU._removeKey=function(e,t){e.splice(t,1)},iU._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},iU._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},cZ(iz,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),iz);c1([c5],_v.prototype,"_colorKeys",void 0),c1([c5],_v.prototype,"_alphaKeys",void 0),c1([c3],_v.prototype,"_colorTypeArray",void 0),c1([c3],_v.prototype,"_alphaTypeArray",void 0);var _y=(cZ(iG=function(e,t){this._onValueChanged=null,this._color=new cj,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged},[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}}]),iG),_x=(cZ(iH=function(e,t){this._onValueChanged=null,this._time=e,this._alpha=t},[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._alpha=e,this._onValueChanged&&this._onValueChanged()}}]),iH),_b=((iW=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new cj,this.constantMax=new cj,this.gradientMin=new _v,this.gradientMax=new _v,t.constructor===cj?r?(this.constantMin.copyFrom(t),this.constantMax.copyFrom(r),this.mode=e.ParticleGradientMode.TwoConstants):(this.constant.copyFrom(t),this.mode=e.ParticleGradientMode.Constant):r?(this.gradientMin=t,this.gradientMax=r,this.mode=e.ParticleGradientMode.TwoGradients):(this.gradient=t,this.mode=e.ParticleGradientMode.Gradient)}).prototype.evaluate=function(t,r,n){switch(this.mode){case e.ParticleGradientMode.Constant:n.copyFrom(this.constant);break;case e.ParticleGradientMode.TwoConstants:cj.lerp(this.constantMin,this.constantMax,r,n)}},cZ(iW,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"gradient",get:function(){return this.gradientMax},set:function(e){this.gradientMax=e}}]),iW);c1([c5],_b.prototype,"constantMin",void 0),c1([c5],_b.prototype,"constantMax",void 0),c1([c5],_b.prototype,"gradientMin",void 0),c1([c5],_b.prototype,"gradientMax",void 0);var _S=((iK=function(e){this.enabled=!1,this._generator=e}).prototype._enableMacro=function(e,t,r){return t!==r&&(t&&e.disableMacro(t),r&&e.enableMacro(r)),r},iK);c1([c3],_S.prototype,"_generator",void 0);var _T=(c0(ij=function(){var e;return e=_S.apply(this,arguments)||this,e.color=new _b(new _v([new _y(0,new cj(1,1,1)),new _y(1,new cj(1,1,1))],[new _x(0,1),new _x(1,1)])),e._colorGradientRand=new cY(0,cm.ColorOverLifetime),e._gradientKeysCount=new cK(0,0,0,0),e},_S),(iX=ij.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.color.mode;if(n!==e.ParticleGradientMode.Gradient&&n!==e.ParticleGradientMode.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(ij._maxGradientColor,a.gradientMax._getColorTypeArray(i)),t.setFloatArray(ij._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=ij._gradientMacro:(t.setFloatArray(ij._minGradientColor,a.gradientMin._getColorTypeArray(i)),t.setFloatArray(ij._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),r=ij._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),t.setVector4(ij._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},iX._resetRandomSeed=function(e){this._colorGradientRand.reset(e,cm.ColorOverLifetime)},ij);_T._gradientMacro=dS.getByName("RENDERER_COL_GRADIENT"),_T._randomGradientsMacro=dS.getByName("RENDERER_COL_RANDOM_GRADIENTS"),_T._minGradientColor=dp.getByName("renderer_COLMinGradientColor"),_T._minGradientAlpha=dp.getByName("renderer_COLMinGradientAlpha"),_T._maxGradientColor=dp.getByName("renderer_COLMaxGradientColor"),_T._maxGradientAlpha=dp.getByName("renderer_COLMaxGradientAlpha"),_T._gradientKeysCount=dp.getByName("renderer_COLGradientKeysMaxTime"),c1([c5],_T.prototype,"color",void 0),c1([c3],_T.prototype,"_colorGradientRand",void 0),c1([c3],_T.prototype,"_gradientKeysCount",void 0),c1([c3],_T.prototype,"_colorMacro",void 0);var _C=((iq=function(t,r){this.mode=e.ParticleCurveMode.Constant,this.constantMin=0,this.constantMax=0,"number"==typeof t?r?(this.constantMin=t,this.constantMax=r,this.mode=e.ParticleCurveMode.TwoConstants):(this.constant=t,this.mode=e.ParticleCurveMode.Constant):r?(this.curveMin=t,this.curveMax=r,this.mode=e.ParticleCurveMode.TwoCurves):(this.curve=t,this.mode=e.ParticleCurveMode.Curve)}).prototype.evaluate=function(t,r){switch(this.mode){case e.ParticleCurveMode.Constant:return this.constant;case e.ParticleCurveMode.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*r}},cZ(iq,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"curve",get:function(){return this.curveMax},set:function(e){this.curveMax=e}}]),iq);c1([c5],_C.prototype,"curveMin",void 0),c1([c5],_C.prototype,"curveMax",void 0);var _A=(c0(iY=function(){var e;return e=_S.apply(this,arguments)||this,e.rateOverTime=new _C(10),e.rateOverDistance=new _C(0),e._shapeRand=new cY(0,cm.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new cY(0,cm.Burst),e},_S),(iQ=iY.prototype).addBurst=function(e){for(var t=this._bursts,r=t.length;--r>=0&&e.time<t[r].time;);t.splice(r+1,0,e)},iQ.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},iQ.removeBurstByIndex=function(e){this._bursts.splice(e,1)},iQ.clearBurst=function(){this._bursts.length=0},iQ._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},iQ._resetRandomSeed=function(e){this._burstRand.reset(e,cm.Burst),this._shapeRand.reset(e,cm.Shape)},iQ._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},iQ._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,a=e-this._frameRateTime;a>=n;)a-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},iQ._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,a=Math.floor((t-e)/n);if(r.isLoop&&(a>0||t%n<e%n)){var i=Math.ceil(e/n)*n;this._emitBySubBurst(e,i,n),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=n,this._emitBySubBurst(s,i,n),this._currentBurstIndex=0}this._emitBySubBurst(i,t,n)}else this._emitBySubBurst(e,t,n)},iQ._emitBySubBurst=function(e,t,r){for(var n=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,d=i.length;c<d;c++){var u=i[c],h=u.time;if(h>l)break;if(h>=s){var _=u.count.evaluate(void 0,a.random());n._emit(o+h,_)}}this._currentBurstIndex=c},cZ(iY,[{key:"bursts",get:function(){return this._bursts}}]),iY);c1([c5],_A.prototype,"rateOverTime",void 0),c1([c5],_A.prototype,"rateOverDistance",void 0),c1([c5],_A.prototype,"shape",void 0),c1([c3],_A.prototype,"_shapeRand",void 0),c1([c5],_A.prototype,"_bursts",void 0),c1([c3],_A.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(iJ=e.ParticleScaleMode||(e.ParticleScaleMode={}))[iJ.Hierarchy=0]="Hierarchy",iJ[iJ.Local=1]="Local",iJ[iJ.World=2]="World";var _E=((i$=(iZ=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new _C(0),this.startLifetime=new _C(5),this.startSpeed=new _C(5),this.startSize3D=!1,this.startSizeX=new _C(1),this.startSizeY=new _C(1),this.startSizeZ=new _C(1),this.startRotation3D=!1,this.startRotationX=new _C(0),this.startRotationY=new _C(0),this.startRotationZ=new _C(0),this.flipRotation=0,this.startColor=new _b(new cj(1,1,1,1)),this.gravityModifier=new _C(0),this.simulationSpace=e.ParticleSimulationSpace.Local,this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new cY(0,cm.StartSpeed),this._startLifeTimeRand=new cY(0,cm.StartLifetime),this._startColorRand=new cY(0,cm.StartColor),this._startSizeRand=new cY(0,cm.StartSize),this._startRotationRand=new cY(0,cm.StartRotation),this._gravityModifierRand=new cY(0,cm.GravityModifier),this._gravity=new cB,this._generator=t}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,cm.StartSpeed),this._startLifeTimeRand.reset(e,cm.StartLifetime),this._startColorRand.reset(e,cm.StartColor),this._startSizeRand.reset(e,cm.StartSize),this._startRotationRand.reset(e,cm.StartRotation)},i$._getPositionScale=function(){var t=this._generator._renderer.entity.transform;switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:case e.ParticleScaleMode.World:return t.lossyWorldScale;case e.ParticleScaleMode.Local:return t.scale}},i$._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(iZ._worldPosition,n.worldPosition);var a=n.worldRotationQuaternion,i=iZ._tempVector40;i.copyFrom(a),t.setVector4(iZ._worldRotation,i);break;case e.ParticleSimulationSpace.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:var o=n.lossyWorldScale;t.setVector3(iZ._positionScale,o),t.setVector3(iZ._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(iZ._positionScale,o),t.setVector3(iZ._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(iZ._positionScale,n.lossyWorldScale),t.setVector3(iZ._sizeScale,iZ._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());cB.scale(r.scene.physics.gravity,l,s),t.setVector3(iZ._gravity,s),t.setInt(iZ._simulationSpace,this.simulationSpace),t.setFloat(iZ._startRotation3D,+this.startRotation3D),t.setInt(iZ._scaleMode,this.scalingMode)},i$._cloneTo=function(e){e.maxParticles=this.maxParticles},cZ(iZ,[{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(e){this._maxParticleBuffer=e+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(e){this.startSizeX=e}}]),iZ);_E._tempVector40=new cK,_E._vector3One=new cB(1,1,1),_E._positionScale=dp.getByName("renderer_PositionScale"),_E._sizeScale=dp.getByName("renderer_SizeScale"),_E._worldPosition=dp.getByName("renderer_WorldPosition"),_E._worldRotation=dp.getByName("renderer_WorldRotation"),_E._gravity=dp.getByName("renderer_Gravity"),_E._simulationSpace=dp.getByName("renderer_SimulationSpace"),_E._startRotation3D=dp.getByName("renderer_ThreeDStartRotation"),_E._scaleMode=dp.getByName("renderer_ScalingMode"),c1([c5],_E.prototype,"startDelay",void 0),c1([c5],_E.prototype,"startLifetime",void 0),c1([c5],_E.prototype,"startSpeed",void 0),c1([c5],_E.prototype,"startSizeX",void 0),c1([c5],_E.prototype,"startSizeY",void 0),c1([c5],_E.prototype,"startSizeZ",void 0),c1([c5],_E.prototype,"startRotationX",void 0),c1([c5],_E.prototype,"startRotationY",void 0),c1([c5],_E.prototype,"startRotationZ",void 0),c1([c5],_E.prototype,"startColor",void 0),c1([c5],_E.prototype,"gravityModifier",void 0),c1([c3],_E.prototype,"_maxParticleBuffer",void 0),c1([c3],_E.prototype,"_startSpeedRand",void 0),c1([c3],_E.prototype,"_startLifeTimeRand",void 0),c1([c3],_E.prototype,"_startColorRand",void 0),c1([c3],_E.prototype,"_startSizeRand",void 0),c1([c3],_E.prototype,"_startRotationRand",void 0),c1([c3],_E.prototype,"_gravityModifierRand",void 0),c1([c3],_E.prototype,"_generator",void 0),c1([c3],_E.prototype,"_gravity",void 0);var _M=(c0(i0=function(){var e;return e=_S.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new _C(0),e.rotationY=new _C(0),e.rotationZ=new _C(45),e._rotationRand=new cY(0,cm.RotationOverLifetime),e._rotationMinConstant=new cB,e._rotationMaxConstant=new cB,e},_S),(i1=i0.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(i0._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(i0._maxCurveXProperty,i.curveMax._getTypeArray()),t.setFloatArray(i0._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(i0._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(i0._minCurveXProperty,i.curveMin._getTypeArray()),t.setFloatArray(i0._minCurveYProperty,o.curveMin._getTypeArray())),a=i0._isRandomTwoMacro),n=i0._curveModeMacro;else{var d=this._rotationMaxConstant;if(d.set(cD.degreeToRadian(i.constantMax),cD.degreeToRadian(o.constantMax),cD.degreeToRadian(s.constantMax)),t.setVector3(i0._maxConstantProperty,d),l?i.mode===e.ParticleCurveMode.TwoConstants&&o.mode===e.ParticleCurveMode.TwoConstants&&s.mode===e.ParticleCurveMode.TwoConstants:s.mode===e.ParticleCurveMode.TwoConstants){var u=this._rotationMinConstant;u.set(cD.degreeToRadian(i.constantMin),cD.degreeToRadian(o.constantMin),cD.degreeToRadian(s.constantMin)),t.setVector3(i0._minConstantProperty,u),a=i0._isRandomTwoMacro}n=i0._constantModeMacro}l&&(r=i0._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},i1._resetRandomSeed=function(e){this._rotationRand.reset(e,cm.RotationOverLifetime)},i0);_M._constantModeMacro=dS.getByName("RENDERER_ROL_CONSTANT_MODE"),_M._curveModeMacro=dS.getByName("RENDERER_ROL_CURVE_MODE"),_M._isSeparateMacro=dS.getByName("RENDERER_ROL_IS_SEPARATE"),_M._isRandomTwoMacro=dS.getByName("RENDERER_ROL_IS_RANDOM_TWO"),_M._minConstantProperty=dp.getByName("renderer_ROLMinConst"),_M._minCurveXProperty=dp.getByName("renderer_ROLMinCurveX"),_M._minCurveYProperty=dp.getByName("renderer_ROLMinCurveY"),_M._minCurveZProperty=dp.getByName("renderer_ROLMinCurveZ"),_M._maxConstantProperty=dp.getByName("renderer_ROLMaxConst"),_M._maxCurveXProperty=dp.getByName("renderer_ROLMaxCurveX"),_M._maxCurveYProperty=dp.getByName("renderer_ROLMaxCurveY"),_M._maxCurveZProperty=dp.getByName("renderer_ROLMaxCurveZ"),c1([c5],_M.prototype,"rotationX",void 0),c1([c5],_M.prototype,"rotationY",void 0),c1([c5],_M.prototype,"rotationZ",void 0),c1([c3],_M.prototype,"_rotationRand",void 0),c1([c3],_M.prototype,"_rotationMinConstant",void 0),c1([c3],_M.prototype,"_rotationMaxConstant",void 0),c1([c3],_M.prototype,"_enableSeparateMacro",void 0),c1([c3],_M.prototype,"_isCurveMacro",void 0),c1([c3],_M.prototype,"_isRandomTwoMacro",void 0);var _R=((i3=(i2=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this._keys=[],this._typeArrayDirty=!1;for(var n=0,a=t.length;n<a;n++){var i=t[n];this.addKey(i)}}).prototype).addKey=function(e,t){var r=this._keys;if(4===r.length)throw Error("Curve can only have 4 keys");var n="number"==typeof e?new _w(e,t):e;this._addKey(r,n),this._typeArrayDirty=!0},i3.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0},i3.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},i3._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},i3._addKey=function(e,t){var r=e.length,n=t.time;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},cZ(i2,[{key:"keys",get:function(){return this._keys}}]),i2);c1([c5],_R.prototype,"_keys",void 0),c1([c3],_R.prototype,"_typeArray",void 0);var _w=function(e,t){this.time=e,this.value=t},_P=(c0(i4=function(){var e;return e=_S.apply(this,arguments)||this,e.separateAxes=!1,e.sizeX=new _C(new _R(new _w(0,0),new _w(1,1))),e.sizeY=new _C(new _R(new _w(0,0),new _w(1,1))),e.sizeZ=new _C(new _R(new _w(0,0),new _w(1,1))),e},_S),i4.prototype._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:i.mode===e.ParticleCurveMode.TwoCurves;(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:i.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(i4._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(t.setFloatArray(i4._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(i4._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(i4._minCurveXProperty,i.curveMin._getTypeArray()),l&&(t.setFloatArray(i4._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(i4._minCurveZProperty,s.curveMin._getTypeArray())),a=i4._isRandomTwoMacro),n=i4._curveModeMacro),l&&(r=i4._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},cZ(i4,[{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),i4);_P._curveModeMacro=dS.getByName("RENDERER_SOL_CURVE_MODE"),_P._isSeparateMacro=dS.getByName("RENDERER_SOL_IS_SEPARATE"),_P._isRandomTwoMacro=dS.getByName("RENDERER_SOL_IS_RANDOM_TWO"),_P._minCurveXProperty=dp.getByName("renderer_SOLMinCurveX"),_P._minCurveYProperty=dp.getByName("renderer_SOLMinCurveY"),_P._minCurveZProperty=dp.getByName("renderer_SOLMinCurveZ"),_P._maxCurveXProperty=dp.getByName("renderer_SOLMaxCurveX"),_P._maxCurveYProperty=dp.getByName("renderer_SOLMaxCurveY"),_P._maxCurveZProperty=dp.getByName("renderer_SOLMaxCurveZ"),c1([c5],_P.prototype,"sizeX",void 0),c1([c5],_P.prototype,"sizeY",void 0),c1([c5],_P.prototype,"sizeZ",void 0),c1([c3],_P.prototype,"_enableSeparateMacro",void 0),c1([c3],_P.prototype,"_isCurveMacro",void 0),c1([c3],_P.prototype,"_isRandomTwoMacro",void 0);var _F=(c0(i8=function(){var e;return e=_S.apply(this,arguments)||this,e.startFrame=new _C(0),e.frameOverTime=new _C(new _R(new _w(0,0),new _w(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new cB(1,1,1),e._frameOverTimeRand=new cY(0,cm.TextureSheetAnimation),e._tiling=new cW(1,1),e},_S),(i5=i8.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.frameOverTime.mode;if(n===e.ParticleCurveMode.Curve||n===e.ParticleCurveMode.TwoCurves){var a=this.frameOverTime;t.setFloatArray(i8._frameMaxCurveProperty,a.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=i8._frameCurveMacro:(t.setFloatArray(i8._frameMinCurveProperty,a.curveMin._getTypeArray()),r=i8._frameRandomCurvesMacro),t.setFloat(i8._cycleCountProperty,this.cycleCount),t.setVector3(i8._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},i5._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,cm.TextureSheetAnimation)},cZ(i8,[{key:"tiling",get:function(){return this._tiling},set:function(e){this._tiling=e,this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)}}]),i8);_F._frameCurveMacro=dS.getByName("RENDERER_TSA_FRAME_CURVE"),_F._frameRandomCurvesMacro=dS.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),_F._cycleCountProperty=dp.getByName("renderer_TSACycles"),_F._tillingParamsProperty=dp.getByName("renderer_TSATillingParams"),_F._frameMinCurveProperty=dp.getByName("renderer_TSAFrameMinCurve"),_F._frameMaxCurveProperty=dp.getByName("renderer_TSAFrameMaxCurve"),c1([c5],_F.prototype,"startFrame",void 0),c1([c5],_F.prototype,"frameOverTime",void 0),c1([c8],_F.prototype,"_tillingInfo",void 0),c1([c3],_F.prototype,"_frameOverTimeRand",void 0),c1([c5],_F.prototype,"_tiling",void 0),c1([c3],_F.prototype,"_textureSheetMacro",void 0),(i9=cg||(cg={}))[i9.WholeSheet=0]="WholeSheet",i9[i9.SingleRow=1]="SingleRow";var _L=(c0(i6=function(){var t;return t=_S.apply(this,arguments)||this,t.velocityX=new _C(0),t.velocityY=new _C(0),t.velocityZ=new _C(0),t.space=e.ParticleSimulationSpace.Local,t._velocityRand=new cY(0,cm.VelocityOverLifetime),t._velocityMinConstant=new cB,t._velocityMaxConstant=new cB,t},_S),(i7=i6.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,a=this.velocityY,i=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve)t.setFloatArray(i6._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(i6._maxGradientYProperty,a.curveMax._getTypeArray()),t.setFloatArray(i6._maxGradientZProperty,i.curveMax._getTypeArray()),o?(t.setFloatArray(i6._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(i6._minGradientYProperty,a.curveMin._getTypeArray()),t.setFloatArray(i6._minGradientZProperty,i.curveMin._getTypeArray()),r=i6._randomCurveMacro):r=i6._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,a.constantMax,i.constantMax),t.setVector3(i6._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,a.constantMin,i.constantMin),t.setVector3(i6._minConstantProperty,l),r=i6._randomConstantMacro}else r=i6._constantMacro}t.setInt(i6._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},i7._resetRandomSeed=function(e){this._velocityRand.reset(e,cm.VelocityOverLifetime)},i6);_L._constantMacro=dS.getByName("RENDERER_VOL_CONSTANT"),_L._curveMacro=dS.getByName("RENDERER_VOL_CURVE"),_L._randomConstantMacro=dS.getByName("RENDERER_VOL_RANDOM_CONSTANT"),_L._randomCurveMacro=dS.getByName("RENDERER_VOL_RANDOM_CURVE"),_L._minConstantProperty=dp.getByName("renderer_VOLMinConst"),_L._maxConstantProperty=dp.getByName("renderer_VOLMaxConst"),_L._minGradientXProperty=dp.getByName("renderer_VOLMinGradientX"),_L._minGradientYProperty=dp.getByName("renderer_VOLMinGradientY"),_L._minGradientZProperty=dp.getByName("renderer_VOLMinGradientZ"),_L._maxGradientXProperty=dp.getByName("renderer_VOLMaxGradientX"),_L._maxGradientYProperty=dp.getByName("renderer_VOLMaxGradientY"),_L._maxGradientZProperty=dp.getByName("renderer_VOLMaxGradientZ"),_L._spaceProperty=dp.getByName("renderer_VOLSpace"),c1([c5],_L.prototype,"velocityX",void 0),c1([c5],_L.prototype,"velocityY",void 0),c1([c5],_L.prototype,"velocityZ",void 0),c1([c3],_L.prototype,"_velocityRand",void 0),c1([c3],_L.prototype,"_velocityMinConstant",void 0),c1([c3],_L.prototype,"_velocityMaxConstant",void 0),c1([c3],_L.prototype,"_velocityMacro",void 0);var _D=function(){function t(r){this.useAutoRandomSeed=!0,this.main=new _E(this),this.emission=new _A(this),this.velocityOverLifetime=new _L(this),this.sizeOverLifetime=new _P(this),this.rotationOverLifetime=new _M(this),this.colorOverLifetime=new _T(this),this.textureSheetAnimation=new _F(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new dJ(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._renderer=r,new _m().start=0,this._primitive=new dZ(r.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,t._particleIncreaseCount),this.emission.enabled=!0}var r=t.prototype;return r.play=function(e){if(void 0===e&&(e=!0),e)for(var r=this._renderer.entity.getComponentsIncludeChildren(_g,t._tempParticleRenderers),n=0,a=r.length;n<a;n++)r[n].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(4294967295*Math.random()))},r.stop=function(r,n){if(void 0===r&&(r=!0),void 0===n&&(n=e.ParticleStopMode.StopEmitting),r)for(var a=this._renderer.entity.getComponentsIncludeChildren(_g,t._tempParticleRenderers),i=0,o=a.length;i<o;i++)a[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===e.ParticleStopMode.StopEmittingAndClear){var s=this._firstFreeElement;this._firstRetiredElement=s,this._firstActiveElement=s,this._firstNewElement=s,this._playTime=0,this.emission._reset()}},r.emit=function(e){this._emit(this._playTime,e)},r._emit=function(e,r){if(this.emission.enabled&&!(this.main._maxParticleBuffer<this._currentParticleCount))for(var n=t._tempVector30,a=t._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,e,n,a);var l=this.main._getPositionScale();n.multiply(l),a.normalize().multiply(l)}else n.set(0,0,0),a.set(0,0,-1);this._addNewParticle(n,a,i,e)}},r._update=function(e){var t=this.main,r=this.emission,n=t.duration,a=this._playTime;if(this._playTime+=e*t.simulationSpeed,this._retireActiveParticles(),this._freeRetiredParticles(),r.enabled&&this._isPlaying&&(this._currentParticleCount>t._maxParticleBuffer&&this._getNotRetiredParticleCount()<t._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(a,this._playTime),!t.isLoop&&this._playTime>n&&(this._isPlaying=!1)),!this.isAlive){var i=Math.min(r._frameRateTime,Math.floor(this._playTime/n)*n);this._playTime-=i,r._frameRateTime-=i}(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},r._reorganizeGeometryBuffers=function(){var t=this._renderer,r=t.engine._particleBufferUtils,n=this._primitive,a=this._vertexBufferBindings;if(n.clearVertexElements(),a.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var i=t.mesh;if(!i)return;var o=i.getVertexElement(e.VertexAttribute.Position),s=i.getVertexElement(e.VertexAttribute.Color),l=i.getVertexElement(e.VertexAttribute.UV),c=o?i.vertexBufferBindings[o.bindingIndex]:null,d=s?i.vertexBufferBindings[s.bindingIndex]:null,u=l?i.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,a);n.addVertexElement(new d1(e.VertexAttribute.Position,o.offset,o.format,h))}if(d){var _=this._addVertexBufferBindingsFilterDuplicate(d,a);n.addVertexElement(new d1(e.VertexAttribute.Color,s.offset,s.format,_))}if(u){var f=this._addVertexBufferBindingsFilterDuplicate(u,a);n.addVertexElement(new d1(e.VertexAttribute.UV,l.offset,l.format,f))}var p=i._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),a.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=r.billboardIndexCount;n.setVertexBufferBindings(a);for(var m=r.instanceVertexElements,g=a.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new d1(x.attribute,x.offset,x.format,g,x.instanceStepRate))}},r._resizeInstanceBuffer=function(t,r){null==(_=this._instanceVertexBufferBinding)||_.buffer.destroy();var n=this._renderer.engine._particleBufferUtils,a=n.instanceVertexStride,i=t?this._currentParticleCount+r:this.main._maxParticleBuffer,o=a*i,s=this._renderer.engine,l=new dq(s,e.BufferBindFlag.VertexBuffer,o,e.BufferUsage.Dynamic,!1);l.isGCIgnored=!0;var c=this._primitive.vertexBufferBindings,d=new d0(l,a),u=new Float32Array(o/4),h=this._instanceVertices;if(h){var _,f,p,m=n.instanceVertexFloatStride,g=this._firstFreeElement,v=this._firstRetiredElement;if(t){var y=this._firstFreeElement*m;u.set(new Float32Array(h.buffer,0,y));var x=(this._firstFreeElement+r)*m;u.set(new Float32Array(h.buffer,4*y),x),this._firstNewElement>g&&(this._firstNewElement+=r),this._firstActiveElement>g&&(this._firstActiveElement+=r),v>g&&(this._firstRetiredElement+=r)}else v<=g?(f=g-v,p=0,this._firstFreeElement-=v,this._firstNewElement-=v,this._firstActiveElement-=v,this._firstRetiredElement=0):(f=this._currentParticleCount-v,p=g,this._firstNewElement>g&&(this._firstNewElement-=g),this._firstActiveElement>g&&(this._firstActiveElement-=g),v>g&&(this._firstRetiredElement-=g)),u.set(new Float32Array(h.buffer,v*m*4,f*m),p*m);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(h?c.length-1:c.length,d),this._instanceVertices=u,this._instanceVertexBufferBinding=d,this._currentParticleCount=i},r._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.textureSheetAnimation._updateShaderData(e),this.sizeOverLifetime._updateShaderData(e),this.rotationOverLifetime._updateShaderData(e),this.colorOverLifetime._updateShaderData(e)},r._resetGlobalRandSeed=function(e){this._randomSeed=e,this.main._resetRandomSeed(e),this.emission._resetRandomSeed(e),this.textureSheetAnimation._resetRandomSeed(e),this.velocityOverLifetime._resetRandomSeed(e),this.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},r._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var e=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},r._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var e=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},r._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy()},r._addNewParticle=function(r,n,a,i){var o,s,l=this._firstFreeElement,c=l+1;c>=this._currentParticleCount&&(c=0);var d=this.main;if(c===this._firstRetiredElement){var u=Math.min(t._particleIncreaseCount,d._maxParticleBuffer-this._currentParticleCount);if(0===u)return;this._resizeInstanceBuffer(!0,u),c=l+1}d.simulationSpace===e.ParticleSimulationSpace.World&&(o=a.worldPosition,s=a.worldRotationQuaternion);var h=this._renderer.engine._particleBufferUtils,_=d.startSpeed.evaluate(void 0,d._startSpeedRand.random()),f=this._instanceVertices,p=l*h.instanceVertexFloatStride;f[p]=r.x,f[p+1]=r.y,f[p+2]=r.z,f[p+h.startLifeTimeOffset]=d.startLifetime.evaluate(void 0,d._startLifeTimeRand.random()),f[p+4]=n.x,f[p+5]=n.y,f[p+6]=n.z,f[p+h.timeOffset]=i;var m=t._tempColor0;d.startColor.evaluate(void 0,d._startColorRand.random(),m),this._renderer.engine.settings.colorSpace===e.ColorSpace.Linear&&m.toLinear(m),f[p+8]=m.r,f[p+9]=m.g,f[p+10]=m.b,f[p+11]=m.a;var g=d._startSizeRand;if(d.startSize3D)f[p+12]=d.startSizeX.evaluate(void 0,g.random()),f[p+13]=d.startSizeY.evaluate(void 0,g.random()),f[p+14]=d.startSizeZ.evaluate(void 0,g.random());else{var v=d.startSize.evaluate(void 0,g.random());f[p+12]=v,f[p+13]=v,f[p+14]=v}var y=d._startRotationRand;d.startRotation3D?(f[p+15]=cD.degreeToRadian(d.startRotationX.evaluate(void 0,y.random())),f[p+16]=cD.degreeToRadian(d.startRotationY.evaluate(void 0,y.random())),f[p+17]=cD.degreeToRadian(d.startRotationZ.evaluate(void 0,y.random()))):f[p+15]=cD.degreeToRadian(d.startRotationZ.evaluate(void 0,y.random())),f[p+18]=_;var x=this.colorOverLifetime;x.enabled&&x.color.mode===e.ParticleGradientMode.TwoGradients&&(f[p+20]=x._colorGradientRand.random());var b=this.rotationOverLifetime;b.enabled&&b.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(f[p+22]=b._rotationRand.random());var S=this.textureSheetAnimation;S.enabled&&S.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(f[p+23]=S._frameOverTimeRand.random());var T=this.velocityOverLifetime;if(T.enabled&&T.velocityX.mode===e.ParticleCurveMode.TwoConstants&&T.velocityY.mode===e.ParticleCurveMode.TwoConstants&&T.velocityZ.mode===e.ParticleCurveMode.TwoConstants){var C=T._velocityRand;f[p+24]=C.random(),f[p+25]=C.random(),f[p+26]=C.random()}if(this.main.simulationSpace===e.ParticleSimulationSpace.World&&(f[p+27]=o.x,f[p+28]=o.y,f[p+29]=o.z,f[p+30]=s.x,f[p+31]=s.y,f[p+32]=s.z,f[p+33]=s.w),this.textureSheetAnimation.enabled){var A=this.textureSheetAnimation._tillingInfo;f[p+h.simulationUVOffset]=A.x,f[p+35]=A.y,f[p+36]=0,f[p+37]=0}else f[p+h.simulationUVOffset]=1,f[p+35]=1,f[p+36]=0,f[p+37]=0;this._firstFreeElement=c},r._retireActiveParticles=function(){for(var e=this._renderer.engine,t=e._particleBufferUtils,r=e.time.frameCount,n=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var a=this._firstActiveElement*t.instanceVertexFloatStride,i=a+t.timeOffset;if(Math.fround(this._playTime-n[i])<n[a+t.startLifeTimeOffset])break;n[i]=r,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},r._freeRetiredParticles=function(){for(var e=this._renderer.engine._particleBufferUtils,t=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var r=this._firstRetiredElement*e.instanceVertexFloatStride+e.startLifeTimeOffset;if(t-this._instanceVertices[r]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},r._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,r=this._firstFreeElement;if(t!==r){var n=this._renderer.engine._particleBufferUtils.instanceVertexStride,a=t*n,i=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)i.setData(o,0,a,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;i.setData(o,0,a,s,e.SetDataOptions.Discard),r>0&&i.setData(o,s,0,r*n)}this._firstNewElement=r,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},r._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return t.push(e),r},cZ(t,[{key:"isAlive",get:function(){return!!this._isPlaying||this._firstActiveElement!==this._firstFreeElement}},{key:"randomSeed",get:function(){return this._randomSeed},set:function(e){this._resetGlobalRandSeed(e),this.useAutoRandomSeed=!1}}]),t}();_D._tempVector30=new cB,_D._tempVector31=new cB,_D._tempColor0=new cj,_D._tempParticleRenderers=[],_D._particleIncreaseCount=128,c1([c5],_D.prototype,"main",void 0),c1([c5],_D.prototype,"emission",void 0),c1([c5],_D.prototype,"velocityOverLifetime",void 0),c1([c5],_D.prototype,"sizeOverLifetime",void 0),c1([c5],_D.prototype,"rotationOverLifetime",void 0),c1([c5],_D.prototype,"colorOverLifetime",void 0),c1([c5],_D.prototype,"textureSheetAnimation",void 0),c1([c3],_D.prototype,"_playTime",void 0),c1([c3],_D.prototype,"_firstNewElement",void 0),c1([c3],_D.prototype,"_firstActiveElement",void 0),c1([c3],_D.prototype,"_firstFreeElement",void 0),c1([c3],_D.prototype,"_firstRetiredElement",void 0),c1([c3],_D.prototype,"_primitive",void 0),c1([c3],_D.prototype,"_vertexBufferBindings",void 0),c1([c3],_D.prototype,"_subPrimitive",void 0),c1([c3],_D.prototype,"_renderer",void 0),c1([c3],_D.prototype,"_isPlaying",void 0),c1([c3],_D.prototype,"_instanceBufferResized",void 0),c1([c3],_D.prototype,"_waitProcessRetiredElementCount",void 0),c1([c3],_D.prototype,"_instanceVertexBufferBinding",void 0),c1([c3],_D.prototype,"_instanceVertices",void 0);var _B=(c0(oe=function(e){var t;return(t=uD.call(this,e,dz.find("particle-shader"))||this).shaderData.setColor(uD._baseColorProp,new cj(1,1,1,1)),t.isTransparent=!0,t},uD),oe.prototype.clone=function(){var e=new oe(this._engine);return this.cloneTo(e),e},cZ(oe,[{key:"baseColor",get:function(){return this.shaderData.getColor(uD._baseColorProp)},set:function(e){var t=this.shaderData.getColor(uD._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(uD._baseTextureProp)},set:function(e){this.shaderData.setTexture(uD._baseTextureProp,e),e?this.shaderData.enableMacro(uD._baseTextureMacro):this.shaderData.disableMacro(uD._baseTextureMacro)}}]),oe),_I=function(e,t){this.time=e,this.count=t};c1([c5],_I.prototype,"count",void 0);var _V=((ot=function(){this.enabled=!0,this.randomDirectionAmount=0}).prototype._generatePositionAndDirection=function(e,t,r,n){throw Error("BaseShape: must override it.")},ot),_O=((or=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},or.randomPointInsideUnitArcCircle=function(e,t,r){or.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},or.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},or.randomPointInsideUnitCircle=function(e,t){or.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},or._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,a=Math.sqrt(1-r*r);e.x=a*Math.cos(n),e.y=a*Math.sin(n),e.z=r},or._randomPointInsideUnitSphere=function(e,t){or._randomPointUnitSphere(e,t);var r=Math.pow(t.random(),1/3);e.x=e.x*r,e.y=e.y*r,e.z=e.z*r},or._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},or);e.ParticleShapeType=void 0,(on=e.ParticleShapeType||(e.ParticleShapeType={}))[on.Box=0]="Box",on[on.Circle=1]="Circle",on[on.Cone=2]="Cone",on[on.Hemisphere=3]="Hemisphere",on[on.Sphere=4]="Sphere";var _N=(c0(oa=function(){var t;return t=_V.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Box,t.size=new cB(1,1,1),t},_V),oa.prototype._generatePositionAndDirection=function(e,t,r,n){_O._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=oa._tempVector30;a.set(0,0,-1),_O._randomPointUnitSphere(n,e),cB.lerp(a,n,this.randomDirectionAmount,n)},oa);_N._tempVector30=new cB,c1([c5],_N.prototype,"size",void 0),e.ParticleShapeArcMode=void 0,(oi=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[oi.Random=0]="Random",oi[oi.Loop=1]="Loop";var _k=(c0(oo=function(){var t;return t=_V.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Circle,t.radius=1,t.arc=360,t.arcMode=e.ParticleShapeArcMode.Random,t.arcSpeed=1,t},_V),oo.prototype._generatePositionAndDirection=function(t,r,n,a){var i=oo._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=cD.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(t.random());break;case e.ParticleShapeArcMode.Random:_O.randomPointInsideUnitArcCircle(cD.degreeToRadian(this.arc),i,t)}n.set(i.x,i.y,0),n.scale(this.radius),_O._randomPointUnitSphere(a,t),cB.lerp(n,a,this.randomDirectionAmount,a)},oo);_k._tempPositionPoint=new cW;var _z=(c0(os=function(){var t;return t=_V.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Cone,t.angle=25,t.radius=1,t.length=5,t.emitType=0,t},_V),os.prototype._generatePositionAndDirection=function(e,t,r,n){var a=os._tempVector20,i=cD.degreeToRadian(this.angle),o=Math.sin(i),s=Math.cos(i);switch(this.emitType){case 0:_O.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var l=os._tempVector21;_O.randomPointInsideUnitCircle(l,e),cW.lerp(a,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:_O.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0),n.set(a.x*o,a.y*o,-s),n.normalize();var c=os._tempVector30;cB.scale(n,this.length*e.random(),c),r.add(c);var d=os._tempVector31;_O._randomPointUnitSphere(d,e),cB.lerp(n,d,this.randomDirectionAmount,n)}},os);_z._tempVector20=new cW,_z._tempVector21=new cW,_z._tempVector30=new cB,_z._tempVector31=new cB,e.ConeEmitType=void 0,(ol=e.ConeEmitType||(e.ConeEmitType={}))[ol.Base=0]="Base",ol[ol.Volume=1]="Volume";var _U=(c0(oc=function(){var t;return t=_V.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Hemisphere,t.radius=1,t},_V),oc.prototype._generatePositionAndDirection=function(e,t,r,n){_O._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var a=r.z;a>0&&(r.z=-a),_O._randomPointUnitSphere(n,e),cB.lerp(r,n,this.randomDirectionAmount,n)},oc),_G=(c0(od=function(){var t;return t=_V.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Sphere,t.radius=1,t},_V),od.prototype._generatePositionAndDirection=function(e,t,r,n){_O._randomPointInsideUnitSphere(r,e),r.scale(this.radius),_O._randomPointUnitSphere(n,e),cB.lerp(r,n,this.randomDirectionAmount,n)},od);dz.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}");var _H=(c0(ou=function(t){var r,n=(r=uL.call(this,t,dz.find("trail"))||this).renderState.blendState.targetBlendState;return n.enabled=!0,n.sourceColorBlendFactor=n.sourceAlphaBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=n.destinationAlphaBlendFactor=e.BlendFactor.One,r.renderState.depthState.writeEnabled=!1,r},uL),ou),_W=new cB,_K=(c0(oh=function(e,t){(r=d8.call(this,e)||this)._stroke=t.stroke||.2,r._minSeg=t.minSeg||.02,r._lifetime=t.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*e.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var r,n=0;n<r._maxPointNum;n++)r._points.push(new cB),r._pointStates.push(r._lifetime),r._strapPoints.push(new cB),r._strapPoints.push(new cB);r._curPointNum=0;var a=t.material||new _H(r.engine);return r.setMaterial(a),r.setTexture(t.texture),r._initGeometry(),r},d8),(o_=oh.prototype).update=function(e){for(var t=0,r=0,n=0;n<this._curPointNum;n++)this._pointStates[n]-=e,this._pointStates[n]<0?t++:t>0&&(r=n-t,this._pointStates[r]=this._pointStates[n],this._points[r].copyFrom(this._points[n]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];cB.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},o_.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},o_._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),d8.prototype._render.call(this,e)},o_._initGeometry=function(){var t=new d4(this._entity.engine),r=2*this._maxPointNum,n=20*r,a=new Float32Array(n),i=[new d1("POSITION",0,e.VertexElementFormat.Vector3,0),new d1("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new dq(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(i),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=a,this.mesh=t},o_._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new cB(r[0],r[4],r[8]),a=new cB(r[1],r[5],r[9]),i=new cB(r[2],r[6],r[10]),o=this._stroke;a.scale(o);var s=new cB,l=new cB,c=new cU;cB.transformByQuat(n,c,n),cB.transformByQuat(a,c,a);var d=new cB,u=new cB,h=new cB;n.normalize();for(var _=this._vertices,f=0;f<this._maxPointNum;f++){if(f<this._curPointNum){var p=t[f];f===this._curPointNum-1&&0!==f?cB.subtract(p,t[f-1],h):cB.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(cB.dot(n,h));cB.cross(n,h,u),0>=cB.dot(u,i)&&(m=2*Math.PI-m),cU.rotationAxisAngle(i,m,c),cB.transformByQuat(a,c,d),cB.add(p,d,s),cB.subtract(p,d,l)}var g=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[g]=s.x,_[g+1]=s.y,_[g+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},o_._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,r=this._vertices,n=0;n<e;n++){var a=1-n*t,i=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[i]=0,r[i+1]=a,r[o]=1,r[o+1]=a}}},o_._projectOnVector=function(e,t,r){var n=t.clone();cB.normalize(n,n);var a=cB.dot(e,n);r.x=n.x*a,r.y=n.y*a,r.z=n.z*a},o_._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,_W),cB.subtract(e,_W,r)},oh),_j=(c0(of=function(){var t;return t=hB.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},hB),(op=of.prototype).onTextureChange=function(e){},op.onBeginRender=function(t){this.enabled&&(this._camera=t,this._oriCameraCullingMask=t.cullingMask,t.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new d5(this.engine,this.width,this.height,this._isCube?new d7(this.engine,this.width):new d9(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new d5(this.engine,this.width,this.height,this._isCube?new d7(this.engine,this.width):new d9(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},op.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},op._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},cZ(of,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),of),_X=new cB,_q=new cB,_Y=new cB,_Q=(c0(om=function(){var e;return e=_j.apply(this,arguments)||this,e.position=new cB(0,0,0),e._isCube=!0,e.oriViewMatrix=new cG,e},_j),(og=om.prototype).onBeginRender=function(t){if(this.enabled){_j.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var r=0;r<6;r++)this._setCamera(r,t),t.render(e.TextureCubeFace.PositiveX+r);this._restoreCamera(t),_j.prototype._reset.call(this)}},og._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},og._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},og._setCamera=function(e,t){switch(e){case 0:_q.set(0,-1,0),_Y.set(1,0,0);break;case 1:_q.set(0,-1,0),_Y.set(-1,0,0);break;case 2:_q.set(0,0,1),_Y.set(0,1,0);break;case 3:_q.set(0,0,-1),_Y.set(0,-1,0);break;case 4:_q.set(0,-1,0),_Y.set(0,0,1);break;case 5:_q.set(0,-1,0),_Y.set(0,0,-1)}cB.add(this.position,_Y,_X),cG.lookAt(this.position,_X,_q,t.viewMatrix),t.fieldOfView=90},om),_J=Object.freeze({__proto__:null,AmbientLight:hM,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:h6,AnimationClipCurveBinding:h5,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:h7,AnimationEvent:h9,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:_i,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:_o,AnimatorControllerLayer:_s,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorLayerMask:__,AnimatorState:_c,AnimatorStateMachine:_d,AnimatorStateTransition:_t,AssetPromise:uQ,get AssetType(){return e.AssetType},Background:hA,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uD,Basic2DBatcher:ux,BasicRenderPipeline:hj,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:d3,BlendShapeFrame:d2,BlendState:dI,BlinnPhongMaterial:uB,BoolUpdateFlag:dx,BoxColliderShape:hd,BoxShape:_N,Buffer:dq,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:d4,get BufferUsage(){return e.BufferUsage},BufferUtil:dY,Burst:_I,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},get CameraType(){return e.CameraType},Canvas:hT,CapsuleColliderShape:h_,CharacterController:u6,CircleShape:_k,CloneManager:c9,get Collider(){return e.Collider},ColliderShape:hc,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:_T,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:dg,get ConeEmitType(){return e.ConeEmitType},ConeShape:_z,ContentRestorer:un,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:_Q,get CullMode(){return e.CullMode},CurveKey:_w,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:dV,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:hw,get Downsampling(){return e.Downsampling},DynamicCollider:u7,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:_A,Engine:hS,EngineObject:c6,Entity:um,EventDispatcher:dl,FixedJoint:ha,get FogMode(){return e.FogMode},Font:uR,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:_x,GradientColorKey:_y,HemisphereShape:_U,HingeJoint:hi,HitResult:he,IndexBufferBinding:dQ,get IndexFormat(){return e.IndexFormat},InputManager:hm,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:hs,JointMotor:hl,Keyframe:_u,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:hR,Loader:hZ,Logger:df,get MSAASamples(){return e.MSAASamples},MainModule:_E,Material:uL,Mesh:d$,MeshRenderer:d8,get MeshTopology(){return e.MeshTopology},ModelMesh:ut,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uI,PBRMaterial:uV,PBRSpecularMaterial:uO,ParticleCompositeCurve:_C,ParticleCompositeGradient:_b,ParticleCurve:_R,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:_D,ParticleGradient:_v,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_B,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:_g,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleShapeType(){return e.ParticleShapeType},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:ht,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:u9,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:hh,get Platform(){return e.Platform},PointLight:hP,Pointer:u2,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:dZ,PrimitiveMesh:uf,Probe:_j,RasterState:dO,ReferResource:c7,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderQueue:hN,get RenderQueueType(){return e.RenderQueueType},RenderState:dk,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:d5,RenderTargetBlendState:dB,get Renderer(){return e.Renderer},ResourceManager:uJ,RotationOverLifetimeModule:_M,Scene:hD,SceneManager:uY,Script:hB,get SetDataOptions(){return e.SetDataOptions},Shader:dz,ShaderData:dH,ShaderFactory:dE,ShaderLib:dA,ShaderMacro:dS,ShaderMacroCollection:dT,ShaderPass:dL,ShaderProperty:dp,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:dM,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:_P,Skin:ug,SkinnedMeshRenderer:uv,Sky:hC,SkyBoxMaterial:_f,SkyProceduralMaterial:_p,SphereColliderShape:hu,SphereShape:_G,SpotLight:hF,SpringJoint:ho,Sprite:ds,SpriteAtlas:de,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:uC,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:uT,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:_l,StaticCollider:hr,get StencilOperation(){return e.StencilOperation},StencilState:dN,SubMesh:dJ,SubShader:dD,get SunMode(){return e.SunMode},SystemInfo:u8,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:uF,TextUtils:uE,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:dG,Texture2D:d9,Texture2DArray:d6,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:d7,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:_F,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:dm,TrailMaterial:_H,TrailRenderer:_K,Transform:db,UnlitMaterial:uN,Utils:dt,VelocityOverLifetimeModule:_L,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:d0,VertexElement:d1,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},XRManager:hb,assignmentClone:c4,deepClone:c5,dependentComponents:dy,ignoreClone:c3,request:hQ,resourceLoader:uZ,shallowClone:c8});function _Z(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _$(e,t,r){return t&&_Z(e.prototype,t),r&&_Z(e,r),e}function _0(e,t){return(_0=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _1(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_0(e,t)}function _2(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(ov=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[ov.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",ov[ov.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",ov[ov.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",ov[ov.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",ov[ov.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",ov[ov.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",ov[ov.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",ov[ov.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",ov[ov.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",ov[ov.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",ov[ov.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",ov[ov.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",ov[ov.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",ov[ov.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",ov[ov.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",ov[ov.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",ov[ov.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",ov[ov.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",ov[ov.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",ov[ov.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",ov[ov.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",ov[ov.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",ov[ov.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",ov[ov.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",ov[ov.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",ov[ov.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",ov[ov.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",ov[ov.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",ov[ov.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",ov[ov.R11_EAC=37488]="R11_EAC",ov[ov.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",ov[ov.RG11_EAC=37490]="RG11_EAC",ov[ov.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",ov[ov.RGB8_ETC2=37492]="RGB8_ETC2",ov[ov.SRGB8_ETC2=37493]="SRGB8_ETC2",ov[ov.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",ov[ov.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",ov[ov.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",ov[ov.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",ov[ov.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",ov[ov.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",ov[ov.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",ov[ov.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",ov[ov.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",ov[ov.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",ov[ov.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",ov[ov.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",ov[ov.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",ov[ov.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",ov[ov.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",ov[ov.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var _3=(_1(oy=function(e){(t=hT.call(this)||this)._scale=new cW;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},hT),(ox=oy.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!_2(t,OffscreenCanvas)){var r=t.clientWidth*e,n=t.clientHeight*e;this.width=r,this.height=n}},ox.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},ox._onWidthChanged=function(e){this._webCanvas.width=e},ox._onHeightChange=function(e){this._webCanvas.height=e},_$(oy,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&_2(e,OffscreenCanvas)||this._scale.set(e.clientWidth*devicePixelRatio/e.width,e.clientHeight*devicePixelRatio/e.height),this._scale},set:function(e){var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&_2(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),oy),_4=(_1(ob=function(){return hS.apply(this,arguments)},hS),ob.create=function(e){var t=e.canvas,r=new _3("string"==typeof t?document.getElementById(t):t),n=new fo(e.graphicDeviceOptions),a=new ob(r,n,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new hD(a,"DefaultScene")),a})},_$(ob,[{key:"canvas",get:function(){return this._canvas}}]),ob);function _8(){return(_8=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var _5=((oT=(oS=function(t,r,n,a,i){void 0===a&&(a=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,a),c=r===e.BufferBindFlag.VertexBuffer?o.ARRAY_BUFFER:o.ELEMENT_ARRAY_BUFFER;this._gl=o,this._glBuffer=s,this._glBufferUsage=l,this._glBindTarget=c,this._isWebGL2=t.isWebGL2,this.bind(),i?o.bufferData(c,i,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},oT.setData=function(t,r,n,a,i,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=r.BYTES_PER_ELEMENT||1,d=i?c*i:r.byteLength;if(0!==a||d<r.byteLength){var u=void 0!==r.byteOffset;if(this._isWebGL2&&u)s.bufferSubData(l,n,r,a,d/c);else{var h=new Uint8Array(u?r.buffer:r,a*c,d);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},oT.getData=function(e,t,r,n){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},oT.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},oT._getGLBufferUsage=function(t,r){switch(r){case e.BufferUsage.Static:return t.STATIC_DRAW;case e.BufferUsage.Dynamic:return t.DYNAMIC_DRAW;case e.BufferUsage.Stream:return t.STREAM_DRAW}},oS),_9=((oA=(oC=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oA.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,a=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR,o=e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,s=e.GLCompressedTextureInternalFormat.R11_EAC,l=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC,c=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,d=e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,u=e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,h=e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,_=e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,f=e.GLCompressedTextureInternalFormat.RGB_BPTC_UNSIGNED_FLOAT_EXT;return t>=r&&n<=n||t>=a&&t<=i?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=d?this.canIUse(e.GLCapabilityType.pvrtc):t>=u&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oA._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),a=e.GLCapabilityType.shaderVertexID,i=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,d=e.GLCapabilityType.instancedArrays,u=e.GLCapabilityType.multipleSample,h=e.GLCapabilityType.drawBuffers,_=e.GLCapabilityType.blendMinMax,f=e.GLCapabilityType.astc,p=e.GLCapabilityType.astc_webkit,m=e.GLCapabilityType.etc,g=e.GLCapabilityType.etc_webkit,v=e.GLCapabilityType.etc1,y=e.GLCapabilityType.etc1_webkit,x=e.GLCapabilityType.pvrtc,b=e.GLCapabilityType.pvrtc_webkit,S=e.GLCapabilityType.s3tc,T=e.GLCapabilityType.s3tc_webkit,C=e.GLCapabilityType.bptc,A=e.GLCapabilityType.textureFloat,E=e.GLCapabilityType.textureHalfFloat,M=e.GLCapabilityType.textureFloatLinear,R=e.GLCapabilityType.textureHalfFloatLinear,w=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic,D=e.GLCapabilityType.fragDepth;t.set(a,r),t.set(i,r||!!n(i)),t.set(o,r||!!n(o)),t.set(s,r||!!n(s)),t.set(l,r||!!n(l)),t.set(c,r||!!n(c)),t.set(d,r||!!n(d)),t.set(u,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(A,r||!!n(A)),t.set(E,r||!!n(E)),t.set(M,!!n(M)),t.set(R,r||!!n(R)),t.set(P,r&&!!n(P)||!!n(w)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),t.set(D,r||!!n(D)),t.set(f,!!(n(f)||n(p))),t.set(m,!!(n(m)||n(g))),t.set(v,!!(n(v)||n(y))),t.set(x,!!(n(x)||n(b))),t.set(S,!!(n(S)||n(T))),t.set(C,!!n(C))},oA._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,a=null;if(a=r.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?n[i]=o.bind(a):n[i]=o}},oA._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,a=e.GLCapabilityType.drawBuffers,i=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat,c=e.GLCapabilityType.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(c,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(r,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var d={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var u=this.maxDrawBuffers,h=0;h<u;h++)0!=h&&(d["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),d["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(a,_8({drawBuffers:"drawBuffersWEBGL"},d))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},_$(oC,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(e.GLCapabilityType.shaderVertexID)&&this.canIUse(e.GLCapabilityType.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(e.GLCapabilityType.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(e.GLCapabilityType.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var t=this._rhi.requireExtension(e.GLCapabilityType.textureFilterAnisotropic);this._maxAnisoLevel=t?this._rhi.gl.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var t=this._rhi.gl,r=this.canIUse(e.GLCapabilityType.multipleSample);this._maxAntiAliasing=r?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),oC),_6=((oE=function(e){this.rhi=e,this._requireResult={}}).prototype.requireExtension=function(e){return void 0!==this._requireResult[e]||(this._requireResult[e]=this.rhi.gl.getExtension(e)),this._requireResult[e]},oE),_7=((oR=(oM=function(t,r){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=r,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._isSupportVAO=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var r=this._gl,n=this._primitive,a=this._isSupportVAO&&n.enableVAO;if(a){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);r.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,d=t.topology,u=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)r.drawElementsInstanced(d,h,l,u*c,s);else{var _=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,_),r.drawElementsInstanced(d,h,l,u*c,s),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArraysInstanced(d,u,h,s)}else df.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)r.drawElements(d,h,l,u*c);else{var f=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,f),r.drawElements(d,h,l,u*c),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArrays(d,u,h);a?r.bindVertexArray(null):this._disableAttrib()},oR.destroy=function(){this._isSupportVAO&&this._clearVAO()},oR._bindBufferAndAttrib=function(e){var t,r,n=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var d=s[l];if(d){var u=i[d.bindingIndex],h=u.buffer,_=u.stride;r!==(t=h._platformBuffer._glBuffer)&&(r=t,n.bindBuffer(n.ARRAY_BUFFER,t)),n.enableVertexAttribArray(c);var f=d._formatMetaInfo;n.vertexAttribPointer(c,f.size,f.type,f.normalized,_,d.offset),this._canUseInstancedArrays&&n.vertexAttribDivisor(c,d.instanceStepRate),this._attribLocArray.push(c)}else df.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},oR._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},oR._registerVAO=function(e){var t=this._gl,r=t.createVertexArray();t.bindVertexArray(r);var n=this._primitive.indexBufferBinding;n&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.buffer._platformBuffer._glBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,r)},oR._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},oM),fe=((ow=function(e){this._parameters={},this._gl=e,this._parameters={},this._parameters[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_VERTEX_UNIFORM_VECTORS]=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this._parameters[e.MAX_VERTEX_ATTRIBS]=e.getParameter(e.MAX_VERTEX_ATTRIBS),this._parameters[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_TEXTURE_SIZE]=e.getParameter(e.MAX_TEXTURE_SIZE),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.disable(e.STENCIL_TEST),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,0,255),e.stencilFuncSeparate(e.BACK,e.ALWAYS,0,255),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMask(255),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.disable(e.POLYGON_OFFSET_FILL),e.polygonOffset(0,0)}).prototype.getParameter=function(e){return this._parameters[e]},ow),ft=((oF=(oP=function(e,t,r){this._texture=t,this._rhi=e,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=r,this._glTexture=this._gl.createTexture()}).prototype).destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},oF.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},oF.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},oF._bind=function(){this._rhi.bindTexture(this)},oF._init=function(t){var r=this._gl,n=this._isWebGL2,a=this._formatDetail,i=a.internalFormat,o=a.baseFormat,s=a.dataType,l=this._texture,c=l.mipmapCount,d=l.width,u=l.height,h=l.usage,_=l._isDepthTexture;if(this._bind(),n&&!(o===r.LUMINANCE_ALPHA||o===r.ALPHA)&&h!==e.TextureUsage.Dynamic)r.texStorage2D(this._target,c,i,d,u);else if(t)for(var f=0;f<c;f++)for(var p=Math.max(1,d>>f),m=0;m<6;m++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+m,f,i,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,i,d,u,0,o,s,null);else for(var g=0;g<c;g++){var v=Math.max(1,d>>g),y=Math.max(1,u>>g);r.texImage2D(this._target,g,i,v,y,0,o,s,null)}},oF._getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,d=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,df.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,r,n,a,c,d,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oF._setWrapMode=function(t,r){var n=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===e.TextureWrapMode.Clamp||oP._isPowerOf2(s)&&oP._isPowerOf2(l)||(df.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=e.TextureWrapMode.Clamp),t){case e.TextureWrapMode.Clamp:n.texParameteri(i,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(i,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(i,r,n.MIRRORED_REPEAT)}},oF._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},oP._isPowerOf2=function(e){return(e&e-1)==0},oP._getFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.R8G8B8:return{internalFormat:n?r.RGB8:r.RGB,baseFormat:r.RGB,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R8G8B8A8:return{internalFormat:n?r.RGBA8:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R4G4B4A4:return{internalFormat:n?r.RGBA4:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case e.TextureFormat.R5G5B5A1:return{internalFormat:n?r.RGB5_A1:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case e.TextureFormat.R5G6B5:return{internalFormat:n?r.RGB565:r.RGB,baseFormat:r.RGB,dataType:r.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case e.TextureFormat.Alpha8:return{internalFormat:r.ALPHA,baseFormat:r.ALPHA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.LuminanceAlpha:return{internalFormat:r.LUMINANCE_ALPHA,baseFormat:r.LUMINANCE_ALPHA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:n?r.RGBA16F:r.RGBA,baseFormat:r.RGBA,dataType:r.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:n?r.RGBA32F:r.RGBA,baseFormat:r.RGBA,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32_UInt:return{internalFormat:n?r.RGBA32UI:r.NONE,baseFormat:r.RGBA_INTEGER,dataType:r.UNSIGNED_INT,isCompressed:!1};case e.TextureFormat.BC1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.BC3:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case e.TextureFormat.BC7:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case e.TextureFormat.ETC1_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,isCompressed:!0};case e.TextureFormat.ETC2_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC,isCompressed:!0};case e.TextureFormat.PVRTC_RGB2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGB4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.ASTC_4x4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,isCompressed:!0};case e.TextureFormat.ASTC_5x5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,isCompressed:!0};case e.TextureFormat.ASTC_6x6:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,isCompressed:!0};case e.TextureFormat.ASTC_8x8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,isCompressed:!0};case e.TextureFormat.ASTC_10x10:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,isCompressed:!0};case e.TextureFormat.ASTC_12x12:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,isCompressed:!0};case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:n?r.DEPTH_COMPONENT16:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oP._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oP._supportTextureFormat=function(t,r){switch(t){case e.TextureFormat.R16G16B16A16:if(!r.canIUse(e.GLCapabilityType.textureHalfFloat))return!1;break;case e.TextureFormat.R32G32B32A32:if(!r.canIUse(e.GLCapabilityType.textureFloat))return!1;break;case e.TextureFormat.Depth16:case e.TextureFormat.Depth24Stencil8:case e.TextureFormat.Depth:case e.TextureFormat.DepthStencil:if(!r.canIUse(e.GLCapabilityType.depthTexture))return!1;break;case e.TextureFormat.R32G32B32A32_UInt:case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},oP._supportRenderBufferColorFormat=function(t,r){var n=!0;switch(t){case e.TextureFormat.R16G16B16A16:r.canIUse(e.GLCapabilityType.colorBufferHalfFloat)&&r.canIUse(e.GLCapabilityType.textureHalfFloat)||(n=!1);break;case e.TextureFormat.R32G32B32A32:r.canIUse(e.GLCapabilityType.colorBufferFloat)&&r.canIUse(e.GLCapabilityType.textureFloat)||(n=!1)}return n},oP._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return!1}return!0},_$(oP,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var r=this._gl,n=this._target,a=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.NEAREST_MIPMAP_NEAREST:r.NEAREST);break;case e.TextureFilterMode.Bilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_NEAREST:r.LINEAR);break;case e.TextureFilterMode.Trilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_LINEAR:r.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(t){this._bind();var r=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NEVER);break;case e.TextureDepthCompareFunction.Less:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LESS);break;case e.TextureDepthCompareFunction.Equal:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GEQUAL);break;case e.TextureDepthCompareFunction.Always:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.ALWAYS)}}}]),oP),fr=((oD=(oL=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,a=r._depth,i=r.width,o=r.height,s=_2(a,dG),l=0,c=n.length;l<c;l++){var d=n[l]._format;if(!ft._supportRenderBufferColorFormat(d,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[d]+" in RenderTarget")}if(!s&&!ft._supportRenderBufferDepthFormat(a,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[a]+" in RenderTarget");if(n.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==i||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(a.width!==i||a.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return _2(e,d7)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=t.capability.maxAntiAliasing;r.antiAliasing>u&&(df.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+u),r._antiAliasing=u),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),r.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).activeRenderTarget=function(e,t){var r=this._gl,n=this._target;r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=n.getColorTexture(0);if(o){var s=_2(o,d7);(a||s&&i)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=n.depthTexture;if(l){var c=_2(l,d7);if(a||c){var d=l._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,d._formatDetail.attachment,c?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,d._glTexture,e)}}else if(a){var u=ft._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,u,n.width>>e,n.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&r.bindFramebuffer(r.FRAMEBUFFER,this._MSAAFrameBuffer)},oD.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),r=this._target,n=r.colorTextureCount,a=r.width,i=r.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<n;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},oD.destroy=function(){var e=this._gl;this._frameBuffer&&e.deleteFramebuffer(this._frameBuffer),this._depthRenderBuffer&&e.deleteRenderbuffer(this._depthRenderBuffer),this._MSAAFrameBuffer&&e.deleteFramebuffer(this._MSAAFrameBuffer),this._MSAADepthRenderBuffer&&e.deleteRenderbuffer(this._MSAADepthRenderBuffer);for(var t=0;t<this._MSAAColorRenderBuffers.length;t++)e.deleteRenderbuffer(this._MSAAColorRenderBuffers[t]);this._frameBuffer=null,this._depthRenderBuffer=null,this._MSAAFrameBuffer=null,this._MSAAColorRenderBuffers.length=0,this._MSAADepthRenderBuffer=null},oD._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,a=r.colorTextureCount,i=r.width,o=r.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),d=e.COLOR_ATTACHMENT0+l;s[l]=d,_2(c,d7)||e.framebufferTexture2D(e.FRAMEBUFFER,d,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(_2(n,dG)&&!_2(n,d7)){var u=n._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,u._formatDetail.attachment,e.TEXTURE_2D,u._glTexture,0)}else if(this._target.antiAliasing<=1){var h=ft._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},oD._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,a=n._depth,i=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var d=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=d,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,d),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,d)}if(e.drawBuffers(this._oriDrawBuffers),null!==a){var u=_2(a,dG)?a._platformTexture._formatDetail:ft._getRenderBufferDepthFormatDetail(a,e,t),h=u.internalFormat,_=u.attachment;e.bindRenderbuffer(e.RENDERBUFFER,r),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,r)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},oD._checkFrameBuffer=function(){var e=this._gl,t=this._isWebGL2,r=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(r){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw Error("The attachment types are mismatched or not all framebuffer attachment points are framebuffer attachment complete");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw Error("There is no attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw Error(" Height and width of the attachment are not the same.");case e.FRAMEBUFFER_UNSUPPORTED:throw Error("The format of the attachment is not supported or if depth and stencil attachments are not the same renderbuffer")}if(t&&r===e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE)throw Error("The values of gl.RENDERBUFFER_SAMPLES are different among attached renderbuffers, or are non-zero if the attached images are a mix of renderbuffers and textures.")},oL),fn=(_1(oB=function(t,r){(n=ft.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,a=r.format,i=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!ft._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||ft._isPowerOf2(o)&&ft._isPowerOf2(s)||(df.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),r._mipmap=!1,r._mipmapCount=r._getMipmapCount()),n._formatDetail=ft._getFormatDetail(a,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},ft),(oI=oB.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,d=l.baseFormat,u=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(a=a||_-r,i=i||f-n,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,r,n,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,a,i,d,u,e)},oI.setImageSource=function(t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.internalFormat,d=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,d,u,t):s.texSubImage2D(this._target,r,i||0,o||0,d,u,t)},oI.getPixelBuffer=function(e,t,r,n,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");ft.prototype._getPixelBuffer.call(this,null,e,t,r,n,a,i)},oB),fa=(_1(oV=function(t,r){n=ft.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,a=r.format,i=r.width,o=r.height,s=r.length,l=r.mipmapCount;if(!n._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!ft._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return n._bind(),n._formatDetail=ft._getFormatDetail(a,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,i,o,s),n},ft),(oO=oV.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){var l=this._target,c=this._gl,d=this._formatDetail,u=d.internalFormat,h=d.baseFormat,_=d.dataType,f=d.isCompressed;i=i||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,r,n,a,e,i,o,s,u,t):c.texSubImage3D(l,r,n,a,e,i,o,s,h,_,t)},oO.setImageSource=function(e,t,r,n,a,i,o){var s,l,c=this._gl,d=this._formatDetail,u=d.baseFormat,h=d.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+n),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),c.texSubImage3D(this._target,r,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,u,h,t)},oO.getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,r,n,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oV),fi=(_1(oN=function(t,r){(n=ft.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,a=r.format,i=r._mipmap,o=r.width,s=n._isWebGL2;if(!ft._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||ft._isPowerOf2(o)||(df.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),r._mipmap=!1,r._mipmapCount=r._getMipmapCount()),n._formatDetail=ft._getFormatDetail(a,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},ft),(ok=oN.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,d=c.internalFormat,u=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>r);if(i=i||f-n,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<r;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,d,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,d,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,u,h,t)},ok.setImageSource=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,d=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,i||0,o||0,c,d,t)},ok.getPixelBuffer=function(e,t,r,n,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");ft.prototype._getPixelBuffer.call(this,e,t,r,n,a,i,o)},oN);e.WebGLMode=void 0,(oz=e.WebGLMode||(e.WebGLMode={}))[oz.Auto=0]="Auto",oz[oz.WebGL2=1]="WebGL2",oz[oz.WebGL1=2]="WebGL1";var fo=((oG=(oU=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new cK(null,null,null,null),this._lastScissor=new cK(null,null,null,null),this._lastClearColor=new cj(null,null,null,null),this._scissorEnable=!1;var r=_8({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(u8.platform===e.Platform.IPhone||u8.platform===e.Platform.IPad){var n=u8.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var a=parseInt(n[1]),i=parseInt(n[2]);15===a&&i>=0&&i<=4&&(r._forceFlush=!0)}}this._options=r,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).init=function(e,t,r){var n,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((n=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&_2(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&_2(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},oG.createPlatformPrimitive=function(e){return new _7(this,e)},oG.createPlatformTexture2D=function(e){return new fn(this,e)},oG.createPlatformTexture2DArray=function(e){return new fa(this,e)},oG.createPlatformTextureCube=function(e){return new fi(this,e)},oG.createPlatformRenderTarget=function(e){return new fr(this,e)},oG.createPlatformBuffer=function(t,r,n,a){return void 0===n&&(n=e.BufferUsage.Static),new _5(this,t,r,n,a)},oG.requireExtension=function(e){return this._extensions.requireExtension(e)},oG.canIUse=function(e){return this.capability.canIUse(e)},oG.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},oG.viewport=function(e,t,r,n){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||r!==i.z||n!==i.w)&&(a.viewport(e,t,r,n),i.set(e,t,r,n))},oG.scissor=function(e,t,r,n){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||r!==i.z||n!==i.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,r,n)),i.set(e,t,r,n)}},oG.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},oG.clearRenderTarget=function(t,r,n){var a=this._gl,i=t._lastRenderState,o=i.blendState.targetBlendState,s=i.depthState,l=i.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=a.COLOR_BUFFER_BIT;var d=this._lastClearColor,u=n.r,h=n.g,_=n.b,f=n.a;n&&(u!==d.r||h!==d.g||_!==d.b||f!==d.a)&&(a.clearColor(u,h,_,f),d.set(u,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(a.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=a.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(a.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=a.STENCIL_BUFFER_BIT,255!==l.writeMask&&(a.stencilMask(255),l.writeMask=255)),a.clear(c)},oG.drawPrimitive=function(e,t,r){e?e.draw(r,t):df.error("draw primitive failed.")},oG.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},oG.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},oG.activeRenderTarget=function(e,t,r,n,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(n,a),i=e.width>>n,o=e.height>>n}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,d=t.x*i,u=r?t.y*o:o-t.y*o-c;this.viewport(d,u,l,c),this.scissor(d,u,l,c)},oG.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},oG.bindTexture=function(e){var t=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[t]!==e&&(this._gl.bindTexture(e._target,e._glTexture),this._activeTextures[t]=e)},oG.setGlobalDepthBias=function(e,t){var r=this._gl,n=0!==e||0!==t;n?(r.enable(r.POLYGON_OFFSET_FILL),r.polygonOffset(t,e)):r.disable(r.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=n},oG.flush=function(){this._gl.flush()},oG.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},oG.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},oG.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var e=this._activeTextures,t=0,r=e.length;t<r;t++)e[t]=null;this._lastViewport.set(null,null,null,null),this._lastScissor.set(null,null,null,null),this._lastClearColor.set(null,null,null,null),this._scissorEnable=!1,this._initGLState(this._gl)},oG._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new fe(e),this._extensions=new _6(this),this._capability=new _9(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},oG.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},oG._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},oG._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},oG._onWebGLContextRestored=function(e){this._onDeviceRestored()},_$(oU,[{key:"isWebGL2",get:function(){return this._isWebGL2}},{key:"renderer",get:function(){return this._renderer}},{key:"gl",get:function(){return this._gl}},{key:"renderStates",get:function(){return this._renderStates}},{key:"capability",get:function(){return this._capability}},{key:"canIUseMoreJoints",get:function(){return this.capability.canIUseMoreJoints}}]),oU);function fs(){return(fs=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function fl(e,t){return(fl=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fc(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&fl(e,t)}function fd(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function fu(e,t){var r,n,a,i,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}},l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i}function fh(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f_(e,t,r){return t&&fh(e.prototype,t),r&&fh(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var ff=((oW=(oH=function(e,t,r,n){void 0===t&&(t=0),void 0===n&&(n=!0),this.data=e,this._dataView=new DataView(e.buffer,e.byteOffset+t,null!=r?r:e.byteLength-t),this._littleEndian=n,this._position=0,this._baseOffset=t}).prototype).nextUint8=function(){var e=this._dataView.getUint8(this._position);return this._position+=1,e},oW.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},oW.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},oW.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},oW.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oW.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},oW.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oW.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oW.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},oW.nextUint64=function(){var e=this._dataView.getUint32(this._position,this._littleEndian),t=this._dataView.getUint32(this._position+4,this._littleEndian);return this._position+=8,e+4294967296*t},oW.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,dt.decodeText(t)},oW.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},oW.nextImagesData=function(e){for(var t=Array(e),r=0;r<e;r++){var n=this._dataView.getUint32(this._position,this._littleEndian);t[r]=n,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},oW.skip=function(e){return this._position+=e,this},oW.scan=function(e,t){void 0===t&&(t=0);for(var r=this._position,n=0;this._dataView.getUint8(this._position)!==t&&n<e;)n++,this._position++;return n<e&&this._position++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)},f_(oH,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),oH),fp={};function fm(e){return function(t){fp[e]=t}}var fg=((oK=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint8(4),a=t.getUint16(5,!0),i=new Uint8Array(e,7,a),o=t.getUint16(7+a,!0),s=new Uint8Array(e,9+a,o),l=dt.decodeText(s),c=dt.decodeText(i),d=new oK;return d.totalLength=r,d.name=l,d.type=c,d.version=n,d.headerLength=s.byteLength+i.byteLength+9,d},f_(oK,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oK);function fv(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cK(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function fy(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cB(e[3*n],e[3*n+1],e[3*n+2]);return r}function fx(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cW(e[2*n],e[2*n+1]);return r}function fb(e,t,r){return(fb=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&fl(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oj=function(){}).decode=function(e,t){return new Promise(function(r){var n=new ut(e),a=JSON.parse(t.nextStr());a.bounds&&n.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=fy(s,l);if(n.setPositions(c),a.normals){var d=fy(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);n.setNormals(d)}if(a.uvs){var u=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);n.setUVs(fx(u,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);n.setUVs(fx(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);n.setUVs(fx(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);n.setUVs(fx(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);n.setUVs(fx(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);n.setUVs(fx(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);n.setUVs(fx(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);n.setUVs(fx(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cj(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);n.setBoneWeights(fv(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);n.setBoneIndices(fv(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new d3(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,a=fy(r,n);e.deltaNormals&&fy(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&fv(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,a)}),n.addBlendShape(t)}),a.indices){var S=null;S=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),n.setIndices(S)}a.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},oj),e.MeshDecoder=fd([fm("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oX=function(){}).decode=function(e,t){return new Promise(function(r,n){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),d=t.nextUint8(),u=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new d9(e,u,h,d,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,r(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&r(m)};if(t(),i){var n=function(e){var r=new window.Blob([p[e]]),n=new Image;n.onload=function(){m.setImageSource(n,e),t()},n.src=URL.createObjectURL(r)};m.generateMipmaps();for(var a=1;a<f;a++)n(a)}},b.src=URL.createObjectURL(x)}})},oX),e.Texture2DDecoder=fd([fm("Texture2D")],e.Texture2DDecoder);var fS=((oY=(oq=function(e){this._context=e}).prototype).parseEntity=function(e){return this._getEntityByConfig(e).then(function(t){t.isActive=null==(r=e.isActive)||r;var r,n,a=e.position,i=e.rotation,o=e.scale;return a&&t.transform.position.copyFrom(a),i&&t.transform.rotation.copyFrom(i),o&&t.transform.scale.copyFrom(o),t.layer=null!=(n=e.layer)?n:t.layer,t})},oY.parseClassObject=function(e){var t,r=this,n=hZ.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return fb(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},oY.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var a=t.methods[n],i=0,o=a.length;i<o;i++)r.push(this.parseMethod(e,n,a[i]));if(t.props){var s=this,l=function(n){var a=t.props[n],i=s.parseBasicType(a,e[n]).then(function(t){return e[n]=t});r.push(i)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=oq.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},oY.parseMethod=function(e,t,r){var n=this;return Promise.all(r.map(function(e){return n.parseBasicType(e)})).then(function(r){return e[t].apply(e,[].concat(r))})},oY.parseBasicType=function(e,t){var r=this;if(Array.isArray(e))return Promise.all(e.map(function(e){return r.parseBasicType(e)}));if("object"==typeof e&&null!=e){if(oq._isClass(e))return this.parseClassObject(e);if(oq._isAssetRef(e))return this._context.resourceManager.getResourceByRef(e);if(oq._isEntityRef(e))return Promise.resolve(this._context.entityMap.get(e.entityId));if(t){var n=this,a=function(r){if("methods"===r){var a=e[r];for(var o in a)for(var s=a[o],l=0,c=s.length;l<c;l++){var d=s[l];i.push(n.parseMethod(t,o,d))}}else i.push(n.parseBasicType(e[r],t[r]).then(function(e){return t[r]=e}))},i=[];for(var o in e)a(o);return Promise.all(i).then(function(){return t})}}return Promise.resolve(e)},oY._getEntityByConfig=function(e){var t=e.assetRefId,r=this._context.engine;return t?r.resourceManager.getResourceByRef({refId:t,key:e.key,isClone:e.isClone}).then(function(t){return t.name=e.name,t}):Promise.resolve(new um(r,e.name))},oq.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oq._isClass=function(e){return void 0!=e.class},oq._isAssetRef=function(e){return void 0!=e.refId},oq._isEntityRef=function(e){return void 0!=e.entityId},oq);fS.customParseComponentHandles=new Map;var fT=((oQ=function(e,t,r){this.originalData=e,this.engine=t,this.target=r,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=t.resourceManager}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},oQ),fC=(fc(oJ=function(){return fT.apply(this,arguments)},fT),oJ);function fA(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function fE(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return fA(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fA(e,t)}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var fM=((o$=(oZ=function(e){var t=this;this.context=e,this.prefabContextMap=new WeakMap,this.prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new fS(e)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},o$._parseEntities=function(){var e=this,t=this.context.originalData.entities,r=this.context.entityConfigMap,n=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var n,i=null!=(n=t.strippedId)?n:t.id;return t.id=i,r.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var r=0,a=e.length;r<a;r++)n.set(t[r].id,e[r]);return e})},o$._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,r=this.context.components,n=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],d=c.refId?c.refId:c.class,u=s.addComponent(hZ.getClass(d));r.set(c.id,u);var h=this._reflectionParser.parsePropsAndMethods(u,c);n.push(h)}return Promise.all(n)},o$._parsePrefabModification=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.target,n=t.props,a=t.methods,i=r.entityId,o=r.componentId,s=e.prefabContextMap.get(c),l=s.entityMap.get(i),d=s.components.get(o);return d?e._reflectionParser.parsePropsAndMethods(d,{props:n,methods:a}):l?Promise.resolve(e._applyEntityData(l,n)):void 0})))}}(a);return Promise.all(n)},o$._parsePrefabRemovedEntities=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.entityId,n=e.prefabContextMap.get(c).entityMap.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},o$._parsePrefabRemovedComponents=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=r.get(s);n.concat.apply(n,[].concat(l.map(function(t){var r=t.componentId,n=e.prefabContextMap.get(c).components.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},o$._clearAndResolve=function(){return this.context.target},o$._organizeEntities=function(){for(var e,t=this.context,r=t.rootIds,n=t.strippedIds,a=r.concat(n),i=fE(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<r.length;s++)this.handleRootEntity(r[s])},o$._getEntityByConfig=function(e,t){var r=this;return(e.assetRefId?this._parseGLTF(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return r._applyEntityData(t,e)})},o$._parseEntity=function(e,t){var r=new um(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(r)},o$._parseGLTF=function(e,t){var r=this,n=e.assetRefId,a=new fT(null,t);return t.resourceManager.getResourceByRef({refId:n}).then(function(t){var n=t.instantiateSceneRoot();e.parent||r.context.rootIds.push(e.id),r._traverseAddEntityToMap(n,a,""),r.prefabContextMap.set(n,a);var i=r.prefabPromiseMap.get(e.id);return i&&i.forEach(function(e){e.resolve(a)}),n})},o$._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(r,n){var a,i=null!=(a=t.prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:r,reject:n}),t.prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var r=e.prefabSource.entityId;return t.entityMap.get(r)})},o$._parseChildren=function(e){var t=this.context,r=t.entityConfigMap,n=t.entityMap,a=r.get(e).children;if(a&&a.length>0)for(var i=n.get(e),o=0;o<a.length;o++){var s=a[o],l=n.get(s);i.addChild(l),this._parseChildren(s)}},o$._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(r=t.isActive)?r:e.isActive,e.name=null!=(n=t.name)?n:e.name;var r,n,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},o$._traverseAddEntityToMap=function(e,t,r){var n=t.entityMap,a=t.components,i={},o={};n.set(r,e),e._components.forEach(function(t){var n=hZ.getClassName(t.constructor);i[n]||(i[n]=e.getComponents(t.constructor,[]),o[n]=0),a.set(r+":"+n+"/"+o[n]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],d=r?r+"/"+s:""+s;this._traverseAddEntityToMap(c,t,d)}},oZ),fR=(fc(o0=function(){return fM.apply(this,arguments)},fM),o0.prototype.handleRootEntity=function(e){this.context.target=this.context.entityMap.get(e)},o0.parse=function(e,t){var r=new fC(t,e),n=new o0(r);return n.start(),n},o0);e.InterpolableValueType=void 0,(o1=e.InterpolableValueType||(e.InterpolableValueType={}))[o1.Float=0]="Float",o1[o1.FloatArray=1]="FloatArray",o1[o1.Vector2=2]="Vector2",o1[o1.Vector3=3]="Vector3",o1[o1.Vector4=4]="Vector4",o1[o1.Quaternion=5]="Quaternion",o1[o1.Color=6]="Color",o1[o1.Array=7]="Array",o1[o1.Boolean=8]="Boolean",o1[o1.Rect=9]="Rect",o1[o1.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((o2=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),a=new h6(n),i=r.nextUint16(),o=0;o<i;++o){var s=new h9;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,a.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var d=r.nextStr(),u=r.nextStr(),h=hZ.getClass(u),_=r.nextStr(),f=r.nextStr(),p=void 0,m=r.nextUint8(),g=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(p=new e.AnimationFloatCurve).interpolation=m;for(var v=0;v<g;++v){var y=new _u;y.time=r.nextFloat32(),y.value=r.nextFloat32(),y.inTangent=r.nextFloat32(),y.outTangent=r.nextFloat32(),p.addKey(y)}break;case"AnimationArrayCurve":(p=new e.AnimationArrayCurve).interpolation=m;for(var x=0;x<g;++x){var b=new _u;b.time=r.nextFloat32();var S=r.nextUint16();b.value=Array.from(r.nextFloat32Array(S)),b.inTangent=Array.from(r.nextFloat32Array(S)),b.outTangent=Array.from(r.nextFloat32Array(S)),p.addKey(b)}break;case"AnimationFloatArrayCurve":(p=new e.AnimationFloatArrayCurve).interpolation=m;for(var T=0;T<g;++T){var C=new _u;C.time=r.nextFloat32();var A=r.nextUint16();C.value=r.nextFloat32Array(A),C.inTangent=Array.from(r.nextFloat32Array(A)),C.outTangent=Array.from(r.nextFloat32Array(A)),p.addKey(C)}break;case"AnimationVector2Curve":(p=new e.AnimationVector2Curve).interpolation=m;for(var E=0;E<g;++E){var M=new _u;M.time=r.nextFloat32(),M.value=new cW(r.nextFloat32(),r.nextFloat32()),M.inTangent=new cW(r.nextFloat32(),r.nextFloat32()),M.outTangent=new cW(r.nextFloat32(),r.nextFloat32()),p.addKey(M)}break;case"AnimationVector3Curve":(p=new e.AnimationVector3Curve).interpolation=m;for(var R=0;R<g;++R){var w=new _u;w.time=r.nextFloat32(),w.value=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(w)}break;case"AnimationVector4Curve":(p=new e.AnimationVector4Curve).interpolation=m;var P=new _u;P.time=r.nextFloat32(),P.value=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(P);break;case"AnimationColorCurve":(p=new e.AnimationColorCurve).interpolation=m;for(var F=0;F<g;++F){var L=new _u;L.time=r.nextFloat32(),L.value=new cj(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(L)}break;case"AnimationQuaternionCurve":(p=new e.AnimationQuaternionCurve).interpolation=m;for(var D=0;D<g;++D){var B=new _u;B.time=r.nextFloat32(),B.value=new cU(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),B.inTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),B.outTangent=new cK(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(B)}break;case"AnimationRefCurve":(p=new e.AnimationRefCurve).interpolation=m;for(var I=0;I<g;++I){var V=new _u;V.time=r.nextFloat32();var O=r.nextStr();O?V.value=JSON.parse(O):V.value=null,p.addKey(V)}break;case"AnimationBoolCurve":(p=new e.AnimationBoolCurve).interpolation=m;for(var N=0;N<g;++N){var k=new _u;k.time=r.nextFloat32(),k.value=1===r.nextUint8(),p.addKey(k)}break;case"AnimationStringCurve":(p=new e.AnimationStringCurve).interpolation=m;for(var z=0;z<g;++z){var U=new _u;U.time=r.nextFloat32(),U.value=r.nextStr(),p.addKey(U)}}a.addCurveBinding(d,h,_,f,p)}t(a)})},o2),e.AnimationClipDecoder=fd([fm("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(o3=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",o3.Custom="Custom";var fw=(fc(o4=function(e,t,r){var n;return(n=fT.call(this,e,t,r)||this).originalData=e,n.engine=t,n.scene=r,n},fT),o4),fP=(fc(o8=function(){return fM.apply(this,arguments)},fM),o8.prototype.handleRootEntity=function(e){var t=this.context,r=t.target,n=t.entityMap;r.addRootEntity(n.get(e))},o8.parse=function(e,t){var r=new hD(e),n=new fw(t,e,r),a=new o8(n);return a.start(),a.promise},o8);function fF(e,t){var r=fg.decode(e),n=new ff(new Uint8Array(e),r.headerLength,r.dataLength);return fp[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(fc(o5=function(){return hZ.apply(this,arguments)},hZ),o5.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,{type:"arraybuffer"}).then(function(e){fF(e,t.engine).then(function(e){n(e)})}).catch(a)})},o5),e.MeshLoader=fd([uZ("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(fc(o9=function(){return hZ.apply(this,arguments)},hZ),o9.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,{type:"arraybuffer"}).then(function(e){fF(e,t.engine).then(function(e){n(e)})}).catch(a)})},o9),e.EditorTextureLoader=fd([uZ("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var fL=(fc(o6=function(){return hZ.apply(this,arguments)},hZ),(o7=o6.prototype).load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,fs({},e,{type:"arraybuffer"})).then(function(e){return fF(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return r._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){n(e)})}).catch(a)}).catch(a)})},o7._parseKeyframeValue=function(e,t){var r=e.value;return"object"==typeof r&&(null==r?void 0:r.refId)?new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e.value)})}):Promise.resolve(e.value)},o6);fL=fd([uZ(e.AssetType.AnimationClip,["ani"])],fL);var fD=(fc(se=function(){return hZ.apply(this,arguments)},hZ),se.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,fs({},e,{type:"json"})).then(function(e){var r=new _o,a=e.layers,i=[];a.forEach(function(e,n){var a=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new _s(a);if(c.blendingMode=o,c.weight=s,l){var d=l.states,u=c.stateMachine=new _d;d.forEach(function(e,r){var a=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,d=e.isDefaultState,h=e.clip,_=e.scripts,f=u.addState(a);d&&(u.defaultState=f),f.speed=o,f.wrapMode=s,f.clipStartTime=l,f.clipEndTime=c;var p=JSON.parse(_);null==p||p.forEach(function(e){f.addStateMachineScript(hZ.getClass(e))}),h&&i.push(new Promise(function(e){t.getResourceByRef(h).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),d.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var r=e.targetStateName,n=e.duration,a=e.offset,i=e.exitTime,o=u.findStateByName(t),s=u.findStateByName(r),l=new _t;l.destinationState=s,l.duration=n,l.exitTime=i,l.offset=a,o.addTransition(l)})})}r.addLayer(c)}),Promise.all(i).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,a=e.clip;r.layers[t].stateMachine.states[n].clip=a}),n(r)})}).catch(a)})},se);fD=fd([uZ(e.AssetType.AnimatorController,["json"],!1)],fD);var fB=(fc(st=function(){return hZ.apply(this,arguments)},hZ),st.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new uQ(function(e){var r=t.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(r),function(e){return e.charCodeAt(0)}).buffer)}):this.request(t,fs({},e,{type:"arraybuffer"}))},st);fB=fd([uZ(e.AssetType.Buffer,["bin","r3bin"],!1)],fB);var fI=(fc(sr=function(){return hZ.apply(this,arguments)},hZ),sr.prototype.load=function(t,r){var n=this;return new uQ(function(a,i){n.request(t.url,{type:"arraybuffer"}).then(function(t){var n=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=r.engine,s=new d7(o,i);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,d=0;d<l;d++)for(var u=i>>d,h=0;h<6;h++){var _=u*u*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+h,f,d)}var p=new hM(o),m=new cq;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,a(p)}).catch(function(e){i(e)})})},sr);function fV(e,t,r,n,a,i,o){try{var s=e[i](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,a)}function fO(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var i=e.apply(t,r);function o(e){fV(i,n,a,o,s,"next",e)}function s(e){fV(i,n,a,o,s,"throw",e)}o(void 0)})}}fI=fd([uZ(e.AssetType.Env,["env"])],fI);var fN=(fc(sn=function(){return hZ.apply(this,arguments)},hZ),(sa=sn.prototype).load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,{type:"json"}).then(function(e){var i=e.fontName,o=e.fontUrl;o?r._registerFont(i,o).then(function(){n(new uR(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):n(new uR(t.engine,i))}).catch(function(e){a(e)})})},sa._registerFont=function(e,t){return fO(function(){var r;return fu(this,function(n){switch(n.label){case 0:return[4,(r=new FontFace(e,"url("+t+")")).load()];case 1:return n.sent(),document.fonts.add(r),[2]}})})()},sn);fN=fd([uZ(e.AssetType.Font,["font"],!1)],fN);var fk=(fc(si=function(e,t){var r;return(r=c7.call(this,e)||this).url=t,r},c7),(so=si.prototype).instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},so._onDestroy=function(){c7.prototype._onDestroy.call(this);var e=this.textures,t=this.materials,r=this.meshes;if(e&&this._disassociationSuperResource(e),t&&this._disassociationSuperResource(t),r)for(var n=0,a=r.length;n<a;n++)this._disassociationSuperResource(r[n])},so._disassociationSuperResource=function(e){for(var t=0,r=e.length;t<r;t++)e[t]._disassociationSuperResource(this)},f_(si,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),si);(ss=cv||(cv={}))[ss.BYTE=5120]="BYTE",ss[ss.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ss[ss.SHORT=5122]="SHORT",ss[ss.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ss[ss.UNSIGNED_INT=5125]="UNSIGNED_INT",ss[ss.FLOAT=5126]="FLOAT",e.AccessorType=void 0,(sl=e.AccessorType||(e.AccessorType={})).SCALAR="SCALAR",sl.VEC2="VEC2",sl.VEC3="VEC3",sl.VEC4="VEC4",sl.MAT2="MAT2",sl.MAT3="MAT3",sl.MAT4="MAT4",(sc=cy||(cy={})).TRANSLATION="translation",sc.ROTATION="rotation",sc.SCALE="scale",sc.WEIGHTS="weights",(sd=cx||(cx={})).Linear="LINEAR",sd.Step="STEP",sd.CubicSpine="CUBICSPLINE",(su=cb||(cb={})).PERSPECTIVE="perspective",su.ORTHOGRAPHIC="orthographic",(sh=cS||(cS={})).JPEG="image/jpeg",sh.PNG="image/png",(s_=cT||(cT={})).OPAQUE="OPAQUE",s_.MASK="MASK",s_.BLEND="BLEND",(sf=cC||(cC={}))[sf.NEAREST=9728]="NEAREST",sf[sf.LINEAR=9729]="LINEAR",(sp=cA||(cA={}))[sp.NEAREST=9728]="NEAREST",sp[sp.LINEAR=9729]="LINEAR",sp[sp.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sp[sp.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sp[sp.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sp[sp.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sm=cE||(cE={}))[sm.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sm[sm.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sm[sm.REPEAT=10497]="REPEAT";var fz=((sv=(sg=function(e,t,r){var n=this;this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,r){var a,i=(a=n._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=r,n._setTaskDetailProgress(e,t,r)},this.contentRestorer=new f1(e)}).prototype).get=function(e,t){var r=this,n=sg._parsers[e];if(!n)return Promise.resolve(null);var a=this._resourceCache,i=void 0===t?""+e:e+":"+t,o=a.get(i);if(o)return o;var s=fG[e],l=!!fH[e];if(s){var c=this.glTF[s];c&&(void 0===t||c[t])?void 0===t?o=8===e?c.map(function(t,n){return r.get(e,n)}):Promise.all(c.map(function(t,n){return r.get(e,n)})):(o=n.parse(this,t),l&&this._handleSubAsset(o,e,t)):o=Promise.resolve(null)}else o=n.parse(this,t),l&&this._handleSubAsset(o,e,t);return a.set(i,o),o},sv.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,r=t.animatorController;return r&&(t._defaultSceneRoot.addComponent(_i).animatorController=r),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},sv._addTaskCompletePromise=function(e){var t=this,r=this._progress.taskComplete;r.total+=1,e.then(function(){t._setTaskCompleteProgress(++r.loaded,r.total)})},sv._handleSubAsset=function(e,t,r){var n,a=this,i=fH[t];if(8===t)((n=this.glTFResource)[i]||(n[i]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==r?a.glTFResource[i]=e:((n=a.glTFResource)[i]||(n[i]=[]))[r]=e,7===t)for(var n,s,l=0,c=e.length;l<c;l++){var d=e[l];a.resourceManager._onSubAssetSuccess(o+"?q="+i+"["+r+"]["+l+"]",d)}else a.resourceManager._onSubAssetSuccess(o+"?q="+i+"["+r+"]",e),2===t&&(null!=(s=a.glTF.scene)?s:0)===r&&a.resourceManager._onSubAssetSuccess(""+o+"?q=defaultSceneRoot",e)})}},sg.addParser=function(e,t){this._parsers[e]=t},sg);fz._parsers={};var fU=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(sy=e.GLTFParserType||(e.GLTFParserType={}))[sy.Schema=0]="Schema",sy[sy.Validator=1]="Validator",sy[sy.Scene=2]="Scene",sy[sy.Buffer=3]="Buffer",sy[sy.BufferView=4]="BufferView",sy[sy.Texture=5]="Texture",sy[sy.Material=6]="Material",sy[sy.Mesh=7]="Mesh",sy[sy.Entity=8]="Entity",sy[sy.Skin=9]="Skin",sy[sy.Animation=10]="Animation",sy[sy.AnimatorController=11]="AnimatorController";var fG=((cM={})[2]="scenes",cM[3]="buffers",cM[5]="textures",cM[6]="materials",cM[7]="meshes",cM[8]="nodes",cM[9]="skins",cM[10]="animations",cM[4]="bufferViews",cM),fH=((cR={})[2]="_sceneRoots",cR[5]="textures",cR[6]="materials",cR[7]="meshes",cR[8]="entities",cR[9]="skins",cR[10]="animations",cR[11]="animatorController",cR);function fW(e){return function(t){var r=new t;fz.addParser(e,r)}}var fK=((sx=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new cW(e[n],e[n+1]);return r},sx.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new cB(e[n],e[n+1],e[n+2]);return r},sx.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new cK(e[n],e[n+1],e[n+2],e[n+3]);return r},sx.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var a=0;a<r;a+=3)n[a/3]=new cj(e[a],e[a+1],e[a+2],1);else for(var i=0;i<r;i+=4)n[i/4]=new cj(e[i],e[i+1],e[i+2],e[i+3]);return n},sx.getAccessorTypeSize=function(t){switch(t){case e.AccessorType.SCALAR:return 1;case e.AccessorType.VEC2:return 2;case e.AccessorType.VEC3:return 3;case e.AccessorType.VEC4:case e.AccessorType.MAT2:return 4;case e.AccessorType.MAT3:return 9;case e.AccessorType.MAT4:return 16}},sx.getComponentType=function(e){switch(e){case cv.BYTE:return Int8Array;case cv.UNSIGNED_BYTE:return Uint8Array;case cv.SHORT:return Int16Array;case cv.UNSIGNED_SHORT:return Uint16Array;case cv.UNSIGNED_INT:return Uint32Array;case cv.FLOAT:return Float32Array}},sx.getNormalizedComponentScale=function(e){switch(e){case cv.BYTE:return 1/127;case cv.UNSIGNED_BYTE:return 1/255;case cv.SHORT:return 1/32767;case cv.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},sx.getAccessorBuffer=function(t,r,n){var a,i=n.componentType,o=sx.getComponentType(i),s=sx.getAccessorTypeSize(n.type),l=o.BYTES_PER_ELEMENT,c=s*l,d=n.count;if(void 0!==n.bufferView){var u=n.bufferView,h=r[u];a=t.get(e.GLTFParserType.BufferView,n.bufferView).then(function(e){var r,a,_,f=h.buffer,p=null!=(r=e.byteOffset)?r:0,m=null!=(a=n.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=u+":"+i+":"+v+":"+d,x=t.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,S=d*(g/l),T=new o(e.buffer,b,S);x[y]=_=new fU(T,!0,g),_.restoreInfo=new f5(new f9(f,o,b,S))}}else{var C=p+m,A=d*s,E=new o(e.buffer,C,A);(_=new fU(E,!1,c)).restoreInfo=new f5(new f9(f,o,C,A))}return _})}else{var _=d*s,f=new o(_),p=new fU(f,!1,c);p.restoreInfo=new f5(new f9(void 0,o,void 0,_)),a=Promise.resolve(p)}return n.sparse?a.then(function(e){return sx.processingSparseData(t,n,e).then(function(){return e})}):a},sx.bufferToVector3Array=function(e,t,r,n,a){for(var i=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?sx.getNormalizedComponentScale(a):1,c=0;c<r;c++){var d=i+c*o;s[c]=new cB(e[d]*l,e[d+1]*l,e[d+2]*l)}return s},sx.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},sx.processingSparseData=function(t,r,n){var a=n.restoreInfo,i=t.glTF.bufferViews,o=sx.getAccessorTypeSize(r.type),s=sx.getComponentType(r.componentType),l=n.data.slice(),c=r.sparse,d=c.count,u=c.indices,h=c.values,_=i[u.bufferView],f=i[h.bufferView];return Promise.all([t.get(e.GLTFParserType.BufferView,u.bufferView),t.get(e.GLTFParserType.BufferView,h.bufferView)]).then(function(e){var t,r,i,c,p=e[0],m=e[1],g=(null!=(t=u.byteOffset)?t:0)+(null!=(r=p.byteOffset)?r:0),v=p.byteLength,y=(null!=(i=h.byteOffset)?i:0)+(null!=(c=m.byteOffset)?c:0),x=m.byteLength;a.typeSize=o,a.sparseCount=d;var b=sx.getComponentType(u.componentType),S=v/b.BYTES_PER_ELEMENT,T=new b(p.buffer,g,S);a.sparseIndices=new f9(_.buffer,b,g,S);var C=x/s.BYTES_PER_ELEMENT,A=new s(m.buffer,y,C);a.sparseValues=new f9(f.buffer,s,y,C);for(var E=0;E<d;E++)for(var M=T[E],R=0;R<o;R++)l[M*o+R]=A[E*o+R];n.data=l})},sx.getIndexFormat=function(t){switch(t){case cv.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case cv.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case cv.UNSIGNED_INT:return e.IndexFormat.UInt32}},sx.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==cv.FLOAT)switch(r){case 1:return e.VertexElementFormat.Float;case 2:return e.VertexElementFormat.Vector2;case 3:return e.VertexElementFormat.Vector3;case 4:return e.VertexElementFormat.Vector4}if(t==cv.SHORT)switch(r){case 2:return n?e.VertexElementFormat.NormalizedShort2:e.VertexElementFormat.Short2;case 3:case 4:return n?e.VertexElementFormat.NormalizedShort4:e.VertexElementFormat.Short4}if(t==cv.UNSIGNED_SHORT)switch(r){case 2:return n?e.VertexElementFormat.NormalizedUShort2:e.VertexElementFormat.UShort2;case 3:case 4:return n?e.VertexElementFormat.NormalizedUShort4:e.VertexElementFormat.UShort4}if(t==cv.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==cv.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},sx.loadImageBuffer=function(e,t){return new Promise(function(r,n){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){n(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){r(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},sx.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),a={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==a.magic)return{originBuffer:t};var i=n.getUint32(12,!0),o=n.getUint32(16,!0);if(o!==r.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(dt.decodeText(s)),c=[],d=20+i,u=e.contentRestorer.glbBufferSlices;d<a.length;){if(i=n.getUint32(d,!0),(o=n.getUint32(d+4,!0))!==r.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=d+8,_=t.slice(h,h+i);c.push(_),u.push(new cW(h,i)),d+=i+8}return{glTF:l,buffers:c}},sx.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,a=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==a&&(e.wrapModeV=a)},sx.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=cA.NEAREST_MIPMAP_NEAREST,n===cC.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=cA.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},sx);(sb=cw||(cw={}))[sb.linear=1]="linear",sb[sb.sRGB=2]="sRGB",(sS=cP||(cP={}))[sS.ETC1S=163]="ETC1S",sS[sS.UASTC=166]="UASTC",(sT=cF||(cF={}))[sT.None=0]="None",sT[sT.BasisLZ=1]="BasisLZ",sT[sT.Zstd=2]="Zstd",sT[sT.ZLib=3]="ZLib";var fj=((sC=function(e){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(e)}).prototype.parse=function(e){var t=e.buffer,r=e.byteOffset,n=new ff(e,12);this.vkFormat=n.nextUint32(),this.typeSize=n.nextUint32(),this.pixelWidth=n.nextUint32(),this.pixelHeight=n.nextUint32(),this.pixelDepth=n.nextUint32(),this.layerCount=n.nextUint32(),this.faceCount=n.nextUint32();var a=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var i=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),d=n.nextUint64(),u=Array(a),h=24*a,_=new ff(e,n.offset,h);this.levels=u;for(var f=0;f<a;f++)u[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new ff(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new ff(e,s,l,!0);x.position<l;){var b=x.nextUint32(),S=x.scan(b),T=dt.decodeText(S),C=x.nextUint8Array(b-S.byteLength-1);this.keyValue[T]=T.match(/^ktx/i)?dt.decodeText(C).replace(/^(.*)\x00$/,"$1"):C;var A=b%4?4-b%4:0;x.skip(A)}if(d<=0)return this;for(var E=new ff(e,c,d,!0),M=E.nextUint16(),R=E.nextUint16(),w=E.nextUint32(),P=E.nextUint32(),F=E.nextUint32(),L=E.nextUint32(),D=Array(a),B=0;B<a;B++)D[B]={imageFlags:E.nextUint32(),rgbSliceByteOffset:E.nextUint32(),rgbSliceByteLength:E.nextUint32(),alphaSliceByteOffset:E.nextUint32(),alphaSliceByteLength:E.nextUint32()};var I=c+E.position,V=I+w,O=V+P,N=O+F,k=new Uint8Array(t,r+I,w),z=new Uint8Array(t,r+V,P),U=new Uint8Array(t,r+O,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:M,selectorCount:R,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},f_(sC,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sC);e.KTX2TargetFormat=void 0,(sA=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sA.ASTC=0]="ASTC",sA[sA.BC7=1]="BC7",sA[sA.BC1_BC3=2]="BC1_BC3",sA[sA.PVRTC=3]="PVRTC",sA[sA.ETC=4]="ETC",sA[sA.R8=5]="R8",sA[sA.R8G8=6]="R8G8",sA[sA.R8G8B8A8=7]="R8G8B8A8";var fX=((sM=(sE=function(e,t){void 0===e&&(e=4),this.limitedCount=e,this._workerCreator=t,this._taskQueue=[],this._workerStatus=0,this._workerItems=Array(e)}).prototype).prepareWorker=function(){for(var e=this.limitedCount,t=Array(e),r=0;r<e;r++)t.push(this._initWorker(r));return Promise.all(t)},sM.postMessage=function(e){var t=this;return new Promise(function(r,n){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sM.destroy=function(){for(var e=this._workerItems,t=0,r=e.length;t<r;t++){var n=e[t];n.worker.terminate(),n.reject=null,n.resolve=null}e.length=0,this._taskQueue.length=0,this._workerStatus=0},sM._initWorker=function(e){var t=this;return Promise.resolve(this._workerCreator()).then(function(r){return r.addEventListener("message",t._onMessage.bind(t,e)),t._workerItems[e]={worker:r,resolve:null,reject:null},r})},sM._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sM._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sM._nextTask=function(e){if(this._taskQueue.length){var t=this._taskQueue.shift(),r=this._workerItems[e];r.resolve=t.resolve,r.reject=t.reject,r.worker.postMessage(t.message)}else this._workerStatus^=1<<e},sE),fq=((sw=(sR=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sw.destroy=function(){this._transcodeWorkerPool.destroy()},sw._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new fX(this.workerLimitCount,function(){return new Promise(function(r,n){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?n(e.data.error):r(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sR);function fY(){var e,t=function(t){return e||(e=new Promise(function(e,r){var n={wasmBinary:t,onRuntimeInitialized:function(){return e(n)},onAbort:r};self.BASIS(n)}).then(function(e){return e.initializeBasis(),e.KTX2File})),e};self.onmessage=function(e){var r=e.data;switch(r.type){case"init":t(r.transcoderWasm).then(function(){self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":t().then(function(e){var t=fJ(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var fQ=function(e){return sP||(sP=new Promise(function(t,r){var n={wasmBinary:e,onRuntimeInitialized:function(){return t(n)},onAbort:r};self.BASIS(n)}).then(function(e){return e.initializeBasis(),e.KTX2File})),sP};function fJ(e,t,r){var n,a,i,o,s=function(){l.close(),l.delete()};(i=n||(n={}))[i.ETC1=0]="ETC1",i[i.ETC2=1]="ETC2",i[i.BC1=2]="BC1",i[i.BC3=3]="BC3",i[i.BC4=4]="BC4",i[i.BC5=5]="BC5",i[i.BC7=7]="BC7",i[i.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",i[i.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",i[i.ASTC_4x4=10]="ASTC_4x4",i[i.RGBA8=13]="RGBA8",(o=a||(a={}))[o.ASTC=0]="ASTC",o[o.BC7=1]="BC7",o[o.BC1_BC3=2]="BC1_BC3",o[o.PVRTC=3]="PVRTC",o[o.ETC=4]="ETC",o[o.R8=5]="R8",o[o.RG8=6]="RG8",o[o.RGBA8=7]="RGBA8";var l=new r(new Uint8Array(e));if(!l.isValid())throw s(),Error("Invalid or unsupported .ktx2 file");if(!l.startTranscoding())throw s(),Error("KTX2 startTranscoding failed");for(var c=l.getWidth(),d=l.getHeight(),u=l.getLayers()||1,h=l.getLevels(),_=l.getHasAlpha(),f=l.getFaces(),p=function(e,t){switch(e){case 2:return t?3:2;case 4:return t?1:0;case 3:return t?9:8;case 7:return 13;case 0:return 10;case 1:return 7}}(t,_),m=Array(f),g=2===p||3===p||7===p,v=0;v<f;v++){for(var y=Array(h),x=0;x<h;x++){for(var b=Array(u),S=void 0,T=void 0,C=0;C<u;C++){var A=l.getImageLevelInfo(x,C,v);g&&0===x&&(c!==A.width||d!==A.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=S=A.width)+", height: "+(d=T=A.height)+". You'd better use an image whose size if multiple of 4."):(S=A.origWidth,T=A.origHeight);var E=new Uint8Array(l.getImageTranscodedSizeInBytes(x,C,0,p));if(!l.transcodeImage(E,x,C,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");b[C]=E}y[x]={data:function(e){if(1===e.length)return e[0];for(var t=0,r=0;r<e.length;r++)t+=e[r].byteLength;for(var n=new Uint8Array(t),a=0,i=0;i<e.length;i++)n.set(e[i],a),a+=e[i].byteLength;return n}(b),width:S,height:T}}m[v]=y}return s(),{faces:m,width:c,height:d,hasAlpha:_,faceCount:f,format:p}}var fZ=(fc(sF=function(e){return fq.call(this,e)},fq),(sL=sF.prototype)._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var r=t[0],n=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){fQ(n).then(function(){e(null)})},a.onerror=function(){t()}});var a=fY.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+r+"\n "+fJ.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},sL.transcode=function(e,t){return 0===this.workerLimitCount?fQ().then(function(r){return fJ(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},sF);function f$(){var e,t,r,n=function(e,t,r,n){var a=(r+3>>2)*(n+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null},a=function(e,t,r){var a=e.length,i=Array(a),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<a;s++){for(var l=e[s].length,c=Array(l),d=0;d<l;d++){var u=e[s][d],h=u.buffer,_=u.levelHeight,f=u.levelWidth,p=u.uncompressedByteLength;t&&(h=o.decode(h.slice(),p));var m=h.byteLength/a,g=h.byteOffset,v=n(r,new Uint8Array(h.buffer,g+s*m,m),f,_);if(v)c[d]={data:v.slice(),width:f,height:_};else throw"buffer decoded error"}i[s]=c}return i})},i=((t=(e=function(){}).prototype).init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,r){if(void 0===r&&(r=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var n=e.instance.exports,a=t.byteLength,i=n.malloc(a);e.heap.set(t,i),r=r||Number(n.ZSTD_findDecompressedSize(i,a));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,i,a),l=e.heap.slice(o,o+s);return n.free(i),n.free(o),l},e);i.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){i.heap=new Uint8Array(i.instance.exports.memory.buffer)}}},i.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new i;self.onmessage=function(e){var t,n=e.data;switch(n.type){case"init":(t=n.transcoderWasm,r=WebAssembly.instantiate(t,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":r.then(function(e){a(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var f0=(fc(sD=function(e,t){var r;return(r=fq.call(this,e)||this).type=t,r},fq),(sB=sD.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(sD.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=f$.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},sB.transcode=function(e){for(var t=e.supercompressionScheme===cF.Zstd,r=e.levels.length,n=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(n)},o=i.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var d=e.levels[c],u=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=d.levelData.buffer,f=d.levelData.byteOffset,p=d.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:u,levelHeight:h,uncompressedByteLength:d.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},sD);f0.transcoderMap=((sI={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",sI),e.KTX2Loader=(fc(sV=function(){return hZ.apply(this,arguments)},hZ),(sO=sV.prototype).initialize=function(t,r){if(r.ktx2Loader){var n=r.ktx2Loader;return(n.priorityFormats&&(e.KTX2Loader._priorityFormats.etc1s=n.priorityFormats,e.KTX2Loader._priorityFormats.uastc=n.priorityFormats),1===n.transcoder)?e.KTX2Loader._getKhronosTranscoder(n.workerCount).init():e.KTX2Loader._getBinomialLLCTranscoder(n.workerCount).init()}},sO.load=function(t,r){var n=this;return new uQ(function(a,i,o,s){n.request(t.url,{type:"arraybuffer"}).onProgress(o,s).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)})}).then(a).catch(i)})},sV.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},sV._parseBuffer=function(t,r,n){var a,i,o=new fj(t),s=null!=(a=null==n?void 0:n.priorityFormats)?a:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&f0.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var d=e.KTX2Loader._getBinomialLLCTranscoder();i=d.init().then(function(){return d.transcode(t,l)})}return i.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},sV._createTextureByBuffer=function(t,r,n,a){var i,o=r.width,s=r.height,l=r.faces,c=l.length,d=l[0],u=d.length>1,h=this._getEngineTextureFormat(n,r);if(6!==c){i=new d9(t,o,s,h,u);for(var _=0;_<d.length;_++){var f=d[_].data;i.setPixelBuffer(f,_)}}else{i=new d7(t,s,h,u);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<d.length;g++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return a&&(i.wrapModeU=a[0],i.wrapModeV=a[1],i.filterMode=a[2],i.anisoLevel=a[3]),i},sV._decideTargetFormat=function(t,r,n){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,n);return i!==e.KTX2TargetFormat.PVRTC||cD.isPowerOf2(r.pixelWidth)&&cD.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===i?(df.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(df.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},sV._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var a=r[n],i=this._supportedMap[a];if(i){for(var o=0;o<i.length;o++)if(t.canIUse(i[o]))return a}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return a;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return a}}return null},sV._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new fZ(t)},sV._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new f0(t,e.KTX2TargetFormat.ASTC)},sV._getEngineTextureFormat=function(t,r){var n=r.hasAlpha;switch(t){case e.KTX2TargetFormat.ASTC:return e.TextureFormat.ASTC_4x4;case e.KTX2TargetFormat.ETC:return n?e.TextureFormat.ETC2_RGBA8:e.TextureFormat.ETC2_RGB;case e.KTX2TargetFormat.BC7:return e.TextureFormat.BC7;case e.KTX2TargetFormat.BC1_BC3:return n?e.TextureFormat.BC3:e.TextureFormat.BC1;case e.KTX2TargetFormat.PVRTC:return n?e.TextureFormat.PVRTC_RGBA4:e.TextureFormat.PVRTC_RGB4;case e.KTX2TargetFormat.R8G8B8A8:return e.TextureFormat.R8G8B8A8}},sV._isBinomialInit=!1,sV._priorityFormats={etc1s:[e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC],uastc:[e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC]},sV._supportedMap=((sN={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],sN[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],sN[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],sN[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],sN[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],sN),sV),e.KTX2Loader=fd([uZ(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(sk=e.KTX2Transcoder||(e.KTX2Transcoder={}))[sk.BinomialLLC=0]="BinomialLLC",sk[sk.Khronos=1]="Khronos";var f1=(fc(sz=function(){var e;return e=un.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},un),(sU=sz.prototype).restoreContent=function(){var t=this;return new uQ(function(r,n){Promise.all(t.bufferRequests.map(function(e){return hQ(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}uQ.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,i=a[n.buffer],o=new Uint8Array(i,null!=(r=n.byteOffset)?r:0,n.byteLength),s=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(o,s.engine).then(function(e){for(var t=e.result.faces[0],r=0;r<t.length;r++)s.setPixelBuffer(t[r].data,r)}):fK.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=fE(t.meshes);!(e=n()).done;){for(var i,o=e.value,s=o.mesh,l=fE(o.vertexBuffers);!(i=l()).done;){var c=i.value,d=t._getBufferData(a,c.data);c.buffer.setData(d)}if(o.indexBuffer){var u=t._getBufferData(a,o.indexBuffer);s.setIndices(u)}for(var h,_=fE(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=fK.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=fK.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=fK.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},sU._getBufferData=function(e,t){var r,n=t.main;if(n){var a=e[n.bufferIndex];r=new n.TypedArray(a,n.byteOffset,n.length)}else r=new n.TypedArray(n.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,d=e[c.bufferIndex],u=new c.TypedArray(d,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)r[f*h+p]=u[_*h+p];return r},sz),f2=function(e,t){this.url=e,this.config=t},f3=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},f4=function(){this.vertexBuffers=[],this.blendShapes=[]},f8=function(e,t){this.buffer=e,this.data=t},f5=function(e,t,r,n,a){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=a},f9=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},f6=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},f7=function(e,t,r,n,a){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=a},pe=((sH=(sG=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];throw"Not implemented."},sH.additiveParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},sG);e.GLTFExtensionMode=void 0,(sW=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[sW.CreateAndParse=0]="CreateAndParse",sW[sW.AdditiveParse=1]="AdditiveParse";var pt=((sK=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],d=e[c];if(o=sK._createAndParse.apply(sK,[].concat(c,t,d,r,a)))return o}},sK.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];for(var s in e){var l=e[s];sK._additiveParse.apply(sK,[].concat(s,t,r,l,n,i))}},sK.hasExtensionParser=function(e){var t;return!!(null==(t=sK._extensionParsers[e])?void 0:t.length)},sK.getExtensionParser=function(e,t){var r=sK._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var a=n-1;a>=0;--a){var i=r[a];if(i._mode===t)return i}},sK._addExtensionParser=function(e,t){sK._extensionParsers[e]||(sK._extensionParsers[e]=[]),sK._extensionParsers[e].push(t)},sK._createAndParse=function(t,r,n,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=sK.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,a,o))},sK._additiveParse=function(t,r,n,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=sK.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,a,i,s))},sK);function pr(e,t){return function(r){var n=new r;n._mode=t,pt._addExtensionParser(e,n)}}function pn(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}pt._extensionParsers={},e.GLTFSchemaParser=(fc(sj=function(){return pt.apply(this,arguments)},pt),sj.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,a=r.bufferRequests,i={type:"arraybuffer"};return hQ(n,i).onProgress(void 0,e._onTaskDetail).then(function(t){return a.push(new f2(n,i)),fK.parseGLB(e,t)}).then(function(t){return(null==t?void 0:t.glTF)?(r.isGLB=!0,e.buffers=t.buffers,t.glTF):(r.isGLB=!1,JSON.parse(dt.decodeText(new Uint8Array(t.originBuffer))))})},sj),e.GLTFSchemaParser=fd([fW(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(fc(sX=function(){return pt.apply(this,arguments)},pt),sX.prototype.parse=function(t,r){var n=t.glTF.animations[r],a=n.name,i=void 0===a?"AnimationClip"+r:a;return Promise.resolve(pt.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new h6(i),n)).then(function(e){return pt.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},sX._parseStandardProperty=function(t,r,n){for(var a=function(r,n){var a=d[r],i=s[a.input],o=s[a.output],c=Promise.all([fK.getAccessorBuffer(t,l,i),fK.getAccessorBuffer(t,l,o)]).then(function(t){var n,i,s=t[0].data,l=t[1].data;if(o.normalized){for(var c=fK.getNormalizedComponentScale(o.componentType),d=new Float32Array(l.length),u=0,_=l.length;u<_;u++)d[u]=l[u]*c;l=d}var f=l.length/s.length;switch(null!=(n=a.interpolation)?n:cx.Linear){case cx.CubicSpine:i=e.InterpolationType.CubicSpine;break;case cx.Step:i=e.InterpolationType.Step;break;case cx.Linear:i=e.InterpolationType.Linear}s[s.length-1],h[r]={type:o.type,interpolation:i,input:s,output:l,outputSize:f}});f.push(c)},i=this,o=t.glTF,s=o.accessors,l=o.bufferViews,c=n.channels,d=n.samplers,u=d.length,h=Array(u),_=t.get(e.GLTFParserType.Entity),f=[],p=0;p<u;p++)a(p);return f.push(t.get(e.GLTFParserType.Scene)),Promise.all(f).then(function(){for(var e=0,n=c.length;e<n;e++){for(var a=c[e],s=a.target,l=_[s.node],d="",u=l;u.parent;)d=""===d?""+u.name:u.name+"/"+d,u=u.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(u)){var f=void 0,p=void 0;switch(s.path){case cy.TRANSLATION:f=db,p="position";break;case cy.ROTATION:f=db,p="rotationQuaternion";break;case cy.SCALE:f=db,p="scale";break;case cy.WEIGHTS:f=uv,p="blendShapeWeights"}var m=i._addCurve(s.path,a,h);if(s.path===cy.WEIGHTS)for(var g=o.nodes[s.node].mesh,v=0,y=o.meshes[g].primitives.length;v<y;v++)r.addCurveBinding(d,f,v,p,m);else r.addCurveBinding(d,f,p,m)}}return r})},sX._addCurve=function(t,r,n){var a=n[r.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case cy.TRANSLATION:case cy.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,d=0,u=0,h=i.length;u<h;u++){var _=new _u;_.time=i[u],c===e.InterpolationType.CubicSpine?(_.inTangent=new cB(o[d++],o[d++],o[d++]),_.value=new cB(o[d++],o[d++],o[d++]),_.outTangent=new cB(o[d++],o[d++],o[d++])):_.value=new cB(o[d++],o[d++],o[d++]),l.addKey(_)}return l;case cy.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new _u;y.time=i[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new cK(o[m++],o[m++],o[m++],o[m++]),y.value=new cU(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new cK(o[m++],o[m++],o[m++],o[m++])):y.value=new cU(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case cy.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,S=0,T=i.length;S<T;S++){var C=new _u;C.time=i[S],x.interpolation===e.InterpolationType.CubicSpine?(C.inTangent=Array.from(o.subarray(b,b+s)),b+=s,C.value=o.slice(b,b+s),b+=s,C.outTangent=Array.from(o.subarray(b,b+s))):C.value=o.slice(b,b+s),b+=s,x.addKey(C)}return x}},sX),e.GLTFAnimationParser=fd([fW(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(fc(sq=function(){return pt.apply(this,arguments)},pt),(sY=sq.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},sY._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,a=r.url,i=n.bufferRequests,o={type:"arraybuffer"},s=dt.resolveAbsoluteUrl(a,t.uri);i.push(new f2(s,o));var l=hQ(s,o).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(l),l},sq),e.GLTFBufferParser=fd([fW(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(fc(sQ=function(){return pt.apply(this,arguments)},pt),sQ.prototype.parse=function(t,r){var n=t.glTFResource,a=t.glTF.nodes[r],i=n.engine,o=a.matrix,s=a.translation,l=a.rotation,c=a.scale,d=a.extensions,u=new um(i,a.name||"_GLTF_ENTITY_"+r);u._markAsTemplate(n);var h=u.transform;if(o){var _=h.localMatrix;_.copyFromArray(o),h.localMatrix=_}else s&&h.setPosition(s[0],s[1],s[2]),l&&h.setRotationQuaternion(l[0],l[1],l[2],l[3]),c&&h.setScale(c[0],c[1],c[2]);var f=a.children;if(f)for(var p=0;p<f.length;p++){var m=f[p],g=t.get(e.GLTFParserType.Entity,m);u.addChild(g)}return pt.executeExtensionsAdditiveAndParse(d,t,u,a),u},sQ),e.GLTFEntityParser=fd([fW(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(fc(sJ=function(){return pt.apply(this,arguments)},pt),sJ.prototype.parse=function(t,r){var n=t.glTF.materials[r],a=t.glTFResource,i=a.engine,o=pt.executeExtensionsCreateAndParse(n.extensions,t,n);return o||((o=new uV(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,o,n)),Promise.resolve(o).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(i)),pt.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r._associationSuperResource(a),r})},sJ._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new uB(t))},sJ._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&df.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},sJ._parseStandardProperty=function(t,r,n){var a=n.pbrMetallicRoughness,i=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,d=n.alphaCutoff,u=n.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(r.baseColor=new cj(cj.linearToGammaSpace(h[0]),cj.linearToGammaSpace(h[1]),cj.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,pt.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===uV&&(r.metallic=null!=f?f:1,r.roughness=null!=p?p:1,m&&(e.GLTFMaterialParser._checkOtherTextureTransform(m,"Roughness metallic"),t.get(e.GLTFParserType.Texture,m.index).then(function(e){r.roughnessMetallicTexture=e})))}if(r.constructor===uV||r.constructor===uO){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new cj(cj.linearToGammaSpace(l[0]),cj.linearToGammaSpace(l[1]),cj.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;e.GLTFMaterialParser._checkOtherTextureTransform(i,"Normal"),t.get(e.GLTFParserType.Texture,g).then(function(e){r.normalTexture=e}),void 0!==v&&(r.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;e.GLTFMaterialParser._checkOtherTextureTransform(o,"Occlusion"),t.get(e.GLTFParserType.Texture,y).then(function(e){r.occlusionTexture=e}),void 0!==x&&(r.occlusionTextureIntensity=x),b===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:b>e.TextureCoordinate.UV1&&df.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(u?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case cT.OPAQUE:r.isTransparent=!1;break;case cT.BLEND:r.isTransparent=!0;break;case cT.MASK:r.alphaCutoff=null!=d?d:.5}},sJ),e.GLTFMaterialParser=fd([fW(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(fc(sZ=function(){return pt.apply(this,arguments)},pt),sZ.prototype.parse=function(t,r){for(var n=function(r,n){var c=a.primitives[r];l[r]=new Promise(function(n){var l=pt.executeExtensionsCreateAndParse(c.extensions,t,c,a);if(l)pn(l,ut)?(l._associationSuperResource(o),n(l)):l.then(function(e){e._associationSuperResource(o),n(e)});else{var d=new ut(s,a.name||r+"");d._associationSuperResource(o);var u=new f4;u.mesh=d,t.contentRestorer.meshes.push(u),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,d,u,a,c,i,t.params.keepMeshData).then(n)}})},a=t.glTF.meshes[r],i=t.glTF,o=t.glTFResource,s=o.engine,l=[],c=0,d=a.primitives.length;c<d;c++)n(c);return Promise.all(l)},sZ._parseMeshFromGLTFPrimitive=function(t,r,n,a,i,o,s){var l,c=function(a){var i=d[u[a]],c=fK.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,c,d,u=fK.getAccessorTypeSize(i.type),h=i.count,_=t.data,f=r.instanceId,v=t.vertexBindingInfos,y=i.normalized,x=fK.getElementFormat(i.componentType,u,y);if(y&&(c=fK.getNormalizedComponentScale(i.componentType)),t.interleaved){var b=i.byteOffset||0,S=t.stride;if(d=b%S,void 0===v[f]){o=new d1(a,d,x,g);var T=t.vertexBuffer;T||(T=new dq(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=T,n.vertexBuffers.push(new f8(T,t.restoreInfo))),r.setVertexBufferBinding(T,S,g),v[f]=g++}else o=new d1(a,d,x,v[f])}else{d=0,o=new d1(a,d,x,g);var C=t.vertexBuffer;C||(C=new dq(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new f8(C,t.restoreInfo))),r.setVertexBufferBinding(C,t.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=r.bounds,E=A.min,M=A.max;if(i.min&&i.max)E.copyFromArray(i.min),M.copyFromArray(i.max);else{var R=e.GLTFMeshParser._tempVector3;E.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),M.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var w=d/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;R.copyFromArray(_,L),cB.min(E,R,E),cB.max(M,R,M)}}y&&(E.scale(c),M.scale(c))}});v.push(c)},d=o.accessors,u=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=r.engine,m=[],g=0,v=[];for(var y in u)c(y);return Promise.all(v).then(function(){if(r.setVertexElements(m),void 0!==_){var c=o.accessors[_],d=fK.getAccessorBuffer(t,o.bufferViews,c).then(function(e){r.setIndices(e.data),r.addSubMesh(0,c.count,f),n.indexBuffer=e.restoreInfo});v.push(d)}else r.addSubMesh(0,l,f);return h&&v.push(e.GLTFMeshParser._createBlendShape(t,r,n,a,i,h)),Promise.all(v).then(function(){return r.uploadData(!s),r})})},sZ._getBlendShapeData=function(e,t,r){return fK.getAccessorBuffer(e,t.bufferViews,r).then(function(e){var t,n=e.data,a=e.interleaved?(null!=(t=r.byteOffset)?t:0)%e.stride:0,i=r.count,o=r.normalized,s=r.componentType;return{vertices:fK.bufferToVector3Array(n,a,i,o,s),restoreInfo:new f7(e.restoreInfo,a,i,o,s)}})},sZ._createBlendShape=function(e,t,r,n,a,i){for(var o=this,s=e.glTF,l=s.accessors,c=n.extras?n.extras.targetNames:null,d=[],u=i.length,h=Array(u),_=0;_<u;_++)(function(t){var r={};h[t]=r;var n=c?c[t]:"blendShape"+t,i=a.targets[t],u=i.NORMAL,_=i.TANGENT,f=void 0!==u,p=void 0!==_;d.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[u]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new d3(n);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),r.blendShape=o,r.restoreInfo=new f6(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))})(_);return Promise.all(d).then(function(){for(var e,n=fE(h);!(e=n()).done;){var a=e.value;t.addBlendShape(a.blendShape),r.blendShapes.push(a.restoreInfo)}})},sZ._tempVector3=new cB,sZ),e.GLTFMeshParser=fd([fW(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(fc(s$=function(){return pt.apply(this,arguments)},pt),(s0=s$.prototype).parse=function(t,r){var n,a=t.glTF,i=a.scene,o=t.glTFResource,s=a.scenes[r],l=s.extensions,c=o.engine,d=s.nodes;if(1===d.length)n=t.get(e.GLTFParserType.Entity,d[0]);else{n=new um(c,"GLTF_ROOT");for(var u=0;u<d.length;u++){var h=t.get(e.GLTFParserType.Entity,d[u]);n.addChild(h)}}(void 0===i?0:i)===r&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<d.length;f++)_.push(this._parseEntityComponent(t,d[f]));return Promise.all(_).then(function(){return pt.executeExtensionsAdditiveAndParse(l,t,n,s),n})},s0._parseEntityComponent=function(t,r){var n,a=this,i=t.glTF,o=t.glTFResource,s=i.nodes[r],l=s.camera,c=s.mesh,d=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,i.cameras[l],d),void 0!==c&&(n=this._createRenderer(t,s,d)),Promise.resolve(n).then(function(){var e=[],r=s.children;if(r)for(var n=0;n<r.length;n++)e.push(a._parseEntityComponent(t,r[n]));return Promise.all(e)})},s0._createCamera=function(t,r,n){var a=r.orthographic,i=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===cb.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,d=a.zfar,u=a.znear;s.isOrthographic=!0,void 0!==u&&(s.nearClipPlane=u),void 0!==d&&(s.farClipPlane=d),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===cb.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},s0._createRenderer=function(t,r,n){for(var a,i=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,d=c.length,u=r.weights||l.weights,h=Array(d),_=0;_<d;_++)h[_]=t.get(e.GLTFParserType.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),Promise.all(h)]).then(function(r){for(var a=r[0],o=r[1],s=r[2],l=0;l<d;l++)!function(r){var l=s[r]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),d=c[r],h=a[r],_=void 0;if(o||u){var f=n.addComponent(uv);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),u&&(f.blendShapeWeights=new Float32Array(u)),_=f}else(_=n.addComponent(d8)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),pt.executeExtensionsAdditiveAndParse(d.extensions,t,_,d)}(l)})},s0._computeLocalBounds=function(e,t,r,n,a){var i=r.indexOf(n);if(-1!==i)cV.transform(t.bounds,a[i],e.localBounds);else{var o=new cG(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,a,n,o);0!==s?(cG.multiplyScalar(o,1/s,o),cV.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},s0._computeApproximateBindMatrix=function(e,t,r,n){for(var a=0,i=r.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(cG.add(n,t[c],n),a++):a+=this._computeApproximateBindMatrix(e,t,l,n)}return a},s$),e.GLTFSceneParser=fd([fW(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(fc(s1=function(){return pt.apply(this,arguments)},pt),(s2=s1.prototype).parse=function(t,r){var n=this,a=t.glTF,i=a.skins[r],o=i.inverseBindMatrices,s=i.skeleton,l=i.joints,c=i.name,d=l.length,u=new ug(void 0===c?"SKIN_"+r:c);u.inverseBindMatrices.length=d;var h=Array(d),_=a.accessors[o];return Promise.resolve(fK.getAccessorBuffer(t,a.bufferViews,_).then(function(r){for(var a=t.get(e.GLTFParserType.Entity),i=r.data,o=0;o<d;o++){var c=new cG;c.copyFromArray(i,16*o),u.inverseBindMatrices[o]=c;var _=a[l[o]];h[o]=_,u.joints[o]=_.name}if(u.bones=h,void 0!==s){var f=a[s];u.rootBone=f}else{var p=n._findSkeletonRootBone(l,a);if(p)u.rootBone=p;else throw"Failed to find skeleton root bone."}return u}))},s2._findSkeletonRootBone=function(e,t){for(var r,n={},a=fE(e);!(r=a()).done;){for(var i=r.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;n[i]=o}for(var l=null,c=0;;c++){var d=n[e[0]];if(c>=d.length)return l;for(var u=d[c],h=1,_=e.length;h<_;h++)if(c>=(d=n[e[h]]).length||u!==d[c])return l;l=u}},s1),e.GLTFSkinParser=fd([fW(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(fc(s3=function(){return pt.apply(this,arguments)},pt),s3.prototype.parse=function(t,r){var n=t.glTF.textures[r],a=t.glTFResource,i=t.glTF,o=a.engine,s=a.url,l=n.sampler,c=n.source,d=n.name,u=n.extensions,h=i.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=pt.executeExtensionsCreateAndParse(u,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&fK.getSamplerInfo(i.samplers[l]);if(_){var x=_.lastIndexOf("."),b=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:dt.resolveAbsoluteUrl(s,_),type:b,params:{mipmap:null==y?void 0:y.mipmap}}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name=d||m||e.name||"texture_"+r,v&&fK.parseSampler(e,y),e}),t._addTaskCompletePromise(g)}else{var S=i.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[S.buffer],a=new Uint8Array(n,S.byteOffset,S.byteLength);return fK.loadImageBuffer(a,p).then(function(e){var n=new d9(o,e.width,e.height,void 0,null==y?void 0:y.mipmap);n.setImageSource(e),n.generateMipmaps(),n.name=d||m||"texture_"+r,v&&fK.parseSampler(n,y);var a=new f3(n,S,p);return t.contentRestorer.bufferTextures.push(a),n})})}}return Promise.resolve(g).then(function(e){return pt.executeExtensionsAdditiveAndParse(u,t,e,n),e._associationSuperResource(a),e})},s3._wrapMap=((s4={})[cE.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,s4[cE.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,s4[cE.REPEAT]=e.TextureWrapMode.Repeat,s4),s3),e.GLTFTextureParser=fd([fW(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(fc(s8=function(){return pt.apply(this,arguments)},pt),s8.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,a=t.extensionsRequired,i=Number(r);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(n){df.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];pt.hasExtensionParser(s)||df.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){df.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];pt.hasExtensionParser(c)||df.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},s8),e.GLTFValidator=fd([fW(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(fc(s5=function(){return pt.apply(this,arguments)},pt),s5.prototype.parse=function(t,r){var n=t.glTF.bufferViews[r],a=n.extensions,i=n.byteOffset,o=void 0===i?0:i,s=n.byteLength,l=n.buffer;return a?pt.executeExtensionsCreateAndParse(a,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},s5),e.GLTFBufferViewParser=fd([fW(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=(fc(s9=function(){return pt.apply(this,arguments)},pt),(s6=s9.prototype).parse=function(t){var r=this;return t.needAnimatorController?t.get(e.GLTFParserType.Animation).then(function(e){return Promise.resolve(r._createAnimatorController(e))}):Promise.resolve(null)},s6._createAnimatorController=function(e){var t=new _o,r=new _s("layer"),n=new _d;if(t.addLayer(r),r.stateMachine=n,e)for(var a=0;a<e.length;a++){var i=e[a],o=i.name,s=n.makeUniqueStateName(o);s!==o&&console.warn("AnimatorState name is existed, name: "+o+" reset to "+s),n.addState(s).clip=i}return t},s9),e.GLTFAnimatorControllerParser=fd([fW(e.GLTFParserType.AnimatorController)],e.GLTFAnimatorControllerParser);var pa=(le=function(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;++r){var n=e.charCodeAt(r);t[r]=n>96?n-97:n>64?n-39:n+4}for(var a=0,i=0;i<e.length;++i)t[a++]=t[i]<60?li[t[i]]:(t[i]-60)*64+t[++i];return t.buffer.slice(0,a)},lt=function(e,t,r,n,a,i){var o=s7.exports.sbrk,s=r+3&-4,l=o(s*n),c=o(a.length),d=new Uint8Array(s7.exports.memory.buffer);d.set(a,c);var u=e(l,r,n,c,a.length);if(0==u&&i&&i(l,s,n),t.set(d.subarray(l,l+r*n)),o(l-o(0)),0!=u)throw Error("Malformed buffer data: "+u)},lr=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var r=e.data;t.pending-=r.count,t.requests[r.id][r.action](r.value),delete t.requests[r.id]},t},ln=function(e){for(var t="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(le(lo))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }',r=new Blob([t],{type:"text/javascript"}),n=URL.createObjectURL(r),a=0;a<e;++a)ld[a]=lr(n);URL.revokeObjectURL(n)},la=function(e,t,r,n,a){for(var i=ld[0],o=1;o<ld.length;++o)ld[o].pending<i.pending&&(i=ld[o]);return new Promise(function(o,s){var l=new Uint8Array(r),c=lu++;i.pending+=e,i.requests[c]={resolve:o,reject:s},i.object.postMessage({id:c,count:e,size:t,source:l,mode:n,filter:a},[l.buffer])})},li=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),lo=u8._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",ls=WebAssembly.instantiate(le(lo),{}).then(function(e){(s7=e.instance).exports.__wasm_call_ctors()}),ll={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},lc={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},ld=[],lu=0,{workerCount:4,ready:ls,useWorkers:function(){ln(this.workerCount)},decodeGltfBuffer:function(e,t,r,n,a){return(this.workerCount>0&&0===ld.length&&this.useWorkers(),ld.length>0)?la(e,t,r,lc[n],ll[a]):ls.then(function(){var i=new Uint8Array(e*t);return lt(s7.exports[lc[n]],i,e,t,r,s7.exports[ll[a]]),i})},release:function(){for(var e=0;e<ld.length;e++)ld[e].object.terminate()}});e.GLTFLoader=(fc(lh=function(){return hZ.apply(this,arguments)},hZ),(l_=lh.prototype).initialize=function(e,t){var r,n=null==(r=t.glTF)?void 0:r.meshOpt;return n&&(pa.workerCount=n.workerCount,pa.useWorkers()),Promise.resolve()},l_.load=function(e,t){var r=e.url,n=e.params,a=new fk(t.engine,r),i=new fz(a,t,fs({keepMeshData:!1},n));return new uQ(function(e,t,r,n){i._setTaskCompleteProgress=r,i._setTaskDetailProgress=n,i.parse().then(e).catch(t)})},lh.release=function(){pa.release()},lh),e.GLTFLoader=fd([uZ(e.AssetType.GLTF,["gltf","glb"])],e.GLTFLoader);var pi=Math.PI,po=(fc(lf=function(){return hZ.apply(this,arguments)},hZ),lf.prototype.load=function(t,r){var n=this;return new uQ(function(a,i){var o=r.engine;n.request(t.url,{type:"arraybuffer"}).then(function(t){for(var r=new Uint8Array(t),n=po._parseHeader(r),i=n.width,s=n.height,l=n.dataPosition,c=po._readPixels(r.subarray(l),i,s),d=s>>1,u=po._convertToCubemap(c,i,s,d),h=new d7(o,d),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,u[_],0);h.generateMipmaps(),a(h)}).catch(i)})},lf._convertToCubemap=function(e,t,r,n){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*r*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(n,this._faceRight,e,t,r),this._createCubemapData(n,this._faceLeft,e,t,r),this._createCubemapData(n,this._faceUp,e,t,r),this._createCubemapData(n,this._faceBottom,e,t,r),this._createCubemapData(n,this._faceFront,e,t,r),this._createCubemapData(n,this._faceBack,e,t,r)]},lf._createCubemapData=function(e,t,r,n,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,d=0;d<e;d++){for(var u=this._temp3Vector3.set(0,0,0).add(t[0]),h=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(h).subtract(u).scale(c).add(u);f.normalize();var p=this._calcProjectionSpherical(f,r,n,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=d*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,u.add(o),h.add(s)}c+=l}return i},lf._calcProjectionSpherical=function(e,t,r,n){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-pi;)a+=2*pi;for(;a>pi;)a-=2*pi;var o=a/pi,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(i/pi*n);l<0?l=0:l>=n&&(l=n-1);var c=(n-l-1)*r*4+4*s,d=t[c],u=t[c+1],h=t[c+2],_=t[c+3];return new cj(d,u,h,_)},lf._readStringLine=function(e,t){for(var r="",n="",a=t;a<e.length-t&&"\n"!=(n=String.fromCharCode(e[a]));a++)r+=n;return r},lf._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?i=!0:0==n.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=n.length+1,n=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(n);if(!s||s.length<3)throw"HDR Bad header format, no size";if(r=parseInt(s[2]),t=parseInt(s[1]),r<8||r>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:r,dataPosition:o+=n.length+1}},lf._readPixels=function(e,t,r){for(var n=e.byteLength,a=new Uint8Array(4*t*r),i=0,o=0,s=4*t,l=new Uint8Array(s),c=r;c>0&&o<n;){var d=e[o++],u=e[o++],h=e[o++],_=e[o++];if(2!=d||2!=u||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<n;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},lf._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},lf._linearToRGBM=function(e,t){var r=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),n=65025/((r=Math.ceil(255*r))*t);e.r*=n,e.g*=n,e.b*=n,e.a*=r},lf._rightBottomBack=new cB(1,-1,-1),lf._rightBottomFront=new cB(1,-1,1),lf._rightUpBack=new cB(1,1,-1),lf._rightUpFront=new cB(1,1,1),lf._leftBottomBack=new cB(-1,-1,-1),lf._leftBottomFront=new cB(-1,-1,1),lf._leftUpBack=new cB(-1,1,-1),lf._leftUpFront=new cB(-1,1,1),lf._faceRight=[lf._rightBottomBack,lf._rightBottomFront,lf._rightUpBack,lf._rightUpFront],lf._faceLeft=[lf._leftBottomFront,lf._leftBottomBack,lf._leftUpFront,lf._leftUpBack],lf._faceUp=[lf._leftBottomFront,lf._rightBottomFront,lf._leftBottomBack,lf._rightBottomBack],lf._faceBottom=[lf._leftUpBack,lf._rightUpBack,lf._leftUpFront,lf._rightUpFront],lf._faceFront=[lf._leftBottomBack,lf._rightBottomBack,lf._leftUpBack,lf._rightUpBack],lf._faceBack=[lf._rightBottomFront,lf._leftBottomFront,lf._rightUpFront,lf._leftUpFront],lf._tempVector3=new cB,lf._temp2Vector3=new cB,lf._temp3Vector3=new cB,lf._temp4Vector3=new cB,lf._temp5Vector3=new cB,lf);po=fd([uZ(e.AssetType.HDR,["hdr"])],po);var ps=(fc(lp=function(){return hZ.apply(this,arguments)},hZ),lp.prototype.load=function(e){return this.request(e.url,fs({},e,{type:"json"}))},lp);ps=fd([uZ(e.AssetType.JSON,["json"],!1)],ps);var pl={parse:function(t,r,n,a){if(void 0===a&&(a=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(t))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var i=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*i),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*i,s),glTypeSize:o.getUint32(2*i,s),glFormat:o.getUint32(3*i,s),glInternalFormat:o.getUint32(4*i,s),glBaseInternalFormat:o.getUint32(5*i,s),pixelWidth:o.getUint32(6*i,s),pixelHeight:o.getUint32(7*i,s),pixelDepth:o.getUint32(8*i,s),numberOfArrayElements:o.getUint32(9*i,s),numberOfFaces:o.getUint32(10*i,s),numberOfMipmapLevels:o.getUint32(11*i,s),bytesOfKeyValueData:o.getUint32(12*i,s),loadType:0};if(0!==l.glType)throw Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),0===l.pixelHeight||0!==l.pixelDepth)throw Error("only 2D textures currently supported");if(0!==l.numberOfArrayElements)throw Error("texture arrays not currently supported");if(l.numberOfFaces!==r)throw Error("number of faces expected"+r+", but found "+l.numberOfFaces);return n&&(l.mipmaps=function(e,t){for(var r=[],n=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,n,1)[0];n+=4;for(var c=0;c<e.numberOfFaces;c++){var d=new Uint8Array(e.buffer,n,l);r.push({data:d,width:a,height:i}),n+=l+(3-(l+3)%4)}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return r}(l,!0)),a&&(l.engineFormat=function(t){switch(t){case e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:return e.TextureFormat.BC1;case e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:return e.TextureFormat.BC3;case e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT:return e.TextureFormat.BC7;case e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL:return e.TextureFormat.ETC1_RGB;case e.GLCompressedTextureInternalFormat.RGB8_ETC2:return e.TextureFormat.ETC2_RGB;case e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return e.TextureFormat.ETC2_RGBA5;case e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC:return e.TextureFormat.ETC2_RGBA8;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGB2;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA2;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGB4;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR:return e.TextureFormat.ASTC_4x4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR:return e.TextureFormat.ASTC_5x5;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR:return e.TextureFormat.ASTC_6x6;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR:return e.TextureFormat.ASTC_8x8;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR:return e.TextureFormat.ASTC_10x10;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR:return e.TextureFormat.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+e.GLCompressedTextureInternalFormat[t])}}(l.glInternalFormat)),l}};function pc(e){var t=pl.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var pd=(fc(lm=function(){return hZ.apply(this,arguments)},hZ),lm.prototype.load=function(t,r){var n=this;return new uQ(function(a,i){Promise.all(t.urls.map(function(e){return n.request(e,fs({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,a,i=[],o=0;o<e.length;o++){var s=pl.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(n=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:i,engineFormat:r,internalFormat:t,width:n,height:a}}(t),i=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new d7(r.engine,i,s,l),d=0;d<6;d++)for(var u=o[d].length,h=0;h<u;h++){var _=o[d][h],f=_.data,p=_.width,m=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+d,f,h,0,0,p,m)}a(c)}).catch(function(e){i(e)})})},lm);pd=fd([uZ(e.AssetType.KTXCube,[])],pd);var pu=(fc(lg=function(){return hZ.apply(this,arguments)},hZ),lg.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,fs({},e,{type:"arraybuffer"})).then(function(e){for(var r=pc(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new d9(t.engine,a,i,s,l),d=0;d<o.length;d++){var u=o[d],h=u.width,_=u.height,f=u.data;c.setPixelBuffer(f,d,0,0,h,_)}n(c)}).catch(function(e){a(e)})})},lg);pu=fd([uZ(e.AssetType.KTX,["ktx"])],pu);var ph=(fc(lv=function(){return hZ.apply(this,arguments)},hZ),lv.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,fs({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,a=r.value;switch(n){case"Vector2":h.setVector2(e,new cW(a.x,a.y));break;case"Vector3":h.setVector3(e,new cB(a.x,a.y,a.z));break;case"Vector4":h.setVector4(e,new cK(a.x,a.y,a.z,a.w));break;case"Color":h.setColor(e,new cj(a.r,a.g,a.b,a.a));break;case"Float":h.setFloat(e,a);break;case"Texture":u.push(t.getResourceByRef(a).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,a?1:0);break;case"Integer":h.setInt(e,Number(a))}},a=t.engine,i=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,d=new uL(a,dz.find(o));d.name=i;var u=[],h=d.shaderData;for(var _ in s)r(_);for(var f=0,p=l.length;f<p;f++){var m=l[f],g=m.name,v=m.value;void 0==v?h.enableMacro(g):h.enableMacro(g,v)}return function e(t,r,n){if("object"==typeof n)for(var a in n)e(t[r],a,n[a]);else t[r]=n}(d,"renderState",c),Promise.all(u).then(function(){n(d)})}).catch(a)})},lv);ph=fd([uZ(e.AssetType.Material,["json"])],ph);var p_=(fc(ly=function(){return hZ.apply(this,arguments)},hZ),ly.prototype.load=function(e,t){var r=this;return new uQ(function(n,a){r.request(e.url,fs({},e,{type:"arraybuffer"})).then(function(e){return fF(e,t.engine)}).then(function(e){n(e)}).catch(a)})},ly);p_=fd([uZ(e.AssetType.Mesh,["mesh"])],p_);var pf=(fc(lx=function(){return hZ.apply(this,arguments)},hZ),lx.prototype.load=function(e,t){var r=t.engine;return this.request(e.url,fs({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return uf.createSubdivisionSurfaceSphere(r,e.sphereRadius,e.sphereStep);case"capsule":return uf.createCapsule(r,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return uf.createCone(r,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return uf.createCuboid(r,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return uf.createCylinder(r,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return uf.createPlane(r,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return uf.createTorus(r,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},lx);pf=fd([uZ(e.AssetType.PrimitiveMesh,["mesh"],!1)],pf),(lb=cL||(cL={})).Sphere="sphere",lb.Cuboid="cuboid",lb.Plane="plane",lb.Cylinder="cylinder",lb.Torus="torus",lb.Cone="cone",lb.Capsule="capsule";var pp=(fc(lS=function(){return hZ.apply(this,arguments)},hZ),lS.prototype.load=function(t,r){var n=this,a=r.engine;return new uQ(function(i,o){n.request(t.url,{type:"json"}).then(function(t){return a.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){a.sceneManager.activeScene=e,i()})}).catch(o)})},lS);pp=fd([uZ(e.AssetType.Project,["proj"],!1)],pp);var pm=(fc(lT=function(){return hZ.apply(this,arguments)},hZ),(lC=lT.prototype).load=function(e,t){var r=this;return new uQ(function(n,a){var i=e.url;r._registerFont(i,i).then(function(){n(new uR(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},lC._registerFont=function(e,t){return fO(function(){var r;return fu(this,function(n){switch(n.label){case 0:return[4,(r=new FontFace(e,"url("+t+")")).load()];case 1:return n.sent(),document.fonts.add(r),[2]}})})()},lT);pm=fd([uZ(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],pm);var pg=(fc(lA=function(){var e;return e=hZ.apply(this,arguments)||this,e._tempRect=new cX,e._tempVec2=new cW,e._tempVec4=new cK,e},hZ),(lE=lA.prototype).load=function(t,r){var n=this;return new uQ(function(a,i,o,s,l){var c=[];l(function(){for(var e=0;e<c.length;e++)c[e].cancel()});var d=n.request(t.url,fs({},t,{type:"json"}));c.push(d),d.then(function(o){var s=o.atlasItems,l=o.mipmap,d=o.anisoLevel,u=o.filterMode,h=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,m=r.engine,g=new de(m);if(p<0){a(g);return}c.length=0;for(var v=0;v<s.length;v++)!function(a){var o,p=s[a];if(p.img)c.push(r.load({url:dt.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:l}}).then(function(e){d&&(e.anisoLevel=d),void 0!==u&&(e.filterMode=u),void 0!==h&&(e.wrapModeU=h),void 0!==_&&(e.wrapModeV=_);for(var t=0;t<p.sprites.length;t++)g._addSprite(n._makeSprite(m,p.sprites[t],e))}).catch(i));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);uQ.all(c).then(function(){a(g)}).catch(i)}).catch(i)})},lE._makeSprite=function(e,t,r){var n=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,d=new ds(e,r,n?this._tempRect.set(n.x,n.y,n.w,n.h):void 0,o?this._tempVec2.set(o.x,o.y):void 0,s?this._tempVec4.set(s.x,s.y,s.z,s.w):void 0,t.name);if(r){var u=1/r.width,h=1/r.height;if(d.atlasRegion.set(i.x*u,i.y*h,i.w*u,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.w;d.atlasRegionOffset.set(_*u,f*h,p*u,m*h)}t.atlasRotated&&(d.atlasRotated=!0)}return isNaN(l)||(d.width=l),isNaN(c)||(d.height=c),d},lA);pg=fd([uZ(e.AssetType.SpriteAtlas,["atlas"],!1)],pg);var pv=(fc(lM=function(){return hZ.apply(this,arguments)},hZ),(lR=lM.prototype).load=function(e,t){var r=this;return this.request(e.url,fs({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},lR._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},lR._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new ds(e.engine,r,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),n}):new uQ(function(r){var n=new ds(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),r(n)})},lM);pv=fd([uZ(e.AssetType.Sprite,["sprite"],!1)],pv);var py=(fc(lw=function(e,t,r){var n;return(n=un.call(this,e)||this).url=t,n.requestConfig=r,n},un),lw.prototype.restoreContent=function(){var e=this;return hQ(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},lw),px=(fc(lP=function(){return hZ.apply(this,arguments)},hZ),lP.prototype.load=function(e,t){var r=this;return new uQ(function(n,a,i,o){var s=e.url,l=fs({},e,{type:"image"});r.request(s,l).onProgress(i,o).then(function(r){var a,i=null!=(a=e.params)?a:{},o=i.format,c=i.mipmap,d=i.anisoLevel,u=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new d9(t.engine,r.width,r.height,o,c);if(f.anisoLevel=null!=d?d:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=u?u:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==s.indexOf("data:")){var p=s.lastIndexOf("/");f.name=s.substring(p+1)}t.addContentRestorer(new py(f,s,l)),n(f)}).catch(function(e){a(e)})})},lP);px=fd([uZ(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],px);var pb=(fc(lF=function(e,t,r){var n;return(n=un.call(this,e)||this).urls=t,n.requestConfig=r,n},un),lF.prototype.restoreContent=function(){var t=this;return new uQ(function(r,n){Promise.all(t.urls.map(function(e){return hQ(e,t.requestConfig)})).then(function(n){for(var a=t.resource,i=0;i<6;i++)a.setImageSource(e.TextureCubeFace.PositiveX+i,n[i],0);a.generateMipmaps(),r(a)}).catch(function(e){n(e)})})},lF),pS=(fc(lL=function(){return hZ.apply(this,arguments)},hZ),lL.prototype.load=function(t,r){var n=this;return new uQ(function(a,i){var o=t.urls,s=fs({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],i=n.width;if(i!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new d7(r.engine,i),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new pb(l,o,s)),a(l)}).catch(function(e){i(e)})})},lL);pS=fd([uZ(e.AssetType.TextureCube,[""])],pS);var pT=(fc(lD=function(){return hZ.apply(this,arguments)},hZ),lD.prototype.load=function(t,r){var n=this,a=r.engine;return new uQ(function(i,o){n.request(t.url,{type:"json"}).then(function(t){return fP.parse(a,t).then(function(n){var a,o,s=[],l=t.scene.ambient;if(l){var c=l.specularMode===e.SpecularMode.Custom,d=l.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=l.diffuseIntensity,n.ambientLight.specularIntensity=l.specularIntensity,n.ambientLight.diffuseMode=l.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(l.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,c&&l.customAmbientLight&&s.push(r.getResourceByRef(l.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),l.ambientLight&&(!c||d)&&s.push(r.getResourceByRef(l.ambientLight).then(function(e){c||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),d&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=t.scene.background;switch(n.background.mode=u.mode,n.background.mode){case e.BackgroundMode.SolidColor:n.background.solidColor.copyFrom(u.color);break;case e.BackgroundMode.Sky:if(u.skyMesh&&u.skyMaterial){var h=r.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),_=r.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});s.push(h,_)}else df.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var f=r.getResourceByRef(u.texture).then(function(e){n.background.texture=e});s.push(f)}}var p=t.scene.shadow;p&&(void 0!=p.castShadows&&(n.castShadows=p.castShadows),void 0!=p.shadowResolution&&(n.shadowResolution=p.shadowResolution),void 0!=p.shadowDistance&&(n.shadowDistance=p.shadowDistance),void 0!=p.shadowCascades&&(n.shadowCascades=p.shadowCascades),n.shadowTwoCascadeSplits=null!=(a=p.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(o=p.shadowFadeBorder)?o:n.shadowFadeBorder);var m=t.scene.fog;return m&&(void 0!=m.fogMode&&(n.fogMode=m.fogMode),void 0!=m.fogStart&&(n.fogStart=m.fogStart),void 0!=m.fogEnd&&(n.fogEnd=m.fogEnd),void 0!=m.fogDensity&&(n.fogDensity=m.fogDensity),void 0!=m.fogColor&&n.fogColor.copyFrom(m.fogColor)),Promise.all(s).then(function(){i(n)})})}).catch(o)})},lD);pT=fd([uZ(e.AssetType.Scene,["scene"],!0)],pT),fS.registerCustomParseComponent("TextRenderer",fO(function(e,t){var r;return fu(this,function(n){return(r=t.props).font||(e.font=uR.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var pC=(fc(lB=function(){return pe.apply(this,arguments)},pe),lB.prototype.additiveParse=function(e,t,r){var n,a=e.glTF.extensions.KHR_lights_punctual.lights[r.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,d=e.glTFResource;if("directional"===s?n=t.addComponent(hw):"point"===s?n=t.addComponent(hP):"spot"===s&&(n=t.addComponent(hF)),i&&n.color.set(i[0],i[1],i[2],1),n.intensity=void 0===o?1:o,l&&!pn(n,hw)&&(n.distance=l),c&&pn(n,hF)){var u=c.innerConeAngle,h=void 0===u?0:u,_=c.outerConeAngle;n.angle=h,n.penumbra=(void 0===_?Math.PI/4:_)-h}d.lights||(d.lights=[]),d.lights.push(n)},lB);pC=fd([pr("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],pC);var pA=(fc(lI=function(){return pe.apply(this,arguments)},pe),lI.prototype.additiveParse=function(t,r,n){var a=n.clearcoatFactor,i=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===a?0:a,r.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(e.GLTFParserType.Texture,i.index).then(function(e){r.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(e.GLTFParserType.Texture,l.index).then(function(e){r.clearCoatNormalTexture=e}))},lI);pA=fd([pr("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],pA);var pE=(fc(lV=function(){return pe.apply(this,arguments)},pe),lV.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},lV);pE=fd([pr("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],pE);var pM=(fc(lO=function(){return pe.apply(this,arguments)},pe),lO.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new uO(a),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,d=r.specularGlossinessTexture;return o&&(i.baseColor=new cj(cj.linearToGammaSpace(o[0]),cj.linearToGammaSpace(o[1]),cj.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,pt.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new cj(cj.linearToGammaSpace(l[0]),cj.linearToGammaSpace(l[1]),cj.linearToGammaSpace(l[2]))),void 0!==c&&(i.glossiness=c),d&&(e.GLTFMaterialParser._checkOtherTextureTransform(d,"Specular glossiness"),t.get(e.GLTFParserType.Texture,d.index).then(function(e){i.specularGlossinessTexture=e})),i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lO);pM=fd([pr("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],pM);var pR=(fc(lN=function(){return pe.apply(this,arguments)},pe),lN.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new uN(a);return i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lN);pR=fd([pr("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],pR);var pw=(fc(lk=function(){return pe.apply(this,arguments)},pe),lk.prototype.additiveParse=function(t,r,n){var a=t.glTF.extensions.KHR_materials_variants.variants,i=t.glTFResource,o=n.mappings;i._extensionsData||(i._extensionsData={});var s=[];i.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var i=o[n],l=i.material,c=i.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return a[e].name})})})}(l)},lk);pw=fd([pr("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],pw);var pP=(fc(lz=function(){return pe.apply(this,arguments)},pe),lz);pP=fd([pr("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],pP);var pF=(fc(lU=function(){return pe.apply(this,arguments)},pe),lU.prototype.createAndParse=function(t,r,n){return fO(function(){var a,i,o,s,l,c,d,u,h,_,f,p,m,g,v,y;return fu(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=n.sampler,c=n.name,d=r.source,h=(u=a.images[d]).uri,_=u.bufferView,f=u.mimeType,p=u.name,m=void 0!==l&&fK.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:dt.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&fK.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,y.buffer).then(function(r){var n=new Uint8Array(r,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&fK.parseSampler(e,m);var r=new f3(e,y,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},lU);pF=fd([pr("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],pF);var pL=(fc(lG=function(){return pe.apply(this,arguments)},pe),lG.prototype.additiveParse=function(e,t,r){var n=r.offset,a=r.rotation,i=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&df.warn("rotation in KHR_texture_transform is not supported now"),o&&df.warn("texCoord in KHR_texture_transform is not supported now")},lG);pL=fd([pr("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],pL);var pD=(fc(lH=function(){return pe.apply(this,arguments)},pe),lH.prototype.createAndParse=function(e,t){var r=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(r),r},lH);pD=fd([pr("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],pD);var pB=(fc(lW=function(){return pe.apply(this,arguments)},pe),lW.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new h9;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},lW);pB=fd([pr("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],pB);var pI=(fc(lK=function(){return pe.apply(this,arguments)},pe),lK.prototype.createAndParse=function(t,r){return t.get(e.GLTFParserType.Buffer,r.buffer).then(function(e){return pa.decodeGltfBuffer(r.count,r.byteStride,new Uint8Array(e,r.byteOffset,r.byteLength),r.mode,r.filter)})},lK);pI=fd([pr("EXT_meshopt_compression",e.GLTFExtensionMode.CreateAndParse)],pI);var pV=(fc(lj=function(){return pe.apply(this,arguments)},pe),lj.prototype.additiveParse=function(t,r,n){var a=n.anisotropyStrength,i=n.anisotropyRotation,o=n.anisotropyTexture;r.anisotropy=void 0===a?0:a,r.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(e.GLTFParserType.Texture,o.index).then(function(e){r.anisotropyTexture=e}))},lj);pV=fd([pr("KHR_materials_anisotropy",e.GLTFExtensionMode.AdditiveParse)],pV);var pO="1.2.0-beta.6";for(var pN in console.log("Galacean engine version: "+pO),_J)hZ.registerClass(pN,_J[pN]);e.AmbientLight=hM,e.AnimationClip=h6,e.AnimationClipCurveBinding=h5,e.AnimationCurve=h7,e.AnimationEvent=h9,e.Animator=_i,e.AnimatorController=_o,e.AnimatorControllerLayer=_s,e.AnimatorLayerMask=__,e.AnimatorState=_c,e.AnimatorStateMachine=_d,e.AnimatorStateTransition=_t,e.AssetPromise=uQ,e.Background=hA,e.BaseMaterial=uD,e.Basic2DBatcher=ux,e.BasicRenderPipeline=hj,e.BlendShape=d3,e.BlendShapeFrame=d2,e.BlendState=dI,e.BlinnPhongMaterial=uB,e.BoolUpdateFlag=dx,e.BoundingBox=cV,e.BoundingFrustum=ck,e.BoundingSphere=cI,e.BoxColliderShape=hd,e.BoxShape=_N,e.Buffer=dq,e.BufferInfo=fU,e.BufferMesh=d4,e.BufferUtil=dY,e.Burst=_I,e.Canvas=hT,e.CapsuleColliderShape=h_,e.CharacterController=u6,e.CircleShape=_k,e.CloneManager=c9,e.ColliderShape=hc,e.CollisionUtil=cO,e.Color=cj,e.ColorOverLifetimeModule=_T,e.Component=dg,e.ConeShape=_z,e.ContentRestorer=un,e.CubeProbe=_Q,e.CurveKey=_w,e.DepthState=dV,e.DirectLight=hw,e.DynamicCollider=u7,e.EmissionModule=_A,e.Engine=hS,e.EngineObject=c6,e.Entity=um,e.EventDispatcher=dl,e.FixedJoint=ha,e.Font=uR,e.GLTFExtensionParser=pe,e.GLTFParser=pt,e.GLTFParserContext=fz,e.GLTFResource=fk,e.GLTFUtils=fK,e.GradientAlphaKey=_x,e.GradientColorKey=_y,e.HemisphereShape=_U,e.HingeJoint=hi,e.HitResult=he,e.IndexBufferBinding=dQ,e.InputManager=hm,e.JointLimits=hs,e.JointMotor=hl,e.Keyframe=_u,e.Light=hR,e.Loader=hZ,e.Logger=df,e.MainModule=_E,e.Material=uL,e.MathUtil=cD,e.Matrix=cG,e.Matrix3x3=cz,e.Mesh=d$,e.MeshRenderer=d8,e.ModelMesh=ut,e.PBRBaseMaterial=uI,e.PBRMaterial=uV,e.PBRSpecularMaterial=uO,e.ParserContext=fT,e.ParticleCompositeCurve=_C,e.ParticleCompositeGradient=_b,e.ParticleCurve=_R,e.ParticleGenerator=_D,e.ParticleGradient=_v,e.ParticleMaterial=_B,e.ParticleRenderer=_g,e.PhysicsMaterial=ht,e.PhysicsScene=u9,e.Plane=cN,e.PlaneColliderShape=hh,e.PointLight=hP,e.Pointer=u2,e.PrefabParser=fR,e.Primitive=dZ,e.PrimitiveMesh=uf,e.Probe=_j,e.Quaternion=cU,e.Rand=cY,e.RasterState=dO,e.Ray=cH,e.Rect=cX,e.ReferResource=c7,e.ReflectionParser=fS,e.RenderQueue=hN,e.RenderState=dk,e.RenderTarget=d5,e.RenderTargetBlendState=dB,e.ResourceManager=uJ,e.RotationOverLifetimeModule=_M,e.Scene=hD,e.SceneManager=uY,e.SceneParser=fP,e.Script=hB,e.Shader=dz,e.ShaderData=dH,e.ShaderFactory=dE,e.ShaderLib=dA,e.ShaderMacro=dS,e.ShaderMacroCollection=dT,e.ShaderPass=dL,e.ShaderProperty=dp,e.ShaderTagKey=dM,e.SizeOverLifetimeModule=_P,e.Skin=ug,e.SkinnedMeshRenderer=uv,e.Sky=hC,e.SkyBoxMaterial=_f,e.SkyProceduralMaterial=_p,e.SphereColliderShape=hu,e.SphereShape=_G,e.SphericalHarmonics3=cq,e.SpotLight=hF,e.SpringJoint=ho,e.Sprite=ds,e.SpriteAtlas=de,e.SpriteMask=uC,e.SpriteRenderer=uT,e.StateMachineScript=_l,e.StaticCollider=hr,e.StencilState=dN,e.SubMesh=dJ,e.SubShader=dD,e.SystemInfo=u8,e.TextRenderer=uF,e.TextUtils=uE,e.Texture=dG,e.Texture2D=d9,e.Texture2DArray=d6,e.TextureCube=d7,e.TextureSheetAnimationModule=_F,e.Time=dm,e.TrailMaterial=_H,e.TrailRenderer=_K,e.Transform=db,e.UnlitMaterial=uN,e.Utils=dt,e.Vector2=cW,e.Vector3=cB,e.Vector4=cK,e.VelocityOverLifetimeModule=_L,e.VertexBufferBinding=d0,e.VertexElement=d1,e.WebCanvas=_3,e.WebGLEngine=_4,e.WebGLGraphicDevice=fo,e.XRManager=hb,e.assignmentClone=c4,e.decode=fF,e.deepClone=c5,e.dependentComponents=dy,e.ignoreClone=c3,e.parseSingleKTX=pc,e.registerGLTFExtension=pr,e.registerGLTFParser=fW,e.request=hQ,e.resourceLoader=uZ,e.shallowClone=c8,e.version=pO,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}e.ContainmentType=void 0,(lI=e.ContainmentType||(e.ContainmentType={}))[lI.Disjoint=0]="Disjoint",lI[lI.Contains=1]="Contains",lI[lI.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(lV=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[lV.Back=0]="Back",lV[lV.Front=1]="Front",lV[lV.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(lO=e.FrustumFace||(e.FrustumFace={}))[lO.Near=0]="Near",lO[lO.Far=1]="Far",lO[lO.Left=2]="Left",lO[lO.Right=3]="Right",lO[lO.Bottom=4]="Bottom",lO[lO.Top=5]="Top";var a,i,o,s,l,c,d,u,h,_,f,p,m,g,v,y,x,b,S,C,T,A,M,E,R,w,P,F,L,D,B,I,V,O,N,k,z,U,G,H,W,K,j,X,q,Y,Q,J,Z,$,ee,et,er,en,ea,ei,eo,es,el,ec,ed,eu,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eS,eC,eT,eA,eM,eE,eR,ew,eP,eF,eL,eD,eB,eI,eV,eO,eN,ek,ez,eU,eG,eH,eW,eK,ej,eX,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tr,tn,ta,ti,to,ts,tl,tc,td,tu,th,t_,tf,tp,tm,tg,tv,ty,tx,tb,tS,tC,tT,tA,tM,tE,tR,tw,tP,tF,tL,tD,tB,tI,tV,tO,tN,tk,tz,tU,tG,tH,tW,tK,tj,tX,tq,tY,tQ,tJ,tZ,t$,t0,t1,t2,t3,t4,t8,t5,t9,t6,t7,re,rt,rr,rn,ra,ri,ro,rs,rl,rc,rd,ru,rh,r_,rf,rp,rm,rg,rv,ry,rx,rb,rS,rC,rT,rA,rM,rE,rR,rw,rP,rF,rL,rD,rB,rI,rV,rO,rN,rk,rz,rU,rG,rH,rW,rK,rj,rX,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r8,r5,r9,r6,r7,ne,nt,nr,nn,na,ni,no,ns,nl,nc,nd,nu,nh,n_,nf,np,nm,ng,nv,ny,nx,nb,nS,nC,nT,nA,nM,nE,nR,nw,nP,nF,nL,nD,nB,nI,nV,nO,nN,nk,nz,nU,nG,nH,nW,nK,nj,nX,nq,nY,nQ,nJ,nZ,n$,n0,n1,n2,n3,n4,n8,n5,n9,n6,n7,ae,at,ar,an,aa,ai,ao,as,al,ac,ad,au,ah,a_,af,ap,am,ag,av,ay,ax,ab,aS,aC,aT,aA,aM,aE,aR,aw,aP,aF,aL,aD,aB,aI,aV,aO,aN,ak,az,aU,aG,aH,aW,aK,aj,aX,aq,aY,aQ,aJ,aZ,a$,a0,a1,a2,a3,a4,a8,a5,a9,a6,a7,ie,it,ir,ia,ii,io,is,il,ic,id,iu,ih,i_,ip,im,ig,iv,iy,ix,ib,iS,iC,iT,iA,iM,iE,iR,iw,iP,iF,iL,iD,iB,iI,iV,iO,iN,ik,iz,iU,iG,iH,iW,iK,ij,iX,iq,iY,iQ,iJ,iZ,i$,i0,i1,i2,i3,i4,i8,i5,i9,i6,i7,oe,ot,or,on,oa,oi,oo,os,ol,oc,od,ou,oh,o_,of,op,om,og,ov,oy,ox,ob,oS,oC,oT,oA,oM,oE,oR,ow,oP,oF,oL,oD,oB,oI,oV,oO,oN,ok,oz,oU,oG,oH,oW,oK,oj,oX,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o8,o5,o9,o6,o7,se,st,sr,sn,sa,si,so,ss,sl,sc,sd,su,sh,s_,sf,sp,sm,sg,sv,sy,sx,sb,sS,sC,sT,sA,sM,sE,sR,sw,sP,sF,sL,sD,sB,sI,sV,sO,sN,sk,sz,sU,sG,sH,sW,sK,sj,sX,sq,sY,sQ,sJ,sZ,s$,s0,s1,s2,s3,s4,s8,s5,s9,s6,s7,le,lt,lr,ln,la,li,lo,ls,ll,lc,ld,lu,lh,l_,lf,lp,lm,lg,lv,ly,lx,lb,lS,lC,lT,lA,lM,lE,lR,lw,lP,lF,lL,lD,lB,lI,lV,lO,lN,lk,lz,lU,lG,lH,lW,lK,lj,lX,lq,lY,lQ,lJ,lZ,l$,l0,l1,l2,l3,l4,l8,l5,l9,l6,l7,ce,ct,cr,cn,ca,ci,co,cs,cl,cc,cd,cu,ch,c_,cf,cp,cm,cg,cv,cy,cx,cb,cS=((lN=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},lN.equals=function(e,t){return Math.abs(e-t)<=lN.zeroTolerance},lN.isPowerOf2=function(e){return(e&e-1)==0},lN.radianToDegree=function(e){return e*lN.radToDegreeFactor},lN.degreeToRadian=function(e){return e*lN.degreeToRadFactor},lN);cS.zeroTolerance=1e-6,cS.radToDegreeFactor=180/Math.PI,cS.degreeToRadFactor=Math.PI/180;var cC=((i=(a=function(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r}).prototype).set=function(e,t,r){return this._x=e,this._y=t,this._z=r,this._onValueChanged&&this._onValueChanged(),this},i.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},i.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},i.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},i.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},i.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},i.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},i.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},i.normalize=function(){return a.normalize(this,this),this},i.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},i.transformNormal=function(e){return a.transformNormal(this,e,this),this},i.transformToVec3=function(e){return a.transformToVec3(this,e,this),this},i.transformCoordinate=function(e){return a.transformCoordinate(this,e,this),this},i.transformByQuat=function(e){return a.transformByQuat(this,e,this),this},i.clone=function(){return new a(this._x,this._y,this._z)},i.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},i.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},i.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},i.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},a.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._onValueChanged&&r._onValueChanged()},a.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._onValueChanged&&r._onValueChanged()},a.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._onValueChanged&&r._onValueChanged()},a.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._onValueChanged&&r._onValueChanged()},a.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},a.cross=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;r.set(a*l-i*s,i*o-n*l,n*s-a*o)},a.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return Math.sqrt(r*r+n*n+a*a)},a.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return r*r+n*n+a*a},a.equals=function(e,t){return cS.equals(e._x,t._x)&&cS.equals(e._y,t._y)&&cS.equals(e._z,t._z)},a.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},a.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},a.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=Math.sqrt(r*r+n*n+a*a);i>cS.zeroTolerance&&(i=1/i,t.set(r*i,n*i,a*i))},a.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},a.transformNormal=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8],r._y=n*o[1]+a*o[5]+i*o[9],r._z=n*o[2]+a*o[6]+i*o[10],r._onValueChanged&&r._onValueChanged()},a.transformToVec3=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},a.transformToVec4=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._w=n*o[3]+a*o[7]+i*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},a.transformCoordinate=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements,s=n*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,r._x=(n*o[0]+a*o[4]+i*o[8]+o[12])*s,r._y=(n*o[1]+a*o[5]+i*o[9]+o[13])*s,r._z=(n*o[2]+a*o[6]+i*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},a.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,d=c*n+s*i-l*a,u=c*a+l*n-o*i,h=c*i+o*a-s*n,_=-o*n-s*a-l*i;r._x=d*c-_*o-u*l+h*s,r._y=u*c-_*s-h*o+d*l,r._z=h*c-_*l-d*s+u*o,r._onValueChanged&&r._onValueChanged()},n(a,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),a);cC._zero=new cC(0,0,0),cC._one=new cC(1,1,1);var cT=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new cC,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}).prototype).clone=function(){return new o(this.center,this.radius)},s.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},o.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=e.length,n=o._tempVec30;n.x=n.y=n.z=0;for(var a=0;a<r;++a)cC.add(e[a],n,n);cC.scale(n,1/r,t.center);for(var i=0,s=0;s<r;++s){var l=cC.distanceSquared(n,e[s]);l>i&&(i=l)}t.radius=Math.sqrt(i)},o.fromBox=function(e,t){var r=t.center,n=e.min,a=e.max;r.x=(n.x+a.x)*.5,r.y=(n.y+a.y)*.5,r.z=(n.z+a.z)*.5,t.radius=cC.distance(r,a)},o);cT._tempVec30=new cC;var cA=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new cC,this.max=new cC,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){var t=this.min,r=this.max,n=r._x+t._x,a=r._y+t._y,i=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,a=r._y-t._y,i=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,a=t.y,i=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var d=0,u=8-c;d<u;++d)e[c+d]=new cC;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(n,a,l),e[4].set(n,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(n,a,i),e},c.transform=function(e){return l.transform(this,e,this),this},c.clone=function(){return new l(this.min,this.max)},c.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,r){cC.subtract(e,t,r.min),cC.add(e,t,r.max)},l.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=t.min,n=t.max;r.x=r.y=r.z=Number.MAX_VALUE,n.x=n.y=n.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];cC.min(r,o,r),cC.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,a=t.min,i=t.max;a.x=r.x-n,a.y=r.y-n,a.z=r.z-n,i.x=r.x+n,i.y=r.y+n,i.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,a=l._tempVec31;e.getCenter(n),e.getExtent(a),cC.transformCoordinate(n,t,n);var i=a.x,o=a.y,s=a.z,c=t.elements,d=c[0],u=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];a.set((0===d?0:Math.abs(i*d))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===u?0:Math.abs(i*u))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(i*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),cC.subtract(n,a,r.min),cC.add(n,a,r.max)},l.merge=function(e,t,r){return cC.min(e.min,t.min,r.min),cC.max(e.max,t.max,r.max),r},l);cA._tempVec30=new cC,cA._tempVec31=new cC;var cM=((d=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var a=e.normal,i=t.normal,o=r.normal;cC.cross(i,o,d._tempVec30),cC.cross(o,a,d._tempVec31),cC.cross(a,i,d._tempVec32);var s=-cC.dot(a,d._tempVec30),l=-cC.dot(i,d._tempVec31),c=-cC.dot(o,d._tempVec32);cC.scale(d._tempVec30,e.distance/s,d._tempVec30),cC.scale(d._tempVec31,t.distance/l,d._tempVec31),cC.scale(d._tempVec32,r.distance/c,d._tempVec32),cC.add(d._tempVec30,d._tempVec31,n),cC.add(n,d._tempVec32,n)},d.distancePlaneAndPoint=function(e,t){return cC.dot(e.normal,t)+e.distance},d.intersectsPlaneAndPoint=function(t,r){var n=d.distancePlaneAndPoint(t,r);return n>0?e.PlaneIntersectionType.Front:n<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},d.intersectsPlaneAndBox=function(t,r){var n=r.min,a=r.max,i=t.normal,o=d._tempVec30,s=d._tempVec31;return(i.x>=0?(o.x=a.x,s.x=n.x):(o.x=n.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=n.y):(o.y=n.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=n.z):(o.z=n.z,s.z=a.z),0>d.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:d.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},d.intersectsPlaneAndSphere=function(t,r){var n=r.center,a=r.radius,i=d.distancePlaneAndPoint(t,n);return i>a?e.PlaneIntersectionType.Front:i<-a?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},d.intersectsRayAndPlane=function(e,t){var r=t.normal,n=cS.zeroTolerance,a=cC.dot(r,e.direction);if(Math.abs(a)<n)return -1;var i=cC.dot(r,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-n)return -1;o=0}return o},d.intersectsRayAndBox=function(e,t){var r=cS.zeroTolerance,n=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,d=n.x,u=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(d<i.x||d>o.x)return -1}else{var p=1/s,m=(i.x-d)*p,g=(o.x-d)*p;if(m>g){var v=m;m=g,g=v}if((_=Math.max(m,_))>(f=Math.min(g,f)))return -1}if(Math.abs(l)<r){if(u<i.y||u>o.y)return -1}else{var y=1/l,x=(i.y-u)*y,b=(o.y-u)*y;if(x>b){var S=x;x=b,b=S}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<r){if(h<i.z||h>o.z)return -1}else{var C=1/c,T=(i.z-h)*C,A=(o.z-h)*C;if(T>A){var M=T;T=A,A=M}if((_=Math.max(T,_))>(f=Math.min(A,f)))return -1}return _},d.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,a=t.center,i=t.radius,o=d._tempVec30;cC.subtract(r,a,o);var s=cC.dot(o,n),l=cC.dot(o,o)-i*i;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var u=-s-Math.sqrt(c);return u<0&&(u=0),u},d.intersectsBoxAndBox=function(e,t){return!(e.min.x>t.max.x)&&!(t.min.x>e.max.x)&&!(e.min.y>t.max.y)&&!(t.min.y>e.max.y)&&!(e.min.z>t.max.z||t.min.z>e.max.z)},d.intersectsSphereAndSphere=function(e,t){var r=e.radius+t.radius;return cC.distanceSquared(e.center,t.center)<r*r},d.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,a=t.min,i=d._tempVec30;return i.set(Math.max(a.x,Math.min(r.x,n.x)),Math.max(a.y,Math.min(r.y,n.y)),Math.max(a.z,Math.min(r.z,n.z))),cC.distanceSquared(r,i)<=e.radius*e.radius},d.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,a=d._tempVec30,i=0;i<6;++i){var o=e.getPlane(i),s=o.normal;if(a.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),cC.dot(s,a)<-o.distance)return!1}return!0},d.frustumContainsPoint=function(t,r){var n=d.distancePlaneAndPoint(t.near,r);return Math.abs(n)<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.far,r))<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.left,r))<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.right,r))<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.top,r))<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=d.distancePlaneAndPoint(t.bottom,r))<cS.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},d.frustumContainsBox=function(t,r){for(var n=r.min,a=r.max,i=d._tempVec30,o=d._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(i.x=a.x,o.x=n.x):(i.x=n.x,o.x=a.x),u.y>=0?(i.y=a.y,o.y=n.y):(i.y=n.y,o.y=a.y),u.z>=0?(i.z=a.z,o.z=n.z):(i.z=n.z,o.z=a.z),d.intersectsPlaneAndPoint(c,i)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;d.intersectsPlaneAndPoint(c,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},d.frustumContainsSphere=function(t,r){for(var n=e.ContainmentType.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=d.intersectsPlaneAndSphere(i,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},d);cM._tempVec30=new cC,cM._tempVec31=new cC,cM._tempVec32=new cC;var cE=((h=(u=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new cC,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return u.normalize(this,this),this},h.clone=function(){var e=new u;return e.copyFrom(this),e},h.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},u.normalize=function(e,t){var r=e.normal,n=1/r.length();cC.scale(r,n,t.normal),t.distance=e.distance*n},u.fromPoints=function(e,t,r,n){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,d=r.x-a,u=r.y-i,h=r.z-o,_=l*h-c*u,f=c*d-s*h,p=s*u-l*d,m=1/Math.sqrt(_*_+f*f+p*p),g=_*m,v=f*m,y=p*m,x=n.normal;x.x=g,x.y=v,x.z=y,n.distance=-(g*a+v*i+y*o)},u),cR=((f=(_=function(e){void 0===e&&(e=null),this.near=new cE,this.far=new cE,this.left=new cE,this.right=new cE,this.top=new cE,this.bottom=new cE,e&&this.calculateFromMatrix(e)}).prototype).getPlane=function(t){switch(t){case e.FrustumFace.Near:return this.near;case e.FrustumFace.Far:return this.far;case e.FrustumFace.Left:return this.left;case e.FrustumFace.Right:return this.right;case e.FrustumFace.Bottom:return this.bottom;case e.FrustumFace.Top:return this.top;default:return null}},f.calculateFromMatrix=function(e){var t=e.elements,r=t[0],n=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],d=t[8],u=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+r,c+o,_+d),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-r,c-o,_-d),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+n,c+s,_+u),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-n,c-s,_-u),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return cM.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return cM.frustumContainsSphere(this,t)!==e.ContainmentType.Disjoint},f.clone=function(){var e=new _;return e.copyFrom(this),e},f.copyFrom=function(e){return this.near.copyFrom(e.near),this.far.copyFrom(e.far),this.left.copyFrom(e.left),this.right.copyFrom(e.right),this.bottom.copyFrom(e.bottom),this.top.copyFrom(e.top),this},_),cw=((m=(p=function(e,t,r,n,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},m.add=function(e){return p.add(this,e,this),this},m.subtract=function(e){return p.subtract(this,e,this),this},m.multiply=function(e){return p.multiply(this,e,this),this},m.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*a+o*s)+n*(l*a-i*s)},m.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},m.invert=function(){return p.invert(this,this),this},m.rotate=function(e){return p.rotate(this,e,this),this},m.scale=function(e){return p.scale(this,e,this),this},m.translate=function(e){return p.translate(this,e,this),this},m.transpose=function(){return p.transpose(this,this),this},m.clone=function(){var e=this.elements;return new p(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},m.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},m.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<12;n++)r[n]=e[n+t];return this},m.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=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]},m.copyFromMatrix=function(e){var t=e.elements,r=this.elements;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[4],r[4]=t[5],r[5]=t[6],r[6]=t[8],r[7]=t[9],r[8]=t[10],this},p.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8]},p.subtract=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3],i[4]=n[4]-a[4],i[5]=n[5]-a[5],i[6]=n[6]-a[6],i[7]=n[7]-a[7],i[8]=n[8]-a[8]},p.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],d=n[4],u=n[5],h=n[6],_=n[7],f=n[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],S=a[7],C=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+d*m+_*g,i[2]=l*p+u*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+d*y+_*x,i[5]=l*v+u*y+f*x,i[6]=o*b+c*S+h*C,i[7]=s*b+d*S+_*C,i[8]=l*b+u*S+f*C},p.equals=function(e,t){var r=e.elements,n=t.elements;return cS.equals(r[0],n[0])&&cS.equals(r[1],n[1])&&cS.equals(r[2],n[2])&&cS.equals(r[3],n[3])&&cS.equals(r[4],n[4])&&cS.equals(r[5],n[5])&&cS.equals(r[6],n[6])&&cS.equals(r[7],n[7])&&cS.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,d=n*s,u=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=u-v,r[6]=_+g,r[1]=u+v,r[4]=1-d-p,r[7]=f-m,r[2]=_-g,r[5]=f+m,r[8]=1-d-h},p.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=e._y,r[5]=0,r[6]=0,r[7]=0,r[8]=1},p.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=e._x,r[7]=e._y,r[8]=1},p.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=h*l-c*u,f=-h*s+c*d,p=u*s-l*d,m=a*_+i*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*i+o*u)*m,n[2]=(c*i-o*l)*m,n[3]=f*m,n[4]=(h*a-o*d)*m,n[5]=(-c*a+o*s)*m,n[6]=p*m,n[7]=(-u*a+i*d)*m,n[8]=(l*a-i*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15],x=a*c-i*l,b=a*d-o*l,S=a*u-s*l,C=i*d-o*c,T=i*u-s*c,A=o*u-s*d,M=h*g-_*m,E=h*v-f*m,R=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+C*R-T*E+A*M;if(!L)return null;L=1/L,n[0]=(c*F-d*P+u*w)*L,n[1]=(d*R-l*F-u*E)*L,n[2]=(l*P-c*R+u*M)*L,n[3]=(o*P-i*F-s*w)*L,n[4]=(a*F-o*R+s*E)*L,n[5]=(i*R-a*P-s*M)*L,n[6]=(g*A-v*T+y*C)*L,n[7]=(v*S-m*A-y*b)*L,n[8]=(m*T-g*S+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,a=r.elements,i=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],d=n[3],u=n[4],h=n[5],_=n[6],f=n[7],p=n[8];a[0]=o*s+i*d,a[1]=o*l+i*u,a[2]=o*c+i*h,a[3]=o*d-i*s,a[4]=o*u-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},p.scale=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements;o[0]=n*i[0],o[1]=n*i[1],o[2]=n*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},p.translate=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements,s=i[0],l=i[1],c=i[2],d=i[3],u=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=d,o[4]=u,o[5]=h,o[6]=n*s+a*d+_,o[7]=n*l+a*u+f,o[8]=n*c+a*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=a,n[5]=r[7],n[6]=i,n[7]=o}else n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8]},p),cP=((v=(g=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},v.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},v.getAxisAngle=function(e){var t=this._x,r=this._y,n=this._z,a=t*t+r*r+n*n;if(a<cS.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},v.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},v.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},v.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},v.normalize=function(){return g.normalize(this,this),this},v.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},v.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},v.rotateX=function(e){return g.rotateX(this,e,this),this},v.rotateY=function(e){return g.rotateY(this,e,this),this},v.rotateZ=function(e){return g.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return g.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return g.multiply(this,e,this),this},v.invert=function(){return g.invert(this,this),this},v.dot=function(e){return g.dot(this,e)},v.lerp=function(e,t){return g.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return g._tempQuat1.rotationAxisAngle(e,t),this.multiply(g._tempQuat1),this},v.clone=function(){return new g(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,r=this._y,n=this._z,a=this._w,i=t*t,o=r*r,s=n*n,l=a*a,c=i+o+s+l,d=2*(t*a-r*n);d>(1-cS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=Math.PI/2,e._z=0):d<-(1-cS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*a),s+l-o-i),e._y=Math.asin(d/c),e._z=Math.atan2(2*(t*r+n*a),o+l-s-i))},g.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},g.multiply=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,d=t._w;r._x=n*d+o*s+a*c-i*l,r._y=a*d+o*l+i*s-n*c,r._z=i*d+o*c+n*l-a*s,r._w=o*d-n*s-a*l-i*c,r._onValueChanged&&r._onValueChanged()},g.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},g.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},g.equals=function(e,t){return cS.equals(e._x,t._x)&&cS.equals(e._y,t._y)&&cS.equals(e._z,t._z)&&cS.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;cC.normalize(e,n);var a=Math.sin(t*=.5);r._x=n._x*a,r._y=n._y*a,r._z=n._z*a,r._w=Math.cos(t),r._onValueChanged&&r._onValueChanged()},g.rotationEuler=function(e,t,r,n){g.rotationYawPitchRoll(t,e,r,n)},g.rotationYawPitchRoll=function(e,t,r,n){var a=.5*r,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),d=Math.cos(i),u=Math.sin(o),h=Math.cos(o),_=h*d,f=u*c;n._x=h*c*l+u*d*s,n._y=u*d*l-h*c*s,n._z=_*s-f*l,n._w=_*l+f*s,n._onValueChanged&&n._onValueChanged()},g.rotationMatrix3x3=function(e,t){var r,n,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],d=a[5],u=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(d-h)*r,t._y=(u-s)*r,t._z=(o-l)*r):i>=c&&i>=_?(n=.5/(r=Math.sqrt(1+i-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+u)*n,t._w=(d-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-i-_)),t._x=(l+o)*n,t._y=.5*r,t._z=(h+d)*n,t._w=(u-s)*n):(n=.5/(r=Math.sqrt(1+_-i-c)),t._x=(s+u)*n,t._y=(d+h)*n,t._z=.5*r,t._w=(o-l)*n),t._onValueChanged&&t._onValueChanged()},g.invert=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=r*r+n*n+a*a+i*i;if(o>cS.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var a=1-r;g.dot(e,t)>=0?(n._x=e._x*a+t._x*r,n._y=e._y*a+t._y*r,n._z=e._z*a+t._z*r,n._w=e._w*a+t._w*r):(n._x=e._x*a-t._x*r,n._y=e._y*a-t._y*r,n._z=e._z*a-t._z*r,n._w=e._w*a-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var a,i,o=g.dot(e,t);if(Math.abs(o)>1-cS.zeroTolerance)i=1-r,a=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);i=Math.sin((1-r)*s)*l,a=Math.sin(r*s)*l*Math.sign(o)}n.x=i*e.x+a*t.x,n.y=i*e.y+a*t.y,n.z=i*e.z+a*t.z,n.w=i*e.w+a*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cS.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},g.rotationX=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=r,t._y=0,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationY=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=r,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationZ=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=0,t._z=r,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotateX=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=a*l+i*s,r._z=i*l-a*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-i*s,r._y=a*l+o*s,r._z=i*l+n*s,r._w=o*l-a*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+a*s,r._y=a*l-n*s,r._z=i*l+o*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},n(g,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<cS.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);cP._tempVector3=new cC,cP._tempQuat1=new cP;var cF=((x=(y=function(e,t,r,n,a,i,o,s,l,c,d,u,h,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===u&&(u=0),void 0===h&&(h=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var m=this.elements;m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=d,m[11]=u,m[12]=h,m[13]=_,m[14]=f,m[15]=p}).prototype).set=function(e,t,r,n,a,i,o,s,l,c,d,u,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=a,m[5]=i,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=d,m[11]=u,m[12]=h,m[13]=_,m[14]=f,m[15]=p,this},x.multiply=function(e){return y.multiply(this,e,this),this},x.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8],d=e[9],u=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-r*i)*(u*m-h*p)-(t*s-n*i)*(d*m-h*f)+(t*l-a*i)*(d*p-u*f)+(r*s-n*o)*(c*m-h*_)-(r*l-a*o)*(c*p-u*_)+(n*l-a*s)*(c*f-d*_)},x.decompose=function(e,t,r){var n=y._tempMat30,a=this.elements,i=n.elements,o=a[0],s=a[1],l=a[2],c=a[4],d=a[5],u=a[6],h=a[8],_=a[9],f=a[10];e.set(a[12],a[13],a[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+d*d+u*u),g=Math.sqrt(h*h+_*_+f*f);if(0>this.determinant()&&(p=-p),r.set(p,m,g),Math.abs(p)<cS.zeroTolerance||Math.abs(m)<cS.zeroTolerance||Math.abs(g)<cS.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,b=1/g;return i[0]=o*v,i[1]=s*v,i[2]=l*v,i[3]=c*x,i[4]=d*x,i[5]=u*x,i[6]=h*b,i[7]=_*b,i[8]=f*b,cP.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>cS.zeroTolerance){var n=2*Math.sqrt(r+1);e._w=.25*n,e._x=(t[6]-t[9])/n,e._y=(t[8]-t[2])/n,e._z=(t[1]-t[4])/n}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},x.getScaling=function(e){var t=this.elements,r=t[0],n=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],d=t[10];return e.set(Math.sqrt(r*r+n*n+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+d*d)),e},x.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},x.identity=function(){var e=this.elements;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,this},x.invert=function(){return y.invert(this,this),this},x.rotateAxisAngle=function(e,t){return y.rotateAxisAngle(this,e,t,this),this},x.scale=function(e){return y.scale(this,e,this),this},x.translate=function(e){return y.translate(this,e,this),this},x.transpose=function(){return y.transpose(this,this),this},x.clone=function(){var e=this.elements;return new y(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])},x.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this},x.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<16;n++)r[n]=e[n+t];return this},x.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=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]},y.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],d=n[4],u=n[5],h=n[6],_=n[7],f=n[8],p=n[9],m=n[10],g=n[11],v=n[12],y=n[13],x=n[14],b=n[15],S=a[0],C=a[1],T=a[2],A=a[3],M=a[4],E=a[5],R=a[6],w=a[7],P=a[8],F=a[9],L=a[10],D=a[11],B=a[12],I=a[13],V=a[14],O=a[15];i[0]=o*S+d*C+f*T+v*A,i[1]=s*S+u*C+p*T+y*A,i[2]=l*S+h*C+m*T+x*A,i[3]=c*S+_*C+g*T+b*A,i[4]=o*M+d*E+f*R+v*w,i[5]=s*M+u*E+p*R+y*w,i[6]=l*M+h*E+m*R+x*w,i[7]=c*M+_*E+g*R+b*w,i[8]=o*P+d*F+f*L+v*D,i[9]=s*P+u*F+p*L+y*D,i[10]=l*P+h*F+m*L+x*D,i[11]=c*P+_*F+g*L+b*D,i[12]=o*B+d*I+f*V+v*O,i[13]=s*B+u*I+p*V+y*O,i[14]=l*B+h*I+m*V+x*O,i[15]=c*B+_*I+g*V+b*O},y.equals=function(e,t){var r=e.elements,n=t.elements;return cS.equals(r[0],n[0])&&cS.equals(r[1],n[1])&&cS.equals(r[2],n[2])&&cS.equals(r[3],n[3])&&cS.equals(r[4],n[4])&&cS.equals(r[5],n[5])&&cS.equals(r[6],n[6])&&cS.equals(r[7],n[7])&&cS.equals(r[8],n[8])&&cS.equals(r[9],n[9])&&cS.equals(r[10],n[10])&&cS.equals(r[11],n[11])&&cS.equals(r[12],n[12])&&cS.equals(r[13],n[13])&&cS.equals(r[14],n[14])&&cS.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r,o[9]=a[9]*s+i[9]*r,o[10]=a[10]*s+i[10]*r,o[11]=a[11]*s+i[11]*r,o[12]=a[12]*s+i[12]*r,o[13]=a[13]*s+i[13]*r,o[14]=a[14]*s+i[14]*r,o[15]=a[15]*s+i[15]*r},y.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8],i[9]=n[9]+a[9],i[10]=n[10]+a[10],i[11]=n[11]+a[11],i[12]=n[12]+a[12],i[13]=n[13]+a[13],i[14]=n[14]+a[14],i[15]=n[15]+a[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,a=r.elements;a[0]=n[0]*t,a[1]=n[1]*t,a[2]=n[2]*t,a[3]=n[3]*t,a[4]=n[4]*t,a[5]=n[5]*t,a[6]=n[6]*t,a[7]=n[7]*t,a[8]=n[8]*t,a[9]=n[9]*t,a[10]=n[10]*t,a[11]=n[11]*t,a[12]=n[12]*t,a[13]=n[13]*t,a[14]=n[14]*t,a[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,d=n*s,u=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=u+v,r[2]=_-g,r[3]=0,r[4]=u-v,r[5]=1-d-p,r[6]=f+m,r[7]=0,r[8]=_+g,r[9]=f-m,r[10]=1-d-h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.rotationAxisAngle=function(e,t,r){var n,a,i,o=r.elements,s=e._x,l=e._y,c=e._z,d=Math.sqrt(s*s+l*l+c*c);Math.abs(d)<cS.zeroTolerance||(s*=d=1/d,l*=d,c*=d,n=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*n,o[2]=c*s*i-l*n,o[3]=0,o[4]=s*l*i-c*n,o[5]=l*l*i+a,o[6]=c*l*i+s*n,o[7]=0,o[8]=s*c*i+l*n,o[9]=l*c*i-s*n,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},y.rotationTranslation=function(e,t,r){y.rotationQuaternion(e,r);var n=r.elements;n[12]=t._x,n[13]=t._y,n[14]=t._z},y.affineTransformation=function(e,t,r,n){var a=n.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,d=o+o,u=s+s,h=i*c,_=i*d,f=i*u,p=o*d,m=o*u,g=s*u,v=l*c,y=l*d,x=l*u,b=e._x,S=e._y,C=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*S,a[5]=(1-(h+g))*S,a[6]=(m+v)*S,a[7]=0,a[8]=(f+y)*C,a[9]=(m-v)*C,a[10]=(1-(h+p))*C,a[11]=0,a[12]=r._x,a[13]=r._y,a[14]=r._z,a[15]=1},y.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e._y,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e._z,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e._x,r[13]=e._y,r[14]=e._z,r[15]=1},y.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],d=r[6],u=r[7],h=r[8],_=r[9],f=r[10],p=r[11],m=r[12],g=r[13],v=r[14],y=r[15],x=a*c-i*l,b=a*d-o*l,S=a*u-s*l,C=i*d-o*c,T=i*u-s*c,A=o*u-s*d,M=h*g-_*m,E=h*v-f*m,R=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+S*w+C*R-T*E+A*M;if(!L)return null;L=1/L,n[0]=(c*F-d*P+u*w)*L,n[1]=(o*P-i*F-s*w)*L,n[2]=(g*A-v*T+y*C)*L,n[3]=(f*T-_*A-p*C)*L,n[4]=(d*R-l*F-u*E)*L,n[5]=(a*F-o*R+s*E)*L,n[6]=(v*S-m*A-y*b)*L,n[7]=(h*A-f*S+p*b)*L,n[8]=(l*P-c*R+u*M)*L,n[9]=(i*R-a*P-s*M)*L,n[10]=(m*T-g*S+y*x)*L,n[11]=(_*S-h*T-p*x)*L,n[12]=(c*E-l*w-d*M)*L,n[13]=(a*w-i*E+o*M)*L,n[14]=(g*b-m*C-v*x)*L,n[15]=(h*C-_*b+f*x)*L},y.lookAt=function(e,t,r,n){var a=n.elements,i=y._tempVec30,o=y._tempVec31,s=y._tempVec32;cC.subtract(e,t,s),s.normalize(),cC.cross(r,s,i),i.normalize(),cC.cross(s,i,o),a[0]=i._x,a[1]=o._x,a[2]=s._x,a[3]=0,a[4]=i._y,a[5]=o._y,a[6]=s._y,a[7]=0,a[8]=i._z,a[9]=o._z,a[10]=s._z,a[11]=0,a[12]=-cC.dot(i,e),a[13]=-cC.dot(o,e),a[14]=-cC.dot(s,e),a[15]=1},y.ortho=function(e,t,r,n,a,i,o){var s=o.elements,l=1/(e-t),c=1/(r-n),d=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*d,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(i+a)*d,s[15]=1},y.perspective=function(e,t,r,n,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(r-n);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(n+r)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*n*r*s,i[15]=0},y.rotateAxisAngle=function(e,t,r,n){var a,i,o,s=t._x,l=t._y,c=t._z,d=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(d)<cS.zeroTolerance)){var u=e.elements,h=n.elements;s*=d=1/d,l*=d,c*=d,a=Math.sin(r),o=1-(i=Math.cos(r));var _=u[0],f=u[1],p=u[2],m=u[3],g=u[4],v=u[5],y=u[6],x=u[7],b=u[8],S=u[9],C=u[10],T=u[11],A=s*s*o+i,M=l*s*o+c*a,E=c*s*o-l*a,R=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;h[0]=_*A+g*M+b*E,h[1]=f*A+v*M+S*E,h[2]=p*A+y*M+C*E,h[3]=m*A+x*M+T*E,h[4]=_*R+g*w+b*P,h[5]=f*R+v*w+S*P,h[6]=p*R+y*w+C*P,h[7]=m*R+x*w+T*P,h[8]=_*F+g*L+b*D,h[9]=f*F+v*L+S*D,h[10]=p*F+y*L+C*D,h[11]=m*F+x*L+T*D,e!==n&&(h[12]=u[12],h[13]=u[13],h[14]=u[14],h[15]=u[15])}},y.scale=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;a[0]=n[0]*i,a[1]=n[1]*i,a[2]=n[2]*i,a[3]=n[3]*i,a[4]=n[4]*o,a[5]=n[5]*o,a[6]=n[6]*o,a[7]=n[7]*o,a[8]=n[8]*s,a[9]=n[9]*s,a[10]=n[10]*s,a[11]=n[11]*s,a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;if(e===r)a[12]=n[0]*i+n[4]*o+n[8]*s+n[12],a[13]=n[1]*i+n[5]*o+n[9]*s+n[13],a[14]=n[2]*i+n[6]*o+n[10]*s+n[14],a[15]=n[3]*i+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],d=n[2],u=n[3],h=n[4],_=n[5],f=n[6],p=n[7],m=n[8],g=n[9],v=n[10],y=n[11];a[0]=l,a[1]=c,a[2]=d,a[3]=u,a[4]=h,a[5]=_,a[6]=f,a[7]=p,a[8]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+n[12],a[13]=c*i+_*o+g*s+n[13],a[14]=d*i+f*o+v*s+n[14],a[15]=u*i+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[3],s=r[6],l=r[7],c=r[11];n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=a,n[6]=r[9],n[7]=r[13],n[8]=i,n[9]=s,n[11]=r[14],n[12]=o,n[13]=l,n[14]=c}else n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15]},y);cF._tempVec30=new cC,cF._tempVec31=new cC,cF._tempVec32=new cC,cF._tempMat30=new cw,cF._identity=new cF(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var cL=((S=(b=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new cC,this.direction=new cC,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return cM.intersectsRayAndPlane(this,e)},S.intersectSphere=function(e){return cM.intersectsRayAndSphere(this,e)},S.intersectBox=function(e){return cM.intersectsRayAndBox(this,e)},S.getPoint=function(e,t){return cC.scale(this.direction,e,t),t.add(this.origin)},b),cD=((T=(C=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}).prototype).set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},T.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},T.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},T.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},T.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},T.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},T.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},T.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},T.normalize=function(){return C.normalize(this,this),this},T.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},T.clone=function(){return new C(this._x,this._y)},T.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},T.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},T.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},T.toJSON=function(){return{x:this._x,y:this._y}},C.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._onValueChanged&&r._onValueChanged()},C.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._onValueChanged&&r._onValueChanged()},C.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._onValueChanged&&r._onValueChanged()},C.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._onValueChanged&&r._onValueChanged()},C.dot=function(e,t){return e._x*t._x+e._y*t._y},C.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y;return Math.sqrt(r*r+n*n)},C.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y;return r*r+n*n},C.equals=function(e,t){return cS.equals(e._x,t._x)&&cS.equals(e._y,t._y)},C.lerp=function(e,t,r,n){var a=e._x,i=e._y;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._onValueChanged&&n._onValueChanged()},C.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},C.normalize=function(e,t){var r=e._x,n=e._y,a=Math.sqrt(r*r+n*n);a>cS.zeroTolerance&&(a=1/a,t._x=r*a,t._y=n*a,t._onValueChanged&&t._onValueChanged())},C.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._onValueChanged&&r._onValueChanged()},n(C,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),C);cD._zero=new cD(0,0),cD._one=new cD(1,1);var cB=((M=(A=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},M.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},M.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},M.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},M.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},M.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},M.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},M.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},M.normalize=function(){return A.normalize(this,this),this},M.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},M.clone=function(){return new A(this._x,this._y,this._z,this._w)},M.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},M.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},M.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},M.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},A.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._w=e._w-t._w,r._onValueChanged&&r._onValueChanged()},A.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._w=e._w*t._w,r._onValueChanged&&r._onValueChanged()},A.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._w=e._w/t._w,r._onValueChanged&&r._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(r*r+n*n+a*a+i*i)},A.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return r*r+n*n+a*a+i*i},A.equals=function(e,t){return cS.equals(e._x,t._x)&&cS.equals(e._y,t._y)&&cS.equals(e._z,t._z)&&cS.equals(e._w,t._w)},A.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z,s=e._w;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},A.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._w=Math.max(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._w=Math.min(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cS.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},A.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},A.transform=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;r._x=n*s[0]+a*s[4]+i*s[8]+o*s[12],r._y=n*s[1]+a*s[5]+i*s[9]+o*s[13],r._z=n*s[2]+a*s[6]+i*s[10]+o*s[14],r._w=n*s[3]+a*s[7]+i*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},A.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,d=t._w,u=d*n+l*i-c*a,h=d*a+c*n-s*i,_=d*i+s*a-l*n,f=-s*n-l*a-c*i;r._x=u*d-f*s-h*c+_*l,r._y=h*d-f*l-_*s+u*c,r._z=_*d-f*c-u*l+h*s,r._w=o,r._onValueChanged&&r._onValueChanged()},n(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);cB._zero=new cB(0,0,0,0),cB._one=new cB(1,1,1,1);var cI=((R=(E=function(e,t,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=r,this._a=n}).prototype).set=function(e,t,r,n){return this._r=e,this._g=t,this._b=r,this._a=n,this._onValueChanged&&this._onValueChanged(),this},R.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this._onValueChanged&&this._onValueChanged(),this},R.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},R.clone=function(){return new E(this._r,this._g,this._b,this._a)},R.copyFrom=function(e){return this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._onValueChanged&&this._onValueChanged(),this},R.copyFromArray=function(e,t){return void 0===t&&(t=0),this._r=e[t],this._g=e[t+1],this._b=e[t+2],this._a=e[t+3],this._onValueChanged&&this._onValueChanged(),this},R.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._r,e[t+1]=this._g,e[t+2]=this._b,e[t+3]=this._a},R.toLinear=function(e){return e._r=E.gammaToLinearSpace(this._r),e._g=E.gammaToLinearSpace(this._g),e._b=E.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},R.toGamma=function(e){return e._r=E.linearToGammaSpace(this._r),e._g=E.linearToGammaSpace(this._g),e._b=E.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},R.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,a=e;return t>n&&(n=t),r>n&&(n=r),t<a&&(a=t),r<a&&(a=r),(n+a)/2},R.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},E.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},E.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},E.equals=function(e,t){return cS.equals(e._r,t._r)&&cS.equals(e._g,t._g)&&cS.equals(e._b,t._b)&&cS.equals(e._a,t._a)},E.add=function(e,t,r){return r._r=e._r+t._r,r._g=e._g+t._g,r._b=e._b+t._b,r._a=e._a+t._a,r._onValueChanged&&r._onValueChanged(),r},E.subtract=function(e,t,r){r._r=e._r-t._r,r._g=e._g-t._g,r._b=e._b-t._b,r._a=e._a-t._a,r._onValueChanged&&r._onValueChanged()},E.scale=function(e,t,r){return r._r=e._r*t,r._g=e._g*t,r._b=e._b*t,r._a=e._a*t,r._onValueChanged&&r._onValueChanged(),r},E.lerp=function(e,t,r,n){var a=e._r,i=e._g,o=e._b,s=e._a;return n._r=a+(t._r-a)*r,n._g=i+(t._g-i)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(E,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),E),cV=((P=(w=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=r,this._height=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._width=r,this._height=n,this._onValueChanged&&this._onValueChanged(),this},P.clone=function(){return new w(this.x,this.y,this.width,this.height)},P.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},n(w,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),w),cO=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,d=-.488603*i,u=.488603*o,h=-.488603*a,_=1.092548*(a*i),f=-1.092548*(i*o),p=.315392*(3*o*o-1),m=-1.092548*(a*o),g=.546274*(a*a-i*i);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*d,n[4]+=l*d,n[5]+=c*d,n[6]+=s*u,n[7]+=l*u,n[8]+=c*u,n[9]+=s*h,n[10]+=l*h,n[11]+=c*h,n[12]+=s*_,n[13]+=l*_,n[14]+=c*_,n[15]+=s*f,n[16]+=l*f,n[17]+=c*f,n[18]+=s*p,n[19]+=l*p,n[20]+=c*p,n[21]+=s*m,n[22]+=l*m,n[23]+=c*m,n[24]+=s*g,n[25]+=l*g,n[26]+=c*g},L.evaluate=function(e,t){var r=this.coefficients,n=e._x,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*n,c=.858086*a*n,d=-.858086*a*i,u=.247708*(3*i*i-1),h=-.858086*i*n,_=.429042*(n*n-a*a),f=.886227*r[0],p=.886227*r[1],m=.886227*r[2];return f+=r[3]*o+r[6]*s+r[9]*l,p+=r[4]*o+r[7]*s+r[10]*l,m+=r[5]*o+r[8]*s+r[11]*l,f+=r[12]*c+r[15]*d+r[18]*u+r[21]*h+r[24]*_,p+=r[13]*c+r[16]*d+r[19]*u+r[22]*h+r[25]*_,m+=r[14]*c+r[17]*d+r[20]*u+r[23]*h+r[26]*_,t.set(f,p,m,1),t},L.scale=function(e){var t=this.coefficients;t[0]*=e,t[1]*=e,t[2]*=e,t[3]*=e,t[4]*=e,t[5]*=e,t[6]*=e,t[7]*=e,t[8]*=e,t[9]*=e,t[10]*=e,t[11]*=e,t[12]*=e,t[13]*=e,t[14]*=e,t[15]*=e,t[16]*=e,t[17]*=e,t[18]*=e,t[19]*=e,t[20]*=e,t[21]*=e,t[22]*=e,t[23]*=e,t[24]*=e,t[25]*=e,t[26]*=e},L.clone=function(){var e=new F;return e.copyFrom(this),e},L.copyFrom=function(e){return e.copyToArray(this.coefficients),this},L.copyFromArray=function(e,t){void 0===t&&(t=0);var r=this.coefficients;r[0]=e[t],r[1]=e[1+t],r[2]=e[2+t],r[3]=e[3+t],r[4]=e[4+t],r[5]=e[5+t],r[6]=e[6+t],r[7]=e[7+t],r[8]=e[8+t],r[9]=e[9+t],r[10]=e[10+t],r[11]=e[11+t],r[12]=e[12+t],r[13]=e[13+t],r[14]=e[14+t],r[15]=e[15+t],r[16]=e[16+t],r[17]=e[17+t],r[18]=e[18+t],r[19]=e[19+t],r[20]=e[20+t],r[21]=e[21+t],r[22]=e[22+t],r[23]=e[23+t],r[24]=e[24+t],r[25]=e[25+t],r[26]=e[26+t]},L.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.coefficients;e[0+t]=r[0],e[1+t]=r[1],e[2+t]=r[2],e[3+t]=r[3],e[4+t]=r[4],e[5+t]=r[5],e[6+t]=r[6],e[7+t]=r[7],e[8+t]=r[8],e[9+t]=r[9],e[10+t]=r[10],e[11+t]=r[11],e[12+t]=r[12],e[13+t]=r[13],e[14+t]=r[14],e[15+t]=r[15],e[16+t]=r[16],e[17+t]=r[17],e[18+t]=r[18],e[19+t]=r[19],e[20+t]=r[20],e[21+t]=r[21],e[22+t]=r[22],e[23+t]=r[23],e[24+t]=r[24],e[25+t]=r[25],e[26+t]=r[26]},F),cN=((B=(D=function(e,t){this.reset(e,t)}).prototype).randomInt32=function(){var e=this._state0,t=this._state1;return this._state0=t,e^=e<<23,e^=e>>>17,e^=t^t>>>26,this._state1=e,this._state0+this._state1>>>0},B.random=function(){return this.randomInt32()/4294967295},B.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},D);function ck(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cz(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function cU(e,t,r){return t&&cz(e.prototype,t),r&&cz(e,r),e}function cG(e,t){return(cG=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cH(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cG(e,t)}function cW(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function cK(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function cj(e,t){cQ.registerCloneMode(e,t,lk.Ignore)}function cX(e,t){cQ.registerCloneMode(e,t,lk.Assignment)}function cq(e,t){cQ.registerCloneMode(e,t,lk.Shallow)}function cY(e,t){cQ.registerCloneMode(e,t,lk.Deep)}e.Platform=void 0,(I=e.Platform||(e.Platform={}))[I.Android=0]="Android",I[I.IPhone=1]="IPhone",I[I.IPad=2]="IPad",I[I.Mac=3]="Mac",I[I.Unknown=4]="Unknown",e.SpriteMaskInteraction=void 0,(V=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[V.None=0]="None",V[V.VisibleInsideMask=1]="VisibleInsideMask",V[V.VisibleOutsideMask=2]="VisibleOutsideMask",e.SpriteMaskLayer=void 0,(O=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[O.Layer0=1]="Layer0",O[O.Layer1=2]="Layer1",O[O.Layer2=4]="Layer2",O[O.Layer3=8]="Layer3",O[O.Layer4=16]="Layer4",O[O.Layer5=32]="Layer5",O[O.Layer6=64]="Layer6",O[O.Layer7=128]="Layer7",O[O.Layer8=256]="Layer8",O[O.Layer9=512]="Layer9",O[O.Layer10=1024]="Layer10",O[O.Layer11=2048]="Layer11",O[O.Layer12=4096]="Layer12",O[O.Layer13=8192]="Layer13",O[O.Layer14=16384]="Layer14",O[O.Layer15=32768]="Layer15",O[O.Layer16=65536]="Layer16",O[O.Layer17=131072]="Layer17",O[O.Layer18=262144]="Layer18",O[O.Layer19=524288]="Layer19",O[O.Layer20=1048576]="Layer20",O[O.Layer21=2097152]="Layer21",O[O.Layer22=4194304]="Layer22",O[O.Layer23=8388608]="Layer23",O[O.Layer24=16777216]="Layer24",O[O.Layer25=33554432]="Layer25",O[O.Layer26=67108864]="Layer26",O[O.Layer27=134217728]="Layer27",O[O.Layer28=268435456]="Layer28",O[O.Layer29=536870912]="Layer29",O[O.Layer30=1073741824]="Layer30",O[O.Layer31=2147483648]="Layer31",O[O.Everything=4294967295]="Everything",e.TextHorizontalAlignment=void 0,(N=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[N.Left=0]="Left",N[N.Center=1]="Center",N[N.Right=2]="Right",e.TextVerticalAlignment=void 0,(k=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[k.Top=0]="Top",k[k.Center=1]="Center",k[k.Bottom=2]="Bottom",e.OverflowMode=void 0,(z=e.OverflowMode||(e.OverflowMode={}))[z.Overflow=0]="Overflow",z[z.Truncate=1]="Truncate",e.FontStyle=void 0,(U=e.FontStyle||(e.FontStyle={}))[U.None=0]="None",U[U.Bold=1]="Bold",U[U.Italic=2]="Italic","function"==typeof SuppressedError&&SuppressedError,(G=lk||(lk={}))[G.Ignore=0]="Ignore",G[G.Assignment=1]="Assignment",G[G.Shallow=2]="Shallow",G[G.Deep=3]="Deep";var cQ=((H=function(){}).registerCloneMode=function(e,t,r){var n=H._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),H._subCloneModeMap.set(e.constructor,n)),n[t]=r},H.getCloneMode=function(e){var t=H._cloneModeMap.get(e);if(!t){t=Object.create(null),H._cloneModeMap.set(e,t);for(var r=H._objectType,n=H._subCloneModeMap;e!==r;){var a=n.get(e);a&&Object.assign(t,a),e=Object.getPrototypeOf(e)}}return t},H.cloneProperty=function(e,t,r,n,a,i,o){if(n!==lk.Ignore){var s=e[r];if(cK(s,Object)){if(void 0===n||n===lk.Assignment){t[r]=s;return}switch(s.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var l=t[r];null==l||l.length!==s.length?t[r]=s.slice():l.set(s);break;case Array:var c=t[r],d=s.length;null==c?t[r]=c=Array(d):c.length=d;for(var u=0;u<d;u++)H.cloneProperty(s,c,u,n,a,i,o);break;default:var h=t[r];if(h||((h=o.get(s))||(h=new s.constructor,o.set(s,h)),t[r]=h),s.copyFrom)h.copyFrom(s);else{var _=H.getCloneMode(s.constructor);for(var f in s)H.cloneProperty(s,h,f,_[f],a,i,o);s._cloneTo&&s._cloneTo(h,a,i)}}}else t[r]=s}},H.deepCloneObject=function(e,t,r){for(var n in e)H.cloneProperty(e,t,n,lk.Deep,null,null,r)},H);cQ._subCloneModeMap=new Map,cQ._cloneModeMap=new Map,cQ._objectType=Object.getPrototypeOf(Object);var cJ=function(){function e(t){this.instanceId=++e._instanceIdCounter,this._destroyed=!1,this._engine=t}var t=e.prototype;return t.destroy=function(){this._destroyed||(this._onDestroy(),this._destroyed=!0)},t._onDestroy=function(){var e=this._engine.resourceManager;e._deleteAsset(this),e._deleteContentRestorer(this)},cU(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();cJ._instanceIdCounter=0,cW([cj],cJ.prototype,"instanceId",void 0),cW([cj],cJ.prototype,"_engine",void 0);var cZ=(cH(W=function(e){var t;return(t=cJ.call(this,e)||this).isGCIgnored=!1,t._refCount=0,t._superResources=null,e.resourceManager._addReferResource(ck(t)),t},cJ),(K=W.prototype).destroy=function(e,t){if(void 0===e&&(e=!1),!e){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!t)return!1;for(var n=0,a=r.length;n<a;n++)if(r[n].refCount>0)return!1}}return cJ.prototype.destroy.call(this),!0},K._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},K._disassociationSuperResource=function(e){var t=this._superResources,r=t.indexOf(e);t.splice(r,1)},K._getReferCount=function(){return this._refCount},K._addReferCount=function(e){this._refCount+=e},K._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},K._onDestroy=function(){cJ.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},cU(W,[{key:"refCount",get:function(){return this._refCount}}]),W),c$=(cH(j=function(e){var t;return(t=cZ.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},cZ),(X=j.prototype).getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},X.getSprites=function(e,t){t.length=0;var r=this._spriteNamesToIndex[e];if(void 0!==r)for(var n=this._sprites;r>=0;r--){var a=n[r];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},X._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},X._onDestroy=function(){cZ.prototype._onDestroy.call(this);for(var e=this._sprites,t=0,r=e.length;t<r;t++)e[t].destroy();e.length=0,this._sprites=null,this._spriteNamesToIndex=null},cU(j,[{key:"sprites",get:function(){return this._sprites}}]),j);e.SpriteDrawMode=void 0,(q=e.SpriteDrawMode||(e.SpriteDrawMode={}))[q.Simple=0]="Simple",q[q.Sliced=1]="Sliced",q[q.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(Y=e.SpriteTileMode||(e.SpriteTileMode={}))[Y.Continuous=0]="Continuous",Y[Y.Adaptive=1]="Adaptive";var c0=((Q=function(){}).removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var a=e[n];e[r]=a}return e.length--,!0},Q.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",r=0,n=e.length;r<n;r++)t+=String.fromCharCode(e[r]);return decodeURIComponent(encodeURIComponent(t))},Q.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Q.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},Q.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},Q.resolveAbsoluteUrl=function(e,t){return Q.isAbsoluteUrl(t)||Q.isBase64Url(t)?t:t?new URL(t,e).href:e},Q._floatMatrixMultiply=function(e,t,r,n,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],d=i[4],u=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],S=t[r],C=t[r+1],T=t[r+2],A=t[r+3],M=t[r+4],E=t[r+5],R=t[r+6],w=t[r+7],P=t[r+8],F=t[r+9],L=t[r+10],D=t[r+11],B=t[r+12],I=t[r+13],V=t[r+14],O=t[r+15];n[a]=o*S+d*C+f*T+v*A,n[a+1]=s*S+u*C+p*T+y*A,n[a+2]=l*S+h*C+m*T+x*A,n[a+3]=c*S+_*C+g*T+b*A,n[a+4]=o*M+d*E+f*R+v*w,n[a+5]=s*M+u*E+p*R+y*w,n[a+6]=l*M+h*E+m*R+x*w,n[a+7]=c*M+_*E+g*R+b*w,n[a+8]=o*P+d*F+f*L+v*D,n[a+9]=s*P+u*F+p*L+y*D,n[a+10]=l*P+h*F+m*L+x*D,n[a+11]=c*P+_*F+g*L+b*D,n[a+12]=o*B+d*I+f*V+v*O,n[a+13]=s*B+u*I+p*V+y*O,n[a+14]=l*B+h*I+m*V+x*O,n[a+15]=c*B+_*I+g*V+b*O},Q._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,a=0,i=r.length;null!=n&&a<i;)n=n[r[a++]];return a&&a==i?n:void 0},Q._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var a=t+r>>1,i=e[t],o=e[r-1],s=e[a];if(n(i,o)>0){var l=i;i=o,o=l}if(n(i,s)>=0){var c=i;i=s,s=o,o=c}else if(n(o,s)>0){var d=o;o=s,s=d}e[t]=i,e[r-1]=s;var u=o,h=t+1,_=r-1;e[a]=e[h],e[h]=u;e:for(var f=h+1;f<_;f++){var p=e[f],m=n(p,u);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=n(e[_],u)}while(m>0);e[f]=e[_],e[_]=p,m<0&&(p=e[f],e[f]=e[h],e[h]=p,h++)}}r-_<h-t?(this._quickSort(e,_,r,n),r=h):(this._quickSort(e,t,h,n),t=_)}},Q._stringToPath=function(e){var t=[];return e.charCodeAt(0)===c1&&t.push(""),e.replace(c3,function(e,r,n,a){var i=e;n?i=a.replace(c2,"$1"):r&&(i=r.trim()),t.push(i)}),t},Q._insertionSort=function(e,t,r,n){for(var a=t+1;a<r;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(n(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},Q),c1=46,c2=/\\(\\)?/g,c3=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),c4=((Z=(J=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},Z.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},Z.removeFlag=function(e){c0.removeFromArray(this._updateFlags,e)&&c0.removeFromArray(e._flagManagers,this)},Z.addListener=function(e){this._listeners.push(e)},Z.removeListener=function(e){c0.removeFromArray(this._listeners,e)},Z.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},J);($=lz||(lz={}))[$.texture=1]="texture",$[$.size=2]="size",$[$.atlasRotate=4]="atlasRotate",$[$.atlasRegion=8]="atlasRegion",$[$.atlasRegionOffset=16]="atlasRegionOffset",$[$.region=32]="region",$[$.pivot=64]="pivot",$[$.border=128]="border",$[$.destroy=256]="destroy";var c8=(cH(ee=function(e,t,r,n,a,i){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===a&&(a=null),void 0===i&&(i=null),(o=cZ.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new cD,new cD,new cD,new cD],o._uvs=[new cD,new cD,new cD,new cD],o._bounds=new cA,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new cV(0,0,1,1),o._atlasRegionOffset=new cB(0,0,0,0),o._region=new cV(0,0,1,1),o._pivot=new cD(.5,.5),o._border=new cB(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new c4,o._texture=t,o._onRegionChange=o._onRegionChange.bind(ck(o)),o._onPivotChange=o._onPivotChange.bind(ck(o)),o._onBorderChange=o._onBorderChange.bind(ck(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,r&&o._region.copyFrom(r),n&&o._pivot.copyFrom(n),a&&o._border.copyFrom(a),o.name=i,o},cZ),(et=ee.prototype).clone=function(){var e=new ee(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},et._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},et._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},et._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},et._addReferCount=function(e){var t;cZ.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},et._onDestroy=function(){this._dispatchSpriteChange(lz.destroy),cZ.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},et._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,a=1/hh._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*a,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},et._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,a=t.width,i=t.height,o=Math.max(e.x-r,0)/a,s=Math.max(e.w-n,0)/i,l=1-Math.max(e.z-(1-r-a),0)/a,c=1-Math.max(e.y-(1-n-i),0)/i,d=this._positions;d[0].set(o,s),d[1].set(l,s),d[2].set(o,c),d[3].set(l,c);var u=this._bounds,h=u.min,_=u.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},et._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,a=r.y,i=r.width,o=r.height,s=1-n-i,l=1-a-o,c=this._atlasRegion,d=c.x,u=c.y,h=c.width,_=c.height,f=t.x,p=t.y,m=t.z,g=t.w,v=h/(1-f-m),y=_/(1-p-g),x=Math.max(n-f,0)*v+d,b=Math.max(l-p,0)*y+u,S=h+d-Math.max(s-m,0)*v,C=_+u-Math.max(a-g,0)*y,T=this._border,A=T.x,M=T.y,E=T.z,R=T.w;e[0].set(x,C),e[1].set((n-f+A*i)*v+d,_+u-(a-g+M*o)*y),e[2].set(h+d-(s-m+E*i)*v,(l-p+R*o)*y+u),e[3].set(S,b),this._dirtyUpdateFlag&=-3},et._dispatchSpriteChange=function(e){switch(e){case lz.texture:this._dirtyUpdateFlag|=4;break;case lz.atlasRegionOffset:case lz.region:this._dirtyUpdateFlag|=7;break;case lz.atlasRegion:this._dirtyUpdateFlag|=6;break;case lz.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},et._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=cS.clamp(e.x,0,1),r=cS.clamp(e.y,0,1);e.set(t,r,cS.clamp(e.width,0,1-t),cS.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lz.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lz.size),e._onValueChanged=this._onRegionChange},et._onPivotChange=function(){this._dispatchSpriteChange(lz.pivot)},et._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=cS.clamp(e.x,0,1),r=cS.clamp(e.y,0,1);e.set(t,r,cS.clamp(e.z,0,1-t),cS.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lz.border),e._onValueChanged=this._onBorderChange},cU(ee,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(lz.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lz.size))}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dispatchSpriteChange(lz.size))}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dispatchSpriteChange(lz.size))}},{key:"atlasRotated",get:function(){return this._atlasRotated},set:function(e){this._atlasRotated!=e&&(this._atlasRotated=e)}},{key:"atlasRegion",get:function(){return this._atlasRegion},set:function(e){var t=cS.clamp(e.x,0,1),r=cS.clamp(e.y,0,1);this._atlasRegion.set(t,r,cS.clamp(e.width,0,1-t),cS.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lz.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lz.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=cS.clamp(e.x,0,1),r=cS.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,cS.clamp(e.z,0,1-t),cS.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lz.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lz.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),ee);(er=lU||(lU={}))[er.positions=1]="positions",er[er.uvs=2]="uvs",er[er.automaticSize=4]="automaticSize",er[er.all=7]="all";var c5=((ea=(en=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},ea.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ea.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ea.dispatch=function(e,t){if(!this._events[e])return!1;var r=this._events[e];if(Array.isArray(r)){var n=r.length,a=en._dispatchingListenersPool,i=a.length>0?a.pop():[];i.length=n;for(var o=0;o<n;o++)i[o]=r[o];for(var s=0;s<n;s++){var l=i[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}i.length=0,a.push(i)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},ea.on=function(e,t){return this._addEventListener(e,t)},ea.once=function(e,t){return this._addEventListener(e,t,!0)},ea.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var r=this._events[e],n=Array.isArray(r);if(n||r.fn!==t){if(n){for(var a=r.length-1;a>=0;a--)r[a].fn===t&&(r[a].destroyed=!0,r.splice(a,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},ea.removeEventListener=function(e,t){return this.off(e,t)},ea.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ea._addEventListener=function(e,t,r){var n={fn:t,once:r},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(n):a[e]=[i,n]:(a[e]=n,this._eventCount++),this},ea._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},en);c5._dispatchingListenersPool=[];var c9=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},c6=console.log.bind(console),c7=console.info.bind(console),de=console.warn.bind(console),dt=console.error.bind(console),dr={debug:c9,info:c9,warn:c9,error:c9,isEnabled:!1,enable:function(){this.debug=c6,this.info=c7,this.warn=de,this.error=dt,this.isEnabled=!0},disable:function(){this.debug=c9,this.info=c9,this.warn=c9,this.error=c9,this.isEnabled=!1}},dn=function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return e.getByName=function(t){var r=e._propertyNameMap;if(null!=r[t])return r[t];var n=new e(t);return r[t]=n,e._propertyIdMap[n._uniqueId]=n,n},e._getShaderPropertyGroup=function(t){var r=e._propertyNameMap[t];return null==r?void 0:r._group},cU(e,[{key:"type",get:function(){return this._type}}]),e}();dn._propertyIdMap=Object.create(null),dn._propertyNameCounter=0,dn._propertyNameMap=Object.create(null);var da=((eo=(ei=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new cB,this._deltaTimeValue=new cB,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},eo._update=function(){var e=performance.now()/1e3,t=e-this._lastSystemTime;this._actualDeltaTime=t,this._actualElapsedTime+=t;var r=Math.min(t,this.maximumDeltaTime)*this.timeScale;this._deltaTime=r,this._elapsedTime+=r,this._frameCount++,this._lastSystemTime=e},eo._updateSceneShaderData=function(e){var t=this._elapsedTimeValue,r=this._deltaTimeValue,n=this._elapsedTime;t.set(n,Math.sin(n),Math.cos(n),0),e.setVector4(ei._elapsedTimeProperty,t),r.set(this._deltaTime,0,0,0),e.setVector4(ei._deltaTimeProperty,r)},cU(ei,[{key:"frameCount",get:function(){return this._frameCount}},{key:"deltaTime",get:function(){return this._deltaTime}},{key:"elapsedTime",get:function(){return this._elapsedTime}},{key:"actualDeltaTime",get:function(){return this._actualDeltaTime}},{key:"actualElapsedTime",get:function(){return this._actualElapsedTime}}]),ei);da._elapsedTimeProperty=dn.getByName("scene_ElapsedTime"),da._deltaTimeProperty=dn.getByName("scene_DeltaTime"),e.DataType=void 0,(es=e.DataType||(e.DataType={}))[es.FLOAT=5126]="FLOAT",es[es.FLOAT_VEC2=35664]="FLOAT_VEC2",es[es.FLOAT_VEC3=35665]="FLOAT_VEC3",es[es.FLOAT_VEC4=35666]="FLOAT_VEC4",es[es.INT=5124]="INT",es[es.INT_VEC2=35667]="INT_VEC2",es[es.INT_VEC3=35668]="INT_VEC3",es[es.INT_VEC4=35669]="INT_VEC4",es[es.BOOL=35670]="BOOL",es[es.BOOL_VEC2=35671]="BOOL_VEC2",es[es.BOOL_VEC3=35672]="BOOL_VEC3",es[es.BOOL_VEC4=35673]="BOOL_VEC4",es[es.FLOAT_MAT2=35674]="FLOAT_MAT2",es[es.FLOAT_MAT3=35675]="FLOAT_MAT3",es[es.FLOAT_MAT4=35676]="FLOAT_MAT4",es[es.FLOAT_ARRAY=35677]="FLOAT_ARRAY",es[es.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",es[es.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",es[es.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",es[es.INT_ARRAY=100003]="INT_ARRAY",es[es.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",es[es.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",es[es.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",es[es.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",es[es.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",es[es.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",es[es.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",es[es.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",es[es.SAMPLER_2D=35678]="SAMPLER_2D",es[es.SAMPLER_CUBE=35680]="SAMPLER_CUBE",es[es.BYTE=5120]="BYTE",es[es.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",es[es.SHORT=5122]="SHORT",es[es.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",es[es.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(el=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",el.standardDerivatives="OES_standard_derivatives",el.shaderTextureLod="EXT_shader_texture_lod",el.elementIndexUint="OES_element_index_uint",el.depthTexture="WEBGL_depth_texture",el.drawBuffers="WEBGL_draw_buffers",el.vertexArrayObject="OES_vertex_array_object",el.instancedArrays="ANGLE_instanced_arrays",el.multipleSample="multipleSampleOnlySupportedInWebGL2",el.textureFloat="OES_texture_float",el.textureFloatLinear="OES_texture_float_linear",el.textureHalfFloat="OES_texture_half_float",el.textureHalfFloatLinear="OES_texture_half_float_linear",el.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",el.colorBufferFloat="EXT_color_buffer_float",el.colorBufferHalfFloat="EXT_color_buffer_half_float",el.textureFilterAnisotropic="EXT_texture_filter_anisotropic",el.blendMinMax="EXT_blend_minmax",el.fragDepth="EXT_frag_depth",el.astc="WEBGL_compressed_texture_astc",el.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",el.etc="WEBGL_compressed_texture_etc",el.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",el.etc1="WEBGL_compressed_texture_etc1",el.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",el.pvrtc="WEBGL_compressed_texture_pvrtc",el.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",el.s3tc="WEBGL_compressed_texture_s3tc",el.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",el.bptc="EXT_texture_compression_bptc",el.WEBGL_lose_context="WEBGL_lose_context",(ec=lG||(lG={}))[ec.None=0]="None",ec[ec.Scene=1]="Scene",ec[ec.Hierarchy=2]="Hierarchy",ec[ec.All=3]="All";var di=(cH(ed=function(e){var t;return(t=cJ.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},cJ),(eu=ed.prototype)._onAwake=function(){},eu._onEnable=function(){},eu._onDisable=function(){},eu._onEnableInScene=function(){},eu._onDisableInScene=function(){},eu._setActive=function(e,t){var r=this._entity;t&lG.Scene&&(e?!this._phasedActiveInScene&&r._isActiveInScene&&this._enabled&&(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&!(r._isActiveInScene&&this._enabled)&&(this._phasedActiveInScene=!1,this._onDisableInScene())),t&lG.Hierarchy&&(e?(!this._awoken&&r._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&r._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(r._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},eu._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},eu._onDestroy=function(){cJ.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},cU(ed,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?this._phasedActiveInScene||(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?this._phasedActive||(this._phasedActive=!0,this._onEnable()):this._phasedActive&&(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),ed);cW([cj],di.prototype,"_entity",void 0),cW([cj],di.prototype,"_awoken",void 0),cW([cj],di.prototype,"_phasedActiveInScene",void 0),cW([cj],di.prototype,"_phasedActive",void 0),cW([cX],di.prototype,"_enabled",void 0);var ds=((eh=function(){})._addCheck=function(e,t){for(;t!==di;){var r=eh._dependenciesMap.get(t);if(r)for(var n=r.components,a=r.mode,i=0,o=n.length;i<o;i++){var s=n[i];if(!e.getComponent(s)){if(1===a)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},eh._removeCheck=function(e,t){for(;t!==di;){var r=eh._invDependenciesMap.get(t);if(r){for(var n=0,a=r.length;n<a;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eh._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eh._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eh);function dl(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){ds._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return ds._addInvDependency(t,e)})}}ds._invDependenciesMap=new Map,ds._dependenciesMap=new Map,e.DependentMode=void 0,(e_=e.DependentMode||(e.DependentMode={}))[e_.CheckOnly=0]="CheckOnly",e_[e_.AutoAdd=1]="AutoAdd";var dc=((ep=(ef=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},ep.destroy=function(){this._removeFromManagers(),this._flagManagers=null},ep._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)c0.removeFromArray(e[t]._updateFlags,this)},cH(em=function(){var e;return e=ef.apply(this,arguments)||this,e.flag=!0,e},ef),em.prototype.dispatch=function(){this.flag=!0},em),dd=(cH(eg=function(e){var t;return(t=di.call(this,e)||this)._position=new cC,t._rotation=new cC,t._rotationQuaternion=new cP,t._scale=new cC(1,1,1),t._worldPosition=new cC,t._worldRotation=new cC,t._worldRotationQuaternion=new cP,t._lossyWorldScale=new cC(1,1,1),t._localMatrix=new cF,t._worldMatrix=new cF,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new c4,t._onPositionChanged=t._onPositionChanged.bind(ck(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(ck(t)),t._onRotationChanged=t._onRotationChanged.bind(ck(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(ck(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(ck(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(ck(t)),t._onScaleChanged=t._onScaleChanged.bind(ck(t)),t._position._onValueChanged=t._onPositionChanged,t._worldPosition._onValueChanged=t._onWorldPositionChanged,t._rotation._onValueChanged=t._onRotationChanged,t._worldRotation._onValueChanged=t._onWorldRotationChanged,t._rotationQuaternion._onValueChanged=t._onRotationQuaternionChanged,t._worldRotationQuaternion._onValueChanged=t._onWorldRotationQuaternionChanged,t._scale._onValueChanged=t._onScaleChanged,t},di),(ev=eg.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},ev.setRotation=function(e,t,r){this._rotation.set(e,t,r)},ev.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},ev.setScale=function(e,t,r){this._scale.set(e,t,r)},ev.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},ev.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},ev.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},ev.translate=function(e,t,r,n){if("number"==typeof e){var a=eg._tempVec30;a.set(e,t,r),this._translate(a,n)}else this._translate(e,t)},ev.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},ev.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*cS.degreeToRadFactor;cP.rotationAxisAngle(e,n,eg._tempQuat0),this._rotateByQuat(eg._tempQuat0,r)},ev.lookAt=function(e,t){var r=eg._tempVec30;cC.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=cS.zeroTolerance)){r.scale(1/n);var a=eg._tempVec31;if(t?cC.cross(t,r,a):a.set(r.z,0,-r.x),!((n=a.length())<=cS.zeroTolerance)){a.scale(1/n);var i=eg._tempVec32;cC.cross(r,a,i);var o=eg._tempMat41,s=o.elements;s[0]=a.x,s[1]=a.y,s[2]=a.z,s[4]=i.x,s[5]=i.y,s[6]=i.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},ev.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(dc)},ev._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},ev._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},ev._onDestroy=function(){di.prototype._onDestroy.call(this),this._worldPosition._onValueChanged=null,this._rotation._onValueChanged=null,this._worldRotation._onValueChanged=null,this._rotationQuaternion._onValueChanged=null,this._worldRotationQuaternion._onValueChanged=null,this._position._onValueChanged=null,this._scale._onValueChanged=null},ev._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)){this._worldAssociatedChange(132);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionFlag()}},ev._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)){this._worldAssociatedChange(152);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndRotationFlag()}},ev._updateWorldPositionAndRotationFlag=function(){if(!this._isContainDirtyFlags(156)){this._worldAssociatedChange(156);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndRotationFlag()}},ev._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)){this._worldAssociatedChange(160);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndScaleFlag()}},ev._updateWorldPositionAndScaleFlag=function(){if(!this._isContainDirtyFlags(164)){this._worldAssociatedChange(164);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateWorldPositionAndScaleFlag()}},ev._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)){this._worldAssociatedChange(188);for(var e,t=this._entity._children,r=0,n=t.length;r<n;r++)null==(e=t[r].transform)||e._updateAllWorldFlag()}},ev._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;for(var e=null,t=this._entity.parent;t;){var r=t.transform;if(r){e=r;break}t=t.parent}return this._parentTransformCache=e,this._isParentDirty=!1,e},ev._getScaleMatrix=function(){var e=eg._tempQuat0,t=eg._tempMat30,r=eg._tempMat31,n=eg._tempMat32;return r.copyFromMatrix(this.worldMatrix),cP.invert(this.worldRotationQuaternion,e),cw.rotationQuaternion(e,t),cw.multiply(t,r,n),n},ev._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},ev._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ev._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ev._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ev._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},ev._rotateByQuat=function(e,t){t?cP.multiply(this.rotationQuaternion,e,this._rotationQuaternion):cP.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},ev._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=eg._tempVec30;cC.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},ev._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var a=cS.degreeToRadFactor,i=eg._tempQuat0;cP.rotationEuler(e*a,t*a,r*a,i),this._rotateByQuat(i,n)},ev._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},ev._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(cF.invert(t.worldMatrix,eg._tempMat41),cC.transformCoordinate(e,eg._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},ev._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},ev._onWorldRotationChanged=function(){var e=this._worldRotation;cP.rotationEuler(cS.degreeToRadian(e.x),cS.degreeToRadian(e.y),cS.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},ev._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},ev._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=eg._tempQuat0;cP.invert(t.worldRotationQuaternion,r),cP.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},ev._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},cU(eg,[{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"worldPosition",get:function(){var e=this._worldPosition;return this._isContainDirtyFlag(4)&&(e._onValueChanged=null,this._getParentTransform()?this.worldMatrix.getTranslation(e):e.copyFrom(this._position),e._onValueChanged=this._onWorldPositionChanged,this._setDirtyFlagFalse(4)),e},set:function(e){this._worldPosition!==e&&this._worldPosition.copyFrom(e)}},{key:"rotation",get:function(){var e=this._rotation;return this._isContainDirtyFlag(1)&&(e._onValueChanged=null,this._rotationQuaternion.toEuler(e),e.scale(cS.radToDegreeFactor),e._onValueChanged=this._onRotationChanged,this._setDirtyFlagFalse(1)),e},set:function(e){this._rotation!==e&&this._rotation.copyFrom(e)}},{key:"worldRotation",get:function(){var e=this._worldRotation;return this._isContainDirtyFlag(8)&&(e._onValueChanged=null,this.worldRotationQuaternion.toEuler(e),e.scale(cS.radToDegreeFactor),e._onValueChanged=this._onWorldRotationChanged,this._setDirtyFlagFalse(8)),e},set:function(e){this._worldRotation!==e&&this._worldRotation.copyFrom(e)}},{key:"rotationQuaternion",get:function(){var e=this._rotationQuaternion;return this._isContainDirtyFlag(2)&&(e._onValueChanged=null,cP.rotationEuler(cS.degreeToRadian(this._rotation.x),cS.degreeToRadian(this._rotation.y),cS.degreeToRadian(this._rotation.z),e),e._onValueChanged=this._onRotationQuaternionChanged,this._setDirtyFlagFalse(2)),e},set:function(e){this._rotationQuaternion!==e?e.normalized?this._rotationQuaternion.copyFrom(e):cP.normalize(e,this._rotationQuaternion):e.normalized||e.normalize()}},{key:"worldRotationQuaternion",get:function(){var e=this._worldRotationQuaternion;if(this._isContainDirtyFlag(16)){e._onValueChanged=null;var t=this._getParentTransform();null!=t?cP.multiply(t.worldRotationQuaternion,this.rotationQuaternion,e):e.copyFrom(this.rotationQuaternion),e._onValueChanged=this._onWorldRotationQuaternionChanged,this._setDirtyFlagFalse(16)}return e},set:function(e){this._worldRotationQuaternion!==e&&(e.normalized?this._worldRotationQuaternion.copyFrom(e):cP.normalize(e,this._worldRotationQuaternion)),e.normalized||e.normalize()}},{key:"scale",get:function(){return this._scale},set:function(e){this._scale!==e&&this._scale.copyFrom(e)}},{key:"lossyWorldScale",get:function(){if(this._isContainDirtyFlag(32)){if(this._getParentTransform()){var e=this._getScaleMatrix().elements;this._lossyWorldScale.set(e[0],e[4],e[8])}else this._lossyWorldScale.copyFrom(this._scale);this._setDirtyFlagFalse(32)}return this._lossyWorldScale}},{key:"localMatrix",get:function(){return this._isContainDirtyFlag(64)&&(cF.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(e){this._localMatrix!==e&&this._localMatrix.copyFrom(e),this._position._onValueChanged=this._rotationQuaternion._onValueChanged=this._scale._onValueChanged=null,this._localMatrix.decompose(this._position,this._rotationQuaternion,this._scale),this._position._onValueChanged=this._onPositionChanged,this._rotationQuaternion._onValueChanged=this._onRotationQuaternionChanged,this._scale._onValueChanged=this._onScaleChanged,this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(66),this._updateAllWorldFlag()}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var e=this._getParentTransform();e?cF.multiply(e.worldMatrix,this.localMatrix,this._worldMatrix):this._worldMatrix.copyFrom(this.localMatrix),this._setDirtyFlagFalse(128)}return this._worldMatrix},set:function(e){this._worldMatrix!==e&&this._worldMatrix.copyFrom(e);var t=this._getParentTransform();t?(cF.invert(t.worldMatrix,eg._tempMat42),cF.multiply(eg._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new cC),t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()}},{key:"worldRight",get:function(){var e=this._worldRight||(this._worldRight=new cC),t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()}},{key:"worldUp",get:function(){var e=this._worldUp||(this._worldUp=new cC),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eg);dd._tempQuat0=new cP,dd._tempVec30=new cC,dd._tempVec31=new cC,dd._tempVec32=new cC,dd._tempMat30=new cw,dd._tempMat31=new cw,dd._tempMat32=new cw,dd._tempMat41=new cF,dd._tempMat42=new cF,cW([cY],dd.prototype,"_position",void 0),cW([cY],dd.prototype,"_rotation",void 0),cW([cY],dd.prototype,"_rotationQuaternion",void 0),cW([cY],dd.prototype,"_scale",void 0),cW([cY],dd.prototype,"_worldPosition",void 0),cW([cY],dd.prototype,"_worldRotation",void 0),cW([cY],dd.prototype,"_worldRotationQuaternion",void 0),cW([cY],dd.prototype,"_lossyWorldScale",void 0),cW([cY],dd.prototype,"_localMatrix",void 0),cW([cY],dd.prototype,"_worldMatrix",void 0),cW([cj],dd.prototype,"_worldForward",void 0),cW([cj],dd.prototype,"_worldRight",void 0),cW([cj],dd.prototype,"_worldUp",void 0),cW([cj],dd.prototype,"_isParentDirty",void 0),cW([cj],dd.prototype,"_parentTransformCache",void 0),cW([cj],dd.prototype,"_updateFlagManager",void 0),cW([cj],dd.prototype,"_onPositionChanged",null),cW([cj],dd.prototype,"_onWorldPositionChanged",null),cW([cj],dd.prototype,"_onRotationChanged",null),cW([cj],dd.prototype,"_onWorldRotationChanged",null),cW([cj],dd.prototype,"_onRotationQuaternionChanged",null),cW([cj],dd.prototype,"_onWorldRotationQuaternionChanged",null),cW([cj],dd.prototype,"_onScaleChanged",null),(ey=lH||(lH={}))[ey.LocalEuler=1]="LocalEuler",ey[ey.LocalQuat=2]="LocalQuat",ey[ey.WorldPosition=4]="WorldPosition",ey[ey.WorldEuler=8]="WorldEuler",ey[ey.WorldQuat=16]="WorldQuat",ey[ey.WorldScale=32]="WorldScale",ey[ey.LocalMatrix=64]="LocalMatrix",ey[ey.WorldMatrix=128]="WorldMatrix",ey[ey.WmWp=132]="WmWp",ey[ey.WmWeWq=152]="WmWeWq",ey[ey.WmWpWeWq=156]="WmWpWeWq",ey[ey.WmWs=160]="WmWs",ey[ey.WmWpWs=164]="WmWpWs",ey[ey.WmWpWeWqWs=188]="WmWpWeWqWs",e.BlendFactor=void 0,(ex=e.BlendFactor||(e.BlendFactor={}))[ex.Zero=0]="Zero",ex[ex.One=1]="One",ex[ex.SourceColor=2]="SourceColor",ex[ex.OneMinusSourceColor=3]="OneMinusSourceColor",ex[ex.DestinationColor=4]="DestinationColor",ex[ex.OneMinusDestinationColor=5]="OneMinusDestinationColor",ex[ex.SourceAlpha=6]="SourceAlpha",ex[ex.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",ex[ex.DestinationAlpha=8]="DestinationAlpha",ex[ex.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",ex[ex.SourceAlphaSaturate=10]="SourceAlphaSaturate",ex[ex.BlendColor=11]="BlendColor",ex[ex.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eb=e.BlendOperation||(e.BlendOperation={}))[eb.Add=0]="Add",eb[eb.Subtract=1]="Subtract",eb[eb.ReverseSubtract=2]="ReverseSubtract",eb[eb.Min=3]="Min",eb[eb.Max=4]="Max",e.ColorWriteMask=void 0,(eS=e.ColorWriteMask||(e.ColorWriteMask={}))[eS.None=0]="None",eS[eS.Red=1]="Red",eS[eS.Green=2]="Green",eS[eS.Blue=4]="Blue",eS[eS.Alpha=8]="Alpha",eS[eS.All=15]="All",e.CompareFunction=void 0,(eC=e.CompareFunction||(e.CompareFunction={}))[eC.Never=0]="Never",eC[eC.Less=1]="Less",eC[eC.Equal=2]="Equal",eC[eC.LessEqual=3]="LessEqual",eC[eC.Greater=4]="Greater",eC[eC.NotEqual=5]="NotEqual",eC[eC.GreaterEqual=6]="GreaterEqual",eC[eC.Always=7]="Always",e.CullMode=void 0,(eT=e.CullMode||(e.CullMode={}))[eT.Off=0]="Off",eT[eT.Front=1]="Front",eT[eT.Back=2]="Back",e.RenderStateDataKey=void 0,(eA=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eA.BlendStateEnabled0=0]="BlendStateEnabled0",eA[eA.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eA[eA.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eA[eA.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eA[eA.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eA[eA.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eA[eA.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eA[eA.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eA[eA.BlendStateBlendColor=8]="BlendStateBlendColor",eA[eA.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eA[eA.DepthStateEnabled=10]="DepthStateEnabled",eA[eA.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eA[eA.DepthStateCompareFunction=12]="DepthStateCompareFunction",eA[eA.StencilStateEnabled=13]="StencilStateEnabled",eA[eA.StencilStateReferenceValue=14]="StencilStateReferenceValue",eA[eA.StencilStateMask=15]="StencilStateMask",eA[eA.StencilStateWriteMask=16]="StencilStateWriteMask",eA[eA.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eA[eA.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eA[eA.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eA[eA.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eA[eA.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eA[eA.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eA[eA.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eA[eA.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eA[eA.RasterStateCullMode=25]="RasterStateCullMode",eA[eA.RasterStateDepthBias=26]="RasterStateDepthBias",eA[eA.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",eA[eA.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(eM=e.RenderQueueType||(e.RenderQueueType={}))[eM.Opaque=0]="Opaque",eM[eM.AlphaTest=1]="AlphaTest",eM[eM.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eE=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eE.Float=0]="Float",eE[eE.Int=1]="Int",eE[eE.Vector2=2]="Vector2",eE[eE.Vector3=3]="Vector3",eE[eE.Vector4=4]="Vector4",eE[eE.Matrix=5]="Matrix",eE[eE.Color=6]="Color",eE[eE.Texture=7]="Texture",eE[eE.FloatArray=8]="FloatArray",eE[eE.IntArray=9]="IntArray",eE[eE.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eR=e.StencilOperation||(e.StencilOperation={}))[eR.Keep=0]="Keep",eR[eR.Zero=1]="Zero",eR[eR.Replace=2]="Replace",eR[eR.IncrementSaturate=3]="IncrementSaturate",eR[eR.DecrementSaturate=4]="DecrementSaturate",eR[eR.Invert=5]="Invert",eR[eR.IncrementWrap=6]="IncrementWrap",eR[eR.DecrementWrap=7]="DecrementWrap";var du=function(){function e(t,r,n,a){this.name=t,this._maskIndex=n,this._maskValue=a,this.value=r;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,a=e._macroMap[n];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,r,s,1<<l),e._macroMap[n]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=n,e._macroCounter++}return a},e._getNamesByMacros=function(t,r){var n=e._macroMaskMap,a=t._mask;r.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=n[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,d=0;d<c;d++)l&1<<d&&r.push(s[d])},e}();du._macroMaskMap=[],du._macroNameIdMap=Object.create(null),du._macroNameCounter=0,du._macroCounter=0,du._macroMap=Object.create(null);var dh=((eP=(ew=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,a=this._length;if(a<r){for(n.length<r&&(n.length=r);a<t;a++)n[a]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},eP.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var a=r[t]&~e._maskValue;t==n&&0===a?this._length--:r[t]=a}},eP.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,a=this._length;if(a<r){n.length<r&&(n.length=r);for(var i=0;i<a;i++)n[i]|=t[i];for(;i<r;i++)n[i]=t[i];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},eP.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,a=Math.min(e._length-1,n);a>=0;a--){var i=r[a]&~t[a];a==n&&0===i?(n--,this._length--):r[a]=i}},eP.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var a=r[n]&t[n];0==a&&n==this._length-1?this._length--:r[n]=a}},eP.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},eP.clear=function(){this._length=0},ew.unionCollection=function(e,t,r){var n,a,i,o,s=r._mask;e._length<t._length?(n=e._length,a=t._length,i=e._mask,o=t._mask):(n=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<n;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];r._length=a},ew);function d_(){return(d_=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}e.PipelineStage=void 0,(eF=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",eF.ShadowCaster="ShadowCaster",eF.Forward="Forward";var df=d_({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return MIN_PERCEPTUAL_ROUGHNESS+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn MIN_PERCEPTUAL_ROUGHNESS;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;highp vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);highp float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge)evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=colorKeys[0].y;}else{vec2 lastKey=alphaKeys[i-1];float lastTime=lastKey.x;float age=(alphaAge-lastTime)/(time-lastTime);value.a=mix(lastKey.y,key.y,age);}break;}}float colorAge=min(normalizedAge,colorKeysMaxTime);for(int i=0;i<4;i++){vec4 key=colorKeys[i];float time=key.x;if(colorAge<=time){if(i==0){value.rgb=colorKeys[0].yzw;}else{vec4 lastKey=colorKeys[i-1];float lastTime=lastKey.x;float age=(colorAge-lastTime)/(time-lastTime);value.rgb=mix(lastKey.yzw,key.yzw,age);}break;}}return value;}\n#endif\nvec4 computeParticleColor(in vec4 color,in float normalizedAge){\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 gradientColor=evaluateParticleGradient(renderer_COLMaxGradientColor,renderer_COLGradientKeysMaxTime.z,renderer_COLMaxGradientAlpha,renderer_COLGradientKeysMaxTime.w,normalizedAge);\n#endif\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\ngradientColor=mix(evaluateParticleGradient(renderer_COLMinGradientColor,renderer_COLGradientKeysMaxTime.x,renderer_COLMinGradientAlpha,renderer_COLGradientKeysMaxTime.y,normalizedAge),gradientColor,a_Random0.y);\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\ncolor*=gradientColor;\n#endif\nreturn color;}",texture_sheet_animation_module:"#define GLSLIFY 1\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nuniform float renderer_TSACycles;uniform vec3 renderer_TSATillingParams;uniform vec2 renderer_TSAFrameMaxCurve[4];\n#endif\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\nvec2 computeParticleUV(in vec2 uv,in float normalizedAge){\n#if defined(RENDERER_TSA_FRAME_CURVE) || defined(RENDERER_TSA_FRAME_RANDOM_CURVES)\nfloat scaledNormalizedAge=normalizedAge*renderer_TSACycles;float cycleNormalizedAge=scaledNormalizedAge-floor(scaledNormalizedAge);float normalizedFrame=evaluateParticleCurve(renderer_TSAFrameMaxCurve,cycleNormalizedAge);\n#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nnormalizedFrame=mix(evaluateParticleCurve(renderer_TSAFrameMinCurve,cycleNormalizedAge),normalizedFrame,a_Random1.x);\n#endif\nfloat frame=floor(normalizedFrame*renderer_TSATillingParams.z);float totalULength=frame*renderer_TSATillingParams.x;float floorTotalULength=floor(totalULength);uv.x+=totalULength-floorTotalULength;uv.y+=floorTotalULength*renderer_TSATillingParams.y;\n#endif\nreturn uv;}",sphere_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_SPHERE_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 sideVector=normalize(cross(camera_Forward,camera_Up));vec3 upVector=normalize(cross(sideVector,camera_Forward));corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,rotation);}else{float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#else\nif(renderer_ThreeDStartRotation){center+=renderer_SizeScale.xzy*rotationByEuler(corner.x*sideVector+corner.y*upVector,a_StartRotation0);}else{float c=cos(a_StartRotation0.x);float s=sin(a_StartRotation0.x);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner;center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*upVector);}\n#endif\n#endif\n",stretched_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nif(renderer_VOLSpace==0){velocity=rotationByQuaternions(renderer_SizeScale*(startVelocity+lifeVelocity),worldRotation)+gravityVelocity;}else{velocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+lifeVelocity+gravityVelocity;}\n#else\nvelocity=rotationByQuaternions(renderer_SizeScale*startVelocity,worldRotation)+gravityVelocity;\n#endif\nvec3 cameraUpVector=normalize(velocity);vec3 direction=normalize(center-camera_Position);vec3 sideVector=normalize(cross(direction,normalize(velocity)));sideVector=renderer_SizeScale.xzy*sideVector;cameraUpVector=length(vec3(renderer_SizeScale.x,0.0,0.0))*cameraUpVector;vec2 size=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);const mat2 rotationZHalfPI=mat2(0.0,-1.0,1.0,0.0);corner=rotationZHalfPI*corner;corner.y=corner.y-abs(corner.y);float speed=length(velocity);center+=sign(renderer_SizeScale.x)*(sign(renderer_StretchedBillboardLengthScale)*size.x*corner.x*sideVector+(speed*renderer_StretchedBillboardSpeedScale+size.y*renderer_StretchedBillboardLengthScale)*corner.y*cameraUpVector);\n#endif\n",vertical_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_VERTICAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,1.0,0.0);vec3 sideVector=normalize(cross(camera_Forward,cameraUpVector));float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",horizontal_billboard:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_HORIZONTAL_BILLBOARD\nvec2 corner=a_CornerTextureCoordinate.xy+renderer_PivotOffset.xy;const vec3 cameraUpVector=vec3(0.0,0.0,1.0);const vec3 sideVector=vec3(-1.0,0.0,0.0);float rot=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);float c=cos(rot);float s=sin(rot);mat2 rotation=mat2(c,-s,s,c);corner=rotation*corner*cos(0.78539816339744830961566084581988);corner*=computeParticleSizeBillboard(a_StartSize.xy,normalizedAge);center+=renderer_SizeScale.xzy*(corner.x*sideVector+corner.y*cameraUpVector);\n#endif\n",particle_mesh:"#define GLSLIFY 1\n#ifdef RENDERER_MODE_MESH\nvec3 size=computeParticleSizeMesh(a_StartSize,normalizedAge);\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\nif(renderer_ThreeDStartRotation){vec3 rotation=vec3(a_StartRotation0.xy,computeParticleRotationFloat(a_StartRotation0.z,age,normalizedAge));center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,rotation),worldRotation);}else{\n#ifdef RENDERER_ROL_IS_SEPARATE\nfloat angle=computeParticleRotationFloat(a_StartRotation0.x,age,normalizedAge);if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){center+=(rotationByQuaternions(rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),angle),worldRotation));}else{\n#ifdef SHAPE\ncenter+=renderer_SizeScale.xzy*(rotationByQuaternions(rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),angle),worldRotation));\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),angle),worldRotation);\n#endif\n}\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\nvec3 angle=computeParticleRotationVec3(vec3(0.0,0.0,-a_StartRotation0.x),age,normalizedAge);center+=(rotationByQuaternions(rotationByEuler(renderer_SizeScale*a_MeshPosition*size,vec3(angle.x,angle.y,angle.z)),worldRotation));\n#endif\n}\n#else\nif(renderer_ThreeDStartRotation){center+=rotationByQuaternions(renderer_SizeScale*rotationByEuler(a_MeshPosition*size,a_StartRotation0),worldRotation);}else{if(a_ShapePositionStartLifeTime.x!=0.0||a_ShapePositionStartLifeTime.y!=0.0){if(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=(rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,normalize(cross(vec3(0.0,0.0,1.0),vec3(a_ShapePositionStartLifeTime.xy,0.0))),a_StartRotation0.x),worldRotation));}else{\n#ifdef SHAPE\nif(renderer_SimulationSpace==1)center+=renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,-1.0,0.0),a_StartRotation0.x),worldRotation);\n#else\nif(renderer_SimulationSpace==1)center+=rotationByAxis(renderer_SizeScale*a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x);else if(renderer_SimulationSpace==0)center+=rotationByQuaternions(renderer_SizeScale*rotationByAxis(a_MeshPosition*size,vec3(0.0,0.0,-1.0),a_StartRotation0.x),worldRotation);\n#endif\n}}\n#endif\nv_MeshColor=a_MeshColor;\n#endif\n"}),dp=((eL=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},eL.registerInclude=function(e,t){if(df[e])throw'The "'+e+'" shader include already exist';df[e]=t},eL.unRegisterInclude=function(e){delete df[e]},eL.parseIncludes=function(e,t){return void 0===t&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm),e.replace(t,function(e,r){var n=df[r];return void 0===n?(dr.error('Shader slice "'+e.trim()+'" not founded.'),""):eL.parseIncludes(n,t)})},eL.convertTo300=function(e,t){if(e=(e=(e=e.replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),t){if(e=(e=(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!eL._has300Output(e)){if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,r)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else e=e.replace(/\battribute\b/g,"in");return e},eL._has300Output=function(e){return eL._has300OutInFragReg.test(e)},eL._replaceMRTShader=function(e,t){for(var r="",n=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);n.add(i[1])}return n.forEach(function(e){r+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),r+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},eL);dp._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),dp._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var dm=function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var r=e._nameMap;return r[t]||(r[t]=new e(t))},e}();dm._nameCounter=0,dm._nameMap=Object.create(null);var dg=((eB=(eD=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?dm.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&dr.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},eB.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?dm.getByName(e):e)._uniqueId]},eB.getTagValue=function(e){return this._tagsMap["string"==typeof e?dm.getByName(e)._uniqueId:e._uniqueId]},cU(eD,[{key:"name",get:function(){return this._name}}]),eD);e.ColorSpace=void 0,(eI=e.ColorSpace||(e.ColorSpace={}))[eI.Linear=0]="Linear",eI[eI.Gamma=1]="Gamma";var dv=((eO=(eV=function(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}).prototype).upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},eO.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},eO.upload2f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform2f(t.location,cI.gammaToLinearSpace(r.r),cI.gammaToLinearSpace(r.g)):this._gl.uniform2f(t.location,r.r,r.g),n.x=r.r,n.y=r.g):(n.x!==r.x||n.y!==r.y)&&(this._gl.uniform2f(t.location,r.x,r.y),n.x=r.x,n.y=r.y)},eO.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},eO.upload3f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g||n.z!==r.b)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform3f(t.location,cI.gammaToLinearSpace(r.r),cI.gammaToLinearSpace(r.g),cI.gammaToLinearSpace(r.b)):this._gl.uniform3f(t.location,r.r,r.g,r.b),n.x=r.r,n.y=r.g,n.z=r.b):(n.x!==r.x||n.y!==r.y||n.z!==r.z)&&(this._gl.uniform3f(t.location,r.x,r.y,r.z),n.x=r.x,n.y=r.y,n.z=r.z)},eO.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},eO.upload4f=function(t,r){var n=this.cacheValue;void 0!==r.r?(n.x!==r.r||n.y!==r.g||n.z!==r.b||n.w!==r.a)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform4f(t.location,cI.gammaToLinearSpace(r.r),cI.gammaToLinearSpace(r.g),cI.gammaToLinearSpace(r.b),r.a):this._gl.uniform4f(t.location,r.r,r.g,r.b,r.a),n.x=r.r,n.y=r.g,n.z=r.b,n.w=r.a):(n.x!==r.x||n.y!==r.y||n.z!==r.z||n.w!==r.w)&&(this._gl.uniform4f(t.location,r.x,r.y,r.z,r.w),n.x=r.x,n.y=r.y,n.z=r.z,n.w=r.w)},eO.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},eO.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},eO.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},eO.upload2i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),r.x=t.r,r.y=t.g):(r.x!==t.x||r.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),r.x=t.x,r.y=t.y)},eO.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},eO.upload3i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g||r.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),r.x=t.r,r.y=t.g,r.z=t.b):(r.x!==t.x||r.y!==t.y||r.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),r.x=t.x,r.y=t.y,r.z=t.z)},eO.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},eO.upload4i=function(e,t){var r=this.cacheValue;void 0!==t.r?(r.x!==t.r||r.y!==t.g||r.z!==t.b||r.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),r.x=t.r,r.y=t.g,r.z=t.b,r.w=t.a):(r.x!==t.x||r.y!==t.y||r.z!==t.z||r.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),r.x=t.x,r.y=t.y,r.z=t.z,r.w=t.w)},eO.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},eO.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},eO.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},eO.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},eO.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,a=0;a<t.length;a++){var i=t[a];r.activeTexture(n[a]),r.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},eV),dy=function(){this.constUniforms=[],this.textureUniforms=[]};(eN=lW||(lW={}))[eN.Scene=0]="Scene",eN[eN.Camera=1]="Camera",eN[eN.Renderer=2]="Renderer",eN[eN.Material=3]="Material";var dx=function(){function e(t,r,n){this.sceneUniformBlock=new dy,this.cameraUniformBlock=new dy,this.rendererUniformBlock=new dy,this.materialUniformBlock=new dy,this.otherUniformBlock=new dy,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(r,n),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var r=t._propertyValueMap,n=e.constUniforms,a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var r=t._propertyValueMap,n=e.textureUniforms;if(n)for(var a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,r=e.length;t<r;t++){var n=e[t];n.applyFunc(n,n.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,r=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r],a=dn._getShaderPropertyGroup(n.name);void 0!==a&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,a,t))}},t._groupingUniform=function(e,t,r){switch(t){case lW.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case lW.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case lW.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case lW.Material:r?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;default:r?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var r=this._gl,n=this._createShader(r.VERTEX_SHADER,e);if(!n)return null;var a=this._createShader(r.FRAGMENT_SHADER,t);if(!a)return null;var i=r.createProgram();return i?(r.attachShader(i,n),r.attachShader(i,a),r.linkProgram(i),r.validateProgram(i),r.deleteShader(n),r.deleteShader(a),!dr.isEnabled||r.getProgramParameter(i,r.LINK_STATUS)||r.isContextLost())?i:(dr.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(i,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(i)),r.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,a=n.createShader(t);return a?(n.shaderSource(a,r),n.compileShader(a),!dr.isEnabled||n.getShaderParameter(a,n.COMPILE_STATUS)||n.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;n.forEach(function(n){var a,o=n.name,s=n.size,l=n.type,c=new dv(e._engine),d=!1,u=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),d=!0);var h=t.getUniformLocation(r,o);switch(c.name=o,c.propertyId=dn.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:d?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:d?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new cD(0,0));break;case t.FLOAT_VEC3:d?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new cC(0,0,0));break;case t.FLOAT_VEC4:d?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new cB(0,0,0,0));break;case t.BOOL:case t.INT:d?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:d?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new cD(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:d?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new cC(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:d?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new cB(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=d?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(u=!0,d){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=dn._getShaderPropertyGroup(o);e._groupingUniform(c,v,u)}),a.forEach(function(n){var a=n.name;e.attributeLocation[a]=t.getAttribLocation(r,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),a=0;a<r;++a){var i=e.getActiveUniform(t,a);n[a]=i}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<n;++a){var i=e.getActiveAttrib(t,a);r[a]=i}return r},e._addLineNum=function(e){var t,r=e.split("\n"),n=(r.length+1).toString().length+6;return r.map(function(e,r){if((t="0:"+(r+1)).length>=n)return t.substring(0,n)+e;for(var a=0;a<n-t.length;a++)t+=" ";return t+e}).join("\n")},cU(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();dx._counter=0;var db=function(t){function r(n,a,i,o){var s;for(var l in(s=t.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderProgramPools=[],s._shaderPassId=r._shaderPassCounter++,"string"==typeof i?(s._name=n,s._vertexSource=a,s._fragmentSource=i,o=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=a,o=null!=i?i:{pipelineStage:e.PipelineStage.Forward}),o)s.setTag(l,o[l]);return s}cH(r,t);var n=r.prototype;return n._getShaderProgram=function(t,r){var n=t._getShaderProgramPool(this),a=n.get(r);if(a)return a;var i=t._hardwareRenderer.isWebGL2,o=[];du._getNamesByMacros(r,o);var s=dp.parseCustomMacros(o),l=i?"#version 300 es":"#version 100",c=i?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",d="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&(d+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(d+="#define HAS_DERIVATIVES\n");var u=" "+l+"\n "+c+"\n "+s+"\n "+dp.parseIncludes(this._vertexSource),h=" "+l+"\n "+c+"\n "+(i?"":dp._shaderExtension)+"\n "+d+"\n "+s+"\n "+dp.parseIncludes(this._fragmentSource);return i&&(u=dp.convertTo300(u),h=dp.convertTo300(h,!0)),a=new dx(t,u,h),n.cache(a),a},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,r=e.length;t<r;t++)e[t]._destroy();e.length=0},r}(dg);db._shaderPassCounter=0;var dS=(cH(ek=function(e,t,r){var n;if((n=dg.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var a in n._passes=t.slice(),r)n.setTag(a,r[a]);return n},dg),cU(ek,[{key:"passes",get:function(){return this._passes}}]),ek),dC=function(){this.enabled=!1,this.colorBlendOperation=e.BlendOperation.Add,this.alphaBlendOperation=e.BlendOperation.Add,this.sourceColorBlendFactor=e.BlendFactor.One,this.sourceAlphaBlendFactor=e.BlendFactor.One,this.destinationColorBlendFactor=e.BlendFactor.Zero,this.destinationAlphaBlendFactor=e.BlendFactor.Zero,this.colorWriteMask=e.ColorWriteMask.All},dT=((eU=(ez=function(){this.targetBlendState=new dC,this.blendColor=new cI(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,d=this.targetBlendState,u=t[e.RenderStateDataKey.BlendStateEnabled0];if(void 0!==u){var h=r.getFloat(u);d.enabled=void 0!==h&&!!h}var _=t[e.RenderStateDataKey.BlendStateColorBlendOperation0];void 0!==_&&(d.colorBlendOperation=null!=(n=r.getFloat(_))?n:e.BlendOperation.Add);var f=t[e.RenderStateDataKey.BlendStateAlphaBlendOperation0];void 0!==f&&(d.alphaBlendOperation=null!=(a=r.getFloat(f))?a:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(d.sourceColorBlendFactor=null!=(i=r.getFloat(p))?i:e.BlendFactor.One);var m=t[e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0];void 0!==m&&(d.sourceAlphaBlendFactor=null!=(o=r.getFloat(m))?o:e.BlendFactor.One);var g=t[e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0];void 0!==g&&(d.destinationColorBlendFactor=null!=(s=r.getFloat(g))?s:e.BlendFactor.Zero);var v=t[e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0];void 0!==v&&(d.destinationAlphaBlendFactor=null!=(l=r.getFloat(v))?l:e.BlendFactor.Zero);var y=t[e.RenderStateDataKey.BlendStateColorWriteMask0];void 0!==y&&(d.colorWriteMask=null!=(c=r.getFloat(y))?c:e.ColorWriteMask.All);var x=t[e.RenderStateDataKey.BlendStateBlendColor];if(void 0!==x){var b=r.getColor(x);void 0!==b&&this.blendColor.copyFrom(b)}var S=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==S){var C=r.getFloat(S);this.alphaToCoverage=void 0!==C&&!!C}},eU._apply=function(e,t){this._platformApply(e,t.blendState)},eU._platformApply=function(t,r){var n=t.gl,a=r.targetBlendState,i=this.targetBlendState,o=i.enabled,s=i.colorBlendOperation,l=i.alphaBlendOperation,c=i.sourceColorBlendFactor,d=i.destinationColorBlendFactor,u=i.sourceAlphaBlendFactor,h=i.destinationAlphaBlendFactor,_=i.colorWriteMask;if(o!==a.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),a.enabled=o),o){(c!==a.sourceColorBlendFactor||d!==a.destinationColorBlendFactor||u!==a.sourceAlphaBlendFactor||h!==a.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(ez._getGLBlendFactor(t,c),ez._getGLBlendFactor(t,d),ez._getGLBlendFactor(t,u),ez._getGLBlendFactor(t,h)),a.sourceColorBlendFactor=c,a.destinationColorBlendFactor=d,a.sourceAlphaBlendFactor=u,a.destinationAlphaBlendFactor=h),(s!==a.colorBlendOperation||l!==a.alphaBlendOperation)&&(n.blendEquationSeparate(ez._getGLBlendOperation(t,s),ez._getGLBlendOperation(t,l)),a.colorBlendOperation=s,a.alphaBlendOperation=l);var f=this.blendColor;cI.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==a.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),a.colorWriteMask=_);var p=this.alphaToCoverage;p!==r.alphaToCoverage&&(p?n.enable(n.SAMPLE_ALPHA_TO_COVERAGE):n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),r.alphaToCoverage=p)},ez._getGLBlendFactor=function(t,r){var n=t.gl;switch(r){case e.BlendFactor.Zero:return n.ZERO;case e.BlendFactor.One:return n.ONE;case e.BlendFactor.SourceColor:return n.SRC_COLOR;case e.BlendFactor.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case e.BlendFactor.DestinationColor:return n.DST_COLOR;case e.BlendFactor.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case e.BlendFactor.SourceAlpha:return n.SRC_ALPHA;case e.BlendFactor.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case e.BlendFactor.DestinationAlpha:return n.DST_ALPHA;case e.BlendFactor.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case e.BlendFactor.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case e.BlendFactor.BlendColor:return n.CONSTANT_COLOR;case e.BlendFactor.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},ez._getGLBlendOperation=function(t,r){var n=t.gl;switch(r){case e.BlendOperation.Add:return n.FUNC_ADD;case e.BlendOperation.Subtract:return n.FUNC_SUBTRACT;case e.BlendOperation.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case e.BlendOperation.Min:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case e.BlendOperation.Max:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},ez);cW([cY],dT.prototype,"targetBlendState",void 0),cW([cY],dT.prototype,"blendColor",void 0);var dA=((eH=(eG=function(){this.enabled=!0,this.compareFunction=e.CompareFunction.Less,this.writeEnabled=!0}).prototype)._applyShaderDataValue=function(t,r){var n,a=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==a){var i=r.getFloat(a);this.enabled=void 0!==i&&!!i}var o=t[e.RenderStateDataKey.DepthStateWriteEnabled];if(void 0!==o){var s=r.getFloat(o);this.writeEnabled=void 0!==s&&!!s}var l=t[e.RenderStateDataKey.DepthStateCompareFunction];void 0!==l&&(this.compareFunction=null!=(n=r.getFloat(l))?n:e.CompareFunction.Less)},eH._apply=function(e,t){this._platformApply(e,t.depthState)},eH._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.compareFunction,i=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&a!=t.compareFunction&&(r.depthFunc(eG._getGLCompareFunction(e,a)),t.compareFunction=a),i!=t.writeEnabled&&(r.depthMask(i),t.writeEnabled=i)},eG._getGLCompareFunction=function(t,r){var n=t.gl;switch(r){case e.CompareFunction.Never:return n.NEVER;case e.CompareFunction.Less:return n.LESS;case e.CompareFunction.Equal:return n.EQUAL;case e.CompareFunction.LessEqual:return n.LEQUAL;case e.CompareFunction.Greater:return n.GREATER;case e.CompareFunction.NotEqual:return n.NOTEQUAL;case e.CompareFunction.GreaterEqual:return n.GEQUAL;case e.CompareFunction.Always:return n.ALWAYS}},eG),dM=((eK=(eW=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o=t[e.RenderStateDataKey.RasterStateCullMode];void 0!==o&&(this.cullMode=null!=(n=r.getFloat(o))?n:e.CullMode.Back);var s=t[e.RenderStateDataKey.RasterStateDepthBias];void 0!==s&&(this.depthBias=null!=(a=r.getFloat(s))?a:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(i=r.getFloat(l))?i:0)},eK._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},eK._platformApply=function(t,r,n){var a=t.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=i!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),r._cullFaceEnable=l),l&&i!==r.cullMode&&(i==e.CullMode.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),r.cullMode=i),n!==r._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},eW),dE=((eX=(ej=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,d,u,h,_,f=t[e.RenderStateDataKey.StencilStateEnabled];if(void 0!==f){var p=r.getFloat(f);this.enabled=void 0!==p&&!!p}var m=t[e.RenderStateDataKey.StencilStateReferenceValue];void 0!==m&&(this.referenceValue=null!=(n=r.getFloat(m))?n:0);var g=t[e.RenderStateDataKey.StencilStateMask];void 0!==g&&(this.mask=null!=(a=r.getFloat(g))?a:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(i=r.getFloat(v))?i:255);var y=t[e.RenderStateDataKey.StencilStateCompareFunctionFront];void 0!==y&&(this.compareFunctionFront=null!=(o=r.getFloat(y))?o:e.CompareFunction.Always);var x=t[e.RenderStateDataKey.StencilStateCompareFunctionBack];void 0!==x&&(this.compareFunctionBack=null!=(s=r.getFloat(x))?s:e.CompareFunction.Always);var b=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==b&&(this.passOperationFront=null!=(l=r.getFloat(b))?l:e.StencilOperation.Keep);var S=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==S&&(this.passOperationBack=null!=(c=r.getFloat(S))?c:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(d=r.getFloat(C))?d:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==T&&(this.failOperationBack=null!=(u=r.getFloat(T))?u:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==A&&(this.zFailOperationFront=null!=(h=r.getFloat(A))?h:e.StencilOperation.Keep);var M=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==M&&(this.zFailOperationBack=null!=(_=r.getFloat(M))?_:e.StencilOperation.Keep)},eX._apply=function(e,t){this._platformApply(e,t.stencilState)},eX._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.referenceValue,i=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,d=this.passOperationFront,u=this.failOperationBack,h=this.zFailOperationBack,_=this.passOperationBack,f=this.writeMask;if(n!=t.enabled&&(n?r.enable(r.STENCIL_TEST):r.disable(r.STENCIL_TEST),t.enabled=n),n){var p=a!==t.referenceValue||i!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,ej._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,ej._getGLCompareFunction(e,s),a,i),t.compareFunctionBack=this.compareFunctionBack),p&&(t.referenceValue=this.referenceValue,t.mask=this.mask),(l!==t.failOperationFront||c!==t.zFailOperationFront||d!==t.passOperationFront)&&(r.stencilOpSeparate(r.FRONT,ej._getGLStencilOperation(e,l),ej._getGLStencilOperation(e,c),ej._getGLStencilOperation(e,d)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=d),(u!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,ej._getGLStencilOperation(e,u),ej._getGLStencilOperation(e,h),ej._getGLStencilOperation(e,_)),t.failOperationBack=u,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},ej._getGLCompareFunction=function(t,r){var n=t.gl;switch(r){case e.CompareFunction.Never:return n.NEVER;case e.CompareFunction.Less:return n.LESS;case e.CompareFunction.Equal:return n.EQUAL;case e.CompareFunction.LessEqual:return n.LEQUAL;case e.CompareFunction.Greater:return n.GREATER;case e.CompareFunction.NotEqual:return n.NOTEQUAL;case e.CompareFunction.GreaterEqual:return n.GEQUAL;case e.CompareFunction.Always:return n.ALWAYS}},ej._getGLStencilOperation=function(t,r){var n=t.gl;switch(r){case e.StencilOperation.Keep:return n.KEEP;case e.StencilOperation.Zero:return n.ZERO;case e.StencilOperation.Replace:return n.REPLACE;case e.StencilOperation.IncrementSaturate:return n.INCR;case e.StencilOperation.DecrementSaturate:return n.DECR;case e.StencilOperation.Invert:return n.INVERT;case e.StencilOperation.IncrementWrap:return n.INCR_WRAP;case e.StencilOperation.DecrementWrap:return n.DECR_WRAP}},ej),dR=((eY=(eq=function(){this.blendState=new dT,this.depthState=new dA,this.stencilState=new dE,this.rasterState=new dM,this.renderQueueType=e.RenderQueueType.Opaque}).prototype)._applyShaderDataValue=function(t,r){this.blendState._applyShaderDataValue(t,r),this.depthState._applyShaderDataValue(t,r),this.stencilState._applyShaderDataValue(t,r),this.rasterState._applyShaderDataValue(t,r);var n,a=t[e.RenderStateDataKey.RenderQueueType];void 0!==a&&(this.renderQueueType=null!=(n=r.getFloat(a))?n:e.RenderQueueType.Opaque)},eY._apply=function(e,t,r,n){r&&this._applyShaderDataValue(r,n);var a=e._hardwareRenderer,i=e._lastRenderState,o=e._renderContext;this.blendState._apply(a,i),this.depthState._apply(a,i),this.stencilState._apply(a,i),this.rasterState._apply(a,i,o.flipProjection?!t:t)},eq);cW([cY],dR.prototype,"blendState",void 0),cW([cY],dR.prototype,"depthState",void 0),cW([cY],dR.prototype,"stencilState",void 0),cW([cY],dR.prototype,"rasterState",void 0);var dw=((eJ=(eQ=function(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}).prototype).compileVariant=function(e,t){var r=eQ._compileMacros;r.clear();for(var n=0,a=t.length;n<a;n++)r.enable(du.getByName(t[n]));for(var i=!1,o=this._subShaders,s=0,l=o.length;s<l;s++)for(var c=o[s].passes,d=0,u=c.length;d<u;d++){var h=c[d]._getShaderProgram(e,r);i=0===d?h.isValid:i&&h.isValid}return i},eJ.destroy=function(e){if(void 0===e&&(e=!1),!e&&0!==this._refCount)return!1;for(var t=this._subShaders,r=0,n=t.length;r<n;r++)for(var a=t[r].passes,i=0,o=a.length;i<o;i++)a[i]._destroy();return delete eQ._shaderMap[this.name],this._destroyed=!0,!0},eJ._getReferCount=function(){return this._refCount},eJ._addReferCount=function(e){this._refCount+=e},eQ.create=function(e,t,r){var n,a=eQ._shaderMap;if(t){if(a[e]){console.error('Shader named "'+e+'" already exists.');return}if("string"==typeof t){var i=new db(t,r);n=new eQ(e,[new dS("Default",[i])])}else if(t.length>0)n=t[0].constructor===db?new eQ(e,[new dS("Default",t)]):new eQ(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!eQ._shaderLab)throw"ShaderLab has not been set up yet.";var o=eQ._shaderLab.parseShader(e);if(a[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(e){var t=e.passes.map(function(e){if("string"==typeof e){var t,r,n=e.split("/");return null==(r=eQ.find(n[0]))?void 0:null==(t=r.subShaders.find(function(e){return e.name===n[1]}))?void 0:t.passes.find(function(e){return e.name===n[2]})}var a=new db(e.name,e.vertexSource,e.fragmentSource,e.tags),i=e.renderStates,o=new dR;a._renderState=o;var s=i[0];for(var l in s)eQ._applyConstRenderStates(o,parseInt(l),s[l]);var c=i[1],d={};for(var u in c)d[u]=dn.getByName(c[u]);return a._renderStateDataMap=d,a});return new dS(o.name,t,e.tags)});return n=new eQ(o.name,s),a[o.name]=n,n}return a[e]=n,n},eQ.find=function(e){return eQ._shaderMap[e]},eQ._applyConstRenderStates=function(t,r,n){switch(r){case e.RenderStateDataKey.BlendStateEnabled0:t.blendState.targetBlendState.enabled=n;break;case e.RenderStateDataKey.BlendStateColorBlendOperation0:t.blendState.targetBlendState.colorBlendOperation=n;break;case e.RenderStateDataKey.BlendStateAlphaBlendOperation0:t.blendState.targetBlendState.alphaBlendOperation=n;break;case e.RenderStateDataKey.BlendStateSourceColorBlendFactor0:t.blendState.targetBlendState.sourceColorBlendFactor=n;break;case e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0:t.blendState.targetBlendState.destinationColorBlendFactor=n;break;case e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0:t.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0:t.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case e.RenderStateDataKey.BlendStateColorWriteMask0:t.blendState.targetBlendState.colorWriteMask=n;break;case e.RenderStateDataKey.DepthStateEnabled:t.depthState.enabled=n;break;case e.RenderStateDataKey.DepthStateWriteEnabled:t.depthState.writeEnabled=n;break;case e.RenderStateDataKey.DepthStateCompareFunction:t.depthState.compareFunction=n;break;case e.RenderStateDataKey.StencilStateEnabled:t.stencilState.enabled=n;break;case e.RenderStateDataKey.StencilStateReferenceValue:t.stencilState.referenceValue=n;break;case e.RenderStateDataKey.StencilStateMask:t.stencilState.mask=n;break;case e.RenderStateDataKey.StencilStateWriteMask:t.stencilState.writeMask=n;break;case e.RenderStateDataKey.StencilStateCompareFunctionFront:t.stencilState.compareFunctionFront=n;break;case e.RenderStateDataKey.StencilStateCompareFunctionBack:t.stencilState.compareFunctionBack=n;break;case e.RenderStateDataKey.StencilStatePassOperationFront:t.stencilState.passOperationFront=n;break;case e.RenderStateDataKey.StencilStatePassOperationBack:t.stencilState.passOperationBack=n;break;case e.RenderStateDataKey.StencilStateFailOperationFront:t.stencilState.failOperationFront=n;break;case e.RenderStateDataKey.StencilStateFailOperationBack:t.stencilState.failOperationBack=n;break;case e.RenderStateDataKey.StencilStateZFailOperationFront:t.stencilState.zFailOperationFront=n;break;case e.RenderStateDataKey.StencilStateZFailOperationBack:t.stencilState.zFailOperationBack=n;break;case e.RenderStateDataKey.RasterStateCullMode:t.rasterState.cullMode=n;break;case e.RenderStateDataKey.RasterStateDepthBias:t.rasterState.depthBias=n;break;case e.RenderStateDataKey.RasterStateSlopeScaledDepthBias:t.rasterState.slopeScaledDepthBias=n;break;case e.RenderStateDataKey.RenderQueueType:t.renderQueueType=n}},eQ.getMacroByName=function(e,t){return du.getByName(e,t)},eQ.getPropertyByName=function(e){return dn.getByName(e)},cU(eQ,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),eQ);dw._compileMacros=new dh,dw._shaderMap=Object.create(null);var dP=(cH(eZ=function(e){var t;return(t=cZ.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(ck(t)),t},cZ),eZ.prototype._onDestroy=function(){cZ.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},cU(eZ,[{key:"isContentLost",get:function(){return this._isContentLost}}]),eZ);e.TextureFilterMode=void 0,(e$=e.TextureFilterMode||(e.TextureFilterMode={}))[e$.Point=0]="Point",e$[e$.Bilinear=1]="Bilinear",e$[e$.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(e0=e.TextureFormat||(e.TextureFormat={}))[e0.R8G8B8=0]="R8G8B8",e0[e0.R8G8B8A8=1]="R8G8B8A8",e0[e0.R4G4B4A4=2]="R4G4B4A4",e0[e0.R5G5B5A1=3]="R5G5B5A1",e0[e0.R5G6B5=4]="R5G6B5",e0[e0.Alpha8=5]="Alpha8",e0[e0.LuminanceAlpha=6]="LuminanceAlpha",e0[e0.R16G16B16A16=7]="R16G16B16A16",e0[e0.R32G32B32A32=8]="R32G32B32A32",e0[e0.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",e0[e0.BC1=10]="BC1",e0[e0.BC3=11]="BC3",e0[e0.BC7=12]="BC7",e0[e0.ETC1_RGB=13]="ETC1_RGB",e0[e0.ETC2_RGB=14]="ETC2_RGB",e0[e0.ETC2_RGBA5=15]="ETC2_RGBA5",e0[e0.ETC2_RGBA8=16]="ETC2_RGBA8",e0[e0.PVRTC_RGB2=17]="PVRTC_RGB2",e0[e0.PVRTC_RGBA2=18]="PVRTC_RGBA2",e0[e0.PVRTC_RGB4=19]="PVRTC_RGB4",e0[e0.PVRTC_RGBA4=20]="PVRTC_RGBA4",e0[e0.ASTC_4x4=21]="ASTC_4x4",e0[e0.ASTC_5x5=22]="ASTC_5x5",e0[e0.ASTC_6x6=23]="ASTC_6x6",e0[e0.ASTC_8x8=24]="ASTC_8x8",e0[e0.ASTC_10x10=25]="ASTC_10x10",e0[e0.ASTC_12x12=26]="ASTC_12x12",e0[e0.Depth=27]="Depth",e0[e0.Stencil=28]="Stencil",e0[e0.DepthStencil=29]="DepthStencil",e0[e0.Depth16=30]="Depth16",e0[e0.Depth24=31]="Depth24",e0[e0.Depth32=32]="Depth32",e0[e0.Depth24Stencil8=33]="Depth24Stencil8",e0[e0.Depth32Stencil8=34]="Depth32Stencil8",e0[e0.DXT1=10]="DXT1",e0[e0.DXT5=11]="DXT5";var dF=(cH(e1=function(){var e;return e=dP.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},dP),(e2=e1.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},e2._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},e2._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,this._engine._hardwareRenderer._isWebGL2&&(e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode))},e2._onDestroy=function(){dP.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},e2._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},e2._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},e2._isIntFormat=function(){return e.TextureFormat.R32G32B32A32_UInt===this._format},cU(e1,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(t){if(t!==this._filterMode){if(t!==e.TextureFilterMode.Point&&this._isIntFormat()){t=e.TextureFilterMode.Point,dr.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=t,this._platformTexture.filterMode=t}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(dr.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(dr.warn("anisoLevel:"+e+", must be greater than 0, and is automatically downgraded to 1"),e=1),e!==this._anisoLevel&&(this._anisoLevel=e,this._platformTexture.anisoLevel=e)}},{key:"depthCompareFunction",get:function(){return this._depthCompareFunction},set:function(e){if(!this._engine._hardwareRenderer._isWebGL2){console.warn("depthCompareFunction only support WebGL2");return}e!==this._depthCompareFunction&&(this._depthCompareFunction=e,this._platformTexture.depthCompareFunction=e)}}]),e1),dL=((e4=(e3=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new dh,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},e4.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},e4.getInt=function(e){return this.getPropertyValue(e)},e4.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},e4.getFloatArray=function(e){return this.getPropertyValue(e)},e4.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},e4.getIntArray=function(e){return this.getPropertyValue(e)},e4.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},e4.getVector2=function(e){return this.getPropertyValue(e)},e4.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},e4.getVector3=function(e){return this.getPropertyValue(e)},e4.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},e4.getVector4=function(e){return this.getPropertyValue(e)},e4.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},e4.getMatrix=function(e){return this.getPropertyValue(e)},e4.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},e4.getColor=function(e){return this.getPropertyValue(e)},e4.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},e4.getTexture=function(e){return this.getPropertyValue(e)},e4.setTexture=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},e4.getTextureArray=function(e){return this.getPropertyValue(e)},e4.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);if(a)for(var i=0,o=a.length;i<o;i++)a[i]._addReferCount(-n);if(r)for(var s=0,l=r.length;s<l;s++)r[s]._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,r)},e4.getPropertyValue=function(e){return"string"==typeof e&&(e=dn.getByName(e)),this._propertyValueMap[e._uniqueId]},e4.enableMacro=function(e,t){"string"==typeof e&&(e=du.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var a=this._macroCollection;n&&a.disable(n),a.enable(e),this._macroMap[r]=e}},e4.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=du._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},e4.getMacros=function(e){if(!e)return Object.values(this._macroMap);var t=this._macroMap;for(var r in e.length=0,t)e.push(t[r])},e4.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=dn._propertyIdMap;for(var a in r)t.push(n[a]);if(!e)return t},e4.clone=function(){var e=new e3(this._group);return this.cloneTo(e),e},e4.cloneTo=function(e){cQ.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,a=Object.keys(r),i=0,o=a.length;i<o;i++){var s=a[i],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(cK(l,dF))n[s]=l,t>0&&l._addReferCount(t);else if(cK(l,Array)||cK(l,Float32Array)||cK(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},e4._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=dn.getByName(t)),t._group!==this._group){if(void 0===t._group)t._group=this._group;else throw"Shader property "+t.name+" has been used as "+lW[t._group]+" group."}if(t._type!==r){if(void 0===t._type)t._type=r;else throw"Shader property "+t.name+" has been used as "+e.ShaderPropertyType[t._type]+" type."}this._propertyValueMap[t._uniqueId]=n},e4._getReferCount=function(){return this._refCount},e4._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&cK(n,dF)&&n._addReferCount(e)}},e3);function dD(){return function(e){}}cW([cj],dL.prototype,"_group",void 0),cW([cj],dL.prototype,"_propertyValueMap",void 0),cW([cj],dL.prototype,"_macroCollection",void 0),cW([cj],dL.prototype,"_macroMap",void 0),cW([cj],dL.prototype,"_refCount",void 0),e.Renderer=(cH(e8=function(t){(r=di.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new dh,r._bounds=new cA,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._shaderData=new dL(lW.Renderer),r._mvMatrix=new cF,r._mvpMatrix=new cF,r._mvInvMatrix=new cF,r._normalMatrix=new cF,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r._rendererLayer=new cB,r.castShadows=!0;var r,n=e.Renderer.prototype,a=r.shaderData;return r._overrideUpdate=r.update!==n.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(ck(r)),r._registerEntityTransformListener(),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},di),(e5=e8.prototype).getInstanceMaterial=function(e){void 0===e&&(e=0);var t=this._materials;if(t.length>e){var r=t[e];if(r)return this._materialsInstanced[e]?r:this._createInstanceMaterial(r,e)}return null},e5.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},e5.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},e5.getInstanceMaterials=function(){for(var e=this._materials,t=this._materialsInstanced,r=0,n=e.length;r<n;r++)t[r]||this._createInstanceMaterial(this._materials[r],r);return e},e5.getMaterials=function(){return this._materials},e5.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,a=t,i=r.length;a<i;a++){var o=r[a];o&&this._addResourceReferCount(o,-1)}r.length!==t&&(r.length=t),0!==n.length&&(n.length=0);for(var s=0;s<t;s++){var l=r[s],c=e[s];l!==c&&(r[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},e5.update=function(e){},e5._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},e5._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},e5._prepareRender=function(t){var r=t.virtualCamera,n=r.position,a=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(cC.subtract(a,n,a),this._distanceForSort=cC.dot(a,r.forward)):this._distanceForSort=cC.distanceSquared(a,n),this._updateShaderData(t,!1),this._render(t),dh.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},e5._cloneTo=function(e,t,r){for(var n=this._materials,a=0,i=n.length;a<i;a++)e._setMaterial(a,n[a])},e5._onDestroy=function(){di.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this._addResourceReferCount(this.shaderData,-1);for(var e=this._materials,t=0,r=e.length;t<r;t++){var n=e[t];n&&this._addResourceReferCount(n,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},e5._updateShaderData=function(e,t){var r=this.entity,n=r.transform.worldMatrix;if(t){this._updateMVPShaderData(e,n);return}this._updateTransformShaderData(e,n);var a=r.layer;this._rendererLayer.set(65535&a,a>>>16&65535,0,0)},e5._updateTransformShaderData=function(t,r){var n=this.shaderData,a=this._mvMatrix,i=this._mvInvMatrix,o=this._normalMatrix;cF.multiply(t.viewMatrix,r,a),cF.invert(a,i),cF.invert(r,o),o.transpose(),n.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),n.setMatrix(e.Renderer._worldMatrixProperty,r),n.setMatrix(e.Renderer._mvMatrixProperty,a),n.setMatrix(e.Renderer._mvInvMatrixProperty,i),n.setMatrix(e.Renderer._normalMatrixProperty,o),this._updateMVPShaderData(t,r)},e5._updateMVPShaderData=function(t,r){var n=this._mvpMatrix;cF.multiply(t.viewProjectionMatrix,r,n),this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,n)},e5._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},e5._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},e5._updateBounds=function(e){},e5._render=function(e){throw"not implement"},e5._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(r,1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},e5._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),n&&this._addResourceReferCount(n,-1),t&&this._addResourceReferCount(t,1),r[e]=t}},e5._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},cU(e8,[{key:"shaderData",get:function(){return this._shaderData}},{key:"isCulled",get:function(){return!(void 0===this._renderFrameCount||this._renderFrameCount===this._engine.time.frameCount-1)}},{key:"receiveShadows",get:function(){return this._receiveShadows},set:function(t){this._receiveShadows!==t&&(t?this.shaderData.enableMacro(e.Renderer._receiveShadowMacro):this.shaderData.disableMacro(e.Renderer._receiveShadowMacro),this._receiveShadows=t)}},{key:"materialCount",get:function(){return this._materials.length},set:function(e){var t=this._materials,r=this._materialsInstanced;t.length!==e&&(t.length=e),r.length>e&&(r.length=e)}},{key:"bounds",get:function(){return 1&this._dirtyUpdateFlag&&(this._updateBounds(this._bounds),this._dirtyUpdateFlag&=-2),this._bounds}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority=e}}]),e8._tempVector0=new cC,e8._receiveShadowMacro=du.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e8._localMatrixProperty=dn.getByName("renderer_LocalMat"),e8._worldMatrixProperty=dn.getByName("renderer_ModelMat"),e8._mvMatrixProperty=dn.getByName("renderer_MVMat"),e8._mvpMatrixProperty=dn.getByName("renderer_MVPMat"),e8._mvInvMatrixProperty=dn.getByName("renderer_MVInvMat"),e8._normalMatrixProperty=dn.getByName("renderer_NormalMat"),e8._rendererLayerProperty=dn.getByName("renderer_Layer"),e8),cW([cj],e.Renderer.prototype,"_distanceForSort",void 0),cW([cj],e.Renderer.prototype,"_onUpdateIndex",void 0),cW([cj],e.Renderer.prototype,"_rendererIndex",void 0),cW([cj],e.Renderer.prototype,"_globalShaderMacro",void 0),cW([cj],e.Renderer.prototype,"_bounds",void 0),cW([cj],e.Renderer.prototype,"_renderFrameCount",void 0),cW([cj],e.Renderer.prototype,"_overrideUpdate",void 0),cW([cj],e.Renderer.prototype,"_materials",void 0),cW([cj],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),cW([cY],e.Renderer.prototype,"_shaderData",void 0),cW([cj],e.Renderer.prototype,"_mvMatrix",void 0),cW([cj],e.Renderer.prototype,"_mvpMatrix",void 0),cW([cj],e.Renderer.prototype,"_mvInvMatrix",void 0),cW([cj],e.Renderer.prototype,"_normalMatrix",void 0),cW([cj],e.Renderer.prototype,"_materialsInstanced",void 0),cW([cX],e.Renderer.prototype,"_priority",void 0),cW([cX],e.Renderer.prototype,"_receiveShadows",void 0),cW([cj],e.Renderer.prototype,"_rendererLayer",void 0),cW([cj],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=cW([dl(dd,e.DependentMode.CheckOnly)],e.Renderer),(e9=lK||(lK={}))[e9.WorldVolume=1]="WorldVolume";var dB=((e6=function(){}).resetData=function(e){var t,r,n=e._verticesData,a=n.positions,i=n.uvs;n.vertexCount=a.length=i.length=4;for(var o=0;o<4;o++)a[t=o]||(a[t]=new cC),i[r=o]||(i[r]=new cD);n.triangles=dB._rectangleTriangles},e6.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,a=n.pivot,i=a.x,o=a.y,s=dB._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,d=e.flipX?-t:t,u=e.flipY?-r:r;l[0]=c[0]*d,l[1]=c[1]*d,l[2]=c[2]*d,l[4]=c[4]*u,l[5]=c[5]*u,l[6]=c[6]*u,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-i*l[0]-o*l[4],l[13]=c[13]-i*l[1]-o*l[5],l[14]=c[14]-i*l[2]-o*l[6];for(var h=n._getPositions(),_=e._verticesData.positions,f=0;f<4;f++){var p=h[f],m=p.x,g=p.y;_[f].set(l[0]*m+l[4]*g+l[12],l[1]*m+l[5]*g+l[13],l[2]*m+l[6]*g+l[14])}cA.transform(n._getBounds(),s,e._bounds)},e6.updateUVs=function(e){var t=e.sprite._getUVs(),r=e._verticesData.uvs,n=t[0],a=n.x,i=n.y,o=t[3],s=o.x,l=o.y;r[0].set(a,i),r[1].set(s,i),r[2].set(a,l),r[3].set(s,l)},e6._rectangleTriangles=[0,1,2,2,1,3],e6._worldMatrix=new cF,e6);dB=cW([dD()],dB);var dI=((e7=function(){}).resetData=function(e){var t,r,n=e._verticesData,a=n.positions,i=n.uvs;n.vertexCount=a.length=i.length=16;for(var o=0;o<16;o++)a[t=o]||(a[t]=new cC),i[r=o]||(i[r]=new cD);n.triangles=dI._rectangleTriangles},e7.updatePositions=function(e){var t,r,n=e.width,a=e.height,i=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=i.border,d=i._getUVs(),u=i._getPositions(),h=u[0],_=h.x,f=h.y,p=u[3],m=p.x,g=p.y,v=i.width,y=i.height,x=v*c.x,b=y*c.y,S=v*c.z,C=y*c.w;if(x+S>n){var T=n/(x+S);t=[v*_*T,x*T,x*T,n-v*(1-m)*T]}else t=[v*_,x,n-S,n-v*(1-m)];if(C+b>a){var A=a/(C+b);r=[y*f*A,b*A,b*A,a-y*(1-g)*A]}else r=[y*f,b,a-C,a-y*(1-g)];var M=e.sprite.pivot,E=M.x,R=M.y,w=e.width*E,P=e.height*R,F=dI._worldMatrix,L=F.elements,D=e.entity.transform.worldMatrix.elements,B=e.flipX?-1:1,I=e.flipY?-1:1;L[0]=D[0]*B,L[1]=D[1]*B,L[2]=D[2]*B,L[4]=D[4]*I,L[5]=D[5]*I,L[6]=D[6]*I,L[8]=D[8],L[9]=D[9],L[10]=D[10],L[12]=D[12]-w*L[0]-P*L[4],L[13]=D[13]-w*L[1]-P*L[5],L[14]=D[14]-w*L[2]-P*L[6];for(var V=0;V<4;V++)for(var O=t[V],N=d[V].x,k=0;k<4;k++){var z=r[k],U=4*V+k;s[U].set(L[0]*O+L[4]*z+L[12],L[1]*O+L[5]*z+L[13],L[2]*O+L[6]*z+L[14]),l[U].set(N,d[k].y)}var G=e._bounds,H=G.min,W=G.max;H.set(t[0],r[0],0),W.set(t[3],r[3],0),e._bounds.transform(F)},e7.updateUVs=function(e){},e7._rectangleTriangles=[0,1,4,1,5,4,1,2,5,2,6,5,2,3,6,3,7,6,4,5,8,5,9,8,5,6,9,6,10,9,6,7,10,7,11,10,8,9,12,9,13,12,9,10,13,10,14,13,10,11,14,11,15,14],e7._worldMatrix=new cF,e7);dI=cW([dD()],dI);var dV=((tt=(te=function(e){void 0===e&&(e=0),this.length=0,this._isLooping=!1,this._blankCount=0,this._elements=Array(e)}).prototype).add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},tt.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},tt.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},tt.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},tt.deleteByIndex=function(e){var t,r=this._elements;if(this._isLooping)this._elements[e]=null,this._blankCount++;else{var n=this.length-1;e!==n&&(t=r[n],r[e]=t),r[n]=null,this.length--}return t},tt.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0,a=this.length;n<a;n++){var i=r[n];i&&e(i)}this._endLoop(t)},tt.forEachAndClean=function(e,t){this._startLoop();for(var r=this.length,n=this._elements,a=0;a<r;a++){var i=n[a];i&&e(i)}this._endLoopAndClean(r,n,t)},tt.sort=function(e){c0._quickSort(this._elements,0,this.length,e)},tt.garbageCollection=function(){this._elements.length=this.length},tt._startLoop=function(){this._isLooping=!0},tt._endLoop=function(e){if(this._isLooping=!1,this._blankCount){var t=0,r=this.length-1,n=this._elements;e:do{for(;n[t];)if(++t>=r)break e;for(;!n[r];)if(t>=--r)break e;var a=n[r];e(a,t),n[t++]=a,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},tt._endLoopAndClean=function(e,t,r){for(var n=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[n]=o,r(o,n),n++)}this._isLooping=!1,this.length=n,this._blankCount=0},te);e.BufferUsage=void 0,(tr=e.BufferUsage||(e.BufferUsage={}))[tr.Static=0]="Static",tr[tr.Dynamic=1]="Dynamic",tr[tr.Stream=2]="Stream",e.SetDataOptions=void 0,(tn=e.SetDataOptions||(e.SetDataOptions={}))[tn.None=0]="None",tn[tn.Discard=1]="Discard";var dO=(cH(ta=function(t,r,n,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=dP.call(this,t)||this)._dataUpdateManager=new c4,o._engine=t,o._type=r,o._bufferUsage=a,o._readable=i,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,a),i&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,a,n),i){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},dP),(ti=ta.prototype).bind=function(){this._platformBuffer.bind()},ti.setData=function(t,r,n,a,i){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,a,i),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=a?s*a:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,d=new Uint8Array(o,c,l);this._data.set(d,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},ti.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},ti.markAsUnreadable=function(){this._data=null,this._readable=!1},ti._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},ti._onDestroy=function(){dP.prototype._onDestroy.call(this),this._platformBuffer.destroy()},cU(ta,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}},{key:"readable",get:function(){return this._readable}},{key:"data",get:function(){if(this._readable)return this._data;throw"Buffer is not readable."}}]),ta);e.IndexFormat=void 0,(to=e.IndexFormat||(e.IndexFormat={}))[to.UInt8=0]="UInt8",to[to.UInt16=1]="UInt16",to[to.UInt32=2]="UInt32",e.VertexElementFormat=void 0,(ts=e.VertexElementFormat||(e.VertexElementFormat={}))[ts.Float=0]="Float",ts[ts.Vector2=1]="Vector2",ts[ts.Vector3=2]="Vector3",ts[ts.Vector4=3]="Vector4",ts[ts.Byte4=4]="Byte4",ts[ts.UByte4=5]="UByte4",ts[ts.NormalizedByte4=6]="NormalizedByte4",ts[ts.NormalizedUByte4=7]="NormalizedUByte4",ts[ts.Short2=8]="Short2",ts[ts.UShort2=9]="UShort2",ts[ts.NormalizedShort2=10]="NormalizedShort2",ts[ts.NormalizedUShort2=11]="NormalizedUShort2",ts[ts.Short4=12]="Short4",ts[ts.UShort4=13]="UShort4",ts[ts.NormalizedShort4=14]="NormalizedShort4",ts[ts.NormalizedUShort4=15]="NormalizedUShort4";var dN=((tl=function(){})._getGLIndexType=function(t){switch(t){case e.IndexFormat.UInt8:return e.DataType.UNSIGNED_BYTE;case e.IndexFormat.UInt16:return e.DataType.UNSIGNED_SHORT;case e.IndexFormat.UInt32:return e.DataType.UNSIGNED_INT}},tl._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tl._getElementInfo=function(t){var r,n,a,i=!1;switch(t){case e.VertexElementFormat.Float:r=1,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:r=2,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:r=3,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:r=4,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:r=4,n=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:r=4,n=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:r=4,n=e.DataType.BYTE,i=!0,a=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,i=!0,a=1/255;break;case e.VertexElementFormat.Short2:r=2,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:r=2,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:r=2,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535;break;case e.VertexElementFormat.Short4:r=4,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:r=4,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:r=4,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535}return{size:r,type:n,normalized:i,normalizedScaleFactor:a}},tl);e.BufferBindFlag=void 0,(tc=e.BufferBindFlag||(e.BufferBindFlag={}))[tc.VertexBuffer=0]="VertexBuffer",tc[tc.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(td=e.MeshTopology||(e.MeshTopology={}))[td.Points=0]="Points",td[td.Lines=1]="Lines",td[td.LineLoop=2]="LineLoop",td[td.LineStrip=3]="LineStrip",td[td.Triangles=4]="Triangles",td[td.TriangleStrip=5]="TriangleStrip",td[td.TriangleFan=6]="TriangleFan";var dk=(cU(tu=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tu),dz=((th=function(t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=e.MeshTopology.Triangles),this.start=t,this.count=r,this.topology=n}).prototype.dispose=function(){},th),dU=(cH(t_=function(e){var t;return(t=dP.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(ck(t)),t},dP),(tf=t_.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,a=t[n];a&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(a),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},tf.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},tf.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},tf.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,a=n[e];a&&delete r[a.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},tf.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,a=r.length;n<a;n++){var i=r[n];delete t[i.attribute]}r.length=e},tf.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),a=this.vertexBufferBindings;n>0&&(null==(r=a[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),a[e]=t,this._bufferStructChanged=!0},tf.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this.setVertexBufferBinding(t+i,e[i])},tf.setIndexBufferBinding=function(e){var t=this.indexBufferBinding,r=this._getReferCount();t!==e&&(this._indexBufferBinding=e,r>0&&(null==t||t.buffer._addReferCount(-r)),e?(r>0&&e.buffer._addReferCount(r),this._glIndexType=dN._getGLIndexType(e.format),this._glIndexByteCount=dN._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},tf.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tf._addReferCount=function(e){dP.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,a=0,i=n.length;a<i;a++)null==(r=n[a])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},tf._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},tf._onDestroy=function(){dP.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},cU(t_,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t_),dG=(cH(tp=function(e,t){(r=cZ.call(this,e)||this)._updateFlagManager=new c4,r._bounds=new cA,r._subMeshes=[],r.name=t,r._primitive=new dU(e),r._onBoundsChanged=r._onBoundsChanged.bind(ck(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},cZ),(tm=tp.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new dz(t,r,n)),this._subMeshes.push(t),t},tm.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},tm.clearSubMesh=function(){this._subMeshes.length=0},tm._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},tm._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},tm._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},tm._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},tm._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},tm._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},tm._addReferCount=function(e){cZ.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},tm._onDestroy=function(){cZ.prototype._onDestroy.call(this),this._primitive.destroy()},tm._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},tm._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},tm._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},cU(tp,[{key:"bounds",get:function(){return this._bounds},set:function(e){this._bounds!==e&&this._bounds.copyFrom(e)}},{key:"subMesh",get:function(){return this._subMeshes[0]||null}},{key:"subMeshes",get:function(){return this._subMeshes}}]),tp);(tg=lj||(lj={}))[tg.Bounds=1]="Bounds",tg[tg.VertexElements=2]="VertexElements";var dH=(cU(tv=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tv),dW=(cU(ty=function(e,t,r,n,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=dN._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)},[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),ty),dK=((tx=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new c4,this._dirty=7,r&&r.length!==t.length)throw"deltaNormals length must same with deltaPositions length.";if(n&&n.length!==t.length)throw"deltaTangents length must same with deltaPositions length.";this.weight=e,this._deltaPositions=t,this._deltaNormals=r,this._deltaTangents=n}).prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},cU(tx,[{key:"deltaPositions",get:function(){return this._deltaPositions},set:function(e){this._deltaPositions=e,this._dirty|=1,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaNormals",get:function(){return this._deltaNormals},set:function(e){this._deltaNormals=e,this._dirty|=2,this._dataChangeManager.dispatch(this._dirty,this)}},{key:"deltaTangents",get:function(){return this._deltaTangents},set:function(e){this._deltaTangents=e,this._dirty|=4,this._dataChangeManager.dispatch(this._dirty,this)}}]),tx);(tb=lX||(lX={}))[tb.Position=1]="Position",tb[tb.Normal=2]="Normal",tb[tb.Tangent=4]="Tangent",tb[tb.All=7]="All";var dj=((tC=(tS=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new c4,this._dataChangeManager=new c4,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var a=new dK(e,t,r,n);return this._addFrame(a),a}this._addFrame(e)},tC.clearFrames=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._dataChangeManager.removeListener(this._frameDataChangeListener);e.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},tC._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},tC._addFrame=function(e){var t=this._frames,r=t.length;if(r>0&&e.deltaPositions.length!==t[r-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(e),this._frameDataChangeListener(lX.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},tC._updateUseNormalAndTangent=function(e,t){var r=this._useBlendShapeNormal&&e,n=this._useBlendShapeTangent&&t;(this._useBlendShapeNormal!==r||this._useBlendShapeTangent!==n)&&(this._useBlendShapeNormal=r,this._useBlendShapeTangent=n,this._layoutChangeManager.dispatch(0,this))},tC._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},cU(tS,[{key:"frames",get:function(){return this._frames}}]),tS),dX=(cH(tT=function(){return dG.apply(this,arguments)},dG),(tA=tT.prototype).setVertexElements=function(e){this._setVertexElements(e)},tA.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dH(e,t));var i=this._primitive.vertexBufferBindings;i.length<=r&&(i.length=r+1),this._setVertexBufferBinding(a?t:r,n)},tA.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this._setVertexBufferBinding(t+i,e[i])},tA.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new dk(e,t))),this._setIndexBufferBinding(r)},cU(tT,[{key:"instanceCount",get:function(){return this._primitive.instanceCount},set:function(e){this._primitive.instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._primitive.indexBufferBinding}},{key:"vertexElements",get:function(){return this._primitive.vertexElements}}]),tT),dq=(tM=e.Renderer,cH(tE=function(e){var t;return(t=tM.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(ck(t)),t},tM),(tR=tE.prototype)._onDestroy=function(){var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),tM.prototype._onDestroy.call(this)},tR._cloneTo=function(e,t,r){tM.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},tR._prepareRender=function(e){if(!this._mesh){dr.error("mesh is null.");return}if(this._mesh.destroyed){dr.error("mesh is destroyed.");return}tM.prototype._prepareRender.call(this,e)},tR._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;cA.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tR._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(tE._uvMacro),r.disableMacro(tE._uv1Macro),r.disableMacro(tE._normalMacro),r.disableMacro(tE._tangentMacro),r.disableMacro(tE._enableVertexColorMacro);for(var a=0,i=n.length;a<i;a++)switch(n[a].attribute){case"TEXCOORD_0":r.enableMacro(tE._uvMacro);break;case"TEXCOORD_1":r.enableMacro(tE._uv1Macro);break;case"NORMAL":r.enableMacro(tE._normalMacro);break;case"TANGENT":r.enableMacro(tE._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(tE._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._renderDataPool,d=0,u=s.length;d<u;d++){var h=o[d];if(h){(h.destroyed||h.shader.destroyed)&&(h=this.engine._meshMagentaMaterial);var _=c.getFromPool();_.setX(this,h,t._primitive,s[d]),l.pushRenderData(e,_)}}},tR._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tR._onMeshChanged=function(e){e&lj.Bounds&&(this._dirtyUpdateFlag|=lK.WorldVolume),e&lj.VertexElements&&(this._dirtyUpdateFlag|=2)},cU(tE,[{key:"mesh",get:function(){return this._mesh},set:function(e){this._mesh!==e&&this._setMesh(e)}},{key:"enableVertexColor",get:function(){return this._enableVertexColor},set:function(e){e!==this._enableVertexColor&&(this._dirtyUpdateFlag|=2,this._enableVertexColor=e)}}]),tE);dq._uvMacro=du.getByName("RENDERER_HAS_UV"),dq._uv1Macro=du.getByName("RENDERER_HAS_UV1"),dq._normalMacro=du.getByName("RENDERER_HAS_NORMAL"),dq._tangentMacro=du.getByName("RENDERER_HAS_TANGENT"),dq._enableVertexColorMacro=du.getByName("RENDERER_ENABLE_VERTEXCOLOR"),cW([cj],dq.prototype,"_mesh",void 0),cW([cj],dq.prototype,"_onMeshChanged",null),(tw=lq||(lq={}))[tw.VertexElementMacro=2]="VertexElementMacro",tw[tw.All=3]="All",e.RenderBufferDepthFormat=void 0,(tP=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[tP.Depth=27]="Depth",tP[tP.Stencil=28]="Stencil",tP[tP.DepthStencil=29]="DepthStencil",tP[tP.Depth16=30]="Depth16",tP[tP.Depth24=31]="Depth24",tP[tP.Depth32=32]="Depth32",tP[tP.Depth24Stencil8=33]="Depth24Stencil8",tP[tP.Depth32Stencil8=34]="Depth32Stencil8",e.TextureCubeFace=void 0,(tF=e.TextureCubeFace||(e.TextureCubeFace={}))[tF.PositiveX=0]="PositiveX",tF[tF.NegativeX=1]="NegativeX",tF[tF.PositiveY=2]="PositiveY",tF[tF.NegativeY=3]="NegativeY",tF[tF.PositiveZ=4]="PositiveZ",tF[tF.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(tL=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[tL.Never=0]="Never",tL[tL.Less=1]="Less",tL[tL.Equal=2]="Equal",tL[tL.LessEqual=3]="LessEqual",tL[tL.Greater=4]="Greater",tL[tL.NotEqual=5]="NotEqual",tL[tL.GreaterEqual=6]="GreaterEqual",tL[tL.Always=7]="Always",e.TextureUsage=void 0,(tD=e.TextureUsage||(e.TextureUsage={}))[tD.Static=0]="Static",tD[tD.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(tB=e.TextureWrapMode||(e.TextureWrapMode={}))[tB.Clamp=0]="Clamp",tB[tB.Repeat=1]="Repeat",tB[tB.Mirror=2]="Mirror";var dY=(cH(tI=function(t,r,n,a,i,o){if(void 0===i&&(i=e.TextureFormat.Depth),void 0===o&&(o=1),(s=dP.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=r,s._height=n,s._antiAliasing=o,s._depth=i,a){for(var s,l=cK(a,Array)?a.slice():[a],c=0,d=l.length;c<d;c++){var u=l[c];if(u._isDepthTexture)throw"Render texture can't use depth format.";u._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(cK(i,dF)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(ck(s)),s},dP),(tV=tI.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},tV.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,r=e.length;t<r;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},tV._onDestroy=function(){dP.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,r=0,n=t.length;r<n;r++)t[r]._addReferCount(-1);t.length=0,null==(e=this._depthTexture)||e._addReferCount(-1),this._depthTexture=null,this._depth=null},tV._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},tV._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},cU(tI,[{key:"autoGenerateMipmaps",get:function(){return this._autoGenerateMipmaps},set:function(e){this._autoGenerateMipmaps=e}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"colorTextureCount",get:function(){return this._colorTextures.length}},{key:"depthTexture",get:function(){return this._depthTexture}},{key:"antiAliasing",get:function(){return this._antiAliasing}}]),tI),dQ=(cH(tO=function(t,r,n,a,i,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=e.TextureUsage.Static),(s=dF.call(this,t)||this)._mipmap=i,s._width=r,s._height=n,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==e.TextureFormat.Depth||a==e.TextureFormat.DepthStencil||a==e.TextureFormat.Depth16||a==e.TextureFormat.Depth24||a==e.TextureFormat.Depth32||a==e.TextureFormat.Depth24Stencil8||a==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(ck(s)),s.filterMode=s._isIntFormat()?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},dF),(tN=tO.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i),this._isContentLost=!1},tN.setImageSource=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,r,n,a,i),this._isContentLost=!1},tN.getPixelBuffer=function(e,t,r,n,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,r,n,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i)},tN._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),dF.prototype._rebuild.call(this)},tO),dJ=(cH(tk=function(t,r,n,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=dF.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(ck(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},dF),(tz=tk.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o,s),this._isContentLost=!1},tz.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tz.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):5===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tz._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),dF.prototype._rebuild.call(this)},cU(tk,[{key:"length",get:function(){return this._length}}]),tk),dZ=(cH(tU=function(t,r,n,a){var i;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=dF.call(this,t)||this)._mipmap=a,i._width=r,i._height=r,i._format=n,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(ck(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},dF),(tG=tU.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o),this._isContentLost=!1},tG.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tG.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):6===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tG._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),dF.prototype._rebuild.call(this)},tU),d$=((tW=(tH=function(e,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._bufferBindingOffset=-1,this._vertexElementOffset=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastHostCreatedInfo=new cB,this._canUseTextureStoreData=!0,this._dataTextureInfo=new cC,this._engine=e,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}).prototype)._addBlendShape=function(e){this._blendShapes.push(e),this._blendShapeCount++,e._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,e),this._subDataDirtyFlags.push(e._dataChangeManager.createFlag(dc))},tW._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var n=this._subDataDirtyFlags,a=0,i=n.length;a<i;a++)n[a].destroy();n.length=0},tW._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(tH._blendShapeMacro),this._useTextureMode())e.enableMacro(tH._blendShapeTextureMacro),e.setTexture(tH._blendShapeTextureProperty,this._vertexTexture),e.setVector3(tH._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(tH._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var a=t._condensedBlendShapeWeights;a||(a=new Float32Array(n),t._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,a),e.setFloatArray(tH._blendShapeWeightsProperty,a),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(tH._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(tH._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(tH._blendShapeNormalMacro):e.disableMacro(tH._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(tH._blendShapeTangentMacro):e.disableMacro(tH._blendShapeTangentMacro)}else e.disableMacro(tH._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},tW._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},tW._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},tW._vertexElementsNeedUpdate=function(){var e=this._getVertexBufferModeSupportCount(),t=this._lastHostCreatedInfo;return Math.min(t.x,e)!==Math.min(this._blendShapeCount,e)||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent},tW._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},tW._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,a=Math.max(r.length,t+1);n<a&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},tW._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,a=0,i=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<o;i++)t._setVertexElement(r++,new dW("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12,this._useBlendNormal&&(t._setVertexElement(r++,new dW("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12),this._useBlendTangent&&(t._setVertexElement(r++,new dW("TANGENT_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12);return r},tW._update=function(e){var t=this._modelMesh.vertexCount,r=this._useTextureMode(),n=this._isCreateHost(t);n&&(r?this._createTextureArray(t):this._createVertexBuffers(t,e),this._lastHostCreatedInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent,t)),this._needUpdateData()&&(r?this._updateTextureArray(t,n):this._updateVertexBuffers(t,n))},tW._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},tW._createVertexBuffers=function(t,r){var n=this._engine,a=this._modelMesh,i=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),d=Math.ceil(i/c),u=s*t*Math.min(c,i);o.length=d,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=i;for(var h=this._bufferBindingOffset,_=0;_<d;_++){var f=d-1,p=(_===f?i-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new dO(n,e.BufferBindFlag.VertexBuffer,m,g);a._setVertexBufferBinding(h+_,new dH(v,p)),o[_]=v}},tW._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,a=n*t,i=1;a>r&&(i=Math.ceil(a/r),a=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new dJ(this._engine,a,i,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*a*i*4),this._vertexTexture=o,this._dataTextureInfo.set(n,a,i)},tW._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,d=this._bufferBindingOffset,u=0,h=r.length;u<h;u++){var _=s[u];if(t||_.flag){var f=r[u].frames,p=f.length,m=f[p-1];if(p>0&&m.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var g=Math.floor(u/n),v=u%n,y=i[g],x=y.byteLength/(4*e),b=v*l,S=o[u];S||(o[u]=S=new cD),S.set(d+g,v*c);for(var C=m.deltaPositions,T=0;T<e;T++){var A=b+x*T,M=C[T];M&&(a[A]=M.x,a[A+1]=M.y,a[A+2]=M.z)}if(b+=3,this._useBlendNormal){var E=m.deltaNormals;if(E)for(var R=0;R<e;R++){var w=b+x*R,P=E[R];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=b+x*L,B=F[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}b+=3}(v===n-1||u===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},tW._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=i[o],c=n.width*n.height*4;if(t||l.flag){var d=r[o].frames,u=d.length,h=d[u-1];if(u>0&&h.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=h.deltaPositions,f=h.deltaNormals,p=h.deltaTangents,m=o*c,g=0;g<e;g++){var v=_[g];if(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,a)},tW._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;r&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&n++,i&&n++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=n},tW._attributeModeUpdateVertexElement=function(e,t,r,n){var a=this._vertexElementOffset+this._vertexElementCount*n,i=t[r],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var d=e[++a];s+=12,d.bindingIndex=o,d.offset=s}},tW._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},tW._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<n)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var d=0;d<n;d++){var u=t[d];u<o&&(o=u,r=d)}}}},tH);d$._blendShapeMacro=du.getByName("RENDERER_HAS_BLENDSHAPE"),d$._blendShapeTextureMacro=du.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),d$._blendShapeNormalMacro=du.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),d$._blendShapeTangentMacro=du.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),d$._blendShapeWeightsProperty=dn.getByName("renderer_BlendShapeWeights"),d$._blendShapeTextureProperty=dn.getByName("renderer_BlendShapeTexture"),d$._blendShapeTextureInfoProperty=dn.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(tK=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",tK.Normal="NORMAL",tK.Color="COLOR_0",tK.Tangent="TANGENT",tK.BoneWeight="WEIGHTS_0",tK.BoneIndex="JOINTS_0",tK.UV="TEXCOORD_0",tK.UV1="TEXCOORD_1",tK.UV2="TEXCOORD_2",tK.UV3="TEXCOORD_3",tK.UV4="TEXCOORD_4",tK.UV5="TEXCOORD_5",tK.UV6="TEXCOORD_6",tK.UV7="TEXCOORD_7";var d0=(cH(tj=function(e,t){var r;return(r=dG.call(this,e)||this)._internalVertexBufferIndex=-1,r._vertexCount=0,r._vertexCountDirty=!1,r._dataVersionCounter=0,r._positions=null,r._normals=null,r._colors=null,r._tangents=null,r._uv=null,r._uv1=null,r._uv2=null,r._uv3=null,r._uv4=null,r._uv5=null,r._uv6=null,r._uv7=null,r._boneWeights=null,r._boneIndices=null,r._advancedElementUpdateFlag=0,r._advancedDataUpdateFlag=0,r._advancedVertexDataVersions=Array(14),r._advancedDataSyncToBuffer=!1,r._internalVertexBufferStride=0,r._internalVertexBufferCreatedInfo=new cC(0,0,-1),r._internalVertexElementsOffset=0,r._internalVertexElementsFlags=0,r._vertexBufferInfos=[],r._indices=null,r._indicesFormat=null,r._indicesChangeFlag=!1,r._accessible=!0,r.name=t,r._blendShapeManager=new d$(e,ck(r)),r},dG),(tX=tj.prototype).setPositions=function(e){var t;(this._positions||e)&&(this._updateAdvancedVertexDataMarks(1,0),this._positions=e,this._vertexCount=null!=(t=null==e?void 0:e.length)?t:0,this._vertexCountDirty=!1)},tX.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},tX.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},tX.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},tX.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},tX.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},tX.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},tX.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},tX.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},tX.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},tX.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},tX.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},tX.setUVs=function(e,t){switch(t=null!=t?t:0){case 0:this._beforeSetAdvancedVertexData(e,64,6),this._uv=e;break;case 1:this._beforeSetAdvancedVertexData(e,128,7),this._uv1=e;break;case 2:this._beforeSetAdvancedVertexData(e,256,8),this._uv2=e;break;case 3:this._beforeSetAdvancedVertexData(e,512,9),this._uv3=e;break;case 4:this._beforeSetAdvancedVertexData(e,1024,10),this._uv4=e;break;case 5:this._beforeSetAdvancedVertexData(e,2048,11),this._uv5=e;break;case 6:this._beforeSetAdvancedVertexData(e,4096,12),this._uv6=e;break;case 7:this._beforeSetAdvancedVertexData(e,8192,13),this._uv7=e;break;default:throw"The index of channel needs to be in range [0 - 7]."}},tX.getUVs=function(t){switch(t=null!=t?t:0){case 0:var r=this._getVertexElementData(this._uv,e.VertexAttribute.UV,6,this._readVector2VertexData);return this._uv=r,r;case 1:var n=this._getVertexElementData(this._uv1,e.VertexAttribute.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var a=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=a,a;case 3:var i=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var o=this._getVertexElementData(this._uv4,e.VertexAttribute.UV4,10,this._readVector2VertexData);return this._uv4=o,o;case 5:var s=this._getVertexElementData(this._uv5,e.VertexAttribute.UV5,11,this._readVector2VertexData);return this._uv5=s,s;case 6:var l=this._getVertexElementData(this._uv6,e.VertexAttribute.UV6,12,this._readVector2VertexData);return this._uv6=l,l;case 7:var c=this._getVertexElementData(this._uv7,e.VertexAttribute.UV7,13,this._readVector2VertexData);return this._uv7=c,c}throw"The index of channel needs to be in range [0 - 7]."},tX.setIndices=function(t){this._indices!==t&&(this._indices=t,cK(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:cK(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:cK(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},tX.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},tX.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,a=0;a<n;a++)this._addVertexElement(t[a]);var i=this._primitive._vertexElementMap;i[e.VertexAttribute.Position]||this.setPositions(null),i[e.VertexAttribute.Normal]||this.setNormals(null),i[e.VertexAttribute.Color]||this.setColors(null),i[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),i[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),i[e.VertexAttribute.Tangent]||this.setTangents(null),i[e.VertexAttribute.UV]||this.setUVs(null,0),i[e.VertexAttribute.UV1]||this.setUVs(null,1),i[e.VertexAttribute.UV2]||this.setUVs(null,2),i[e.VertexAttribute.UV3]||this.setUVs(null,3),i[e.VertexAttribute.UV4]||this.setUVs(null,4),i[e.VertexAttribute.UV5]||this.setUVs(null,5),i[e.VertexAttribute.UV6]||this.setUVs(null,6),i[e.VertexAttribute.UV7]||this.setUVs(null,7);var o=this._internalVertexBufferCreatedInfo.z;-1!==o&&(null==(r=this._primitive.vertexBufferBindings[o])||r.buffer.destroy(),this._setVertexBufferBinding(o,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},tX.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dH(e,t));var i=a?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,n),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},tX.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+r;n.length<i&&(n.length=i,a.length=i);for(var o=0;o<r;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},tX.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},tX.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},tX.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},tX.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},tX.uploadData=function(t){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(t),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var r=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,a=0,i=n.length;a<i;a++){var o=r[a];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[a])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,d=null==(u=this._primitive.indexBufferBinding)?void 0:u._buffer;if(c){if(d&&c.byteLength==d.byteLength)d.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new dk(d,this._indicesFormat));else{null==d||d.destroy();var u,h=new dO(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new dk(h,this._indicesFormat))}}else d&&(d.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var _=this._blendShapeManager;_._blendShapeCount>0&&_._update(t),t&&(this._accessible=!1,this._releaseCache(!1))},tX.calculateTangents=function(){var e=this.getPositions(),t=this.getNormals(),r=this.getUVs();if(!t||!r)throw"Set normal and uv before calculation.";for(var n=this._indices,a=this.vertexCount,i=tj._tempVec0,o=tj._tempVec1,s=tj._tempVec2,l=tj._tempVec3,c=tj._tempVec4,d=n?n.length/3:e.length/3,u=Array(a),h=Array(a),_=0;_<a;_++)u[_]=new cB,h[_]=new cC;for(var f=0;f<d;f++){var p=3*f,m=3*f+1,g=3*f+2;n&&(p=n[p],m=n[m],g=n[g]);var v=e[p],y=e[m],x=e[g],b=r[p],S=r[m],C=r[g];cC.subtract(y,v,i),cC.subtract(x,v,o);var T=S.x-b.x,A=C.x-b.x,M=S.y-b.y,E=C.y-b.y,R=1/(T*E-A*M);cC.scale(i,E*R,s),cC.scale(o,M*R,c),cC.subtract(s,c,s),cC.scale(o,T*R,l),cC.scale(i,A*R,c),cC.subtract(l,c,l);var w=u[p];w.set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=u[m]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=u[g]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<a;P++){var F=t[P],L=h[P],D=u[P];s.set(D.x,D.y,D.z),cC.cross(s,L,c);var B=cC.dot(c,F)>0?1:-1;cC.scale(F,cC.dot(s,F),c),cC.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,B)}this.setTangents(u)},tX._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=function(){r._advancedDataSyncToBuffer||(a[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(i),dG.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(i),(a[e]||(a[e]=new d1)).reset(),i()):e+1==n.length&&n.length--},tX._getVertexTypedArray=function(t,r){switch(r){case e.DataType.BYTE:return new Int8Array(t);case e.DataType.UNSIGNED_BYTE:return new Uint8Array(t);case e.DataType.SHORT:return new Int16Array(t);case e.DataType.UNSIGNED_SHORT:return new Uint16Array(t);case e.DataType.FLOAT:return new Float32Array(t)}},tX._onDestroy=function(){dG.prototype._onDestroy.call(this),this._releaseCache(!0)},tX._getVertexElementData=function(e,t,r,n){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[r])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[r]=l,n.call(this,t))},tX._beforeSetAdvancedVertexData=function(e,t,r){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(t,r)},tX._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},tX._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,a=this._internalVertexBufferCreatedInfo,i=r*n;if(a.x*a.y!==i){var o,s=a.z;-1!==s&&(null==(o=this._primitive.vertexBufferBindings[s])||o.buffer.destroy(),this._setVertexBufferBinding(s,null));var l=this._internalVertexBufferIndex,c=r*this.vertexCount>0;if(c){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var d=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,u=new dO(this._engine,e.BufferBindFlag.VertexBuffer,i,d,!0);this._setVertexBufferBinding(l,new dH(u,r))}a.set(r,n,c?l:-1)}},tX._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new cD(e[t],e[t+1])})},tX._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new cC(e[t],e[t+1],e[t+2])})},tX._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new cB(e[t],e[t+1],e[t+2],e[t+3])})},tX._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new cI(e[t],e[t+1],e[t+2],e[t+3])})},tX._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var a=r.vertexBufferBindings[n.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=n._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),d=n.offset,u=a.stride,h=0;h<o;h++){var _=(h*u+d)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},tX._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new dW(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=r,this._blendShapeManager._vertexElementOffset++}}else{var s=n[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~r):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},tX._updateAdvancedVertexElements=function(){var t=this._advancedElementUpdateFlag;1&t&&this._updateAdvancedVertexElement(this._positions,e.VertexAttribute.Position,1),2&t&&this._updateAdvancedVertexElement(this._normals,e.VertexAttribute.Normal,2),4&t&&this._updateAdvancedVertexElement(this._colors,e.VertexAttribute.Color,4),16&t&&this._updateAdvancedVertexElement(this._boneWeights,e.VertexAttribute.BoneWeight,16),32&t&&this._updateAdvancedVertexElement(this._boneIndices,e.VertexAttribute.BoneIndex,32),8&t&&this._updateAdvancedVertexElement(this._tangents,e.VertexAttribute.Tangent,8),64&t&&this._updateAdvancedVertexElement(this._uv,e.VertexAttribute.UV,64),128&t&&this._updateAdvancedVertexElement(this._uv1,e.VertexAttribute.UV1,128),256&t&&this._updateAdvancedVertexElement(this._uv2,e.VertexAttribute.UV2,256),512&t&&this._updateAdvancedVertexElement(this._uv3,e.VertexAttribute.UV3,512),1024&t&&this._updateAdvancedVertexElement(this._uv4,e.VertexAttribute.UV4,1024),2048&t&&this._updateAdvancedVertexElement(this._uv5,e.VertexAttribute.UV5,2048),4096&t&&this._updateAdvancedVertexElement(this._uv6,e.VertexAttribute.UV6,4096),8192&t&&this._updateAdvancedVertexElement(this._uv7,e.VertexAttribute.UV7,8192)},tX._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,r=e.length,n=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<r&&this._setVertexElementsLength(i)}},tX._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y)})},tX._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},tX._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},tX._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},tX._writeAdvancedVertexData=function(e,t,r){var n,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(n=this._advancedVertexDataVersions[t])?n:-1,d=this._vertexBufferInfos[o];if(c>d.dataVersion){for(var u=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,u.type),_=i.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=u.normalized,g=u.size,v=u.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var b=(y*f+_)/p;if(r(h,b,y),m)for(var S=0;S<g;S++)h[b+S]/=v}d.uploadAdvancedData=!0}}},tX._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,a=this._advancedDataUpdateFlag,i=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,d=this._uv2,u=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&a&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),i&&16&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,i),o&&32&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),d&&256&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,d),u&&512&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,u),h&&1024&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},tX._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,r=this._primitive.vertexBufferBindings,n=r.length;t<n&&r[t];t++);return this._internalVertexBufferIndex=t,t},tX._getAttributeFormat=function(t){switch(t){case e.VertexAttribute.Position:case e.VertexAttribute.Normal:return e.VertexElementFormat.Vector3;case e.VertexAttribute.Color:case e.VertexAttribute.BoneWeight:case e.VertexAttribute.Tangent:return e.VertexElementFormat.Vector4;case e.VertexAttribute.BoneIndex:return e.VertexElementFormat.UByte4;case e.VertexAttribute.UV:case e.VertexAttribute.UV1:case e.VertexAttribute.UV2:case e.VertexAttribute.UV3:case e.VertexAttribute.UV4:case e.VertexAttribute.UV5:case e.VertexAttribute.UV6:case e.VertexAttribute.UV7:return e.VertexElementFormat.Vector2}},tX._getAttributeByteLength=function(t){switch(t){case e.VertexAttribute.Position:case e.VertexAttribute.Normal:return 12;case e.VertexAttribute.Color:case e.VertexAttribute.BoneWeight:case e.VertexAttribute.Tangent:return 16;case e.VertexAttribute.BoneIndex:return 4;case e.VertexAttribute.UV:case e.VertexAttribute.UV1:case e.VertexAttribute.UV2:case e.VertexAttribute.UV3:case e.VertexAttribute.UV4:case e.VertexAttribute.UV5:case e.VertexAttribute.UV6:case e.VertexAttribute.UV7:return 8}},tX._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,r=this._dataVersionCounter++,n=this._vertexBufferInfos,a=0,i=n.length;a<i;a++){var o=n[a];o&&(o.dataVersion=r)}}},cU(tj,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var t=0,r=this._primitive._vertexElementMap[e.VertexAttribute.Position];if(r){var n=this._primitive.vertexBufferBindings[r.bindingIndex];n&&(t=n.buffer.byteLength/n.stride)}this._vertexCount=t,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._primitive.vertexElements}},{key:"vertexBufferBindings",get:function(){return this._primitive.vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}},{key:"accessible",get:function(){return this._accessible}}]),tj);d0._tempVec0=new cC,d0._tempVec1=new cC,d0._tempVec2=new cC,d0._tempVec3=new cC,d0._tempVec4=new cC;var d1=((tq=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},tq);(tY=lY||(lY={}))[tY.None=0]="None",tY[tY.Position=1]="Position",tY[tY.Normal=2]="Normal",tY[tY.Color=4]="Color",tY[tY.Tangent=8]="Tangent",tY[tY.BoneWeight=16]="BoneWeight",tY[tY.BoneIndex=32]="BoneIndex",tY[tY.UV=64]="UV",tY[tY.UV1=128]="UV1",tY[tY.UV2=256]="UV2",tY[tY.UV3=512]="UV3",tY[tY.UV4=1024]="UV4",tY[tY.UV5=2048]="UV5",tY[tY.UV6=4096]="UV6",tY[tY.UV7=8192]="UV7",tY[tY.All=65535]="All",(tQ=lQ||(lQ={}))[tQ.Position=0]="Position",tQ[tQ.Normal=1]="Normal",tQ[tQ.Color=2]="Color",tQ[tQ.Tangent=3]="Tangent",tQ[tQ.BoneWeight=4]="BoneWeight",tQ[tQ.BoneIndex=5]="BoneIndex",tQ[tQ.UV=6]="UV",tQ[tQ.UV1=7]="UV1",tQ[tQ.UV2=8]="UV2",tQ[tQ.UV3=9]="UV3",tQ[tQ.UV4=10]="UV4",tQ[tQ.UV5=11]="UV5",tQ[tQ.UV6=12]="UV6",tQ[tQ.UV7=13]="UV7";var d2=function(e){this.resource=e},d3=(cH(tJ=function(e,t){var r;return(r=d2.call(this,e)||this).primitiveInfo=t,r},d2),tJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:un._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:un._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:un._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:un._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:un._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:un._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:un._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:un._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},tJ);(tZ=lJ||(lJ={}))[tZ.Sphere=0]="Sphere",tZ[tZ.Cuboid=1]="Cuboid",tZ[tZ.Plane=2]="Plane",tZ[tZ.Cylinder=3]="Cylinder",tZ[tZ.Torus=4]="Torus",tZ[tZ.Cone=5]="Cone",tZ[tZ.Capsule=6]="Capsule",tZ[tZ.CCSphere=7]="CCSphere";var d4=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},d8=(cH(t$=function(e,t,r,n){var a;return(a=d4.call(this,0,r,n)||this).radius=e,a.segments=t,a},d4),t$),d5=(cH(t0=function(e,t,r,n){var a;return(a=d4.call(this,7,r,n)||this).radius=e,a.step=t,a},d4),t0),d9=(cH(t1=function(e,t,r,n,a){var i;return(i=d4.call(this,1,n,a)||this).width=e,i.height=t,i.depth=r,i},d4),t1),d6=(cH(t2=function(e,t,r,n,a,i){var o;return(o=d4.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},d4),t2),d7=(cH(t3=function(e,t,r,n,a,i,o){var s;return(s=d4.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=a,s},d4),t3),ue=(cH(t4=function(e,t,r,n,a,i,o){var s;return(s=d4.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=a,s},d4),t4),ut=(cH(t8=function(e,t,r,n,a,i){var o;return(o=d4.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d4),t8),ur=(cH(t5=function(e,t,r,n,a,i){var o;return(o=d4.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d4),t5),un=((t9=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var a=new d0(e);t9._setSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(a,new d8(t,r,i,n))),a},t9.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var a=new d0(e);t9._setSubdivisionSurfaceSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(a,new d5(t,r,i,n))),a},t9.createCuboid=function(e,t,r,n,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=!0);var i=new d0(e);t9._setCuboidData(i,t,r,n,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(i,new d9(t,r,n,o,a))),i},t9.createPlane=function(e,t,r,n,a,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d0(e);t9._setPlaneData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new d6(t,r,n,a,s,i))),o},t9.createCylinder=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new d0(e);t9._setCylinderData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(s,new d7(t,r,n,a,i,l,o))),s},t9.createTorus=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===a&&(a=30),void 0===i&&(i=360),void 0===o&&(o=!0);var s=new d0(e);t9._setTorusData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(s,new ue(t,r,n,a,i,l,o))),s},t9.createCone=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d0(e);t9._setConeData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new ut(t,r,n,a,s,i))),o},t9.createCapsule=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d0(e);t9._setCapsuleData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new ur(t,r,n,a,s,i))),o},t9._setSubdivisionSurfaceSphereData=function(e,t,r,n,a,i){r=cS.clamp(Math.floor(r),1,6);var o=new Float32Array(3*(6*Math.pow(4,r)+2)),s=new Float32Array(24*Math.pow(4,r));t9._subdiveCatmullClark(r,o,s);for(var l=o.length/3,c=s.length/4,d=l+Math.pow(2,r+1)-1,u=d+16,h=new Float32Array(8*u),_=t9._generateIndices(e.engine,l,6*c),f=0,p={},m=0;m<l;m++){var g=3*m,v=o[g],y=o[g+1],x=o[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*t,h[g+1]=y*t,h[g+2]=x*t,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var S=8*(l+f++);h.set(h.subarray(g,g+8),S),h[S+6]=1,p[g/8]=S/8}}var C=0;this._spherePoleIdx=0;for(var T=0;T<c;T++){var A=4*T,M=s[A],E=s[A+1],R=s[A+2],w=s[A+3],P=8*M,F=8*E,L=8*R,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(M=p[M]),0===h[F+6]&&(E=p[E]),0===h[L+6]&&(R=p[R]),0===h[D+6]&&(w=p[w])),_[C]=M,_[C+1]=E,_[C+2]=R,this._generateAndReplacePoleUV(_,h,C,d),_[C+3]=M,_[C+4]=R,_[C+5]=w,this._generateAndReplacePoleUV(_,h,C+3,d),C+=6}if(!a){var B=e.bounds;B.min.set(-t,-t,-t),B.max.set(t,t,t)}t9._initialize(e,h,_,n,a,i)},t9._setSphereData=function(e,t,r,n,a,i){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=t9._generateIndices(e.engine,s,6*l),d=Math.PI,u=2*d,h=1/o,_=1/r,f=new Float32Array(8*s),p=0;p<s;++p){var m=p%o*_,g=(p*h|0)*_,v=m*u,y=g*d,x=Math.sin(y),b=-t*Math.cos(v)*x,S=t*Math.cos(y),C=t*Math.sin(v)*x,T=8*p;f[T++]=b,f[T++]=S,f[T++]=C,f[T++]=b,f[T++]=S,f[T++]=C,f[T++]=m,f[T++]=g}for(var A=0,M=0;M<l;++M){var E=M%r,R=(M*_|0)*o+E,w=R+1,P=R+o,F=P+1;c[A++]=w,c[A++]=R,c[A++]=F,c[A++]=R,c[A++]=P,c[A++]=F}if(!a){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}t9._initialize(e,f,c,n,a,i)},t9._subdiveCatmullClark=function(e,t,r){var n=new Map,a=[];t.set(t9._sphereSeedPositions),r.set(t9._sphereSeedCells);for(var i=0;i<e;i++){var o=6*Math.pow(4,i),s=4*o+2;n.clear(),a.length=0;for(var l=0;l<o;l++){for(var c=a[l]={facePoint:new cC,adjacentEdges:[,,,,]},d=0;d<4;d++){var u=3*r[4*l+d];c.facePoint.x+=.25*t[u],c.facePoint.y+=.25*t[u+1],c.facePoint.z+=.25*t[u+2]}for(var h=0;h<4;h++){var _=r[4*l+h],f=r[4*l+(h+1)%4],p=Math.min(_,f)*s+Math.max(_,f);if(!n.has(p)){var m={edgePoint:new cC,edgePointIndex:void 0},g=3*_,v=3*f;m.edgePoint.set(.25*(t[g]+t[v]),.25*(t[g+1]+t[v+1]),.25*(t[g+2]+t[v+2])),n.set(p,m)}var y=n.get(p);c.adjacentEdges[h]=y;var x=y.edgePoint,b=c.facePoint;x.x+=.25*b.x,x.y+=.25*b.y,x.z+=.25*b.z}}var S=o+2,C=S+o,T=0;this._sphereEdgeIdx=0;for(var A=r.slice(0,4*o),M=0;M<o;M++){var E=a[M];E.facePoint.copyToArray(t,3*(S+M));for(var R=S+M,w=void 0,P=void 0,F=void 0,L=0;L<4;L++){var D=A[T++];switch(L){case 0:var B=E.adjacentEdges[L%4],I=E.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,B,C),F=w=this._calculateEdgeIndex(t,I,C);break;case 1:case 2:var V=E.adjacentEdges[L%4];w=P,P=this._calculateEdgeIndex(t,V,C);break;case 3:w=P,P=F}var O=4*(4*M+L);r[O]=D,r[O+1]=P,r[O+2]=R,r[O+3]=w}}}},t9._generateAndReplacePoleUV=function(e,t,r,n){var a=t[8*e[r]+7];if(0===a||1===a){var i=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},t9._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+t9._sphereEdgeIdx));var n=r+t9._sphereEdgeIdx++;return t.edgePointIndex=n,n},t9._setCuboidData=function(e,t,r,n,a,i,o){var s=t/2,l=r/2,c=n/2,d=new Float32Array(192);d[0]=-s,d[1]=l,d[2]=-c,d[6]=0,d[7]=0,d[8]=s,d[9]=l,d[10]=-c,d[14]=1,d[15]=0,d[16]=s,d[17]=l,d[18]=c,d[22]=1,d[23]=1,d[24]=-s,d[25]=l,d[26]=c,d[30]=0,d[31]=1;for(var u=0;u<4;u++){var h=8*u+3;d[h++]=0,d[h++]=1,d[h++]=0}d[32]=-s,d[33]=-l,d[34]=-c,d[38]=0,d[39]=1,d[40]=s,d[41]=-l,d[42]=-c,d[46]=1,d[47]=1,d[48]=s,d[49]=-l,d[50]=c,d[54]=1,d[55]=0,d[56]=-s,d[57]=-l,d[58]=c,d[62]=0,d[63]=0;for(var _=0;_<4;_++){var f=8*_+35;d[f++]=0,d[f++]=-1,d[f++]=0}d[64]=-s,d[65]=l,d[66]=-c,d[70]=0,d[71]=0,d[72]=-s,d[73]=l,d[74]=c,d[78]=1,d[79]=0,d[80]=-s,d[81]=-l,d[82]=c,d[86]=1,d[87]=1,d[88]=-s,d[89]=-l,d[90]=-c,d[94]=0,d[95]=1;for(var p=0;p<4;p++){var m=8*p+67;d[m++]=-1,d[m++]=0,d[m++]=0}d[96]=s,d[97]=l,d[98]=-c,d[102]=1,d[103]=0,d[104]=s,d[105]=l,d[106]=c,d[110]=0,d[111]=0,d[112]=s,d[113]=-l,d[114]=c,d[118]=0,d[119]=1,d[120]=s,d[121]=-l,d[122]=-c,d[126]=1,d[127]=1;for(var g=0;g<4;g++){var v=8*g+99;d[v++]=1,d[v++]=0,d[v++]=0}d[128]=-s,d[129]=l,d[130]=c,d[134]=0,d[135]=0,d[136]=s,d[137]=l,d[138]=c,d[142]=1,d[143]=0,d[144]=s,d[145]=-l,d[146]=c,d[150]=1,d[151]=1,d[152]=-s,d[153]=-l,d[154]=c,d[158]=0,d[159]=1;for(var y=0;y<4;y++){var x=8*y+131;d[x++]=0,d[x++]=0,d[x++]=1}d[160]=-s,d[161]=l,d[162]=-c,d[166]=1,d[167]=0,d[168]=s,d[169]=l,d[170]=-c,d[174]=0,d[175]=0,d[176]=s,d[177]=-l,d[178]=-c,d[182]=0,d[183]=1,d[184]=-s,d[185]=-l,d[186]=-c,d[190]=1,d[191]=1;for(var b=0;b<4;b++){var S=8*b+163;d[S++]=0,d[S++]=0,d[S++]=-1}var C=new Uint16Array(36);if(C[0]=0,C[1]=2,C[2]=1,C[3]=2,C[4]=0,C[5]=3,C[6]=4,C[7]=6,C[8]=7,C[9]=6,C[10]=4,C[11]=5,C[12]=8,C[13]=10,C[14]=9,C[15]=10,C[16]=8,C[17]=11,C[18]=12,C[19]=14,C[20]=15,C[21]=14,C[22]=12,C[23]=13,C[24]=16,C[25]=18,C[26]=17,C[27]=18,C[28]=16,C[29]=19,C[30]=20,C[31]=22,C[32]=23,C[33]=22,C[34]=20,C[35]=21,!i){var T=e.bounds;T.min.set(-s,-l,-c),T.max.set(s,l,c)}t9._initialize(e,d,C,a,i,o)},t9._setPlaneData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(a=Math.max(1,Math.floor(a)))+1,d=t/2,u=r/2,h=t/n,_=r/a,f=l*c,p=a*n,m=t9._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/a,x=new Float32Array(8*f),b=0;b<f;++b){var S=b%l,C=b*g|0,T=8*b;x[T++]=S*h-d,x[T++]=0,x[T++]=C*_-u,x[T++]=0,x[T++]=1,x[T++]=0,x[T++]=S*v,x[T++]=C*y}for(var A=0,M=0;M<p;++M){var E=M%n,R=(M*v|0)*l+E,w=R+1,P=R+l,F=P+1;m[A++]=R,m[A++]=P,m[A++]=w,m[A++]=P,m[A++]=F,m[A++]=w}if(!o){var L=e.bounds;L.min.set(-d,0,-u),L.max.set(d,0,u)}t9._initialize(e,x,m,i,o,s)},t9._setCylinderData=function(e,t,r,n,a,i,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1);for(var c=(a=Math.floor(a))+1,d=(i=Math.floor(i))+1,u=.5*n,h=n/i,_=c*d,f=a*i,p=2*a,m=_+2+p,g=t9._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*m),S=0,C=Math.PI,T=2*Math.PI,A=r-t,M=A/n,E=A/i,R=0;R<_;++R){var w=R%c,P=R*v|0,F=w*y,L=P*x,D=C+F*T,B=Math.sin(D),I=Math.cos(D),V=r-P*E,O=V*B,N=P*h-u,k=V*I,z=8*R;b[z++]=O,b[z++]=N,b[z++]=k,b[z++]=B,b[z++]=M,b[z++]=I,b[z++]=F,b[z++]=1-L}for(var U=0;U<f;++U){var G=U%a,H=(U*y|0)*c+G,W=H+1,K=H+c,j=K+1;g[S++]=W,g[S++]=K,g[S++]=H,g[S++]=W,g[S++]=j,g[S++]=K}var X=8*_;b[X++]=0,b[X++]=-u,b[X++]=0,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=.5,b[X++]=.5,b[X++]=0,b[X++]=u,b[X++]=0,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=.5,b[X++]=.5,X=(_+2)*8;for(var q=1/(2*t),Y=1/(2*r),Q=c*i,J=0;J<a;++J){var Z=8*J,$=b[Z],ee=b[Z+2];b[X++]=$,b[X++]=-u,b[X++]=ee,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=$*Y+.5,b[X++]=.5-ee*Y;var et=(J+Q)*8;$=b[et],ee=b[et+2],b[X++]=$,b[X++]=u,b[X++]=ee,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=$*q+.5,b[X++]=.5-ee*q}for(var er=_+1,en=_+2,ea=en+1,ei=0;ei<a;++ei){var eo=2*ei,es=ei===a-1?0:eo+2;g[S++]=_,g[S++]=en+es,g[S++]=en+eo,g[S++]=er,g[S++]=ea+eo,g[S++]=ea+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-u,-ec),el.max.set(ec,u,ec)}t9._initialize(e,b,g,o,s,l)},t9._setTorusData=function(e,t,r,n,a,i,o,s,l){var c=((n=Math.floor(n))+1)*((a=Math.floor(a))+1),d=n*a,u=t9._generateIndices(e.engine,c,6*d),h=new Float32Array(8*c);i=i/180*Math.PI;for(var _=0,f=t9._tempVec30,p=0;p<=n;p++)for(var m=0;m<=a;m++){var g=m/a*i,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),b=Math.sin(g),S=(t+r*y)*x,C=(t+r*y)*b,T=r*Math.sin(v);h[_++]=S,h[_++]=C,h[_++]=T;var A=t*x,M=t*b;f.set(S-A,C-M,T).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/a,h[_++]=p/n}_=0;for(var E=1;E<=n;E++)for(var R=1;R<=a;R++){var w=(a+1)*E+R-1,P=(a+1)*(E-1)+R-1,F=(a+1)*(E-1)+R,L=(a+1)*E+R;u[_++]=w,u[_++]=P,u[_++]=L,u[_++]=P,u[_++]=F,u[_++]=L}if(!s){var D=e.bounds,B=t+r;D.min.set(-B,-B,-r),D.max.set(B,B,r)}t9._initialize(e,h,u,o,s,l)},t9._setConeData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.floor(n))+1,c=(a=Math.floor(a))+1,d=.5*r,u=r/a,h=l*c,_=n*a,f=h+1+n,p=t9._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/a,y=new Float32Array(8*f),x=0,b=Math.PI,S=2*Math.PI,C=t/r,T=0;T<h;++T){var A=T%l,M=T*m|0,E=A*g,R=M*v,w=b+E*S,P=Math.sin(w),F=Math.cos(w),L=t-R*t,D=L*P,B=M*u-d,I=L*F,V=8*T;y[V++]=D,y[V++]=B,y[V++]=I,y[V++]=P,y[V++]=C,y[V++]=F,y[V++]=E,y[V++]=1-R}for(var O=0;O<_;++O){var N=O%n,k=(O*g|0)*l+N,z=k+1,U=k+l,G=U+1;p[x++]=z,p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=G,p[x++]=U}var H=8*h;y[H++]=0,y[H++]=-d,y[H++]=0,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=.5,y[H++]=.5,H=(h+1)*8;for(var W=1/(2*t),K=0;K<n;++K){var j=y[8*K],X=y[8*K+2];y[H++]=j,y[H++]=-d,y[H++]=X,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=j*W+.5,y[H++]=.5-X*W}for(var q=h+1,Y=0;Y<n;++Y){var Q=Y,J=Y===n-1?0:Q+1;p[x++]=h,p[x++]=q+J,p[x++]=q+Q}if(!o){var Z=e.bounds;Z.min.set(-t,-d,-t),Z.max.set(t,d,t)}t9._initialize(e,y,p,i,o,s)},t9._setCapsuleData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(a=Math.floor(a))+1,d=.5*r,u=r/a,h=l*c,_=n*a,f=l*l,p=n*n,m=h+2*f,g=t9._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/a,b=Math.PI,S=2*Math.PI,C=new Float32Array(8*m),T=0,A=0;A<h;++A){var M=A%l,E=A*v|0,R=M*y,w=E*x,P=b+R*S,F=Math.sin(P),L=Math.cos(P),D=8*A;C[D++]=t*F,C[D++]=E*u-d,C[D++]=t*L,C[D++]=F,C[D++]=0,C[D++]=L,C[D++]=R,C[D++]=1-w}for(var B=0;B<_;++B){var I=B%n,V=(B*y|0)*l+I,O=V+1,N=V+l,k=N+1;g[T++]=O,g[T++]=N,g[T++]=V,g[T++]=O,g[T++]=k,g[T++]=N}if(t9._createCapsuleCap(t,r,n,b,S,h,1,C,g,T),t9._createCapsuleCap(t,r,n,b,-S,h+f,-1,C,g,T+6*p),!o){var z=e.bounds;z.min.set(-t,-t-d,-t),z.max.set(t,t+d,t)}t9._initialize(e,C,g,i,o,s)},t9._initialize=function(t,r,n,a,i,o){if(i)o.setData(r),t.setIndices(n),t.uploadData(a);else{var s=[new dW(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new dW(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new dW(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new dO(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(a),t.addSubMesh(0,n.length)}},t9._generateIndices=function(t,r,n){var a=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))a=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(n);return a},t9._createCapsuleCap=function(e,t,r,n,a,i,o,s,l,c){for(var d=r+1,u=.5*t*o,h=d*d,_=r*r,f=1/d,p=1/r,m=0;m<h;++m){var g=m%d*p,v=(m*f|0)*p,y=n+g*a,x=v*Math.PI*.5,b=Math.sin(x),S=e*Math.sin(y)*b,C=e*Math.cos(x)*o+u,T=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=S,s[A++]=C,s[A++]=T,s[A++]=S,s[A++]=C-u,s[A++]=T,s[A++]=g,s[A++]=v}for(var M=0;M<_;++M){var E=M%r,R=(M*p|0)*d+E+i,w=R+1,P=R+d,F=P+1;l[c++]=w,l[c++]=R,l[c++]=F,l[c++]=R,l[c++]=P,l[c++]=F}},t9);function ua(e,t,r){return(ua=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&cG(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}un._tempVec30=new cC,un._sphereSeedPositions=new Float32Array([-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1]),un._sphereSeedCells=new Float32Array([0,1,2,3,3,2,4,5,5,4,6,7,7,0,3,5,7,6,1,0,6,4,2,1]),un._sphereEdgeIdx=0,un._spherePoleIdx=0,e.Layer=void 0,(t6=e.Layer||(e.Layer={}))[t6.Layer0=1]="Layer0",t6[t6.Layer1=2]="Layer1",t6[t6.Layer2=4]="Layer2",t6[t6.Layer3=8]="Layer3",t6[t6.Layer4=16]="Layer4",t6[t6.Layer5=32]="Layer5",t6[t6.Layer6=64]="Layer6",t6[t6.Layer7=128]="Layer7",t6[t6.Layer8=256]="Layer8",t6[t6.Layer9=512]="Layer9",t6[t6.Layer10=1024]="Layer10",t6[t6.Layer11=2048]="Layer11",t6[t6.Layer12=4096]="Layer12",t6[t6.Layer13=8192]="Layer13",t6[t6.Layer14=16384]="Layer14",t6[t6.Layer15=32768]="Layer15",t6[t6.Layer16=65536]="Layer16",t6[t6.Layer17=131072]="Layer17",t6[t6.Layer18=262144]="Layer18",t6[t6.Layer19=524288]="Layer19",t6[t6.Layer20=1048576]="Layer20",t6[t6.Layer21=2097152]="Layer21",t6[t6.Layer22=4194304]="Layer22",t6[t6.Layer23=8388608]="Layer23",t6[t6.Layer24=16777216]="Layer24",t6[t6.Layer25=33554432]="Layer25",t6[t6.Layer26=67108864]="Layer26",t6[t6.Layer27=134217728]="Layer27",t6[t6.Layer28=268435456]="Layer28",t6[t6.Layer29=536870912]="Layer29",t6[t6.Layer30=1073741824]="Layer30",t6[t6.Layer31=2147483648]="Layer31",t6[t6.Everything=4294967295]="Everything",t6[t6.Nothing=0]="Nothing";var ui=((t7=function(){}).cloneComponent=function(e,t,r,n,a){var i=cQ.getCloneMode(e.constructor);for(var o in e)cQ.cloneProperty(e,t,o,i[o],r,n,a);e._cloneTo&&e._cloneTo(t,r,n)},t7),uo=(cH(re=function(t,r){var n;return(n=cJ.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new dV,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._isTemplate=!1,n._parent=null,n._invModelMatrix=new cF,n.name=r,n.transform=n.addComponent(dd),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},cJ),(rt=re.prototype).addComponent=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];ds._addCheck(this,e);var a=ua(e,[].concat(this,r));return this._components.push(a),a._setActive(!0,lG.All),a},rt.getComponent=function(e){for(var t=this._components,r=0,n=t.length;r<n;r++){var a=t[r];if(cK(a,e))return a}return null},rt.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];cK(i,e)&&t.push(i)}return t},rt.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},rt.addChild=function(e,t){var r;if("number"==typeof e?r=e:(r=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(r,t),t._parent=this;var n=t._scene,a=this._scene,i=lG.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=lG.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==a&&(i|=lG.Scene):i|=lG.Scene),i&&t._processInActive(i),t._scene!==a&&re._traverseSetOwnerScene(t,a);var o=lG.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=lG.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===a||(o|=lG.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},rt.removeChild=function(e){e._setParent(null)},rt.getChild=function(e){return this._children[e]},rt.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},rt.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,a=t.length;n<a;++n){var i=t[n];if(i&&!(r=re._findChildByName(r,i)))return null}return r},rt.createChild=function(e){var t=new re(this.engine,e);return t.layer=this.layer,t.parent=this,t},rt.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=lG.None;r._isActiveInHierarchy&&(n|=lG.Hierarchy),r._isActiveInScene&&(n|=lG.Scene),n&&r._processInActive(n),re._traverseSetOwnerScene(r,null)}e.length=0},rt.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},rt._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},rt._createCloneEntity=function(){var e=new re(this._engine,this.name),t=this._templateResource;t&&(e._templateResource=t,t._addReferCount(1)),e.layer=this.layer,e._isActive=this._isActive;var r=e.transform,n=this.transform;r.position=n.position,r.rotation=n.rotation,r.scale=n.scale;for(var a=this._children,i=0,o=a.length;i<o;i++)e.addChild(a[i]._createCloneEntity());return e},rt._parseCloneEntity=function(e,t,r,n,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],r,n,a);for(var c=e._components,d=0,u=c.length;d<u;d++){var h=c[d];if(!cK(h,dd)){var _=t.addComponent(h.constructor);ui.cloneComponent(h,_,r,n,a)}}},rt.destroy=function(){if(!this._destroyed){cJ.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},rt._removeComponent=function(e){ds._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},rt._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},rt._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},rt._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,r=this._siblingIndex;t.splice(r,1);for(var n=t.length;r<n;r++)t[r]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},rt._processActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main inActive entity' active in hierarchy, if the operation is in main inActive entity or it's children script's onDisable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!0,e)},rt._processInActive=function(e){if(this._activeChangedComponents)throw"Note: can't set the 'main active entity' inActive in hierarchy, if the operation is in main active entity or it's children script's onEnable Event.";this._activeChangedComponents=this._scene._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents,e),this._setActiveComponents(!1,e)},rt._addToChildrenList=function(e,t){var r=this._children,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},rt._setParent=function(e,t){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var n=this._scene,a=e._scene,i=lG.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=lG.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==a&&(i|=lG.Scene):this._isActiveInScene&&(i|=lG.Scene),i&&this._processInActive(i),n!==a&&re._traverseSetOwnerScene(this,a);var o=lG.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=lG.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===a||(o|=lG.Scene))),o&&this._processActive(o)}else{var s=lG.None;this._isActiveInHierarchy&&(s|=lG.Hierarchy),this._isActiveInScene&&(s|=lG.Scene),s&&this._processInActive(s),r&&re._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},rt._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];cK(n,e)&&t.push(n)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},rt._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,a=r.length;n<a;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},rt._setActiveInHierarchy=function(e,t){t&lG.Hierarchy&&(this._isActiveInHierarchy=!0),t&lG.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},rt._setInActiveInHierarchy=function(e,t){t&lG.Hierarchy&&(this._isActiveInHierarchy=!1),t&lG.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},rt._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},rt._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var r=this._siblingIndex;if(t<r)for(var n=r;n>=t;n--){var a=n==t?this:e[n-1];e[n]=a,a._siblingIndex=n}else for(var i=r;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},rt.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(cF.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},re._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var a=r[n];if(a.name===t)return a}return null},re._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},re._getEntityHierarchyPath=function(e,t,r){for(r.length=0;t!==e;){var n=t.parent;if(!n)return!1;r.push(t.siblingIndex),t=n}return!0},re._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},cU(re,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=lG.None;this._isRoot&&this._scene._isActiveInEngine?r|=lG.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=lG.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=lG.Scene)),r&&this._processActive(r)}else{var n=lG.None;this._isActiveInHierarchy&&(n|=lG.Hierarchy),this._isActiveInScene&&(n|=lG.Scene),n&&this._processInActive(n)}}}},{key:"isActiveInHierarchy",get:function(){return this._isActiveInHierarchy}},{key:"parent",get:function(){return this._parent},set:function(e){this._setParent(e)}},{key:"children",get:function(){return this._children}},{key:"childCount",get:function(){return this._children.length}},{key:"scene",get:function(){return this._scene}},{key:"siblingIndex",get:function(){return this._siblingIndex},set:function(e){if(-1===this._siblingIndex)throw"The entity "+this.name+" is not in the hierarchy";this._setSiblingIndex(this._isRoot?this._scene._rootEntities:this._parent._children,e)}}]),re),us=(cH(rr=function(e){var t;return(t=cJ.call(this,null)||this).name=e,t.inverseBindMatrices=[],t._updatedManager=new c4,t._bones=[],t._updateMark=-1,t.joints=[],t},cJ),(rn=rr.prototype)._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,r=this.bones,n=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=r.length-1;o>=0;o--){var s=r[o],l=16*o;s?c0._floatMatrixMultiply(s.transform.worldMatrix,n[o].elements,0,a,l):a.set(n[o].elements,l),c0._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},rn._cloneTo=function(e,t,r){var n=[],a=this.rootBone;if(a){var i=uo._getEntityHierarchyPath(t,a,n);e.rootBone=i?uo._getEntityByHierarchyPath(r,n):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var d=o[c],u=uo._getEntityHierarchyPath(t,d,n);l[c]=u?uo._getEntityByHierarchyPath(r,n):d}e.bones=l}},cU(rr,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,r=this._bones,n=null!=(t=null==e?void 0:e.length)?t:0,a=r.length;r.length=n;for(var i=0;i<n;i++)r[i]=e[i];a!==n&&(this._skinMatrices=new Float32Array(16*n),this._updatedManager.dispatch(0,n))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),rr);cW([cY],us.prototype,"inverseBindMatrices",void 0),cW([cj],us.prototype,"_skinMatrices",void 0),cW([cj],us.prototype,"_updatedManager",void 0),cW([cj],us.prototype,"_rootBone",void 0),cW([cj],us.prototype,"_bones",void 0),cW([cj],us.prototype,"_updateMark",void 0),(ra=lZ||(lZ={}))[ra.BoneCountChanged=0]="BoneCountChanged",ra[ra.RootBoneChanged=1]="RootBoneChanged";var ul=(cH(ri=function(e){(t=dq.call(this,e)||this)._localBounds=new cA,t._jointDataCreateCache=new cD(-1,-1),t._skin=null;var t,r=t.entity.engine._hardwareRenderer,n=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);n=Math.min(n,r._options._maxAllowSkinUniformVectorCount),t._maxVertexUniformVectors=n,t._onLocalBoundsChanged=t._onLocalBoundsChanged.bind(ck(t)),t._onSkinUpdated=t._onSkinUpdated.bind(ck(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},dq),(ro=ri.prototype).update=function(){var e=this._skin;(null==e?void 0:e.bones.length)>0&&e._updateSkinMatrices(this)},ro._updateShaderData=function(t,r){var n=this.entity,a=this.skin,i=(null!=(_=null==a?void 0:a.rootBone)?_:n).transform.worldMatrix;if(r){this._updateMVPShaderData(t,i);return}this._updateTransformShaderData(t,i);var o=this.shaderData,s=this.mesh._blendShapeManager;s._updateShaderData(o,this);var l=null==a?void 0:a.bones;if(l){var c=s._uniformOccupiesCount,d=l.length,u=this._jointDataCreateCache,h=d!==u.x;if(h||c!==u.y){var _,f,p=Math.ceil((this._maxVertexUniformVectors-(44+c))/4);if(d>p){var m,g=this.engine;g._hardwareRenderer.canIUseMoreJoints?(h&&(null==(m=this._jointTexture)||m.destroy(),this._jointTexture=new dQ(g,4,d,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),o.disableMacro("RENDERER_JOINTS_NUM"),o.enableMacro("RENDERER_USE_JOINT_TEXTURE"),o.setTexture(ri._jointSamplerProperty,this._jointTexture)):dr.error("component's joints count("+d+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+p+".",this)}else null==(f=this._jointTexture)||f.destroy(),o.disableMacro("RENDERER_USE_JOINT_TEXTURE"),o.enableMacro("RENDERER_JOINTS_NUM",p.toString()),o.setFloatArray(ri._jointMatrixProperty,a._skinMatrices);u.set(d,c)}this._jointTexture&&this._jointTexture.setPixelBuffer(a._skinMatrices)}var v=n.layer;this._rendererLayer.set(65535&v,v>>>16&65535,0,0)},ro._onDestroy=function(){var e;dq.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null},ro._cloneTo=function(e,t,r){dq.prototype._cloneTo.call(this,e,t,r),this.skin&&e._applySkin(null,e.skin),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},ro._updateBounds=function(e){var t,r=null==(t=this.skin)?void 0:t.rootBone;r?cA.transform(this._localBounds,r.transform.worldMatrix,e):dq.prototype._updateBounds.call(this,e)},ro._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var a=new Float32Array(t);if(t>n)a.set(r);else for(var i=0;i<t;i++)a[i]=r[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},ro._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=lK.WorldVolume},ro._onSkinUpdated=function(e,t){switch(e){case lZ.BoneCountChanged:var r=this.shaderData;t>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(ri._jointCountProperty,t)):r.disableMacro("RENDERER_HAS_SKIN");break;case lZ.RootBoneChanged:this._dirtyUpdateFlag|=lK.WorldVolume}},ro._applySkin=function(e,t){var r,n,a,i,o,s,l=null!=(a=null==e?void 0:null==(r=e.bones)?void 0:r.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var d=null!=(o=null==t?void 0:null==(n=t.bones)?void 0:n.length)?o:0,u=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==d&&this._onSkinUpdated(lZ.BoneCountChanged,d),c!==u&&this._onSkinUpdated(lZ.RootBoneChanged,u)},cU(ri,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var r=0,n=t.length;r<n;r++)t[r]=e[r]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),ri);ul._jointCountProperty=dn.getByName("renderer_JointCount"),ul._jointSamplerProperty=dn.getByName("renderer_JointSampler"),ul._jointMatrixProperty=dn.getByName("renderer_JointMatrix"),cW([cj],ul.prototype,"_condensedBlendShapeWeights",void 0),cW([cY],ul.prototype,"_localBounds",void 0),cW([cj],ul.prototype,"_jointDataCreateCache",void 0),cW([cj],ul.prototype,"_blendShapeWeights",void 0),cW([cj],ul.prototype,"_maxVertexUniformVectors",void 0),cW([cj],ul.prototype,"_jointTexture",void 0),cW([cY],ul.prototype,"_skin",void 0),cW([cj],ul.prototype,"_onLocalBoundsChanged",null),cW([cj],ul.prototype,"_onSkinUpdated",null);var uc=((rl=(rs=function(e){this._elementPoolIndex=0,this._elementPool=[],this._type=e}).prototype).getFromPool=function(){var e=this._elementPoolIndex,t=this._elementPool;if(this._elementPoolIndex++,t.length!==e)return t[e];var r=new this._type;return t.push(r),r},rl.resetPool=function(){this._elementPoolIndex=0},rl.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},rs),ud=((rd=(rc=function(e){this._subMeshPool=new uc(dz),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=e,this._initMeshes(e)}).prototype).drawElement=function(e,t){var r=e.data;if(r.multiRenderData)for(var n=r.charsData,a=t.engine._renderElementPool,i=0,o=n.length;i<o;++i){var s=a.getFromPool();s.set(n[i],e.shaderPasses),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},rd._initMeshes=function(e){var t=rc.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var r=this._meshes,n=this._meshCount,a=0;a<n;a++)r[a]=this._createMesh(e,a)},rd.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rc._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},rd.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},rd.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,a=e.length;n<a;++n){var i=e[n];i._addReferCount(-1),i.destroy()}this._meshes=null;for(var o=0,s=t.length;o<s;++o)t[o].destroy();this._vertexBuffers=null;for(var l=0,c=r.length;l<c;++l)r[l].destroy();this._indiceBuffers=null},rd._drawSubElement=function(e,t){var r=e.data.verticesData.vertexCount;this._vertexCount+r>rc.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=e},rd._createMesh=function(t,r){var n=rc.MAX_VERTEX_COUNT,a=new dX(t,"BufferMesh"+r);a._addReferCount(1);var i=[],o=this.createVertexElements(i),s=this._vertexBuffers[r]=new dO(t,e.BufferBindFlag.VertexBuffer,n*o,e.BufferUsage.Dynamic),l=this._indiceBuffers[r]=new dO(t,e.BufferBindFlag.IndexBuffer,6*n,e.BufferUsage.Dynamic);return a.setVertexBufferBinding(s,o),a.setIndexBufferBinding(l,e.IndexFormat.UInt16),a.setVertexElements(i),a},rd._updateData=function(t){var r=this._meshes,n=this._flushId;!rc._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,r[n]=this._createMesh(t,n));var a=this._batchedQueue,i=this._vertices,o=this._indices,s=r[n];s.clearSubMesh();for(var l=0,c=0,d=0,u=0,h=0,_=0,f=null,p=0,m=a.length;p<m;p++){var g=a[p],v=g.data;l=this.updateVertices(v,i,l);for(var y=v.verticesData.triangles,x=y.length,b=0;b<x;b++)o[c++]=y[b]+h;h+=v.verticesData.vertexCount,null===f?u+=x:this.canBatch(f,g)?u+=x:(s.addSubMesh(this._getSubMeshFromPool(d,u)),d+=u,u=x,a[_++]=f),f=g}s.addSubMesh(this._getSubMeshFromPool(d,u)),a[_]=f,this._vertexBuffers[n].setData(i,0,0,l,e.SetDataOptions.Discard),this._indiceBuffers[n].setData(o,0,0,c,e.SetDataOptions.Discard)},rd._getSubMeshFromPool=function(t,r){var n=this._subMeshPool.getFromPool();return n.start=t,n.count=r,n.topology=e.MeshTopology.Triangles,n},rc);ud._disableBatchTag=dm.getByName("spriteDisableBatching"),ud.MAX_VERTEX_COUNT=4096,ud._canUploadSameBuffer=!0;var uu=((ru=function(){}).resetData=function(e){e._verticesData.triangles=[]},ru.updatePositions=function(t){var r,n,a,i,o,s,l=t.width,c=t.height,d=t.sprite,u=t.tileMode,h=t.tiledAdaptiveThreshold,_=t._verticesData,f=_.positions,p=_.uvs,m=_.triangles,g=this._posRow,v=this._posColumn,y=this._uvRow,x=this._uvColumn;g.length=v.length=y.length=x.length=0,u===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(d,l,c,h,g,v,y,x):this._calculateContinuousDividing(d,l,c,g,v,y,x);var b=t.sprite.pivot,S=b.x,C=b.y,T=t.width*S,A=t.height*C,M=uu._worldMatrix,E=M.elements,R=t.entity.transform.worldMatrix.elements,w=t.flipX?-1:1,P=t.flipY?-1:1;r=E[0]=R[0]*w,n=E[1]=R[1]*w,a=E[2]=R[2]*w,i=E[4]=R[4]*P,o=E[5]=R[5]*P,s=E[6]=R[6]*P,E[8]=R[8],E[9]=R[9],E[10]=R[10];for(var F=E[12]=R[12]-T*E[0]-A*E[4],L=E[13]=R[13]-T*E[1]-A*E[5],D=E[14]=R[14]-T*E[2]-A*E[6],B=g.length-1,I=v.length-1,V=0,O=0,N=0;N<I;N++)for(var k=2*N,z=0;z<B;z++){var U=y.get(2*z),G=x.get(k),H=y.get(2*z+1),W=x.get(k+1);if(!(isNaN(U)||isNaN(U)||isNaN(H)||isNaN(W))){m[O++]=V,m[O++]=V+1,m[O++]=V+2,m[O++]=V+2,m[O++]=V+1,m[O++]=V+3;var K=g.get(z),j=v.get(N),X=g.get(z+1),q=v.get(N+1);p[V]?p[V].set(U,G):p[V]=new cD(U,G);var Y=f[V];Y?Y.set(r*K+i*j+F,n*K+o*j+L,a*K+s*j+D):f[V]=new cC(r*K+i*j+F,n*K+o*j+L,a*K+s*j+D),p[++V]?p[V].set(H,G):p[V]=new cD(H,G),(Y=f[V])?Y.set(r*X+i*j+F,n*X+o*j+L,a*X+s*j+D):f[V]=new cC(r*X+i*j+F,n*X+o*j+L,a*X+s*j+D),p[++V]?p[V].set(U,W):p[V]=new cD(U,W),(Y=f[V])?Y.set(r*K+i*q+F,n*K+o*q+L,a*K+s*q+D):f[V]=new cC(r*K+i*q+F,n*K+o*q+L,a*K+s*q+D),p[++V]?p[V].set(H,W):p[V]=new cD(H,W),(Y=f[V])?Y.set(r*X+i*q+F,n*X+o*q+L,a*X+s*q+D):f[V]=new cC(r*X+i*q+F,n*X+o*q+L,a*X+s*q+D),V++}}t._verticesData.vertexCount=V,m.length=O;var Q=t._bounds,J=Q.min,Z=Q.max;J.set(g.get(0),v.get(0),0),Z.set(g.get(B),v.get(I),0),t._bounds.transform(M)},ru.updateUVs=function(e){},ru._calculateAdaptiveDividing=function(e,t,r,n,a,i,o,s){var l,c,d,u,h,_,f,p=e.border,m=e._getPositions(),g=m[0],v=g.x,y=g.y,x=m[3],b=x.x,S=x.y,C=e._getUVs(),T=C[0],A=C[1],M=C[2],E=C[3],R=e.width,w=e.height,P=R*p.x,F=R*p.z,L=P+F,D=R-L,B=w*p.w,I=w*p.y,V=B+I,O=w-V;if(L>=t?(u=3,c=0):D>cS.zeroTolerance?(u=4+(_=(_=(t-L)/D)%1>=n?Math.ceil(_):Math.floor(_))-1,c=2):(u=4,c=1),V>=r?(h=3,d=0):O>cS.zeroTolerance?(h=4+(f=(f=(r-V)/O)%1>=n?Math.ceil(f):Math.floor(f))-1,d=2):(h=4,d=1),(u-1)*(h-1)*4>ud.MAX_VERTEX_COUNT){a.add(t*v),a.add(t*b),i.add(r*y),i.add(r*S),o.add(T.x),o.add(E.x),s.add(T.y),s.add(E.y),dr.warn("The number of vertices exceeds the upper limit("+ud.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,a.add(R*v*l),a.add(P*l),a.add(t-R*(1-b)*l),o.add(T.x),o.add(A.x),o.add(M.x),o.add(E.x);break;case 1:a.add(R*v),a.add(P),a.add(t-F),a.add(t-R*(1-b)),o.add(T.x),o.add(A.x),o.add(NaN),o.add(NaN),o.add(M.x),o.add(E.x);break;case 2:l=t/(L+_*D),a.add(R*v*l),a.add(P*l),o.add(T.x),o.add(A.x),o.add(A.x);for(var N=0,k=_-1;N<k;N++)a.add(P+(N+1)*D*l),o.add(M.x),o.add(A.x);a.add(t-F*l),a.add(t-R*(1-b)*l),o.add(M.x),o.add(M.x),o.add(E.x)}switch(d){case 0:l=r/V,i.add(w*y*l),i.add(I*l),i.add(r-w*(1-S)*l),s.add(T.y),s.add(A.y),s.add(M.y),s.add(E.y);break;case 1:i.add(w*y),i.add(I),i.add(r-B),i.add(r-w*(1-S)),s.add(T.y),s.add(A.y),s.add(NaN),s.add(NaN),s.add(M.y),s.add(E.y);break;case 2:l=r/(V+f*O),i.add(w*y*l),i.add(I*l),s.add(T.y),s.add(A.y),s.add(A.y);for(var z=0,U=f-1;z<U;z++)i.add(I+(z+1)*O*l),s.add(M.y),s.add(A.y);i.add(r-B*l),i.add(r-w*(1-S)*l),s.add(M.y),s.add(M.y),s.add(E.y)}},ru._calculateContinuousDividing=function(e,t,r,n,a,i,o){var s,l,c,d,u,h,_=e.border,f=e._getPositions(),p=f[0],m=p.x,g=p.y,v=f[3],y=v.x,x=v.y,b=e._getUVs(),S=b[0],C=b[1],T=b[2],A=b[3],M=e.width,E=e.height,R=M*_.x,w=M*_.z,P=R+w,F=M-P,L=E*_.w,D=E*_.y,B=L+D,I=E-B;if(P>=t?(c=3,s=0):F>cS.zeroTolerance?(c=4+(0|(u=(t-P)/F)),s=2):(c=4,s=1),B>=r?(d=3,l=0):I>cS.zeroTolerance?(d=4+(0|(h=(r-B)/I)),l=2):(d=4,l=1),(c-1)*(d-1)*4>ud.MAX_VERTEX_COUNT){n.add(t*m),n.add(t*y),a.add(r*g),a.add(r*x),i.add(S.x),i.add(A.x),o.add(S.y),o.add(A.y),dr.warn("The number of vertices exceeds the upper limit("+ud.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var V=t/P;n.add(M*m*V),n.add(R*V),n.add(t-M*(1-y)*V),i.add(S.x),i.add(C.x),i.add(T.x),i.add(A.x);break;case 1:n.add(M*m),n.add(R),n.add(t-w),n.add(t-M*(1-y)),i.add(S.x),i.add(C.x),i.add(NaN),i.add(NaN),i.add(T.x),i.add(A.x);break;case 2:n.add(M*m),n.add(R),i.add(S.x),i.add(C.x),i.add(C.x);for(var O=0|u,N=0;N<O;N++)n.add(R+(N+1)*F),i.add(T.x),i.add(C.x);n.add(t-w),n.add(t-M*(1-y)),i.add((T.x-C.x)*(u-O)+C.x),i.add(T.x),i.add(A.x)}switch(l){case 0:var k=r/B;a.add(E*g*k),a.add(D*k),a.add(r-E*(1-x)*k),o.add(S.y),o.add(C.y),o.add(T.y),o.add(A.y);break;case 1:a.add(E*g),a.add(D),a.add(r-L),a.add(r-E*(1-x)),o.add(S.y),o.add(C.y),o.add(NaN),o.add(NaN),o.add(T.y),o.add(A.y);break;case 2:a.add(E*g),a.add(D),o.add(S.y),o.add(C.y),o.add(C.y);for(var z=0|h,U=0;U<z;U++)a.add(D+(U+1)*I),o.add(T.y),o.add(C.y);a.add(r-L),a.add(r-E*(1-x)),o.add((T.y-C.y)*(h-z)+C.y),o.add(T.y),o.add(A.y)}},ru._worldMatrix=new cF,ru._posRow=new dV,ru._posColumn=new dV,ru._uvRow=new dV,ru._uvColumn=new dV,ru);uu=cW([dD()],uu),(rh=l$||(l$={}))[rh.Compressed=0]="Compressed",rh[rh.WithoutTiled=1]="WithoutTiled",rh[rh.WithTiled=2]="WithTiled";var uh=function(e,t,r,n,a){void 0===n&&(n=null),void 0===a&&(a=null),this.vertexCount=e,this.positions=t,this.uvs=r,this.triangles=n,this.color=a},u_=(r_=e.Renderer,cH(rf=function(t){var r;return(r=r_.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new cI(1,1,1,1),r._sprite=null,r._automaticWidth=0,r._automaticHeight=0,r._customWidth=void 0,r._customHeight=void 0,r._flipX=!1,r._flipY=!1,r._maskLayer=e.SpriteMaskLayer.Layer0,r._maskInteraction=e.SpriteMaskInteraction.None,r._verticesData=new uh(4,[],[],null,r._color),r.drawMode=e.SpriteDrawMode.Simple,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(ck(r)),r},r_),(rp=rf.prototype)._cloneTo=function(e,t,r){r_.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},rp._updateShaderData=function(e,t){if(t){this._updateMVPShaderData(e,cF._identity);return}this._updateTransformShaderData(e,cF._identity)},rp._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},rp._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,r=this.getMaterial();if(r){r.destroyed&&(r=this._engine._spriteDefaultMaterials[this._maskInteraction]),this._dirtyUpdateFlag&lK.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~lK.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var n=this.sprite.texture,a=this._engine._spriteRenderDataPool.getFromPool();a.set(this,r,this._verticesData,n),e.camera._renderPipeline.pushRenderData(e,a)}}},rp._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),r_.prototype._onDestroy.call(this),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},rp._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},rp._updateStencilState=function(t,r){var n=this.getMaterial(),a=this._engine._spriteDefaultMaterials;if(n===a[t])this.setMaterial(a[r]);else{var i=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(i.enabled=!1,i.writeMask=255,i.referenceValue=0,i.compareFunctionFront=i.compareFunctionBack=e.CompareFunction.Always):(i.enabled=!0,i.writeMask=0,i.referenceValue=1,i.compareFunctionFront=i.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},rp._onSpriteChange=function(t){switch(t){case lz.texture:this.shaderData.setTexture(rf._textureProperty,this.sprite.texture);break;case lz.size:var r=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=lK.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lK.WorldVolume);break;case lz.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case lz.region:case lz.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lz.atlasRegion:this._dirtyUpdateFlag|=2;break;case lz.pivot:this._dirtyUpdateFlag|=lK.WorldVolume;break;case lz.destroy:this.sprite=null}},cU(rf,[{key:"drawMode",get:function(){return this._drawMode},set:function(t){if(this._drawMode!==t){switch(this._drawMode=t,t){case e.SpriteDrawMode.Simple:this._assembler=dB;break;case e.SpriteDrawMode.Sliced:this._assembler=dI;break;case e.SpriteDrawMode.Tiled:this._assembler=uu}this._assembler.resetData(this),this._dirtyUpdateFlag|=3}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=cS.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(rf._textureProperty,e.texture)):this.shaderData.setTexture(rf._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._updateStencilState(this._maskInteraction,e),this._maskInteraction=e)}}]),rf);u_._textureProperty=dn.getByName("renderer_SpriteTexture"),cW([cj],u_.prototype,"_verticesData",void 0),cW([cj],u_.prototype,"_drawMode",void 0),cW([cX],u_.prototype,"_assembler",void 0),cW([cX],u_.prototype,"_tileMode",void 0),cW([cX],u_.prototype,"_tiledAdaptiveThreshold",void 0),cW([cY],u_.prototype,"_color",void 0),cW([cj],u_.prototype,"_sprite",void 0),cW([cj],u_.prototype,"_automaticWidth",void 0),cW([cj],u_.prototype,"_automaticHeight",void 0),cW([cX],u_.prototype,"_customWidth",void 0),cW([cX],u_.prototype,"_customHeight",void 0),cW([cX],u_.prototype,"_flipX",void 0),cW([cX],u_.prototype,"_flipY",void 0),cW([cX],u_.prototype,"_maskLayer",void 0),cW([cX],u_.prototype,"_maskInteraction",void 0),cW([cj],u_.prototype,"_onSpriteChange",null),(rm=l0||(l0={}))[rm.UV=2]="UV",rm[rm.RenderData=3]="RenderData",rm[rm.AutomaticSize=4]="AutomaticSize",rm[rm.All=7]="All";var uf=function(t){function r(n){var a;return(a=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,a._sprite=null,a._automaticWidth=0,a._automaticHeight=0,a._customWidth=void 0,a._customHeight=void 0,a._flipX=!1,a._flipY=!1,a._alphaCutoff=.5,a._verticesData=new uh(4,[],[]),dB.resetData(ck(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(r._alphaCutoffProperty,a._alphaCutoff),a._onSpriteChange=a._onSpriteChange.bind(ck(a)),a}cH(r,t);var n=r.prototype;return n._cloneTo=function(e,r,n){t.prototype._cloneTo.call(this,e,r,n),e.sprite=this._sprite},n._updateBounds=function(e){this.sprite?dB.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},n._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){var t,r=this.getMaterial();if(r){var n=this._engine;r.destroyed&&(r=n._spriteMaskDefaultMaterial),this._dirtyUpdateFlag&lK.WorldVolume&&(dB.updatePositions(this),this._dirtyUpdateFlag&=~lK.WorldVolume),2&this._dirtyUpdateFlag&&(dB.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var a=n._spriteMaskRenderDataPool.getFromPool();a.set(this,r,this._verticesData);var i=n._renderElementPool.getFromPool();i.set(a,r.shader.subShaders[0].passes),this._maskElement=i}}},n._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),t.prototype._onDestroy.call(this),this._sprite=null,this._verticesData=null},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},n._onSpriteChange=function(e){switch(e){case lz.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case lz.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lK.WorldVolume);break;case lz.region:case lz.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lz.atlasRegion:this._dirtyUpdateFlag|=2;break;case lz.pivot:this._dirtyUpdateFlag|=lK.WorldVolume;break;case lz.destroy:this.sprite=null}},cU(r,[{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lK.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(r._textureProperty,e.texture)):this.shaderData.setTexture(r._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(r._alphaCutoffProperty,e))}}]),r}(e.Renderer);uf._textureProperty=dn.getByName("renderer_MaskTexture"),uf._alphaCutoffProperty=dn.getByName("renderer_MaskAlphaCutoff"),cW([cX],uf.prototype,"influenceLayers",void 0),cW([cj],uf.prototype,"_verticesData",void 0),cW([cj],uf.prototype,"_sprite",void 0),cW([cj],uf.prototype,"_automaticWidth",void 0),cW([cj],uf.prototype,"_automaticHeight",void 0),cW([cX],uf.prototype,"_customWidth",void 0),cW([cX],uf.prototype,"_customHeight",void 0),cW([cX],uf.prototype,"_flipX",void 0),cW([cX],uf.prototype,"_flipY",void 0),cW([cX],uf.prototype,"_alphaCutoff",void 0),cW([cj],uf.prototype,"_onSpriteChange",null),(rg=l1||(l1={}))[rg.UV=2]="UV",rg[rg.RenderData=3]="RenderData",rg[rg.AutomaticSize=4]="AutomaticSize",rg[rg.All=7]="All";var up=(cH(rv=function(e){var t;return(t=cZ.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},cZ),(ry=rv.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=r+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new cD(this._curX,this._curY),i.setPixelBuffer(n,0,this._curX,this._curY,t,r),i.generateMipmaps());var d=1/o,u=this._curX,h=this._curY,_=u*d,f=(u+t)*d,p=h*d,m=(h+r)*d;e.x=u,e.y=h;var g=e.uvs;return g[0].set(_,p),g[1].set(f,p),g[2].set(f,m),g[3].set(_,m),this._curX+=s+a,!0},ry.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},ry.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},ry._onDestroy=function(){cZ.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},rv),um=((rx=function(){}).textContext=function(){var e=rx._textContext;if(!e){try{t=new OffscreenCanvas(0,0)}catch(e){t=document.createElement("canvas")}var t,r=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,context:r},rx._textContext=e}return e},rx.measureFont=function(e){var t=rx._fontSizeInfoCache,r=t[e];return r||(r=rx._measureFontOrChar(e,rx._measureString,!1),t[e]=r),r},rx.getNativeFontString=function(t,r,n){var a=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rx._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=r+"px "+t},rx.measureChar=function(e,t){return rx._measureFontOrChar(t,e,!0)},rx.measureTextWithWrap=function(t){var r=t._subFont,n=r.nativeFontString,a=rx.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=hh._pixelsPerUnit,d=a.size+t.lineSpacing*c,u=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,S=0,C=0,T=!1,A=0,M=p.length;A<M;++A){var E=p[A],R=rx._getCharInfo(E,n,r),w=E.charCodeAt(0),P=32===w;if(!P||!T||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=R.w,D=R.offsetY,B=.5*R.h,I=B+D,V=B-D;F?(m.length>0&&(b+g>u?(b>0&&this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),T=!0,x=m,b=g,S=v,C=y):(x+=m,b+=g,S=Math.max(S,v),C=Math.max(C,y)),m="",g=v=y=0),b+L>u&&b>0?(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),T=!0,P?(x="",b=S=C=0):(x=E,b=R.xAdvance,S=I,C=V)):(x+=E,b+=R.xAdvance,S=Math.max(S,I),C=Math.max(C,V))):g+R.w>u?(b>0&&(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),x="",b=S=C=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),T=!0,m=E,g=R.xAdvance,v=I,y=V):(m+=E,g+=R.xAdvance,v=Math.max(v,I),y=Math.max(y,V))}}g>0&&(b+g>u?(b>0&&this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,S=Math.max(S,v),C=Math.max(C,y))),b>0&&(this._pushLine(o,s,l,x,b,S,C),h=Math.max(h,b))}var O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=d*o.length),{width:h,height:O,lines:o,lineWidths:s,lineHeight:d,lineMaxSizes:l}},rx.measureTextWithoutWrap=function(t){var r=t._subFont,n=r.nativeFontString,a=rx.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],d=hh._pixelsPerUnit,u=a.size+t.lineSpacing*d,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=rx._getCharInfo(f[v],n,r);p+=x.xAdvance;var b=x.offsetY,S=.5*x.h,C=S+b,T=S-b;m<C&&(m=C),g<T&&(g=T)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*d;return t.overflowMode===e.OverflowMode.Overflow&&(A=u*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:u,lineMaxSizes:c}},rx.getNativeFontHash=function(t,r,n){var a=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rx._genericFontFamilies.indexOf(t)||(t=""+t),a+=r+"px"+t},rx._measureFontOrChar=function(e,t,r){var n,a=rx.textContext(),i=a.canvas,o=a.context;o.font=e;var s=o.measureText(t),l=Math.max(1,Math.round(s.actualBoundingBoxRight-s.actualBoundingBoxLeft||s.width)),c=Math.ceil(o.measureText(rx._measureBaseline).width),d=c*rx._heightMultiplier;c=rx._baselineMultiplier*c|0;var u=rx._extendHeight;d+=u,c+=.5*u,i.width=l,i.height=d,o.font=e,o.fillStyle="#000",o.clearRect(0,0,l,d),o.textBaseline="middle",o.fillStyle="#fff",o.fillText(t,0,c);for(var h=o.getImageData(0,0,l,d).data,_=h.length,f=-1,p=-1,m=0,g=0,v=0,y=i.width,x=1/y,b=0;b<_;b+=4)0!==h[b+3]?(n=~~(.25*b*x),-1===f&&(f=n),n>p&&(p=n)):h[b]=h[b+1]=h[b+2]=255;if(-1!==f&&-1!==p&&(v=(m=c-f)+(g=p-c+1)),!r)return{ascent:m,descent:g,size:v};var S=null;if(v>0){var C=4*y;S=new Uint8Array(h.buffer,f*C,v*C)}return{char:t,x:0,y:0,w:l,h:v,offsetX:0,offsetY:(m-g)*.5,xAdvance:l,uvs:[new cD,new cD,new cD,new cD],ascent:m,descent:g,index:0,data:S}},rx._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=rx.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},rx._pushLine=function(e,t,r,n,a,i,o){e.push(n),t.push(a),r.push({ascent:i,descent:o,size:i+o})},rx);um._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],um._extendHeight=0,um._measureString="|\xc9q\xc5",um._measureBaseline="M",um._heightMultiplier=2,um._baselineMultiplier=1.4,um._fontSizeInfoCache={},um._textContext=null;var ug=((rS=(rb=function(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}).prototype).destroy=function(){for(var e=this._fontAtlases,t=0,r=e.length;t<r;++t)e[t].destroy(!0);e.length=0},rS._uploadCharTexture=function(e){var t=this._lastIndex;-1===t&&(this._createFontAtlas(),t++);var r=this._fontAtlases[t];!r.uploadCharTexture(e)&&((r=this._createFontAtlas()).uploadCharTexture(e),t++),this._lastIndex=t,e.data=null},rS._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},rS._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var a=t[r].getCharInfo(e);if(a)return a}return null},rS._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},rS._getLastIndex=function(){return this._lastIndex},rS._createFontAtlas=function(){var t,r=this._engine,n=new up(r),a=new dQ(r,256,256,e.TextureFormat.R8G8B8A8,!1);a.filterMode=e.TextureFilterMode.Bilinear,n.texture=a,n.isGCIgnored=a.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return r.resourceManager.addContentRestorer(new(cH(t=function(){return d2.call(this,n)},d2),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var a=t[n],o=um.measureChar(a.char,i).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}r.generateMipmaps()},t)),n},rb),uv=(cH(rC=function(e,t){var r;return void 0===t&&(t=""),(r=cZ.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},cZ),(rT=rC.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,a=n[r];return a||(a=new ug(this.engine),n[r]=a),a},rT._onDestroy=function(){cZ.prototype._onDestroy.call(this);var e=this._subFontMap;for(var t in e)e[t].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},rC.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new rC(e,t),r[t]=n),n}return null},cU(rC,[{key:"name",get:function(){return this._name}}]),rC),uy=function e(){this.localPositions=new cB;var t=[new cC,new cC,new cC,new cC];this.renderData=new uh(4,t,null,e.triangles,null)};uy.triangles=[0,2,1,2,0,3];var ux=((rM=(rA=function(e,t){this._elements=[],this._type=e;for(var r=this._elements,n=0;n<t;++n)r[n]=new e}).prototype).get=function(){return this._elements.length>0?this._elements.pop():new this._type},rM.put=function(e){this._elements.push(e)},rA),ub=(rE=e.Renderer,cH(rR=function(t){var r;return(r=rE.call(this,t)||this)._subFont=null,r._charRenderDatas=[],r._dirtyFlag=15,r._color=new cI(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new cA,r._font=null,r._fontSize=24,r._fontStyle=e.FontStyle.None,r._lineSpacing=0,r._horizontalAlignment=e.TextHorizontalAlignment.Center,r._verticalAlignment=e.TextVerticalAlignment.Center,r._enableWrapping=!1,r._overflowMode=e.OverflowMode.Overflow,r._maskInteraction=e.SpriteMaskInteraction.None,r._maskLayer=e.SpriteMaskLayer.Layer0,r._init(),r},rE),(rw=rR.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._addResourceReferCount(this._font,1),this.setMaterial(e._spriteDefaultMaterial)},rw._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),rE.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,r=e.length;t<r;++t)rR._charRenderDataPool.put(e[t]);e.length=0,this._subFont&&(this._subFont=null)},rw._cloneTo=function(e,t,r){rE.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},rw._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rw._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rw._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rw._updateShaderData=function(e,t){if(t){this._updateMVPShaderData(e,cF._identity);return}this._updateTransformShaderData(e,cF._identity)},rw._updateBounds=function(e){cA.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rw._render=function(e){if(!this._isTextNoVisible()){this._isContainDirtyFlag(16)&&(this._updateStencilState(),this._setDirtyFlagFalse(16)),this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4));var t=this._engine._spriteRenderDataPool,r=this._engine._textRenderDataPool.getFromPool(),n=r.charsData,a=this.getMaterial(),i=this._charRenderDatas,o=i.length;r.component=this,r.material=a,n.length=o;for(var s=0;s<o;++s){var l=i[s],c=t.getFromPool();c.set(this,a,l.renderData,l.texture,s),n[s]=c}e.camera._renderPipeline.pushRenderData(e,r)}},rw._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,r=this._maskInteraction;if(r===e.SpriteMaskInteraction.None)t.enabled=!1,t.writeMask=255,t.referenceValue=0,t.compareFunctionFront=t.compareFunctionBack=e.CompareFunction.Always;else{t.enabled=!0,t.writeMask=0,t.referenceValue=1;var n=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=n,t.compareFunctionBack=n}},rw._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=um.getNativeFontString(e.name,this.fontSize,this.fontStyle)},rw._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,r=e[0],n=e[1],a=e[2],i=e[4],o=e[5],s=e[6],l=e[12],c=e[13],d=e[14],u=rR._tempVec31.set(i,o,s),h=rR._tempVec30.set(r,n,a),_=0,f=t.length;_<f;++_){var p=t[_],m=p.localPositions,g=p.renderData.positions,v=m.x,y=m.y,x=g[0];x.x=v*r+y*i+l,x.y=v*n+y*o+c,x.z=v*a+y*s+d;var b=g[1];cC.scale(h,m.z-v,b),cC.add(x,b,b);var S=g[2];cC.scale(u,m.w-y,S),cC.add(x,S,g[3]),cC.add(b,S,S)}},rw._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,a=this.color,i=this._charRenderDatas,o=this._subFont,s=this.enableWrapping?um.measureTextWithWrap(this):um.measureTextWithoutWrap(this),l=s.height,c=s.lines,d=s.lineWidths,u=s.lineHeight,h=s.lineMaxSizes,_=rR._charRenderDataPool,f=c.length,p=0;if(f>0){var m=hh._pixelsPerUnit,g=this.horizontalAlignment,v=1/m,y=.5*(this.width*m),x=this.height*m,b=.5*u,S=0,C=.5*u-h[0].ascent,T=.5*u-h[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:S=.5*x-b+C;break;case e.TextVerticalAlignment.Center:S=.5*l-b-(T-C)*.5;break;case e.TextVerticalAlignment.Bottom:S=l-.5*x-b-T}for(var A=-1,M=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,w=Number.MIN_SAFE_INTEGER,P=0;P<f;++P){var F=d[P];if(F>0){var L=c[P],D=0,B=-1;switch(A<0&&(A=P),g){case e.TextHorizontalAlignment.Left:D=-y;break;case e.TextHorizontalAlignment.Center:D=-(.5*F);break;case e.TextHorizontalAlignment.Right:D=y-F}for(var I=0,V=L.length;I<V;++I){var O=L[I],N=o._getCharInfo(O);if(N.h>0){B<0&&(B=I);var k,z=i[k=p++]||(i[k]=_.get()),U=z.renderData,G=z.localPositions;z.texture=o._getTextureByIndex(N.index),U.color=a,U.uvs=N.uvs;var H=N.w,W=N.ascent,K=N.descent,j=D*v,X=(D+H)*v,q=(S+W)*v,Y=(S-K)*v;G.set(j,q,X,Y),P===A&&(w=Math.max(w,q)),E=Math.min(E,Y),I===B&&(M=Math.min(M,j)),R=Math.max(R,X)}D+=N.xAdvance}}S-=u}A<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(M,E,0),n.set(R,w,0))}else r.set(0,0,0),n.set(0,0,0);var Q=i.length;if(Q>p){for(var J=p;J<Q;++J)_.put(i[J]);i.length=p}o._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},rw._onTransformChanged=function(e){rE.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},rw._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},cU(rR,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),rR);ub._charRenderDataPool=new ux(uy,50),ub._tempVec30=new cC,ub._tempVec31=new cC,cW([cX],ub.prototype,"_subFont",void 0),cW([cj],ub.prototype,"_charRenderDatas",void 0),cW([cj],ub.prototype,"_dirtyFlag",void 0),cW([cY],ub.prototype,"_color",void 0),cW([cX],ub.prototype,"_text",void 0),cW([cX],ub.prototype,"_width",void 0),cW([cX],ub.prototype,"_height",void 0),cW([cj],ub.prototype,"_localBounds",void 0),cW([cX],ub.prototype,"_font",void 0),cW([cX],ub.prototype,"_fontSize",void 0),cW([cX],ub.prototype,"_fontStyle",void 0),cW([cX],ub.prototype,"_lineSpacing",void 0),cW([cX],ub.prototype,"_horizontalAlignment",void 0),cW([cX],ub.prototype,"_verticalAlignment",void 0),cW([cX],ub.prototype,"_enableWrapping",void 0),cW([cX],ub.prototype,"_overflowMode",void 0),cW([cX],ub.prototype,"_maskInteraction",void 0),cW([cX],ub.prototype,"_maskLayer",void 0),(rP=l2||(l2={}))[rP.SubFont=1]="SubFont",rP[rP.LocalPositionBounds=2]="LocalPositionBounds",rP[rP.WorldPosition=4]="WorldPosition",rP[rP.WorldBounds=8]="WorldBounds",rP[rP.MaskInteraction=16]="MaskInteraction",rP[rP.Position=14]="Position",rP[rP.Font=15]="Font",e.BlendMode=void 0,(rF=e.BlendMode||(e.BlendMode={}))[rF.Normal=0]="Normal",rF[rF.Additive=1]="Additive",e.RenderFace=void 0,(rL=e.RenderFace||(e.RenderFace={}))[rL.Front=0]="Front",rL[rL.Back=1]="Back",rL[rL.Double=2]="Double";var uS=(cH(rD=function(e,t){var r;return(r=cZ.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new dL(lW.Material),r.shader=t,r},cZ),(rB=rD.prototype).clone=function(){var e=new rD(this._engine,this.shader);return this.cloneTo(e),e},rB.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),cQ.deepCloneObject(this.renderStates,e.renderStates,new Map)},rB._addReferCount=function(e){this._destroyed||(cZ.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},rB._onDestroy=function(){cZ.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},cU(rD,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,r=this._getReferCount();r>0&&(null==(t=this._shader)||t._addReferCount(-r),e._addReferCount(r)),this._shader=e;for(var n=this._renderStates,a=n.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)n.push(new dR);else n.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rD),uC=function(t){function r(n,a){var i;return(i=t.call(this,n,a)||this)._renderFace=e.RenderFace.Front,i._isTransparent=!1,i._blendMode=e.BlendMode.Normal,i.shaderData.setFloat(r._alphaCutoffProp,0),i}cH(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var a=this.renderStates;if(a.length<t)throw"Pass should less than pass count.";var i=a[t];n?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(r._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=this.shaderData.getFloat(r._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,this.shaderData.disableMacro(r._transparentMacro))},n.setBlendMode=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";var a=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.One,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add}},n.setRenderFace=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";switch(r){case e.RenderFace.Front:n[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:n[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:n[t].rasterState.cullMode=e.CullMode.Off}},n.clone=function(){var e=new r(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},cU(r,[{key:"shader",get:function(){return this._shader},set:function(t){var r,n=this._getReferCount();n>0&&(null==(r=this._shader)||r._addReferCount(-n),t._addReferCount(n)),this._shader=t;for(var a=this._renderStates,i=a.length,o=0,s=t.subShaders,l=0;l<s.length;l++)o=Math.max(s[l].passes.length,o);if(i<o)for(var c=i;c<o;c++)a.push(new dR),this.setBlendMode(c,e.BlendMode.Normal);else a.length=o}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){e!==this._isTransparent&&(this.setIsTransparent(0,e),this._isTransparent=e)}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(r._alphaCutoffProp)},set:function(t){var n=this.shaderData;if(n.getFloat(r._alphaCutoffProp)!==t){t?n.enableMacro(r._alphaCutoffMacro):n.disableMacro(r._alphaCutoffMacro);for(var a=this.renderStates,i=0,o=a.length;i<o;i++){var s=a[i];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}n.setFloat(r._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),r}(uS);uC._baseTextureMacro=du.getByName("MATERIAL_HAS_BASETEXTURE"),uC._normalTextureMacro=du.getByName("MATERIAL_HAS_NORMALTEXTURE"),uC._emissiveTextureMacro=du.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uC._transparentMacro=du.getByName("MATERIAL_IS_TRANSPARENT"),uC._baseColorProp=dn.getByName("material_BaseColor"),uC._baseTextureProp=dn.getByName("material_BaseTexture"),uC._tilingOffsetProp=dn.getByName("material_TilingOffset"),uC._normalTextureProp=dn.getByName("material_NormalTexture"),uC._normalIntensityProp=dn.getByName("material_NormalIntensity"),uC._emissiveColorProp=dn.getByName("material_EmissiveColor"),uC._emissiveTextureProp=dn.getByName("material_EmissiveTexture"),uC._alphaCutoffProp=dn.getByName("material_AlphaCutoff"),uC._alphaCutoffMacro=du.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uT=function(e){function t(r){var n,a=(n=e.call(this,r,dw.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new cI(1,1,1,1)),a.setColor(t._specularColorProp,new cI(1,1,1,1)),a.setColor(t._emissiveColorProp,new cI(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new cB(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),n}return cH(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cU(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var r=this.shaderData.getColor(t._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var r=this.shaderData.getColor(t._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"specularTexture",get:function(){return this.shaderData.getTexture(t._specularTextureProp)},set:function(e){this.shaderData.setTexture(t._specularTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SPECULAR_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SPECULAR_TEXTURE")}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var r=this.shaderData.getColor(t._emissiveColorProp);e!==r&&r.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(t._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(t._emissiveTextureProp,e),e?this.shaderData.enableMacro(t._emissiveTextureMacro):this.shaderData.disableMacro(t._emissiveTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(t._normalTextureProp)},set:function(e){this.shaderData.setTexture(t._normalTextureProp,e),e?this.shaderData.enableMacro(t._normalTextureMacro):this.shaderData.disableMacro(t._normalTextureMacro)}},{key:"normalIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"shininess",get:function(){return this.shaderData.getFloat(t._shininessProp)},set:function(e){this.shaderData.setFloat(t._shininessProp,Math.max(e,1e-4))}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(t._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),t}(uC);uT._specularColorProp=dn.getByName("material_SpecularColor"),uT._shininessProp=dn.getByName("material_Shininess"),uT._specularTextureProp=dn.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rI=e.TextureCoordinate||(e.TextureCoordinate={}))[rI.UV0=0]="UV0",rI[rI.UV1=1]="UV1",rI[rI.UV2=2]="UV2",rI[rI.UV3=3]="UV3",rI[rI.UV4=4]="UV4",rI[rI.UV5=5]="UV5",rI[rI.UV6=6]="UV6",rI[rI.UV7=7]="UV7";var uA=function(t){function r(n,a){var i,o=(i=t.call(this,n,a)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new cI(1,1,1,1)),o.setColor(r._emissiveColorProp,new cI(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new cB(1,1,0,0)),o.setFloat(r._normalIntensityProp,1),o.setFloat(r._occlusionTextureIntensityProp,1),o.setFloat(r._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(r._clearCoatProp,0),o.setFloat(r._clearCoatRoughnessProp,0),i}return cH(r,t),cU(r,[{key:"baseColor",get:function(){return this.shaderData.getColor(r._baseColorProp)},set:function(e){var t=this.shaderData.getColor(r._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(r._baseTextureProp)},set:function(e){this.shaderData.setTexture(r._baseTextureProp,e),e?this.shaderData.enableMacro(r._baseTextureMacro):this.shaderData.disableMacro(r._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(r._normalTextureProp)},set:function(e){this.shaderData.setTexture(r._normalTextureProp,e),e?this.shaderData.enableMacro(r._normalTextureMacro):this.shaderData.disableMacro(r._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(r._normalIntensityProp)},set:function(e){this.shaderData.setFloat(r._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(r._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(r._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(r._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(r._emissiveTextureProp,e),e?this.shaderData.enableMacro(r._emissiveTextureMacro):this.shaderData.disableMacro(r._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(r._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(r._occlusionTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_OCCLUSION_TEXTURE")}},{key:"occlusionTextureIntensity",get:function(){return this.shaderData.getFloat(r._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(r._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(r._occlusionTextureCoordProp)},set:function(t){t>e.TextureCoordinate.UV1&&dr.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(r._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(r._tilingOffsetProp)},set:function(e){var t=this.shaderData.getVector4(r._tilingOffsetProp);e!==t&&t.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(r._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(r._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(r._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(r._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_TEXTURE")}},{key:"clearCoatRoughness",get:function(){return this.shaderData.getFloat(r._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(r._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(r._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(r._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(r._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),r}(uC);uA._occlusionTextureIntensityProp=dn.getByName("material_OcclusionIntensity"),uA._occlusionTextureCoordProp=dn.getByName("material_OcclusionTextureCoord"),uA._occlusionTextureProp=dn.getByName("material_OcclusionTexture"),uA._clearCoatProp=dn.getByName("material_ClearCoat"),uA._clearCoatTextureProp=dn.getByName("material_ClearCoatTexture"),uA._clearCoatRoughnessProp=dn.getByName("material_ClearCoatRoughness"),uA._clearCoatRoughnessTextureProp=dn.getByName("material_ClearCoatRoughnessTexture"),uA._clearCoatNormalTextureProp=dn.getByName("material_ClearCoatNormalTexture");var uM=function(e){function t(r){(n=e.call(this,r,dw.find("pbr"))||this)._anisotropyRotation=0;var n,a=n.shaderData;return a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new cC(1,0,0)),n}return cH(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cU(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(t._anisotropyInfoProp);!!r.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(t._anisotropyInfoProp),n=cS.degreeToRadFactor*e;r.x=Math.cos(n),r.y=Math.sin(n)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),t}(uA);uM._metallicProp=dn.getByName("material_Metal"),uM._roughnessProp=dn.getByName("material_Roughness"),uM._roughnessMetallicTextureProp=dn.getByName("material_RoughnessMetallicTexture"),uM._iorProp=dn.getByName("material_IOR"),uM._anisotropyInfoProp=dn.getByName("material_AnisotropyInfo"),uM._anisotropyTextureProp=dn.getByName("material_AnisotropyTexture");var uE=function(e){function t(r){var n;return(n=e.call(this,r,dw.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new cI(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return cH(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cU(t,[{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var r=this.shaderData.getColor(t._specularColorProp);e!==r&&r.copyFrom(e)}},{key:"glossiness",get:function(){return this.shaderData.getFloat(t._glossinessProp)},set:function(e){this.shaderData.setFloat(t._glossinessProp,e)}},{key:"specularGlossinessTexture",get:function(){return this.shaderData.getTexture(t._specularGlossinessTextureProp)},set:function(e){this.shaderData.setTexture(t._specularGlossinessTextureProp,e),e?this.shaderData.enableMacro(t._specularGlossinessTextureMacro):this.shaderData.disableMacro(t._specularGlossinessTextureMacro)}}]),t}(uA);uE._specularColorProp=dn.getByName("material_PBRSpecularColor"),uE._glossinessProp=dn.getByName("material_Glossiness"),uE._specularGlossinessTextureProp=dn.getByName("material_SpecularGlossinessTexture"),uE._specularGlossinessTextureMacro=du.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uR=function(e){function t(r){var n,a=(n=e.call(this,r,dw.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new cI(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new cB(1,1,0,0)),n}return cH(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cU(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var r=this.shaderData.getColor(t._baseColorProp);e!==r&&r.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(t._baseTextureProp)},set:function(e){this.shaderData.setTexture(t._baseTextureProp,e),e?this.shaderData.enableMacro(t._baseTextureMacro):this.shaderData.disableMacro(t._baseTextureMacro)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var r=this.shaderData.getVector4(t._tilingOffsetProp);e!==r&&r.copyFrom(e)}}]),t}(uC),uw=((rO=(rV=function(t){var r=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),n=new Float32Array([1,-1,1,0,-1,-1,0,0,1,1,1,1,-1,1,0,1]),a=new uS(t,dw.find("blit"));a._addReferCount(1),a.renderState.depthState.enabled=!1,a.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(t,r),this.flipYBlitMesh=this._createBlitMesh(t,n),this.blitMaterial=a;var i=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R8G8B8A8,i),this.whiteTextureCube=this._create1x1Texture(t,1,e.TextureFormat.R8G8B8A8,i),t._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(t,2,e.TextureFormat.R8G8B8A8,i);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R32G32B32A32_UInt,o)}}).prototype)._createBlitMesh=function(t,r){var n=new d0(t);return n._addReferCount(1),n.setVertexElements([new dW("POSITION_UV",0,e.VertexElementFormat.Vector4,0)]),n.setVertexBufferBinding(new dO(t,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static),16),n.addSubMesh(0,4,e.MeshTopology.TriangleStrip),n},rO._create1x1Texture=function(t,r,n,a){switch(r){case 0:var i,o,s=new dQ(t,1,1,n,!1);s.setPixelBuffer(a),i=s;break;case 2:var l=new dJ(t,1,1,1,n,!1);l.setPixelBuffer(0,a),i=l;break;case 1:for(var c=new dZ(t,1,n,!1),d=0;d<6;d++)c.setPixelBuffer(e.TextureCubeFace.PositiveX+d,a);i=c;break;default:throw"Invalid texture type"}return i.isGCIgnored=!0,t.resourceManager.addContentRestorer(new(cH(o=function(){return d2.call(this,i)},d2),o.prototype.restoreContent=function(){switch(r){case 0:this.resource.setPixelBuffer(a);break;case 2:this.resource.setPixelBuffer(0,a);break;case 1:for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,a)}},o)),i},rV);(rN=l3||(l3={}))[rN.Texture2D=0]="Texture2D",rN[rN.TextureCube=1]="TextureCube",rN[rN.Texture2DArray=2]="Texture2DArray";var uP=((rz=(rk=function(){this._projectionParams=new cB,this.flipProjection=!1}).prototype).applyVirtualCamera=function(e,t){this.virtualCamera=e,this.flipProjection=t;var r=this.camera.shaderData,n=e.viewMatrix,a=e.projectionMatrix,i=e.viewProjectionMatrix;t&&(cF.multiply(rk._flipYMatrix,a,rk._flipYProjectionMatrix),cF.multiply(rk._flipYProjectionMatrix,n,rk._flipYViewProjectionMatrix),a=rk._flipYProjectionMatrix,i=rk._flipYViewProjectionMatrix),this.viewMatrix=n,this.projectionMatrix=a,this.viewProjectionMatrix=i,r.setMatrix(rk._viewMatrixProperty,n),r.setMatrix(rk._projectionMatrixProperty,a),r.setMatrix(rk.vpMatrixProperty,i);var o=this._projectionParams;o.set(t?-1:1,e.nearClipPlane,e.farClipPlane,0),r.setVector4(rk._cameraProjectionProperty,o)},rz.garbageCollection=function(){this.camera=null},rk);uP.vpMatrixProperty=dn.getByName("camera_VPMat"),uP.pipelineStageKey=dm.getByName("pipelineStage"),uP._flipYMatrix=new cF(1,0,0,0,0,-1),uP._cameraProjectionProperty=dn.getByName("camera_ProjectionParams"),uP._viewMatrixProperty=dn.getByName("camera_ViewMat"),uP._projectionMatrixProperty=dn.getByName("camera_ProjMat"),uP._flipYProjectionMatrix=new cF,uP._flipYViewProjectionMatrix=new cF;var uF=((rG=(rU=function(){}).prototype).setX=function(e,t,r,n){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n},rG.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},rU),uL=((rW=(rH=function(){}).prototype).set=function(e,t){this.data=e,this.shaderPasses=t},rW.dispose=function(){this.data=this.shaderPasses=null},rH),uD=(cH(rK=function(){return ud.apply(this,arguments)},ud),(rj=rK.prototype).createVertexElements=function(t){return t[0]=new dW("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new dW("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},rj.canBatch=function(e,t){var r=e.data,n=t.data;if(r.isAdd!==n.isAdd)return!1;var a=r.component.shaderData,i=n.component.shaderData,o=uf._textureProperty,s=uf._alphaCutoffProperty;return a.getTexture(o)===i.getTexture(o)&&a.getTexture(s)===i.getTexture(s)},rj.updateVertices=function(e,t,r){for(var n=e.verticesData,a=n.positions,i=n.uvs,o=n.vertexCount,s=0;s<o;s++){var l=a[s],c=i[s];t[r++]=l.x,t[r++]=l.y,t[r++]=l.z,t[r++]=c.x,t[r++]=c.y}return r},rj.drawBatches=function(t){for(var r=this._engine,n=this._batchedQueue,a=this._meshes[this._flushId],i=a.subMeshes,o=a._primitive,s=t.scene.shaderData,l=t.shaderData,c=0,d=i.length;c<d;c++){var u=i[c],h=n[c],_=h.data;if(!u||!h)return;var f=_.component,p=_.material,m=dw._compileMacros;dh.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=p.renderState.stencilState,v=_.isAdd?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate;g.passOperationFront=v,g.passOperationBack=v;var y=p.shader.subShaders[0].passes[0],x=y._getShaderProgram(r,m);if(!x.isValid)return;x.bind(),x.groupingOtherUniformBlock(),x.uploadAll(x.sceneUniformBlock,s),x.uploadAll(x.cameraUniformBlock,l),x.uploadAll(x.rendererUniformBlock,f.shaderData),x.uploadAll(x.materialUniformBlock,p.shaderData),(y._renderState||p.renderState)._apply(r,!1,y._renderStateDataMap,p.shaderData),r._hardwareRenderer.drawPrimitive(o,u,x)}},rK),uB=((rq=(rX=function(e){this._preMaskLayer=0,this._batcher=new uD(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rq.preRender=function(t,r){r.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,r),this._batcher.flush(t))},rq.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rq.destroy=function(){this._batcher.destroy(),this._batcher=null},rq._processMasksDiff=function(e,t){var r=this._preMaskLayer,n=t.maskLayer;if(r!==n)for(var a=e._renderPipeline._allSpriteMasks,i=r&n,o=n&~r,s=r&~n,l=a._elements,c=0,d=a.length;c<d;c++){var u=l[c],h=u.influenceLayers;if(!(h&i)){if(h&o){var _=u._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(h&s){var f=u._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},rX),uI=(cH(rY=function(){var e;return(e=uF.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},uF),(rQ=rY.prototype).set=function(e,t,r){this.component=e,this.material=t,this.verticesData=r},rQ.dispose=function(){this.component=this.material=this.verticesData=null},rY),uV=(cH(rJ=function(){var e;return(e=uF.call(this)||this).multiRenderData=!1,e},uF),(rZ=rJ.prototype).set=function(e,t,r,n,a){void 0===a&&(a=0),this.component=e,this.material=t,this.verticesData=r,this.texture=n,this.dataIndex=a},rZ.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rJ),uO=(cH(r$=function(){var e;return(e=uF.call(this)||this).charsData=[],e.multiRenderData=!0,e},uF),r$.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},r$);e.AssetType=void 0,(r0=e.AssetType||(e.AssetType={})).Text="Text",r0.JSON="JSON",r0.Buffer="Buffer",r0.Texture2D="Texture2D",r0.TextureCube="TextureCube",r0.Material="Material",r0.Mesh="Mesh",r0.AnimationClip="AnimationClip",r0.AnimatorController="AnimatorController",r0.GLTF="GLTF",r0.KTX="KTX",r0.KTXCube="KTXCube",r0.KTX2="KTX2",r0.Sprite="Sprite",r0.PrimitiveMesh="PrimitiveMesh",r0.SpriteAtlas="SpriteAtlas",r0.Env="Environment",r0.Scene="Scene",r0.HDR="HDR",r0.Font="Font",r0.SourceFont="SourceFont",r0.Project="project";var uN=((r2=(r1=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},r2.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},r2.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},r2.indexOf=function(e){return this._array.indexOf(e)},r2.getArray=function(){return this._array},r2.getLoopArray=function(){var e=this._loopArray;if(this._loopArrayDirty){var t=this._array,r=t.length;e.length=r;for(var n=0;n<r;n++)e[n]=t[n];this._loopArrayDirty=!1}return e},cU(r1,[{key:"length",get:function(){return this._array.length}}]),r1),uk=((r4=(r3=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new uN}).prototype).addScene=function(e,t){var r,n=this._scenes;if("number"==typeof e){if(e<0||e>n.length)throw"The index is out of range.";r=e}else r=n.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=n.indexOf(t);a!==r&&(n.removeByIndex(a),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},r4.removeScene=function(e){var t=this._scenes,r=t.indexOf(e);if(-1!==r){var n=t.getArray()[r];t.removeByIndex(r),e._sceneManager=null,n.isActive&&n._processActive(!1)}},r4.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,a=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return a.then(function(e){if(r)for(var t=n._scenes.getArray(),a=0,i=t.length;a<i;a++)t[a].destroy();n.addScene(e)}),a},r4.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},r4._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},cU(r3,[{key:"scenes",get:function(){return this._scenes.getArray()}},{key:"activeScene",get:function(){return this._scenes.getArray()[0]},set:function(e){var t=this.scenes[0];t&&this.removeScene(t),e&&this.addScene(0,e)}}]),r3),uz=((r5=(r8=function(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,r){if("pending"===t._state){var n=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:r});n.loaded=e,n.total=r,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,r)})}},function(e,r,n){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:r,total:n});i.loaded=r,i.total=n,t._onTaskDetailCallbacks.forEach(function(t){return t(e,r,n)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e,t){var r=this._taskCompleteProgress,n=this._taskDetailProgress;if(r&&e(r.loaded,r.total),n)for(var a in n){var i=n[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},r5.then=function(e,t){var r=this;return new r8(function(n,a){r._promise.then(e,t).then(n).catch(a)})},r5.catch=function(e){var t=this;return new r8(function(r,n){t._promise.catch(e).then(r).catch(n)})},r5.finally=function(e){return this._promise.finally(e)},r5.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},r8.all=function(e){return new r8(function(t,r,n){var a=function(e,r){l++,s[e]=r,n(l,o),l===o&&t(s)},i=function(e,t){cK(e,Promise)||cK(e,r8)?e.then(function(e){a(t,e)},r):Promise.resolve().then(function(){a(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)i(e[c],c)})},cU(r8,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),r8);(r9=l4||(l4={})).Pending="pending",r9.Fulfilled="fulfilled",r9.Rejected="rejected",r9.Canceled="canceled";var uU=((r7=(r6=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}).prototype).load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var r=e.map(function(e){return t._loadSingleItem(e)});return uz.all(r)},r7.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},r7.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var a=r[n];cK(a,e)&&t.push(a)}return t},r7.getAssetPath=function(e){return this._assetPool[e]},r7.cancelNotLoaded=function(e){var t,r=this;e?"string"==typeof e?null==(t=this._loadingPromises[e])||t.cancel():e.forEach(function(e){var t;null==(t=r._loadingPromises[e])||t.cancel()}):c0.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},r7.gc=function(){this._gc(!1),this.engine._pendingGC()},r7.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},r7._onSubAssetSuccess=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.resolve(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={resolve:r}},r7._onSubAssetFail=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.reject(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={reject:r}},r7._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},r7._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},r7._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},r7._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},r7._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},r7._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},r7._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},r7._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},r7._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},r7._restoreResourcesContent=function(){var e=this._contentRestorerPool,t=[];for(var r in e){var n=e[r].restoreContent();n&&t.push(n)}return Promise.all(t)},r7._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._referResourcePool=null,this._graphicResourcePool=null,this._contentRestorerPool=null,this._loadingPromises=null},r7._assignDefaultOptions=function(e){var t,r,n,a,i;if(e.type=null!=(t=e.type)?t:r6._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(r=e.retryCount)?r:this.retryCount,e.timeout=null!=(n=e.timeout)?n:this.timeout,e.retryInterval=null!=(a=e.retryInterval)?a:this.retryInterval,e.url=null!=(i=e.url)?i:e.urls.join(","),e},r7._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),a=n.url,i=this._virtualPathMap[a]?this._virtualPathMap[a]:a;!c0.isAbsoluteUrl(i)&&this.baseUrl&&(i=c0.resolveAbsoluteUrl(this.baseUrl,i));var o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],d=this._assetUrlPool[s];if(d)return new uz(function(e){e(r._getResolveResource(d,c))});var u=s;if(l)for(u+="?q="+c.shift();t=c.shift();)u+="["+t+"]";var h=this._loadingPromises,_=h[u];if(_)return new uz(function(e,t,r,n){_.onProgress(r,n).then(function(t){e(t)}).catch(function(e){t(e)})});var f=r6._loaders[n.type];if(!f)throw"loader not found: "+n.type;return l?((h[s]||this._loadMainAsset(f,n,s)).catch(function(e){r._onSubAssetFail(s,l,e)}),this._createSubAssetPromiseCallback(s,u,l)):this._loadMainAsset(f,n,s)},r7._loadMainAsset=function(e,t,r){var n=this;t.url=r;var a=this._loadingPromises,i=e.load(t,this);return a[r]=i,i.then(function(t){e.useCache&&n._addAsset(r,t),delete a[r],n._releaseSubAssetPromiseCallback(r)},function(){delete a[r],n._releaseSubAssetPromiseCallback(r)}),i},r7._createSubAssetPromiseCallback=function(e,t,r){var n,a=this,i=this._loadingPromises,o=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[r],s=null==o?void 0:o.resolve,l=null==o?void 0:o.reject,c=new uz(function(n,o){if(s)n(s);else if(l)o(l);else{var d;i[t]=c,((d=a._subAssetPromiseCallbacks)[e]||(d[e]={}))[r]={resolve:n,reject:o}}});return s||l||c.then(function(){delete i[t]},function(){return delete i[t]}),c},r7._gc=function(e){for(var t=c0.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++){var a=t[r];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},r7._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,a=t.length;n<a;n++)r=r[t[n]];return r},r7._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],a=void 0,i=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:i,queryPath:a}},r7._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===uH&&t.push(""),e.replace(uK,function(e,r,n,a){var i=e;n?i=a.replace(uW,"$1"):r&&(i=r.trim()),t.push(i)}),t},r7._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},r7.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,a=this._objectPool[t];if(a)i=Promise.resolve(a);else{var i,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return dr.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,i=this.load({url:s,type:this._editorResourceConfig[t].type})}return i.then(function(e){return n?e.clone():e})},r7.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},r6._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,a=r.length;n<a;n++)this._extTypeMapping[r[n].toLowerCase()]=e},r6._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},r6);function uG(e,t,r){return void 0===r&&(r=!0),function(n){var a=new n(r);uU._addLoader(e,a,t)}}uU._loaders={},uU._extTypeMapping={};var uH=46,uW=/\\(\\)?/g,uK=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(ne=e.PointerPhase||(e.PointerPhase={}))[ne.Down=0]="Down",ne[ne.Move=1]="Move",ne[ne.Stationary=2]="Stationary",ne[ne.Up=3]="Up",ne[ne.Leave=4]="Leave";var uj=((nr=(nt=function(t){this.phase=e.PointerPhase.Leave,this.position=new cD,this.deltaPosition=new cD,this._events=[],this._upMap=[],this._downMap=[],this._upList=new dV,this._downList=new dV,this.id=t}).prototype)._firePointerExitAndEnter=function(e){var t=this;this._currentEnteredEntity!==e&&(this._currentEnteredEntity&&this._currentEnteredEntity._scripts.forEach(function(e){e.onPointerExit(t)},function(e,t){e._entityScriptsIndex=t}),e&&e._scripts.forEach(function(e){e.onPointerEnter(t)},function(e,t){e._entityScriptsIndex=t}),this._currentEnteredEntity=e)},nr._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},nr._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},nr._firePointerUpAndClick=function(e){var t=this,r=this._currentPressedEntity;if(r){var n=r===e;r._scripts.forEach(function(e){n&&e.onPointerClick(t),e.onPointerUp(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=null}},nt);e.PointerButton=void 0,(nn=e.PointerButton||(e.PointerButton={}))[nn.None=0]="None",nn[nn.Primary=1]="Primary",nn[nn.Secondary=2]="Secondary",nn[nn.Auxiliary=4]="Auxiliary",nn[nn.XButton1=8]="XButton1",nn[nn.XButton2=16]="XButton2",nn[nn.XButton3=32]="XButton3",nn[nn.XButton4=64]="XButton4",nn[nn.XButton5=128]="XButton5",nn[nn.XButton6=256]="XButton6",nn[nn.XButton7=512]="XButton7",nn[nn.XButton8=1024]="XButton8";var uX=[1,4,2,8,16,32,64,128,256,512,1024],uq={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},uY=((na=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?na.platform=e.Platform.IPhone:/iPad/i.test(r)?na.platform=e.Platform.IPad:/Android/i.test(r)?na.platform=e.Platform.Android:/Macintosh/i.test(r)&&(na.platform=e.Platform.Mac),na.platform){case e.Platform.IPhone:t=r.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case e.Platform.IPad:t=r.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case e.Platform.Android:t=r.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case e.Platform.Mac:t=r.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X"}}},na._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},cU(na,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),na);uY.platform=e.Platform.Unknown,uY.operatingSystem="",uY._simdSupported=null,uY._initialize(),e.Keys=void 0,(ni=e.Keys||(e.Keys={}))[ni.Backquote=0]="Backquote",ni[ni.Backslash=1]="Backslash",ni[ni.Backspace=2]="Backspace",ni[ni.BracketLeft=3]="BracketLeft",ni[ni.BracketRight=4]="BracketRight",ni[ni.Comma=5]="Comma",ni[ni.Digit0=6]="Digit0",ni[ni.Digit1=7]="Digit1",ni[ni.Digit2=8]="Digit2",ni[ni.Digit3=9]="Digit3",ni[ni.Digit4=10]="Digit4",ni[ni.Digit5=11]="Digit5",ni[ni.Digit6=12]="Digit6",ni[ni.Digit7=13]="Digit7",ni[ni.Digit8=14]="Digit8",ni[ni.Digit9=15]="Digit9",ni[ni.Equal=16]="Equal",ni[ni.IntlBackslash=17]="IntlBackslash",ni[ni.IntlRo=18]="IntlRo",ni[ni.IntlYen=19]="IntlYen",ni[ni.KeyA=20]="KeyA",ni[ni.KeyB=21]="KeyB",ni[ni.KeyC=22]="KeyC",ni[ni.KeyD=23]="KeyD",ni[ni.KeyE=24]="KeyE",ni[ni.KeyF=25]="KeyF",ni[ni.KeyG=26]="KeyG",ni[ni.KeyH=27]="KeyH",ni[ni.KeyI=28]="KeyI",ni[ni.KeyJ=29]="KeyJ",ni[ni.KeyK=30]="KeyK",ni[ni.KeyL=31]="KeyL",ni[ni.KeyM=32]="KeyM",ni[ni.KeyN=33]="KeyN",ni[ni.KeyO=34]="KeyO",ni[ni.KeyP=35]="KeyP",ni[ni.KeyQ=36]="KeyQ",ni[ni.KeyR=37]="KeyR",ni[ni.KeyS=38]="KeyS",ni[ni.KeyT=39]="KeyT",ni[ni.KeyU=40]="KeyU",ni[ni.KeyV=41]="KeyV",ni[ni.KeyW=42]="KeyW",ni[ni.KeyX=43]="KeyX",ni[ni.KeyY=44]="KeyY",ni[ni.KeyZ=45]="KeyZ",ni[ni.Minus=46]="Minus",ni[ni.Period=47]="Period",ni[ni.Quote=48]="Quote",ni[ni.Semicolon=49]="Semicolon",ni[ni.Slash=50]="Slash",ni[ni.AltLeft=51]="AltLeft",ni[ni.AltRight=52]="AltRight",ni[ni.CapsLock=53]="CapsLock",ni[ni.ContextMenu=54]="ContextMenu",ni[ni.ControlLeft=55]="ControlLeft",ni[ni.ControlRight=56]="ControlRight",ni[ni.Enter=57]="Enter",ni[ni.MetaLeft=58]="MetaLeft",ni[ni.MetaRight=59]="MetaRight",ni[ni.ShiftLeft=60]="ShiftLeft",ni[ni.ShiftRight=61]="ShiftRight",ni[ni.Space=62]="Space",ni[ni.Tab=63]="Tab",ni[ni.Convert=64]="Convert",ni[ni.KanaMode=65]="KanaMode",ni[ni.Lang1=66]="Lang1",ni[ni.Lang2=67]="Lang2",ni[ni.Lang3=68]="Lang3",ni[ni.Lang4=69]="Lang4",ni[ni.Lang5=70]="Lang5",ni[ni.NonConvert=71]="NonConvert",ni[ni.Delete=72]="Delete",ni[ni.End=73]="End",ni[ni.Help=74]="Help",ni[ni.Home=75]="Home",ni[ni.Insert=76]="Insert",ni[ni.PageDown=77]="PageDown",ni[ni.PageUp=78]="PageUp",ni[ni.ArrowDown=79]="ArrowDown",ni[ni.ArrowLeft=80]="ArrowLeft",ni[ni.ArrowRight=81]="ArrowRight",ni[ni.ArrowUp=82]="ArrowUp",ni[ni.NumLock=83]="NumLock",ni[ni.Numpad0=84]="Numpad0",ni[ni.Numpad1=85]="Numpad1",ni[ni.Numpad2=86]="Numpad2",ni[ni.Numpad3=87]="Numpad3",ni[ni.Numpad4=88]="Numpad4",ni[ni.Numpad5=89]="Numpad5",ni[ni.Numpad6=90]="Numpad6",ni[ni.Numpad7=91]="Numpad7",ni[ni.Numpad8=92]="Numpad8",ni[ni.Numpad9=93]="Numpad9",ni[ni.NumpadAdd=94]="NumpadAdd",ni[ni.NumpadBackspace=95]="NumpadBackspace",ni[ni.NumpadClear=96]="NumpadClear",ni[ni.NumpadClearEntry=97]="NumpadClearEntry",ni[ni.NumpadComma=98]="NumpadComma",ni[ni.NumpadDecimal=99]="NumpadDecimal",ni[ni.NumpadDivide=100]="NumpadDivide",ni[ni.NumpadEnter=101]="NumpadEnter",ni[ni.NumpadEqual=102]="NumpadEqual",ni[ni.NumpadHash=103]="NumpadHash",ni[ni.NumpadMemoryAdd=104]="NumpadMemoryAdd",ni[ni.NumpadMemoryClear=105]="NumpadMemoryClear",ni[ni.NumpadMemoryRecall=106]="NumpadMemoryRecall",ni[ni.NumpadMemoryStore=107]="NumpadMemoryStore",ni[ni.NumpadMemorySubtract=108]="NumpadMemorySubtract",ni[ni.NumpadMultiply=109]="NumpadMultiply",ni[ni.NumpadParenLeft=110]="NumpadParenLeft",ni[ni.NumpadParenRight=111]="NumpadParenRight",ni[ni.NumpadStar=112]="NumpadStar",ni[ni.NumpadSubtract=113]="NumpadSubtract",ni[ni.Escape=114]="Escape",ni[ni.F1=115]="F1",ni[ni.F2=116]="F2",ni[ni.F3=117]="F3",ni[ni.F4=118]="F4",ni[ni.F5=119]="F5",ni[ni.F6=120]="F6",ni[ni.F7=121]="F7",ni[ni.F8=122]="F8",ni[ni.F9=123]="F9",ni[ni.F10=124]="F10",ni[ni.F11=125]="F11",ni[ni.F12=126]="F12",ni[ni.F13=127]="F13",ni[ni.F14=128]="F14",ni[ni.F15=129]="F15",ni[ni.Fn=130]="Fn",ni[ni.FnLock=131]="FnLock",ni[ni.PrintScreen=132]="PrintScreen",ni[ni.ScrollLock=133]="ScrollLock",ni[ni.Pause=134]="Pause",ni[ni.BrowserBack=135]="BrowserBack",ni[ni.BrowserFavorites=136]="BrowserFavorites",ni[ni.BrowserForward=137]="BrowserForward",ni[ni.BrowserHome=138]="BrowserHome",ni[ni.BrowserRefresh=139]="BrowserRefresh",ni[ni.BrowserSearch=140]="BrowserSearch",ni[ni.BrowserStop=141]="BrowserStop",ni[ni.Eject=142]="Eject",ni[ni.LaunchApp1=143]="LaunchApp1",ni[ni.LaunchApp2=144]="LaunchApp2",ni[ni.LaunchMail=145]="LaunchMail",ni[ni.MediaPlayPause=146]="MediaPlayPause",ni[ni.MediaSelect=147]="MediaSelect",ni[ni.MediaStop=148]="MediaStop",ni[ni.MediaTrackNext=149]="MediaTrackNext",ni[ni.MediaTrackPrevious=150]="MediaTrackPrevious",ni[ni.Power=151]="Power",ni[ni.Sleep=152]="Sleep",ni[ni.AudioVolumeDown=153]="AudioVolumeDown",ni[ni.AudioVolumeMute=154]="AudioVolumeMute",ni[ni.AudioVolumeUp=155]="AudioVolumeUp",ni[ni.WakeUp=156]="WakeUp",ni[ni.Hyper=157]="Hyper",ni[ni.Super=158]="Super",ni[ni.Turbo=159]="Turbo",ni[ni.Abort=160]="Abort",ni[ni.Resume=161]="Resume",ni[ni.Suspend=162]="Suspend",ni[ni.Again=163]="Again",ni[ni.Copy=164]="Copy",ni[ni.Cut=165]="Cut",ni[ni.Find=166]="Find",ni[ni.Open=167]="Open",ni[ni.Paste=168]="Paste",ni[ni.Props=169]="Props",ni[ni.Select=170]="Select",ni[ni.Undo=171]="Undo",ni[ni.Hiragana=172]="Hiragana",ni[ni.Katakana=173]="Katakana",ni[ni.Unidentified=174]="Unidentified";var uQ=((ns=(no=function(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new dV,this._curFrameDownList=new dV,this._curFrameUpList=new dV,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var t=this._nativeEvents,r=this._curFrameDownList,n=this._curFrameUpList;if(r.length=0,n.length=0,t.length>0){for(var a=this._engine.time.frameCount,i=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,d=t.length;c<d;c++){var u=t[c],h=e.Keys[u.code];switch(u.type){case"keydown":null==i[h]&&(r.add(h),o.add(h),i[h]=o.length-1,s[h]=a);break;case"keyup":var _=i[h];if(null!=_){i[h]=null;var f=o.deleteByIndex(_);f&&(i[f]=_)}if(n.add(h),l[h]=a,uY.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)i[o.get(p)]=null;o.length=0}}}t.length=0}},ns._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},ns._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},ns._onKeyEvent=function(e){this._nativeEvents.push(e)},ns._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},ns._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},no);e.CameraClearFlags=void 0,(nl=e.CameraClearFlags||(e.CameraClearFlags={}))[nl.None=0]="None",nl[nl.Color=1]="Color",nl[nl.Depth=2]="Depth",nl[nl.Stencil=4]="Stencil",nl[nl.ColorDepth=3]="ColorDepth",nl[nl.ColorStencil=5]="ColorStencil",nl[nl.DepthStencil=6]="DepthStencil",nl[nl.All=7]="All",e.Collider=(cH(nc=function(e){var t;return(t=di.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},di),(nd=nc.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e))},nd.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._phasedActiveInScene&&this.scene.physics._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},nd.clearShapes=function(){for(var e=this._shapes,t=0,r=e.length;t<r;t++){var n=e[t];this._phasedActiveInScene&&this.scene.physics._removeColliderShape(n),n._destroy(),this._nativeCollider.removeShape(n._nativeShape)}e.length=0},nd._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform;this._nativeCollider.setWorldTransform(e.worldPosition,e.worldRotationQuaternion);for(var t=e.lossyWorldScale,r=0,n=this.shapes.length;r<n;r++)this.shapes[r]._nativeShape.setWorldScale(t);this._updateFlag.flag=!1}},nd._onLateUpdate=function(){},nd._onEnableInScene=function(){var e=this.scene.physics;e._addCollider(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._addColliderShape(t[r])},nd._onDisableInScene=function(){var e=this.scene.physics;e._removeCollider(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._removeColliderShape(t[r])},nd._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},nd._onDestroy=function(){di.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nd._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},cU(nc,[{key:"shapes",get:function(){return this._shapes}}]),nc),cW([cj],e.Collider.prototype,"_index",void 0),cW([cj],e.Collider.prototype,"_nativeCollider",void 0),cW([cj],e.Collider.prototype,"_updateFlag",void 0),cW([cY],e.Collider.prototype,"_shapes",void 0),e.Collider=cW([dl(dd,e.DependentMode.CheckOnly)],e.Collider);var uJ=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new dV,this._gravity=new cC(0,-9.81,0),this._onContactEnter=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t})},this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=e.engine;n._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var r=t.prototype;return r.raycast=function(t,r,n,a){var i,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(i=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(i=n),a&&(i=a);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==i?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var a=o._scene.engine._physicalObjectsMap[e];i.entity=a._collider.entity,i.shape=a,i.distance=t,i.normal.copyFrom(n),i.point.copyFrom(r)})||(i.entity=null,i.shape=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)n.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),r.update(t),this._callColliderOnLateUpdate()},r._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},r._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},r._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},r._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},r._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},r._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},r._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},r._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},r._gc=function(){this._colliders.garbageCollection()},r._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},cU(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(e){this._fixedTimeStep=Math.max(e,cS.zeroTolerance)}}]),t}();uJ._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nu=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nu.PreventClimbing=0]="PreventClimbing",nu[nu.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var uZ=(nh=e.Collider,cH(n_=function(t){var r;return(r=nh.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new cC(0,1,0),r._slopeLimit=.707,r._nativeCollider=uJ._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(ck(r)),r._upDirection._onValueChanged=r._setUpDirection,r},nh),(nf=n_.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},nf.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nh.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nf.clearShapes=function(){this._shapes.length>0&&nh.prototype.removeShape.call(this,this._shapes[0])},nf._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var r=e.lossyWorldScale,n=0,a=t.length;n<a;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},nf._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},nf._onEnableInScene=function(){var e=this.scene.physics;e._addCharacterController(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._addColliderShape(t[r])},nf._onDisableInScene=function(){var e=this.scene.physics;e._removeCharacterController(this);for(var t=this.shapes,r=0,n=t.length;r<n;r++)e._removeColliderShape(t[r])},nf._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},cU(n_,[{key:"stepOffset",get:function(){return this._stepOffset},set:function(e){this._stepOffset!==e&&(this._stepOffset=e,this._nativeCollider.setStepOffset(e))}},{key:"nonWalkableMode",get:function(){return this._nonWalkableMode},set:function(e){this._nonWalkableMode!==e&&(this._nonWalkableMode=e,this._nativeCollider.setNonWalkableMode(e))}},{key:"upDirection",get:function(){return this._upDirection},set:function(e){this._upDirection!==e&&this._upDirection.copyFrom(e)}},{key:"slopeLimit",get:function(){return this._slopeLimit},set:function(e){this._slopeLimit!==e&&(this._slopeLimit=e,this._nativeCollider.setSlopeLimit(e))}}]),n_),u$=(np=e.Collider,cH(nm=function(e){(t=np.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new cC,t._angularVelocity=new cC,t._mass=1,t._centerOfMass=new cC,t._inertiaTensor=new cC(1,1,1),t._maxAngularVelocity=100,t._maxDepenetrationVelocity=1e3,t._solverIterations=4,t._isKinematic=!1,t._constraints=0,t._collisionDetectionMode=0,t._sleepThreshold=.005;var t,r=t.entity.transform;return t._nativeCollider=uJ._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(ck(t)),t._setAngularVelocity=t._setAngularVelocity.bind(ck(t)),t._setCenterOfMass=t._setCenterOfMass.bind(ck(t)),t._setInertiaTensor=t._setInertiaTensor.bind(ck(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},np),(ng=nm.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},ng.applyTorque=function(e){this._nativeCollider.addTorque(e)},ng.move=function(e,t){this._nativeCollider.move(e,t)},ng.sleep=function(){this._nativeCollider.sleep()},ng.wakeUp=function(){this._nativeCollider.wakeUp()},ng._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},ng._cloneTo=function(e){np.prototype._cloneTo.call(this,e),e.linearDamping=this.linearDamping,e.angularDamping=this.angularDamping,e.linearVelocity=this.linearVelocity,e.angularVelocity=this.angularVelocity,e.mass=this.mass,e.centerOfMass=this.centerOfMass,e.inertiaTensor=this.inertiaTensor,e.maxAngularVelocity=this.maxAngularVelocity,e.maxDepenetrationVelocity=this.maxDepenetrationVelocity,e.sleepThreshold=this.sleepThreshold,e.solverIterations=this.solverIterations,e.isKinematic=this.isKinematic,e.constraints=this.constraints,e.collisionDetectionMode=this.collisionDetectionMode},ng._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},ng._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},ng._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},ng._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},cU(nm,[{key:"linearDamping",get:function(){return this._linearDamping},set:function(e){this._linearDamping!==e&&(this._linearDamping=e,this._nativeCollider.setLinearDamping(e))}},{key:"angularDamping",get:function(){return this._angularDamping},set:function(e){this._angularDamping!==e&&(this._angularDamping=e,this._nativeCollider.setAngularDamping(e))}},{key:"linearVelocity",get:function(){return this._linearVelocity},set:function(e){this._linearVelocity!==e&&this._linearVelocity.copyFrom(e)}},{key:"angularVelocity",get:function(){return this._angularVelocity},set:function(e){this._angularVelocity!==e&&this._angularVelocity.copyFrom(e)}},{key:"mass",get:function(){return this._mass},set:function(e){this._mass!==e&&(this._mass=e,this._nativeCollider.setMass(e))}},{key:"centerOfMass",get:function(){return this._centerOfMass},set:function(e){this._centerOfMass!==e&&this._centerOfMass.copyFrom(e)}},{key:"inertiaTensor",get:function(){return this._inertiaTensor},set:function(e){this._inertiaTensor!==e&&this._inertiaTensor.copyFrom(e)}},{key:"maxAngularVelocity",get:function(){return this._maxAngularVelocity},set:function(e){this._maxAngularVelocity!==e&&(this._maxAngularVelocity=e,this._nativeCollider.setMaxAngularVelocity(e))}},{key:"maxDepenetrationVelocity",get:function(){return this._maxDepenetrationVelocity},set:function(e){this._maxDepenetrationVelocity!==e&&(this._maxDepenetrationVelocity=e,this._nativeCollider.setMaxDepenetrationVelocity(e))}},{key:"sleepThreshold",get:function(){return this._sleepThreshold},set:function(e){e!==this._sleepThreshold&&(this._sleepThreshold=e,this._nativeCollider.setSleepThreshold(e))}},{key:"solverIterations",get:function(){return this._solverIterations},set:function(e){this._solverIterations!==e&&(this._solverIterations=e,this._nativeCollider.setSolverIterations(e))}},{key:"isKinematic",get:function(){return this._isKinematic},set:function(e){this._isKinematic!==e&&(this._isKinematic=e,this._nativeCollider.setIsKinematic(e))}},{key:"constraints",get:function(){return this._constraints},set:function(e){this._constraints!==e&&(this._constraints=e,this._nativeCollider.setConstraints(e))}},{key:"collisionDetectionMode",get:function(){return this._collisionDetectionMode},set:function(e){this._collisionDetectionMode!==e&&(this._collisionDetectionMode=e,this._nativeCollider.setCollisionDetectionMode(e))}}]),nm);cW([cj],u$.prototype,"_linearDamping",void 0),cW([cj],u$.prototype,"_angularDamping",void 0),cW([cj],u$.prototype,"_linearVelocity",void 0),cW([cj],u$.prototype,"_angularVelocity",void 0),cW([cj],u$.prototype,"_mass",void 0),cW([cj],u$.prototype,"_centerOfMass",void 0),cW([cj],u$.prototype,"_inertiaTensor",void 0),cW([cj],u$.prototype,"_maxAngularVelocity",void 0),cW([cj],u$.prototype,"_maxDepenetrationVelocity",void 0),cW([cj],u$.prototype,"_solverIterations",void 0),cW([cj],u$.prototype,"_isKinematic",void 0),cW([cj],u$.prototype,"_constraints",void 0),cW([cj],u$.prototype,"_collisionDetectionMode",void 0),cW([cj],u$.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(nv=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nv.Discrete=0]="Discrete",nv[nv.Continuous=1]="Continuous",nv[nv.ContinuousDynamic=2]="ContinuousDynamic",nv[nv.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(ny=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[ny.None=0]="None",ny[ny.FreezePositionX=1]="FreezePositionX",ny[ny.FreezePositionY=2]="FreezePositionY",ny[ny.FreezePositionZ=4]="FreezePositionZ",ny[ny.FreezeRotationX=8]="FreezeRotationX",ny[ny.FreezeRotationY=16]="FreezeRotationY",ny[ny.FreezeRotationZ=32]="FreezeRotationZ";var u0=function(){this.entity=null,this.distance=0,this.point=new cC,this.normal=new cC,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(nx=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nx.Average=0]="Average",nx[nx.Minimum=1]="Minimum",nx[nx.Multiply=2]="Multiply",nx[nx.Maximum=3]="Maximum";var u1=((nb=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=uJ._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},cU(nb,[{key:"bounciness",get:function(){return this._bounciness},set:function(e){this._bounciness!==e&&(this._bounciness=e,this._nativeMaterial.setBounciness(e))}},{key:"dynamicFriction",get:function(){return this._dynamicFriction},set:function(e){this._dynamicFriction!==e&&(this._dynamicFriction=e,this._nativeMaterial.setDynamicFriction(e))}},{key:"staticFriction",get:function(){return this._staticFriction},set:function(e){this._staticFriction!==e&&(this._staticFriction=e,this._nativeMaterial.setStaticFriction(e))}},{key:"bounceCombine",get:function(){return this._bounceCombine},set:function(e){this._bounceCombine!==e&&(this._bounceCombine=e,this._nativeMaterial.setBounceCombine(e))}},{key:"frictionCombine",get:function(){return this._frictionCombine},set:function(e){this._frictionCombine!==e&&(this._frictionCombine=e,this._nativeMaterial.setFrictionCombine(e))}}]),nb),u2=(nS=e.Collider,cH(nC=function(e){var t,r=(t=nS.call(this,e)||this).entity.transform;return t._nativeCollider=uJ._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},nS),nC);e.ColliderShapeUpAxis=void 0,(nT=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nT.X=0]="X",nT[nT.Y=1]="Y",nT[nT.Z=2]="Z",e.ControllerCollisionFlag=void 0,(nA=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[nA.Sides=1]="Sides",nA[nA.Up=2]="Up",nA[nA.Down=4]="Down",e.Joint=(cH(nM=function(e){var t;return(t=di.call(this,e)||this)._colliderInfo=new u3,t._connectedColliderInfo=new u3,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new cC,t},di),nM.prototype._cloneTo=function(e){e.connectedCollider=this.connectedCollider,e.connectedAnchor=this.connectedAnchor,e.connectedMassScale=this.connectedMassScale,e.connectedInertiaScale=this.connectedInertiaScale,e.massScale=this.massScale,e.inertiaScale=this.inertiaScale,e.breakForce=this.breakForce,e.breakTorque=this.breakTorque},cU(nM,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){this._connectedColliderInfo.collider!==e&&(this._connectedColliderInfo.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){e!==this._connectedColliderInfo.massScale&&(this._connectedColliderInfo.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){e!==this._connectedColliderInfo.inertiaScale&&(this._connectedColliderInfo.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._colliderInfo.massScale},set:function(e){e!==this._colliderInfo.massScale&&(this._colliderInfo.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._colliderInfo.inertiaScale},set:function(e){e!==this._colliderInfo.inertiaScale&&(this._colliderInfo.inertiaScale=e,this._nativeJoint.setInertiaScale(e))}},{key:"breakForce",get:function(){return this._force},set:function(e){e!==this._force&&(this._force=e,this._nativeJoint.setBreakForce(e))}},{key:"breakTorque",get:function(){return this._torque},set:function(e){e!==this._torque&&(this._torque=e,this._nativeJoint.setBreakTorque(e))}}]),nM),cW([cj],e.Joint.prototype,"_colliderInfo",void 0),cW([cj],e.Joint.prototype,"_connectedColliderInfo",void 0),cW([cj],e.Joint.prototype,"_nativeJoint",void 0),cW([cj],e.Joint.prototype,"_force",void 0),cW([cj],e.Joint.prototype,"_torque",void 0),e.Joint=cW([dl(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var u3=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},u4=(nE=e.Joint,cH(nR=function(){return nE.apply(this,arguments)},nE),nR.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uJ._nativePhysics.createFixedJoint(t.collider._nativeCollider)},nR);(nw=l8||(l8={}))[nw.None=0]="None",nw[nw.LimitEnabled=1]="LimitEnabled",nw[nw.DriveEnabled=2]="DriveEnabled",nw[nw.DriveFreeSpin=4]="DriveFreeSpin";var u8=(nP=e.Joint,cH(nF=function(){var e;return e=nP.apply(this,arguments)||this,e._axis=new cC(1,0,0),e._hingeFlags=l8.None,e._useSpring=!1,e},nP),(nL=nF.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cC,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uJ._nativePhysics.createHingeJoint(t.collider._nativeCollider)},nL._cloneTo=function(e){e.axis=this.axis,e.swingOffset=this.swingOffset,e.useLimits=this.useLimits,e.useMotor=this.useMotor,e.useSpring=this.useSpring,e.motor=this.motor,e.limits=this.limits},cU(nF,[{key:"axis",get:function(){return this._axis},set:function(e){var t=this._axis;e!==t&&t.copyFrom(e),this._nativeJoint.setAxis(t)}},{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(t)}},{key:"angle",get:function(){return this._nativeJoint.getAngle()}},{key:"velocity",get:function(){return this._nativeJoint.getVelocity()}},{key:"useLimits",get:function(){return(this._hingeFlags&l8.LimitEnabled)==l8.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=l8.LimitEnabled:this._hingeFlags&=~l8.LimitEnabled,this._nativeJoint.setHingeJointFlag(l8.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&l8.DriveEnabled)==l8.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=l8.DriveEnabled:this._hingeFlags&=~l8.DriveEnabled,this._nativeJoint.setHingeJointFlag(l8.DriveEnabled,e))}},{key:"useSpring",get:function(){return this._useSpring},set:function(e){this._useSpring!==e&&(this._useSpring=e,this.limits=this._limits)}},{key:"motor",get:function(){return this._jointMonitor},set:function(e){this._jointMonitor!==e&&(this._jointMonitor=e,this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRation),this._nativeJoint.setHingeJointFlag(l8.DriveFreeSpin,e.freeSpin))}},{key:"limits",get:function(){return this._limits},set:function(e){this._limits!==e&&(this._limits=e,this.useSpring?this._nativeJoint.setSoftLimit(e.min,e.max,e.stiffness,e.damping):this._nativeJoint.setHardLimit(e.min,e.max,e.contactDistance))}}]),nF);cW([cj],u8.prototype,"_axis",void 0),cW([cj],u8.prototype,"_hingeFlags",void 0),cW([cj],u8.prototype,"_useSpring",void 0),cW([cj],u8.prototype,"_jointMonitor",void 0),cW([cj],u8.prototype,"_limits",void 0);var u5=(nD=e.Joint,cH(nB=function(){var e;return e=nD.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},nD),(nI=nB.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cC,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uJ._nativePhysics.createSpringJoint(t.collider._nativeCollider)},nI._cloneTo=function(e){e.swingOffset=this.swingOffset,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.tolerance=this.tolerance,e.stiffness=this.stiffness,e.damping=this.damping},cU(nB,[{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(e)}},{key:"minDistance",get:function(){return this._minDistance},set:function(e){this._minDistance!==e&&(this._minDistance=e,this._nativeJoint.setMinDistance(e))}},{key:"maxDistance",get:function(){return this._maxDistance},set:function(e){this._maxDistance!==e&&(this._maxDistance=e,this._nativeJoint.setMaxDistance(e))}},{key:"tolerance",get:function(){return this._tolerance},set:function(e){this._tolerance!==e&&(this._tolerance=e,this._nativeJoint.setTolerance(e))}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){this._stiffness!==e&&(this._stiffness=e,this._nativeJoint.setStiffness(e))}},{key:"damping",get:function(){return this._damping},set:function(e){this._damping!==e&&(this._damping=e,this._nativeJoint.setDamping(e))}}]),nB),u9=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},u6=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},u7=function(){function e(){this._isTrigger=!1,this._rotation=new cC,this._position=new cC,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new u1,this._id=e._idGenerator++,this._setRotation=this._setRotation.bind(this),this._setPosition=this._setPosition.bind(this),this._rotation._onValueChanged=this._setRotation,this._position._onValueChanged=this._setPosition}var t=e.prototype;return t._cloneTo=function(e){e.contactOffset=this.contactOffset,e.rotation=this.rotation,e.position=this.position,e.isTrigger=this.isTrigger,e.material=this.material},t._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},cU(e,[{key:"collider",get:function(){return this._collider}},{key:"id",get:function(){return this._id}},{key:"contactOffset",get:function(){return this._contactOffset},set:function(e){this._contactOffset!==e&&(this._contactOffset=e,this._nativeShape.setContactOffset(e))}},{key:"material",get:function(){return this._material},set:function(e){this._material!==e&&(this._material=e,this._nativeShape.setMaterial(e._nativeMaterial))}},{key:"rotation",get:function(){return this._rotation},set:function(e){this._rotation!=e&&this._rotation.copyFrom(e)}},{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"isTrigger",get:function(){return this._isTrigger},set:function(e){this._isTrigger!==e&&(this._isTrigger=e,this._nativeShape.setIsTrigger(e))}}]),e}();u7._idGenerator=0,cW([cj],u7.prototype,"_collider",void 0),cW([cj],u7.prototype,"_nativeShape",void 0),cW([cj],u7.prototype,"_id",void 0),cW([cj],u7.prototype,"_material",void 0),cW([cj],u7.prototype,"_isTrigger",void 0),cW([cj],u7.prototype,"_rotation",void 0),cW([cj],u7.prototype,"_position",void 0),cW([cj],u7.prototype,"_contactOffset",void 0);var he=(cH(nV=function(){var e;return(e=u7.call(this)||this)._size=new cC(1,1,1),e._nativeShape=uJ._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(ck(e)),e._size._onValueChanged=e._setSize,e},u7),(nO=nV.prototype)._cloneTo=function(e){u7.prototype._cloneTo.call(this,e),e.size=this.size},nO._setSize=function(){this._nativeShape.setSize(this._size)},cU(nV,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),nV);cW([cj],he.prototype,"_size",void 0);var ht=(cH(nN=function(){var e;return(e=u7.call(this)||this)._radius=1,e._nativeShape=uJ._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},u7),nN.prototype._cloneTo=function(e){u7.prototype._cloneTo.call(this,e),e.radius=this.radius},cU(nN,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),nN);cW([cj],ht.prototype,"_radius",void 0);var hr=(cH(nk=function(){var e;return(e=u7.call(this)||this)._nativeShape=uJ._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},u7),nk),hn=(cH(nz=function(){var t;return(t=u7.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=uJ._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},u7),nz.prototype._cloneTo=function(e){u7.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},cU(nz,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._nativeShape.setHeight(e))}},{key:"upAxis",get:function(){return this._upAxis},set:function(e){this._upAxis!==e&&(this._upAxis=e,this._nativeShape.setUpAxis(e))}}]),nz);cW([cj],hn.prototype,"_radius",void 0),cW([cj],hn.prototype,"_height",void 0),cW([cj],hn.prototype,"_upAxis",void 0);var ha=((nG=(nU=function(t,r){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new dV,this._downList=new dV,this._nativeEvents=[],"undefined"!=typeof Window&&cK(r,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=t,this._target=r,this._canvas=t.canvas,this._htmlCanvas=t._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,a=this._canvas,i=a.width,o=a.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),d=c.left,u=c.top,h=i/s,_=o/l,f=t.length-1;f>=0;f--)t[f].phase===e.PointerPhase.Leave&&t.splice(f,1);for(var p=0,m=r.length;p<m;p++){var g=r[p],v=g.pointerId,y=this._getPointerByID(v);if(y)y._events.push(g);else{var x=t.length;if(0===x||this._multiPointerEnabled){for(var b,S=this._pointerPool,C=0;C<x&&!(t[C].id>C);C++);(y=S[b=C]||(S[b]=new uj(C)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-d)*h,(g.clientY-u)*_),t.splice(C,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var T=this._engine.time.frameCount,A=0,M=t.length;A<M;A++){var E=t[A];E._upList.length=E._downList.length=0,this._updatePointerInfo(T,E,d,u,h,_),this._buttons|=E.pressedButtons}},nG._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,a=0,i=r.length;a<i;a++){var o=r[a],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/n.width,l.y/n.height);o._firePointerExitAndEnter(c);var d=s.length;if(d>0){for(var u=0;u<d;u++)switch(s[u].type){case"pointerdown":o.phase=e.PointerPhase.Down,o._firePointerDown(c);break;case"pointerup":o.phase=e.PointerPhase.Up,o._firePointerUpAndClick(c);break;case"pointerleave":case"pointercancel":o.phase=e.PointerPhase.Leave,o._firePointerExitAndEnter(null)}s.length=0}}},nG._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},nG._onPointerEvent=function(e){this._nativeEvents.push(e)},nG._getPointerByID=function(e){for(var t=this._pointers,r=t.length-1;r>=0;r--)if(t[r]._uniqueID===e)return t[r];return null},nG._updatePointerInfo=function(t,r,n,a,i,o){var s=r._events,l=r.position,c=s.length;if(c>0){var d=this._upList,u=this._upMap,h=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-n)*i,m=(f.clientY-a)*o;r.deltaPosition.set(p-l.x,m-l.y),l.set(p,m);for(var g=0;g<c;g++){var v=s[g],y=v.button;switch(r.button=uX[y]||e.PointerButton.None,r.pressedButtons=v.buttons,v.type){case"pointerdown":h.add(y),_[y]=t,r._downList.add(y),r._downMap[y]=t,r.phase=e.PointerPhase.Down;break;case"pointerup":d.add(y),u[y]=t,r._upList.add(y),r._upMap[y]=t,r.phase=e.PointerPhase.Up;break;case"pointermove":r.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":r.phase=e.PointerPhase.Leave}}this._engine._physicsInitialized||(s.length=0)}else r.deltaPosition.set(0,0),r.phase=e.PointerPhase.Stationary},nG._pointerRayCast=function(t,r,n){for(var a=nU._tempPoint,i=nU._tempRay,o=nU._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,d=c._elements,u=c.length-1;u>=0;u--){var h=d[u];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(r>=f&&n>=p&&r-f<=m&&n-p<=g){if(a.set((r-f)/m,(n-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},nG._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},nG._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},nU);ha._tempRay=new cL,ha._tempPoint=new cD,ha._tempHitResult=new u0;var hi=((nW=(nH=function(e,t){this._delta=new cC,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var r=t.length-1;r>=0;r--){var n=t[r];e.x+=n.deltaX,e.y+=n.deltaY,e.z+=n.deltaZ}t.length=0}},nW._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},nW._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},nW._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},nW._onWheelEvent=function(e){this._nativeEvents.push(e)},nH),ho=((nj=(nK=function(e,t){this._initialized=!1,this._engine=e;var r,n,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&cK(i,OffscreenCanvas)||(this._wheelManager=new hi(e,null!=(r=null==t?void 0:t.wheelTarget)?r:i),this._pointerManager=new ha(e,null!=(n=null==t?void 0:t.pointerTarget)?n:i),this._keyboardManager=new uQ(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},nj.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},nj.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},nj.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},nj.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[uq[e]]===this._engine.time.frameCount)},nj.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[uq[e]]===this._engine.time.frameCount)},nj._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},nj._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},nj._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},cU(nK,[{key:"pointers",get:function(){return this._initialized?this._pointerManager._pointers:[]}},{key:"multiPointerEnabled",get:function(){return!!this._initialized&&this._pointerManager._multiPointerEnabled},set:function(e){this._initialized&&(this._pointerManager._multiPointerEnabled=e)}},{key:"wheelDelta",get:function(){return this._initialized?this._wheelManager._delta:null}}]),nK);(l5||(l5={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(nX=l9||(l9={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",nX.DirectionTime="a_DirectionTime",nX.StartColor="a_StartColor",nX.StartSize="a_StartSize",nX.StartRotation0="a_StartRotation0",nX.StartSpeed="a_StartSpeed",nX.Random0="a_Random0",nX.Random1="a_Random1",nX.SimulationWorldPosition="a_SimulationWorldPosition",nX.SimulationWorldRotation="a_SimulationWorldRotation",nX.SimulationUV="a_SimulationUV";var hs=function(t){this.billboardVertexElement=new dW(l5.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new dW(l9.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new dW(l9.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new dW(l9.StartColor,32,e.VertexElementFormat.Vector4,1,1),new dW(l9.StartSize,48,e.VertexElementFormat.Vector3,1,1),new dW(l9.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new dW(l9.StartSpeed,72,e.VertexElementFormat.Float,1,1),new dW(l9.Random0,76,e.VertexElementFormat.Vector4,1,1),new dW(l9.Random1,92,e.VertexElementFormat.Vector4,1,1),new dW(l9.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new dW(l9.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new dW(l9.SimulationUV,136,e.VertexElementFormat.Vector4,1,1)],this.instanceVertexStride=152,this.instanceVertexFloatStride=this.instanceVertexStride/4,this.startLifeTimeOffset=3,this.timeOffset=7,this.simulationUVOffset=34,this.billboardIndexCount=6;var r,n,a=new dO(t,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);a.isGCIgnored=!0,this.billboardVertexBufferBinding=new dH(a,16);var i=new dO(t,e.BufferBindFlag.IndexBuffer,this.billboardIndexCount,e.BufferUsage.Static,!1);i.isGCIgnored=!0,this.billboardIndexBufferBinding=new dk(i,e.IndexFormat.UInt8);var o=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),s=new Uint8Array([0,2,3,0,1,2]);a.setData(o),i.setData(s),t.resourceManager.addContentRestorer(new(cH(r=function(){return d2.call(this,a)},d2),r.prototype.restoreContent=function(){a.setData(o)},r)),t.resourceManager.addContentRestorer(new(cH(n=function(){return d2.call(this,i)},d2),n.prototype.restoreContent=function(){},n))},hl="#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}",hc=((nq=function(){}).init=function(){var t=new db("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nvoid main(){\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",{pipelineStage:e.PipelineStage.ShadowCaster}),r=new db("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:e.PipelineStage.DepthOnly}),n=[t,r],a={pipelineStage:e.PipelineStage.Forward};dw.create("blinn-phong",[].concat(new db("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dw.create("pbr",[].concat(new db("Forward",hl,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dw.create("pbr-specular",[].concat(new db("Forward",hl,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dw.create("unlit",[].concat(new db("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),dw.create("blit",[new db("Forward","#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}","#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}",a)]),dw.create("skybox",[new db("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dw.create("SkyProcedural",[new db("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dw.create("particle-shader",[new db("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),dw.create("SpriteMask",[new db("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",a)]),dw.create("Sprite",[new db("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),dw.create("background-texture",[new db("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",a)])},nq),hd=((nQ=(nY=function(){this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,r=e._length,n=this._cacheHierarchyDepth;r>n&&(this._resizeCacheMapHierarchy(t,0,n,r-n),this._cacheHierarchyDepth=r);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var d=i<o?0:a[o],u=t[d];return u||(this._lastQueryKey=d,this._lastQueryMap=t),u},nQ.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},nQ._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},nQ._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var r in t)t[r].destroy();return}for(var n in++e,t)this._recursiveDestroy(e,t[n])},nQ._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var a in e){for(var i=e[a],o=e,s=0;s<n;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},nY),hu=((nZ=(nJ=function(){}).prototype)._initialize=function(e,t){},nZ._update=function(){},nZ._destroy=function(){},nZ._getRequestAnimationFrame=function(){return null},nZ._getCancelAnimationFrame=function(){return null},nZ._getCameraClearFlagsMask=function(t){return e.CameraClearFlags.None},nJ);hc.init();var hh=function(t){function r(n,a,i){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new dR,o._renderElementPool=new uc(uL),o._renderDataPool=new uc(uF),o._spriteRenderDataPool=new uc(uV),o._spriteMaskRenderDataPool=new uc(uI),o._textRenderDataPool=new uc(uO),o._spriteDefaultMaterials=[],o._renderContext=new uP,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new dh,o._settings={},o._resourceManager=new uU(ck(o)),o._sceneManager=new uk(ck(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new da,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){if(o._vSyncCount){var e,t=(null==(e=o.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;o._requestId=t(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)}else o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update()},o._hardwareRenderer=a,o._hardwareRenderer.init(n,o._onDeviceLost.bind(ck(o)),o._onDeviceRestored.bind(ck(o))),o._canvas=n,o._spriteMaskManager=new uB(ck(o));var o,s=ck(o)._spriteDefaultMaterials;o._spriteDefaultMaterial=s[e.SpriteMaskInteraction.None]=o._createSpriteMaterial(e.SpriteMaskInteraction.None),s[e.SpriteMaskInteraction.VisibleInsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleInsideMask),s[e.SpriteMaskInteraction.VisibleOutsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleOutsideMask),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=uv.createFromOS(ck(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new ho(ck(o),i.input);var l=i.xrDevice;if(l&&(o.xrManager=new hu,o.xrManager._initialize(ck(o),l)),a.canIUse(e.GLCapabilityType.depthTexture)){var c=new dQ(ck(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(r._noDepthTextureMacro);var d=new uS(ck(o),dw.find("unlit"));d.isGCIgnored=!0,d.shaderData.setColor("material_BaseColor",new cI(1,0,1.01,1)),o._meshMagentaMaterial=d;var u=new uS(ck(o),dw.find("particle-shader"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new cI(1,0,1.01,1)),o._particleMagentaMaterial=u;var h=o._settings,_=i.colorSpace||e.ColorSpace.Linear;return _===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),h.colorSpace=_,o._basicResources=new uw(ck(o)),o._particleBufferUtils=new hs(ck(o)),o}cH(r,t);var n=r.prototype;return n.createEntity=function(e){return new uo(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var r=t.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._renderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool(),null==(e=this.xrManager)||e._update();var n=this.inputManager,a=this._physicsInitialized;n._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var d=0;d<o;d++){var u=i[d];u.isActive&&!u.destroyed&&u.physics._update(r)}a&&n._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(r)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(r)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(r)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._spriteMaskManager.destroy(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,r=this._shaderProgramPools,n=r[t];if(!n){var a=t+1;a>r.length&&(r.length=a),r[t]=n=new hd,e._shaderProgramPools.push(n)}return n},n._render=function(e){for(var t=this,r=this.time.deltaTime,n=0,a=e.length;n<a;n++){var i=e[n];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(r),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(r,n){var a=e[r];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return dr.debug("No active camera in scene.");i.forEach(function(e){var r=a._componentsManager;r.callCameraOnBeginRender(e),e.render(),r.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&(dw._shaderLab=r);var a=[];n&&a.push(n.initialize().then(function(){return uJ._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=uU._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new uS(this,dw.find("Sprite")),n=r.renderState,a=n.blendState.targetBlendState;if(a.enabled=!0,a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var i=n.stencilState;i.enabled=!0,i.writeMask=0,i.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;i.compareFunctionFront=o,i.compareFunctionBack=o}return n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,n.renderQueueType=e.RenderQueueType.Transparent,r.isGCIgnored=!0,r},n._createSpriteMaskMaterial=function(){var t=new uS(this,dw.find("SpriteMask")),r=t.renderState;return r.blendState.targetBlendState.colorWriteMask=e.ColorWriteMask.None,r.rasterState.cullMode=e.CullMode.Off,r.stencilState.enabled=!0,r.depthState.enabled=!1,t.isGCIgnored=!0,t},n._onDeviceLost=function(){this._isDeviceLost=!0,this.resourceManager._lostGraphicResources(),console.log("Device lost."),this.dispatch("devicelost",this)},n._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new dR,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._renderElementPool.garbageCollection(),this._renderDataPool.garbageCollection(),this._spriteRenderDataPool.garbageCollection(),this._spriteMaskRenderDataPool.garbageCollection(),this._textRenderDataPool.garbageCollection(),this._renderContext.garbageCollection()},cU(r,[{key:"settings",get:function(){return this._settings}},{key:"canvas",get:function(){return this._canvas}},{key:"resourceManager",get:function(){return this._resourceManager}},{key:"sceneManager",get:function(){return this._sceneManager}},{key:"time",get:function(){return this._time}},{key:"isPaused",get:function(){return this._isPaused}},{key:"vSyncCount",get:function(){return this._vSyncCount},set:function(e){this._vSyncCount=Math.max(0,Math.floor(e))}},{key:"targetFrameRate",get:function(){return this._targetFrameRate},set:function(e){e=Math.max(1e-6,e),this._targetFrameRate=e,this._targetFrameInterval=1e3/e}},{key:"destroyed",get:function(){return this._destroyed}},{key:"physicsManager",get:function(){var e;return null==(e=this.sceneManager.scenes[0])?void 0:e.physics}}]),r}(c5);hh._gammaMacro=du.getByName("ENGINE_IS_COLORSPACE_GAMMA"),hh._noDepthTextureMacro=du.getByName("ENGINE_NO_DEPTH_TEXTURE"),hh._pixelsPerUnit=100;var h_=(cU(n$=function(){this._sizeUpdateFlagManager=new c4},[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._onWidthChanged(e),this._sizeUpdateFlagManager.dispatch())}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._onHeightChange(e),this._sizeUpdateFlagManager.dispatch())}}]),n$);e.BackgroundMode=void 0,(n0=e.BackgroundMode||(e.BackgroundMode={}))[n0.SolidColor=0]="SolidColor",n0[n0.Sky=1]="Sky",n0[n0.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(n1=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[n1.AspectFitWidth=0]="AspectFitWidth",n1[n1.AspectFitHeight=1]="AspectFitHeight",n1[n1.Fill=2]="Fill";var hf=((n3=(n2=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},n3._render=function(e){var t=this.material,r=this.mesh;if(!t){dr.warn("The material of sky is not defined.");return}if(t.destroyed){dr.warn("The material of sky is destroyed.");return}if(!r){dr.warn("The mesh of sky is not defined.");return}if(r.destroyed){dr.warn("The mesh of sky is destroyed.");return}var n=e.camera,a=n.engine,i=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,d=i.shaderData,u=n2._viewProjMatrix,h=n2._projectionMatrix,_=a._hardwareRenderer,f=t.shaderData,p=t.shader,m=t.renderState;u.copyFrom(l);var g=u.elements;g[12]=g[13]=g[14]=0;var v=1/Math.tan(cS.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,cF.multiply(h,u,u);var y=c.getMatrix(uP.vpMatrixProperty);e.flipProjection&&cF.multiply(uP._flipYMatrix,u,u),c.setMatrix(uP.vpMatrixProperty,u);var x=dw._compileMacros;dh.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var b=p.subShaders[0].passes[0],S=b._getShaderProgram(a,x);S.bind(),S.groupingOtherUniformBlock(),S.uploadAll(S.sceneUniformBlock,d),S.uploadAll(S.cameraUniformBlock,c),S.uploadAll(S.materialUniformBlock,f),S.uploadUnGroupTextures(),m._apply(a,!1,b._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,S),c.setMatrix(uP.vpMatrixProperty,y)},cU(n2,[{key:"material",get:function(){return this._material},set:function(e){if(this._material!==e){var t;null==e||e._addReferCount(1),null==(t=this._material)||t._addReferCount(-1),this._material=e}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==e||e._addReferCount(1),null==(t=this._mesh)||t._addReferCount(-1),this._mesh=e}}}]),n2);hf._epsilon=1e-6,hf._viewProjMatrix=new cF,hf._projectionMatrix=new cF(1,0,0,0,0,1,0,0,0,0,hf._epsilon-1,-1,0,0,0,0);var hp=((n8=(n4=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new cI(.25,.25,.25,1),this.sky=new hf,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._initMesh(t),this._initMaterial(t)}).prototype).destroy=function(){this.texture=null,this._mesh._addReferCount(-1),this._mesh=null,this._material._addReferCount(-1),this._material=null,this.solidColor=null,this.sky.destroy()},n8._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,a=n.width,i=n.height,o=r.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.Fill:o[0].set(-1,-1,1),o[1].set(1,-1,1),o[2].set(-1,1,1),o[3].set(1,1,1);break;case e.BackgroundTextureFillMode.AspectFitWidth:var s=t.height*a/t.width/i;o[0].set(-1,-s,1),o[1].set(1,-s,1),o[2].set(-1,s,1),o[3].set(1,s,1);break;case e.BackgroundTextureFillMode.AspectFitHeight:var l=t.width*i/t.height/a;o[0].set(-l,-1,1),o[1].set(l,-1,1),o[2].set(-l,1,1),o[3].set(l,1,1)}r.setPositions(o),r.uploadData(!1)}},n8._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},n8._initMaterial=function(t){var r=this._material=new uS(t,dw.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},n8._createPlane=function(e){for(var t=new d0(e),r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],a=[,,,,],i=0;i<4;++i)n[i]=new cC,a[i]=new cD(i%2,1-(.5*i|0));return t.setPositions(n),t.setUVs(a),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},cU(n4,[{key:"texture",get:function(){return this._texture},set:function(e){if(this._texture!==e){var t;null==e||e._addReferCount(1),null==(t=this._texture)||t._addReferCount(-1),this._texture=e,this._material.shaderData.setTexture("material_BaseTexture",e),this._resizeBackgroundTexture()}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),n4),hm=((n9=(n5=function(){this._cameraNeedSorting=!1,this._activeCameras=new dV,this._renderers=new dV,this._onStartScripts=new dV,this._onUpdateScripts=new dV,this._onLateUpdateScripts=new dV,this._onPhysicsUpdateScripts=new dV,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new dV,this._onUpdateRenderers=new dV,this._componentsContainerPool=[]}).prototype).addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},n9.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},n9.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,r=e.length;t<r;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},n9.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},n9.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},n9.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},n9.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},n9.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},n9.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},n9.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},n9.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},n9.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},n9.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},n9.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},n9.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n9.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},n9.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},n9.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},n9.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},n9.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},n9.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.engine.time.frameCount>t._playFrameCount&&t.update(e)},function(e,t){e._onUpdateIndex=t})},n9.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},n9.handlingInvalidScripts=function(){var e=this._disposeDestroyScripts,t=this._pendingDestroyScripts;this._disposeDestroyScripts=t,this._pendingDestroyScripts=e;var r=t.length;if(r>0){for(var n=r-1;n>=0;n--)t[n].onDestroy();t.length=0}},n9.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},n9.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},n9.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},n9.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},n9._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},n5);e.FogMode=void 0,(n6=e.FogMode||(e.FogMode={}))[n6.None=0]="None",n6[n6.Linear=1]="Linear",n6[n6.Exponential=2]="Exponential",n6[n6.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n7=e.DiffuseMode||(e.DiffuseMode={}))[n7.SolidColor=0]="SolidColor",n7[n7.SphericalHarmonics=1]="SphericalHarmonics";var hg=(cH(ae=function(t){var r;return(r=cZ.call(this,t)||this)._diffuseSolidColor=new cI(.212,.227,.259),r._diffuseIntensity=1,r._specularIntensity=1,r._diffuseMode=e.DiffuseMode.SolidColor,r._shArray=new Float32Array(27),r._scenes=[],r._specularTextureDecodeRGBM=!1,r},cZ),(at=ae.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(ae._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(ae._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(ae._specularIntensityProperty,this._specularIntensity),t.setFloatArray(ae._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},at._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(ae._specularTextureProperty,null),n.disableMacro(ae._specularMacro)},at._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(ae._shMacro):t.disableMacro(ae._shMacro)},at._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(ae._specularTextureProperty,this._specularTexture),e.setFloat(ae._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(ae._specularMacro)):e.disableMacro(ae._specularMacro)},at._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(ae._decodeRGBMMacro):e.disableMacro(ae._decodeRGBMMacro)},at._preComputeSH=function(e,t){var r=e.coefficients;t[0]=.886227*r[0],t[1]=.886227*r[1],t[2]=.886227*r[2],t[3]=-1.023327*r[3],t[4]=-1.023327*r[4],t[5]=-1.023327*r[5],t[6]=1.023327*r[6],t[7]=1.023327*r[7],t[8]=1.023327*r[8],t[9]=-1.023327*r[9],t[10]=-1.023327*r[10],t[11]=-1.023327*r[11],t[12]=.858086*r[12],t[13]=.858086*r[13],t[14]=.858086*r[14],t[15]=-.858086*r[15],t[16]=-.858086*r[16],t[17]=-.858086*r[17],t[18]=.247708*r[18],t[19]=.247708*r[19],t[20]=.247708*r[20],t[21]=-.858086*r[21],t[22]=-.858086*r[22],t[23]=-.858086*r[23],t[24]=.429042*r[24],t[25]=.429042*r[25],t[26]=.429042*r[26]},cU(ae,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTextureDecodeRGBM(t[r].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setDiffuseMode(t[r].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloatArray(ae._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloat(ae._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTexture(t[r].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var t=0,r=this._scenes.length;t<r;t++)this._scenes[t].shaderData.setFloat(ae._specularIntensityProperty,e)}}]),ae);hg._shMacro=du.getByName("SCENE_USE_SH"),hg._specularMacro=du.getByName("SCENE_USE_SPECULAR_ENV"),hg._decodeRGBMMacro=du.getByName("SCENE_IS_DECODE_ENV_RGBM"),hg._diffuseColorProperty=dn.getByName("scene_EnvMapLight.diffuse"),hg._diffuseSHProperty=dn.getByName("scene_EnvSH"),hg._diffuseIntensityProperty=dn.getByName("scene_EnvMapLight.diffuseIntensity"),hg._specularTextureProperty=dn.getByName("scene_EnvSpecularSampler"),hg._specularIntensityProperty=dn.getByName("scene_EnvMapLight.specularIntensity"),hg._mipLevelProperty=dn.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(ar=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[ar.NoCascades=1]="NoCascades",ar[ar.TwoCascades=2]="TwoCascades",ar[ar.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(an=e.ShadowResolution||(e.ShadowResolution={}))[an.Low=0]="Low",an[an.Medium=1]="Medium",an[an.High=2]="High",an[an.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(aa=e.ShadowType||(e.ShadowType={}))[aa.None=0]="None",aa[aa.Hard=1]="Hard",aa[aa.SoftLow=2]="SoftLow",aa[aa.SoftHigh=3]="SoftHigh";var hv=(cH(ai=function(){var t;return t=di.apply(this,arguments)||this,t.intensity=1,t.cullingMask=e.Layer.Everything,t.shadowType=e.ShadowType.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t.shadowStrength=1,t._lightIndex=-1,t._lightColor=new cI,t._color=new cI(1,1,1,1),t},di),ai.prototype._getLightIntensityColor=function(){return this._lightColor.r=this.color.r*this.intensity,this._lightColor.g=this.color.g*this.intensity,this._lightColor.b=this.color.b*this.intensity,this._lightColor.a=this.color.a*this.intensity,this._lightColor},cU(ai,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"viewMatrix",get:function(){return this._viewMat||(this._viewMat=new cF),cF.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new cF),cF.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),ai);cW([cj],hv.prototype,"_lightIndex",void 0);var hy=(cH(ao=function(){var e;return e=hv.apply(this,arguments)||this,e._reverseDirection=new cC,e},hv),(as=ao.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.direction,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cI.gammaToLinearSpace(o.r),r.color[a+1]=cI.gammaToLinearSpace(o.g),r.color[a+2]=cI.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.direction[i]=s.x,r.direction[i+1]=s.y,r.direction[i+2]=s.z},as._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},as._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},ao._updateShaderData=function(e,t){e.setIntArray(ao._cullingMaskProperty,t.cullingMask),e.setFloatArray(ao._colorProperty,t.color),e.setFloatArray(ao._directionProperty,t.direction)},cU(ao,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cC.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),ao);hy._cullingMaskProperty=dn.getByName("scene_DirectLightCullingMask"),hy._colorProperty=dn.getByName("scene_DirectLightColor"),hy._directionProperty=dn.getByName("scene_DirectLightDirection");var hx=(cH(al=function(){var e;return e=hv.apply(this,arguments)||this,e.distance=100,e},hv),(ac=al.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cI.gammaToLinearSpace(o.r),r.color[a+1]=cI.gammaToLinearSpace(o.g),r.color[a+2]=cI.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.position[i]=s.x,r.position[i+1]=s.y,r.position[i+2]=s.z,r.distance[t]=this.distance},ac._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},ac._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},al._updateShaderData=function(e,t){e.setIntArray(al._cullingMaskProperty,t.cullingMask),e.setFloatArray(al._colorProperty,t.color),e.setFloatArray(al._positionProperty,t.position),e.setFloatArray(al._distanceProperty,t.distance)},cU(al,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),al);hx._cullingMaskProperty=dn.getByName("scene_PointLightCullingMask"),hx._colorProperty=dn.getByName("scene_PointLightColor"),hx._positionProperty=dn.getByName("scene_PointLightPosition"),hx._distanceProperty=dn.getByName("scene_PointLightDistance");var hb=(cH(ad=function(){var e;return e=hv.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new cC,e._projectMatrix=new cF,e},hv),(au=ad.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,d=this.cullingMask;r.cullingMask[n]=65535&d,r.cullingMask[n+1]=d>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=cI.gammaToLinearSpace(s.r),r.color[a+1]=cI.gammaToLinearSpace(s.g),r.color[a+2]=cI.gammaToLinearSpace(s.b)):(r.color[a]=s.r,r.color[a+1]=s.g,r.color[a+2]=s.b),r.position[i]=l.x,r.position[i+1]=l.y,r.position[i+2]=l.z,r.direction[o]=c.x,r.direction[o+1]=c.y,r.direction[o+2]=c.z,r.distance[t]=this.distance,r.angleCos[t]=Math.cos(this.angle),r.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},au._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},au._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},ad._updateShaderData=function(e,t){e.setIntArray(ad._cullingMaskProperty,t.cullingMask),e.setFloatArray(ad._colorProperty,t.color),e.setFloatArray(ad._positionProperty,t.position),e.setFloatArray(ad._directionProperty,t.direction),e.setFloatArray(ad._distanceProperty,t.distance),e.setFloatArray(ad._angleCosProperty,t.angleCos),e.setFloatArray(ad._penumbraCosProperty,t.penumbraCos)},cU(ad,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cC.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}},{key:"_shadowProjectionMatrix",get:function(){var e=this._projectMatrix,t=Math.min(Math.PI/2,2*this.angle*Math.sqrt(2));return cF.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),ad);hb._cullingMaskProperty=dn.getByName("scene_SpotLightCullingMask"),hb._colorProperty=dn.getByName("scene_SpotLightColor"),hb._positionProperty=dn.getByName("scene_SpotLightPosition"),hb._directionProperty=dn.getByName("scene_SpotLightDirection"),hb._distanceProperty=dn.getByName("scene_SpotLightDistance"),hb._angleCosProperty=dn.getByName("scene_SpotLightAngleCos"),hb._penumbraCosProperty=dn.getByName("scene_SpotLightPenumbraCos");var hS=function(){function t(){this._spotLights=new dV,this._pointLights=new dV,this._directLights=new dV,this._directData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight)},this._pointData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight)},this._spotData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight),angleCos:new Float32Array(t._maxLight),penumbraCos:new Float32Array(t._maxLight)}}var r=t.prototype;return r._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},r._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},r._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},r._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._updateShaderData=function(e){for(var r=this._spotLights,n=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=t._maxLight,c=Math.min(r.length,l),d=Math.min(n.length,l),u=Math.min(a.length,l),h=0;h<c;h++)r.get(h)._appendData(h,i);for(var _=0;_<d;_++)n.get(_)._appendData(_,o);for(var f=0;f<u;f++)a.get(f)._appendData(f,s);u?(hy._updateShaderData(e,s),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",u.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),d?(hx._updateShaderData(e,o),e.enableMacro("SCENE_POINT_LIGHT_COUNT",d.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(hb._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._updateSunlightIndex=function(e){var t=this._directLights,r=e._lightIndex;if(r>0){var n=t.get(0),a=t.get(r);t.set(0,a),t.set(r,n),a._lightIndex=0,n._lightIndex=r}},r._getMaxBrightestSunlight=function(){for(var t=this._directLights,r=null,n=Number.NEGATIVE_INFINITY,a=!1,i=0,o=t.length;i<o;i++){var s=t.get(i);s.shadowType===e.ShadowType.None||a||(n=Number.NEGATIVE_INFINITY,a=!0);var l=s.intensity*s.color.getBrightness();a?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=s):n<l&&(n=l,r=s)}return r},t}();hS._sunlightColorProperty=dn.getByName("scene_SunlightColor"),hS._sunlightDirectionProperty=dn.getByName("scene_SunlightDirection"),hS._maxLight=10;var hC=function(t){function r(n,a){(i=t.call(this,n)||this).physics=new uJ(ck(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new cC(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i._lightManager=new hS,i._componentsManager=new hm,i._isActiveInEngine=!1,i._globalShaderMacro=new dh,i._rootEntities=[],i._background=new hp(i._engine),i._shaderData=new dL(lW.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new cI(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new cB,i._isActive=!0,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new hg(n),n.sceneManager._allCreatedScenes.push(ck(i)),o.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),o.setColor(r._fogColorProperty,i._fogColor),o.setVector4(r._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}cH(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new uo(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?r=e:(r=void 0,t=e);var r,n=t._isRoot;n||(t._isRoot=!0,t._removeFromParent());var a=t._scene;a!==this?(a&&n&&a._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var i=lG.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=lG.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=lG.Scene),i&&t._processInActive(i),a!==this&&uo._traverseSetOwnerScene(t,this);var o=lG.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=lG.Hierarchy)),t._isActiveInScene&&a===this||(o|=lG.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=lG.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=lG.Hierarchy),e._isActiveInScene&&(t|=lG.Scene),t&&e._processInActive(t),uo._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var a=this.getRootEntity(r);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=uo._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,r=t.length-1;r>=0;r--){var n=t[r];n._isActive&&(e?n._processActive(lG.Hierarchy):n._processInActive(lG.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,r=this._engine,n=this._lightManager;r.time._updateSceneShaderData(t),n._updateShaderData(this.shaderData);var a=this._lightManager._sunlight=this._getSunlight();a?(n._updateSunlightIndex(a),t.setColor(hS._sunlightColorProperty,a._lightColor),t.setVector3(hS._sunlightDirectionProperty,a.direction)):t.setVector3(hS._sunlightDirectionProperty,cC._zero),this.castShadows&&a&&a.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",a.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),dh.unionCollection(this.engine._macroCollection,t._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,r=e._siblingIndex;t.splice(r,1);for(var n=t.length;r<n;r++)t[r]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._engine.sceneManager;for(e.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},n._addToRootEntityList=function(e,t){var r=this._rootEntities,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var r=t-e,n=this._fogParams;n.x=-1/r,n.y=t/r},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},cU(r,[{key:"isActive",get:function(){return this._isActive},set:function(e){this._isActive!==e&&(this._isActive=e,e?this._sceneManager&&this._processActive(!0):this._sceneManager&&this._processActive(!1))}},{key:"shaderData",get:function(){return this._shaderData}},{key:"background",get:function(){return this._background}},{key:"shadowCascades",get:function(){return this._shadowCascades},set:function(e){this._shadowCascades!==e&&(this.shaderData.enableMacro("SCENE_SHADOW_CASCADED_COUNT",e.toString()),this._shadowCascades=e)}},{key:"ambientLight",get:function(){return this._ambientLight},set:function(e){if(!e){dr.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}}]),r}(cJ);hC._fogColorProperty=dn.getByName("scene_FogColor"),hC._fogParamsProperty=dn.getByName("scene_FogParams");var hT=(cH(ah=function(){var e;return e=di.apply(this,arguments)||this,e._started=!1,e._onStartIndex=-1,e._onUpdateIndex=-1,e._onLateUpdateIndex=-1,e._onPhysicsUpdateIndex=-1,e._onPreRenderIndex=-1,e._onPostRenderIndex=-1,e._entityScriptsIndex=-1,e},di),(a_=ah.prototype).onAwake=function(){},a_.onEnable=function(){},a_.onStart=function(){},a_.onUpdate=function(e){},a_.onLateUpdate=function(e){},a_.onBeginRender=function(e){},a_.onEndRender=function(e){},a_.onPhysicsUpdate=function(){},a_.onTriggerEnter=function(e){},a_.onTriggerExit=function(e){},a_.onTriggerStay=function(e){},a_.onCollisionEnter=function(e){},a_.onCollisionExit=function(e){},a_.onCollisionStay=function(e){},a_.onPointerDown=function(e){},a_.onPointerUp=function(e){},a_.onPointerClick=function(e){},a_.onPointerEnter=function(e){},a_.onPointerExit=function(e){},a_.onPointerDrag=function(e){},a_.onDisable=function(){},a_.onDestroy=function(){},a_._onAwake=function(){this.onAwake()},a_._onEnable=function(){this.onEnable()},a_._onDisable=function(){this.onDisable()},a_._onEnableInScene=function(){var e=this.scene._componentsManager,t=ah.prototype;this._started||e.addOnStartScript(this),this.onUpdate!==t.onUpdate&&e.addOnUpdateScript(this),this.onLateUpdate!==t.onLateUpdate&&e.addOnLateUpdateScript(this),this.onPhysicsUpdate!==t.onPhysicsUpdate&&e.addOnPhysicsUpdateScript(this),this._entity._addScript(this)},a_._onDisableInScene=function(){var e=this.scene._componentsManager,t=ah.prototype;this._started||e.removeOnStartScript(this),this.onUpdate!==t.onUpdate&&e.removeOnUpdateScript(this),this.onLateUpdate!==t.onLateUpdate&&e.removeOnLateUpdateScript(this),this.onPhysicsUpdate!==t.onPhysicsUpdate&&e.removeOnPhysicsUpdateScript(this),this._entity._removeScript(this)},a_._onDestroy=function(){di.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},ah);cW([cj],hT.prototype,"_started",void 0),cW([cj],hT.prototype,"_onStartIndex",void 0),cW([cj],hT.prototype,"_onUpdateIndex",void 0),cW([cj],hT.prototype,"_onLateUpdateIndex",void 0),cW([cj],hT.prototype,"_onPhysicsUpdateIndex",void 0),cW([cj],hT.prototype,"_onPreRenderIndex",void 0),cW([cj],hT.prototype,"_onPostRenderIndex",void 0),cW([cj],hT.prototype,"_entityScriptsIndex",void 0),e.DepthTextureMode=void 0,(af=e.DepthTextureMode||(e.DepthTextureMode={}))[af.None=0]="None",af[af.PrePass=1]="PrePass",e.ReplacementFailureStrategy=void 0,(ap=e.ReplacementFailureStrategy||(e.ReplacementFailureStrategy={}))[ap.KeepOriginalShader=0]="KeepOriginalShader",ap[ap.DoNotRender=1]="DoNotRender";var hA=function(e){this._engine=e},hM=((am=function(){}).recreateTextureIfNeeded=function(e,t,r,n,a,i){if(t){if(t.width===r&&t.height===n&&t.format===a&&t.mipmapCount>1===i)return t;t.destroy(!0);var o=new dQ(e,r,n,a,i);return o.isGCIgnored=!0,o}var s=new dQ(e,r,n,a,i);return s.isGCIgnored=!0,s},am.recreateRenderTargetIfNeeded=function(e,t,r,n,a,i,o,s,l){var c,d,u=null==(_=t)?void 0:_.getColorTexture(0),h=a?am.recreateTextureIfNeeded(e,u,r,n,a,s):null;if(o){var _,f,p,m=null==(f=t)?void 0:f.depthTexture,g=i?am.recreateTextureIfNeeded(e,m,r,n,i,s):null;(u!==h||m!==g)&&(null==(p=t)||p.destroy(!0),(t=new dY(e,r,n,h,g,l)).isGCIgnored=!0)}else(u!==h||(null==(c=t)?void 0:c._depthFormat)!==i)&&(null==(d=t)||d.destroy(!0),(t=new dY(e,r,n,h,i,l)).isGCIgnored=!0);return t},am.blitTexture=function(e,t,r,n,a){void 0===n&&(n=0);var i=e._basicResources,o=r?i.flipYBlitMesh:i.blitMesh,s=i.blitMaterial,l=e._hardwareRenderer,c=e._renderContext;c.flipProjection=!!r,l.activeRenderTarget(r,null!=a?a:am.defaultViewport,c.flipProjection,0);var d=am._rendererShaderData,u=s.shader.subShaders[0].passes[0],h=u._getShaderProgram(e,dw._compileMacros);d.setTexture(am._blitTextureProperty,t),d.setFloat(am._blitMipLevelProperty,n),h.bind(),h.groupingOtherUniformBlock(),h.uploadAll(h.rendererUniformBlock,d),h.uploadAll(h.materialUniformBlock,s.shaderData),h.uploadUnGroupTextures(),(u._renderState||s.renderState)._apply(e,!1,u._renderStateDataMap,s.shaderData),l.drawPrimitive(o._primitive,o.subMesh,h)},am);hM._blitTextureProperty=dn.getByName("renderer_BlitTexture"),hM._blitMipLevelProperty=dn.getByName("renderer_BlitMipLevel"),hM._rendererShaderData=new dL(lW.Renderer),hM.defaultViewport=new cB(0,0,1,1);var hE=(cH(ag=function(){return ud.apply(this,arguments)},ud),(av=ag.prototype).createVertexElements=function(t){return t[0]=new dW("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new dW("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new dW("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},av.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPasses[0].getTagValue(ud._disableBatchTag))return!1;var r=e.data,n=t.data,a=r.component,i=n.component;return!!this.checkBatchWithMask(a,i)&&r.texture===n.texture&&r.material===n.material},av.checkBatchWithMask=function(t,r){var n=t.maskInteraction;return n===r.maskInteraction&&(n===e.SpriteMaskInteraction.None||t.maskLayer===r.maskLayer)},av.updateVertices=function(e,t,r){for(var n=e.verticesData,a=n.positions,i=n.uvs,o=n.color,s=n.vertexCount,l=0;l<s;l++){var c=a[l],d=i[l];t[r++]=c.x,t[r++]=c.y,t[r++]=c.z,t[r++]=d.x,t[r++]=d.y,t[r++]=o.r,t[r++]=o.g,t[r++]=o.b,t[r++]=o.a}return r},av.drawBatches=function(e){for(var t=this._engine,r=this._batchedQueue,n=this._meshes[this._flushId],a=n.subMeshes,i=n._primitive,o=t._spriteMaskManager,s=e.scene.shaderData,l=e.shaderData,c=0,d=a.length;c<d;c++){var u=a[c],h=r[c],_=h.data;if(!u||!h)return;var f=_.component,p=_.material;o.preRender(e,f);var m=dw._compileMacros;dh.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=h.shaderPasses[0],v=g._getShaderProgram(t,m);if(!v.isValid)return;f.shaderData.setTexture(ag._textureProperty,_.texture),v.bind(),v.groupingOtherUniformBlock(),v.uploadAll(v.sceneUniformBlock,s),v.uploadAll(v.cameraUniformBlock,l),v.uploadAll(v.rendererUniformBlock,f.shaderData),v.uploadAll(v.materialUniformBlock,p.shaderData),(g._renderState||p.renderState)._apply(t,!1,g._renderStateDataMap,p.shaderData),t._hardwareRenderer.drawPrimitive(i,u,v),o.postRender(f)}},ag);hE._textureProperty=dn.getByName("renderer_SpriteTexture");var hR=((ax=(ay=function(e,t){this.elements=[],this._initSpriteBatcher(e),this._renderQueueType=t}).prototype).pushRenderElement=function(e){this.elements.push(e)},ax.render=function(e,t){var r=this.elements;if(0!==r.length){for(var n=e.engine,a=e.instanceId,i=e.shaderData,o=e.scene,s=o.shaderData,l=o.instanceId,c=n._renderCount,d=n._hardwareRenderer,u=uP.pipelineStageKey,h=this._renderQueueType,_=0,f=r.length;_<f;_++){var p=r[_],m=p.data,g=p.shaderPasses;if(m.primitive){this._spriteBatcher.flush(e);var v=dw._compileMacros,y=m.primitive,x=m.component,b=m.material,S=x.shaderData,C=x.instanceId,T=b.shaderData,A=b.instanceId,M=b.renderStates;dh.unionCollection(x._globalShaderMacro,T._macroCollection,v);for(var E=0,R=g.length;E<R;E++){var w,P,F=g[E];if(F.getTagValue(u)===t&&(null!=(w=F._renderState)?w:M[E]).renderQueueType===h){var L=F._getShaderProgram(n,v);if(L.isValid){var D=L.bind();c!==L._uploadRenderCount?(L.groupingOtherUniformBlock(),L.uploadAll(L.sceneUniformBlock,s),L.uploadAll(L.cameraUniformBlock,i),L.uploadAll(L.rendererUniformBlock,S),L.uploadAll(L.materialUniformBlock,T),L.uploadUnGroupTextures(),L._uploadSceneId=l,L._uploadCameraId=a,L._uploadRendererId=C,L._uploadMaterialId=A,L._uploadRenderCount=c):(L._uploadSceneId!==l?(L.uploadAll(L.sceneUniformBlock,s),L._uploadSceneId=l):D&&L.uploadTextures(L.sceneUniformBlock,s),L._uploadCameraId!==a?(L.uploadAll(L.cameraUniformBlock,i),L._uploadCameraId=a):D&&L.uploadTextures(L.cameraUniformBlock,i),L._uploadRendererId!==C?(L.uploadAll(L.rendererUniformBlock,S),L._uploadRendererId=C):D&&L.uploadTextures(L.rendererUniformBlock,S),L._uploadMaterialId!==A?(L.uploadAll(L.materialUniformBlock,T),L._uploadMaterialId=A):D&&L.uploadTextures(L.materialUniformBlock,T),D&&L.uploadUnGroupTextures()),(null!=(P=F._renderState)?P:M[E])._apply(n,x.entity.transform._isFrontFaceInvert(),F._renderStateDataMap,b.shaderData),d.drawPrimitive(y,m.subPrimitive,L)}}}}else this._spriteBatcher.drawElement(p,e)}this._spriteBatcher.flush(e)}},ax.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},ax.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},ax.sort=function(e){c0._quickSort(this.elements,0,this.elements.length,e)},ax._initSpriteBatcher=function(e){this._spriteBatcher=new hE(e)},ay._compareFromNearToFar=function(e,t){var r=e.data,n=t.data,a=r.component,i=n.component,o=a.priority-i.priority;if(0!==o)return o;if(a.instanceId===i.instanceId)return r.material._priority-n.material._priority;var s=a._distanceForSort-i._distanceForSort;return 0===s?a.instanceId-i.instanceId:s},ay._compareFromFarToNear=function(e,t){var r=e.data,n=t.data,a=r.component,i=n.component,o=a.priority-i.priority;if(0!==o)return o;if(a.instanceId===i.instanceId)return r.material._priority-n.material._priority;var s=i._distanceForSort-a._distanceForSort;return 0===s?a.instanceId-i.instanceId:s},ay),hw=function(){this.position=new cC,this.isOrthographic=!1,this.viewMatrix=new cF,this.projectionMatrix=new cF,this.viewProjectionMatrix=new cF,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new cC},hP=function(){this.virtualCamera=new hw,this.cullPlanes=[new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC),new cE(new cC)],this.splitBoundSphere=new cT(new cC,0)};(ab=l6||(l6={}))[ab.FarBottomLeft=0]="FarBottomLeft",ab[ab.FarTopLeft=1]="FarTopLeft",ab[ab.FarTopRight=2]="FarTopRight",ab[ab.FarBottomRight=3]="FarBottomRight",ab[ab.nearBottomLeft=4]="nearBottomLeft",ab[ab.nearTopLeft=5]="nearTopLeft",ab[ab.nearTopRight=6]="nearTopRight",ab[ab.nearBottomRight=7]="nearBottomRight",ab[ab.unknown=8]="unknown";var hF=((aS=function(){}).shadowResolution=function(t){switch(t){case e.ShadowResolution.Low:return 512;case e.ShadowResolution.Medium:return 1024;case e.ShadowResolution.High:return 2048;case e.ShadowResolution.VeryHigh:return 4096}},aS.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},aS.cullingRenderBounds=function(e,t,r){for(var n=e.min,a=e.max,i=0;i<t;i++){var o=r[i],s=o.normal;if(s.x*(s.x>=0?a.x:n.x)+s.y*(s.y>=0?a.y:n.y)+s.z*(s.z>=0?a.z:n.z)<-o.distance)return!1}return!0},aS.shadowCullFrustum=function(e,t,r,n){var a=r._entity.layer;e.camera.cullingMask&a&&t.cullingMask&a&&r.castShadows&&aS.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._renderFrameCount=r.engine.time.frameCount,r._prepareRender(e))},aS.getBoundSphereByFrustum=function(e,t,r,n,a){var i,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(cS.degreeToRadian(l)/2),d=c*c,u=t-e,h=t+e;d>u/h?(i=t,o=t*c):(i=.5*h*(1+d),o=.5*Math.sqrt(u*u+2*(t*t+e*e)*d+h*h*d*d));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,cC.scale(n,i,_),cC.add(r.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},aS.getDirectionLightShadowCullPlanes=function(t,r,n,a,i){var o=aS._frustumCorners,s=aS._backPlaneFaces,l=aS._frustumPlaneNeighbors,c=aS._frustumTwoPlaneCorners,d=aS._edgePlanePoint2,u=i.cullPlanes,h=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),m=t.getPlane(e.FrustumFace.Bottom),g=t.getPlane(e.FrustumFace.Top),v=aS._adjustNearPlane,y=aS._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),cM.intersectionPointThreePlanes(v,m,p,o[7]),cM.intersectionPointThreePlanes(v,g,p,o[6]),cM.intersectionPointThreePlanes(v,g,f,o[5]),cM.intersectionPointThreePlanes(v,m,f,o[4]),cM.intersectionPointThreePlanes(y,m,p,o[3]),cM.intersectionPointThreePlanes(y,g,p,o[2]),cM.intersectionPointThreePlanes(y,g,f,o[1]),cM.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var S=void 0;switch(b){case e.FrustumFace.Near:S=v;break;case e.FrustumFace.Far:S=y;break;default:S=t.getPlane(b)}0>cC.dot(S.normal,a)&&(u[x].copyFrom(S),s[x]=b,x++)}for(var C=x,T=0;T<x;T++)for(var A=s[T],M=l[A],E=0;E<4;E++){for(var R=M[E],w=!0,P=0;P<x;P++)if(R==s[P]){w=!1;break}if(w){var F=c[A][R],L=o[F[0]],D=o[F[1]];cC.add(L,a,d),cE.fromPoints(L,D,d,u[C++])}}i.cullPlaneCount=C},aS.getDirectionalLightMatrices=function(e,t,r,n,a,i,o,s){var l=o.splitBoundSphere;o.resolution=i;var c=l.center,d=l.radius,u=i/2,h=d*u/(u-aS.atlasBorderSize),_=2*h,f=i/_,p=_/i,m=Math.ceil(cC.dot(c,e)*f)*p,g=Math.ceil(cC.dot(c,t)*f)*p,v=cC.dot(c,r);c.x=e.x*m+t.x*g+r.x*v,c.y=e.y*m+t.y*g+r.y*v,c.z=e.z*m+t.z*g+r.z*v;var y=o.virtualCamera,x=y.position,b=y.viewMatrix,S=y.projectionMatrix;cC.scale(r,d+a,x),cC.subtract(c,x,x),cF.lookAt(x,c,e,b),cF.ortho(-h,h,-h,h,0,2*d+a,S);var C=y.viewProjectionMatrix;cF.multiply(S,b,C),c0._floatMatrixMultiply(aS._shadowMapCoordMatrix,C.elements,0,s,16*n)},aS.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),a=Math.floor(e/n)*Math.floor(t/n);a<r;)a=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},aS.getShadowBias=function(t,r,n,a){var i=2/r.elements[0]/n,o=-t.shadowBias*i,s=-t.shadowNormalBias*i;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),a.set(o,s)},aS.applySliceTransform=function(e,t,r,n,a,i){var o=aS._tempMatrix0,s=o.elements,l=1/t,c=1/r,d=a.x*l,u=a.y*c;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=d,s[13]=u,s[14]=0,s[15]=1;var h=16*n;c0._floatMatrixMultiply(o,i,h,i,h)},aS.getScaleAndBiasForLinearDistanceFade=function(e,t,r){if(t<1e-4){r.z=1e3,r.w=-(1e3*e);return}t=1-t;var n=(t*=t)*e,a=e-n;r.z=1/a,r.w=-n/a},aS);hF._tempMatrix0=new cF,hF._shadowMapCoordMatrix=new cF(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),hF._frustumCorners=[new cC,new cC,new cC,new cC,new cC,new cC,new cC,new cC],hF._adjustNearPlane=new cE(new cC),hF._adjustFarPlane=new cE(new cC),hF._backPlaneFaces=[,,,,,],hF._edgePlanePoint2=new cC,hF._frustumPlaneNeighbors=[[e.FrustumFace.Left,e.FrustumFace.Right,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Left,e.FrustumFace.Right,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Top,e.FrustumFace.Bottom],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Left,e.FrustumFace.Right],[e.FrustumFace.Near,e.FrustumFace.Far,e.FrustumFace.Left,e.FrustumFace.Right]],hF._frustumTwoPlaneCorners=[[[8,8],[8,8],[4,5],[6,7],[7,4],[5,6]],[[8,8],[8,8],[1,0],[3,2],[0,3],[2,1]],[[5,4],[0,1],[8,8],[8,8],[4,0],[1,5]],[[7,6],[2,3],[8,8],[8,8],[3,7],[6,2]],[[4,7],[3,0],[0,4],[7,3],[8,8],[8,8]],[[6,5],[1,2],[5,1],[2,6],[8,8],[8,8]]],hF.atlasBorderSize=4;var hL=function(t){function r(n){var a;return(a=t.call(this,n.engine)||this)._shadowMapSize=new cB,a._shadowBias=new cD,a._shadowSliceData=new hP,a._lightUp=new cC,a._lightSide=new cC,a._splitBoundSpheres=new Float32Array(4*r._maxCascades),a._shadowMatrices=new Float32Array((r._maxCascades+1)*16),a._shadowInfos=new cB,a._viewportOffsets=[new cD,new cD,new cD,new cD],a._camera=n,a._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}cH(r,t);var n=r.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(t,n){var a,i,o=this._engine,s=this._camera,l=this._viewportOffsets,c=this._shadowSliceData,d=this._splitBoundSpheres,u=this._shadowMatrices,h=s._renderPipeline._cullingResults,_=h.opaqueQueue,f=h.alphaTestQueue,p=h.transparentQueue,m=s.scene,g=m._componentsManager,v=o._hardwareRenderer,y=m.shadowCascades,x=r._cascadesSplitDistance,b=c.splitBoundSphere,S=r._tempMatrix0,C=S.elements,T=this._lightUp,A=this._lightSide,M=c.virtualCamera.forward,E=this._shadowMapSize,R=E.z,w=E.w,P=this._shadowMapFormat;(i=this._supportDepthTexture?(a=hM.recreateRenderTargetIfNeeded(o,this._renderTarget,R,w,null,P,!0,!1,1)).depthTexture:(a=hM.recreateRenderTargetIfNeeded(o,this._renderTarget,R,w,P,null,!1,!1,1)).getColorTexture(0)).wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,o._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=a,this._depthTexture=i,v.activeRenderTarget(a,r._viewport,t.flipProjection,0),this._supportDepthTexture?v.clearRenderTarget(o,e.CameraClearFlags.Depth,null):v.clearRenderTarget(o,e.CameraClearFlags.All,r._clearColor),cF.rotationQuaternion(n.entity.transform.worldRotationQuaternion,S),A.set(C[0],C[1],C[2]),T.set(C[4],C[5],C[6]),M.set(-C[8],-C[9],-C[10]);var F=r._tempVector;F.copyFrom(s.entity.transform.worldForward);for(var L=this._shadowTileResolution,D=0;D<y;D++){hF.getBoundSphereByFrustum(x[D],x[D+1],s,F,c),hF.getDirectionLightShadowCullPlanes(s._frustum,x[D],s.nearClipPlane,M,c),hF.getDirectionalLightMatrices(T,A,M,D,n.shadowNearPlane,L,c,u),y>1&&hF.applySliceTransform(L,R,w,D,this._viewportOffsets[D],u),this._updateSingleShadowCasterShaderData(n,c,t);var B=b.center,I=b.radius,V=4*D;d[V]=B.x,d[V+1]=B.y,d[V+2]=B.z,d[V+3]=I*I,_.clear(),f.clear(),p.clear();for(var O=g._renderers,N=O._elements,k=O.length-1;k>=0;--k)hF.shadowCullFrustum(t,n,N[k],c);if(_.elements.length||f.elements.length){_.sort(hR._compareFromNearToFar),f.sort(hR._compareFromNearToFar);var z=l[D],U=z.x,G=z.y;v.setGlobalDepthBias(1,1),v.viewport(U,G,L,L),v.scissor(U+1,G+1,L-2,L-2),o._renderCount++,_.render(s,e.PipelineStage.ShadowCaster),f.render(s,e.PipelineStage.ShadowCaster),v.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var t=this._camera,n=t.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=n.shadowCascades,s=Math.min(n.shadowDistance,t.farClipPlane);if(hF.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),n.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var d=16*o,u=i.length;d<u;d++)i[d]=0;var h=n.shaderData;h.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),h.setVector4(r._shadowInfosProperty,this._shadowInfos),h.setTexture(r._shadowMapsProperty,this._depthTexture),h.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,a=this._camera.scene,i=a.shadowTwoCascadeSplits,o=a.shadowFourCascadeSplits,s=a.shadowCascades,l=this._camera,c=l.nearClipPlane,d=l.aspectRatio,u=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*cS.degreeToRadian(u)),f=1+_*_*(d*d+1);switch(s){case e.ShadowCascadesMode.NoCascades:n[1]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.TwoCascades:n[1]=this._getFarWithRadius(c+h*i,f),n[2]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.FourCascades:n[1]=this._getFarWithRadius(c+h*o.x,f),n[2]=this._getFarWithRadius(c+h*o.y,f),n[3]=this._getFarWithRadius(c+h*o.z,f),n[4]=this._getFarWithRadius(t,f)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var t=this._camera,r=t.scene,n=hF.shadowDepthFormat(r.shadowResolution,this._supportDepthTexture),a=hF.shadowResolution(r.shadowResolution),i=r.shadowCascades,o=Math.min(r.shadowDistance,t.farClipPlane);if(this._getCascadesSplitDistance(o),n!==this._shadowMapFormat||a!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=a,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=a,this._shadowMapSize.set(1/a,1/a,a,a);else{var s=hF.getMaxTileResolutionInAtlas(a,a,i);this._shadowTileResolution=s;var l=2*s,c=i==e.ShadowCascadesMode.TwoCascades?s:2*s;this._shadowMapSize.set(1/l,1/c,l,c)}this._renderTarget=null;var d=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:d[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:d[0].set(0,0),d[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:d[0].set(0,0),d[1].set(u,0),d[2].set(0,u),d[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var a=t.virtualCamera;hF.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(r._lightShadowBiasProperty,this._shadowBias),i.setVector3(r._lightDirectionProperty,e.direction),n.applyVirtualCamera(a,!0)},r}(hA);hL._lightShadowBiasProperty=dn.getByName("scene_ShadowBias"),hL._lightDirectionProperty=dn.getByName("scene_LightDirection"),hL._shadowMatricesProperty=dn.getByName("scene_ShadowMatrices"),hL._shadowMapSize=dn.getByName("scene_ShadowMapSize"),hL._shadowInfosProperty=dn.getByName("scene_ShadowInfo"),hL._shadowMapsProperty=dn.getByName("scene_ShadowMap"),hL._shadowSplitSpheresProperty=dn.getByName("scene_ShadowSplitSpheres"),hL._maxCascades=4,hL._cascadesSplitDistance=Array(hL._maxCascades+1),hL._viewport=new cB(0,0,1,1),hL._clearColor=new cI(1,1,1,1),hL._tempVector=new cC,hL._tempMatrix0=new cF;var hD=((aT=(aC=function(t){this.opaqueQueue=new hR(t,e.RenderQueueType.Opaque),this.transparentQueue=new hR(t,e.RenderQueueType.Transparent),this.alphaTestQueue=new hR(t,e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},aT.sort=function(){this.opaqueQueue.sort(hR._compareFromNearToFar),this.alphaTestQueue.sort(hR._compareFromNearToFar),this.transparentQueue.sort(hR._compareFromFarToNear)},aT.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},aC),hB=(cH(aA=function(t){var r;return(r=hA.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},hA),(aM=aA.prototype).onConfig=function(t){var r=this._engine,n=t.pixelViewport,a=n.width,i=n.height,o=hM.recreateRenderTargetIfNeeded(r,this._renderTarget,a,i,null,e.TextureFormat.Depth16,!0,!1,1),s=o.depthTexture;s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Clamp,s.filterMode=e.TextureFilterMode.Point,this._renderTarget=o},aM.onRender=function(t,r){var n=this._engine,a=this._renderTarget,i=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(a,i.viewport,t.flipProjection,0),o.viewport(0,0,a.width,a.height),o.scissor(0,0,a.width,a.height),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),r.opaqueQueue.render(i,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(i,e.PipelineStage.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},aA);e.Downsampling=void 0,(aE=e.Downsampling||(e.Downsampling={}))[aE.None=1]="None",aE[aE.TwoX=2]="TwoX",aE[aE.FourX=4]="FourX";var hI=(cH(aR=function(e){return hA.call(this,e)},hA),(aw=aR.prototype).onConfig=function(t,r){this._cameraColorTexture=r;var n=t.opaqueTextureDownsampling,a=n===e.Downsampling.None,i=t.pixelViewport,o=a?1:n===e.Downsampling.TwoX?.5:.25,s=hM.recreateRenderTargetIfNeeded(this._engine,this._renderTarget,i.width*o,i.height*o,e.TextureFormat.R8G8B8A8,null,!1,!1,1),l=s.getColorTexture(0);l.wrapModeU=l.wrapModeV=e.TextureWrapMode.Clamp,l.filterMode=a?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,this._renderTarget=s},aw.onRender=function(t,r){hM.blitTexture(this._engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},aR),hV=((aF=(aP=function(e){this._allSpriteMasks=new dV,this._lastCanvasSize=new cD,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new hD(t),this._cascadedShadowCasterPass=new hL(e),this._depthOnlyPass=new hB(t),this._opaqueTexturePass=new hI(t)}).prototype).destroy=function(){this._cullingResults.destroy(),this._allSpriteMasks=null,this._camera=null},aF.render=function(t,r,n,a){var i=this._camera,o=i.scene,s=i.engine,l=this._cullingResults,c=o._lightManager._sunlight,d=this._depthOnlyPass,u=i.depthTextureMode===e.DepthTextureMode.PrePass&&d._supportDepthTexture;if(i.engine._spriteMaskManager.clear(),o.castShadows&&c&&c.shadowType!==e.ShadowType.None&&this._cascadedShadowCasterPass.onRender(t),l.reset(),this._allSpriteMasks.length=0,t.applyVirtualCamera(i._virtualCamera,u),this._prepareRender(t),l.sort(),u?(d.onConfig(i),d.onRender(t,l)):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var h=i.pixelViewport,_=hM.recreateRenderTargetIfNeeded(s,this._internalColorTarget,h.width,h.height,e.TextureFormat.R8G8B8A8,e.TextureFormat.Depth24Stencil8,!1,!1,i.msaaSamples),f=_.getColorTexture(0);f.wrapModeU=f.wrapModeV=e.TextureWrapMode.Clamp,this._internalColorTarget=_}else{var p,m=this._internalColorTarget;m&&(null==(p=m.getColorTexture(0))||p.destroy(!0),m.destroy(!0),this._internalColorTarget=null)}this._drawRenderPass(t,i,r,n,a)},aF._drawRenderPass=function(t,r,n,a,i){var o,s=this._cullingResults,l=s.opaqueQueue,c=s.alphaTestQueue,d=s.transparentQueue,u=r.engine,h=r.scene.background,_=this._internalColorTarget,f=u._hardwareRenderer,p=null!=(o=r.renderTarget)?o:_,m=_?hM.defaultViewport:r.viewport,g=r.renderTarget&&void 0==n||null!==_;t.flipProjection!==g&&(t.applyVirtualCamera(r._virtualCamera,g),this._updateMVPShaderData(t),u._renderCount++),f.activeRenderTarget(p,m,t.flipProjection,a,n);var v=r.clearFlags&~(null!=i?i:e.CameraClearFlags.None),y=h.solidColor;if(v!==e.CameraClearFlags.None&&f.clearRenderTarget(r.engine,v,y),l.render(r,e.PipelineStage.Forward),c.render(r,e.PipelineStage.Forward),v&e.CameraClearFlags.Color&&(h.mode===e.BackgroundMode.Sky?h.sky._render(t):h.mode===e.BackgroundMode.Texture&&h.texture&&this._drawBackgroundTexture(u,h)),r.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(r,p.getColorTexture(0)),x.onRender(t,s),f.activeRenderTarget(p,m,t.flipProjection,a,n)}else r.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);d.render(r,e.PipelineStage.Forward),null==p||p._blitRenderTarget(),null==p||p.generateMipmaps(),_&&hM.blitTexture(u,_.getColorTexture(0),null,0,r.viewport)},aF.pushRenderData=function(t,r){var n=r.material,a=n.renderStates,i=n.shader.subShaders[0],o=t.replacementShader;if(o){var s=o.subShaders,l=t.replacementTag;if(l){for(var c=i.getTagValue(l),d=0,u=s.length;d<u;d++){var h=s[d];if(h.getTagValue(l)===c){this.pushRenderDataWithShader(t,r,h.passes,a);return}}t.replacementFailureStrategy===e.ReplacementFailureStrategy.KeepOriginalShader&&this.pushRenderDataWithShader(t,r,i.passes,a)}else this.pushRenderDataWithShader(t,r,s[0].passes,a)}else this.pushRenderDataWithShader(t,r,i.passes,a)},aF.pushRenderDataWithShader=function(t,r,n,a){for(var i=this._cullingResults,o=i.opaqueQueue,s=i.alphaTestQueue,l=i.transparentQueue,c=t.camera.engine._renderElementPool,d=0,u=0,h=n.length;u<h;u++){var _,f=(null!=(_=n[u]._renderState)?_:a[u]).renderQueueType;if(!(d&1<<f)){var p=c.getFromPool();switch(p.set(r,n),f){case e.RenderQueueType.Opaque:o.pushRenderElement(p),d|=1;break;case e.RenderQueueType.AlphaTest:s.pushRenderElement(p),d|=2;break;case e.RenderQueueType.Transparent:l.pushRenderElement(p),d|=4}}}},aF._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,a=t.canvas,i=r._material,o=r._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(a.width,a.height),r._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,dw._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._apply(t,!1,s._renderStateDataMap,i.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},aF._prepareRender=function(e){for(var t=e.camera,r=t.engine,n=t.scene._componentsManager._renderers,a=n._elements,i=n.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=r.time.frameCount,o._prepareRender(e))}},aF._updateMVPShaderData=function(e){for(var t=e.camera.scene._componentsManager._renderers,r=t._elements,n=t.length-1;n>=0;--n)r[n]._updateShaderData(e,!0)},aP);(aL=l7||(l7={}))[aL.None=0]="None",aL[aL.Opaque=1]="Opaque",aL[aL.AlphaTest=2]="AlphaTest",aL[aL.Transparent=4]="Transparent",e.CameraType=void 0,(aD=e.CameraType||(e.CameraType={}))[aD.Normal=0]="Normal",aD[aD.XRCenterCamera=1]="XRCenterCamera",aD[aD.XRLeftCamera=2]="XRLeftCamera",aD[aD.XRRightCamera=4]="XRRightCamera",e.MSAASamples=void 0,(aB=e.MSAASamples||(e.MSAASamples={}))[aB.None=1]="None",aB[aB.TwoX=2]="TwoX",aB[aB.FourX=4]="FourX",aB[aB.EightX=8]="EightX";var hO=function(){};hO.tempVec4=new cB,hO.tempVec3=new cC,hO.tempVec2=new cD,e.Camera=(cH(aI=function(t){(r=di.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r.opaqueTextureDownsampling=e.Downsampling.TwoX,r.msaaSamples=e.MSAASamples.None,r._cameraType=e.CameraType.Normal,r._globalShaderMacro=new dh,r._frustum=new cR,r._virtualCamera=new hw,r._replacementShader=null,r._replacementSubShaderTag=null,r._replacementFailureStrategy=null,r._cameraIndex=-1,r._priority=0,r._shaderData=new dL(lW.Camera),r._isCustomViewMatrix=!1,r._isCustomProjectionMatrix=!1,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new cB,r._opaqueTextureEnabled=!1,r._viewport=new cB(0,0,1,1),r._pixelViewport=new cV(0,0,0,0),r._inverseProjectionMatrix=new cF,r._invViewProjMat=new cF;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new hV(ck(r)),r._addResourceReferCount(r.shaderData,1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(ck(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},di),(aV=aI.prototype).resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},aV.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},aV.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},aV.worldToViewportPoint=function(e,t){var r=hO.tempVec3,n=hO.tempVec4;cC.transformCoordinate(e,this.viewMatrix,r),cC.transformToVec4(r,this.projectionMatrix,n);var a=n.w;return t.set((n.x/a+1)*.5,(1-n.y/a)*.5,-r.z),t},aV.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,a=this.farClipPlane,i=1/(n-a);if(this.isOrthographic)r=-(2*e.z)*i+(a+n)*i;else{var o=e.z;r=(-o*(n+a)*i+2*n*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},aV.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-cS.zeroTolerance,r,t.direction);return cC.subtract(a,n,a),a.normalize(),t},aV.screenToViewportPoint=function(e,t){var r=this.engine.canvas,n=this.viewport;return t.x=(e.x/r.width-n.x)/n.z,t.y=(e.y/r.height-n.y)/n.w,void 0!==e.z&&(t.z=e.z),t},aV.viewportToScreenPoint=function(e,t){var r=this.engine.canvas,n=this.viewport;return t.x=(n.x+e.x*n.z)*r.width,t.y=(n.y+e.y*n.w)*r.height,void 0!==e.z&&(t.z=e.z),t},aV.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},aV.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},aV.screenPointToRay=function(e,t){var r=hO.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},aV.render=function(t,r){void 0===r&&(r=0);var n,a=this.engine._renderContext,i=this._virtualCamera,o=this.entity.transform;cF.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,a.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),dh.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,dr.error("mipLevel only take effect in WebGL2.0")),this._cameraType!==e.CameraType.Normal&&(n=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,t,r,n),this._engine._renderCount++},aV.setReplacementShader=function(t,r,n){void 0===n&&(n=e.ReplacementFailureStrategy.KeepOriginalShader),this._replacementShader=t,this._replacementSubShaderTag="string"==typeof r?dm.getByName(r):r,this._replacementFailureStrategy=n},aV.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},aV._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},aV._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},aV._onDestroy=function(){var e;di.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},aV._updatePixelViewport=function(){var e,t,r=this._renderTarget;if(r)e=r.width,t=r.height;else{var n=this.engine.canvas;e=n.width,t=n.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},aV._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},aV._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},aV._innerViewportToWorldPoint=function(e,t,r,n,a){var i=hO.tempVec3;return i.set(2*e-1,1-2*t,2*r-1),cC.transformCoordinate(i,n,a),a},aV._updateShaderData=function(){var t=this.shaderData,r=this._transform;t.setMatrix(e.Camera._inverseViewMatrixProperty,r.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,r.worldPosition),t.setVector3(e.Camera._cameraForwardProperty,r.worldForward),t.setVector3(e.Camera._cameraUpProperty,r.worldUp);var n=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;n.set(1-a,a,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},aV._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,cF.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},aV._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,cF.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},aV._forceUseInternalCanvas=function(){return this.opaqueTextureEnabled},aV._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},aV._checkMainCanvasAntialiasWaste=function(){this.independentCanvasEnabled&&cB.equals(this._viewport,hM.defaultViewport)&&console.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},cU(aI,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return!this._renderTarget&&this._forceUseInternalCanvas()}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._transform;return cF.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,a=this._orthographicSize;cF.ortho(-n,n,-a,a,this.nearClipPlane,this.farClipPlane,t)}else cF.perspective(cS.degreeToRadian(this._fieldOfView),r,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged(),this._checkMainCanvasAntialiasWaste())}}]),aI._cameraDepthTextureProperty=dn.getByName("camera_DepthTexture"),aI._cameraOpaqueTextureProperty=dn.getByName("camera_OpaqueTexture"),aI._inverseViewMatrixProperty=dn.getByName("camera_ViewInvMat"),aI._cameraPositionProperty=dn.getByName("camera_Position"),aI._cameraForwardProperty=dn.getByName("camera_Forward"),aI._cameraUpProperty=dn.getByName("camera_Up"),aI._cameraDepthBufferParamsProperty=dn.getByName("camera_DepthBufferParams"),aI),cW([cY],e.Camera.prototype,"_frustum",void 0),cW([cj],e.Camera.prototype,"_renderPipeline",void 0),cW([cj],e.Camera.prototype,"_virtualCamera",void 0),cW([cj],e.Camera.prototype,"_cameraIndex",void 0),cW([cj],e.Camera.prototype,"_frustumChangeFlag",void 0),cW([cj],e.Camera.prototype,"_transform",void 0),cW([cj],e.Camera.prototype,"_isViewMatrixDirty",void 0),cW([cj],e.Camera.prototype,"_isInvViewProjDirty",void 0),cW([cY],e.Camera.prototype,"_viewport",void 0),cW([cY],e.Camera.prototype,"_pixelViewport",void 0),cW([cY],e.Camera.prototype,"_inverseProjectionMatrix",void 0),cW([cY],e.Camera.prototype,"_invViewProjMat",void 0),cW([cj],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=cW([dl(dd,e.DependentMode.CheckOnly)],e.Camera);var hN={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hk=1/0;function hz(e,t){return void 0===t&&(t={}),new uz(function(r,n,a,i){var o,s,l,c,d=null!=(o=t.retryCount)?o:1,u=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:hk,t.type=null!=(c=t.type)?c:hN[e.substring(e.lastIndexOf(".")+1)],new hU(function(){var r;return(r=t,new uz(function(t,n,a,i){var o,s=new XMLHttpRequest,l="image"===r.type;s.timeout=r.timeout,r.method=null!=(o=r.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){n(Error("request failed from: "+e));return}var r,i=null!=(r=s.response)?r:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){n(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){n(Error("request failed from: "+e))},s.ontimeout=function(){n(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(r.method,e,!0),s.withCredentials="include"===r.credentials,s.responseType=l?"blob":r.type;var c=r.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(r.body)})).onProgress(a,i)},d,u).start().onError(n).onComplete(r)})}var hU=((aN=(aO=function(e,t,r){this.execFunc=e,this.totalCount=t,this.interval=r,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}).prototype).start=function(){return this.exec(),this},aN.onComplete=function(e){return this._onComplete=e,this},aN.onError=function(e){return this._onError=e,this},aN.cancel=function(){window.clearTimeout(this._timeoutId)},aN.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(t){return e._onComplete&&e._onComplete(t)}).catch(function(t){e._error=t,e._timeoutId=window.setTimeout(e.exec,e.interval)})},aO),hG=((ak=function(e){this.useCache=e,this.request=hz}).registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},ak.getClass=function(e){return this._engineObjects[e]},ak.getClassName=function(e){return this._classNameMap.get(e)},ak);hG._engineObjects={},hG._classNameMap=new Map;var hH=((aU=(az=function(){}).prototype).initialize=function(e){var t=e.component,r=e.property.split(".");if(e.getProperty){var n=e.getProperty.split(".");this._initializeMounted(t,n,1),this._initializeMounted(t,r,2)}else this._initializeMounted(t,r,3)},aU.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},aU.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},aU._initializeMounted=function(e,t,r){for(var n,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var d=c.indexOf("[");e=(e=e[c.slice(0,d)])[parseInt(c.slice(d+1,-1))]}else if(c.endsWith(")")){var u=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[u].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");n=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),n=1,2&r){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else n=0;2&r&&(this._setMounted=e,this._setType=n,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&r&&(this._getMounted=e,this._getType=n,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},az);(aG=ce||(ce={}))[aG.Property=0]="Property",aG[aG.Method=1]="Method",aG[aG.Array=2]="Array",(aH=ct||(ct={}))[aH.Get=1]="Get",aH[aH.Set=2]="Set",aH[aH.Both=3]="Both";var hW=function(){function e(t,r,n,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=n,this.cureType=o;var s=e.getAssemblerType(r,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,r){return r?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,r,n,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?n?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):n?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,r)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,r){var n=this.cureType;if(r){var a=this._assembler;if(n._isCopyMode)n._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=n._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)n._isCopyMode?n._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(n._isCopyMode){var s=this.referenceTargetValue;n._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=n._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,r){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,r),this.baseEvaluateData.value)},e.registerAssembler=function(t,r,n){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),a=n?n[r]:void 0;return null!=a?a:hH},e}();hW._components=[],hW._assemblerMap=new Map;var hK=((aK=(aW=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aK.getTargetValue=function(){return this._transform.position},aK.setTargetValue=function(e){this._transform.position=e},aW);hW.registerAssembler(dd,"position",hK);var hj=((aX=(aj=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aX.getTargetValue=function(){return this._transform.rotationQuaternion},aX.setTargetValue=function(e){this._transform.rotationQuaternion=e},aj);hW.registerAssembler(dd,"rotationQuaternion",hj);var hX=((aY=(aq=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aY.getTargetValue=function(){return this._transform.scale},aY.setTargetValue=function(e){this._transform.scale=e},aq);hW.registerAssembler(dd,"scale",hX);var hq=((aJ=(aQ=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.component},aJ.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},aJ.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},aQ);hW.registerAssembler(ul,"blendShapeWeights",hq);var hY=((a$=(aZ=function(){this.crossCurveMark=0,this.isActive=!0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},a$.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},aZ),hQ=((a1=(a0=function(){this.typeIndex=0,this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new hW(e,this.type,t,this.property,this.getProperty,r);return r._initializeOwner(n),n.saveDefaultValue(),n},a1._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new hY;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},a1._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},a0),hJ=function(){},hZ=(cH(a2=function(e){var t;return(t=cJ.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new c4,t._length=0,t._events=[],t},cJ),(a3=a2.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,a=new hJ;a.functionName=e,a.time=t,a.parameter=r,n=a}else n=e;var i=this._events,o=i.length,s=n.time;if(s>=(o?i[o-1].time:0))i.push(n);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,n)}this._updateFlagManager.dispatch()},a3.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},a3.addCurveBinding=function(e,t,r,n,a,i){var o=new hQ;o.relativePath=e,o.type=t,"number"==typeof r?(o.typeIndex=r,o.property=n,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=r,"string"==typeof n?(o.getProperty=n,o.curve=a):o.curve=n),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},a3.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},a3._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var a=r[n],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,hW._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},cU(a2,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),a2);e.InterpolationType=void 0,(a4=e.InterpolationType||(e.InterpolationType={}))[a4.Linear=0]="Linear",a4[a4.CubicSpine=1]="CubicSpine",a4[a4.Step=2]="Step",a4[a4.Hermite=3]="Hermite";var h$=((a5=(a8=function(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var t=this.constructor;this._interpolation=t._supportInterpolationMode?e.InterpolationType.Linear:e.InterpolationType.Step,this._type=t}).prototype).addKey=function(e){var t=e.time,r=this.keys;if(t>=this._length)r.push(e),this._length=t;else{for(var n=r.length;--n>=0&&t<r[n].time;);r.splice(n+1,0,e)}},a5.evaluate=function(e){return this._evaluate(e,this._evaluateData)},a5.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var a=t[n];a.time>this._length&&(r=a.time)}this._length=r},a5._evaluate=function(t,r){var n,a=this.keys.length;if(!a){console.warn("This curve don't have any keyframes: ",this);return}var i=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=a||t<i[s].time)&&(s=-1);for(var l=s+1;l<a&&!(t<i[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(i[0].value,r.value);else if(l===a)n=this._type._setValue(i[s].value,r.value);else{var c=i[s],d=i[l],u=c.time,h=d.time-u,_=(t-u)/h;switch(o){case e.InterpolationType.Linear:n=this._type._lerpValue(c.value,d.value,_,r.value);break;case e.InterpolationType.Step:n=this._type._setValue(c.value,r.value);break;case e.InterpolationType.CubicSpine:case e.InterpolationType.Hermite:n=this._type._hermiteInterpolationValue(c,d,_,h,r.value)}}return r.value=n,n},a5._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},cU(a8,[{key:"interpolation",get:function(){return this._interpolation},set:function(t){this._type._supportInterpolationMode||t===e.InterpolationType.Step?this._interpolation=t:(this._interpolation=e.InterpolationType.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),a8);e.AnimationArrayCurve=(cH(a9=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=[],e},h$),a9._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},a9._initializeLayerOwner=function(e){e.finalValue=[]},a9._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},a9._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},a9._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},a9._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},a9._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},a9._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=u*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},a9._isCopyMode=!0,a9._supportInterpolationMode=!0,a9),e.AnimationArrayCurve=cW([dD()],e.AnimationArrayCurve),e.AnimationBoolCurve=(cH(a6=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=!1,e},h$),a6._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},a6._initializeLayerOwner=function(e){e.finalValue=!1},a6._lerpValue=function(e,t){return e},a6._subtractValue=function(e,t,r){return e},a6._getZeroValue=function(){return!1},a6._additiveValue=function(e,t,r){return e},a6._setValue=function(e){return e},a6._hermiteInterpolationValue=function(e){return e.value},a6._isCopyMode=!1,a6._supportInterpolationMode=!1,a6),e.AnimationBoolCurve=cW([dD()],e.AnimationBoolCurve),e.AnimationColorCurve=(cH(a7=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cI,e},h$),a7._initializeOwner=function(e){e.defaultValue=new cI,e.fixedPoseValue=new cI,e.baseEvaluateData.value=new cI,e.crossEvaluateData.value=new cI},a7._initializeLayerOwner=function(e){e.finalValue=new cI},a7._lerpValue=function(e,t,r,n){return cI.lerp(e,t,r,n),n},a7._subtractValue=function(e,t,r){return cI.subtract(e,t,r),r},a7._getZeroValue=function(e){return e.set(0,0,0,0),e},a7._additiveValue=function(e,t,r){return cI.scale(e,t,e),cI.add(r,e,r),r},a7._setValue=function(e,t){return t.copyFrom(e),t},a7._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.r=u*i.r+h*p*n+_*m*n+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=u*i.g+h*p*n+_*m*n+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=u*i.b+h*p*n+_*m*n+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=u*i.a+h*p*n+_*m*n+f*s.a:a.a=i.a,a},a7._isCopyMode=!0,a7._supportInterpolationMode=!0,a7),e.AnimationColorCurve=cW([dD()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(cH(ie=function(){return h$.apply(this,arguments)},h$),ie.prototype.addKey=function(e){h$.prototype.addKey.call(this,e);var t=this._evaluateData;if(!t.value||t.value.length!==e.value.length){var r=e.value.length;t.value=new Float32Array(r)}},ie._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},ie._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},ie._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},ie._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},ie._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},ie._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},ie._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},ie._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=u*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},ie._isCopyMode=!0,ie._supportInterpolationMode=!0,ie),e.AnimationFloatArrayCurve=cW([dD()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(cH(it=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=0,e},h$),it._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},it._initializeLayerOwner=function(e){e.finalValue=0},it._lerpValue=function(e,t,r){return e+(t-e)*r},it._additiveValue=function(e,t,r){return r+e*t},it._subtractValue=function(e,t){return e-t},it._getZeroValue=function(){return 0},it._setValue=function(e){return e},it._hermiteInterpolationValue=function(e,t,r,n){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*a*n+(s-o)*i*n+(-2*s+3*o)*t.value},it._isCopyMode=!1,it._supportInterpolationMode=!0,it),e.AnimationFloatCurve=cW([dD()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(cH(ir=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cP,e},h$),ir._initializeOwner=function(e){e.defaultValue=new cP,e.fixedPoseValue=new cP,e.baseEvaluateData.value=new cP,e.crossEvaluateData.value=new cP},ir._initializeLayerOwner=function(e){e.finalValue=new cP},ir._lerpValue=function(e,t,r,n){return cP.slerp(e,t,r,n),n},ir._additiveValue=function(e,t,r){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),r.multiply(e),r},ir._subtractValue=function(t,r,n){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return cP.conjugate(r,a),cP.multiply(a,t,n),n},ir._getZeroValue=function(e){return e.set(0,0,0,1),e},ir._setValue=function(e,t){return t.copyFrom(e),t},ir._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=u*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},ir._supportInterpolationMode=!0,ir._isCopyMode=!0,ir._tempConjugateQuat=new cP,ir),e.AnimationQuaternionCurve=cW([dD()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(cH(ia=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cD,e},h$),ia._initializeOwner=function(e){e.defaultValue=new cD,e.fixedPoseValue=new cD,e.baseEvaluateData.value=new cD,e.crossEvaluateData.value=new cD},ia._initializeLayerOwner=function(e){e.finalValue=new cD},ia._lerpValue=function(e,t,r,n){return cD.lerp(e,t,r,n),n},ia._additiveValue=function(e,t,r){return cD.scale(e,t,e),cD.add(r,e,r),r},ia._subtractValue=function(e,t,r){return cD.subtract(e,t,r),r},ia._getZeroValue=function(e){return e.set(0,0),e},ia._setValue=function(e,t){return t.copyFrom(e),t},ia._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,a},ia._isCopyMode=!0,ia._supportInterpolationMode=!0,ia),e.AnimationVector2Curve=cW([dD()],e.AnimationVector2Curve),e.AnimationVector3Curve=(cH(ii=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cC,e},h$),ii._initializeOwner=function(e){e.defaultValue=new cC,e.fixedPoseValue=new cC,e.baseEvaluateData.value=new cC,e.crossEvaluateData.value=new cC},ii._initializeLayerOwner=function(e){e.finalValue=new cC},ii._lerpValue=function(e,t,r,n){return cC.lerp(e,t,r,n),n},ii._relativeBaseValue=function(e,t){return cC.subtract(t,e,t),t},ii._additiveValue=function(e,t,r){return cC.scale(e,t,e),cC.add(r,e,r),r},ii._subtractValue=function(e,t,r){return cC.subtract(e,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0),e},ii._setValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,a},ii._isCopyMode=!0,ii._supportInterpolationMode=!0,ii),e.AnimationVector3Curve=cW([dD()],e.AnimationVector3Curve),e.AnimationVector4Curve=(cH(io=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cB,e},h$),io._initializeOwner=function(e){e.defaultValue=new cB,e.fixedPoseValue=new cB,e.baseEvaluateData.value=new cB,e.crossEvaluateData.value=new cB},io._initializeLayerOwner=function(e){e.finalValue=new cB},io._lerpValue=function(e,t,r,n){return cB.lerp(e,t,r,n),n},io._additiveValue=function(e,t,r){return cB.scale(e,t,e),cB.add(r,e,r),r},io._subtractValue=function(e,t,r){return cB.subtract(e,t,r),r},io._getZeroValue=function(e){return e.set(0,0,0,0),e},io._setValue=function(e,t){return t.copyFrom(e),t},io._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,d=c*r,u=2*d-3*c+1,h=d-2*c+r,_=d-c,f=-2*d+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?a.x=u*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=u*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=u*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=u*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},io._isCopyMode=!0,io._supportInterpolationMode=!0,io),e.AnimationVector4Curve=cW([dD()],e.AnimationVector4Curve),e.AnimationRefCurve=(cH(is=function(){return h$.call(this)},h$),is._initializeOwner=function(e){},is._initializeLayerOwner=function(e){},is._setValue=function(e){return e},is._isCopyMode=!1,is._supportInterpolationMode=!1,is),e.AnimationRefCurve=cW([dD()],e.AnimationRefCurve),e.AnimationRectCurve=(cH(il=function(){var e;return(e=h$.call(this)||this)._evaluateData.value=new cV,e},h$),il._initializeOwner=function(e){e.defaultValue=new cV,e.fixedPoseValue=new cV,e.baseEvaluateData.value=new cV,e.crossEvaluateData.value=new cV},il._initializeLayerOwner=function(e){e.finalValue=new cV},il._setValue=function(e,t){return t.copyFrom(e),t},il._isCopyMode=!0,il._supportInterpolationMode=!1,il),e.AnimationRectCurve=cW([dD()],e.AnimationRectCurve),e.AnimationStringCurve=(cH(ic=function(){var e;return(e=h$.call(this)||this)._evaluateData.value="",e},h$),ic._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},ic._initializeLayerOwner=function(e){e.finalValue=""},ic._lerpValue=function(e,t){return e},ic._subtractValue=function(e,t,r){return e},ic._getZeroValue=function(){return""},ic._additiveValue=function(e,t,r){return e},ic._setValue=function(e){return e},ic._hermiteInterpolationValue=function(e){return e.value},ic._isCopyMode=!1,ic._supportInterpolationMode=!1,ic),e.AnimationStringCurve=cW([dD()],e.AnimationStringCurve),e.AnimatorCullingMode=void 0,(id=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[id.None=0]="None",id[id.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iu=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iu.Override=0]="Override",iu[iu.Additive=1]="Additive",(ih=cr||(cr={}))[ih.UnStarted=0]="UnStarted",ih[ih.Playing=1]="Playing",ih[ih.Finished=2]="Finished",(i_=cn||(cn={}))[i_.Standby=0]="Standby",i_[i_.Playing=1]="Playing",i_[i_.CrossFading=2]="CrossFading",i_[i_.FixedCrossFading=3]="FixedCrossFading",i_[i_.Finished=4]="Finished";var h0=((ip=function(){this.handlers=[]}).prototype.dispose=function(){},ip),h1=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(im=e.WrapMode||(e.WrapMode={}))[im.Once=0]="Once",im[im.Loop=1]="Loop";var h2=((iv=(ig=function(){}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=cr.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0},iv.update=function(t){var r=this.state,n=this.frameTime,a=r._getDuration();this.playState=cr.Playing,r.wrapMode===e.WrapMode.Loop?n=a?n%a:0:Math.abs(n)>a&&(n=n<0?-a:a,this.playState=cr.Finished),t&&0===n?this.clipTime=r.clipEndTime*r.clip.length:(n<0&&(n+=a),this.clipTime=n+r.clipStartTime*r.clip.length)},ig),h3=((iy=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new h2,this.destPlayData=new h2,this.layerState=cn.Standby,this.crossCurveMark=0,this.manuallyTransition=new h1,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iy),h4=function(){this.curveLayerOwner=[],this.eventHandlers=[]},h8=(cH(ix=function(t){var r;return(r=di.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,r.speed=1,r._playFrameCount=-1,r._onUpdateIndex=-1,r._updateMark=0,r._animatorLayersData=[],r._curveOwnerPool=Object.create(null),r._animationEventHandlerPool=new uc(h0),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},di),(ib=ix.prototype).play=function(e,t,r){void 0===t&&(t=-1),void 0===r&&(r=0),(null==(n=this._controllerUpdateFlag)?void 0:n.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var n,a=this._getAnimatorStateInfo(e,t),i=a.state,o=a.layerIndex;if(i){if(!i.clip){dr.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,i,s,o);this._preparePlay(s,i),s.layerState=cn.Playing,s.srcPlayData.reset(i,l,i._getDuration()*r),this.update(0)}},ib.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var a,i=this._getAnimatorStateInfo(e,r),o=i.state,s=i.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._crossFadeByTransition(l,s)&&this.update(0)},ib.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,a=this._controlledRenderers,i=0,o=a.length;i<o;i++)if(!a[i].isCulled){n=!0;break}}else n=!0;var s=this._animatorController;if(s){if(null==(r=this._controllerUpdateFlag)?void 0:r.flag){this._checkAutoPlay();return}this._updateMark++;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==cn.Standby&&this._updateLayer(l,0===l,t,n)}},ib.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},ib.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},ib._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},ib._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},ib._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},ib._reset=function(){var e=this._curveOwnerPool;for(var t in e){var r=e[t];for(var n in r)r[n].revertDefaultValue()}this._animatorLayersData.length=0,this._curveOwnerPool={},this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},ib._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,a=null;if(r){var i=r.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=a,n},ib._getAnimatorStateData=function(e,t,r,n){var a=r.animatorStateDataMap,i=a[e];return i||(i=new h4,a[e]=i,this._saveAnimatorStateData(t,i,r,n),this._saveAnimatorEventHandlers(t,i)),i},ib._saveAnimatorStateData=function(e,t,r,n){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[n].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=r.curveOwnerPool,d=l.length-1;d>=0;d--){var u=l[d],h=u.relativePath,_=""===u.relativePath?a:a.findByPath(u.relativePath);if(_){var f,p,m=u.typeIndex>0?_.getComponents(u.type,hW._components)[u.typeIndex]:_.getComponent(u.type);if(!m)continue;var g=u.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=u._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),S=b[g]||(b[g]=u._createCurveLayerOwner(x));o&&o.pathMasks.length&&(S.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[d]=S}else s[d]=null,dr.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},ib._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){r._entity.getComponents(hT,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],d=n.getFromPool(),u=c.functionName,h=d.handlers;d.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=a[_][u];f&&h.push(f)}i.push(d)}};o(),e._updateFlagManager.addListener(o)},ib._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},ib._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},ib._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},ib._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},ib._prepareFixedPoseCrossFading=function(e){for(var t=e.crossLayerOwnerCollection,r=t.length-1;r>=0;r--){var n=t[r];n&&(n.curveOwner.saveFixedPoseValue(),n.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},ib._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,n,-1))}},ib._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=n;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,n)}}}},ib._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new h3),t},ib._updateLayer=function(t,r,n,a){var i=this._animatorController.layers[t],o=i.blendingMode,s=i.weight,l=this._animatorLayersData[t],c=l.srcPlayData,d=l.destPlayData,u=o===e.AnimatorLayerBlendingMode.Additive;switch(r&&(s=1),l.layerState){case cn.Playing:this._updatePlayingState(c,l,t,s,n,u,a);break;case cn.FixedCrossFading:this._updateCrossFadeFromPose(d,l,t,s,n,u,a);break;case cn.CrossFading:this._updateCrossFade(c,d,l,t,s,n,u,a);break;case cn.Finished:this._updateFinishedState(c,s,u,a)}},ib._updatePlayingState=function(e,t,r,n,a,i,o){var s=e.stateData,l=s.curveLayerOwner,c=s.eventHandlers,d=e.state,u=e.playState,h=e.clipTime,_=d.transitions,f=d.clip._curveBindings,p=d.speed*this.speed;e.frameTime+=p*a,e.update(p<0);var m=e.clipTime,g=e.playState,v=g===cr.Finished;if(o||v)for(var y=f.length-1;y>=0;y--){var x=l[y],b=null==x?void 0:x.curveOwner;if(b&&x.isActive){var S=f[y].curve;if(S.keys.length){this._checkRevertOwner(b,i);var C=b.evaluateValue(S,m,i);o&&b.applyValue(C,n,i),v&&x.saveFinalValue()}}}if(g===cr.Finished&&(t.layerState=cn.Finished),c.length&&this._fireAnimationEvents(e,c,h,m),u===cr.UnStarted&&this._callAnimatorScriptOnEnter(d,r),g===cr.Finished?this._callAnimatorScriptOnExit(d,r):this._callAnimatorScriptOnUpdate(d,r),_.length){var T=t.layerState;T!==cn.CrossFading&&T!==cn.FixedCrossFading&&this._checkTransition(e,_,r,h,m)}},ib._updateCrossFade=function(e,t,r,n,a,i,o,s){var l=this.speed,c=r.crossLayerOwnerCollection,d=e.state.clip._curveBindings,u=e.state,h=e.stateData,_=e.playState,f=h.eventHandlers,p=t.state,m=t.stateData,g=t.playState,v=m.eventHandlers,y=p.clip._curveBindings,x=e.clipTime,b=t.clipTime,S=p._getDuration()*r.crossFadeTransition.duration,C=Math.abs(t.frameTime)/S;(C>=1||0===S)&&(C=1);var T=u.speed*l,A=p.speed*l;e.frameTime+=T*i,t.frameTime+=A*i,e.update(T<0),t.update(A<0);var M=e.clipTime,E=e.playState,R=t.clipTime,w=t.playState,P=t.playState===cr.Finished;if(s||P)for(var F=c.length-1;F>=0;F--){var L=c[F],D=null==L?void 0:L.curveOwner;if(D){var B=L.crossSrcCurveIndex,I=L.crossDestCurveIndex;this._checkRevertOwner(D,o);var V=D.evaluateCrossFadeValue(B>=0?d[B].curve:null,I>=0?y[I].curve:null,M,R,C,o);s&&D.applyValue(V,a,o),P&&L.saveFinalValue()}}this._updateCrossFadeData(r,C),f.length&&this._fireAnimationEvents(e,f,x,M),v.length&&this._fireAnimationEvents(t,v,b,R),_===cr.UnStarted&&this._callAnimatorScriptOnEnter(u,n),1===C||E===cr.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n),g===cr.UnStarted&&this._callAnimatorScriptOnEnter(p,n),w===cr.Finished?this._callAnimatorScriptOnExit(p,n):this._callAnimatorScriptOnUpdate(p,n)},ib._updateCrossFadeFromPose=function(e,t,r,n,a,i,o){var s=t.crossLayerOwnerCollection,l=e.state,c=e.stateData,d=e.playState,u=c.eventHandlers,h=l.clip._curveBindings,_=e.clipTime,f=l._getDuration()*t.crossFadeTransition.duration,p=Math.abs(e.frameTime)/f;(p>=1||0===f)&&(p=1);var m=l.speed*this.speed;e.frameTime+=m*a,e.update(m<0);var g=e.clipTime,v=e.playState,y=v===cr.Finished;if(o||y)for(var x=s.length-1;x>=0;x--){var b=s[x],S=null==b?void 0:b.curveOwner;if(S){var C=b.crossDestCurveIndex;this._checkRevertOwner(S,i);var T=b.curveOwner.crossFadeFromPoseAndApplyValue(C>=0?h[C].curve:null,g,p,i);o&&S.applyValue(T,n,i),y&&b.saveFinalValue()}}this._updateCrossFadeData(t,p),u.length&&this._fireAnimationEvents(e,u,_,g),d===cr.UnStarted&&this._callAnimatorScriptOnEnter(l,r),v===cr.Finished?this._callAnimatorScriptOnExit(l,r):this._callAnimatorScriptOnUpdate(l,r)},ib._updateFinishedState=function(e,t,r,n){if(n)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},ib._updateCrossFadeData=function(e,t){var r=e.destPlayData;1===t&&(r.playState===cr.Finished?e.layerState=cn.Finished:e.layerState=cn.Playing,e.switchPlayData(),e.crossFadeTransition=null)},ib._preparePlay=function(e,t){if(e.layerState===cn.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,a=r.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(n=a[i])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},ib._checkTransition=function(e,t,r,n,a){var i=e.state,o=i.clip.length;this.speed*i.speed>=0?a<n?(this._checkSubTransition(e,t,r,n,i.clipEndTime*o),e.currentTransitionIndex=0,this._checkSubTransition(e,t,r,i.clipStartTime*o,a)):this._checkSubTransition(e,t,r,n,a):a>n?(this._checkBackwardsSubTransition(e,t,r,n,i.clipStartTime*o),e.currentTransitionIndex=t.length-1,this._checkBackwardsSubTransition(e,t,r,a,i.clipEndTime*o)):this._checkBackwardsSubTransition(e,t,r,n,a)},ib._checkSubTransition=function(e,t,r,n,a){for(var i=e.currentTransitionIndex,o=e.state._getDuration(),s=t.length;i<s;i++){var l=t[i],c=l.exitTime*o;if(c>a)break;c>=n&&(this._crossFadeByTransition(l,r),e.currentTransitionIndex=Math.min(i+1,s-1))}},ib._checkBackwardsSubTransition=function(e,t,r,n,a){for(var i=e.currentTransitionIndex,o=e.state._getDuration();i>=0;i--){var s=t[i],l=s.exitTime*o;if(l<a)break;l<=n&&(this._crossFadeByTransition(s,r),e.currentTransitionIndex=Math.max(i-1,0))}},ib._crossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return dr.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),a=n.layerState,i=n.destPlayData,o=this._getAnimatorStateData(r.name,r,n,t),s=r._getDuration()*e.offset;switch(i.reset(r,o,s),a){case cn.Standby:case cn.Finished:n.layerState=cn.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case cn.Playing:n.layerState=cn.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case cn.CrossFading:n.layerState=cn.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case cn.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},ib._fireAnimationEvents=function(e,t,r,n){var a=e.state,i=a.clip.length;this.speed*a.speed>=0?n<r?(this._fireSubAnimationEvents(e,t,r,a.clipEndTime*i),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,a.clipStartTime*i,n)):this._fireSubAnimationEvents(e,t,r,n):n>r?(this._fireBackwardSubAnimationEvents(e,t,r,a.clipStartTime*i),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,a.clipEndTime*i,n)):this._fireBackwardSubAnimationEvents(e,t,r,n)},ib._fireSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var d=o.handlers;if(l>=r){for(var u=d.length-1;u>=0;u--)d[u](c);e.currentEventIndex=Math.min(a+1,i-1)}}},ib._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=i.handlers,d=c.length-1;d>=0;d--)c[d](l);e.currentEventIndex=Math.max(a-1,0)}}},ib._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,a=r.length;n<a;n++)r[n].onStateEnter(this,e,t)},ib._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,a=r.length;n<a;n++)r[n].onStateUpdate(this,e,t)},ib._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,a=r.length;n<a;n++)r[n].onStateExit(this,e,t)},ib._checkAutoPlay=function(){for(var e=this._animatorController.layers,t=0,r=e.length;t<r;++t){var n=e[t].stateMachine;(null==n?void 0:n.defaultState)&&this.play(n.defaultState.name,t)}},ib._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},cU(ix,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){e!==this._animatorController&&(this._reset(),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._controllerUpdateFlag=e&&e._registerChangeFlag(),this._animatorController=e)}}]),ix);cW([cX],h8.prototype,"speed",void 0),cW([cj],h8.prototype,"_controllerUpdateFlag",void 0),cW([cj],h8.prototype,"_updateMark",void 0),cW([cj],h8.prototype,"_animatorLayersData",void 0),cW([cj],h8.prototype,"_curveOwnerPool",void 0),cW([cj],h8.prototype,"_animationEventHandlerPool",void 0),cW([cj],h8.prototype,"_tempAnimatorStateInfo",void 0),cW([cj],h8.prototype,"_controlledRenderers",void 0);var h5=((iC=(iS=function(){this._updateFlagManager=new c4,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iC.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iC.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iC.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iC._registerChangeFlag=function(){return this._updateFlagManager.createFlag(dc)},cU(iS,[{key:"layers",get:function(){return this._layers}}]),iS),h9=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},h6=((iA=(iT=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},iA.onStateUpdate=function(e,t,r){},iA.onStateExit=function(e,t,r){},iA.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iT),h7=((iE=(iM=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new c4,this._clipStartTime=0,this._clipEndTime=1,this._transitions=[],this._onClipChanged=this._onClipChanged.bind(this)}).prototype).addTransition=function(e){var t=this._transitions,r=t.length,n=e.exitTime;if(n>=(r?t[r-1].exitTime:0))t.push(e);else{for(var a=r;--a>=0&&n<t[a].exitTime;);t.splice(a+1,0,e)}},iE.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},iE.addStateMachineScript=function(e){var t=new e;t._state=this;var r=h6.prototype;return t.onStateEnter!==r.onStateEnter&&this._onStateEnterScripts.push(t),t.onStateUpdate!==r.onStateUpdate&&this._onStateUpdateScripts.push(t),t.onStateExit!==r.onStateExit&&this._onStateExitScripts.push(t),t},iE.clearTransitions=function(){this._transitions.length=0},iE._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iE._removeStateMachineScript=function(e){var t=h6.prototype;if(e.onStateEnter!==t.onStateEnter){var r=this._onStateEnterScripts.indexOf(e);-1!==r&&this._onStateEnterScripts.splice(r,1)}if(e.onStateUpdate!==t.onStateUpdate){var n=this._onStateUpdateScripts.indexOf(e);-1!==n&&this._onStateUpdateScripts.splice(n,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},iE._onClipChanged=function(){this._updateFlagManager.dispatch()},cU(iM,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),iM),_e=((iw=(iR=function(){this.states=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new h7(e),this.states.push(t),this._statesMap[e]=t),t},iw.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},iw.findStateByName=function(e){return this._statesMap[e]},iw.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},iR);e.AnimatorConditionMode=void 0,(iP=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iP.If=0]="If",iP[iP.IfNot=1]="IfNot",iP[iP.Greater=2]="Greater",iP[iP.Less=3]="Less",iP[iP.Equals=4]="Equals",iP[iP.NotEquals=5]="NotEquals";var _t=function(){},_r=function(){},_n=((iL=(iF=function(){this._pathMasks=[],this._pathMaskMap={}}).prototype).addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var r=new _r;return r.path=e,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[e]=r,r},iL.removePathMask=function(e){for(var t=this._pathMasks,r=0,n=this._pathMasks.length;r<n;++r)if(t[r].path===e){t.splice(r,1),delete this._pathMaskMap[e];break}},iL.getPathMask=function(e){return this._pathMaskMap[e]},iL.setPathMaskActive=function(e,t,r){void 0===r&&(r=!1);var n=this._pathMaskMap[e];if(n&&(n.active=t),r)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},iF.createByEntity=function(e){var t=new iF;return t.addPathMask(""),iF._addPathMaskWithChildren(t,e,""),t},iF._addPathMaskWithChildren=function(e,t,r){for(var n=t.children,a=0,i=n.length;a<i;++a){var o=n[a],s=r?r+"/"+o.name:o.name;e.addPathMask(s),iF._addPathMaskWithChildren(e,o,s)}},cU(iF,[{key:"pathMasks",get:function(){return this._pathMasks}}]),iF),_a=function(t){function r(n){var a;return(a=t.call(this,n,dw.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new cI(1,1,1,1),a.renderState.rasterState.cullMode=e.CullMode.Off,a.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,a.shaderData.setFloat(r._rotationProp,0),a.shaderData.setFloat(r._exposureProp,1),a.shaderData.setColor(r._tintColorProp,a._tintColor),a}return cH(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},cU(r,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(r._decodeSkyRGBMMacro):this.shaderData.disableMacro(r._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(r._textureCubeProp)},set:function(e){this.shaderData.setTexture(r._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(r._rotationProp)},set:function(e){this.shaderData.setFloat(r._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(r._exposureProp)},set:function(e){this.shaderData.setFloat(r._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),r}(uS);_a._tintColorProp=dn.getByName("material_TintColor"),_a._textureCubeProp=dn.getByName("material_CubeTexture"),_a._rotationProp=dn.getByName("material_Rotation"),_a._exposureProp=dn.getByName("material_Exposure"),_a._decodeSkyRGBMMacro=du.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iD=e.SunMode||(e.SunMode={}))[iD.None=0]="None",iD[iD.Simple=1]="Simple",iD[iD.HighQuality=2]="HighQuality";var _i=(cH(iB=function(t){var r;return(r=uS.call(this,t,dw.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new cI(.5,.5,.5,1),r.groundTint=new cI(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},uS),iB.prototype.clone=function(){var e=new iB(this._engine);return this.cloneTo(e),e},cU(iB,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iB._sunSimpleMacro),t.enableMacro(iB._sunHighQualityMacro);break;case 1:t.disableMacro(iB._sunHighQualityMacro),t.enableMacro(iB._sunSimpleMacro);break;case 0:t.disableMacro(iB._sunHighQualityMacro),t.disableMacro(iB._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iB._sunSizeProp)},set:function(e){this.shaderData.setFloat(iB._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iB._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iB._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iB._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iB._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iB._skyTintProp)},set:function(e){this.shaderData.setColor(iB._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iB._groundTintProp)},set:function(e){this.shaderData.setColor(iB._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iB._exposureProp)},set:function(e){this.shaderData.setFloat(iB._exposureProp,Math.min(Math.max(0,e),8))}}]),iB);_i._sunSizeProp=dn.getByName("material_SunSize"),_i._sunSizeConvergenceProp=dn.getByName("material_SunSizeConvergence"),_i._atmosphereThicknessProp=dn.getByName("material_AtmosphereThickness"),_i._skyTintProp=dn.getByName("material_SkyTint"),_i._groundTintProp=dn.getByName("material_GroundTint"),_i._exposureProp=dn.getByName("material_Exposure"),_i._sunHighQualityMacro=du.getByName("MATERIAL_SUN_HIGH_QUALITY"),_i._sunSimpleMacro=du.getByName("MATERIAL_SUN_SIMPLE");var _o=function(){};e.ParticleRenderMode=void 0,(iI=e.ParticleRenderMode||(e.ParticleRenderMode={}))[iI.Billboard=0]="Billboard",iI[iI.StretchBillboard=1]="StretchBillboard",iI[iI.HorizontalBillboard=2]="HorizontalBillboard",iI[iI.VerticalBillboard=3]="VerticalBillboard",iI[iI.Mesh=4]="Mesh",iI[iI.None=5]="None",e.ParticleStopMode=void 0,(iV=e.ParticleStopMode||(e.ParticleStopMode={}))[iV.StopEmittingAndClear=0]="StopEmittingAndClear",iV[iV.StopEmitting=1]="StopEmitting";var _s=function(t){function r(n){var a;return(a=t.call(this,n)||this).generator=new _C(ck(a)),a.velocityScale=0,a.lengthScale=2,a.pivot=new cC,a._currentRenderModeMacro=r._billboardModeMacro,a.shaderData.enableMacro(r._billboardModeMacro),a._supportInstancedArrays=a.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),a._dirtyUpdateFlag|=lK.WorldVolume,a}cH(r,t);var n=r.prototype;return n._onEnable=function(){this.generator.main.playOnEnabled&&this.generator.play(!1)},n._onDisable=function(){this.generator.stop(!1,e.ParticleStopMode.StopEmittingAndClear)},n._prepareRender=function(e){if(this._supportInstancedArrays){var r=this.generator;r._update(this.engine.time.deltaTime),r._firstActiveElement!==r._firstFreeElement&&t.prototype._prepareRender.call(this,e)}},n._updateBounds=function(e){e.min.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),e.max.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},n._updateShaderData=function(e,t){var n=this.shaderData;n.setFloat(r._lengthScale,this.lengthScale),n.setFloat(r._speedScale,this.velocityScale),n.setFloat(r._currentTime,this.generator._playTime),n.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(n)},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var n=this._engine._renderDataPool.getFromPool();n.setX(this,r,t._primitive,t._subPrimitive),e.camera._renderPipeline.pushRenderData(e,n)}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1)),this.generator._destroy()},cU(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var a=null,i=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:a=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:a=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==a&&(this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),a&&i.enableMacro(a),this._currentRenderModeMacro=a),n!==e.ParticleRenderMode.Mesh!=(t===e.ParticleRenderMode.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(t){var r=this._mesh;r!==t&&(this._mesh=t,r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);_s._billboardModeMacro=du.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),_s._stretchedBillboardModeMacro=du.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),_s._horizontalBillboardModeMacro=du.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),_s._verticalBillboardModeMacro=du.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),_s._renderModeMeshMacro=du.getByName("RENDERER_MODE_MESH"),_s._pivotOffsetProperty=dn.getByName("renderer_PivotOffset"),_s._lengthScale=dn.getByName("renderer_StretchedBillboardLengthScale"),_s._speedScale=dn.getByName("renderer_StretchedBillboardSpeedScale"),_s._currentTime=dn.getByName("renderer_CurrentTime"),cW([cY],_s.prototype,"generator",void 0),cW([cq],_s.prototype,"pivot",void 0),e.ParticleCurveMode=void 0,(iO=e.ParticleCurveMode||(e.ParticleCurveMode={}))[iO.Constant=0]="Constant",iO[iO.TwoConstants=1]="TwoConstants",iO[iO.Curve=2]="Curve",iO[iO.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(iN=e.ParticleGradientMode||(e.ParticleGradientMode={}))[iN.Constant=0]="Constant",iN[iN.TwoConstants=1]="TwoConstants",iN[iN.Gradient=2]="Gradient",iN[iN.TwoGradients=3]="TwoGradients",e.ParticleSimulationSpace=void 0,(ik=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[ik.Local=0]="Local",ik[ik.World=1]="World",(iz=ca||(ca={}))[iz.Burst=592910910]="Burst",iz[iz.StartDelay=322376503]="StartDelay",iz[iz.StartColor=306581307]="StartColor",iz[iz.StartSize=1793934638]="StartSize",iz[iz.StartRotation=3737431713]="StartRotation",iz[iz.randomizeRotationDirection=2527743459]="randomizeRotationDirection",iz[iz.StartLifetime=2368504881]="StartLifetime",iz[iz.StartSpeed=4085612399]="StartSpeed",iz[iz.VelocityOverLifetime=3774601268]="VelocityOverLifetime",iz[iz.ColorOverLifetime=326370691]="ColorOverLifetime",iz[iz.SizeOverLifetime=1494990940]="SizeOverLifetime",iz[iz.RotationOverLifetime=1089181156]="RotationOverLifetime",iz[iz.TextureSheetAnimation=197469413]="TextureSheetAnimation",iz[iz.Shape=2941263940]="Shape",iz[iz.GravityModifier=2759560269]="GravityModifier";var _l=((iG=(iU=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var r=0,n=e.length;r<n;r++){var a=e[r];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}).prototype).addColorKey=function(e,t){var r=this._colorKeys;if(4===r.length)throw Error("Gradient can only have 4 color keys");var n="number"==typeof e?new _c(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},iG.addAlphaKey=function(e,t){var r=this._alphaKeys;if(4===r.length)throw Error("Gradient can only have 4 alpha keys");var n="number"==typeof e?new _d(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},iG.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},iG.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},iG.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,a=0,i=r.length;a<i;a++)r[a]._onValueChanged=null;for(var o=0,s=n.length;o<s;o++)n[o]._onValueChanged=null;r.length=0,n.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(r,e[l]);for(var d=0,u=t.length;d<u;d++)this._addKey(n,t[d]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},iG._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,a=0,i=Math.min(n.length,4);a<i;a++){var o=4*a,s=n[a];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=cI.gammaToLinearSpace(l.r),r[o+2]=cI.gammaToLinearSpace(l.g),r[o+3]=cI.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},iG._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},iG._addKey=function(e,t){var r=t.time,n=e.length;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},iG._removeKey=function(e,t){e.splice(t,1)},iG._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},iG._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},cU(iU,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),iU);cW([cY],_l.prototype,"_colorKeys",void 0),cW([cY],_l.prototype,"_alphaKeys",void 0),cW([cj],_l.prototype,"_colorTypeArray",void 0),cW([cj],_l.prototype,"_alphaTypeArray",void 0);var _c=(cU(iH=function(e,t){this._onValueChanged=null,this._color=new cI,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged},[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}}]),iH),_d=(cU(iW=function(e,t){this._onValueChanged=null,this._time=e,this._alpha=t},[{key:"time",get:function(){return this._time},set:function(e){this._time=e,this._onValueChanged&&this._onValueChanged()}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._alpha=e,this._onValueChanged&&this._onValueChanged()}}]),iW),_u=((iK=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new cI,this.constantMax=new cI,this.gradientMin=new _l,this.gradientMax=new _l,t.constructor===cI?r?(this.constantMin.copyFrom(t),this.constantMax.copyFrom(r),this.mode=e.ParticleGradientMode.TwoConstants):(this.constant.copyFrom(t),this.mode=e.ParticleGradientMode.Constant):r?(this.gradientMin=t,this.gradientMax=r,this.mode=e.ParticleGradientMode.TwoGradients):(this.gradient=t,this.mode=e.ParticleGradientMode.Gradient)}).prototype.evaluate=function(t,r,n){switch(this.mode){case e.ParticleGradientMode.Constant:n.copyFrom(this.constant);break;case e.ParticleGradientMode.TwoConstants:cI.lerp(this.constantMin,this.constantMax,r,n)}},cU(iK,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"gradient",get:function(){return this.gradientMax},set:function(e){this.gradientMax=e}}]),iK);cW([cY],_u.prototype,"constantMin",void 0),cW([cY],_u.prototype,"constantMax",void 0),cW([cY],_u.prototype,"gradientMin",void 0),cW([cY],_u.prototype,"gradientMax",void 0);var _h=((ij=function(e){this.enabled=!1,this._generator=e}).prototype._enableMacro=function(e,t,r){return t!==r&&(t&&e.disableMacro(t),r&&e.enableMacro(r)),r},ij);cW([cj],_h.prototype,"_generator",void 0);var __=(cH(iX=function(){var e;return e=_h.apply(this,arguments)||this,e.color=new _u(new _l([new _c(0,new cI(1,1,1)),new _c(1,new cI(1,1,1))],[new _d(0,1),new _d(1,1)])),e._colorGradientRand=new cN(0,ca.ColorOverLifetime),e._gradientKeysCount=new cB(0,0,0,0),e},_h),(iq=iX.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.color.mode;if(n!==e.ParticleGradientMode.Gradient&&n!==e.ParticleGradientMode.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(iX._maxGradientColor,a.gradientMax._getColorTypeArray(i)),t.setFloatArray(iX._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=iX._gradientMacro:(t.setFloatArray(iX._minGradientColor,a.gradientMin._getColorTypeArray(i)),t.setFloatArray(iX._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),r=iX._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),t.setVector4(iX._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},iq._resetRandomSeed=function(e){this._colorGradientRand.reset(e,ca.ColorOverLifetime)},iX);__._gradientMacro=du.getByName("RENDERER_COL_GRADIENT"),__._randomGradientsMacro=du.getByName("RENDERER_COL_RANDOM_GRADIENTS"),__._minGradientColor=dn.getByName("renderer_COLMinGradientColor"),__._minGradientAlpha=dn.getByName("renderer_COLMinGradientAlpha"),__._maxGradientColor=dn.getByName("renderer_COLMaxGradientColor"),__._maxGradientAlpha=dn.getByName("renderer_COLMaxGradientAlpha"),__._gradientKeysCount=dn.getByName("renderer_COLGradientKeysMaxTime"),cW([cY],__.prototype,"color",void 0),cW([cj],__.prototype,"_colorGradientRand",void 0),cW([cj],__.prototype,"_gradientKeysCount",void 0),cW([cj],__.prototype,"_colorMacro",void 0);var _f=((iY=function(t,r){this.mode=e.ParticleCurveMode.Constant,this.constantMin=0,this.constantMax=0,"number"==typeof t?r?(this.constantMin=t,this.constantMax=r,this.mode=e.ParticleCurveMode.TwoConstants):(this.constant=t,this.mode=e.ParticleCurveMode.Constant):r?(this.curveMin=t,this.curveMax=r,this.mode=e.ParticleCurveMode.TwoCurves):(this.curve=t,this.mode=e.ParticleCurveMode.Curve)}).prototype.evaluate=function(t,r){switch(this.mode){case e.ParticleCurveMode.Constant:return this.constant;case e.ParticleCurveMode.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*r}},cU(iY,[{key:"constant",get:function(){return this.constantMax},set:function(e){this.constantMax=e}},{key:"curve",get:function(){return this.curveMax},set:function(e){this.curveMax=e}}]),iY);cW([cY],_f.prototype,"curveMin",void 0),cW([cY],_f.prototype,"curveMax",void 0);var _p=(cH(iQ=function(){var e;return e=_h.apply(this,arguments)||this,e.rateOverTime=new _f(10),e.rateOverDistance=new _f(0),e._shapeRand=new cN(0,ca.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new cN(0,ca.Burst),e},_h),(iJ=iQ.prototype).addBurst=function(e){for(var t=this._bursts,r=t.length;--r>=0&&e.time<t[r].time;);t.splice(r+1,0,e)},iJ.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},iJ.removeBurstByIndex=function(e){this._bursts.splice(e,1)},iJ.clearBurst=function(){this._bursts.length=0},iJ._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},iJ._resetRandomSeed=function(e){this._burstRand.reset(e,ca.Burst),this._shapeRand.reset(e,ca.Shape)},iJ._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},iJ._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,a=e-this._frameRateTime;a>=n;)a-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},iJ._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,a=Math.floor((t-e)/n);if(r.isLoop&&(a>0||t%n<e%n)){var i=Math.ceil(e/n)*n;this._emitBySubBurst(e,i,n),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=n,this._emitBySubBurst(s,i,n),this._currentBurstIndex=0}this._emitBySubBurst(i,t,n)}else this._emitBySubBurst(e,t,n)},iJ._emitBySubBurst=function(e,t,r){for(var n=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,d=i.length;c<d;c++){var u=i[c],h=u.time;if(h>l)break;if(h>=s){var _=u.count.evaluate(void 0,a.random());n._emit(o+h,_)}}this._currentBurstIndex=c},cU(iQ,[{key:"bursts",get:function(){return this._bursts}}]),iQ);cW([cY],_p.prototype,"rateOverTime",void 0),cW([cY],_p.prototype,"rateOverDistance",void 0),cW([cY],_p.prototype,"shape",void 0),cW([cj],_p.prototype,"_shapeRand",void 0),cW([cY],_p.prototype,"_bursts",void 0),cW([cj],_p.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(iZ=e.ParticleScaleMode||(e.ParticleScaleMode={}))[iZ.Hierarchy=0]="Hierarchy",iZ[iZ.Local=1]="Local",iZ[iZ.World=2]="World";var _m=((i0=(i$=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new _f(0),this.startLifetime=new _f(5),this.startSpeed=new _f(5),this.startSize3D=!1,this.startSizeX=new _f(1),this.startSizeY=new _f(1),this.startSizeZ=new _f(1),this.startRotation3D=!1,this.startRotationX=new _f(0),this.startRotationY=new _f(0),this.startRotationZ=new _f(0),this.flipRotation=0,this.startColor=new _u(new cI(1,1,1,1)),this.gravityModifier=new _f(0),this.simulationSpace=e.ParticleSimulationSpace.Local,this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new cN(0,ca.StartSpeed),this._startLifeTimeRand=new cN(0,ca.StartLifetime),this._startColorRand=new cN(0,ca.StartColor),this._startSizeRand=new cN(0,ca.StartSize),this._startRotationRand=new cN(0,ca.StartRotation),this._gravityModifierRand=new cN(0,ca.GravityModifier),this._gravity=new cC,this._generator=t}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,ca.StartSpeed),this._startLifeTimeRand.reset(e,ca.StartLifetime),this._startColorRand.reset(e,ca.StartColor),this._startSizeRand.reset(e,ca.StartSize),this._startRotationRand.reset(e,ca.StartRotation)},i0._getPositionScale=function(){var t=this._generator._renderer.entity.transform;switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:case e.ParticleScaleMode.World:return t.lossyWorldScale;case e.ParticleScaleMode.Local:return t.scale}},i0._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(i$._worldPosition,n.worldPosition);var a=n.worldRotationQuaternion,i=i$._tempVector40;i.copyFrom(a),t.setVector4(i$._worldRotation,i);break;case e.ParticleSimulationSpace.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:var o=n.lossyWorldScale;t.setVector3(i$._positionScale,o),t.setVector3(i$._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(i$._positionScale,o),t.setVector3(i$._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(i$._positionScale,n.lossyWorldScale),t.setVector3(i$._sizeScale,i$._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());cC.scale(r.scene.physics.gravity,l,s),t.setVector3(i$._gravity,s),t.setInt(i$._simulationSpace,this.simulationSpace),t.setFloat(i$._startRotation3D,+this.startRotation3D),t.setInt(i$._scaleMode,this.scalingMode)},i0._cloneTo=function(e){e.maxParticles=this.maxParticles},cU(i$,[{key:"maxParticles",get:function(){return this._maxParticleBuffer-1},set:function(e){this._maxParticleBuffer=e+1}},{key:"startSize",get:function(){return this.startSizeX},set:function(e){this.startSizeX=e}}]),i$);_m._tempVector40=new cB,_m._vector3One=new cC(1,1,1),_m._positionScale=dn.getByName("renderer_PositionScale"),_m._sizeScale=dn.getByName("renderer_SizeScale"),_m._worldPosition=dn.getByName("renderer_WorldPosition"),_m._worldRotation=dn.getByName("renderer_WorldRotation"),_m._gravity=dn.getByName("renderer_Gravity"),_m._simulationSpace=dn.getByName("renderer_SimulationSpace"),_m._startRotation3D=dn.getByName("renderer_ThreeDStartRotation"),_m._scaleMode=dn.getByName("renderer_ScalingMode"),cW([cY],_m.prototype,"startDelay",void 0),cW([cY],_m.prototype,"startLifetime",void 0),cW([cY],_m.prototype,"startSpeed",void 0),cW([cY],_m.prototype,"startSizeX",void 0),cW([cY],_m.prototype,"startSizeY",void 0),cW([cY],_m.prototype,"startSizeZ",void 0),cW([cY],_m.prototype,"startRotationX",void 0),cW([cY],_m.prototype,"startRotationY",void 0),cW([cY],_m.prototype,"startRotationZ",void 0),cW([cY],_m.prototype,"startColor",void 0),cW([cY],_m.prototype,"gravityModifier",void 0),cW([cj],_m.prototype,"_maxParticleBuffer",void 0),cW([cj],_m.prototype,"_startSpeedRand",void 0),cW([cj],_m.prototype,"_startLifeTimeRand",void 0),cW([cj],_m.prototype,"_startColorRand",void 0),cW([cj],_m.prototype,"_startSizeRand",void 0),cW([cj],_m.prototype,"_startRotationRand",void 0),cW([cj],_m.prototype,"_gravityModifierRand",void 0),cW([cj],_m.prototype,"_generator",void 0),cW([cj],_m.prototype,"_gravity",void 0);var _g=(cH(i1=function(){var e;return e=_h.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new _f(0),e.rotationY=new _f(0),e.rotationZ=new _f(45),e._rotationRand=new cN(0,ca.RotationOverLifetime),e._rotationMinConstant=new cC,e._rotationMaxConstant=new cC,e},_h),(i2=i1.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(i1._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(i1._maxCurveXProperty,i.curveMax._getTypeArray()),t.setFloatArray(i1._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(i1._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(i1._minCurveXProperty,i.curveMin._getTypeArray()),t.setFloatArray(i1._minCurveYProperty,o.curveMin._getTypeArray())),a=i1._isRandomTwoMacro),n=i1._curveModeMacro;else{var d=this._rotationMaxConstant;if(d.set(cS.degreeToRadian(i.constantMax),cS.degreeToRadian(o.constantMax),cS.degreeToRadian(s.constantMax)),t.setVector3(i1._maxConstantProperty,d),l?i.mode===e.ParticleCurveMode.TwoConstants&&o.mode===e.ParticleCurveMode.TwoConstants&&s.mode===e.ParticleCurveMode.TwoConstants:s.mode===e.ParticleCurveMode.TwoConstants){var u=this._rotationMinConstant;u.set(cS.degreeToRadian(i.constantMin),cS.degreeToRadian(o.constantMin),cS.degreeToRadian(s.constantMin)),t.setVector3(i1._minConstantProperty,u),a=i1._isRandomTwoMacro}n=i1._constantModeMacro}l&&(r=i1._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},i2._resetRandomSeed=function(e){this._rotationRand.reset(e,ca.RotationOverLifetime)},i1);_g._constantModeMacro=du.getByName("RENDERER_ROL_CONSTANT_MODE"),_g._curveModeMacro=du.getByName("RENDERER_ROL_CURVE_MODE"),_g._isSeparateMacro=du.getByName("RENDERER_ROL_IS_SEPARATE"),_g._isRandomTwoMacro=du.getByName("RENDERER_ROL_IS_RANDOM_TWO"),_g._minConstantProperty=dn.getByName("renderer_ROLMinConst"),_g._minCurveXProperty=dn.getByName("renderer_ROLMinCurveX"),_g._minCurveYProperty=dn.getByName("renderer_ROLMinCurveY"),_g._minCurveZProperty=dn.getByName("renderer_ROLMinCurveZ"),_g._maxConstantProperty=dn.getByName("renderer_ROLMaxConst"),_g._maxCurveXProperty=dn.getByName("renderer_ROLMaxCurveX"),_g._maxCurveYProperty=dn.getByName("renderer_ROLMaxCurveY"),_g._maxCurveZProperty=dn.getByName("renderer_ROLMaxCurveZ"),cW([cY],_g.prototype,"rotationX",void 0),cW([cY],_g.prototype,"rotationY",void 0),cW([cY],_g.prototype,"rotationZ",void 0),cW([cj],_g.prototype,"_rotationRand",void 0),cW([cj],_g.prototype,"_rotationMinConstant",void 0),cW([cj],_g.prototype,"_rotationMaxConstant",void 0),cW([cj],_g.prototype,"_enableSeparateMacro",void 0),cW([cj],_g.prototype,"_isCurveMacro",void 0),cW([cj],_g.prototype,"_isRandomTwoMacro",void 0);var _v=((i4=(i3=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this._keys=[],this._typeArrayDirty=!1;for(var n=0,a=t.length;n<a;n++){var i=t[n];this.addKey(i)}}).prototype).addKey=function(e,t){var r=this._keys;if(4===r.length)throw Error("Curve can only have 4 keys");var n="number"==typeof e?new _y(e,t):e;this._addKey(r,n),this._typeArrayDirty=!0},i4.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0},i4.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},i4._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},i4._addKey=function(e,t){var r=e.length,n=t.time;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},cU(i3,[{key:"keys",get:function(){return this._keys}}]),i3);cW([cY],_v.prototype,"_keys",void 0),cW([cj],_v.prototype,"_typeArray",void 0);var _y=function(e,t){this.time=e,this.value=t},_x=(cH(i8=function(){var e;return e=_h.apply(this,arguments)||this,e.separateAxes=!1,e.sizeX=new _f(new _v(new _y(0,0),new _y(1,1))),e.sizeY=new _f(new _v(new _y(0,0),new _y(1,1))),e.sizeZ=new _f(new _v(new _y(0,0),new _y(1,1))),e},_h),i8.prototype._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:i.mode===e.ParticleCurveMode.TwoCurves;(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:i.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(i8._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(t.setFloatArray(i8._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(i8._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(i8._minCurveXProperty,i.curveMin._getTypeArray()),l&&(t.setFloatArray(i8._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(i8._minCurveZProperty,s.curveMin._getTypeArray())),a=i8._isRandomTwoMacro),n=i8._curveModeMacro),l&&(r=i8._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},cU(i8,[{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),i8);_x._curveModeMacro=du.getByName("RENDERER_SOL_CURVE_MODE"),_x._isSeparateMacro=du.getByName("RENDERER_SOL_IS_SEPARATE"),_x._isRandomTwoMacro=du.getByName("RENDERER_SOL_IS_RANDOM_TWO"),_x._minCurveXProperty=dn.getByName("renderer_SOLMinCurveX"),_x._minCurveYProperty=dn.getByName("renderer_SOLMinCurveY"),_x._minCurveZProperty=dn.getByName("renderer_SOLMinCurveZ"),_x._maxCurveXProperty=dn.getByName("renderer_SOLMaxCurveX"),_x._maxCurveYProperty=dn.getByName("renderer_SOLMaxCurveY"),_x._maxCurveZProperty=dn.getByName("renderer_SOLMaxCurveZ"),cW([cY],_x.prototype,"sizeX",void 0),cW([cY],_x.prototype,"sizeY",void 0),cW([cY],_x.prototype,"sizeZ",void 0),cW([cj],_x.prototype,"_enableSeparateMacro",void 0),cW([cj],_x.prototype,"_isCurveMacro",void 0),cW([cj],_x.prototype,"_isRandomTwoMacro",void 0);var _b=(cH(i5=function(){var e;return e=_h.apply(this,arguments)||this,e.startFrame=new _f(0),e.frameOverTime=new _f(new _v(new _y(0,0),new _y(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new cC(1,1,1),e._frameOverTimeRand=new cN(0,ca.TextureSheetAnimation),e._tiling=new cD(1,1),e},_h),(i9=i5.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.frameOverTime.mode;if(n===e.ParticleCurveMode.Curve||n===e.ParticleCurveMode.TwoCurves){var a=this.frameOverTime;t.setFloatArray(i5._frameMaxCurveProperty,a.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=i5._frameCurveMacro:(t.setFloatArray(i5._frameMinCurveProperty,a.curveMin._getTypeArray()),r=i5._frameRandomCurvesMacro),t.setFloat(i5._cycleCountProperty,this.cycleCount),t.setVector3(i5._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},i9._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,ca.TextureSheetAnimation)},cU(i5,[{key:"tiling",get:function(){return this._tiling},set:function(e){this._tiling=e,this._tillingInfo.set(1/e.x,1/e.y,e.x*e.y)}}]),i5);_b._frameCurveMacro=du.getByName("RENDERER_TSA_FRAME_CURVE"),_b._frameRandomCurvesMacro=du.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),_b._cycleCountProperty=dn.getByName("renderer_TSACycles"),_b._tillingParamsProperty=dn.getByName("renderer_TSATillingParams"),_b._frameMinCurveProperty=dn.getByName("renderer_TSAFrameMinCurve"),_b._frameMaxCurveProperty=dn.getByName("renderer_TSAFrameMaxCurve"),cW([cY],_b.prototype,"startFrame",void 0),cW([cY],_b.prototype,"frameOverTime",void 0),cW([cq],_b.prototype,"_tillingInfo",void 0),cW([cj],_b.prototype,"_frameOverTimeRand",void 0),cW([cY],_b.prototype,"_tiling",void 0),cW([cj],_b.prototype,"_textureSheetMacro",void 0),(i6=ci||(ci={}))[i6.WholeSheet=0]="WholeSheet",i6[i6.SingleRow=1]="SingleRow";var _S=(cH(i7=function(){var t;return t=_h.apply(this,arguments)||this,t.velocityX=new _f(0),t.velocityY=new _f(0),t.velocityZ=new _f(0),t.space=e.ParticleSimulationSpace.Local,t._velocityRand=new cN(0,ca.VelocityOverLifetime),t._velocityMinConstant=new cC,t._velocityMaxConstant=new cC,t},_h),(oe=i7.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,a=this.velocityY,i=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve)t.setFloatArray(i7._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(i7._maxGradientYProperty,a.curveMax._getTypeArray()),t.setFloatArray(i7._maxGradientZProperty,i.curveMax._getTypeArray()),o?(t.setFloatArray(i7._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(i7._minGradientYProperty,a.curveMin._getTypeArray()),t.setFloatArray(i7._minGradientZProperty,i.curveMin._getTypeArray()),r=i7._randomCurveMacro):r=i7._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,a.constantMax,i.constantMax),t.setVector3(i7._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,a.constantMin,i.constantMin),t.setVector3(i7._minConstantProperty,l),r=i7._randomConstantMacro}else r=i7._constantMacro}t.setInt(i7._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},oe._resetRandomSeed=function(e){this._velocityRand.reset(e,ca.VelocityOverLifetime)},i7);_S._constantMacro=du.getByName("RENDERER_VOL_CONSTANT"),_S._curveMacro=du.getByName("RENDERER_VOL_CURVE"),_S._randomConstantMacro=du.getByName("RENDERER_VOL_RANDOM_CONSTANT"),_S._randomCurveMacro=du.getByName("RENDERER_VOL_RANDOM_CURVE"),_S._minConstantProperty=dn.getByName("renderer_VOLMinConst"),_S._maxConstantProperty=dn.getByName("renderer_VOLMaxConst"),_S._minGradientXProperty=dn.getByName("renderer_VOLMinGradientX"),_S._minGradientYProperty=dn.getByName("renderer_VOLMinGradientY"),_S._minGradientZProperty=dn.getByName("renderer_VOLMinGradientZ"),_S._maxGradientXProperty=dn.getByName("renderer_VOLMaxGradientX"),_S._maxGradientYProperty=dn.getByName("renderer_VOLMaxGradientY"),_S._maxGradientZProperty=dn.getByName("renderer_VOLMaxGradientZ"),_S._spaceProperty=dn.getByName("renderer_VOLSpace"),cW([cY],_S.prototype,"velocityX",void 0),cW([cY],_S.prototype,"velocityY",void 0),cW([cY],_S.prototype,"velocityZ",void 0),cW([cj],_S.prototype,"_velocityRand",void 0),cW([cj],_S.prototype,"_velocityMinConstant",void 0),cW([cj],_S.prototype,"_velocityMaxConstant",void 0),cW([cj],_S.prototype,"_velocityMacro",void 0);var _C=function(){function t(r){this.useAutoRandomSeed=!0,this.main=new _m(this),this.emission=new _p(this),this.velocityOverLifetime=new _S(this),this.sizeOverLifetime=new _x(this),this.rotationOverLifetime=new _g(this),this.colorOverLifetime=new __(this),this.textureSheetAnimation=new _b(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new dz(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._renderer=r,new _o().start=0,this._primitive=new dU(r.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,t._particleIncreaseCount),this.emission.enabled=!0}var r=t.prototype;return r.play=function(e){if(void 0===e&&(e=!0),e)for(var r=this._renderer.entity.getComponentsIncludeChildren(_s,t._tempParticleRenderers),n=0,a=r.length;n<a;n++)r[n].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(4294967295*Math.random()))},r.stop=function(r,n){if(void 0===r&&(r=!0),void 0===n&&(n=e.ParticleStopMode.StopEmitting),r)for(var a=this._renderer.entity.getComponentsIncludeChildren(_s,t._tempParticleRenderers),i=0,o=a.length;i<o;i++)a[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===e.ParticleStopMode.StopEmittingAndClear){var s=this._firstFreeElement;this._firstRetiredElement=s,this._firstActiveElement=s,this._firstNewElement=s,this._playTime=0,this.emission._reset()}},r.emit=function(e){this._emit(this._playTime,e)},r._emit=function(e,r){if(this.emission.enabled&&!(this.main._maxParticleBuffer<this._currentParticleCount))for(var n=t._tempVector30,a=t._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,e,n,a);var l=this.main._getPositionScale();n.multiply(l),a.normalize().multiply(l)}else n.set(0,0,0),a.set(0,0,-1);this._addNewParticle(n,a,i,e)}},r._update=function(e){var t=this.main,r=this.emission,n=t.duration,a=this._playTime;if(this._playTime+=e*t.simulationSpeed,this._retireActiveParticles(),this._freeRetiredParticles(),r.enabled&&this._isPlaying&&(this._currentParticleCount>t._maxParticleBuffer&&this._getNotRetiredParticleCount()<t._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(a,this._playTime),!t.isLoop&&this._playTime>n&&(this._isPlaying=!1)),!this.isAlive){var i=Math.min(r._frameRateTime,Math.floor(this._playTime/n)*n);this._playTime-=i,r._frameRateTime-=i}(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},r._reorganizeGeometryBuffers=function(){var t=this._renderer,r=t.engine._particleBufferUtils,n=this._primitive,a=this._vertexBufferBindings;if(n.clearVertexElements(),a.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var i=t.mesh;if(!i)return;var o=i.getVertexElement(e.VertexAttribute.Position),s=i.getVertexElement(e.VertexAttribute.Color),l=i.getVertexElement(e.VertexAttribute.UV),c=o?i.vertexBufferBindings[o.bindingIndex]:null,d=s?i.vertexBufferBindings[s.bindingIndex]:null,u=l?i.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,a);n.addVertexElement(new dW(e.VertexAttribute.Position,o.offset,o.format,h))}if(d){var _=this._addVertexBufferBindingsFilterDuplicate(d,a);n.addVertexElement(new dW(e.VertexAttribute.Color,s.offset,s.format,_))}if(u){var f=this._addVertexBufferBindingsFilterDuplicate(u,a);n.addVertexElement(new dW(e.VertexAttribute.UV,l.offset,l.format,f))}var p=i._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),a.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=r.billboardIndexCount;n.setVertexBufferBindings(a);for(var m=r.instanceVertexElements,g=a.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new dW(x.attribute,x.offset,x.format,g,x.instanceStepRate))}},r._resizeInstanceBuffer=function(t,r){null==(_=this._instanceVertexBufferBinding)||_.buffer.destroy();var n=this._renderer.engine._particleBufferUtils,a=n.instanceVertexStride,i=t?this._currentParticleCount+r:this.main._maxParticleBuffer,o=a*i,s=this._renderer.engine,l=new dO(s,e.BufferBindFlag.VertexBuffer,o,e.BufferUsage.Dynamic,!1);l.isGCIgnored=!0;var c=this._primitive.vertexBufferBindings,d=new dH(l,a),u=new Float32Array(o/4),h=this._instanceVertices;if(h){var _,f,p,m=n.instanceVertexFloatStride,g=this._firstFreeElement,v=this._firstRetiredElement;if(t){var y=this._firstFreeElement*m;u.set(new Float32Array(h.buffer,0,y));var x=(this._firstFreeElement+r)*m;u.set(new Float32Array(h.buffer,4*y),x),this._firstNewElement>g&&(this._firstNewElement+=r),this._firstActiveElement>g&&(this._firstActiveElement+=r),v>g&&(this._firstRetiredElement+=r)}else v<=g?(f=g-v,p=0,this._firstFreeElement-=v,this._firstNewElement-=v,this._firstActiveElement-=v,this._firstRetiredElement=0):(f=this._currentParticleCount-v,p=g,this._firstNewElement>g&&(this._firstNewElement-=g),this._firstActiveElement>g&&(this._firstActiveElement-=g),v>g&&(this._firstRetiredElement-=g)),u.set(new Float32Array(h.buffer,v*m*4,f*m),p*m);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(h?c.length-1:c.length,d),this._instanceVertices=u,this._instanceVertexBufferBinding=d,this._currentParticleCount=i},r._updateShaderData=function(e){this.main._updateShaderData(e),this.velocityOverLifetime._updateShaderData(e),this.textureSheetAnimation._updateShaderData(e),this.sizeOverLifetime._updateShaderData(e),this.rotationOverLifetime._updateShaderData(e),this.colorOverLifetime._updateShaderData(e)},r._resetGlobalRandSeed=function(e){this._randomSeed=e,this.main._resetRandomSeed(e),this.emission._resetRandomSeed(e),this.textureSheetAnimation._resetRandomSeed(e),this.velocityOverLifetime._resetRandomSeed(e),this.rotationOverLifetime._resetRandomSeed(e),this.colorOverLifetime._resetRandomSeed(e)},r._getAliveParticleCount=function(){if(this._firstActiveElement<=this._firstFreeElement)return this._firstFreeElement-this._firstActiveElement;var e=this._currentParticleCount-this._firstActiveElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},r._getNotRetiredParticleCount=function(){if(this._firstRetiredElement<=this._firstFreeElement)return this._firstFreeElement-this._firstRetiredElement;var e=this._currentParticleCount-this._firstRetiredElement;return this._firstFreeElement>0&&(e+=this._firstFreeElement),e},r._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy()},r._addNewParticle=function(r,n,a,i){var o,s,l=this._firstFreeElement,c=l+1;c>=this._currentParticleCount&&(c=0);var d=this.main;if(c===this._firstRetiredElement){var u=Math.min(t._particleIncreaseCount,d._maxParticleBuffer-this._currentParticleCount);if(0===u)return;this._resizeInstanceBuffer(!0,u),c=l+1}d.simulationSpace===e.ParticleSimulationSpace.World&&(o=a.worldPosition,s=a.worldRotationQuaternion);var h=this._renderer.engine._particleBufferUtils,_=d.startSpeed.evaluate(void 0,d._startSpeedRand.random()),f=this._instanceVertices,p=l*h.instanceVertexFloatStride;f[p]=r.x,f[p+1]=r.y,f[p+2]=r.z,f[p+h.startLifeTimeOffset]=d.startLifetime.evaluate(void 0,d._startLifeTimeRand.random()),f[p+4]=n.x,f[p+5]=n.y,f[p+6]=n.z,f[p+h.timeOffset]=i;var m=t._tempColor0;d.startColor.evaluate(void 0,d._startColorRand.random(),m),this._renderer.engine.settings.colorSpace===e.ColorSpace.Linear&&m.toLinear(m),f[p+8]=m.r,f[p+9]=m.g,f[p+10]=m.b,f[p+11]=m.a;var g=d._startSizeRand;if(d.startSize3D)f[p+12]=d.startSizeX.evaluate(void 0,g.random()),f[p+13]=d.startSizeY.evaluate(void 0,g.random()),f[p+14]=d.startSizeZ.evaluate(void 0,g.random());else{var v=d.startSize.evaluate(void 0,g.random());f[p+12]=v,f[p+13]=v,f[p+14]=v}var y=d._startRotationRand;d.startRotation3D?(f[p+15]=cS.degreeToRadian(d.startRotationX.evaluate(void 0,y.random())),f[p+16]=cS.degreeToRadian(d.startRotationY.evaluate(void 0,y.random())),f[p+17]=cS.degreeToRadian(d.startRotationZ.evaluate(void 0,y.random()))):f[p+15]=cS.degreeToRadian(d.startRotationZ.evaluate(void 0,y.random())),f[p+18]=_;var x=this.colorOverLifetime;x.enabled&&x.color.mode===e.ParticleGradientMode.TwoGradients&&(f[p+20]=x._colorGradientRand.random());var b=this.rotationOverLifetime;b.enabled&&b.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(f[p+22]=b._rotationRand.random());var S=this.textureSheetAnimation;S.enabled&&S.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(f[p+23]=S._frameOverTimeRand.random());var C=this.velocityOverLifetime;if(C.enabled&&C.velocityX.mode===e.ParticleCurveMode.TwoConstants&&C.velocityY.mode===e.ParticleCurveMode.TwoConstants&&C.velocityZ.mode===e.ParticleCurveMode.TwoConstants){var T=C._velocityRand;f[p+24]=T.random(),f[p+25]=T.random(),f[p+26]=T.random()}if(this.main.simulationSpace===e.ParticleSimulationSpace.World&&(f[p+27]=o.x,f[p+28]=o.y,f[p+29]=o.z,f[p+30]=s.x,f[p+31]=s.y,f[p+32]=s.z,f[p+33]=s.w),this.textureSheetAnimation.enabled){var A=this.textureSheetAnimation._tillingInfo;f[p+h.simulationUVOffset]=A.x,f[p+35]=A.y,f[p+36]=0,f[p+37]=0}else f[p+h.simulationUVOffset]=1,f[p+35]=1,f[p+36]=0,f[p+37]=0;this._firstFreeElement=c},r._retireActiveParticles=function(){for(var e=this._renderer.engine,t=e._particleBufferUtils,r=e.time.frameCount,n=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var a=this._firstActiveElement*t.instanceVertexFloatStride,i=a+t.timeOffset;if(Math.fround(this._playTime-n[i])<n[a+t.startLifeTimeOffset])break;n[i]=r,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},r._freeRetiredParticles=function(){for(var e=this._renderer.engine._particleBufferUtils,t=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var r=this._firstRetiredElement*e.instanceVertexFloatStride+e.startLifeTimeOffset;if(t-this._instanceVertices[r]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},r._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,r=this._firstFreeElement;if(t!==r){var n=this._renderer.engine._particleBufferUtils.instanceVertexStride,a=t*n,i=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)i.setData(o,0,a,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;i.setData(o,0,a,s,e.SetDataOptions.Discard),r>0&&i.setData(o,s,0,r*n)}this._firstNewElement=r,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},r._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return t.push(e),r},cU(t,[{key:"isAlive",get:function(){return!!this._isPlaying||this._firstActiveElement!==this._firstFreeElement}},{key:"randomSeed",get:function(){return this._randomSeed},set:function(e){this._resetGlobalRandSeed(e),this.useAutoRandomSeed=!1}}]),t}();_C._tempVector30=new cC,_C._tempVector31=new cC,_C._tempColor0=new cI,_C._tempParticleRenderers=[],_C._particleIncreaseCount=128,cW([cY],_C.prototype,"main",void 0),cW([cY],_C.prototype,"emission",void 0),cW([cY],_C.prototype,"velocityOverLifetime",void 0),cW([cY],_C.prototype,"sizeOverLifetime",void 0),cW([cY],_C.prototype,"rotationOverLifetime",void 0),cW([cY],_C.prototype,"colorOverLifetime",void 0),cW([cY],_C.prototype,"textureSheetAnimation",void 0),cW([cj],_C.prototype,"_playTime",void 0),cW([cj],_C.prototype,"_firstNewElement",void 0),cW([cj],_C.prototype,"_firstActiveElement",void 0),cW([cj],_C.prototype,"_firstFreeElement",void 0),cW([cj],_C.prototype,"_firstRetiredElement",void 0),cW([cj],_C.prototype,"_primitive",void 0),cW([cj],_C.prototype,"_vertexBufferBindings",void 0),cW([cj],_C.prototype,"_subPrimitive",void 0),cW([cj],_C.prototype,"_renderer",void 0),cW([cj],_C.prototype,"_isPlaying",void 0),cW([cj],_C.prototype,"_instanceBufferResized",void 0),cW([cj],_C.prototype,"_waitProcessRetiredElementCount",void 0),cW([cj],_C.prototype,"_instanceVertexBufferBinding",void 0),cW([cj],_C.prototype,"_instanceVertices",void 0);var _T=(cH(ot=function(e){var t;return(t=uC.call(this,e,dw.find("particle-shader"))||this).shaderData.setColor(uC._baseColorProp,new cI(1,1,1,1)),t.isTransparent=!0,t},uC),ot.prototype.clone=function(){var e=new ot(this._engine);return this.cloneTo(e),e},cU(ot,[{key:"baseColor",get:function(){return this.shaderData.getColor(uC._baseColorProp)},set:function(e){var t=this.shaderData.getColor(uC._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(uC._baseTextureProp)},set:function(e){this.shaderData.setTexture(uC._baseTextureProp,e),e?this.shaderData.enableMacro(uC._baseTextureMacro):this.shaderData.disableMacro(uC._baseTextureMacro)}}]),ot),_A=function(e,t){this.time=e,this.count=t};cW([cY],_A.prototype,"count",void 0);var _M=((or=function(){this.enabled=!0,this.randomDirectionAmount=0}).prototype._generatePositionAndDirection=function(e,t,r,n){throw Error("BaseShape: must override it.")},or),_E=((on=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},on.randomPointInsideUnitArcCircle=function(e,t,r){on.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},on.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},on.randomPointInsideUnitCircle=function(e,t){on.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},on._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,a=Math.sqrt(1-r*r);e.x=a*Math.cos(n),e.y=a*Math.sin(n),e.z=r},on._randomPointInsideUnitSphere=function(e,t){on._randomPointUnitSphere(e,t);var r=Math.pow(t.random(),1/3);e.x=e.x*r,e.y=e.y*r,e.z=e.z*r},on._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},on);e.ParticleShapeType=void 0,(oa=e.ParticleShapeType||(e.ParticleShapeType={}))[oa.Box=0]="Box",oa[oa.Circle=1]="Circle",oa[oa.Cone=2]="Cone",oa[oa.Hemisphere=3]="Hemisphere",oa[oa.Sphere=4]="Sphere";var _R=(cH(oi=function(){var t;return t=_M.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Box,t.size=new cC(1,1,1),t},_M),oi.prototype._generatePositionAndDirection=function(e,t,r,n){_E._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=oi._tempVector30;a.set(0,0,-1),_E._randomPointUnitSphere(n,e),cC.lerp(a,n,this.randomDirectionAmount,n)},oi);_R._tempVector30=new cC,cW([cY],_R.prototype,"size",void 0),e.ParticleShapeArcMode=void 0,(oo=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[oo.Random=0]="Random",oo[oo.Loop=1]="Loop";var _w=(cH(os=function(){var t;return t=_M.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Circle,t.radius=1,t.arc=360,t.arcMode=e.ParticleShapeArcMode.Random,t.arcSpeed=1,t},_M),os.prototype._generatePositionAndDirection=function(t,r,n,a){var i=os._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=cS.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(t.random());break;case e.ParticleShapeArcMode.Random:_E.randomPointInsideUnitArcCircle(cS.degreeToRadian(this.arc),i,t)}n.set(i.x,i.y,0),n.scale(this.radius),_E._randomPointUnitSphere(a,t),cC.lerp(n,a,this.randomDirectionAmount,a)},os);_w._tempPositionPoint=new cD;var _P=(cH(ol=function(){var t;return t=_M.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Cone,t.angle=25,t.radius=1,t.length=5,t.emitType=0,t},_M),ol.prototype._generatePositionAndDirection=function(e,t,r,n){var a=ol._tempVector20,i=cS.degreeToRadian(this.angle),o=Math.sin(i),s=Math.cos(i);switch(this.emitType){case 0:_E.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var l=ol._tempVector21;_E.randomPointInsideUnitCircle(l,e),cD.lerp(a,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:_E.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0),n.set(a.x*o,a.y*o,-s),n.normalize();var c=ol._tempVector30;cC.scale(n,this.length*e.random(),c),r.add(c);var d=ol._tempVector31;_E._randomPointUnitSphere(d,e),cC.lerp(n,d,this.randomDirectionAmount,n)}},ol);_P._tempVector20=new cD,_P._tempVector21=new cD,_P._tempVector30=new cC,_P._tempVector31=new cC,e.ConeEmitType=void 0,(oc=e.ConeEmitType||(e.ConeEmitType={}))[oc.Base=0]="Base",oc[oc.Volume=1]="Volume";var _F=(cH(od=function(){var t;return t=_M.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Hemisphere,t.radius=1,t},_M),od.prototype._generatePositionAndDirection=function(e,t,r,n){_E._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var a=r.z;a>0&&(r.z=-a),_E._randomPointUnitSphere(n,e),cC.lerp(r,n,this.randomDirectionAmount,n)},od),_L=(cH(ou=function(){var t;return t=_M.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Sphere,t.radius=1,t},_M),ou.prototype._generatePositionAndDirection=function(e,t,r,n){_E._randomPointInsideUnitSphere(r,e),r.scale(this.radius),_E._randomPointUnitSphere(n,e),cC.lerp(r,n,this.randomDirectionAmount,n)},ou);dw.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;void main(){gl_Position=camera_ProjMat*camera_ViewMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nvarying vec2 v_uv;uniform sampler2D u_texture;void main(void){gl_FragColor=texture2D(u_texture,v_uv);}");var _D=(cH(oh=function(t){var r,n=(r=uS.call(this,t,dw.find("trail"))||this).renderState.blendState.targetBlendState;return n.enabled=!0,n.sourceColorBlendFactor=n.sourceAlphaBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=n.destinationAlphaBlendFactor=e.BlendFactor.One,r.renderState.depthState.writeEnabled=!1,r},uS),oh),_B=new cC,_I=(cH(o_=function(e,t){(r=dq.call(this,e)||this)._stroke=t.stroke||.2,r._minSeg=t.minSeg||.02,r._lifetime=t.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*e.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var r,n=0;n<r._maxPointNum;n++)r._points.push(new cC),r._pointStates.push(r._lifetime),r._strapPoints.push(new cC),r._strapPoints.push(new cC);r._curPointNum=0;var a=t.material||new _D(r.engine);return r.setMaterial(a),r.setTexture(t.texture),r._initGeometry(),r},dq),(of=o_.prototype).update=function(e){for(var t=0,r=0,n=0;n<this._curPointNum;n++)this._pointStates[n]-=e,this._pointStates[n]<0?t++:t>0&&(r=n-t,this._pointStates[r]=this._pointStates[n],this._points[r].copyFrom(this._points[n]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];cC.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},of.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},of._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),dq.prototype._render.call(this,e)},of._initGeometry=function(){var t=new dX(this._entity.engine),r=2*this._maxPointNum,n=20*r,a=new Float32Array(n),i=[new dW("POSITION",0,e.VertexElementFormat.Vector3,0),new dW("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new dO(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(i),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=a,this.mesh=t},of._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new cC(r[0],r[4],r[8]),a=new cC(r[1],r[5],r[9]),i=new cC(r[2],r[6],r[10]),o=this._stroke;a.scale(o);var s=new cC,l=new cC,c=new cP;cC.transformByQuat(n,c,n),cC.transformByQuat(a,c,a);var d=new cC,u=new cC,h=new cC;n.normalize();for(var _=this._vertices,f=0;f<this._maxPointNum;f++){if(f<this._curPointNum){var p=t[f];f===this._curPointNum-1&&0!==f?cC.subtract(p,t[f-1],h):cC.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(cC.dot(n,h));cC.cross(n,h,u),0>=cC.dot(u,i)&&(m=2*Math.PI-m),cP.rotationAxisAngle(i,m,c),cC.transformByQuat(a,c,d),cC.add(p,d,s),cC.subtract(p,d,l)}var g=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[g]=s.x,_[g+1]=s.y,_[g+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},of._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,r=this._vertices,n=0;n<e;n++){var a=1-n*t,i=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[i]=0,r[i+1]=a,r[o]=1,r[o+1]=a}}},of._projectOnVector=function(e,t,r){var n=t.clone();cC.normalize(n,n);var a=cC.dot(e,n);r.x=n.x*a,r.y=n.y*a,r.z=n.z*a},of._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,_B),cC.subtract(e,_B,r)},o_),_V=(cH(op=function(){var t;return t=hT.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},hT),(om=op.prototype).onTextureChange=function(e){},om.onBeginRender=function(t){this.enabled&&(this._camera=t,this._oriCameraCullingMask=t.cullingMask,t.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new dY(this.engine,this.width,this.height,this._isCube?new dZ(this.engine,this.width):new dQ(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new dY(this.engine,this.width,this.height,this._isCube?new dZ(this.engine,this.width):new dQ(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},om.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},om._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},cU(op,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),op),_O=new cC,_N=new cC,_k=new cC,_z=(cH(og=function(){var e;return e=_V.apply(this,arguments)||this,e.position=new cC(0,0,0),e._isCube=!0,e.oriViewMatrix=new cF,e},_V),(ov=og.prototype).onBeginRender=function(t){if(this.enabled){_V.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var r=0;r<6;r++)this._setCamera(r,t),t.render(e.TextureCubeFace.PositiveX+r);this._restoreCamera(t),_V.prototype._reset.call(this)}},ov._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ov._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ov._setCamera=function(e,t){switch(e){case 0:_N.set(0,-1,0),_k.set(1,0,0);break;case 1:_N.set(0,-1,0),_k.set(-1,0,0);break;case 2:_N.set(0,0,1),_k.set(0,1,0);break;case 3:_N.set(0,0,-1),_k.set(0,-1,0);break;case 4:_N.set(0,-1,0),_k.set(0,0,1);break;case 5:_N.set(0,-1,0),_k.set(0,0,-1)}cC.add(this.position,_k,_O),cF.lookAt(this.position,_O,_N,t.viewMatrix),t.fieldOfView=90},og),_U=Object.freeze({__proto__:null,AmbientLight:hg,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:hZ,AnimationClipCurveBinding:hQ,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:h$,AnimationEvent:hJ,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:h8,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:h5,AnimatorControllerLayer:h9,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorLayerMask:_n,AnimatorState:h7,AnimatorStateMachine:_e,AnimatorStateTransition:h1,AssetPromise:uz,get AssetType(){return e.AssetType},Background:hp,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uC,Basic2DBatcher:ud,BasicRenderPipeline:hV,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:dj,BlendShapeFrame:dK,BlendState:dT,BlinnPhongMaterial:uT,BoolUpdateFlag:dc,BoxColliderShape:he,BoxShape:_R,Buffer:dO,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:dX,get BufferUsage(){return e.BufferUsage},BufferUtil:dN,Burst:_A,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},get CameraType(){return e.CameraType},Canvas:h_,CapsuleColliderShape:hn,CharacterController:uZ,CircleShape:_w,CloneManager:cQ,get Collider(){return e.Collider},ColliderShape:u7,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:__,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:di,get ConeEmitType(){return e.ConeEmitType},ConeShape:_P,ContentRestorer:d2,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:_z,get CullMode(){return e.CullMode},CurveKey:_y,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:dA,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:hy,get Downsampling(){return e.Downsampling},DynamicCollider:u$,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:_p,Engine:hh,EngineObject:cJ,Entity:uo,EventDispatcher:c5,FixedJoint:u4,get FogMode(){return e.FogMode},Font:uv,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:_d,GradientColorKey:_c,HemisphereShape:_F,HingeJoint:u8,HitResult:u0,IndexBufferBinding:dk,get IndexFormat(){return e.IndexFormat},InputManager:ho,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:u9,JointMotor:u6,Keyframe:_t,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:hv,Loader:hG,Logger:dr,get MSAASamples(){return e.MSAASamples},MainModule:_m,Material:uS,Mesh:dG,MeshRenderer:dq,get MeshTopology(){return e.MeshTopology},ModelMesh:d0,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uA,PBRMaterial:uM,PBRSpecularMaterial:uE,ParticleCompositeCurve:_f,ParticleCompositeGradient:_u,ParticleCurve:_v,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:_C,ParticleGradient:_l,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_T,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:_s,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleShapeType(){return e.ParticleShapeType},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:u1,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:uJ,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:hr,get Platform(){return e.Platform},PointLight:hx,Pointer:uj,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:dU,PrimitiveMesh:un,Probe:_V,RasterState:dM,ReferResource:cZ,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderQueue:hR,get RenderQueueType(){return e.RenderQueueType},RenderState:dR,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:dY,RenderTargetBlendState:dC,get Renderer(){return e.Renderer},get ReplacementFailureStrategy(){return e.ReplacementFailureStrategy},ResourceManager:uU,RotationOverLifetimeModule:_g,Scene:hC,SceneManager:uk,Script:hT,get SetDataOptions(){return e.SetDataOptions},Shader:dw,ShaderData:dL,ShaderFactory:dp,ShaderLib:df,ShaderMacro:du,ShaderMacroCollection:dh,ShaderPass:db,ShaderProperty:dn,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:dm,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:_x,Skin:us,SkinnedMeshRenderer:ul,Sky:hf,SkyBoxMaterial:_a,SkyProceduralMaterial:_i,SphereColliderShape:ht,SphereShape:_L,SpotLight:hb,SpringJoint:u5,Sprite:c8,SpriteAtlas:c$,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:uf,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:u_,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:h6,StaticCollider:u2,get StencilOperation(){return e.StencilOperation},StencilState:dE,SubMesh:dz,SubShader:dS,get SunMode(){return e.SunMode},SystemInfo:uY,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:ub,TextUtils:um,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:dF,Texture2D:dQ,Texture2DArray:dJ,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:dZ,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:_b,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:da,TrailMaterial:_D,TrailRenderer:_I,Transform:dd,UnlitMaterial:uR,Utils:c0,VelocityOverLifetimeModule:_S,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:dH,VertexElement:dW,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},XRManager:hu,assignmentClone:cX,deepClone:cY,dependentComponents:dl,ignoreClone:cj,request:hz,resourceLoader:uG,shallowClone:cq});function _G(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _H(e,t,r){return t&&_G(e.prototype,t),r&&_G(e,r),e}function _W(e,t){return(_W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _K(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_W(e,t)}function _j(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oy=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oy.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oy[oy.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oy[oy.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oy[oy.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oy[oy.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oy[oy.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oy[oy.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oy[oy.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oy[oy.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oy[oy.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oy[oy.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oy[oy.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oy[oy.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oy[oy.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oy[oy.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oy[oy.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oy[oy.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oy[oy.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oy[oy.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oy[oy.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oy[oy.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oy[oy.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oy[oy.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oy[oy.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oy[oy.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oy[oy.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oy[oy.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oy[oy.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oy[oy.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oy[oy.R11_EAC=37488]="R11_EAC",oy[oy.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oy[oy.RG11_EAC=37490]="RG11_EAC",oy[oy.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oy[oy.RGB8_ETC2=37492]="RGB8_ETC2",oy[oy.SRGB8_ETC2=37493]="SRGB8_ETC2",oy[oy.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oy[oy.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oy[oy.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oy[oy.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oy[oy.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oy[oy.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oy[oy.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oy[oy.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oy[oy.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oy[oy.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oy[oy.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oy[oy.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oy[oy.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oy[oy.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oy[oy.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oy[oy.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var _X=(_K(ox=function(e){(t=h_.call(this)||this)._scale=new cD;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},h_),(ob=ox.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!_j(t,OffscreenCanvas)){var r=t.clientWidth*e,n=t.clientHeight*e;this.width=r,this.height=n}},ob.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},ob._onWidthChanged=function(e){this._webCanvas.width=e},ob._onHeightChange=function(e){this._webCanvas.height=e},_H(ox,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&_j(e,OffscreenCanvas)||this._scale.set(e.clientWidth*devicePixelRatio/e.width,e.clientHeight*devicePixelRatio/e.height),this._scale},set:function(e){var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&_j(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),ox),_q=(_K(oS=function(){return hh.apply(this,arguments)},hh),oS.create=function(e){var t=e.canvas,r=new _X("string"==typeof t?document.getElementById(t):t),n=new _5(e.graphicDeviceOptions),a=new oS(r,n,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new hC(a,"DefaultScene")),a})},_H(oS,[{key:"canvas",get:function(){return this._canvas}}]),oS);function _Y(){return(_Y=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}var _Q=((oT=(oC=function(t,r,n,a,i){void 0===a&&(a=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,a),c=r===e.BufferBindFlag.VertexBuffer?o.ARRAY_BUFFER:o.ELEMENT_ARRAY_BUFFER;this._gl=o,this._glBuffer=s,this._glBufferUsage=l,this._glBindTarget=c,this._isWebGL2=t.isWebGL2,this.bind(),i?o.bufferData(c,i,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},oT.setData=function(t,r,n,a,i,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=r.BYTES_PER_ELEMENT||1,d=i?c*i:r.byteLength;if(0!==a||d<r.byteLength){var u=void 0!==r.byteOffset;if(this._isWebGL2&&u)s.bufferSubData(l,n,r,a,d/c);else{var h=new Uint8Array(u?r.buffer:r,a*c,d);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},oT.getData=function(e,t,r,n){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},oT.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},oT._getGLBufferUsage=function(t,r){switch(r){case e.BufferUsage.Static:return t.STATIC_DRAW;case e.BufferUsage.Dynamic:return t.DYNAMIC_DRAW;case e.BufferUsage.Stream:return t.STREAM_DRAW}},oC),_J=((oM=(oA=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oM.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,a=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR,o=e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,s=e.GLCompressedTextureInternalFormat.R11_EAC,l=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC,c=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,d=e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,u=e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,h=e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,_=e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,f=e.GLCompressedTextureInternalFormat.RGB_BPTC_UNSIGNED_FLOAT_EXT;return t>=r&&n<=n||t>=a&&t<=i?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=d?this.canIUse(e.GLCapabilityType.pvrtc):t>=u&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oM._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),a=e.GLCapabilityType.shaderVertexID,i=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,d=e.GLCapabilityType.instancedArrays,u=e.GLCapabilityType.multipleSample,h=e.GLCapabilityType.drawBuffers,_=e.GLCapabilityType.blendMinMax,f=e.GLCapabilityType.astc,p=e.GLCapabilityType.astc_webkit,m=e.GLCapabilityType.etc,g=e.GLCapabilityType.etc_webkit,v=e.GLCapabilityType.etc1,y=e.GLCapabilityType.etc1_webkit,x=e.GLCapabilityType.pvrtc,b=e.GLCapabilityType.pvrtc_webkit,S=e.GLCapabilityType.s3tc,C=e.GLCapabilityType.s3tc_webkit,T=e.GLCapabilityType.bptc,A=e.GLCapabilityType.textureFloat,M=e.GLCapabilityType.textureHalfFloat,E=e.GLCapabilityType.textureFloatLinear,R=e.GLCapabilityType.textureHalfFloatLinear,w=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic,D=e.GLCapabilityType.fragDepth;t.set(a,r),t.set(i,r||!!n(i)),t.set(o,r||!!n(o)),t.set(s,r||!!n(s)),t.set(l,r||!!n(l)),t.set(c,r||!!n(c)),t.set(d,r||!!n(d)),t.set(u,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(A,r||!!n(A)),t.set(M,r||!!n(M)),t.set(E,!!n(E)),t.set(R,r||!!n(R)),t.set(P,r&&!!n(P)||!!n(w)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),t.set(D,r||!!n(D)),t.set(f,!!(n(f)||n(p))),t.set(m,!!(n(m)||n(g))),t.set(v,!!(n(v)||n(y))),t.set(x,!!(n(x)||n(b))),t.set(S,!!(n(S)||n(C))),t.set(T,!!n(T))},oM._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,a=null;if(a=r.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?n[i]=o.bind(a):n[i]=o}},oM._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,a=e.GLCapabilityType.drawBuffers,i=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat,c=e.GLCapabilityType.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(c,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(r,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var d={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var u=this.maxDrawBuffers,h=0;h<u;h++)0!=h&&(d["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),d["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(a,_Y({drawBuffers:"drawBuffersWEBGL"},d))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},_H(oA,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(e.GLCapabilityType.shaderVertexID)&&this.canIUse(e.GLCapabilityType.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(e.GLCapabilityType.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(e.GLCapabilityType.drawBuffers)?this._maxDrawBuffers=this._rhi.gl.getParameter(this._rhi.gl.MAX_DRAW_BUFFERS):this._maxDrawBuffers=1),this._maxDrawBuffers}},{key:"maxAnisoLevel",get:function(){if(!this._maxAnisoLevel){var t=this._rhi.requireExtension(e.GLCapabilityType.textureFilterAnisotropic);this._maxAnisoLevel=t?this._rhi.gl.getParameter(t.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var t=this._rhi.gl,r=this.canIUse(e.GLCapabilityType.multipleSample);this._maxAntiAliasing=r?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),oA),_Z=((oE=function(e){this.rhi=e,this._requireResult={}}).prototype.requireExtension=function(e){return void 0!==this._requireResult[e]||(this._requireResult[e]=this.rhi.gl.getExtension(e)),this._requireResult[e]},oE),_$=((ow=(oR=function(t,r){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=r,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._isSupportVAO=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var r=this._gl,n=this._primitive,a=this._isSupportVAO&&n.enableVAO;if(a){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);r.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,d=t.topology,u=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)r.drawElementsInstanced(d,h,l,u*c,s);else{var _=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,_),r.drawElementsInstanced(d,h,l,u*c,s),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArraysInstanced(d,u,h,s)}else dr.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)r.drawElements(d,h,l,u*c);else{var f=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,f),r.drawElements(d,h,l,u*c),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArrays(d,u,h);a?r.bindVertexArray(null):this._disableAttrib()},ow.destroy=function(){this._isSupportVAO&&this._clearVAO()},ow._bindBufferAndAttrib=function(e){var t,r,n=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var d=s[l];if(d){var u=i[d.bindingIndex],h=u.buffer,_=u.stride;r!==(t=h._platformBuffer._glBuffer)&&(r=t,n.bindBuffer(n.ARRAY_BUFFER,t)),n.enableVertexAttribArray(c);var f=d._formatMetaInfo;n.vertexAttribPointer(c,f.size,f.type,f.normalized,_,d.offset),this._canUseInstancedArrays&&n.vertexAttribDivisor(c,d.instanceStepRate),this._attribLocArray.push(c)}else dr.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},ow._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},ow._registerVAO=function(e){var t=this._gl,r=t.createVertexArray();t.bindVertexArray(r);var n=this._primitive.indexBufferBinding;n&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.buffer._platformBuffer._glBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,r)},ow._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},oR),_0=((oP=function(e){this._parameters={},this._gl=e,this._parameters={},this._parameters[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_VERTEX_UNIFORM_VECTORS]=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),this._parameters[e.MAX_VERTEX_ATTRIBS]=e.getParameter(e.MAX_VERTEX_ATTRIBS),this._parameters[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS]=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._parameters[e.MAX_TEXTURE_SIZE]=e.getParameter(e.MAX_TEXTURE_SIZE),e.blendFuncSeparate(e.ONE,e.ZERO,e.ONE,e.ZERO),e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.colorMask(!0,!0,!0,!0),e.blendColor(0,0,0,0),e.disable(e.SAMPLE_ALPHA_TO_COVERAGE),e.enable(e.DEPTH_TEST),e.depthFunc(e.LESS),e.depthMask(!0),e.disable(e.STENCIL_TEST),e.stencilFuncSeparate(e.FRONT,e.ALWAYS,0,255),e.stencilFuncSeparate(e.BACK,e.ALWAYS,0,255),e.stencilOpSeparate(e.FRONT,e.KEEP,e.KEEP,e.KEEP),e.stencilOpSeparate(e.BACK,e.KEEP,e.KEEP,e.KEEP),e.stencilMask(255),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.disable(e.POLYGON_OFFSET_FILL),e.polygonOffset(0,0)}).prototype.getParameter=function(e){return this._parameters[e]},oP),_1=((oL=(oF=function(e,t,r){this._texture=t,this._rhi=e,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=r,this._glTexture=this._gl.createTexture()}).prototype).destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},oL.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},oL.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},oL._bind=function(){this._rhi.bindTexture(this)},oL._init=function(t){var r=this._gl,n=this._isWebGL2,a=this._formatDetail,i=a.internalFormat,o=a.baseFormat,s=a.dataType,l=this._texture,c=l.mipmapCount,d=l.width,u=l.height,h=l.usage,_=l._isDepthTexture;if(this._bind(),n&&!(o===r.LUMINANCE_ALPHA||o===r.ALPHA)&&h!==e.TextureUsage.Dynamic)r.texStorage2D(this._target,c,i,d,u);else if(t)for(var f=0;f<c;f++)for(var p=Math.max(1,d>>f),m=0;m<6;m++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+m,f,i,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,i,d,u,0,o,s,null);else for(var g=0;g<c;g++){var v=Math.max(1,d>>g),y=Math.max(1,u>>g);r.texImage2D(this._target,g,i,v,y,0,o,s,null)}},oL._getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,d=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,dr.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,r,n,a,c,d,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oL._setWrapMode=function(t,r){var n=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===e.TextureWrapMode.Clamp||oF._isPowerOf2(s)&&oF._isPowerOf2(l)||(dr.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=e.TextureWrapMode.Clamp),t){case e.TextureWrapMode.Clamp:n.texParameteri(i,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(i,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(i,r,n.MIRRORED_REPEAT)}},oL._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},oF._isPowerOf2=function(e){return(e&e-1)==0},oF._getFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.R8G8B8:return{internalFormat:n?r.RGB8:r.RGB,baseFormat:r.RGB,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R8G8B8A8:return{internalFormat:n?r.RGBA8:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R4G4B4A4:return{internalFormat:n?r.RGBA4:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case e.TextureFormat.R5G5B5A1:return{internalFormat:n?r.RGB5_A1:r.RGBA,baseFormat:r.RGBA,dataType:r.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case e.TextureFormat.R5G6B5:return{internalFormat:n?r.RGB565:r.RGB,baseFormat:r.RGB,dataType:r.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case e.TextureFormat.Alpha8:return{internalFormat:r.ALPHA,baseFormat:r.ALPHA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.LuminanceAlpha:return{internalFormat:r.LUMINANCE_ALPHA,baseFormat:r.LUMINANCE_ALPHA,dataType:r.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:n?r.RGBA16F:r.RGBA,baseFormat:r.RGBA,dataType:r.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:n?r.RGBA32F:r.RGBA,baseFormat:r.RGBA,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32_UInt:return{internalFormat:n?r.RGBA32UI:r.NONE,baseFormat:r.RGBA_INTEGER,dataType:r.UNSIGNED_INT,isCompressed:!1};case e.TextureFormat.BC1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.BC3:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case e.TextureFormat.BC7:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case e.TextureFormat.ETC1_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,isCompressed:!0};case e.TextureFormat.ETC2_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC,isCompressed:!0};case e.TextureFormat.PVRTC_RGB2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGB4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.ASTC_4x4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,isCompressed:!0};case e.TextureFormat.ASTC_5x5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,isCompressed:!0};case e.TextureFormat.ASTC_6x6:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,isCompressed:!0};case e.TextureFormat.ASTC_8x8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,isCompressed:!0};case e.TextureFormat.ASTC_10x10:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,isCompressed:!0};case e.TextureFormat.ASTC_12x12:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,isCompressed:!0};case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:n?r.DEPTH_COMPONENT16:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oF._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oF._supportTextureFormat=function(t,r){switch(t){case e.TextureFormat.R16G16B16A16:if(!r.canIUse(e.GLCapabilityType.textureHalfFloat))return!1;break;case e.TextureFormat.R32G32B32A32:if(!r.canIUse(e.GLCapabilityType.textureFloat))return!1;break;case e.TextureFormat.Depth16:case e.TextureFormat.Depth24Stencil8:case e.TextureFormat.Depth:case e.TextureFormat.DepthStencil:if(!r.canIUse(e.GLCapabilityType.depthTexture))return!1;break;case e.TextureFormat.R32G32B32A32_UInt:case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},oF._supportRenderBufferColorFormat=function(t,r){var n=!0;switch(t){case e.TextureFormat.R16G16B16A16:r.canIUse(e.GLCapabilityType.colorBufferHalfFloat)&&r.canIUse(e.GLCapabilityType.textureHalfFloat)||(n=!1);break;case e.TextureFormat.R32G32B32A32:r.canIUse(e.GLCapabilityType.colorBufferFloat)&&r.canIUse(e.GLCapabilityType.textureFloat)||(n=!1)}return n},oF._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return!1}return!0},_H(oF,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var r=this._gl,n=this._target,a=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.NEAREST_MIPMAP_NEAREST:r.NEAREST);break;case e.TextureFilterMode.Bilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_NEAREST:r.LINEAR);break;case e.TextureFilterMode.Trilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_LINEAR:r.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(t){this._bind();var r=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NEVER);break;case e.TextureDepthCompareFunction.Less:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LESS);break;case e.TextureDepthCompareFunction.Equal:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GEQUAL);break;case e.TextureDepthCompareFunction.Always:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.ALWAYS)}}}]),oF),_2=((oB=(oD=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,a=r._depth,i=r.width,o=r.height,s=_j(a,dF),l=0,c=n.length;l<c;l++){var d=n[l]._format;if(!_1._supportRenderBufferColorFormat(d,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[d]+" in RenderTarget")}if(!s&&!_1._supportRenderBufferDepthFormat(a,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[a]+" in RenderTarget");if(n.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==i||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(a.width!==i||a.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return _j(e,dZ)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=t.capability.maxAntiAliasing;r.antiAliasing>u&&(dr.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+u),r._antiAliasing=u),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),r.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).activeRenderTarget=function(e,t){var r=this._gl,n=this._target;r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=n.getColorTexture(0);if(o){var s=_j(o,dZ);(a||s&&i)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=n.depthTexture;if(l){var c=_j(l,dZ);if(a||c){var d=l._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,d._formatDetail.attachment,c?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,d._glTexture,e)}}else if(a){var u=_1._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,u,n.width>>e,n.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&r.bindFramebuffer(r.FRAMEBUFFER,this._MSAAFrameBuffer)},oB.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),r=this._target,n=r.colorTextureCount,a=r.width,i=r.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<n;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},oB.destroy=function(){var e=this._gl;this._frameBuffer&&e.deleteFramebuffer(this._frameBuffer),this._depthRenderBuffer&&e.deleteRenderbuffer(this._depthRenderBuffer),this._MSAAFrameBuffer&&e.deleteFramebuffer(this._MSAAFrameBuffer),this._MSAADepthRenderBuffer&&e.deleteRenderbuffer(this._MSAADepthRenderBuffer);for(var t=0;t<this._MSAAColorRenderBuffers.length;t++)e.deleteRenderbuffer(this._MSAAColorRenderBuffers[t]);this._frameBuffer=null,this._depthRenderBuffer=null,this._MSAAFrameBuffer=null,this._MSAAColorRenderBuffers.length=0,this._MSAADepthRenderBuffer=null},oB._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,a=r.colorTextureCount,i=r.width,o=r.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),d=e.COLOR_ATTACHMENT0+l;s[l]=d,_j(c,dZ)||e.framebufferTexture2D(e.FRAMEBUFFER,d,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(_j(n,dF)&&!_j(n,dZ)){var u=n._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,u._formatDetail.attachment,e.TEXTURE_2D,u._glTexture,0)}else if(this._target.antiAliasing<=1){var h=_1._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},oB._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,a=n._depth,i=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var d=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=d,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,d),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,d)}if(e.drawBuffers(this._oriDrawBuffers),null!==a){var u=_j(a,dF)?a._platformTexture._formatDetail:_1._getRenderBufferDepthFormatDetail(a,e,t),h=u.internalFormat,_=u.attachment;e.bindRenderbuffer(e.RENDERBUFFER,r),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,r)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},oB._checkFrameBuffer=function(){var e=this._gl,t=this._isWebGL2,r=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(r){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw Error("The attachment types are mismatched or not all framebuffer attachment points are framebuffer attachment complete");case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw Error("There is no attachment");case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw Error(" Height and width of the attachment are not the same.");case e.FRAMEBUFFER_UNSUPPORTED:throw Error("The format of the attachment is not supported or if depth and stencil attachments are not the same renderbuffer")}if(t&&r===e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE)throw Error("The values of gl.RENDERBUFFER_SAMPLES are different among attached renderbuffers, or are non-zero if the attached images are a mix of renderbuffers and textures.")},oD),_3=(_K(oI=function(t,r){(n=_1.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,a=r.format,i=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!_1._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||_1._isPowerOf2(o)&&_1._isPowerOf2(s)||(dr.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),r._mipmap=!1,r._mipmapCount=r._getMipmapCount()),n._formatDetail=_1._getFormatDetail(a,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},_1),(oV=oI.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,d=l.baseFormat,u=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(a=a||_-r,i=i||f-n,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,r,n,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,a,i,d,u,e)},oV.setImageSource=function(t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.internalFormat,d=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,d,u,t):s.texSubImage2D(this._target,r,i||0,o||0,d,u,t)},oV.getPixelBuffer=function(e,t,r,n,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_1.prototype._getPixelBuffer.call(this,null,e,t,r,n,a,i)},oI),_4=(_K(oO=function(t,r){n=_1.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,a=r.format,i=r.width,o=r.height,s=r.length,l=r.mipmapCount;if(!n._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!_1._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return n._bind(),n._formatDetail=_1._getFormatDetail(a,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,i,o,s),n},_1),(oN=oO.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){var l=this._target,c=this._gl,d=this._formatDetail,u=d.internalFormat,h=d.baseFormat,_=d.dataType,f=d.isCompressed;i=i||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,r,n,a,e,i,o,s,u,t):c.texSubImage3D(l,r,n,a,e,i,o,s,h,_,t)},oN.setImageSource=function(e,t,r,n,a,i,o){var s,l,c=this._gl,d=this._formatDetail,u=d.baseFormat,h=d.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+n),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),c.texSubImage3D(this._target,r,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,u,h,t)},oN.getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,r,n,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oO),_8=(_K(ok=function(t,r){(n=_1.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,a=r.format,i=r._mipmap,o=r.width,s=n._isWebGL2;if(!_1._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||_1._isPowerOf2(o)||(dr.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),r._mipmap=!1,r._mipmapCount=r._getMipmapCount()),n._formatDetail=_1._getFormatDetail(a,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},_1),(oz=ok.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,d=c.internalFormat,u=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>r);if(i=i||f-n,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<r;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,d,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,d,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,u,h,t)},oz.setImageSource=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,d=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,i||0,o||0,c,d,t)},oz.getPixelBuffer=function(e,t,r,n,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_1.prototype._getPixelBuffer.call(this,e,t,r,n,a,i,o)},ok);e.WebGLMode=void 0,(oU=e.WebGLMode||(e.WebGLMode={}))[oU.Auto=0]="Auto",oU[oU.WebGL2=1]="WebGL2",oU[oU.WebGL1=2]="WebGL1";var _5=((oH=(oG=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new cB(null,null,null,null),this._lastScissor=new cB(null,null,null,null),this._lastClearColor=new cI(null,null,null,null),this._scissorEnable=!1;var r=_Y({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(uY.platform===e.Platform.IPhone||uY.platform===e.Platform.IPad){var n=uY.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var a=parseInt(n[1]),i=parseInt(n[2]);15===a&&i>=0&&i<=4&&(r._forceFlush=!0)}}this._options=r,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).init=function(e,t,r){var n,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((n=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&_j(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&_j(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},oH.createPlatformPrimitive=function(e){return new _$(this,e)},oH.createPlatformTexture2D=function(e){return new _3(this,e)},oH.createPlatformTexture2DArray=function(e){return new _4(this,e)},oH.createPlatformTextureCube=function(e){return new _8(this,e)},oH.createPlatformRenderTarget=function(e){return new _2(this,e)},oH.createPlatformBuffer=function(t,r,n,a){return void 0===n&&(n=e.BufferUsage.Static),new _Q(this,t,r,n,a)},oH.requireExtension=function(e){return this._extensions.requireExtension(e)},oH.canIUse=function(e){return this.capability.canIUse(e)},oH.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},oH.viewport=function(e,t,r,n){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||r!==i.z||n!==i.w)&&(a.viewport(e,t,r,n),i.set(e,t,r,n))},oH.scissor=function(e,t,r,n){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||r!==i.z||n!==i.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,r,n)),i.set(e,t,r,n)}},oH.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},oH.clearRenderTarget=function(t,r,n){var a=this._gl,i=t._lastRenderState,o=i.blendState.targetBlendState,s=i.depthState,l=i.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=a.COLOR_BUFFER_BIT;var d=this._lastClearColor,u=n.r,h=n.g,_=n.b,f=n.a;n&&(u!==d.r||h!==d.g||_!==d.b||f!==d.a)&&(a.clearColor(u,h,_,f),d.set(u,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(a.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=a.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(a.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=a.STENCIL_BUFFER_BIT,255!==l.writeMask&&(a.stencilMask(255),l.writeMask=255)),a.clear(c)},oH.drawPrimitive=function(e,t,r){e?e.draw(r,t):dr.error("draw primitive failed.")},oH.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},oH.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},oH.activeRenderTarget=function(e,t,r,n,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(n,a),i=e.width>>n,o=e.height>>n}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,d=t.x*i,u=r?t.y*o:o-t.y*o-c;this.viewport(d,u,l,c),this.scissor(d,u,l,c)},oH.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},oH.bindTexture=function(e){var t=this._activeTextureID-this._gl.TEXTURE0;this._activeTextures[t]!==e&&(this._gl.bindTexture(e._target,e._glTexture),this._activeTextures[t]=e)},oH.setGlobalDepthBias=function(e,t){var r=this._gl,n=0!==e||0!==t;n?(r.enable(r.POLYGON_OFFSET_FILL),r.polygonOffset(t,e)):r.disable(r.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=n},oH.flush=function(){this._gl.flush()},oH.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},oH.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},oH.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var e=this._activeTextures,t=0,r=e.length;t<r;t++)e[t]=null;this._lastViewport.set(null,null,null,null),this._lastScissor.set(null,null,null,null),this._lastClearColor.set(null,null,null,null),this._scissorEnable=!1,this._initGLState(this._gl)},oH._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new _0(e),this._extensions=new _Z(this),this._capability=new _J(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},oH.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},oH._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},oH._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},oH._onWebGLContextRestored=function(e){this._onDeviceRestored()},_H(oG,[{key:"isWebGL2",get:function(){return this._isWebGL2}},{key:"renderer",get:function(){return this._renderer}},{key:"gl",get:function(){return this._gl}},{key:"renderStates",get:function(){return this._renderStates}},{key:"capability",get:function(){return this._capability}},{key:"canIUseMoreJoints",get:function(){return this.capability.canIUseMoreJoints}}]),oG);function _9(){return(_9=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function _6(e,t){return(_6=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _7(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_6(e,t)}function fe(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function ft(e,t){var r,n,a,i,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}},l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i}function fr(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function fn(e,t,r){return t&&fr(e.prototype,t),r&&fr(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var fa=((oK=(oW=function(e,t,r,n){void 0===t&&(t=0),void 0===n&&(n=!0),this.data=e,this._dataView=new DataView(e.buffer,e.byteOffset+t,null!=r?r:e.byteLength-t),this._littleEndian=n,this._position=0,this._baseOffset=t}).prototype).nextUint8=function(){var e=this._dataView.getUint8(this._position);return this._position+=1,e},oK.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},oK.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},oK.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},oK.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oK.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},oK.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oK.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oK.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},oK.nextUint64=function(){var e=this._dataView.getUint32(this._position,this._littleEndian),t=this._dataView.getUint32(this._position+4,this._littleEndian);return this._position+=8,e+4294967296*t},oK.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,c0.decodeText(t)},oK.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},oK.nextImagesData=function(e){for(var t=Array(e),r=0;r<e;r++){var n=this._dataView.getUint32(this._position,this._littleEndian);t[r]=n,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},oK.skip=function(e){return this._position+=e,this},oK.scan=function(e,t){void 0===t&&(t=0);for(var r=this._position,n=0;this._dataView.getUint8(this._position)!==t&&n<e;)n++,this._position++;return n<e&&this._position++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)},fn(oW,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),oW),fi={};function fo(e){return function(t){fi[e]=t}}var fs=((oj=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint8(4),a=t.getUint16(5,!0),i=new Uint8Array(e,7,a),o=t.getUint16(7+a,!0),s=new Uint8Array(e,9+a,o),l=c0.decodeText(s),c=c0.decodeText(i),d=new oj;return d.totalLength=r,d.name=l,d.type=c,d.version=n,d.headerLength=s.byteLength+i.byteLength+9,d},fn(oj,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oj);function fl(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cB(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function fc(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cC(e[3*n],e[3*n+1],e[3*n+2]);return r}function fd(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cD(e[2*n],e[2*n+1]);return r}function fu(e,t,r){return(fu=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&_6(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oX=function(){}).decode=function(e,t){return new Promise(function(r){var n=new d0(e),a=JSON.parse(t.nextStr());a.bounds&&n.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=fc(s,l);if(n.setPositions(c),a.normals){var d=fc(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);n.setNormals(d)}if(a.uvs){var u=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);n.setUVs(fd(u,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);n.setUVs(fd(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);n.setUVs(fd(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);n.setUVs(fd(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);n.setUVs(fd(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);n.setUVs(fd(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);n.setUVs(fd(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);n.setUVs(fd(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cI(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);n.setBoneWeights(fl(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);n.setBoneIndices(fl(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new dj(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,a=fc(r,n);e.deltaNormals&&fc(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&fl(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,a)}),n.addBlendShape(t)}),a.indices){var S=null;S=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),n.setIndices(S)}a.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},oX),e.MeshDecoder=fe([fo("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oq=function(){}).decode=function(e,t){return new Promise(function(r,n){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),d=t.nextUint8(),u=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new dQ(e,u,h,d,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,r(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&r(m)};if(t(),i){var n=function(e){var r=new window.Blob([p[e]]),n=new Image;n.onload=function(){m.setImageSource(n,e),t()},n.src=URL.createObjectURL(r)};m.generateMipmaps();for(var a=1;a<f;a++)n(a)}},b.src=URL.createObjectURL(x)}})},oq),e.Texture2DDecoder=fe([fo("Texture2D")],e.Texture2DDecoder);var fh=((oQ=(oY=function(e){this._context=e}).prototype).parseEntity=function(e){return this._getEntityByConfig(e).then(function(t){t.isActive=null==(r=e.isActive)||r;var r,n,a=e.position,i=e.rotation,o=e.scale;return a&&t.transform.position.copyFrom(a),i&&t.transform.rotation.copyFrom(i),o&&t.transform.scale.copyFrom(o),t.layer=null!=(n=e.layer)?n:t.layer,t})},oQ.parseClassObject=function(e){var t,r=this,n=hG.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return fu(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},oQ.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var a=t.methods[n],i=0,o=a.length;i<o;i++)r.push(this.parseMethod(e,n,a[i]));if(t.props){var s=this,l=function(n){var a=t.props[n],i=s.parseBasicType(a,e[n]).then(function(t){return e[n]=t});r.push(i)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=oY.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},oQ.parseMethod=function(e,t,r){var n=this;return Promise.all(r.map(function(e){return n.parseBasicType(e)})).then(function(r){return e[t].apply(e,[].concat(r))})},oQ.parseBasicType=function(e,t){var r=this;if(Array.isArray(e))return Promise.all(e.map(function(e){return r.parseBasicType(e)}));if("object"==typeof e&&null!=e){if(oY._isClass(e))return this.parseClassObject(e);if(oY._isAssetRef(e))return this._context.resourceManager.getResourceByRef(e);if(oY._isEntityRef(e))return Promise.resolve(this._context.entityMap.get(e.entityId));if(t){var n=this,a=function(r){if("methods"===r){var a=e[r];for(var o in a)for(var s=a[o],l=0,c=s.length;l<c;l++){var d=s[l];i.push(n.parseMethod(t,o,d))}}else i.push(n.parseBasicType(e[r],t[r]).then(function(e){return t[r]=e}))},i=[];for(var o in e)a(o);return Promise.all(i).then(function(){return t})}}return Promise.resolve(e)},oQ._getEntityByConfig=function(e){var t=e.assetRefId,r=this._context.engine;return t?r.resourceManager.getResourceByRef({refId:t,key:e.key,isClone:e.isClone}).then(function(t){return t.name=e.name,t}):Promise.resolve(new uo(r,e.name))},oY.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oY._isClass=function(e){return void 0!=e.class},oY._isAssetRef=function(e){return void 0!=e.refId},oY._isEntityRef=function(e){return void 0!=e.entityId},oY);fh.customParseComponentHandles=new Map;var f_=((oJ=function(e,t,r){this.originalData=e,this.engine=t,this.target=r,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=t.resourceManager}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},oJ),ff=(_7(oZ=function(){return f_.apply(this,arguments)},f_),oZ);function fp(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function fm(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return fp(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return fp(e,t)}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var fg=((o0=(o$=function(e){var t=this;this.context=e,this.prefabContextMap=new WeakMap,this.prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new fh(e)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},o0._parseEntities=function(){var e=this,t=this.context.originalData.entities,r=this.context.entityConfigMap,n=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var n,i=null!=(n=t.strippedId)?n:t.id;return t.id=i,r.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var r=0,a=e.length;r<a;r++)n.set(t[r].id,e[r]);return e})},o0._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,r=this.context.components,n=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],d=c.refId?c.refId:c.class,u=s.addComponent(hG.getClass(d));r.set(c.id,u);var h=this._reflectionParser.parsePropsAndMethods(u,c);n.push(h)}return Promise.all(n)},o0._parsePrefabModification=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.target,n=t.props,a=t.methods,i=r.entityId,o=r.componentId,s=e.prefabContextMap.get(c),l=s.entityMap.get(i),d=s.components.get(o);return d?e._reflectionParser.parsePropsAndMethods(d,{props:n,methods:a}):l?Promise.resolve(e._applyEntityData(l,n)):void 0})))}}(a);return Promise.all(n)},o0._parsePrefabRemovedEntities=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.entityId,n=e.prefabContextMap.get(c).entityMap.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},o0._parsePrefabRemovedComponents=function(){for(var e=this,t=this.context.originalData.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=r.get(s);n.concat.apply(n,[].concat(l.map(function(t){var r=t.componentId,n=e.prefabContextMap.get(c).components.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},o0._clearAndResolve=function(){return this.context.target},o0._organizeEntities=function(){for(var e,t=this.context,r=t.rootIds,n=t.strippedIds,a=r.concat(n),i=fm(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<r.length;s++)this.handleRootEntity(r[s])},o0._getEntityByConfig=function(e,t){var r=this;return(e.assetRefId?this._parseGLTF(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return r._applyEntityData(t,e)})},o0._parseEntity=function(e,t){var r=new uo(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(r)},o0._parseGLTF=function(e,t){var r=this,n=e.assetRefId,a=new f_(null,t);return t.resourceManager.getResourceByRef({refId:n}).then(function(t){var n=t.instantiateSceneRoot();e.parent||r.context.rootIds.push(e.id),r._traverseAddEntityToMap(n,a,""),r.prefabContextMap.set(n,a);var i=r.prefabPromiseMap.get(e.id);return i&&i.forEach(function(e){e.resolve(a)}),n})},o0._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(r,n){var a,i=null!=(a=t.prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:r,reject:n}),t.prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var r=e.prefabSource.entityId;return t.entityMap.get(r)})},o0._parseChildren=function(e){var t=this.context,r=t.entityConfigMap,n=t.entityMap,a=r.get(e).children;if(a&&a.length>0)for(var i=n.get(e),o=0;o<a.length;o++){var s=a[o],l=n.get(s);i.addChild(l),this._parseChildren(s)}},o0._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(r=t.isActive)?r:e.isActive,e.name=null!=(n=t.name)?n:e.name;var r,n,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},o0._traverseAddEntityToMap=function(e,t,r){var n=t.entityMap,a=t.components,i={},o={};n.set(r,e),e._components.forEach(function(t){var n=hG.getClassName(t.constructor);i[n]||(i[n]=e.getComponents(t.constructor,[]),o[n]=0),a.set(r+":"+n+"/"+o[n]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],d=r?r+"/"+s:""+s;this._traverseAddEntityToMap(c,t,d)}},o$),fv=(_7(o1=function(){return fg.apply(this,arguments)},fg),o1.prototype.handleRootEntity=function(e){this.context.target=this.context.entityMap.get(e)},o1.parse=function(e,t){var r=new ff(t,e),n=new o1(r);return n.start(),n},o1);e.InterpolableValueType=void 0,(o2=e.InterpolableValueType||(e.InterpolableValueType={}))[o2.Float=0]="Float",o2[o2.FloatArray=1]="FloatArray",o2[o2.Vector2=2]="Vector2",o2[o2.Vector3=3]="Vector3",o2[o2.Vector4=4]="Vector4",o2[o2.Quaternion=5]="Quaternion",o2[o2.Color=6]="Color",o2[o2.Array=7]="Array",o2[o2.Boolean=8]="Boolean",o2[o2.Rect=9]="Rect",o2[o2.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((o3=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),a=new hZ(n),i=r.nextUint16(),o=0;o<i;++o){var s=new hJ;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,a.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var d=r.nextStr(),u=r.nextStr(),h=hG.getClass(u),_=r.nextStr(),f=r.nextStr(),p=void 0,m=r.nextUint8(),g=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(p=new e.AnimationFloatCurve).interpolation=m;for(var v=0;v<g;++v){var y=new _t;y.time=r.nextFloat32(),y.value=r.nextFloat32(),y.inTangent=r.nextFloat32(),y.outTangent=r.nextFloat32(),p.addKey(y)}break;case"AnimationArrayCurve":(p=new e.AnimationArrayCurve).interpolation=m;for(var x=0;x<g;++x){var b=new _t;b.time=r.nextFloat32();var S=r.nextUint16();b.value=Array.from(r.nextFloat32Array(S)),b.inTangent=Array.from(r.nextFloat32Array(S)),b.outTangent=Array.from(r.nextFloat32Array(S)),p.addKey(b)}break;case"AnimationFloatArrayCurve":(p=new e.AnimationFloatArrayCurve).interpolation=m;for(var C=0;C<g;++C){var T=new _t;T.time=r.nextFloat32();var A=r.nextUint16();T.value=r.nextFloat32Array(A),T.inTangent=Array.from(r.nextFloat32Array(A)),T.outTangent=Array.from(r.nextFloat32Array(A)),p.addKey(T)}break;case"AnimationVector2Curve":(p=new e.AnimationVector2Curve).interpolation=m;for(var M=0;M<g;++M){var E=new _t;E.time=r.nextFloat32(),E.value=new cD(r.nextFloat32(),r.nextFloat32()),E.inTangent=new cD(r.nextFloat32(),r.nextFloat32()),E.outTangent=new cD(r.nextFloat32(),r.nextFloat32()),p.addKey(E)}break;case"AnimationVector3Curve":(p=new e.AnimationVector3Curve).interpolation=m;for(var R=0;R<g;++R){var w=new _t;w.time=r.nextFloat32(),w.value=new cC(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cC(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cC(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(w)}break;case"AnimationVector4Curve":(p=new e.AnimationVector4Curve).interpolation=m;var P=new _t;P.time=r.nextFloat32(),P.value=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(P);break;case"AnimationColorCurve":(p=new e.AnimationColorCurve).interpolation=m;for(var F=0;F<g;++F){var L=new _t;L.time=r.nextFloat32(),L.value=new cI(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(L)}break;case"AnimationQuaternionCurve":(p=new e.AnimationQuaternionCurve).interpolation=m;for(var D=0;D<g;++D){var B=new _t;B.time=r.nextFloat32(),B.value=new cP(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),B.inTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),B.outTangent=new cB(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(B)}break;case"AnimationRefCurve":(p=new e.AnimationRefCurve).interpolation=m;for(var I=0;I<g;++I){var V=new _t;V.time=r.nextFloat32();var O=r.nextStr();O?V.value=JSON.parse(O):V.value=null,p.addKey(V)}break;case"AnimationBoolCurve":(p=new e.AnimationBoolCurve).interpolation=m;for(var N=0;N<g;++N){var k=new _t;k.time=r.nextFloat32(),k.value=1===r.nextUint8(),p.addKey(k)}break;case"AnimationStringCurve":(p=new e.AnimationStringCurve).interpolation=m;for(var z=0;z<g;++z){var U=new _t;U.time=r.nextFloat32(),U.value=r.nextStr(),p.addKey(U)}}a.addCurveBinding(d,h,_,f,p)}t(a)})},o3),e.AnimationClipDecoder=fe([fo("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(o4=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",o4.Custom="Custom";var fy=(_7(o8=function(e,t,r){var n;return(n=f_.call(this,e,t,r)||this).originalData=e,n.engine=t,n.scene=r,n},f_),o8),fx=(_7(o5=function(){return fg.apply(this,arguments)},fg),o5.prototype.handleRootEntity=function(e){var t=this.context,r=t.target,n=t.entityMap;r.addRootEntity(n.get(e))},o5.parse=function(e,t){var r=new hC(e),n=new fy(t,e,r),a=new o5(n);return a.start(),a.promise},o5);function fb(e,t){var r=fs.decode(e),n=new fa(new Uint8Array(e),r.headerLength,r.dataLength);return fi[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(_7(o9=function(){return hG.apply(this,arguments)},hG),o9.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"arraybuffer"})).then(function(e){fb(e,t.engine).then(function(e){n(e)})}).catch(a)})},o9),e.MeshLoader=fe([uG("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(_7(o6=function(){return hG.apply(this,arguments)},hG),o6.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"arraybuffer"})).then(function(e){fb(e,t.engine).then(function(e){n(e)})}).catch(a)})},o6),e.EditorTextureLoader=fe([uG("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var fS=(_7(o7=function(){return hG.apply(this,arguments)},hG),(se=o7.prototype).load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"arraybuffer"})).then(function(e){return fb(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return r._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){n(e)})}).catch(a)}).catch(a)})},se._parseKeyframeValue=function(e,t){var r=e.value;return"object"==typeof r&&(null==r?void 0:r.refId)?new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e.value)})}):Promise.resolve(e.value)},o7);fS=fe([uG(e.AssetType.AnimationClip,["ani"])],fS);var fC=(_7(st=function(){return hG.apply(this,arguments)},hG),st.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"json"})).then(function(e){var r=new h5,a=e.layers,i=[];a.forEach(function(e,n){var a=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new h9(a);if(c.blendingMode=o,c.weight=s,l){var d=l.states,u=c.stateMachine=new _e;d.forEach(function(e,r){var a=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,d=e.isDefaultState,h=e.clip,_=e.scripts,f=u.addState(a);d&&(u.defaultState=f),f.speed=o,f.wrapMode=s,f.clipStartTime=l,f.clipEndTime=c;var p=JSON.parse(_);null==p||p.forEach(function(e){f.addStateMachineScript(hG.getClass(e))}),h&&i.push(new Promise(function(e){t.getResourceByRef(h).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),d.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var r=e.targetStateName,n=e.duration,a=e.offset,i=e.exitTime,o=u.findStateByName(t),s=u.findStateByName(r),l=new h1;l.destinationState=s,l.duration=n,l.exitTime=i,l.offset=a,o.addTransition(l)})})}r.addLayer(c)}),Promise.all(i).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,a=e.clip;r.layers[t].stateMachine.states[n].clip=a}),n(r)})}).catch(a)})},st);fC=fe([uG(e.AssetType.AnimatorController,["json"],!1)],fC);var fT=(_7(sr=function(){return hG.apply(this,arguments)},hG),sr.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new uz(function(e){var r=t.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(r),function(e){return e.charCodeAt(0)}).buffer)}):this.request(t,_9({},e,{type:"arraybuffer"}))},sr);fT=fe([uG(e.AssetType.Buffer,["bin","r3bin"],!1)],fT);var fA=(_7(sn=function(){return hG.apply(this,arguments)},hG),sn.prototype.load=function(t,r){var n=this;return new uz(function(a,i){n.request(t.url,_9({},t,{type:"arraybuffer"})).then(function(t){var n=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=r.engine,s=new dZ(o,i);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,d=0;d<l;d++)for(var u=i>>d,h=0;h<6;h++){var _=u*u*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+h,f,d)}var p=new hg(o),m=new cO;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,a(p)}).catch(function(e){i(e)})})},sn);function fM(e,t,r,n,a,i,o){try{var s=e[i](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,a)}function fE(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var i=e.apply(t,r);function o(e){fM(i,n,a,o,s,"next",e)}function s(e){fM(i,n,a,o,s,"throw",e)}o(void 0)})}}fA=fe([uG(e.AssetType.Env,["env"])],fA);var fR=(_7(sa=function(){return hG.apply(this,arguments)},hG),(si=sa.prototype).load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?r._registerFont(i,o).then(function(){n(new uv(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):n(new uv(t.engine,i))}).catch(function(e){a(e)})})},si._registerFont=function(e,t){return fE(function(){var r;return ft(this,function(n){switch(n.label){case 0:return[4,(r=new FontFace(e,"url("+t+")")).load()];case 1:return n.sent(),document.fonts.add(r),[2]}})})()},sa);fR=fe([uG(e.AssetType.Font,["font"],!1)],fR);var fw=(_7(so=function(e,t){var r;return(r=cZ.call(this,e)||this).url=t,r},cZ),(ss=so.prototype).instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},ss._onDestroy=function(){cZ.prototype._onDestroy.call(this);var e=this.textures,t=this.materials,r=this.meshes;if(e&&this._disassociationSuperResource(e),t&&this._disassociationSuperResource(t),r)for(var n=0,a=r.length;n<a;n++)this._disassociationSuperResource(r[n])},ss._disassociationSuperResource=function(e){for(var t=0,r=e.length;t<r;t++)e[t]._disassociationSuperResource(this)},fn(so,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),so);(sl=co||(co={}))[sl.BYTE=5120]="BYTE",sl[sl.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",sl[sl.SHORT=5122]="SHORT",sl[sl.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",sl[sl.UNSIGNED_INT=5125]="UNSIGNED_INT",sl[sl.FLOAT=5126]="FLOAT",e.AccessorType=void 0,(sc=e.AccessorType||(e.AccessorType={})).SCALAR="SCALAR",sc.VEC2="VEC2",sc.VEC3="VEC3",sc.VEC4="VEC4",sc.MAT2="MAT2",sc.MAT3="MAT3",sc.MAT4="MAT4",(sd=cs||(cs={})).TRANSLATION="translation",sd.ROTATION="rotation",sd.SCALE="scale",sd.WEIGHTS="weights",(su=cl||(cl={})).Linear="LINEAR",su.Step="STEP",su.CubicSpine="CUBICSPLINE",(sh=cc||(cc={})).PERSPECTIVE="perspective",sh.ORTHOGRAPHIC="orthographic",(s_=cd||(cd={})).JPEG="image/jpeg",s_.PNG="image/png",(sf=cu||(cu={})).OPAQUE="OPAQUE",sf.MASK="MASK",sf.BLEND="BLEND",(sp=ch||(ch={}))[sp.NEAREST=9728]="NEAREST",sp[sp.LINEAR=9729]="LINEAR",(sm=c_||(c_={}))[sm.NEAREST=9728]="NEAREST",sm[sm.LINEAR=9729]="LINEAR",sm[sm.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sm[sm.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sm[sm.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sm[sm.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sg=cf||(cf={}))[sg.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sg[sg.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sg[sg.REPEAT=10497]="REPEAT";var fP=((sy=(sv=function(e,t,r){var n=this;this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,r){var a,i=(a=n._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=r,n._setTaskDetailProgress(e,t,r)},this.contentRestorer=new fK(e)}).prototype).get=function(e,t){var r=this,n=sv._parsers[e];if(!n)return Promise.resolve(null);var a=this._resourceCache,i=void 0===t?""+e:e+":"+t,o=a.get(i);if(o)return o;var s=fL[e],l=!!fD[e];if(s){var c=this.glTF[s];c&&(void 0===t||c[t])?void 0===t?o=8===e?c.map(function(t,n){return r.get(e,n)}):Promise.all(c.map(function(t,n){return r.get(e,n)})):(o=n.parse(this,t),l&&this._handleSubAsset(o,e,t)):o=Promise.resolve(null)}else o=n.parse(this,t),l&&this._handleSubAsset(o,e,t);return a.set(i,o),o},sy.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,r=t.animatorController;return r&&(t._defaultSceneRoot.addComponent(h8).animatorController=r),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},sy._addTaskCompletePromise=function(e){var t=this,r=this._progress.taskComplete;r.total+=1,e.then(function(){t._setTaskCompleteProgress(++r.loaded,r.total)})},sy._handleSubAsset=function(e,t,r){var n,a=this,i=fD[t];if(8===t)((n=this.glTFResource)[i]||(n[i]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==r?a.glTFResource[i]=e:((n=a.glTFResource)[i]||(n[i]=[]))[r]=e,7===t)for(var n,s,l=0,c=e.length;l<c;l++){var d=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+r+"]["+l+"]",d)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===r?"":"["+r+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===r&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},sv.addParser=function(e,t){this._parsers[e]=t},sv);fP._parsers={};var fF=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(sx=e.GLTFParserType||(e.GLTFParserType={}))[sx.Schema=0]="Schema",sx[sx.Validator=1]="Validator",sx[sx.Scene=2]="Scene",sx[sx.Buffer=3]="Buffer",sx[sx.BufferView=4]="BufferView",sx[sx.Texture=5]="Texture",sx[sx.Material=6]="Material",sx[sx.Mesh=7]="Mesh",sx[sx.Entity=8]="Entity",sx[sx.Skin=9]="Skin",sx[sx.Animation=10]="Animation",sx[sx.AnimatorController=11]="AnimatorController";var fL=((cp={})[2]="scenes",cp[3]="buffers",cp[5]="textures",cp[6]="materials",cp[7]="meshes",cp[8]="nodes",cp[9]="skins",cp[10]="animations",cp[4]="bufferViews",cp),fD=((cm={})[2]="_sceneRoots",cm[5]="textures",cm[6]="materials",cm[7]="meshes",cm[8]="entities",cm[9]="skins",cm[10]="animations",cm[11]="animatorController",cm);function fB(e){return function(t){var r=new t;fP.addParser(e,r)}}var fI=((sb=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new cD(e[n],e[n+1]);return r},sb.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new cC(e[n],e[n+1],e[n+2]);return r},sb.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new cB(e[n],e[n+1],e[n+2],e[n+3]);return r},sb.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var a=0;a<r;a+=3)n[a/3]=new cI(e[a],e[a+1],e[a+2],1);else for(var i=0;i<r;i+=4)n[i/4]=new cI(e[i],e[i+1],e[i+2],e[i+3]);return n},sb.getAccessorTypeSize=function(t){switch(t){case e.AccessorType.SCALAR:return 1;case e.AccessorType.VEC2:return 2;case e.AccessorType.VEC3:return 3;case e.AccessorType.VEC4:case e.AccessorType.MAT2:return 4;case e.AccessorType.MAT3:return 9;case e.AccessorType.MAT4:return 16}},sb.getComponentType=function(e){switch(e){case co.BYTE:return Int8Array;case co.UNSIGNED_BYTE:return Uint8Array;case co.SHORT:return Int16Array;case co.UNSIGNED_SHORT:return Uint16Array;case co.UNSIGNED_INT:return Uint32Array;case co.FLOAT:return Float32Array}},sb.getNormalizedComponentScale=function(e){switch(e){case co.BYTE:return 1/127;case co.UNSIGNED_BYTE:return 1/255;case co.SHORT:return 1/32767;case co.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},sb.getAccessorBuffer=function(t,r,n){var a,i=n.componentType,o=sb.getComponentType(i),s=sb.getAccessorTypeSize(n.type),l=o.BYTES_PER_ELEMENT,c=s*l,d=n.count;if(void 0!==n.bufferView){var u=n.bufferView,h=r[u];a=t.get(e.GLTFParserType.BufferView,n.bufferView).then(function(e){var r,a,_,f=h.buffer,p=null!=(r=e.byteOffset)?r:0,m=null!=(a=n.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=u+":"+i+":"+v+":"+d,x=t.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,S=d*(g/l),C=new o(e.buffer,b,S);x[y]=_=new fF(C,!0,g),_.restoreInfo=new fQ(new fJ(f,o,b,S))}}else{var T=p+m,A=d*s,M=new o(e.buffer,T,A);(_=new fF(M,!1,c)).restoreInfo=new fQ(new fJ(f,o,T,A))}return _})}else{var _=d*s,f=new o(_),p=new fF(f,!1,c);p.restoreInfo=new fQ(new fJ(void 0,o,void 0,_)),a=Promise.resolve(p)}return n.sparse?a.then(function(e){return sb.processingSparseData(t,n,e).then(function(){return e})}):a},sb.bufferToVector3Array=function(e,t,r,n,a){for(var i=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?sb.getNormalizedComponentScale(a):1,c=0;c<r;c++){var d=i+c*o;s[c]=new cC(e[d]*l,e[d+1]*l,e[d+2]*l)}return s},sb.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},sb.processingSparseData=function(t,r,n){var a=n.restoreInfo,i=t.glTF.bufferViews,o=sb.getAccessorTypeSize(r.type),s=sb.getComponentType(r.componentType),l=n.data.slice(),c=r.sparse,d=c.count,u=c.indices,h=c.values,_=i[u.bufferView],f=i[h.bufferView];return Promise.all([t.get(e.GLTFParserType.BufferView,u.bufferView),t.get(e.GLTFParserType.BufferView,h.bufferView)]).then(function(e){var t,r,i,c,p=e[0],m=e[1],g=(null!=(t=u.byteOffset)?t:0)+(null!=(r=p.byteOffset)?r:0),v=p.byteLength,y=(null!=(i=h.byteOffset)?i:0)+(null!=(c=m.byteOffset)?c:0),x=m.byteLength;a.typeSize=o,a.sparseCount=d;var b=sb.getComponentType(u.componentType),S=v/b.BYTES_PER_ELEMENT,C=new b(p.buffer,g,S);a.sparseIndices=new fJ(_.buffer,b,g,S);var T=x/s.BYTES_PER_ELEMENT,A=new s(m.buffer,y,T);a.sparseValues=new fJ(f.buffer,s,y,T);for(var M=0;M<d;M++)for(var E=C[M],R=0;R<o;R++)l[E*o+R]=A[M*o+R];n.data=l})},sb.getIndexFormat=function(t){switch(t){case co.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case co.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case co.UNSIGNED_INT:return e.IndexFormat.UInt32}},sb.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==co.FLOAT)switch(r){case 1:return e.VertexElementFormat.Float;case 2:return e.VertexElementFormat.Vector2;case 3:return e.VertexElementFormat.Vector3;case 4:return e.VertexElementFormat.Vector4}if(t==co.SHORT)switch(r){case 2:return n?e.VertexElementFormat.NormalizedShort2:e.VertexElementFormat.Short2;case 3:case 4:return n?e.VertexElementFormat.NormalizedShort4:e.VertexElementFormat.Short4}if(t==co.UNSIGNED_SHORT)switch(r){case 2:return n?e.VertexElementFormat.NormalizedUShort2:e.VertexElementFormat.UShort2;case 3:case 4:return n?e.VertexElementFormat.NormalizedUShort4:e.VertexElementFormat.UShort4}if(t==co.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==co.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},sb.loadImageBuffer=function(e,t){return new Promise(function(r,n){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){n(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){r(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},sb.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),a={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==a.magic)return{originBuffer:t};var i=n.getUint32(12,!0),o=n.getUint32(16,!0);if(o!==r.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(c0.decodeText(s)),c=[],d=20+i,u=e.contentRestorer.glbBufferSlices;d<a.length;){if(i=n.getUint32(d,!0),(o=n.getUint32(d+4,!0))!==r.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=d+8,_=t.slice(h,h+i);c.push(_),u.push(new cD(h,i)),d+=i+8}return{glTF:l,buffers:c}},sb.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,a=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==a&&(e.wrapModeV=a)},sb.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=c_.NEAREST_MIPMAP_NEAREST,n===ch.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=c_.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},sb);(sS=cg||(cg={}))[sS.linear=1]="linear",sS[sS.sRGB=2]="sRGB",(sC=cv||(cv={}))[sC.ETC1S=163]="ETC1S",sC[sC.UASTC=166]="UASTC",(sT=cy||(cy={}))[sT.None=0]="None",sT[sT.BasisLZ=1]="BasisLZ",sT[sT.Zstd=2]="Zstd",sT[sT.ZLib=3]="ZLib";var fV=((sA=function(e){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.keyValue={},this.globalData=null,this.parse(e)}).prototype.parse=function(e){var t=e.buffer,r=e.byteOffset,n=new fa(e,12);this.vkFormat=n.nextUint32(),this.typeSize=n.nextUint32(),this.pixelWidth=n.nextUint32(),this.pixelHeight=n.nextUint32(),this.pixelDepth=n.nextUint32(),this.layerCount=n.nextUint32(),this.faceCount=n.nextUint32();var a=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var i=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),d=n.nextUint64(),u=Array(a),h=24*a,_=new fa(e,n.offset,h);this.levels=u;for(var f=0;f<a;f++)u[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new fa(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new fa(e,s,l,!0);x.position<l;){var b=x.nextUint32(),S=x.scan(b),C=c0.decodeText(S),T=x.nextUint8Array(b-S.byteLength-1);this.keyValue[C]=C.match(/^ktx/i)?c0.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var A=b%4?4-b%4:0;x.skip(A)}if(d<=0)return this;for(var M=new fa(e,c,d,!0),E=M.nextUint16(),R=M.nextUint16(),w=M.nextUint32(),P=M.nextUint32(),F=M.nextUint32(),L=M.nextUint32(),D=Array(a),B=0;B<a;B++)D[B]={imageFlags:M.nextUint32(),rgbSliceByteOffset:M.nextUint32(),rgbSliceByteLength:M.nextUint32(),alphaSliceByteOffset:M.nextUint32(),alphaSliceByteLength:M.nextUint32()};var I=c+M.position,V=I+w,O=V+P,N=O+F,k=new Uint8Array(t,r+I,w),z=new Uint8Array(t,r+V,P),U=new Uint8Array(t,r+O,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:E,selectorCount:R,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},fn(sA,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sA);e.KTX2TargetFormat=void 0,(sM=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sM.ASTC=0]="ASTC",sM[sM.BC7=1]="BC7",sM[sM.BC1_BC3=2]="BC1_BC3",sM[sM.PVRTC=3]="PVRTC",sM[sM.ETC=4]="ETC",sM[sM.R8=5]="R8",sM[sM.R8G8=6]="R8G8",sM[sM.R8G8B8A8=7]="R8G8B8A8";var fO=((sR=(sE=function(e,t){void 0===e&&(e=4),this.limitedCount=e,this._workerCreator=t,this._taskQueue=[],this._workerStatus=0,this._workerItems=Array(e)}).prototype).prepareWorker=function(){for(var e=this.limitedCount,t=Array(e),r=0;r<e;r++)t.push(this._initWorker(r));return Promise.all(t)},sR.postMessage=function(e){var t=this;return new Promise(function(r,n){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sR.destroy=function(){for(var e=this._workerItems,t=0,r=e.length;t<r;t++){var n=e[t];n.worker.terminate(),n.reject=null,n.resolve=null}e.length=0,this._taskQueue.length=0,this._workerStatus=0},sR._initWorker=function(e){var t=this;return Promise.resolve(this._workerCreator()).then(function(r){return r.addEventListener("message",t._onMessage.bind(t,e)),t._workerItems[e]={worker:r,resolve:null,reject:null},r})},sR._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sR._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sR._nextTask=function(e){if(this._taskQueue.length){var t=this._taskQueue.shift(),r=this._workerItems[e];r.resolve=t.resolve,r.reject=t.reject,r.worker.postMessage(t.message)}else this._workerStatus^=1<<e},sE),fN=((sP=(sw=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sP.destroy=function(){this._transcodeWorkerPool.destroy()},sP._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new fO(this.workerLimitCount,function(){return new Promise(function(r,n){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?n(e.data.error):r(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sw);function fk(){var e,t=function(t){return e||(e=new Promise(function(e,r){var n={wasmBinary:t,onRuntimeInitialized:function(){return e(n)},onAbort:r};self.BASIS(n)}).then(function(e){return e.initializeBasis(),e.KTX2File})),e};self.onmessage=function(e){var r=e.data;switch(r.type){case"init":t(r.transcoderWasm).then(function(){self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":t().then(function(e){var t=fU(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var fz=function(e){return sF||(sF=new Promise(function(t,r){var n={wasmBinary:e,onRuntimeInitialized:function(){return t(n)},onAbort:r};self.BASIS(n)}).then(function(e){return e.initializeBasis(),e.KTX2File})),sF};function fU(e,t,r){var n,a,i,o,s=function(){l.close(),l.delete()};(i=n||(n={}))[i.ETC1=0]="ETC1",i[i.ETC2=1]="ETC2",i[i.BC1=2]="BC1",i[i.BC3=3]="BC3",i[i.BC4=4]="BC4",i[i.BC5=5]="BC5",i[i.BC7=7]="BC7",i[i.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",i[i.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",i[i.ASTC_4x4=10]="ASTC_4x4",i[i.RGBA8=13]="RGBA8",(o=a||(a={}))[o.ASTC=0]="ASTC",o[o.BC7=1]="BC7",o[o.BC1_BC3=2]="BC1_BC3",o[o.PVRTC=3]="PVRTC",o[o.ETC=4]="ETC",o[o.R8=5]="R8",o[o.RG8=6]="RG8",o[o.RGBA8=7]="RGBA8";var l=new r(new Uint8Array(e));if(!l.isValid())throw s(),Error("Invalid or unsupported .ktx2 file");if(!l.startTranscoding())throw s(),Error("KTX2 startTranscoding failed");for(var c=l.getWidth(),d=l.getHeight(),u=l.getLayers()||1,h=l.getLevels(),_=l.getHasAlpha(),f=l.getFaces(),p=function(e,t){switch(e){case 2:return t?3:2;case 4:return t?1:0;case 3:return t?9:8;case 7:return 13;case 0:return 10;case 1:return 7}}(t,_),m=Array(f),g=2===p||3===p||7===p,v=0;v<f;v++){for(var y=Array(h),x=0;x<h;x++){for(var b=Array(u),S=void 0,C=void 0,T=0;T<u;T++){var A=l.getImageLevelInfo(x,T,v);g&&0===x&&(c!==A.width||d!==A.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=S=A.width)+", height: "+(d=C=A.height)+". You'd better use an image whose size if multiple of 4."):(S=A.origWidth,C=A.origHeight);var M=new Uint8Array(l.getImageTranscodedSizeInBytes(x,T,0,p));if(!l.transcodeImage(M,x,T,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");b[T]=M}y[x]={data:function(e){if(1===e.length)return e[0];for(var t=0,r=0;r<e.length;r++)t+=e[r].byteLength;for(var n=new Uint8Array(t),a=0,i=0;i<e.length;i++)n.set(e[i],a),a+=e[i].byteLength;return n}(b),width:S,height:C}}m[v]=y}return s(),{faces:m,width:c,height:d,hasAlpha:_,faceCount:f,format:p}}var fG=(_7(sL=function(e){return fN.call(this,e)},fN),(sD=sL.prototype)._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var r=t[0],n=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){fz(n).then(function(){e(null)})},a.onerror=function(){t()}});var a=fk.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+r+"\n "+fU.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},sD.transcode=function(e,t){return 0===this.workerLimitCount?fz().then(function(r){return fU(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},sL);function fH(){var e,t,r,n=function(e,t,r,n){var a=(r+3>>2)*(n+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null},a=function(e,t,r){var a=e.length,i=Array(a),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<a;s++){for(var l=e[s].length,c=Array(l),d=0;d<l;d++){var u=e[s][d],h=u.buffer,_=u.levelHeight,f=u.levelWidth,p=u.uncompressedByteLength;t&&(h=o.decode(h.slice(),p));var m=h.byteLength/a,g=h.byteOffset,v=n(r,new Uint8Array(h.buffer,g+s*m,m),f,_);if(v)c[d]={data:v.slice(),width:f,height:_};else throw"buffer decoded error"}i[s]=c}return i})},i=((t=(e=function(){}).prototype).init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,r){if(void 0===r&&(r=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var n=e.instance.exports,a=t.byteLength,i=n.malloc(a);e.heap.set(t,i),r=r||Number(n.ZSTD_findDecompressedSize(i,a));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,i,a),l=e.heap.slice(o,o+s);return n.free(i),n.free(o),l},e);i.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){i.heap=new Uint8Array(i.instance.exports.memory.buffer)}}},i.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new i;self.onmessage=function(e){var t,n=e.data;switch(n.type){case"init":(t=n.transcoderWasm,r=WebAssembly.instantiate(t,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":r.then(function(e){a(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var fW=(_7(sB=function(e,t){var r;return(r=fN.call(this,e)||this).type=t,r},fN),(sI=sB.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(sB.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=fH.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},sI.transcode=function(e){for(var t=e.supercompressionScheme===cy.Zstd,r=e.levels.length,n=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(n)},o=i.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var d=e.levels[c],u=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=d.levelData.buffer,f=d.levelData.byteOffset,p=d.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:u,levelHeight:h,uncompressedByteLength:d.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},sB);fW.transcoderMap=((sV={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",sV),e.KTX2Loader=(_7(sO=function(){return hG.apply(this,arguments)},hG),(sN=sO.prototype).initialize=function(t,r){if(r.ktx2Loader){var n=r.ktx2Loader;return(n.priorityFormats&&(e.KTX2Loader._priorityFormats.etc1s=n.priorityFormats,e.KTX2Loader._priorityFormats.uastc=n.priorityFormats),1===n.transcoder)?e.KTX2Loader._getKhronosTranscoder(n.workerCount).init():e.KTX2Loader._getBinomialLLCTranscoder(n.workerCount).init()}},sN.load=function(t,r){var n=this;return new uz(function(a,i,o,s){n.request(t.url,{type:"arraybuffer"}).onProgress(o,s).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)})}).then(a).catch(i)})},sO.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},sO._parseBuffer=function(t,r,n){var a,i,o=new fV(t),s=null!=(a=null==n?void 0:n.priorityFormats)?a:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&fW.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var d=e.KTX2Loader._getBinomialLLCTranscoder();i=d.init().then(function(){return d.transcode(t,l)})}return i.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},sO._createTextureByBuffer=function(t,r,n,a){var i,o=r.width,s=r.height,l=r.faces,c=l.length,d=l[0],u=d.length>1,h=this._getEngineTextureFormat(n,r);if(6!==c){i=new dQ(t,o,s,h,u);for(var _=0;_<d.length;_++){var f=d[_].data;i.setPixelBuffer(f,_)}}else{i=new dZ(t,s,h,u);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<d.length;g++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return a&&(i.wrapModeU=a[0],i.wrapModeV=a[1],i.filterMode=a[2],i.anisoLevel=a[3]),i},sO._decideTargetFormat=function(t,r,n){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,n);return i!==e.KTX2TargetFormat.PVRTC||cS.isPowerOf2(r.pixelWidth)&&cS.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===i?(dr.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(dr.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},sO._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var a=r[n],i=this._supportedMap[a];if(i){for(var o=0;o<i.length;o++)if(t.canIUse(i[o]))return a}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return a;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return a}}return null},sO._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new fG(t)},sO._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new fW(t,e.KTX2TargetFormat.ASTC)},sO._getEngineTextureFormat=function(t,r){var n=r.hasAlpha;switch(t){case e.KTX2TargetFormat.ASTC:return e.TextureFormat.ASTC_4x4;case e.KTX2TargetFormat.ETC:return n?e.TextureFormat.ETC2_RGBA8:e.TextureFormat.ETC2_RGB;case e.KTX2TargetFormat.BC7:return e.TextureFormat.BC7;case e.KTX2TargetFormat.BC1_BC3:return n?e.TextureFormat.BC3:e.TextureFormat.BC1;case e.KTX2TargetFormat.PVRTC:return n?e.TextureFormat.PVRTC_RGBA4:e.TextureFormat.PVRTC_RGB4;case e.KTX2TargetFormat.R8G8B8A8:return e.TextureFormat.R8G8B8A8}},sO._isBinomialInit=!1,sO._priorityFormats={etc1s:[e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC],uastc:[e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC]},sO._supportedMap=((sk={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],sk[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],sk[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],sk[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],sk[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],sk),sO),e.KTX2Loader=fe([uG(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(sz=e.KTX2Transcoder||(e.KTX2Transcoder={}))[sz.BinomialLLC=0]="BinomialLLC",sz[sz.Khronos=1]="Khronos";var fK=(_7(sU=function(){var e;return e=d2.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},d2),(sG=sU.prototype).restoreContent=function(){var t=this;return new uz(function(r,n){Promise.all(t.bufferRequests.map(function(e){return hz(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}uz.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,i=a[n.buffer],o=new Uint8Array(i,null!=(r=n.byteOffset)?r:0,n.byteLength),s=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(o,s.engine).then(function(e){for(var t=e.result.faces[0],r=0;r<t.length;r++)s.setPixelBuffer(t[r].data,r)}):fI.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=fm(t.meshes);!(e=n()).done;){for(var i,o=e.value,s=o.mesh,l=fm(o.vertexBuffers);!(i=l()).done;){var c=i.value,d=t._getBufferData(a,c.data);c.buffer.setData(d)}if(o.indexBuffer){var u=t._getBufferData(a,o.indexBuffer);s.setIndices(u)}for(var h,_=fm(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=fI.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=fI.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=fI.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},sG._getBufferData=function(e,t){var r,n=t.main;if(n){var a=e[n.bufferIndex];r=new n.TypedArray(a,n.byteOffset,n.length)}else r=new n.TypedArray(n.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,d=e[c.bufferIndex],u=new c.TypedArray(d,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)r[f*h+p]=u[_*h+p];return r},sU),fj=function(e,t){this.url=e,this.config=t},fX=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},fq=function(){this.vertexBuffers=[],this.blendShapes=[]},fY=function(e,t){this.buffer=e,this.data=t},fQ=function(e,t,r,n,a){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=a},fJ=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},fZ=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},f$=function(e,t,r,n,a){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=a},f0=((sW=(sH=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];throw"Not implemented."},sW.additiveParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},sH);e.GLTFExtensionMode=void 0,(sK=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[sK.CreateAndParse=0]="CreateAndParse",sK[sK.AdditiveParse=1]="AdditiveParse";var f1=((sj=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],d=e[c];if(o=sj._createAndParse.apply(sj,[].concat(c,t,d,r,a)))return o}},sj.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];for(var s in e){var l=e[s];sj._additiveParse.apply(sj,[].concat(s,t,r,l,n,i))}},sj.hasExtensionParser=function(e){var t;return!!(null==(t=sj._extensionParsers[e])?void 0:t.length)},sj.getExtensionParser=function(e,t){var r=sj._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var a=n-1;a>=0;--a){var i=r[a];if(i._mode===t)return i}},sj._addExtensionParser=function(e,t){sj._extensionParsers[e]||(sj._extensionParsers[e]=[]),sj._extensionParsers[e].push(t)},sj._createAndParse=function(t,r,n,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=sj.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,a,o))},sj._additiveParse=function(t,r,n,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=sj.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,a,i,s))},sj);function f2(e,t){return function(r){var n=new r;n._mode=t,f1._addExtensionParser(e,n)}}function f3(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function f4(){var e,t=function(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;++r){var n=e.charCodeAt(r);t[r]=n>96?n-97:n>64?n-39:n+4}for(var a=0,i=0;i<e.length;++i)t[a++]=t[i]<60?o[t[i]]:(t[i]-60)*64+t[++i];return t.buffer.slice(0,a)},r=function(t,r,n,a,i,o){var s=e.exports.sbrk,l=n+3&-4,c=s(l*a),d=s(i.length),u=new Uint8Array(e.exports.memory.buffer);u.set(i,d);var h=t(c,n,a,d,i.length);if(0==h&&o&&o(c,l,a),r.set(u.subarray(c,c+n*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)},n=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var r=e.data;t.pending-=r.count,t.requests[r.id][r.action](r.value),delete t.requests[r.id]},t},a=function(e){for(var r="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(t(s))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }',a=new Blob([r],{type:"text/javascript"}),i=URL.createObjectURL(a),o=0;o<e;++o)d[o]=n(i);URL.revokeObjectURL(i)},i=function(e,t,r,n,a){for(var i=d[0],o=1;o<d.length;++o)d[o].pending<i.pending&&(i=d[o]);return new Promise(function(o,s){var l=new Uint8Array(r),c=u++;i.pending+=e,i.requests[c]={resolve:o,reject:s},i.object.postMessage({id:c,count:e,size:t,source:l,mode:n,filter:a},[l.buffer])})};if(cx)return cx;var o=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),s=uY._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";cx=WebAssembly.instantiate(t(s)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:cx,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,a(this.workerCount)},decodeGltfBuffer:function(t,n,a,o,s){return(this.workerCount>0&&0===d.length&&this.useWorkers(),d.length>0)?i(t,n,a,c[o],l[s]):cx.then(function(){var i=new Uint8Array(t*n);return r(e.exports[c[o]],i,t,n,a,e.exports[l[s]]),i})},release:function(){for(var e=0;e<d.length;e++)d[e].object.terminate()}}});var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},c={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},d=[],u=0;return cx}f1._extensionParsers={},e.GLTFSchemaParser=(_7(sX=function(){return f1.apply(this,arguments)},f1),sX.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,a=r.bufferRequests,i={type:"arraybuffer"};return hz(n,i).onProgress(void 0,e._onTaskDetail).then(function(t){return a.push(new fj(n,i)),fI.parseGLB(e,t)}).then(function(t){return(null==t?void 0:t.glTF)?(r.isGLB=!0,e.buffers=t.buffers,t.glTF):(r.isGLB=!1,JSON.parse(c0.decodeText(new Uint8Array(t.originBuffer))))})},sX),e.GLTFSchemaParser=fe([fB(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(_7(sq=function(){return f1.apply(this,arguments)},f1),sq.prototype.parse=function(t,r){var n=t.glTF.animations[r],a=n.name,i=void 0===a?"AnimationClip"+r:a;return Promise.resolve(f1.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new hZ(i),n)).then(function(e){return f1.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},sq._parseStandardProperty=function(t,r,n){for(var a=function(r,n){var a=d[r],i=s[a.input],o=s[a.output],c=Promise.all([fI.getAccessorBuffer(t,l,i),fI.getAccessorBuffer(t,l,o)]).then(function(t){var n,i,s=t[0].data,l=t[1].data;if(o.normalized){for(var c=fI.getNormalizedComponentScale(o.componentType),d=new Float32Array(l.length),u=0,_=l.length;u<_;u++)d[u]=l[u]*c;l=d}var f=l.length/s.length;switch(null!=(n=a.interpolation)?n:cl.Linear){case cl.CubicSpine:i=e.InterpolationType.CubicSpine;break;case cl.Step:i=e.InterpolationType.Step;break;case cl.Linear:i=e.InterpolationType.Linear}s[s.length-1],h[r]={type:o.type,interpolation:i,input:s,output:l,outputSize:f}});f.push(c)},i=this,o=t.glTF,s=o.accessors,l=o.bufferViews,c=n.channels,d=n.samplers,u=d.length,h=Array(u),_=t.get(e.GLTFParserType.Entity),f=[],p=0;p<u;p++)a(p);return f.push(t.get(e.GLTFParserType.Scene)),Promise.all(f).then(function(){for(var e=0,n=c.length;e<n;e++){for(var a=c[e],s=a.target,l=_[s.node],d="",u=l;u.parent;)d=""===d?""+u.name:u.name+"/"+d,u=u.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(u)){var f=void 0,p=void 0;switch(s.path){case cs.TRANSLATION:f=dd,p="position";break;case cs.ROTATION:f=dd,p="rotationQuaternion";break;case cs.SCALE:f=dd,p="scale";break;case cs.WEIGHTS:f=ul,p="blendShapeWeights"}var m=i._addCurve(s.path,a,h);if(s.path===cs.WEIGHTS)for(var g=o.nodes[s.node].mesh,v=0,y=o.meshes[g].primitives.length;v<y;v++)r.addCurveBinding(d,f,v,p,m);else r.addCurveBinding(d,f,p,m)}}return r})},sq._addCurve=function(t,r,n){var a=n[r.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case cs.TRANSLATION:case cs.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,d=0,u=0,h=i.length;u<h;u++){var _=new _t;_.time=i[u],c===e.InterpolationType.CubicSpine?(_.inTangent=new cC(o[d++],o[d++],o[d++]),_.value=new cC(o[d++],o[d++],o[d++]),_.outTangent=new cC(o[d++],o[d++],o[d++])):_.value=new cC(o[d++],o[d++],o[d++]),l.addKey(_)}return l;case cs.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new _t;y.time=i[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new cB(o[m++],o[m++],o[m++],o[m++]),y.value=new cP(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new cB(o[m++],o[m++],o[m++],o[m++])):y.value=new cP(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case cs.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,S=0,C=i.length;S<C;S++){var T=new _t;T.time=i[S],x.interpolation===e.InterpolationType.CubicSpine?(T.inTangent=Array.from(o.subarray(b,b+s)),b+=s,T.value=o.slice(b,b+s),b+=s,T.outTangent=Array.from(o.subarray(b,b+s))):T.value=o.slice(b,b+s),b+=s,x.addKey(T)}return x}},sq),e.GLTFAnimationParser=fe([fB(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(_7(sY=function(){return f1.apply(this,arguments)},f1),(sQ=sY.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},sQ._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,a=r.url,i=n.bufferRequests,o={type:"arraybuffer"},s=c0.resolveAbsoluteUrl(a,t.uri);i.push(new fj(s,o));var l=hz(s,o).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(l),l},sY),e.GLTFBufferParser=fe([fB(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(_7(sJ=function(){return f1.apply(this,arguments)},f1),sJ.prototype.parse=function(t,r){var n=t.glTFResource,a=t.glTF.nodes[r],i=n.engine,o=a.matrix,s=a.translation,l=a.rotation,c=a.scale,d=a.extensions,u=new uo(i,a.name||"_GLTF_ENTITY_"+r);u._markAsTemplate(n);var h=u.transform;if(o){var _=h.localMatrix;_.copyFromArray(o),h.localMatrix=_}else s&&h.setPosition(s[0],s[1],s[2]),l&&h.setRotationQuaternion(l[0],l[1],l[2],l[3]),c&&h.setScale(c[0],c[1],c[2]);var f=a.children;if(f)for(var p=0;p<f.length;p++){var m=f[p],g=t.get(e.GLTFParserType.Entity,m);u.addChild(g)}return f1.executeExtensionsAdditiveAndParse(d,t,u,a),u},sJ),e.GLTFEntityParser=fe([fB(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(_7(sZ=function(){return f1.apply(this,arguments)},f1),sZ.prototype.parse=function(t,r){var n=t.glTF.materials[r],a=t.glTFResource,i=a.engine,o=f1.executeExtensionsCreateAndParse(n.extensions,t,n);return o||((o=new uM(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,o,n)),Promise.resolve(o).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(i)),f1.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r._associationSuperResource(a),r})},sZ._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new uT(t))},sZ._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&dr.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},sZ._parseStandardProperty=function(t,r,n){var a=n.pbrMetallicRoughness,i=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,d=n.alphaCutoff,u=n.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(r.baseColor=new cI(cI.linearToGammaSpace(h[0]),cI.linearToGammaSpace(h[1]),cI.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,f1.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===uM&&(r.metallic=null!=f?f:1,r.roughness=null!=p?p:1,m&&(e.GLTFMaterialParser._checkOtherTextureTransform(m,"Roughness metallic"),t.get(e.GLTFParserType.Texture,m.index).then(function(e){r.roughnessMetallicTexture=e})))}if(r.constructor===uM||r.constructor===uE){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new cI(cI.linearToGammaSpace(l[0]),cI.linearToGammaSpace(l[1]),cI.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;e.GLTFMaterialParser._checkOtherTextureTransform(i,"Normal"),t.get(e.GLTFParserType.Texture,g).then(function(e){r.normalTexture=e}),void 0!==v&&(r.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;e.GLTFMaterialParser._checkOtherTextureTransform(o,"Occlusion"),t.get(e.GLTFParserType.Texture,y).then(function(e){r.occlusionTexture=e}),void 0!==x&&(r.occlusionTextureIntensity=x),b===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:b>e.TextureCoordinate.UV1&&dr.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(u?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case cu.OPAQUE:r.isTransparent=!1;break;case cu.BLEND:r.isTransparent=!0;break;case cu.MASK:r.alphaCutoff=null!=d?d:.5}},sZ),e.GLTFMaterialParser=fe([fB(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(_7(s$=function(){return f1.apply(this,arguments)},f1),s$.prototype.parse=function(t,r){for(var n=function(r,n){var c=a.primitives[r];l[r]=new Promise(function(n){var l=f1.executeExtensionsCreateAndParse(c.extensions,t,c,a);if(l)f3(l,d0)?(l._associationSuperResource(o),n(l)):l.then(function(e){e._associationSuperResource(o),n(e)});else{var d=new d0(s,a.name||r+"");d._associationSuperResource(o);var u=new fq;u.mesh=d,t.contentRestorer.meshes.push(u),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,d,u,a,c,i,t.params.keepMeshData).then(n)}})},a=t.glTF.meshes[r],i=t.glTF,o=t.glTFResource,s=o.engine,l=[],c=0,d=a.primitives.length;c<d;c++)n(c);return Promise.all(l)},s$._parseMeshFromGLTFPrimitive=function(t,r,n,a,i,o,s){var l,c=function(a){var i=d[u[a]],c=fI.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,c,d,u=fI.getAccessorTypeSize(i.type),h=i.count,_=t.data,f=r.instanceId,v=t.vertexBindingInfos,y=i.normalized,x=fI.getElementFormat(i.componentType,u,y);if(y&&(c=fI.getNormalizedComponentScale(i.componentType)),t.interleaved){var b=i.byteOffset||0,S=t.stride;if(d=b%S,void 0===v[f]){o=new dW(a,d,x,g);var C=t.vertexBuffer;C||(C=new dO(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=C,n.vertexBuffers.push(new fY(C,t.restoreInfo))),r.setVertexBufferBinding(C,S,g),v[f]=g++}else o=new dW(a,d,x,v[f])}else{d=0,o=new dW(a,d,x,g);var T=t.vertexBuffer;T||(T=new dO(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new fY(T,t.restoreInfo))),r.setVertexBufferBinding(T,t.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=r.bounds,M=A.min,E=A.max;if(i.min&&i.max)M.copyFromArray(i.min),E.copyFromArray(i.max);else{var R=e.GLTFMeshParser._tempVector3;M.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),E.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var w=d/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;R.copyFromArray(_,L),cC.min(M,R,M),cC.max(E,R,E)}}y&&(M.scale(c),E.scale(c))}});v.push(c)},d=o.accessors,u=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=r.engine,m=[],g=0,v=[];for(var y in u)c(y);return Promise.all(v).then(function(){if(r.setVertexElements(m),void 0!==_){var c=o.accessors[_],d=fI.getAccessorBuffer(t,o.bufferViews,c).then(function(e){r.setIndices(e.data),r.addSubMesh(0,c.count,f),n.indexBuffer=e.restoreInfo});v.push(d)}else r.addSubMesh(0,l,f);return h&&v.push(e.GLTFMeshParser._createBlendShape(t,r,n,a,i,h)),Promise.all(v).then(function(){return r.uploadData(!s),r})})},s$._getBlendShapeData=function(e,t,r){return fI.getAccessorBuffer(e,t.bufferViews,r).then(function(e){var t,n=e.data,a=e.interleaved?(null!=(t=r.byteOffset)?t:0)%e.stride:0,i=r.count,o=r.normalized,s=r.componentType;return{vertices:fI.bufferToVector3Array(n,a,i,o,s),restoreInfo:new f$(e.restoreInfo,a,i,o,s)}})},s$._createBlendShape=function(e,t,r,n,a,i){for(var o=this,s=e.glTF,l=s.accessors,c=n.extras?n.extras.targetNames:null,d=[],u=i.length,h=Array(u),_=0;_<u;_++)(function(t){var r={};h[t]=r;var n=c?c[t]:"blendShape"+t,i=a.targets[t],u=i.NORMAL,_=i.TANGENT,f=void 0!==u,p=void 0!==_;d.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[u]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new dj(n);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),r.blendShape=o,r.restoreInfo=new fZ(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))})(_);return Promise.all(d).then(function(){for(var e,n=fm(h);!(e=n()).done;){var a=e.value;t.addBlendShape(a.blendShape),r.blendShapes.push(a.restoreInfo)}})},s$._tempVector3=new cC,s$),e.GLTFMeshParser=fe([fB(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(_7(s0=function(){return f1.apply(this,arguments)},f1),(s1=s0.prototype).parse=function(t,r){var n,a=t.glTF,i=a.scene,o=t.glTFResource,s=a.scenes[r],l=s.extensions,c=o.engine,d=s.nodes||[];if(1===d.length)n=t.get(e.GLTFParserType.Entity,d[0]);else{n=new uo(c,"GLTF_ROOT");for(var u=0;u<d.length;u++){var h=t.get(e.GLTFParserType.Entity,d[u]);n.addChild(h)}}(void 0===i?0:i)===r&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<d.length;f++)_.push(this._parseEntityComponent(t,d[f]));return Promise.all(_).then(function(){return f1.executeExtensionsAdditiveAndParse(l,t,n,s),n})},s1._parseEntityComponent=function(t,r){var n,a=this,i=t.glTF,o=t.glTFResource,s=i.nodes[r],l=s.camera,c=s.mesh,d=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,i.cameras[l],d),void 0!==c&&(n=this._createRenderer(t,s,d)),Promise.resolve(n).then(function(){var e=[],r=s.children;if(r)for(var n=0;n<r.length;n++)e.push(a._parseEntityComponent(t,r[n]));return Promise.all(e)})},s1._createCamera=function(t,r,n){var a=r.orthographic,i=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===cc.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,d=a.zfar,u=a.znear;s.isOrthographic=!0,void 0!==u&&(s.nearClipPlane=u),void 0!==d&&(s.farClipPlane=d),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===cc.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},s1._createRenderer=function(t,r,n){for(var a,i=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,d=c.length,u=r.weights||l.weights,h=Array(d),_=0;_<d;_++)h[_]=t.get(e.GLTFParserType.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),Promise.all(h)]).then(function(r){for(var a=r[0],o=r[1],s=r[2],l=0;l<d;l++)!function(r){var l=s[r]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),d=c[r],h=a[r],_=void 0;if(o||u){var f=n.addComponent(ul);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),u&&(f.blendShapeWeights=new Float32Array(u)),_=f}else(_=n.addComponent(dq)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),f1.executeExtensionsAdditiveAndParse(d.extensions,t,_,d)}(l)})},s1._computeLocalBounds=function(e,t,r,n,a){var i=r.indexOf(n);if(-1!==i)cA.transform(t.bounds,a[i],e.localBounds);else{var o=new cF(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,a,n,o);0!==s?(cF.multiplyScalar(o,1/s,o),cA.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},s1._computeApproximateBindMatrix=function(e,t,r,n){for(var a=0,i=r.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(cF.add(n,t[c],n),a++):a+=this._computeApproximateBindMatrix(e,t,l,n)}return a},s0),e.GLTFSceneParser=fe([fB(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(_7(s2=function(){return f1.apply(this,arguments)},f1),(s3=s2.prototype).parse=function(t,r){var n=this,a=t.glTF,i=a.skins[r],o=i.inverseBindMatrices,s=i.skeleton,l=i.joints,c=i.name,d=l.length,u=new us(void 0===c?"SKIN_"+r:c);u.inverseBindMatrices.length=d;var h=Array(d),_=a.accessors[o];return Promise.resolve(fI.getAccessorBuffer(t,a.bufferViews,_).then(function(r){for(var a=t.get(e.GLTFParserType.Entity),i=r.data,o=0;o<d;o++){var c=new cF;c.copyFromArray(i,16*o),u.inverseBindMatrices[o]=c;var _=a[l[o]];h[o]=_,u.joints[o]=_.name}if(u.bones=h,void 0!==s){var f=a[s];u.rootBone=f}else{var p=n._findSkeletonRootBone(l,a);if(p)u.rootBone=p;else throw"Failed to find skeleton root bone."}return u}))},s3._findSkeletonRootBone=function(e,t){for(var r,n={},a=fm(e);!(r=a()).done;){for(var i=r.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;n[i]=o}for(var l=null,c=0;;c++){var d=n[e[0]];if(c>=d.length)return l;for(var u=d[c],h=1,_=e.length;h<_;h++)if(c>=(d=n[e[h]]).length||u!==d[c])return l;l=u}},s2),e.GLTFSkinParser=fe([fB(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(_7(s4=function(){return f1.apply(this,arguments)},f1),s4.prototype.parse=function(t,r){var n=t.glTF.textures[r],a=t.glTFResource,i=t.glTF,o=a.engine,s=a.url,l=n.sampler,c=n.source,d=n.name,u=n.extensions,h=i.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=f1.executeExtensionsCreateAndParse(u,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&fI.getSamplerInfo(i.samplers[l]);if(_){var x=_.lastIndexOf("."),b=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:c0.resolveAbsoluteUrl(s,_),type:b,params:{mipmap:null==y?void 0:y.mipmap}}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name=d||m||e.name||"texture_"+r,v&&fI.parseSampler(e,y),e}),t._addTaskCompletePromise(g)}else{var S=i.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[S.buffer],a=new Uint8Array(n,S.byteOffset,S.byteLength);return fI.loadImageBuffer(a,p).then(function(e){var n=new dQ(o,e.width,e.height,void 0,null==y?void 0:y.mipmap);n.setImageSource(e),n.generateMipmaps(),n.name=d||m||"texture_"+r,v&&fI.parseSampler(n,y);var a=new fX(n,S,p);return t.contentRestorer.bufferTextures.push(a),n})})}}return Promise.resolve(g).then(function(e){return f1.executeExtensionsAdditiveAndParse(u,t,e,n),e._associationSuperResource(a),e})},s4._wrapMap=((s8={})[cf.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,s8[cf.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,s8[cf.REPEAT]=e.TextureWrapMode.Repeat,s8),s4),e.GLTFTextureParser=fe([fB(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(_7(s5=function(){return f1.apply(this,arguments)},f1),s5.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,a=t.extensionsRequired,i=Number(r);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(n){dr.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];f1.hasExtensionParser(s)||dr.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){dr.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];f1.hasExtensionParser(c)||dr.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},s5),e.GLTFValidator=fe([fB(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(_7(s9=function(){return f1.apply(this,arguments)},f1),s9.prototype.parse=function(t,r){var n=t.glTF.bufferViews[r],a=n.extensions,i=n.byteOffset,o=void 0===i?0:i,s=n.byteLength,l=n.buffer;return a?f1.executeExtensionsCreateAndParse(a,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},s9),e.GLTFBufferViewParser=fe([fB(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=(_7(s6=function(){return f1.apply(this,arguments)},f1),(s7=s6.prototype).parse=function(t){var r=this;return t.needAnimatorController?t.get(e.GLTFParserType.Animation).then(function(e){return Promise.resolve(r._createAnimatorController(e))}):Promise.resolve(null)},s7._createAnimatorController=function(e){var t=new h5,r=new h9("layer"),n=new _e;if(t.addLayer(r),r.stateMachine=n,e)for(var a=0;a<e.length;a++){var i=e[a],o=i.name,s=n.makeUniqueStateName(o);s!==o&&console.warn("AnimatorState name is existed, name: "+o+" reset to "+s),n.addState(s).clip=i}return t},s6),e.GLTFAnimatorControllerParser=fe([fB(e.GLTFParserType.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=(_7(le=function(){return hG.apply(this,arguments)},hG),(lt=le.prototype).initialize=function(e,t){var r,n,a,i=null!=(a=null==(r=t.glTFLoader)?void 0:r.meshOpt)?a:null==(n=t.glTF)?void 0:n.meshOpt;return i?f4().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},lt.load=function(e,t){var r=e.url,n=e.params,a=new fw(t.engine,r),i=new fP(a,t,_9({keepMeshData:!1},n));return new uz(function(e,t,r,n){i._setTaskCompleteProgress=r,i._setTaskDetailProgress=n,i.parse().then(e).catch(t)})},le.release=function(){cx&&f4().then(function(e){e.release()})},le),e.GLTFLoader=fe([uG(e.AssetType.GLTF,["gltf","glb"])],e.GLTFLoader);var f8=Math.PI,f5=(_7(lr=function(){return hG.apply(this,arguments)},hG),lr.prototype.load=function(t,r){var n=this;return new uz(function(a,i){var o=r.engine;n.request(t.url,_9({},t,{type:"arraybuffer"})).then(function(t){for(var r=new Uint8Array(t),n=f5._parseHeader(r),i=n.width,s=n.height,l=n.dataPosition,c=f5._readPixels(r.subarray(l),i,s),d=s>>1,u=f5._convertToCubemap(c,i,s,d),h=new dZ(o,d),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,u[_],0);h.generateMipmaps(),a(h)}).catch(i)})},lr._convertToCubemap=function(e,t,r,n){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*r*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(n,this._faceRight,e,t,r),this._createCubemapData(n,this._faceLeft,e,t,r),this._createCubemapData(n,this._faceUp,e,t,r),this._createCubemapData(n,this._faceBottom,e,t,r),this._createCubemapData(n,this._faceFront,e,t,r),this._createCubemapData(n,this._faceBack,e,t,r)]},lr._createCubemapData=function(e,t,r,n,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,d=0;d<e;d++){for(var u=this._temp3Vector3.set(0,0,0).add(t[0]),h=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(h).subtract(u).scale(c).add(u);f.normalize();var p=this._calcProjectionSpherical(f,r,n,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=d*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,u.add(o),h.add(s)}c+=l}return i},lr._calcProjectionSpherical=function(e,t,r,n){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-f8;)a+=2*f8;for(;a>f8;)a-=2*f8;var o=a/f8,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(i/f8*n);l<0?l=0:l>=n&&(l=n-1);var c=(n-l-1)*r*4+4*s,d=t[c],u=t[c+1],h=t[c+2],_=t[c+3];return new cI(d,u,h,_)},lr._readStringLine=function(e,t){for(var r="",n="",a=t;a<e.length-t&&"\n"!=(n=String.fromCharCode(e[a]));a++)r+=n;return r},lr._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?i=!0:0==n.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=n.length+1,n=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(n);if(!s||s.length<3)throw"HDR Bad header format, no size";if(r=parseInt(s[2]),t=parseInt(s[1]),r<8||r>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:r,dataPosition:o+=n.length+1}},lr._readPixels=function(e,t,r){for(var n=e.byteLength,a=new Uint8Array(4*t*r),i=0,o=0,s=4*t,l=new Uint8Array(s),c=r;c>0&&o<n;){var d=e[o++],u=e[o++],h=e[o++],_=e[o++];if(2!=d||2!=u||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<n;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},lr._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},lr._linearToRGBM=function(e,t){var r=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),n=65025/((r=Math.ceil(255*r))*t);e.r*=n,e.g*=n,e.b*=n,e.a*=r},lr._rightBottomBack=new cC(1,-1,-1),lr._rightBottomFront=new cC(1,-1,1),lr._rightUpBack=new cC(1,1,-1),lr._rightUpFront=new cC(1,1,1),lr._leftBottomBack=new cC(-1,-1,-1),lr._leftBottomFront=new cC(-1,-1,1),lr._leftUpBack=new cC(-1,1,-1),lr._leftUpFront=new cC(-1,1,1),lr._faceRight=[lr._rightBottomBack,lr._rightBottomFront,lr._rightUpBack,lr._rightUpFront],lr._faceLeft=[lr._leftBottomFront,lr._leftBottomBack,lr._leftUpFront,lr._leftUpBack],lr._faceUp=[lr._leftBottomFront,lr._rightBottomFront,lr._leftBottomBack,lr._rightBottomBack],lr._faceBottom=[lr._leftUpBack,lr._rightUpBack,lr._leftUpFront,lr._rightUpFront],lr._faceFront=[lr._leftBottomBack,lr._rightBottomBack,lr._leftUpBack,lr._rightUpBack],lr._faceBack=[lr._rightBottomFront,lr._leftBottomFront,lr._rightUpFront,lr._leftUpFront],lr._tempVector3=new cC,lr._temp2Vector3=new cC,lr._temp3Vector3=new cC,lr._temp4Vector3=new cC,lr._temp5Vector3=new cC,lr);f5=fe([uG(e.AssetType.HDR,["hdr"])],f5);var f9=(_7(ln=function(){return hG.apply(this,arguments)},hG),ln.prototype.load=function(e){return this.request(e.url,_9({},e,{type:"json"}))},ln);f9=fe([uG(e.AssetType.JSON,["json"],!1)],f9);var f6={parse:function(t,r,n,a){if(void 0===a&&(a=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(t))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var i=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*i),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*i,s),glTypeSize:o.getUint32(2*i,s),glFormat:o.getUint32(3*i,s),glInternalFormat:o.getUint32(4*i,s),glBaseInternalFormat:o.getUint32(5*i,s),pixelWidth:o.getUint32(6*i,s),pixelHeight:o.getUint32(7*i,s),pixelDepth:o.getUint32(8*i,s),numberOfArrayElements:o.getUint32(9*i,s),numberOfFaces:o.getUint32(10*i,s),numberOfMipmapLevels:o.getUint32(11*i,s),bytesOfKeyValueData:o.getUint32(12*i,s),loadType:0};if(0!==l.glType)throw Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),0===l.pixelHeight||0!==l.pixelDepth)throw Error("only 2D textures currently supported");if(0!==l.numberOfArrayElements)throw Error("texture arrays not currently supported");if(l.numberOfFaces!==r)throw Error("number of faces expected"+r+", but found "+l.numberOfFaces);return n&&(l.mipmaps=function(e,t){for(var r=[],n=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,n,1)[0];n+=4;for(var c=0;c<e.numberOfFaces;c++){var d=new Uint8Array(e.buffer,n,l);r.push({data:d,width:a,height:i}),n+=l+(3-(l+3)%4)}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return r}(l,!0)),a&&(l.engineFormat=function(t){switch(t){case e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:return e.TextureFormat.BC1;case e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:return e.TextureFormat.BC3;case e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT:return e.TextureFormat.BC7;case e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL:return e.TextureFormat.ETC1_RGB;case e.GLCompressedTextureInternalFormat.RGB8_ETC2:return e.TextureFormat.ETC2_RGB;case e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return e.TextureFormat.ETC2_RGBA5;case e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC:return e.TextureFormat.ETC2_RGBA8;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGB2;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA2;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGB4;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR:return e.TextureFormat.ASTC_4x4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR:return e.TextureFormat.ASTC_5x5;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR:return e.TextureFormat.ASTC_6x6;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR:return e.TextureFormat.ASTC_8x8;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR:return e.TextureFormat.ASTC_10x10;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR:return e.TextureFormat.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+e.GLCompressedTextureInternalFormat[t])}}(l.glInternalFormat)),l}};function f7(e){var t=f6.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var pe=(_7(la=function(){return hG.apply(this,arguments)},hG),la.prototype.load=function(t,r){var n=this;return new uz(function(a,i){Promise.all(t.urls.map(function(e){return n.request(e,_9({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,a,i=[],o=0;o<e.length;o++){var s=f6.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(n=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:i,engineFormat:r,internalFormat:t,width:n,height:a}}(t),i=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new dZ(r.engine,i,s,l),d=0;d<6;d++)for(var u=o[d].length,h=0;h<u;h++){var _=o[d][h],f=_.data,p=_.width,m=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+d,f,h,0,0,p,m)}a(c)}).catch(function(e){i(e)})})},la);pe=fe([uG(e.AssetType.KTXCube,[])],pe);var pt=(_7(li=function(){return hG.apply(this,arguments)},hG),li.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"arraybuffer"})).then(function(e){for(var r=f7(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new dQ(t.engine,a,i,s,l),d=0;d<o.length;d++){var u=o[d],h=u.width,_=u.height,f=u.data;c.setPixelBuffer(f,d,0,0,h,_)}n(c)}).catch(function(e){a(e)})})},li);pt=fe([uG(e.AssetType.KTX,["ktx"])],pt);var pr=(_7(lo=function(){return hG.apply(this,arguments)},hG),lo.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,a=r.value;switch(n){case"Vector2":h.setVector2(e,new cD(a.x,a.y));break;case"Vector3":h.setVector3(e,new cC(a.x,a.y,a.z));break;case"Vector4":h.setVector4(e,new cB(a.x,a.y,a.z,a.w));break;case"Color":h.setColor(e,new cI(a.r,a.g,a.b,a.a));break;case"Float":h.setFloat(e,a);break;case"Texture":u.push(t.getResourceByRef(a).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,a?1:0);break;case"Integer":h.setInt(e,Number(a))}},a=t.engine,i=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,d=new uS(a,dw.find(o));d.name=i;var u=[],h=d.shaderData;for(var _ in s)r(_);for(var f=0,p=l.length;f<p;f++){var m=l[f],g=m.name,v=m.value;void 0==v?h.enableMacro(g):h.enableMacro(g,v)}return function e(t,r,n){if("object"==typeof n)for(var a in n)e(t[r],a,n[a]);else t[r]=n}(d,"renderState",c),Promise.all(u).then(function(){n(d)})}).catch(a)})},lo);pr=fe([uG(e.AssetType.Material,["json"])],pr);var pn=(_7(ls=function(){return hG.apply(this,arguments)},hG),ls.prototype.load=function(e,t){var r=this;return new uz(function(n,a){r.request(e.url,_9({},e,{type:"arraybuffer"})).then(function(e){return fb(e,t.engine)}).then(function(e){n(e)}).catch(a)})},ls);pn=fe([uG(e.AssetType.Mesh,["mesh"])],pn);var pa=(_7(ll=function(){return hG.apply(this,arguments)},hG),ll.prototype.load=function(e,t){var r=t.engine;return this.request(e.url,_9({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return un.createSubdivisionSurfaceSphere(r,e.sphereRadius,e.sphereStep);case"capsule":return un.createCapsule(r,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return un.createCone(r,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return un.createCuboid(r,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return un.createCylinder(r,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return un.createPlane(r,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return un.createTorus(r,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},ll);pa=fe([uG(e.AssetType.PrimitiveMesh,["mesh"],!1)],pa),(lc=cb||(cb={})).Sphere="sphere",lc.Cuboid="cuboid",lc.Plane="plane",lc.Cylinder="cylinder",lc.Torus="torus",lc.Cone="cone",lc.Capsule="capsule";var pi=(_7(ld=function(){return hG.apply(this,arguments)},hG),ld.prototype.load=function(t,r){var n=this,a=r.engine;return new uz(function(i,o){n.request(t.url,_9({},t,{type:"json"})).then(function(t){return a.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){a.sceneManager.activeScene=e,i()})}).catch(o)})},ld);pi=fe([uG(e.AssetType.Project,["proj"],!1)],pi);var po=(_7(lu=function(){return hG.apply(this,arguments)},hG),(lh=lu.prototype).load=function(e,t){var r=this;return new uz(function(n,a){var i=e.url;r._registerFont(i,i).then(function(){n(new uv(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},lh._registerFont=function(e,t){return fE(function(){var r;return ft(this,function(n){switch(n.label){case 0:return[4,(r=new FontFace(e,"url("+t+")")).load()];case 1:return n.sent(),document.fonts.add(r),[2]}})})()},lu);po=fe([uG(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],po);var ps=(_7(l_=function(){var e;return e=hG.apply(this,arguments)||this,e._tempRect=new cV,e._tempVec2=new cD,e._tempVec4=new cB,e},hG),(lf=l_.prototype).load=function(t,r){var n=this;return new uz(function(a,i,o,s,l){var c=[];l(function(){for(var e=0;e<c.length;e++)c[e].cancel()});var d=n.request(t.url,_9({},t,{type:"json"}));c.push(d),d.then(function(o){var s=o.atlasItems,l=o.mipmap,d=o.anisoLevel,u=o.filterMode,h=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,m=r.engine,g=new c$(m);if(p<0){a(g);return}c.length=0;for(var v=0;v<s.length;v++)!function(a){var o,p=s[a];if(p.img)c.push(r.load({url:c0.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:l}}).then(function(e){d&&(e.anisoLevel=d),void 0!==u&&(e.filterMode=u),void 0!==h&&(e.wrapModeU=h),void 0!==_&&(e.wrapModeV=_);for(var t=0;t<p.sprites.length;t++)g._addSprite(n._makeSprite(m,p.sprites[t],e))}).catch(i));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);uz.all(c).then(function(){a(g)}).catch(i)}).catch(i)})},lf._makeSprite=function(e,t,r){var n=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,d=new c8(e,r,n?this._tempRect.set(n.x,n.y,n.w,n.h):void 0,o?this._tempVec2.set(o.x,o.y):void 0,s?this._tempVec4.set(s.x,s.y,s.z,s.w):void 0,t.name);if(r){var u=1/r.width,h=1/r.height;if(d.atlasRegion.set(i.x*u,i.y*h,i.w*u,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.w;d.atlasRegionOffset.set(_*u,f*h,p*u,m*h)}t.atlasRotated&&(d.atlasRotated=!0)}return isNaN(l)||(d.width=l),isNaN(c)||(d.height=c),d},l_);ps=fe([uG(e.AssetType.SpriteAtlas,["atlas"],!1)],ps);var pl=(_7(lp=function(){return hG.apply(this,arguments)},hG),(lm=lp.prototype).load=function(e,t){var r=this;return this.request(e.url,_9({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},lm._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},lm._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new c8(e.engine,r,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),n}):new uz(function(r){var n=new c8(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),r(n)})},lp);pl=fe([uG(e.AssetType.Sprite,["sprite"],!1)],pl);var pc=(_7(lg=function(e,t,r){var n;return(n=d2.call(this,e)||this).url=t,n.requestConfig=r,n},d2),lg.prototype.restoreContent=function(){var e=this;return hz(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},lg),pd=(_7(lv=function(){return hG.apply(this,arguments)},hG),lv.prototype.load=function(e,t){var r=this;return new uz(function(n,a,i,o){var s=e.url,l=_9({},e,{type:"image"});r.request(s,l).onProgress(i,o).then(function(r){var a,i=null!=(a=e.params)?a:{},o=i.format,c=i.mipmap,d=i.anisoLevel,u=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new dQ(t.engine,r.width,r.height,o,c);if(f.anisoLevel=null!=d?d:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=u?u:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==s.indexOf("data:")){var p=s.lastIndexOf("/");f.name=s.substring(p+1)}t.addContentRestorer(new pc(f,s,l)),n(f)}).catch(function(e){a(e)})})},lv);pd=fe([uG(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],pd);var pu=(_7(ly=function(e,t,r){var n;return(n=d2.call(this,e)||this).urls=t,n.requestConfig=r,n},d2),ly.prototype.restoreContent=function(){var t=this;return new uz(function(r,n){Promise.all(t.urls.map(function(e){return hz(e,t.requestConfig)})).then(function(n){for(var a=t.resource,i=0;i<6;i++)a.setImageSource(e.TextureCubeFace.PositiveX+i,n[i],0);a.generateMipmaps(),r(a)}).catch(function(e){n(e)})})},ly),ph=(_7(lx=function(){return hG.apply(this,arguments)},hG),lx.prototype.load=function(t,r){var n=this;return new uz(function(a,i){var o=t.urls,s=_9({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],i=n.width;if(i!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new dZ(r.engine,i),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new pu(l,o,s)),a(l)}).catch(function(e){i(e)})})},lx);ph=fe([uG(e.AssetType.TextureCube,[""])],ph);var p_=(_7(lb=function(){return hG.apply(this,arguments)},hG),lb.prototype.load=function(t,r){var n=this,a=r.engine;return new uz(function(i,o){n.request(t.url,_9({},t,{type:"json"})).then(function(t){return fx.parse(a,t).then(function(n){var a,o,s=[],l=t.scene.ambient;if(l){var c=l.specularMode===e.SpecularMode.Custom,d=l.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=l.diffuseIntensity,n.ambientLight.specularIntensity=l.specularIntensity,n.ambientLight.diffuseMode=l.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(l.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,c&&l.customAmbientLight&&s.push(r.getResourceByRef(l.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),l.ambientLight&&(!c||d)&&s.push(r.getResourceByRef(l.ambientLight).then(function(e){c||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),d&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=t.scene.background;switch(n.background.mode=u.mode,n.background.mode){case e.BackgroundMode.SolidColor:n.background.solidColor.copyFrom(u.color);break;case e.BackgroundMode.Sky:if(u.skyMesh&&u.skyMaterial){var h=r.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),_=r.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});s.push(h,_)}else dr.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var f,p=r.getResourceByRef(u.texture).then(function(e){n.background.texture=e});s.push(p),n.background.textureFillMode=null!=(f=u.textureFillMode)?f:n.background.textureFillMode}}var m=t.scene.shadow;m&&(void 0!=m.castShadows&&(n.castShadows=m.castShadows),void 0!=m.shadowResolution&&(n.shadowResolution=m.shadowResolution),void 0!=m.shadowDistance&&(n.shadowDistance=m.shadowDistance),void 0!=m.shadowCascades&&(n.shadowCascades=m.shadowCascades),n.shadowTwoCascadeSplits=null!=(a=m.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,m.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(m.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(o=m.shadowFadeBorder)?o:n.shadowFadeBorder);var g=t.scene.fog;return g&&(void 0!=g.fogMode&&(n.fogMode=g.fogMode),void 0!=g.fogStart&&(n.fogStart=g.fogStart),void 0!=g.fogEnd&&(n.fogEnd=g.fogEnd),void 0!=g.fogDensity&&(n.fogDensity=g.fogDensity),void 0!=g.fogColor&&n.fogColor.copyFrom(g.fogColor)),Promise.all(s).then(function(){i(n)})})}).catch(o)})},lb);p_=fe([uG(e.AssetType.Scene,["scene"],!0)],p_),fh.registerCustomParseComponent("TextRenderer",fE(function(e,t){var r;return ft(this,function(n){return(r=t.props).font||(e.font=uv.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var pf=(_7(lS=function(){return f0.apply(this,arguments)},f0),lS.prototype.additiveParse=function(e,t,r){var n,a=e.glTF.extensions.KHR_lights_punctual.lights[r.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,d=e.glTFResource;if("directional"===s?n=t.addComponent(hy):"point"===s?n=t.addComponent(hx):"spot"===s&&(n=t.addComponent(hb)),i&&n.color.set(i[0],i[1],i[2],1),n.intensity=void 0===o?1:o,l&&!f3(n,hy)&&(n.distance=l),c&&f3(n,hb)){var u=c.innerConeAngle,h=void 0===u?0:u,_=c.outerConeAngle;n.angle=h,n.penumbra=(void 0===_?Math.PI/4:_)-h}d.lights||(d.lights=[]),d.lights.push(n)},lS);pf=fe([f2("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],pf);var pp=(_7(lC=function(){return f0.apply(this,arguments)},f0),lC.prototype.additiveParse=function(t,r,n){var a=n.clearcoatFactor,i=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===a?0:a,r.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(e.GLTFParserType.Texture,i.index).then(function(e){r.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(e.GLTFParserType.Texture,l.index).then(function(e){r.clearCoatNormalTexture=e}))},lC);pp=fe([f2("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],pp);var pm=(_7(lT=function(){return f0.apply(this,arguments)},f0),lT.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},lT);pm=fe([f2("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],pm);var pg=(_7(lA=function(){return f0.apply(this,arguments)},f0),lA.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new uE(a),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,d=r.specularGlossinessTexture;return o&&(i.baseColor=new cI(cI.linearToGammaSpace(o[0]),cI.linearToGammaSpace(o[1]),cI.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,f1.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new cI(cI.linearToGammaSpace(l[0]),cI.linearToGammaSpace(l[1]),cI.linearToGammaSpace(l[2]))),void 0!==c&&(i.glossiness=c),d&&(e.GLTFMaterialParser._checkOtherTextureTransform(d,"Specular glossiness"),t.get(e.GLTFParserType.Texture,d.index).then(function(e){i.specularGlossinessTexture=e})),i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lA);pg=fe([f2("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],pg);var pv=(_7(lM=function(){return f0.apply(this,arguments)},f0),lM.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new uR(a);return i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lM);pv=fe([f2("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],pv);var py=(_7(lE=function(){return f0.apply(this,arguments)},f0),lE.prototype.additiveParse=function(t,r,n){var a=t.glTF.extensions.KHR_materials_variants.variants,i=t.glTFResource,o=n.mappings;i._extensionsData||(i._extensionsData={});var s=[];i.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var i=o[n],l=i.material,c=i.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return a[e].name})})})}(l)},lE);py=fe([f2("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],py);var px=(_7(lR=function(){return f0.apply(this,arguments)},f0),lR);px=fe([f2("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],px);var pb=(_7(lw=function(){return f0.apply(this,arguments)},f0),lw.prototype.createAndParse=function(t,r,n){return fE(function(){var a,i,o,s,l,c,d,u,h,_,f,p,m,g,v,y;return ft(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=n.sampler,c=n.name,d=r.source,h=(u=a.images[d]).uri,_=u.bufferView,f=u.mimeType,p=u.name,m=void 0!==l&&fI.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:c0.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&fI.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,y.buffer).then(function(r){var n=new Uint8Array(r,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&fI.parseSampler(e,m);var r=new fX(e,y,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},lw);pb=fe([f2("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],pb);var pS=(_7(lP=function(){return f0.apply(this,arguments)},f0),lP.prototype.additiveParse=function(e,t,r){var n=r.offset,a=r.rotation,i=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&dr.warn("rotation in KHR_texture_transform is not supported now"),o&&dr.warn("texCoord in KHR_texture_transform is not supported now")},lP);pS=fe([f2("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],pS);var pC=(_7(lF=function(){return f0.apply(this,arguments)},f0),lF.prototype.createAndParse=function(e,t){var r=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(r),r},lF);pC=fe([f2("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],pC);var pT=(_7(lL=function(){return f0.apply(this,arguments)},f0),lL.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new hJ;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},lL);pT=fe([f2("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],pT);var pA=(_7(lD=function(){return f0.apply(this,arguments)},f0),lD.prototype.createAndParse=function(t,r){return t.get(e.GLTFParserType.Buffer,r.buffer).then(function(e){return f4().then(function(t){return t.decodeGltfBuffer(r.count,r.byteStride,new Uint8Array(e,r.byteOffset,r.byteLength),r.mode,r.filter)})})},lD);pA=fe([f2("EXT_meshopt_compression",e.GLTFExtensionMode.CreateAndParse)],pA);var pM=(_7(lB=function(){return f0.apply(this,arguments)},f0),lB.prototype.additiveParse=function(t,r,n){var a=n.anisotropyStrength,i=n.anisotropyRotation,o=n.anisotropyTexture;r.anisotropy=void 0===a?0:a,r.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(e.GLTFParserType.Texture,o.index).then(function(e){r.anisotropyTexture=e}))},lB);pM=fe([f2("KHR_materials_anisotropy",e.GLTFExtensionMode.AdditiveParse)],pM);var pE="1.2.0";for(var pR in console.log("Galacean engine version: "+pE),_U)hG.registerClass(pR,_U[pR]);e.AmbientLight=hg,e.AnimationClip=hZ,e.AnimationClipCurveBinding=hQ,e.AnimationCurve=h$,e.AnimationEvent=hJ,e.Animator=h8,e.AnimatorController=h5,e.AnimatorControllerLayer=h9,e.AnimatorLayerMask=_n,e.AnimatorState=h7,e.AnimatorStateMachine=_e,e.AnimatorStateTransition=h1,e.AssetPromise=uz,e.Background=hp,e.BaseMaterial=uC,e.Basic2DBatcher=ud,e.BasicRenderPipeline=hV,e.BlendShape=dj,e.BlendShapeFrame=dK,e.BlendState=dT,e.BlinnPhongMaterial=uT,e.BoolUpdateFlag=dc,e.BoundingBox=cA,e.BoundingFrustum=cR,e.BoundingSphere=cT,e.BoxColliderShape=he,e.BoxShape=_R,e.Buffer=dO,e.BufferInfo=fF,e.BufferMesh=dX,e.BufferUtil=dN,e.Burst=_A,e.Canvas=h_,e.CapsuleColliderShape=hn,e.CharacterController=uZ,e.CircleShape=_w,e.CloneManager=cQ,e.ColliderShape=u7,e.CollisionUtil=cM,e.Color=cI,e.ColorOverLifetimeModule=__,e.Component=di,e.ConeShape=_P,e.ContentRestorer=d2,e.CubeProbe=_z,e.CurveKey=_y,e.DepthState=dA,e.DirectLight=hy,e.DynamicCollider=u$,e.EmissionModule=_p,e.Engine=hh,e.EngineObject=cJ,e.Entity=uo,e.EventDispatcher=c5,e.FixedJoint=u4,e.Font=uv,e.GLTFExtensionParser=f0,e.GLTFParser=f1,e.GLTFParserContext=fP,e.GLTFResource=fw,e.GLTFUtils=fI,e.GradientAlphaKey=_d,e.GradientColorKey=_c,e.HemisphereShape=_F,e.HingeJoint=u8,e.HitResult=u0,e.IndexBufferBinding=dk,e.InputManager=ho,e.JointLimits=u9,e.JointMotor=u6,e.Keyframe=_t,e.Light=hv,e.Loader=hG,e.Logger=dr,e.MainModule=_m,e.Material=uS,e.MathUtil=cS,e.Matrix=cF,e.Matrix3x3=cw,e.Mesh=dG,e.MeshRenderer=dq,e.ModelMesh=d0,e.PBRBaseMaterial=uA,e.PBRMaterial=uM,e.PBRSpecularMaterial=uE,e.ParserContext=f_,e.ParticleCompositeCurve=_f,e.ParticleCompositeGradient=_u,e.ParticleCurve=_v,e.ParticleGenerator=_C,e.ParticleGradient=_l,e.ParticleMaterial=_T,e.ParticleRenderer=_s,e.PhysicsMaterial=u1,e.PhysicsScene=uJ,e.Plane=cE,e.PlaneColliderShape=hr,e.PointLight=hx,e.Pointer=uj,e.PrefabParser=fv,e.Primitive=dU,e.PrimitiveMesh=un,e.Probe=_V,e.Quaternion=cP,e.Rand=cN,e.RasterState=dM,e.Ray=cL,e.Rect=cV,e.ReferResource=cZ,e.ReflectionParser=fh,e.RenderQueue=hR,e.RenderState=dR,e.RenderTarget=dY,e.RenderTargetBlendState=dC,e.ResourceManager=uU,e.RotationOverLifetimeModule=_g,e.Scene=hC,e.SceneManager=uk,e.SceneParser=fx,e.Script=hT,e.Shader=dw,e.ShaderData=dL,e.ShaderFactory=dp,e.ShaderLib=df,e.ShaderMacro=du,e.ShaderMacroCollection=dh,e.ShaderPass=db,e.ShaderProperty=dn,e.ShaderTagKey=dm,e.SizeOverLifetimeModule=_x,e.Skin=us,e.SkinnedMeshRenderer=ul,e.Sky=hf,e.SkyBoxMaterial=_a,e.SkyProceduralMaterial=_i,e.SphereColliderShape=ht,e.SphereShape=_L,e.SphericalHarmonics3=cO,e.SpotLight=hb,e.SpringJoint=u5,e.Sprite=c8,e.SpriteAtlas=c$,e.SpriteMask=uf,e.SpriteRenderer=u_,e.StateMachineScript=h6,e.StaticCollider=u2,e.StencilState=dE,e.SubMesh=dz,e.SubShader=dS,e.SystemInfo=uY,e.TextRenderer=ub,e.TextUtils=um,e.Texture=dF,e.Texture2D=dQ,e.Texture2DArray=dJ,e.TextureCube=dZ,e.TextureSheetAnimationModule=_b,e.Time=da,e.TrailMaterial=_D,e.TrailRenderer=_I,e.Transform=dd,e.UnlitMaterial=uR,e.Utils=c0,e.Vector2=cD,e.Vector3=cC,e.Vector4=cB,e.VelocityOverLifetimeModule=_S,e.VertexBufferBinding=dH,e.VertexElement=dW,e.WebCanvas=_X,e.WebGLEngine=_q,e.WebGLGraphicDevice=_5,e.XRManager=hu,e.assignmentClone=cX,e.decode=fb,e.deepClone=cY,e.dependentComponents=dl,e.ignoreClone=cj,e.parseSingleKTX=f7,e.registerGLTFExtension=f2,e.registerGLTFParser=fB,e.request=hz,e.resourceLoader=uG,e.shallowClone=cq,e.version=pE,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=browser.min.js.map