@galacean/engine 1.1.2 → 1.1.3

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 +1 @@
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,(lp=e.ContainmentType||(e.ContainmentType={}))[lp.Disjoint=0]="Disjoint",lp[lp.Contains=1]="Contains",lp[lp.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(lm=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[lm.Back=0]="Back",lm[lm.Front=1]="Front",lm[lm.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(lg=e.FrustumFace||(e.FrustumFace={}))[lg.Near=0]="Near",lg[lg.Far=1]="Far",lg[lg.Left=2]="Left",lg[lg.Right=3]="Right",lg[lg.Bottom=4]="Bottom",lg[lg.Top=5]="Top";var i,a,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,S,C,T,A,E,M,R,w,b,P,F,L,D,B,I,V,O,N,z,U,k,G,H,W,X,K,j,Y,q,Q,Z,J,$,ee,et,er,en,ei,ea,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eS,eC,eT,eA,eE,eM,eR,ew,eb,eP,eF,eL,eD,eB,eI,eV,eO,eN,ez,eU,ek,eG,eH,eW,eX,eK,ej,eY,eq,eQ,eZ,eJ,e$,e0,e1,e2,e3,e4,e5,e8,e6,e7,e9,te,tt,tr,tn,ti,ta,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv,ty,tx,tS,tC,tT,tA,tE,tM,tR,tw,tb,tP,tF,tL,tD,tB,tI,tV,tO,tN,tz,tU,tk,tG,tH,tW,tX,tK,tj,tY,tq,tQ,tZ,tJ,t$,t0,t1,t2,t3,t4,t5,t8,t6,t7,t9,re,rt,rr,rn,ri,ra,ro,rs,rl,rc,ru,rd,rh,r_,rf,rp,rm,rg,rv,ry,rx,rS,rC,rT,rA,rE,rM,rR,rw,rb,rP,rF,rL,rD,rB,rI,rV,rO,rN,rz,rU,rk,rG,rH,rW,rX,rK,rj,rY,rq,rQ,rZ,rJ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ne,nt,nr,nn,ni,na,no,ns,nl,nc,nu,nd,nh,n_,nf,np,nm,ng,nv,ny,nx,nS,nC,nT,nA,nE,nM,nR,nw,nb,nP,nF,nL,nD,nB,nI,nV,nO,nN,nz,nU,nk,nG,nH,nW,nX,nK,nj,nY,nq,nQ,nZ,nJ,n$,n0,n1,n2,n3,n4,n5,n8,n6,n7,n9,ie,it,ir,ii,ia,io,is,il,ic,iu,id,ih,i_,ip,im,ig,iv,iy,ix,iS,iC,iT,iA,iE,iM,iR,iw,ib,iP,iF,iL,iD,iB,iI,iV,iO,iN,iz,iU,ik,iG,iH,iW,iX,iK,ij,iY,iq,iQ,iZ,iJ,i$,i0,i1,i2,i3,i4,i5,i8,i6,i7,i9,ae,at,ar,an,ai,aa,ao,as,al,ac,au,ad,ah,a_,af,ap,am,ag,av,ay,ax,aS,aC,aT,aA,aE,aM,aR,aw,ab,aP,aF,aL,aD,aB,aI,aV,aO,aN,az,aU,ak,aG,aH,aW,aX,aK,aj,aY,aq,aQ,aZ,aJ,a$,a0,a1,a2,a3,a4,a5,a8,a6,a7,a9,oe,ot,or,on,oi,oa,oo,os,ol,oc,ou,od,oh,o_,of,op,om,og,ov,oy,ox,oS,oC,oT,oA,oE,oM,oR,ow,ob,oP,oF,oL,oD,oB,oI,oV,oO,oN,oz,oU,ok,oG,oH,oW,oX,oK,oj,oY,oq,oQ,oZ,oJ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st,sr,sn,si,sa,so,ss,sl,sc,su,sd,sh,s_,sf,sp,sm,sg,sv,sy,sx,sS,sC,sT,sA,sE,sM,sR,sw,sb,sP,sF,sL,sD,sB,sI,sV,sO,sN,sz,sU,sk,sG,sH,sW,sX,sK,sj,sY,sq,sQ,sZ,sJ,s$,s0,s1,s2,s3,s4,s5,s8,s6,s7,s9,le,lt,lr,ln,li,la,lo,ls,ll,lc,lu,ld,lh,l_,lf,lp,lm,lg,lv,ly,lx,lS,lC,lT,lA,lE,lM,lR,lw,lb,lP,lF,lL,lD,lB,lI,lV,lO,lN,lz,lU,lk,lG,lH,lW,lX,lK,lj,lY,lq,lQ,lZ,lJ,l$,l0,l1,l2,l3,l4,l5,l8,l6,l7=((lv=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},lv.equals=function(e,t){return Math.abs(e-t)<=lv.zeroTolerance},lv.isPowerOf2=function(e){return(e&e-1)==0},lv.radianToDegree=function(e){return e*lv.radToDegreeFactor},lv.degreeToRadian=function(e){return e*lv.degreeToRadFactor},lv);l7.zeroTolerance=1e-6,l7.radToDegreeFactor=180/Math.PI,l7.degreeToRadFactor=Math.PI/180;var l9=((a=(i=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},a.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},a.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},a.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},a.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},a.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},a.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},a.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},a.normalize=function(){return i.normalize(this,this),this},a.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},a.transformNormal=function(e){return i.transformNormal(this,e,this),this},a.transformToVec3=function(e){return i.transformToVec3(this,e,this),this},a.transformCoordinate=function(e){return i.transformCoordinate(this,e,this),this},a.transformByQuat=function(e){return i.transformByQuat(this,e,this),this},a.clone=function(){return new i(this._x,this._y,this._z)},a.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},a.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},a.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},a.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},i.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()},i.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()},i.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()},i.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()},i.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},i.cross=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z;r.set(i*l-a*s,a*o-n*l,n*s-i*o)},i.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z;return Math.sqrt(r*r+n*n+i*i)},i.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z;return r*r+n*n+i*i},i.equals=function(e,t){return l7.equals(e._x,t._x)&&l7.equals(e._y,t._y)&&l7.equals(e._z,t._z)},i.lerp=function(e,t,r,n){var i=e._x,a=e._y,o=e._z;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},i.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()},i.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()},i.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},i.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=Math.sqrt(r*r+n*n+i*i);a>l7.zeroTolerance&&(a=1/a,t.set(r*a,n*a,i*a))},i.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},i.transformNormal=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8],r._y=n*o[1]+i*o[5]+a*o[9],r._z=n*o[2]+i*o[6]+a*o[10],r._onValueChanged&&r._onValueChanged()},i.transformToVec3=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8]+o[12],r._y=n*o[1]+i*o[5]+a*o[9]+o[13],r._z=n*o[2]+i*o[6]+a*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},i.transformToVec4=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8]+o[12],r._y=n*o[1]+i*o[5]+a*o[9]+o[13],r._z=n*o[2]+i*o[6]+a*o[10]+o[14],r._w=n*o[3]+i*o[7]+a*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},i.transformCoordinate=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements,s=n*o[3]+i*o[7]+a*o[11]+o[15];s=1/s,r._x=(n*o[0]+i*o[4]+a*o[8]+o[12])*s,r._y=(n*o[1]+i*o[5]+a*o[9]+o[13])*s,r._z=(n*o[2]+i*o[6]+a*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},i.transformByQuat=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*n+s*a-l*i,d=c*i+l*n-o*a,h=c*a+o*i-s*n,_=-o*n-s*i-l*a;r._x=u*c-_*o-d*l+h*s,r._y=d*c-_*s-h*o+u*l,r._z=h*c-_*l-u*s+d*o,r._onValueChanged&&r._onValueChanged()},n(i,[{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()}}]),i);l9._zero=new l9(0,0,0),l9._one=new l9(1,1,1);var ce=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new l9,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 i=0;i<r;++i)l9.add(e[i],n,n);l9.scale(n,1/r,t.center);for(var a=0,s=0;s<r;++s){var l=l9.distanceSquared(n,e[s]);l>a&&(a=l)}t.radius=Math.sqrt(a)},o.fromBox=function(e,t){var r=t.center,n=e.min,i=e.max;r.x=(n.x+i.x)*.5,r.y=(n.y+i.y)*.5,r.z=(n.z+i.z)*.5,t.radius=l9.distance(r,i)},o);ce._tempVec30=new l9;var ct=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new l9,this.max=new l9,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,i=r._y+t._y,a=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,i=r._y-t._y,a=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,i=t.y,a=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new l9;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,i,l),e[3].set(n,i,l),e[4].set(n,s,a),e[5].set(o,s,a),e[6].set(o,i,a),e[7].set(n,i,a),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){l9.subtract(e,t,r.min),l9.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 i=0,a=e.length;i<a;++i){var o=e[i];l9.min(r,o,r),l9.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,i=t.min,a=t.max;i.x=r.x-n,i.y=r.y-n,i.z=r.z-n,a.x=r.x+n,a.y=r.y+n,a.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,i=l._tempVec31;e.getCenter(n),e.getExtent(i),l9.transformCoordinate(n,t,n);var a=i.x,o=i.y,s=i.z,c=t.elements,u=c[0],d=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];i.set((0===u?0:Math.abs(a*u))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===d?0:Math.abs(a*d))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(a*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),l9.subtract(n,i,r.min),l9.add(n,i,r.max)},l.merge=function(e,t,r){return l9.min(e.min,t.min,r.min),l9.max(e.max,t.max,r.max),r},l);ct._tempVec30=new l9,ct._tempVec31=new l9;var cr=((u=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var i=e.normal,a=t.normal,o=r.normal;l9.cross(a,o,u._tempVec30),l9.cross(o,i,u._tempVec31),l9.cross(i,a,u._tempVec32);var s=-l9.dot(i,u._tempVec30),l=-l9.dot(a,u._tempVec31),c=-l9.dot(o,u._tempVec32);l9.scale(u._tempVec30,e.distance/s,u._tempVec30),l9.scale(u._tempVec31,t.distance/l,u._tempVec31),l9.scale(u._tempVec32,r.distance/c,u._tempVec32),l9.add(u._tempVec30,u._tempVec31,n),l9.add(n,u._tempVec32,n)},u.distancePlaneAndPoint=function(e,t){return l9.dot(e.normal,t)+e.distance},u.intersectsPlaneAndPoint=function(t,r){var n=u.distancePlaneAndPoint(t,r);return n>0?e.PlaneIntersectionType.Front:n<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndBox=function(t,r){var n=r.min,i=r.max,a=t.normal,o=u._tempVec30,s=u._tempVec31;return(a.x>=0?(o.x=i.x,s.x=n.x):(o.x=n.x,s.x=i.x),a.y>=0?(o.y=i.y,s.y=n.y):(o.y=n.y,s.y=i.y),a.z>=0?(o.z=i.z,s.z=n.z):(o.z=n.z,s.z=i.z),0>u.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:u.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndSphere=function(t,r){var n=r.center,i=r.radius,a=u.distancePlaneAndPoint(t,n);return a>i?e.PlaneIntersectionType.Front:a<-i?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var r=t.normal,n=l7.zeroTolerance,i=l9.dot(r,e.direction);if(Math.abs(i)<n)return -1;var a=l9.dot(r,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-n)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var r=l7.zeroTolerance,n=e.origin,i=e.direction,a=t.min,o=t.max,s=i.x,l=i.y,c=i.z,u=n.x,d=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(u<a.x||u>o.x)return -1}else{var p=1/s,m=(a.x-u)*p,g=(o.x-u)*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(d<a.y||d>o.y)return -1}else{var y=1/l,x=(a.y-d)*y,S=(o.y-d)*y;if(x>S){var C=x;x=S,S=C}if((_=Math.max(x,_))>(f=Math.min(S,f)))return -1}if(Math.abs(c)<r){if(h<a.z||h>o.z)return -1}else{var T=1/c,A=(a.z-h)*T,E=(o.z-h)*T;if(A>E){var M=A;A=E,E=M}if((_=Math.max(A,_))>(f=Math.min(E,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,i=t.center,a=t.radius,o=u._tempVec30;l9.subtract(r,i,o);var s=l9.dot(o,n),l=l9.dot(o,o)-a*a;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var d=-s-Math.sqrt(c);return d<0&&(d=0),d},u.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)},u.intersectsSphereAndSphere=function(e,t){var r=e.radius+t.radius;return l9.distanceSquared(e.center,t.center)<r*r},u.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,i=t.min,a=u._tempVec30;return a.set(Math.max(i.x,Math.min(r.x,n.x)),Math.max(i.y,Math.min(r.y,n.y)),Math.max(i.z,Math.min(r.z,n.z))),l9.distanceSquared(r,a)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,i=u._tempVec30,a=0;a<6;++a){var o=e.getPlane(a),s=o.normal;if(i.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),l9.dot(s,i)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,r){var n=u.distancePlaneAndPoint(t.near,r);return Math.abs(n)<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.far,r))<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.left,r))<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.right,r))<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.top,r))<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.bottom,r))<l7.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,r){for(var n=r.min,i=r.max,a=u._tempVec30,o=u._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),d=c.normal;if(d.x>=0?(a.x=i.x,o.x=n.x):(a.x=n.x,o.x=i.x),d.y>=0?(a.y=i.y,o.y=n.y):(a.y=n.y,o.y=i.y),d.z>=0?(a.z=i.z,o.z=n.z):(a.z=n.z,o.z=i.z),u.intersectsPlaneAndPoint(c,a)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;u.intersectsPlaneAndPoint(c,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},u.frustumContainsSphere=function(t,r){for(var n=e.ContainmentType.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=u.intersectsPlaneAndSphere(a,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},u);cr._tempVec30=new l9,cr._tempVec31=new l9,cr._tempVec32=new l9;var cn=((h=(d=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new l9,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return d.normalize(this,this),this},h.clone=function(){var e=new d;return e.copyFrom(this),e},h.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},d.normalize=function(e,t){var r=e.normal,n=1/r.length();l9.scale(r,n,t.normal),t.distance=e.distance*n},d.fromPoints=function(e,t,r,n){var i=e.x,a=e.y,o=e.z,s=t.x-i,l=t.y-a,c=t.z-o,u=r.x-i,d=r.y-a,h=r.z-o,_=l*h-c*d,f=c*u-s*h,p=s*d-l*u,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*i+v*a+y*o)},d),ci=((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],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(a+i,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(a-i,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(a+r,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(a-r,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(a+n,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(a-n,c-s,_-d),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return cr.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return cr.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},_),ca=((m=(p=function(e,t,r,n,i,a,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===i&&(i=1),void 0===a&&(a=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]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=a,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],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*a-o*l)+r*(-c*i+o*s)+n*(l*i-a*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,i=t.elements,a=r.elements;a[0]=n[0]+i[0],a[1]=n[1]+i[1],a[2]=n[2]+i[2],a[3]=n[3]+i[3],a[4]=n[4]+i[4],a[5]=n[5]+i[5],a[6]=n[6]+i[6],a[7]=n[7]+i[7],a[8]=n[8]+i[8]},p.subtract=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements;a[0]=n[0]-i[0],a[1]=n[1]-i[1],a[2]=n[2]-i[2],a[3]=n[3]-i[3],a[4]=n[4]-i[4],a[5]=n[5]-i[5],a[6]=n[6]-i[6],a[7]=n[7]-i[7],a[8]=n[8]-i[8]},p.multiply=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=n[5],h=n[6],_=n[7],f=n[8],p=i[0],m=i[1],g=i[2],v=i[3],y=i[4],x=i[5],S=i[6],C=i[7],T=i[8];a[0]=o*p+c*m+h*g,a[1]=s*p+u*m+_*g,a[2]=l*p+d*m+f*g,a[3]=o*v+c*y+h*x,a[4]=s*v+u*y+_*x,a[5]=l*v+d*y+f*x,a[6]=o*S+c*C+h*T,a[7]=s*S+u*C+_*T,a[8]=l*S+d*C+f*T},p.equals=function(e,t){var r=e.elements,n=t.elements;return l7.equals(r[0],n[0])&&l7.equals(r[1],n[1])&&l7.equals(r[2],n[2])&&l7.equals(r[3],n[3])&&l7.equals(r[4],n[4])&&l7.equals(r[5],n[5])&&l7.equals(r[6],n[6])&&l7.equals(r[7],n[7])&&l7.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var i=e.elements,a=t.elements,o=n.elements,s=1-r;o[0]=i[0]*s+a[0]*r,o[1]=i[1]*s+a[1]*r,o[2]=i[2]*s+a[2]*r,o[3]=i[3]*s+a[3]*r,o[4]=i[4]*s+a[4]*r,o[5]=i[5]*s+a[5]*r,o[6]=i[6]*s+a[6]*r,o[7]=i[7]*s+a[7]*r,o[8]=i[8]*s+a[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,i=e._y,a=e._z,o=e._w,s=n+n,l=i+i,c=a+a,u=n*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=d-v,r[6]=_+g,r[1]=d+v,r[4]=1-u-p,r[7]=f-m,r[2]=_-g,r[5]=f+m,r[8]=1-u-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,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=r[7],h=r[8],_=h*l-c*d,f=-h*s+c*u,p=d*s-l*u,m=i*_+a*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*a+o*d)*m,n[2]=(c*a-o*l)*m,n[3]=f*m,n[4]=(h*i-o*u)*m,n[5]=(-c*i+o*s)*m,n[6]=p*m,n[7]=(-d*i+a*u)*m,n[8]=(l*i-a*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=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=i*c-a*l,S=i*u-o*l,C=i*d-s*l,T=a*u-o*c,A=a*d-s*c,E=o*d-s*u,M=h*g-_*m,R=h*v-f*m,w=h*y-p*m,b=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-S*P+C*b+T*w-A*R+E*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*b)*L,n[1]=(u*w-l*F-d*R)*L,n[2]=(l*P-c*w+d*M)*L,n[3]=(o*P-a*F-s*b)*L,n[4]=(i*F-o*w+s*R)*L,n[5]=(a*w-i*P-s*M)*L,n[6]=(g*E-v*A+y*T)*L,n[7]=(v*C-m*E-y*S)*L,n[8]=(m*A-g*C+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,i=r.elements,a=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],u=n[3],d=n[4],h=n[5],_=n[6],f=n[7],p=n[8];i[0]=o*s+a*u,i[1]=o*l+a*d,i[2]=o*c+a*h,i[3]=o*u-a*s,i[4]=o*d-a*l,i[5]=o*h-a*c,i[6]=_,i[7]=f,i[8]=p},p.scale=function(e,t,r){var n=t._x,i=t._y,a=e.elements,o=r.elements;o[0]=n*a[0],o[1]=n*a[1],o[2]=n*a[2],o[3]=i*a[3],o[4]=i*a[4],o[5]=i*a[5],o[6]=a[6],o[7]=a[7],o[8]=a[8]},p.translate=function(e,t,r){var n=t._x,i=t._y,a=e.elements,o=r.elements,s=a[0],l=a[1],c=a[2],u=a[3],d=a[4],h=a[5],_=a[6],f=a[7],p=a[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=n*s+i*u+_,o[7]=n*l+i*d+f,o[8]=n*c+i*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var i=r[1],a=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=i,n[5]=r[7],n[6]=a,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),co=((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,i=t*t+r*r+n*n;if(i<l7.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var a=1/i;return e._x=this._x*a,e._y=this._y*a,e._z=this._z*a,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,i=this._w,a=t*t,o=r*r,s=n*n,l=i*i,c=a+o+s+l,u=2*(t*i-r*n);u>(1-l7.zeroTolerance)*c?(e._x=Math.atan2(2*(i*r-t*n),s+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-l7.zeroTolerance)*c?(e._x=Math.atan2(2*(i*r-t*n),s+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*i),s+l-o-a),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*r+n*i),o+l-s-a))},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,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;r._x=n*u+o*s+i*c-a*l,r._y=i*u+o*l+a*s-n*c,r._z=a*u+o*c+n*l-i*s,r._w=o*u-n*s-i*l-a*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 l7.equals(e._x,t._x)&&l7.equals(e._y,t._y)&&l7.equals(e._z,t._z)&&l7.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;l9.normalize(e,n);var i=Math.sin(t*=.5);r._x=n._x*i,r._y=n._y*i,r._z=n._z*i,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 i=.5*r,a=.5*t,o=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(a),u=Math.cos(a),d=Math.sin(o),h=Math.cos(o),_=h*u,f=d*c;n._x=h*c*l+d*u*s,n._y=d*u*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,i=e.elements,a=i[0],o=i[1],s=i[2],l=i[3],c=i[4],u=i[5],d=i[6],h=i[7],_=i[8],f=a+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(u-h)*r,t._y=(d-s)*r,t._z=(o-l)*r):a>=c&&a>=_?(n=.5/(r=Math.sqrt(1+a-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+d)*n,t._w=(u-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-a-_)),t._x=(l+o)*n,t._y=.5*r,t._z=(h+u)*n,t._w=(d-s)*n):(n=.5/(r=Math.sqrt(1+_-a-c)),t._x=(s+d)*n,t._y=(u+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,i=e._z,a=e._w,o=r*r+n*n+i*i+a*a;if(o>l7.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-i*s,t._w=a*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var i=1-r;g.dot(e,t)>=0?(n._x=e._x*i+t._x*r,n._y=e._y*i+t._y*r,n._z=e._z*i+t._z*r,n._w=e._w*i+t._w*r):(n._x=e._x*i-t._x*r,n._y=e._y*i-t._y*r,n._z=e._z*i-t._z*r,n._w=e._w*i-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var i,a,o=g.dot(e,t);if(Math.abs(o)>1-l7.zeroTolerance)a=1-r,i=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);a=Math.sin((1-r)*s)*l,i=Math.sin(r*s)*l*Math.sign(o)}n.x=a*e.x+i*t.x,n.y=a*e.y+i*t.y,n.z=a*e.z+i*t.z,n.w=a*e.w+i*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,o=Math.sqrt(r*r+n*n+i*i+a*a);o>l7.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=i*o,t._w=a*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,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=i*l+a*s,r._z=a*l-i*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-a*s,r._y=i*l+o*s,r._z=a*l+n*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+i*s,r._y=i*l-n*s,r._z=a*l+o*s,r._w=o*l-a*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)<l7.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);co._tempVector3=new l9,co._tempQuat1=new co;var cs=((x=(y=function(e,t,r,n,i,a,o,s,l,c,u,d,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===i&&(i=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===d&&(d=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]=i,m[5]=a,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p}).prototype).set=function(e,t,r,n,i,a,o,s,l,c,u,d,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=i,m[5]=a,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,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],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-r*a)*(d*m-h*p)-(t*s-n*a)*(u*m-h*f)+(t*l-i*a)*(u*p-d*f)+(r*s-n*o)*(c*m-h*_)-(r*l-i*o)*(c*p-d*_)+(n*l-i*s)*(c*f-u*_)},x.decompose=function(e,t,r){var n=y._tempMat30,i=this.elements,a=n.elements,o=i[0],s=i[1],l=i[2],c=i[4],u=i[5],d=i[6],h=i[8],_=i[9],f=i[10];e.set(i[12],i[13],i[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+u*u+d*d),g=Math.sqrt(h*h+_*_+f*f);if(0>this.determinant()&&(p=-p),r.set(p,m,g),Math.abs(p)<l7.zeroTolerance||Math.abs(m)<l7.zeroTolerance||Math.abs(g)<l7.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,S=1/g;return a[0]=o*v,a[1]=s*v,a[2]=l*v,a[3]=c*x,a[4]=u*x,a[5]=d*x,a[6]=h*S,a[7]=_*S,a[8]=f*S,co.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>l7.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 i=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/i,e._x=.25*i,e._y=(t[1]+t[4])/i,e._z=(t[8]+t[2])/i}else if(t[5]>t[10]){var a=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/a,e._x=(t[1]+t[4])/a,e._y=.25*a,e._z=(t[6]+t[9])/a}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],i=t[2],a=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(r*r+n*n+i*i),Math.sqrt(a*a+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),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,i=t.elements,a=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=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],S=n[15],C=i[0],T=i[1],A=i[2],E=i[3],M=i[4],R=i[5],w=i[6],b=i[7],P=i[8],F=i[9],L=i[10],D=i[11],B=i[12],I=i[13],V=i[14],O=i[15];a[0]=o*C+u*T+f*A+v*E,a[1]=s*C+d*T+p*A+y*E,a[2]=l*C+h*T+m*A+x*E,a[3]=c*C+_*T+g*A+S*E,a[4]=o*M+u*R+f*w+v*b,a[5]=s*M+d*R+p*w+y*b,a[6]=l*M+h*R+m*w+x*b,a[7]=c*M+_*R+g*w+S*b,a[8]=o*P+u*F+f*L+v*D,a[9]=s*P+d*F+p*L+y*D,a[10]=l*P+h*F+m*L+x*D,a[11]=c*P+_*F+g*L+S*D,a[12]=o*B+u*I+f*V+v*O,a[13]=s*B+d*I+p*V+y*O,a[14]=l*B+h*I+m*V+x*O,a[15]=c*B+_*I+g*V+S*O},y.equals=function(e,t){var r=e.elements,n=t.elements;return l7.equals(r[0],n[0])&&l7.equals(r[1],n[1])&&l7.equals(r[2],n[2])&&l7.equals(r[3],n[3])&&l7.equals(r[4],n[4])&&l7.equals(r[5],n[5])&&l7.equals(r[6],n[6])&&l7.equals(r[7],n[7])&&l7.equals(r[8],n[8])&&l7.equals(r[9],n[9])&&l7.equals(r[10],n[10])&&l7.equals(r[11],n[11])&&l7.equals(r[12],n[12])&&l7.equals(r[13],n[13])&&l7.equals(r[14],n[14])&&l7.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var i=e.elements,a=t.elements,o=n.elements,s=1-r;o[0]=i[0]*s+a[0]*r,o[1]=i[1]*s+a[1]*r,o[2]=i[2]*s+a[2]*r,o[3]=i[3]*s+a[3]*r,o[4]=i[4]*s+a[4]*r,o[5]=i[5]*s+a[5]*r,o[6]=i[6]*s+a[6]*r,o[7]=i[7]*s+a[7]*r,o[8]=i[8]*s+a[8]*r,o[9]=i[9]*s+a[9]*r,o[10]=i[10]*s+a[10]*r,o[11]=i[11]*s+a[11]*r,o[12]=i[12]*s+a[12]*r,o[13]=i[13]*s+a[13]*r,o[14]=i[14]*s+a[14]*r,o[15]=i[15]*s+a[15]*r},y.add=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements;a[0]=n[0]+i[0],a[1]=n[1]+i[1],a[2]=n[2]+i[2],a[3]=n[3]+i[3],a[4]=n[4]+i[4],a[5]=n[5]+i[5],a[6]=n[6]+i[6],a[7]=n[7]+i[7],a[8]=n[8]+i[8],a[9]=n[9]+i[9],a[10]=n[10]+i[10],a[11]=n[11]+i[11],a[12]=n[12]+i[12],a[13]=n[13]+i[13],a[14]=n[14]+i[14],a[15]=n[15]+i[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,i=r.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t,i[3]=n[3]*t,i[4]=n[4]*t,i[5]=n[5]*t,i[6]=n[6]*t,i[7]=n[7]*t,i[8]=n[8]*t,i[9]=n[9]*t,i[10]=n[10]*t,i[11]=n[11]*t,i[12]=n[12]*t,i[13]=n[13]*t,i[14]=n[14]*t,i[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,i=e._y,a=e._z,o=e._w,s=n+n,l=i+i,c=a+a,u=n*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=d+v,r[2]=_-g,r[3]=0,r[4]=d-v,r[5]=1-u-p,r[6]=f+m,r[7]=0,r[8]=_+g,r[9]=f-m,r[10]=1-u-h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.rotationAxisAngle=function(e,t,r){var n,i,a,o=r.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<l7.zeroTolerance||(s*=u=1/u,l*=u,c*=u,n=Math.sin(t),a=1-(i=Math.cos(t)),o[0]=s*s*a+i,o[1]=l*s*a+c*n,o[2]=c*s*a-l*n,o[3]=0,o[4]=s*l*a-c*n,o[5]=l*l*a+i,o[6]=c*l*a+s*n,o[7]=0,o[8]=s*c*a+l*n,o[9]=l*c*a-s*n,o[10]=c*c*a+i,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 i=n.elements,a=t._x,o=t._y,s=t._z,l=t._w,c=a+a,u=o+o,d=s+s,h=a*c,_=a*u,f=a*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,S=e._x,C=e._y,T=e._z;i[0]=(1-(p+g))*S,i[1]=(_+x)*S,i[2]=(f-y)*S,i[3]=0,i[4]=(_-x)*C,i[5]=(1-(h+g))*C,i[6]=(m+v)*C,i[7]=0,i[8]=(f+y)*T,i[9]=(m-v)*T,i[10]=(1-(h+p))*T,i[11]=0,i[12]=r._x,i[13]=r._y,i[14]=r._z,i[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,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=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=i*c-a*l,S=i*u-o*l,C=i*d-s*l,T=a*u-o*c,A=a*d-s*c,E=o*d-s*u,M=h*g-_*m,R=h*v-f*m,w=h*y-p*m,b=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-S*P+C*b+T*w-A*R+E*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*b)*L,n[1]=(o*P-a*F-s*b)*L,n[2]=(g*E-v*A+y*T)*L,n[3]=(f*A-_*E-p*T)*L,n[4]=(u*w-l*F-d*R)*L,n[5]=(i*F-o*w+s*R)*L,n[6]=(v*C-m*E-y*S)*L,n[7]=(h*E-f*C+p*S)*L,n[8]=(l*P-c*w+d*M)*L,n[9]=(a*w-i*P-s*M)*L,n[10]=(m*A-g*C+y*x)*L,n[11]=(_*C-h*A-p*x)*L,n[12]=(c*R-l*b-u*M)*L,n[13]=(i*b-a*R+o*M)*L,n[14]=(g*S-m*T-v*x)*L,n[15]=(h*T-_*S+f*x)*L},y.lookAt=function(e,t,r,n){var i=n.elements,a=y._tempVec30,o=y._tempVec31,s=y._tempVec32;l9.subtract(e,t,s),s.normalize(),l9.cross(r,s,a),a.normalize(),l9.cross(s,a,o),i[0]=a._x,i[1]=o._x,i[2]=s._x,i[3]=0,i[4]=a._y,i[5]=o._y,i[6]=s._y,i[7]=0,i[8]=a._z,i[9]=o._z,i[10]=s._z,i[11]=0,i[12]=-l9.dot(a,e),i[13]=-l9.dot(o,e),i[14]=-l9.dot(s,e),i[15]=1},y.ortho=function(e,t,r,n,i,a,o){var s=o.elements,l=1/(e-t),c=1/(r-n),u=1/(i-a);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*u,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(a+i)*u,s[15]=1},y.perspective=function(e,t,r,n,i){var a=i.elements,o=1/Math.tan(e/2),s=1/(r-n);a[0]=o/t,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(n+r)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*n*r*s,a[15]=0},y.rotateAxisAngle=function(e,t,r,n){var i,a,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<l7.zeroTolerance)){var d=e.elements,h=n.elements;s*=u=1/u,l*=u,c*=u,i=Math.sin(r),o=1-(a=Math.cos(r));var _=d[0],f=d[1],p=d[2],m=d[3],g=d[4],v=d[5],y=d[6],x=d[7],S=d[8],C=d[9],T=d[10],A=d[11],E=s*s*o+a,M=l*s*o+c*i,R=c*s*o-l*i,w=s*l*o-c*i,b=l*l*o+a,P=c*l*o+s*i,F=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;h[0]=_*E+g*M+S*R,h[1]=f*E+v*M+C*R,h[2]=p*E+y*M+T*R,h[3]=m*E+x*M+A*R,h[4]=_*w+g*b+S*P,h[5]=f*w+v*b+C*P,h[6]=p*w+y*b+T*P,h[7]=m*w+x*b+A*P,h[8]=_*F+g*L+S*D,h[9]=f*F+v*L+C*D,h[10]=p*F+y*L+T*D,h[11]=m*F+x*L+A*D,e!==n&&(h[12]=d[12],h[13]=d[13],h[14]=d[14],h[15]=d[15])}},y.scale=function(e,t,r){var n=e.elements,i=r.elements,a=t._x,o=t._y,s=t._z;i[0]=n[0]*a,i[1]=n[1]*a,i[2]=n[2]*a,i[3]=n[3]*a,i[4]=n[4]*o,i[5]=n[5]*o,i[6]=n[6]*o,i[7]=n[7]*o,i[8]=n[8]*s,i[9]=n[9]*s,i[10]=n[10]*s,i[11]=n[11]*s,i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,i=r.elements,a=t._x,o=t._y,s=t._z;if(e===r)i[12]=n[0]*a+n[4]*o+n[8]*s+n[12],i[13]=n[1]*a+n[5]*o+n[9]*s+n[13],i[14]=n[2]*a+n[6]*o+n[10]*s+n[14],i[15]=n[3]*a+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],u=n[2],d=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];i[0]=l,i[1]=c,i[2]=u,i[3]=d,i[4]=h,i[5]=_,i[6]=f,i[7]=p,i[8]=m,i[9]=g,i[10]=v,i[11]=y,i[12]=l*a+h*o+m*s+n[12],i[13]=c*a+_*o+g*s+n[13],i[14]=u*a+f*o+v*s+n[14],i[15]=d*a+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var i=r[1],a=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]=i,n[6]=r[9],n[7]=r[13],n[8]=a,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);cs._tempVec30=new l9,cs._tempVec31=new l9,cs._tempVec32=new l9,cs._tempMat30=new ca,cs._identity=new cs(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var cl=((C=(S=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new l9,this.direction=new l9,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return cr.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return cr.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return cr.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return l9.scale(this.direction,e,t),t.add(this.origin)},S),cc=((A=(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},A.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},A.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},A.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},A.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},A.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},A.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},A.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},A.normalize=function(){return T.normalize(this,this),this},A.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},A.clone=function(){return new T(this._x,this._y)},A.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},A.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},A.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},A.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 l7.equals(e._x,t._x)&&l7.equals(e._y,t._y)},T.lerp=function(e,t,r,n){var i=e._x,a=e._y;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*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,i=Math.sqrt(r*r+n*n);i>l7.zeroTolerance&&(i=1/i,t._x=r*i,t._y=n*i,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);cc._zero=new cc(0,0),cc._one=new cc(1,1);var cu=((M=(E=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 E.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 E(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}},E.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()},E.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()},E.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()},E.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()},E.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},E.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return Math.sqrt(r*r+n*n+i*i+a*a)},E.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return r*r+n*n+i*i+a*a},E.equals=function(e,t){return l7.equals(e._x,t._x)&&l7.equals(e._y,t._y)&&l7.equals(e._z,t._z)&&l7.equals(e._w,t._w)},E.lerp=function(e,t,r,n){var i=e._x,a=e._y,o=e._z,s=e._w;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},E.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()},E.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()},E.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},E.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,o=Math.sqrt(r*r+n*n+i*i+a*a);o>l7.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},E.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()},E.transform=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=t.elements;r._x=n*s[0]+i*s[4]+a*s[8]+o*s[12],r._y=n*s[1]+i*s[5]+a*s[9]+o*s[13],r._z=n*s[2]+i*s[6]+a*s[10]+o*s[14],r._w=n*s[3]+i*s[7]+a*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},E.transformByQuat=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*n+l*a-c*i,h=u*i+c*n-s*a,_=u*a+s*i-l*n,f=-s*n-l*i-c*a;r._x=d*u-f*s-h*c+_*l,r._y=h*u-f*l-_*s+d*c,r._z=_*u-f*c-d*l+h*s,r._w=o,r._onValueChanged&&r._onValueChanged()},n(E,[{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()}}]),E);cu._zero=new cu(0,0,0,0),cu._one=new cu(1,1,1,1);var cd=((w=(R=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},w.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},w.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},w.clone=function(){return new R(this._r,this._g,this._b,this._a)},w.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},w.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},w.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},w.toLinear=function(e){return e._r=R.gammaToLinearSpace(this._r),e._g=R.gammaToLinearSpace(this._g),e._b=R.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},w.toGamma=function(e){return e._r=R.linearToGammaSpace(this._r),e._g=R.linearToGammaSpace(this._g),e._b=R.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},w.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,i=e;return t>n&&(n=t),r>n&&(n=r),t<i&&(i=t),r<i&&(i=r),(n+i)/2},w.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},R.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)},R.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)},R.equals=function(e,t){return l7.equals(e._r,t._r)&&l7.equals(e._g,t._g)&&l7.equals(e._b,t._b)&&l7.equals(e._a,t._a)},R.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},R.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()},R.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},R.lerp=function(e,t,r,n){var i=e._r,a=e._g,o=e._b,s=e._a;return n._r=i+(t._r-i)*r,n._g=a+(t._g-a)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(R,[{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()}}]),R),ch=((P=(b=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 b(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(b,[{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()}}]),b),c_=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,i=e._x,a=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*a,d=.488603*o,h=-.488603*i,_=1.092548*(i*a),f=-1.092548*(a*o),p=.315392*(3*o*o-1),m=-1.092548*(i*o),g=.546274*(i*i-a*a);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*u,n[4]+=l*u,n[5]+=c*u,n[6]+=s*d,n[7]+=l*d,n[8]+=c*d,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,i=e._y,a=e._z,o=-1.023327*i,s=1.023327*a,l=-1.023327*n,c=.858086*i*n,u=-.858086*i*a,d=.247708*(3*a*a-1),h=-.858086*a*n,_=.429042*(n*n-i*i),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]*u+r[18]*d+r[21]*h+r[24]*_,p+=r[13]*c+r[16]*u+r[19]*d+r[22]*h+r[25]*_,m+=r[14]*c+r[17]*u+r[20]*d+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),cf=((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 cp(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cm(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 cg(e,t,r){return t&&cm(e.prototype,t),r&&cm(e,r),e}function cv(e,t){return(cv=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cy(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&&cv(e,t)}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";var cx=((V=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},V.equals=function(e,t){return Math.abs(e-t)<=V.zeroTolerance},V.isPowerOf2=function(e){return(e&e-1)==0},V.radianToDegree=function(e){return e*V.radToDegreeFactor},V.degreeToRadian=function(e){return e*V.degreeToRadFactor},V);cx.zeroTolerance=1e-6,cx.radToDegreeFactor=180/Math.PI,cx.degreeToRadFactor=Math.PI/180;var cS=((N=(O=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},N.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},N.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},N.clone=function(){return new O(this._r,this._g,this._b,this._a)},N.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},N.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},N.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},N.toLinear=function(e){return e._r=O.gammaToLinearSpace(this._r),e._g=O.gammaToLinearSpace(this._g),e._b=O.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.toGamma=function(e){return e._r=O.linearToGammaSpace(this._r),e._g=O.linearToGammaSpace(this._g),e._b=O.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,i=e;return t>n&&(n=t),r>n&&(n=r),t<i&&(i=t),r<i&&(i=r),(n+i)/2},N.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},O.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)},O.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)},O.equals=function(e,t){return cx.equals(e._r,t._r)&&cx.equals(e._g,t._g)&&cx.equals(e._b,t._b)&&cx.equals(e._a,t._a)},O.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},O.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()},O.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},O.lerp=function(e,t,r,n){var i=e._r,a=e._g,o=e._b,s=e._a;return n._r=i+(t._r-i)*r,n._g=a+(t._g-a)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},cg(O,[{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()}}]),O);function cC(e,t,r,n){var i,a=arguments.length,o=a<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--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function cT(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function cA(e,t){cw.registerCloneMode(e,t,ly.Ignore)}function cE(e,t){cw.registerCloneMode(e,t,ly.Assignment)}function cM(e,t){cw.registerCloneMode(e,t,ly.Shallow)}function cR(e,t){cw.registerCloneMode(e,t,ly.Deep)}"function"==typeof SuppressedError&&SuppressedError,(z=ly||(ly={}))[z.Ignore=0]="Ignore",z[z.Assignment=1]="Assignment",z[z.Shallow=2]="Shallow",z[z.Deep=3]="Deep";var cw=((U=function(){}).registerCloneMode=function(e,t,r){var n=U._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),U._subCloneModeMap.set(e.constructor,n)),n[t]=r},U.getCloneMode=function(e){var t=U._cloneModeMap.get(e);if(!t){t=Object.create(null),U._cloneModeMap.set(e,t);for(var r=U._objectType,n=U._subCloneModeMap;e!==r;){var i=n.get(e);i&&Object.assign(t,i),e=Object.getPrototypeOf(e)}}return t},U.cloneProperty=function(e,t,r,n){if(n!==ly.Ignore){var i=e[r];if(cT(i,Object)){if(void 0===n||n===ly.Assignment){t[r]=i;return}switch(i.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var a=t[r];null==a||a.length!==i.length?t[r]=i.slice():a.set(i);break;case Array:var o=t[r],s=i.length;null==o?t[r]=o=Array(s):o.length=s;for(var l=0;l<s;l++)U.cloneProperty(i,o,l,n);break;default:var c=t[r]||(t[r]=new i.constructor),u=U.getCloneMode(i.constructor);for(var d in i)U.cloneProperty(i,c,d,u[d]);i._cloneTo&&i._cloneTo(c),i.copyFrom&&c.copyFrom(i)}}else t[r]=i}},U.deepCloneObject=function(e,t){for(var r in e)U.cloneProperty(e,t,r,ly.Deep)},U);cw._subCloneModeMap=new Map,cw._cloneModeMap=new Map,cw._objectType=Object.getPrototypeOf(Object);var cb=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)},cg(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();cb._instanceIdCounter=0,cC([cA],cb.prototype,"instanceId",void 0),cC([cA],cb.prototype,"_engine",void 0);var cP=(cy(k=function(e){var t;return(t=cb.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(cp(t)),t},cb),(G=k.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(cb.prototype.destroy.call(this),!0)},G._getReferCount=function(){return this._refCount},G._addReferCount=function(e){this._refCount+=e},G._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},G._onDestroy=function(){cb.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},cg(k,[{key:"refCount",get:function(){return this._refCount}}]),k),cF=function(e){this.resource=e};e.RenderBufferDepthFormat=void 0,(H=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[H.Depth=0]="Depth",H[H.DepthStencil=1]="DepthStencil",H[H.Stencil=2]="Stencil",H[H.Depth16=3]="Depth16",H[H.Depth24=4]="Depth24",H[H.Depth32=5]="Depth32",H[H.Depth24Stencil8=6]="Depth24Stencil8",H[H.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(W=e.TextureCubeFace||(e.TextureCubeFace={}))[W.PositiveX=0]="PositiveX",W[W.NegativeX=1]="NegativeX",W[W.PositiveY=2]="PositiveY",W[W.NegativeY=3]="NegativeY",W[W.PositiveZ=4]="PositiveZ",W[W.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(X=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[X.Never=0]="Never",X[X.Less=1]="Less",X[X.Equal=2]="Equal",X[X.LessEqual=3]="LessEqual",X[X.Greater=4]="Greater",X[X.NotEqual=5]="NotEqual",X[X.GreaterEqual=6]="GreaterEqual",X[X.Always=7]="Always",e.TextureFilterMode=void 0,(K=e.TextureFilterMode||(e.TextureFilterMode={}))[K.Point=0]="Point",K[K.Bilinear=1]="Bilinear",K[K.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(j=e.TextureFormat||(e.TextureFormat={}))[j.R8G8B8=0]="R8G8B8",j[j.R8G8B8A8=1]="R8G8B8A8",j[j.R4G4B4A4=2]="R4G4B4A4",j[j.R5G5B5A1=3]="R5G5B5A1",j[j.R5G6B5=4]="R5G6B5",j[j.Alpha8=5]="Alpha8",j[j.LuminanceAlpha=6]="LuminanceAlpha",j[j.R16G16B16A16=7]="R16G16B16A16",j[j.R32G32B32A32=8]="R32G32B32A32",j[j.BC1=9]="BC1",j[j.BC3=10]="BC3",j[j.BC7=11]="BC7",j[j.ETC1_RGB=12]="ETC1_RGB",j[j.ETC2_RGB=13]="ETC2_RGB",j[j.ETC2_RGBA5=14]="ETC2_RGBA5",j[j.ETC2_RGBA8=15]="ETC2_RGBA8",j[j.PVRTC_RGB2=16]="PVRTC_RGB2",j[j.PVRTC_RGBA2=17]="PVRTC_RGBA2",j[j.PVRTC_RGB4=18]="PVRTC_RGB4",j[j.PVRTC_RGBA4=19]="PVRTC_RGBA4",j[j.ASTC_4x4=20]="ASTC_4x4",j[j.ASTC_5x5=21]="ASTC_5x5",j[j.ASTC_6x6=22]="ASTC_6x6",j[j.ASTC_8x8=23]="ASTC_8x8",j[j.ASTC_10x10=24]="ASTC_10x10",j[j.ASTC_12x12=25]="ASTC_12x12",j[j.Depth=26]="Depth",j[j.DepthStencil=27]="DepthStencil",j[j.Depth16=28]="Depth16",j[j.Depth24=29]="Depth24",j[j.Depth32=30]="Depth32",j[j.Depth24Stencil8=31]="Depth24Stencil8",j[j.Depth32Stencil8=32]="Depth32Stencil8",j[j.DXT1=33]="DXT1",j[j.DXT5=34]="DXT5",e.TextureUsage=void 0,(Y=e.TextureUsage||(e.TextureUsage={}))[Y.Static=0]="Static",Y[Y.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(q=e.TextureWrapMode||(e.TextureWrapMode={}))[q.Clamp=0]="Clamp",q[q.Repeat=1]="Repeat",q[q.Mirror=2]="Mirror";var cL=(cy(Q=function(e){var t;return(t=cP.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(cp(t)),t},cP),Q.prototype._onDestroy=function(){cP.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},cg(Q,[{key:"isContentLost",get:function(){return this._isContentLost}}]),Q),cD=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},cB=console.log.bind(console),cI=console.info.bind(console),cV=console.warn.bind(console),cO=console.error.bind(console),cN={debug:cD,info:cD,warn:cD,error:cD,isEnabled:!1,enable:function(){this.debug=cB,this.info=cI,this.warn=cV,this.error=cO,this.isEnabled=!0},disable:function(){this.debug=cD,this.info=cD,this.warn=cD,this.error=cD,this.isEnabled=!1}},cz=(cy(Z=function(){var e;return e=cL.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},cL),(J=Z.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},J._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},J._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))},J._onDestroy=function(){cL.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},J._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},J._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},cg(Z,[{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(e){e!==this._filterMode&&(this._filterMode=e,this._platformTexture.filterMode=e)}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(cN.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(cN.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)}}]),Z),cU=(cy($=function(t,r,n,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=cL.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=r,s._height=n,s._antiAliasing=o,s._depth=a,i){for(var s,l=cT(i,Array)?i.slice():[i],c=0,u=l.length;c<u;c++){var d=l[c];if(d._isDepthTexture)throw"Render texture can't use depth format.";d._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(cT(a,cz)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(cp(s)),s},cL),(ee=$.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},ee.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()}},ee._onDestroy=function(){cL.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},ee._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t),this._isContentLost=!1},ee._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},ee._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},cg($,[{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}}]),$),ck=(cy(et=function(t,r,n,i,a,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=e.TextureUsage.Static),(s=cz.call(this,t)||this)._mipmap=a,s._width=r,s._height=n,s._usage=o,s._format=i,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(cp(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},cz),(er=et.prototype).setPixelBuffer=function(e,t,r,n,i,a){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a),this._isContentLost=!1},er.setImageSource=function(e,t,r,n,i,a){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===a&&(a=0),this._platformTexture.setImageSource(e,t,r,n,i,a),this._isContentLost=!1},er.getPixelBuffer=function(e,t,r,n,i,a){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,i):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a)},er._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),cz.prototype._rebuild.call(this)},et),cG=(cy(en=function(t,r,n,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=cz.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=i,s._format=a,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(cp(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},cz),(ei=en.prototype).setPixelBuffer=function(e,t,r,n,i,a,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a,o,s),this._isContentLost=!1},ei.setImageSource=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,i,a,o),this._isContentLost=!1},ei.getPixelBuffer=function(e,t,r,n,i,a,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,i,0,a):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a,o)},ei._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),cz.prototype._rebuild.call(this)},cg(en,[{key:"length",get:function(){return this._length}}]),en),cH=(cy(ea=function(t,r,n,i){var a;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=cz.call(this,t)||this)._mipmap=i,a._width=r,a._height=r,a._format=n,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(cp(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},cz),(eo=ea.prototype).setPixelBuffer=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a,o),this._isContentLost=!1},eo.setImageSource=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,i,a,o),this._isContentLost=!1},eo.getPixelBuffer=function(e,t,r,n,i,a,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,i,0,a):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a,o)},eo._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),cz.prototype._rebuild.call(this)},ea),cW=(cy(es=function(e){var t;return(t=cP.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},cP),(el=es.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,i=this._space,a=this.texture,o=a.width,s=t+i,l=r+i;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=i,this._curY=this._nextY+i);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new cc(this._curX,this._curY),a.setPixelBuffer(n,0,this._curX,this._curY,t,r),a.generateMipmaps());var u=1/o,d=this._curX,h=this._curY,_=d*u,f=(d+t)*u,p=h*u,m=(h+r)*u;e.x=d,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+i,!0},el.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},el.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},el._onDestroy=function(){cP.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},es);e.FontStyle=void 0,(ec=e.FontStyle||(e.FontStyle={}))[ec.None=0]="None",ec[ec.Bold=1]="Bold",ec[ec.Italic=2]="Italic",e.OverflowMode=void 0,(eu=e.OverflowMode||(e.OverflowMode={}))[eu.Overflow=0]="Overflow",eu[eu.Truncate=1]="Truncate";var cX=((ed=function(){}).textContext=function(){var e=ed._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},ed._textContext=e}return e},ed.measureFont=function(e){var t=ed._fontSizeInfoCache,r=t[e];return r||(r=ed._measureFontOrChar(e),t[e]=r),r},ed.getNativeFontString=function(t,r,n){var i=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ed._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=r+"px "+t},ed.measureChar=function(e,t){return ed._measureFontOrChar(t,e)},ed.measureTextWithWrap=function(t){var r=t._subFont,n=r.nativeFontString,i=ed.measureFont(n),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=dX._pixelsPerUnit,u=i.size+t.lineSpacing*c,d=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=a.length;_<f;_++){var p=a[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",S=0,C=0,T=0,A=!1,E=0,M=p.length;E<M;++E){var R=p[E],w=ed._getCharInfo(R,n,r),b=R.charCodeAt(0),P=32===b;if(!P||!A||0!==x.length||0!==m.length){var F=P||b>=19968&&b<=40959,L=w.w,D=w.offsetY,B=.5*w.h,I=B+D,V=B-D;F?(m.length>0&&(S+g>d?(S>0&&this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),A=!0,x=m,S=g,C=v,T=y):(x+=m,S+=g,C=Math.max(C,v),T=Math.max(T,y)),m="",g=v=y=0),S+L>d&&S>0?(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),A=!0,P?(x="",S=C=T=0):(x=R,S=w.xAdvance,C=I,T=V)):(x+=R,S+=w.xAdvance,C=Math.max(C,I),T=Math.max(T,V))):g+w.w>d?(S>0&&(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),x="",S=C=T=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),A=!0,m=R,g=w.xAdvance,v=I,y=V):(m+=R,g+=w.xAdvance,v=Math.max(v,I),y=Math.max(y,V))}}g>0&&(S+g>d?(S>0&&this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),S=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,S+=g,C=Math.max(C,v),T=Math.max(T,y))),S>0&&(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S))}var O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=u*o.length),{width:h,height:O,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},ed.measureTextWithoutWrap=function(t){var r=t._subFont,n=r.nativeFontString,i=ed.measureFont(n),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=[],u=dX._pixelsPerUnit,d=i.size+t.lineSpacing*u,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=a[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=ed._getCharInfo(f[v],n,r);p+=x.xAdvance;var S=x.offsetY,C=.5*x.h,T=C+S,A=C-S;m<T&&(m=T),g<A&&(g=A)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var E=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(E=d*s.length),{width:h,height:E,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},ed.getNativeFontHash=function(t,r,n){var i=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ed._genericFontFamilies.indexOf(t)||(t=""+t),i+=r+"px"+t},ed._measureFontOrChar=function(e,t){void 0===t&&(t="");var r,n=ed.textContext(),i=n.canvas,a=n.context;a.font=e;var o=t||ed._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(ed._measureBaseline).width),c=l*ed._heightMultiplier;l=ed._baselineMultiplier*l|0;var u=ed._extendHeight;c+=u,l+=.5*u,i.width=s,i.height=c,a.font=e,a.fillStyle="#000",a.clearRect(0,0,s,c),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var d=a.getImageData(0,0,s,c).data,h=d.length,_=-1,f=-1,p=0,m=0,g=0,v=i.width,y=1/v,x=0;x<h;x+=4)0!==d[x+3]?(r=~~(.25*x*y),-1===_&&(_=r),r>f&&(f=r)):d[x]=d[x+1]=d[x+2]=255;-1!==_&&-1!==f&&(g=(p=l-_)+(m=f-l+1));var S={ascent:p,descent:m,size:g};if(!t)return S;var C=null;if(g>0){var T=4*v;C=new Uint8Array(d.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 cc,new cc,new cc,new cc],ascent:p,descent:m,index:0,data:C}},ed._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=ed.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},ed._pushLine=function(e,t,r,n,i,a,o){e.push(n),t.push(i),r.push({ascent:a,descent:o,size:a+o})},ed);cX._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],cX._extendHeight=0,cX._measureString="|\xc9q\xc5",cX._measureBaseline="M",cX._heightMultiplier=2,cX._baselineMultiplier=1.4,cX._fontSizeInfoCache={},cX._textContext=null;var cK=((e_=(eh=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},e_._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},e_._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},e_._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var i=t[r].getCharInfo(e);if(i)return i}return null},e_._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},e_._getLastIndex=function(){return this._lastIndex},e_._createFontAtlas=function(){var t,r=this._engine,n=new cW(r),i=new ck(r,256,256,e.TextureFormat.R8G8B8A8,!1);i.filterMode=e.TextureFilterMode.Bilinear,n.texture=i,n.isGCIgnored=i.isGCIgnored=!0,this._fontAtlases.push(n);var a=this.nativeFontString;return r.resourceManager.addContentRestorer(new(cy(t=function(){return cF.call(this,n)},cF),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var i=t[n],o=cX.measureChar(i.char,a).data;if(i.w>0&&i.h>0&&o){var s=i.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,i.w,i.h)}}r.generateMipmaps()},t)),n},eh),cj=(cy(ef=function(e,t){var r;return void 0===t&&(t=""),(r=cP.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},cP),(ep=ef.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,i=n[r];return i||(i=new cK(this.engine),n[r]=i),i},ep._onDestroy=function(){cP.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]},ef.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new ef(e,t),r[t]=n),n}return null},cg(ef,[{key:"name",get:function(){return this._name}}]),ef),cY=((eg=(em=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},eg.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},eg.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},eg.dispatch=function(e,t){if(!this._events[e])return!1;var r=this._events[e];if(Array.isArray(r)){var n=r.length,i=em._dispatchingListenersPool,a=i.length>0?i.pop():[];a.length=n;for(var o=0;o<n;o++)a[o]=r[o];for(var s=0;s<n;s++){var l=a[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}a.length=0,i.push(a)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},eg.on=function(e,t){return this._addEventListener(e,t)},eg.once=function(e,t){return this._addEventListener(e,t,!0)},eg.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 i=r.length-1;i>=0;i--)r[i].fn===t&&(r[i].destroyed=!0,r.splice(i,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},eg.removeEventListener=function(e,t){return this.off(e,t)},eg.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},eg._addEventListener=function(e,t,r){var n={fn:t,once:r},i=this._events,a=i[e];return a?Array.isArray(a)?a.push(n):i[e]=[a,n]:(i[e]=n,this._eventCount++),this},eg._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},em);cY._dispatchingListenersPool=[];var cq=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},cg(e,[{key:"type",get:function(){return this._type}}]),e}();cq._propertyIdMap=Object.create(null),cq._propertyNameCounter=0,cq._propertyNameMap=Object.create(null);var cQ=((ey=(ev=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new cu,this._deltaTimeValue=new cu,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},ey._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},ey._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(ev._elapsedTimeProperty,t),r.set(this._deltaTime,0,0,0),e.setVector4(ev._deltaTimeProperty,r)},cg(ev,[{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}}]),ev);cQ._elapsedTimeProperty=cq.getByName("scene_ElapsedTime"),cQ._deltaTimeProperty=cq.getByName("scene_DeltaTime"),e.DataType=void 0,(ex=e.DataType||(e.DataType={}))[ex.FLOAT=5126]="FLOAT",ex[ex.FLOAT_VEC2=35664]="FLOAT_VEC2",ex[ex.FLOAT_VEC3=35665]="FLOAT_VEC3",ex[ex.FLOAT_VEC4=35666]="FLOAT_VEC4",ex[ex.INT=5124]="INT",ex[ex.INT_VEC2=35667]="INT_VEC2",ex[ex.INT_VEC3=35668]="INT_VEC3",ex[ex.INT_VEC4=35669]="INT_VEC4",ex[ex.BOOL=35670]="BOOL",ex[ex.BOOL_VEC2=35671]="BOOL_VEC2",ex[ex.BOOL_VEC3=35672]="BOOL_VEC3",ex[ex.BOOL_VEC4=35673]="BOOL_VEC4",ex[ex.FLOAT_MAT2=35674]="FLOAT_MAT2",ex[ex.FLOAT_MAT3=35675]="FLOAT_MAT3",ex[ex.FLOAT_MAT4=35676]="FLOAT_MAT4",ex[ex.FLOAT_ARRAY=35677]="FLOAT_ARRAY",ex[ex.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",ex[ex.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",ex[ex.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",ex[ex.INT_ARRAY=100003]="INT_ARRAY",ex[ex.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",ex[ex.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",ex[ex.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",ex[ex.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",ex[ex.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",ex[ex.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",ex[ex.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",ex[ex.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",ex[ex.SAMPLER_2D=35678]="SAMPLER_2D",ex[ex.SAMPLER_CUBE=35680]="SAMPLER_CUBE",ex[ex.BYTE=5120]="BYTE",ex[ex.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ex[ex.SHORT=5122]="SHORT",ex[ex.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ex[ex.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(eS=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",eS.standardDerivatives="OES_standard_derivatives",eS.shaderTextureLod="EXT_shader_texture_lod",eS.elementIndexUint="OES_element_index_uint",eS.depthTexture="WEBGL_depth_texture",eS.drawBuffers="WEBGL_draw_buffers",eS.vertexArrayObject="OES_vertex_array_object",eS.instancedArrays="ANGLE_instanced_arrays",eS.multipleSample="multipleSampleOnlySupportedInWebGL2",eS.textureFloat="OES_texture_float",eS.textureFloatLinear="OES_texture_float_linear",eS.textureHalfFloat="OES_texture_half_float",eS.textureHalfFloatLinear="OES_texture_half_float_linear",eS.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",eS.colorBufferFloat="EXT_color_buffer_float",eS.colorBufferHalfFloat="EXT_color_buffer_half_float",eS.textureFilterAnisotropic="EXT_texture_filter_anisotropic",eS.blendMinMax="EXT_blend_minmax",eS.astc="WEBGL_compressed_texture_astc",eS.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",eS.etc="WEBGL_compressed_texture_etc",eS.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",eS.etc1="WEBGL_compressed_texture_etc1",eS.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",eS.pvrtc="WEBGL_compressed_texture_pvrtc",eS.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",eS.s3tc="WEBGL_compressed_texture_s3tc",eS.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",eS.bptc="EXT_texture_compression_bptc",eS.WEBGL_lose_context="WEBGL_lose_context",(eC=lx||(lx={}))[eC.None=0]="None",eC[eC.Scene=1]="Scene",eC[eC.Hierarchy=2]="Hierarchy",eC[eC.All=3]="All";var cZ=(cy(eT=function(e){var t;return(t=cb.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},cb),(eA=eT.prototype)._onAwake=function(){},eA._onEnable=function(){},eA._onDisable=function(){},eA._onEnableInScene=function(){},eA._onDisableInScene=function(){},eA._setActive=function(e,t){var r=this._entity;t&lx.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&lx.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()))},eA._onDestroy=function(){cb.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},cg(eT,[{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}}]),eT);cC([cA],cZ.prototype,"_entity",void 0),cC([cA],cZ.prototype,"_awoken",void 0),cC([cA],cZ.prototype,"_phasedActiveInScene",void 0),cC([cA],cZ.prototype,"_phasedActive",void 0),cC([cE],cZ.prototype,"_enabled",void 0);var cJ=((eE=function(){})._addCheck=function(e,t){for(;t!==cZ;){var r=eE._dependenciesMap.get(t);if(r)for(var n=r.components,i=r.mode,a=0,o=n.length;a<o;a++){var s=n[a];if(!e.getComponent(s)){if(1===i)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},eE._removeCheck=function(e,t){for(;t!==cZ;){var r=eE._invDependenciesMap.get(t);if(r){for(var n=0,i=r.length;n<i;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eE._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eE._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eE);function c$(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){cJ._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return cJ._addInvDependency(t,e)})}}cJ._invDependenciesMap=new Map,cJ._dependenciesMap=new Map,e.DependentMode=void 0,(eM=e.DependentMode||(e.DependentMode={}))[eM.CheckOnly=0]="CheckOnly",eM[eM.AutoAdd=1]="AutoAdd";var c0=((ew=(eR=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++},ew.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ew.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},ew.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ew.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},ew.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0;n<this.length;n++){var i=r[n];i&&e(i)}this._endLoop(t)},ew.forEachAndClean=function(e){this._startLoop();for(var t=this._elements,r=0;r<this.length;r++){var n=t[r];n&&e(n)}this._endLoopAndClear()},ew.garbageCollection=function(){this._elements.length=this.length},ew._startLoop=function(){this._isLooping=!0},ew._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 i=n[r];e(i,t),n[t++]=i,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},ew._endLoopAndClear=function(){this._isLooping=!1,this.length=0,this._blankCount=0},eR);e.Layer=void 0,(eb=e.Layer||(e.Layer={}))[eb.Layer0=1]="Layer0",eb[eb.Layer1=2]="Layer1",eb[eb.Layer2=4]="Layer2",eb[eb.Layer3=8]="Layer3",eb[eb.Layer4=16]="Layer4",eb[eb.Layer5=32]="Layer5",eb[eb.Layer6=64]="Layer6",eb[eb.Layer7=128]="Layer7",eb[eb.Layer8=256]="Layer8",eb[eb.Layer9=512]="Layer9",eb[eb.Layer10=1024]="Layer10",eb[eb.Layer11=2048]="Layer11",eb[eb.Layer12=4096]="Layer12",eb[eb.Layer13=8192]="Layer13",eb[eb.Layer14=16384]="Layer14",eb[eb.Layer15=32768]="Layer15",eb[eb.Layer16=65536]="Layer16",eb[eb.Layer17=131072]="Layer17",eb[eb.Layer18=262144]="Layer18",eb[eb.Layer19=524288]="Layer19",eb[eb.Layer20=1048576]="Layer20",eb[eb.Layer21=2097152]="Layer21",eb[eb.Layer22=4194304]="Layer22",eb[eb.Layer23=8388608]="Layer23",eb[eb.Layer24=16777216]="Layer24",eb[eb.Layer25=33554432]="Layer25",eb[eb.Layer26=67108864]="Layer26",eb[eb.Layer27=134217728]="Layer27",eb[eb.Layer28=268435456]="Layer28",eb[eb.Layer29=536870912]="Layer29",eb[eb.Layer30=1073741824]="Layer30",eb[eb.Layer31=2147483648]="Layer31",eb[eb.Everything=4294967295]="Everything",eb[eb.Nothing=0]="Nothing";var c1=((eP=function(){})._floatMatrixMultiply=function(e,t,r,n,i){var a=e.elements,o=a[0],s=a[1],l=a[2],c=a[3],u=a[4],d=a[5],h=a[6],_=a[7],f=a[8],p=a[9],m=a[10],g=a[11],v=a[12],y=a[13],x=a[14],S=a[15],C=t[r],T=t[r+1],A=t[r+2],E=t[r+3],M=t[r+4],R=t[r+5],w=t[r+6],b=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[i]=o*C+u*T+f*A+v*E,n[i+1]=s*C+d*T+p*A+y*E,n[i+2]=l*C+h*T+m*A+x*E,n[i+3]=c*C+_*T+g*A+S*E,n[i+4]=o*M+u*R+f*w+v*b,n[i+5]=s*M+d*R+p*w+y*b,n[i+6]=l*M+h*R+m*w+x*b,n[i+7]=c*M+_*R+g*w+S*b,n[i+8]=o*P+u*F+f*L+v*D,n[i+9]=s*P+d*F+p*L+y*D,n[i+10]=l*P+h*F+m*L+x*D,n[i+11]=c*P+_*F+g*L+S*D,n[i+12]=o*B+u*I+f*V+v*O,n[i+13]=s*B+d*I+p*V+y*O,n[i+14]=l*B+h*I+m*V+x*O,n[i+15]=c*B+_*I+g*V+S*O},eP._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,i=0,a=r.length;null!=n&&i<a;)n=n[r[i++]];return i&&i==a?n:void 0},eP.removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var i=e[n];e[r]=i}return e.length--,!0},eP.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))},eP.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eP.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eP.resolveAbsoluteUrl=function(e,t){return eP.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+this._formatRelativePath(t)},eP._stringToPath=function(e){var t=[];return e.charCodeAt(0)===c2&&t.push(""),e.replace(c4,function(e,r,n,i){var a=e;n?a=i.replace(c3,"$1"):r&&(a=r.trim()),t.push(a)}),t},eP._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},eP),c2=46,c3=/\\(\\)?/g,c4=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),c5=((eL=(eF=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eL.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eL._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)c1.removeFromArray(e[t]._updateFlags,this)},cy(eD=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eD.prototype.dispatch=function(){this.flag=!0},eD),c8=((eI=(eB=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eI.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eI.removeFlag=function(e){c1.removeFromArray(this._updateFlags,e)&&c1.removeFromArray(e._flagManagers,this)},eI.addListener=function(e){this._listeners.push(e)},eI.removeListener=function(e){c1.removeFromArray(this._listeners,e)},eI.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var i=this._listeners,a=i.length-1;a>=0;a--)i[a](e,t)},eB),c6=(cy(eV=function(e){var t;return(t=cZ.call(this,e)||this)._position=new l9,t._rotation=new l9,t._rotationQuaternion=new co,t._scale=new l9(1,1,1),t._worldPosition=new l9,t._worldRotation=new l9,t._worldRotationQuaternion=new co,t._lossyWorldScale=new l9(1,1,1),t._localMatrix=new cs,t._worldMatrix=new cs,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new c8,t._onPositionChanged=t._onPositionChanged.bind(cp(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(cp(t)),t._onRotationChanged=t._onRotationChanged.bind(cp(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(cp(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(cp(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(cp(t)),t._onScaleChanged=t._onScaleChanged.bind(cp(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},cZ),(eO=eV.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},eO.setRotation=function(e,t,r){this._rotation.set(e,t,r)},eO.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},eO.setScale=function(e,t,r){this._scale.set(e,t,r)},eO.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},eO.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},eO.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},eO.translate=function(e,t,r,n){if("number"==typeof e){var i=eV._tempVec30;i.set(e,t,r),this._translate(i,n)}else this._translate(e,t)},eO.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},eO.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*l7.degreeToRadFactor;co.rotationAxisAngle(e,n,eV._tempQuat0),this._rotateByQuat(eV._tempQuat0,r)},eO.lookAt=function(e,t){var r=eV._tempVec30;l9.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=l7.zeroTolerance)){r.scale(1/n);var i=eV._tempVec31;if(t?l9.cross(t,r,i):i.set(r.z,0,-r.x),!((n=i.length())<=l7.zeroTolerance)){i.scale(1/n);var a=eV._tempVec32;l9.cross(r,i,a);var o=eV._tempMat41,s=o.elements;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[4]=a.x,s[5]=a.y,s[6]=a.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},eO.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(c5)},eO._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eO._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eO._onDestroy=function(){cZ.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},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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},eO._getScaleMatrix=function(){var e=eV._tempQuat0,t=eV._tempMat30,r=eV._tempMat31,n=eV._tempMat32;return r.copyFromMatrix(this.worldMatrix),co.invert(this.worldRotationQuaternion,e),ca.rotationQuaternion(e,t),ca.multiply(t,r,n),n},eO._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eO._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eO._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eO._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eO._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eO._rotateByQuat=function(e,t){t?co.multiply(this.rotationQuaternion,e,this._rotationQuaternion):co.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eO._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=eV._tempVec30;l9.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},eO._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var i=l7.degreeToRadFactor,a=eV._tempQuat0;co.rotationEuler(e*i,t*i,r*i,a),this._rotateByQuat(a,n)},eO._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eO._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(cs.invert(t.worldMatrix,eV._tempMat41),l9.transformCoordinate(e,eV._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eO._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eO._onWorldRotationChanged=function(){var e=this._worldRotation;co.rotationEuler(l7.degreeToRadian(e.x),l7.degreeToRadian(e.y),l7.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eO._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eO._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=eV._tempQuat0;co.invert(t.worldRotationQuaternion,r),co.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eO._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},cg(eV,[{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(l7.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(l7.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,co.rotationEuler(l7.degreeToRadian(this._rotation.x),l7.degreeToRadian(this._rotation.y),l7.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):co.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?co.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):co.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)&&(cs.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?cs.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?(cs.invert(t.worldMatrix,eV._tempMat42),cs.multiply(eV._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 l9),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 l9),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 l9),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eV);c6._tempQuat0=new co,c6._tempVec30=new l9,c6._tempVec31=new l9,c6._tempVec32=new l9,c6._tempMat30=new ca,c6._tempMat31=new ca,c6._tempMat32=new ca,c6._tempMat41=new cs,c6._tempMat42=new cs,cC([cR],c6.prototype,"_position",void 0),cC([cR],c6.prototype,"_rotation",void 0),cC([cR],c6.prototype,"_rotationQuaternion",void 0),cC([cR],c6.prototype,"_scale",void 0),cC([cR],c6.prototype,"_worldPosition",void 0),cC([cR],c6.prototype,"_worldRotation",void 0),cC([cR],c6.prototype,"_worldRotationQuaternion",void 0),cC([cR],c6.prototype,"_lossyWorldScale",void 0),cC([cR],c6.prototype,"_localMatrix",void 0),cC([cR],c6.prototype,"_worldMatrix",void 0),cC([cA],c6.prototype,"_worldForward",void 0),cC([cA],c6.prototype,"_worldRight",void 0),cC([cA],c6.prototype,"_worldUp",void 0),cC([cA],c6.prototype,"_isParentDirty",void 0),cC([cA],c6.prototype,"_parentTransformCache",void 0),cC([cA],c6.prototype,"_updateFlagManager",void 0),cC([cA],c6.prototype,"_onPositionChanged",null),cC([cA],c6.prototype,"_onWorldPositionChanged",null),cC([cA],c6.prototype,"_onRotationChanged",null),cC([cA],c6.prototype,"_onWorldRotationChanged",null),cC([cA],c6.prototype,"_onRotationQuaternionChanged",null),cC([cA],c6.prototype,"_onWorldRotationQuaternionChanged",null),cC([cA],c6.prototype,"_onScaleChanged",null),(eN=lS||(lS={}))[eN.LocalEuler=1]="LocalEuler",eN[eN.LocalQuat=2]="LocalQuat",eN[eN.WorldPosition=4]="WorldPosition",eN[eN.WorldEuler=8]="WorldEuler",eN[eN.WorldQuat=16]="WorldQuat",eN[eN.WorldScale=32]="WorldScale",eN[eN.LocalMatrix=64]="LocalMatrix",eN[eN.WorldMatrix=128]="WorldMatrix",eN[eN.WmWp=132]="WmWp",eN[eN.WmWeWq=152]="WmWeWq",eN[eN.WmWpWeWq=156]="WmWpWeWq",eN[eN.WmWs=160]="WmWs",eN[eN.WmWpWs=164]="WmWpWs",eN[eN.WmWpWeWqWs=188]="WmWpWeWqWs";var c7=((ez=function(){}).cloneComponent=function(e,t,r,n){var i=cw.getCloneMode(e.constructor);for(var a in e)cw.cloneProperty(e,t,a,i[a]);e._cloneTo&&e._cloneTo(t,r,n)},ez),c9=(cy(eU=function(t,r){var n;return(n=cb.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new c0,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._parent=null,n._invModelMatrix=new cs,n.name=r,n.transform=n.addComponent(c6),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},cb),(ek=eU.prototype).addComponent=function(e){cJ._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0,lx.All),t},ek.getComponent=function(e){for(var t=this._components,r=t.length-1;r>=0;r--){var n=t[r];if(cT(n,e))return n}return null},ek.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,i=r.length;n<i;n++){var a=r[n];cT(a,e)&&t.push(a)}return t},ek.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},ek.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,i=this._scene,a=lx.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(a|=lx.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==i&&(a|=lx.Scene):a|=lx.Scene),a&&t._processInActive(a),t._scene!==i&&eU._traverseSetOwnerScene(t,i);var o=lx.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=lx.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===i||(o|=lx.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},ek.removeChild=function(e){e._setParent(null)},ek.getChild=function(e){return this._children[e]},ek.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var i=t[r].findByName(e);if(i)return i}return null},ek.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,i=t.length;n<i;++n){var a=t[n];if(a&&!(r=eU._findChildByName(r,a)))return null}return r},ek.createChild=function(e){var t=new eU(this.engine,e);return t.layer=this.layer,t.parent=this,t},ek.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=lx.None;r._isActiveInHierarchy&&(n|=lx.Hierarchy),r._isActiveInScene&&(n|=lx.Scene),n&&r._processInActive(n),eU._traverseSetOwnerScene(r,null)}e.length=0},ek.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e),e},ek._createCloneEntity=function(e){var t=new eU(e._engine,e.name),r=this._hookResource;r&&(t._hookResource=r,r._addReferCount(1)),t.layer=e.layer,t._isActive=e._isActive;var n=t.transform,i=e.transform;n.position=i.position,n.rotation=i.rotation,n.scale=i.scale;for(var a=e._children,o=0,s=e._children.length;o<s;o++)t.addChild(this._createCloneEntity(a[o]));return t},ek._parseCloneEntity=function(e,t,r,n){for(var i=e._children,a=t._children,o=0,s=i.length;o<s;o++)this._parseCloneEntity(i[o],a[o],r,n);for(var l=e._components,c=0,u=l.length;c<u;c++){var d=l[c];if(!cT(d,c6)){var h=t.addComponent(d.constructor);c7.cloneComponent(d,h,r,n)}}},ek.destroy=function(){if(!this._destroyed){cb.prototype.destroy.call(this),this._hookResource&&(this._hookResource._addReferCount(-1),this._hookResource=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}},ek._removeComponent=function(e){cJ._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},ek._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},ek._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},ek._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}},ek._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)},ek._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)},ek._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 i=e+1,a=n+1;i<a;i++)r[i]._siblingIndex++}},ek._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,i=e._scene,a=lx.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(a|=lx.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==i&&(a|=lx.Scene):this._isActiveInScene&&(a|=lx.Scene),a&&this._processInActive(a),n!==i&&eU._traverseSetOwnerScene(this,i);var o=lx.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=lx.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===i||(o|=lx.Scene))),o&&this._processActive(o)}else{var s=lx.None;this._isActiveInHierarchy&&(s|=lx.Hierarchy),this._isActiveInScene&&(s|=lx.Scene),s&&this._processInActive(s),r&&eU._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},ek._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];cT(n,e)&&t.push(n)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},ek._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,i=r.length;n<i;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},ek._setActiveInHierarchy=function(e,t){t&lx.Hierarchy&&(this._isActiveInHierarchy=!0),t&lx.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=r.length-1;n>=0;n--){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setActiveInHierarchy(e,t)}},ek._setInActiveInHierarchy=function(e,t){t&lx.Hierarchy&&(this._isActiveInHierarchy=!1),t&lx.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=r.length-1;n>=0;n--){var i=r[n];i.enabled&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setInActiveInHierarchy(e,t)}},ek._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},ek._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 i=n==t?this:e[n-1];e[n]=i,i._siblingIndex=n}else for(var a=r;a<=t;a++){var o=a==t?this:e[a+1];e[a]=o,o._siblingIndex=a}}},ek.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(cs.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eU._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var i=r[n];if(i.name===t)return i}return null},eU._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},cg(eU,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=lx.None;this._isRoot&&this._scene._isActiveInEngine?r|=lx.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=lx.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=lx.Scene)),r&&this._processActive(r)}else{var n=lx.None;this._isActiveInHierarchy&&(n|=lx.Hierarchy),this._isActiveInScene&&(n|=lx.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)}}]),eU),ue=((eH=(eG=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},eH.resetPool=function(){this._elementPoolIndex=0},eH.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},eG);e.BlendFactor=void 0,(eW=e.BlendFactor||(e.BlendFactor={}))[eW.Zero=0]="Zero",eW[eW.One=1]="One",eW[eW.SourceColor=2]="SourceColor",eW[eW.OneMinusSourceColor=3]="OneMinusSourceColor",eW[eW.DestinationColor=4]="DestinationColor",eW[eW.OneMinusDestinationColor=5]="OneMinusDestinationColor",eW[eW.SourceAlpha=6]="SourceAlpha",eW[eW.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eW[eW.DestinationAlpha=8]="DestinationAlpha",eW[eW.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eW[eW.SourceAlphaSaturate=10]="SourceAlphaSaturate",eW[eW.BlendColor=11]="BlendColor",eW[eW.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eX=e.BlendOperation||(e.BlendOperation={}))[eX.Add=0]="Add",eX[eX.Subtract=1]="Subtract",eX[eX.ReverseSubtract=2]="ReverseSubtract",eX[eX.Min=3]="Min",eX[eX.Max=4]="Max",e.ColorWriteMask=void 0,(eK=e.ColorWriteMask||(e.ColorWriteMask={}))[eK.None=0]="None",eK[eK.Red=1]="Red",eK[eK.Green=2]="Green",eK[eK.Blue=4]="Blue",eK[eK.Alpha=8]="Alpha",eK[eK.All=15]="All",e.CompareFunction=void 0,(ej=e.CompareFunction||(e.CompareFunction={}))[ej.Never=0]="Never",ej[ej.Less=1]="Less",ej[ej.Equal=2]="Equal",ej[ej.LessEqual=3]="LessEqual",ej[ej.Greater=4]="Greater",ej[ej.NotEqual=5]="NotEqual",ej[ej.GreaterEqual=6]="GreaterEqual",ej[ej.Always=7]="Always",e.CullMode=void 0,(eY=e.CullMode||(e.CullMode={}))[eY.Off=0]="Off",eY[eY.Front=1]="Front",eY[eY.Back=2]="Back",e.RenderStateDataKey=void 0,(eq=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eq.BlendStateEnabled0=0]="BlendStateEnabled0",eq[eq.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eq[eq.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eq[eq.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eq[eq.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eq[eq.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eq[eq.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eq[eq.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eq[eq.BlendStateBlendColor=8]="BlendStateBlendColor",eq[eq.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eq[eq.DepthStateEnabled=10]="DepthStateEnabled",eq[eq.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eq[eq.DepthStateCompareFunction=12]="DepthStateCompareFunction",eq[eq.StencilStateEnabled=13]="StencilStateEnabled",eq[eq.StencilStateReferenceValue=14]="StencilStateReferenceValue",eq[eq.StencilStateMask=15]="StencilStateMask",eq[eq.StencilStateWriteMask=16]="StencilStateWriteMask",eq[eq.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eq[eq.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eq[eq.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eq[eq.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eq[eq.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eq[eq.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eq[eq.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eq[eq.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eq[eq.RasterStateCullMode=25]="RasterStateCullMode",eq[eq.RasterStateDepthBias=26]="RasterStateDepthBias",eq[eq.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",eq[eq.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(eQ=e.RenderQueueType||(e.RenderQueueType={}))[eQ.Opaque=0]="Opaque",eQ[eQ.AlphaTest=1]="AlphaTest",eQ[eQ.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eZ=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eZ.Float=0]="Float",eZ[eZ.Int=1]="Int",eZ[eZ.Vector2=2]="Vector2",eZ[eZ.Vector3=3]="Vector3",eZ[eZ.Vector4=4]="Vector4",eZ[eZ.Matrix=5]="Matrix",eZ[eZ.Color=6]="Color",eZ[eZ.Texture=7]="Texture",eZ[eZ.FloatArray=8]="FloatArray",eZ[eZ.IntArray=9]="IntArray",eZ[eZ.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eJ=e.StencilOperation||(e.StencilOperation={}))[eJ.Keep=0]="Keep",eJ[eJ.Zero=1]="Zero",eJ[eJ.Replace=2]="Replace",eJ[eJ.IncrementSaturate=3]="IncrementSaturate",eJ[eJ.DecrementSaturate=4]="DecrementSaturate",eJ[eJ.Invert=5]="Invert",eJ[eJ.IncrementWrap=6]="IncrementWrap",eJ[eJ.DecrementWrap=7]="DecrementWrap";var ut=function(){function e(t,r,n,i){this.name=t,this._maskIndex=n,this._maskValue=i,this.value=r;var a=e._macroNameIdMap,o=a[t];void 0===a[t]&&(a[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,i=e._macroMap[n];if(!i){var a=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;i=new e(t,r,s,1<<l),e._macroMap[n]=i,s==a.length&&(a.length++,a[s]=Array(32)),a[s][l]=n,e._macroCounter++}return i},e._getNamesByMacros=function(t,r){var n=e._macroMaskMap,i=t._mask;r.length=0;for(var a=0,o=t._length;a<o;a++)for(var s=n[a],l=i[a],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&r.push(s[u])},e}();ut._macroMaskMap=[],ut._macroNameIdMap=Object.create(null),ut._macroNameCounter=0,ut._macroCounter=0,ut._macroMap=Object.create(null);var ur=((e0=(e$=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,i=this._length;if(i<r){for(n.length<r&&(n.length=r);i<t;i++)n[i]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},e0.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var i=r[t]&~e._maskValue;t==n&&0===i?this._length--:r[t]=i}},e0.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,i=this._length;if(i<r){n.length<r&&(n.length=r);for(var a=0;a<i;a++)n[a]|=t[a];for(;a<r;a++)n[a]=t[a];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},e0.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,i=Math.min(e._length-1,n);i>=0;i--){var a=r[i]&~t[i];i==n&&0===a?(n--,this._length--):r[i]=a}},e0.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var i=r[n]&t[n];0==i&&n==this._length-1?this._length--:r[n]=i}},e0.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},e0.clear=function(){this._length=0},e$.unionCollection=function(e,t,r){var n,i,a,o,s=r._mask;e._length<t._length?(n=e._length,i=t._length,a=e._mask,o=t._mask):(n=t._length,i=e._length,a=t._mask,o=e._mask);var l=0;for(s.length<i&&(s.length=i);l<n;l++)s[l]=a[l]|o[l];for(;l<i;l++)s[l]=o[l];r._length=i},e$);function un(){return(un=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,(e1=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",e1.ShadowCaster="ShadowCaster",e1.Forward="Forward";var ui=un({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;",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) )\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) )\nvec3 normalW=normalize(mat3(renderer_NormalMat)*normal.xyz);vec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\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 MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\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 vec3 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 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\nattenuation=mix(1.0,attenuation,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\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;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\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\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\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};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\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}void initMaterial(out Material material,const in 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));\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}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+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);}float 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);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}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.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(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.viewDir,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 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,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.viewDir,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.viewDir,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(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));\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) )\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 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*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"}),ua=((e2=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},e2.registerInclude=function(e,t){if(ui[e])throw'The "'+e+'" shader include already exist';ui[e]=t},e2.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var r=ui[t];return void 0===r?(cN.error('Shader slice "'+e.trim()+'" not founded.'),""):e2.parseIncludes(r)})},e2.convertTo300=function(e,t){if(e=(e=(e=(e=e.replace(/\battribute\b/g,"in")).replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),t){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")}return e},e2._replaceMRTShader=function(e,t){for(var r="",n=new Set,i=0;i<t.length;i++){var a=t[i].match(/\bgl_FragData\[(.+?)\]/);n.add(a[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)},e2);ua._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"].map(function(e){return"#extension "+e+" : enable\n"}).join("");var uo=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}();uo._nameCounter=0,uo._nameMap=Object.create(null);var us=((e4=(e3=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?uo.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&cN.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},e4.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?uo.getByName(e):e)._uniqueId]},e4.getTagValue=function(e){return this._tagsMap["string"==typeof e?uo.getByName(e)._uniqueId:e._uniqueId]},cg(e3,[{key:"name",get:function(){return this._name}}]),e3);(e5=lC||(lC={}))[e5.Scene=0]="Scene",e5[e5.Camera=1]="Camera",e5[e5.Renderer=2]="Renderer",e5[e5.Material=3]="Material",e.ColorSpace=void 0,(e8=e.ColorSpace||(e.ColorSpace={}))[e8.Linear=0]="Linear",e8[e8.Gamma=1]="Gamma";var ul=((e7=(e6=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)},e7.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},e7.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,cd.gammaToLinearSpace(r.r),cd.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)},e7.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},e7.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,cd.gammaToLinearSpace(r.r),cd.gammaToLinearSpace(r.g),cd.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)},e7.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},e7.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,cd.gammaToLinearSpace(r.r),cd.gammaToLinearSpace(r.g),cd.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)},e7.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},e7.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},e7.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},e7.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)},e7.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},e7.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)},e7.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},e7.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)},e7.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},e7.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},e7.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},e7.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},e7.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,i=0;i<t.length;i++){var a=t[i];r.activeTexture(n[i]),r.bindTexture(a._platformTexture),a._setUseDepthCompareMode(e.textureUseCompareMode)}},e6),uc=function(){this.constUniforms=[],this.textureUniforms=[]},uu=function(){function e(t,r,n){this.sceneUniformBlock=new uc,this.cameraUniformBlock=new uc,this.rendererUniformBlock=new uc,this.materialUniformBlock=new uc,this.otherUniformBlock=new uc,this._uploadRenderCount=-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,i=0,a=n.length;i<a;i++){var o=n[i],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 i=0,a=n.length;i<a;i++){var o=n[i],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],i=cq._getShaderPropertyGroup(n.name);void 0!==i&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,i,t))}},t._groupingUniform=function(e,t,r){switch(t){case lC.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case lC.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case lC.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case lC.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 i=this._createShader(r.FRAGMENT_SHADER,t);if(!i)return null;var a=r.createProgram();return a?(r.attachShader(a,n),r.attachShader(a,i),r.linkProgram(a),r.validateProgram(a),r.deleteShader(n),r.deleteShader(i),!cN.isEnabled||r.getProgramParameter(a,r.LINK_STATUS)||r.isContextLost())?a:(cN.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(a,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(a)),r.deleteProgram(a),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,i=n.createShader(t);return i?(n.shaderSource(i,r),n.compileShader(i),!cN.isEnabled||n.getShaderParameter(i,n.COMPILE_STATUS)||n.isContextLost())?i:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(i)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(i),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),i=this._getAttributeInfos();n.forEach(function(n){var i,a=n.name,o=n.size,s=n.type,l=new ul(e._engine),c=!1,u=!1;a.indexOf("[0]")>0&&(a=a.substr(0,a.length-3),c=!0);var d=t.getUniformLocation(r,a);switch(l.name=a,l.propertyId=cq.getByName(a)._uniqueId,l.location=d,s){case t.FLOAT:c?l.applyFunc=l.upload1fv:(l.applyFunc=l.upload1f,l.cacheValue=0);break;case t.FLOAT_VEC2:c?l.applyFunc=l.upload2fv:(l.applyFunc=l.upload2f,l.cacheValue=new cc(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new l9(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new cu(0,0,0,0));break;case t.BOOL:case t.INT:c?l.applyFunc=l.upload1iv:(l.applyFunc=l.upload1i,l.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:c?l.applyFunc=l.upload2iv:(l.applyFunc=l.upload2i,l.cacheValue=new cc(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:c?l.applyFunc=l.upload3iv:(l.applyFunc=l.upload3i,l.cacheValue=new l9(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new cu(0,0,0));break;case t.FLOAT_MAT4:l.applyFunc=c?l.uploadMat4v:l.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(s){case t.SAMPLER_2D:i=e._engine._magentaTexture2D;break;case t.SAMPLER_CUBE:i=e._engine._magentaTextureCube;break;case t.SAMPLER_2D_ARRAY:i=e._engine._magentaTexture2DArray;break;case t.SAMPLER_2D_SHADOW:i=e._engine._depthTexture2D,l.textureUseCompareMode=!0}if(u=!0,c){for(var h=Array(o),_=new Int32Array(o),f=Array(o),p=0;p<o;p++)h[p]=i,_[p]=e._activeTextureUint,f[p]=t.TEXTURE0+e._activeTextureUint++;l.textureDefault=h,l.textureIndex=f,l.applyFunc=l.uploadTextureArray,e.bind(),t.uniform1iv(d,_)}else{var m=t.TEXTURE0+e._activeTextureUint;l.textureDefault=i,l.textureIndex=m,l.applyFunc=l.uploadTexture,e.bind(),t.uniform1i(d,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var g=cq._getShaderPropertyGroup(a);e._groupingUniform(l,g,u)}),i.forEach(function(n){var i=n.name;e.attributeLocation[i]=t.getAttribLocation(r,i)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),i=0;i<r;++i){var a=e.getActiveUniform(t,i);n[i]=a}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<n;++i){var a=e.getActiveAttrib(t,i);r[i]=a}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 i=0;i<n-t.length;i++)t+=" ";return t+e}).join("\n")},cg(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();uu._counter=0;var ud=function(t){function r(n,i,a,o){var s;for(var l in(s=t.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderPassId=r._shaderPassCounter++,"string"==typeof a?(s._name=n,s._vertexSource=i,s._fragmentSource=a,o=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=i,o=null!=a?a:{pipelineStage:e.PipelineStage.Forward}),o)s.setTag(l,o[l]);return s}return cy(r,t),r.prototype._getShaderProgram=function(t,r){var n=t._getShaderProgramPool(this),i=n.get(r);if(i)return i;var a=t._hardwareRenderer.isWebGL2,o=[];ut._getNamesByMacros(r,o);var s=ua.parseCustomMacros(o),l=a?"#version 300 es":"#version 100",c=a?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",u="\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)&&(u+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(u+="#define HAS_DERIVATIVES\n");var d=" "+l+"\n "+c+"\n "+s+"\n "+ua.parseIncludes(this._vertexSource),h=" "+l+"\n "+c+"\n "+(a?"":ua._shaderExtension)+"\n "+u+"\n "+s+"\n "+ua.parseIncludes(this._fragmentSource);return a&&(d=ua.convertTo300(d),h=ua.convertTo300(h,!0)),i=new uu(t,d,h),n.cache(i),i},r}(us);ud._shaderPassCounter=0;var uh=(cy(e9=function(e,t,r){var n;if((n=us.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var i in n._passes=t.slice(),r)n.setTag(i,r[i]);return n},us),cg(e9,[{key:"passes",get:function(){return this._passes}}]),e9),u_=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},uf=((tt=(te=function(){this.targetBlendState=new u_,this.blendColor=new cd(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,i,a,o,s,l,c,u=this.targetBlendState,d=t[e.RenderStateDataKey.BlendStateEnabled0];if(void 0!==d){var h=r.getFloat(d);u.enabled=void 0!==h&&!!h}var _=t[e.RenderStateDataKey.BlendStateColorBlendOperation0];void 0!==_&&(u.colorBlendOperation=null!=(n=r.getFloat(_))?n:e.BlendOperation.Add);var f=t[e.RenderStateDataKey.BlendStateAlphaBlendOperation0];void 0!==f&&(u.alphaBlendOperation=null!=(i=r.getFloat(f))?i:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(u.sourceColorBlendFactor=null!=(a=r.getFloat(p))?a:e.BlendFactor.One);var m=t[e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0];void 0!==m&&(u.sourceAlphaBlendFactor=null!=(o=r.getFloat(m))?o:e.BlendFactor.One);var g=t[e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0];void 0!==g&&(u.destinationColorBlendFactor=null!=(s=r.getFloat(g))?s:e.BlendFactor.Zero);var v=t[e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0];void 0!==v&&(u.destinationAlphaBlendFactor=null!=(l=r.getFloat(v))?l:e.BlendFactor.Zero);var y=t[e.RenderStateDataKey.BlendStateColorWriteMask0];void 0!==y&&(u.colorWriteMask=null!=(c=r.getFloat(y))?c:e.ColorWriteMask.All);var x=t[e.RenderStateDataKey.BlendStateBlendColor];if(void 0!==x){var S=r.getColor(x);void 0!==S&&this.blendColor.copyFrom(S)}var C=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==C){var T=r.getFloat(C);this.alphaToCoverage=void 0!==T&&!!T}},tt._apply=function(e,t){this._platformApply(e,t.blendState)},tt._platformApply=function(t,r){var n=t.gl,i=r.targetBlendState,a=this.targetBlendState,o=a.enabled,s=a.colorBlendOperation,l=a.alphaBlendOperation,c=a.sourceColorBlendFactor,u=a.destinationColorBlendFactor,d=a.sourceAlphaBlendFactor,h=a.destinationAlphaBlendFactor,_=a.colorWriteMask;if(o!==i.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),i.enabled=o),o){(c!==i.sourceColorBlendFactor||u!==i.destinationColorBlendFactor||d!==i.sourceAlphaBlendFactor||h!==i.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(te._getGLBlendFactor(t,c),te._getGLBlendFactor(t,u),te._getGLBlendFactor(t,d),te._getGLBlendFactor(t,h)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=d,i.destinationAlphaBlendFactor=h),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(n.blendEquationSeparate(te._getGLBlendOperation(t,s),te._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;cd.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==i.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),i.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)},te._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}},te._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}},te);cC([cR],uf.prototype,"targetBlendState",void 0),cC([cR],uf.prototype,"blendColor",void 0);var up=((tn=(tr=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._applyShaderDataValue=function(t,r){var n,i=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==i){var a=r.getFloat(i);this.enabled=void 0!==a&&!!a}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)},tn._apply=function(e,t){this._platformApply(e,t.depthState)},tn._platformApply=function(e,t){var r=e.gl,n=this.enabled,i=this.compareFunction,a=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&(i!=t.compareFunction&&(r.depthFunc(tr._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(r.depthMask(a),t.writeEnabled=a))},tr._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}},tr),um=((ta=(ti=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,i,a,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!=(i=r.getFloat(s))?i:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(a=r.getFloat(l))?a:0)},ta._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},ta._platformApply=function(t,r,n){var i=t.gl,a=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=a!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),r._cullFaceEnable=l),l&&a!==r.cullMode&&(a==e.CullMode.Back?i.cullFace(i.BACK):i.cullFace(i.FRONT),r.cullMode=a),n!==r._frontFaceInvert&&(n?i.frontFace(i.CW):i.frontFace(i.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset(s,o)):i.disable(i.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},ti),ug=((ts=(to=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,i,a,o,s,l,c,u,d,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!=(i=r.getFloat(g))?i:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(a=r.getFloat(v))?a: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 S=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==S&&(this.passOperationFront=null!=(l=r.getFloat(S))?l:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==C&&(this.passOperationBack=null!=(c=r.getFloat(C))?c:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==T&&(this.failOperationFront=null!=(u=r.getFloat(T))?u:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==A&&(this.failOperationBack=null!=(d=r.getFloat(A))?d:e.StencilOperation.Keep);var E=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==E&&(this.zFailOperationFront=null!=(h=r.getFloat(E))?h:e.StencilOperation.Keep);var M=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==M&&(this.zFailOperationBack=null!=(_=r.getFloat(M))?_:e.StencilOperation.Keep)},ts._apply=function(e,t){this._platformApply(e,t.stencilState)},ts._platformApply=function(e,t){var r=e.gl,n=this.enabled,i=this.referenceValue,a=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,u=this.passOperationFront,d=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=i!==t.referenceValue||a!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,to._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,to._getGLCompareFunction(e,s),i,a),t.compareFunctionBack=this.compareFunctionBack),p&&(t.referenceValue=this.referenceValue,t.mask=this.mask),(l!==t.failOperationFront||c!==t.zFailOperationFront||u!==t.passOperationFront)&&(r.stencilOpSeparate(r.FRONT,to._getGLStencilOperation(e,l),to._getGLStencilOperation(e,c),to._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(d!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,to._getGLStencilOperation(e,d),to._getGLStencilOperation(e,h),to._getGLStencilOperation(e,_)),t.failOperationBack=d,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},to._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}},to._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}},to),uv=((tc=(tl=function(){this.blendState=new uf,this.depthState=new up,this.stencilState=new ug,this.rasterState=new um,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,i=t[e.RenderStateDataKey.RenderQueueType];void 0!==i&&(this.renderQueueType=null!=(n=r.getFloat(i))?n:e.RenderQueueType.Opaque)},tc._apply=function(e,t,r,n){r&&this._applyShaderDataValue(r,n);var i=e._hardwareRenderer,a=e._lastRenderState;this.blendState._apply(i,a),this.depthState._apply(i,a),this.stencilState._apply(i,a),this.rasterState._apply(i,a,t)},tl);cC([cR],uv.prototype,"blendState",void 0),cC([cR],uv.prototype,"depthState",void 0),cC([cR],uv.prototype,"stencilState",void 0),cC([cR],uv.prototype,"rasterState",void 0);var uy=((tu=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var r=tu._compileMacros;r.clear();for(var n=0,i=t.length;n<i;n++)r.enable(ut.getByName(t[n]));for(var a=this._subShaders,o=0,s=a.length;o<s;o++){for(var l=void 0,c=a[o].passes,u=0,d=c.length;u<d;u++)void 0===l?l=c[u]._getShaderProgram(e,r).isValid:l&&(l=c[u]._getShaderProgram(e,r).isValid);if(l)return!0}return!1},tu.create=function(e,t,r){var n,i=tu._shaderMap;if(t){if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new ud(t,r);n=new tu(e,[new uh("Default",[a])])}else if(t.length>0)n=t[0].constructor===ud?new tu(e,[new uh("Default",t)]):new tu(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!tu._shaderLab)throw"ShaderLab has not been set up yet.";var o=tu._shaderLab.parseShader(e);if(i[o.name])throw'Shader named "'+o.name+'" already exists.';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=tu.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 i=new ud(e.name,e.vertexSource,e.fragmentSource,e.tags),a=e.renderStates,o=new uv;i._renderState=o;var s=a[0];for(var l in s)tu._applyConstRenderStates(o,parseInt(l),s[l]);var c=a[1],u={};for(var d in c)u[d]=cq.getByName(c[d]);return i._renderStateDataMap=u,i});return new uh(o.name,t,e.tags)});return n=new tu(o.name,s),i[o.name]=n,n}return i[e]=n,n},tu.find=function(e){return tu._shaderMap[e]},tu._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}},tu.getMacroByName=function(e,t){return ut.getByName(e,t)},tu.getPropertyByName=function(e){return cq.getByName(e)},cg(tu,[{key:"subShaders",get:function(){return this._subShaders}}]),tu);uy._compileMacros=new ur,uy._shaderMap=Object.create(null);var ux=((th=(td=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new ur,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},th.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},th.getInt=function(e){return this.getPropertyValue(e)},th.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},th.getFloatArray=function(e){return this.getPropertyValue(e)},th.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},th.getIntArray=function(e){return this.getPropertyValue(e)},th.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},th.getVector2=function(e){return this.getPropertyValue(e)},th.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},th.getVector3=function(e){return this.getPropertyValue(e)},th.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},th.getVector4=function(e){return this.getPropertyValue(e)},th.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},th.getMatrix=function(e){return this.getPropertyValue(e)},th.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},th.getColor=function(e){return this.getPropertyValue(e)},th.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},th.getTexture=function(e){return this.getPropertyValue(e)},th.setTexture=function(t,r){var n=this._refCount;if(n>0){var i=this.getPropertyValue(t);i&&i._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},th.getTextureArray=function(e){return this.getPropertyValue(e)},th.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var i=this.getPropertyValue(t);if(i)for(var a=0,o=i.length;a<o;a++)i[a]._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)},th.getPropertyValue=function(e){return"string"==typeof e&&(e=cq.getByName(e)),this._propertyValueMap[e._uniqueId]},th.enableMacro=function(e,t){"string"==typeof e&&(e=ut.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var i=this._macroCollection;n&&i.disable(n),i.enable(e),this._macroMap[r]=e}},th.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=ut._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},th.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])},th.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=cq._propertyIdMap;for(var i in r)t.push(n[i]);if(!e)return t},th.clone=function(){var e=new td(this._group);return this.cloneTo(e),e},th.cloneTo=function(e){cw.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,i=Object.keys(r),a=0,o=i.length;a<o;a++){var s=i[a],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(cT(l,cz))n[s]=l,t>0&&l._addReferCount(t);else if(cT(l,Array)||cT(l,Float32Array)||cT(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},th._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=cq.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 "+lC[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},th._getReferCount=function(){return this._refCount},th._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&cT(n,cz)&&n._addReferCount(e)}},td);cC([cA],ux.prototype,"_group",void 0),cC([cA],ux.prototype,"_propertyValueMap",void 0),cC([cA],ux.prototype,"_macroCollection",void 0),cC([cA],ux.prototype,"_macroMap",void 0),cC([cA],ux.prototype,"_refCount",void 0);var uS=((t_=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(t_._viewMatrixProperty,e.viewMatrix),t.setMatrix(t_._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(t_.vpMatrixProperty,e.viewProjectionMatrix)},t_);uS.vpMatrixProperty=cq.getByName("camera_VPMat"),uS.pipelineStageKey=uo.getByName("pipelineStage"),uS._viewMatrixProperty=cq.getByName("camera_ViewMat"),uS._projectionMatrixProperty=cq.getByName("camera_ProjMat");var uC=((tp=(tf=function(){}).prototype).setX=function(e,t,r,n){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n},tp.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},tf),uT=((tg=(tm=function(){}).prototype).set=function(e,t){this.data=e,this.shaderPasses=t},tg.dispose=function(){this.data=this.shaderPasses=null},tm);function uA(){return function(e){}}e.SpriteMaskInteraction=void 0,(tv=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[tv.None=0]="None",tv[tv.VisibleInsideMask=1]="VisibleInsideMask",tv[tv.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(cy(ty=function(t){(r=cZ.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new ur,r._bounds=new ct,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._shaderData=new ux(lC.Renderer),r._mvMatrix=new cs,r._mvpMatrix=new cs,r._mvInvMatrix=new cs,r._normalMatrix=new cs,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r._rendererLayer=new cu,r.castShadows=!0;var r,n=e.Renderer.prototype,i=r.shaderData;return r._overrideUpdate=r.update!==n.update,i._addReferCount(1),r._onTransformChanged=r._onTransformChanged.bind(cp(r)),r._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},cZ),(tx=ty.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},tx.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},tx.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},tx.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},tx.getMaterials=function(){return this._materials},tx.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,i=t,a=r.length;i<a;i++){var o=r[i];o&&o._addReferCount(-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&&l._addReferCount(-1),c&&c._addReferCount(1))}},tx.update=function(e){},tx._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},tx._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},tx._prepareRender=function(t){var r=t.virtualCamera,n=r.position,i=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(l9.subtract(i,n,i),this._distanceForSort=l9.dot(i,r.forward)):this._distanceForSort=l9.distanceSquared(i,n),this._updateShaderData(t),this._render(t),ur.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},tx._cloneTo=function(e,t,r){for(var n=this._materials,i=0,a=n.length;i<a;i++)e._setMaterial(i,n[i])},tx._onDestroy=function(){cZ.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this.shaderData._addReferCount(-1);for(var e,t=this._materials,r=0,n=t.length;r<n;r++)null==(e=t[r])||e._addReferCount(-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},tx._updateShaderData=function(e){var t=this.entity,r=t.transform.worldMatrix;this._updateTransformShaderData(e,r);var n=t.layer;this._rendererLayer.set(65535&n,n>>>16&65535,0,0)},tx._updateTransformShaderData=function(t,r){var n=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;cs.multiply(i.viewMatrix,r,a),cs.multiply(i.viewProjectionMatrix,r,o),cs.invert(a,s),cs.invert(r,l),l.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._mvpMatrixProperty,o),n.setMatrix(e.Renderer._mvInvMatrixProperty,s),n.setMatrix(e.Renderer._normalMatrixProperty,l)},tx._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},tx._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},tx._updateBounds=function(e){},tx._render=function(e){throw"not implement"},tx._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",e._addReferCount(-1),r._addReferCount(1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},tx._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var i=this._materialsInstanced;e<i.length&&(i[e]=!1),n&&n._addReferCount(-1),t&&t._addReferCount(1),r[e]=t}},tx._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},cg(ty,[{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}}]),ty._tempVector0=new l9,ty._receiveShadowMacro=ut.getByName("RENDERER_IS_RECEIVE_SHADOWS"),ty._localMatrixProperty=cq.getByName("renderer_LocalMat"),ty._worldMatrixProperty=cq.getByName("renderer_ModelMat"),ty._mvMatrixProperty=cq.getByName("renderer_MVMat"),ty._mvpMatrixProperty=cq.getByName("renderer_MVPMat"),ty._mvInvMatrixProperty=cq.getByName("renderer_MVInvMat"),ty._normalMatrixProperty=cq.getByName("renderer_NormalMat"),ty._rendererLayerProperty=cq.getByName("renderer_Layer"),ty),cC([cA],e.Renderer.prototype,"_distanceForSort",void 0),cC([cA],e.Renderer.prototype,"_onUpdateIndex",void 0),cC([cA],e.Renderer.prototype,"_rendererIndex",void 0),cC([cA],e.Renderer.prototype,"_globalShaderMacro",void 0),cC([cA],e.Renderer.prototype,"_bounds",void 0),cC([cA],e.Renderer.prototype,"_renderFrameCount",void 0),cC([cA],e.Renderer.prototype,"_overrideUpdate",void 0),cC([cA],e.Renderer.prototype,"_materials",void 0),cC([cA],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),cC([cR],e.Renderer.prototype,"_shaderData",void 0),cC([cA],e.Renderer.prototype,"_mvMatrix",void 0),cC([cA],e.Renderer.prototype,"_mvpMatrix",void 0),cC([cA],e.Renderer.prototype,"_mvInvMatrix",void 0),cC([cA],e.Renderer.prototype,"_normalMatrix",void 0),cC([cA],e.Renderer.prototype,"_materialsInstanced",void 0),cC([cE],e.Renderer.prototype,"_priority",void 0),cC([cE],e.Renderer.prototype,"_receiveShadows",void 0),cC([cA],e.Renderer.prototype,"_rendererLayer",void 0),cC([cA],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=cC([c$(c6,e.DependentMode.CheckOnly)],e.Renderer),(tS=lT||(lT={}))[tS.WorldVolume=1]="WorldVolume";var uE=((tC=function(){}).resetData=function(e){var t,r,n=e._verticesData,i=n.positions,a=n.uvs;n.vertexCount=i.length=a.length=4;for(var o=0;o<4;o++)i[t=o]||(i[t]=new l9),a[r=o]||(a[r]=new cc);n.triangles=uE._rectangleTriangles},tC.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,i=n.pivot,a=i.x,o=i.y,s=uE._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,u=e.flipX?-t:t,d=e.flipY?-r:r;l[0]=c[0]*u,l[1]=c[1]*u,l[2]=c[2]*u,l[4]=c[4]*d,l[5]=c[5]*d,l[6]=c[6]*d,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-a*l[0]-o*l[4],l[13]=c[13]-a*l[1]-o*l[5],l[14]=c[14]-a*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])}ct.transform(n._getBounds(),s,e._bounds)},tC.updateUVs=function(e){var t=e.sprite._getUVs(),r=e._verticesData.uvs,n=t[0],i=n.x,a=n.y,o=t[3],s=o.x,l=o.y;r[0].set(i,a),r[1].set(s,a),r[2].set(i,l),r[3].set(s,l)},tC._rectangleTriangles=[0,1,2,2,1,3],tC._worldMatrix=new cs,tC);uE=cC([uA()],uE);var uM=function(e,t,r,n,i){void 0===n&&(n=null),void 0===i&&(i=null),this.vertexCount=e,this.positions=t,this.uvs=r,this.triangles=n,this.color=i};e.SpriteMaskLayer=void 0,(tT=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[tT.Layer0=1]="Layer0",tT[tT.Layer1=2]="Layer1",tT[tT.Layer2=4]="Layer2",tT[tT.Layer3=8]="Layer3",tT[tT.Layer4=16]="Layer4",tT[tT.Layer5=32]="Layer5",tT[tT.Layer6=64]="Layer6",tT[tT.Layer7=128]="Layer7",tT[tT.Layer8=256]="Layer8",tT[tT.Layer9=512]="Layer9",tT[tT.Layer10=1024]="Layer10",tT[tT.Layer11=2048]="Layer11",tT[tT.Layer12=4096]="Layer12",tT[tT.Layer13=8192]="Layer13",tT[tT.Layer14=16384]="Layer14",tT[tT.Layer15=32768]="Layer15",tT[tT.Layer16=65536]="Layer16",tT[tT.Layer17=131072]="Layer17",tT[tT.Layer18=262144]="Layer18",tT[tT.Layer19=524288]="Layer19",tT[tT.Layer20=1048576]="Layer20",tT[tT.Layer21=2097152]="Layer21",tT[tT.Layer22=4194304]="Layer22",tT[tT.Layer23=8388608]="Layer23",tT[tT.Layer24=16777216]="Layer24",tT[tT.Layer25=33554432]="Layer25",tT[tT.Layer26=67108864]="Layer26",tT[tT.Layer27=134217728]="Layer27",tT[tT.Layer28=268435456]="Layer28",tT[tT.Layer29=536870912]="Layer29",tT[tT.Layer30=1073741824]="Layer30",tT[tT.Layer31=2147483648]="Layer31",tT[tT.Everything=4294967295]="Everything",(tA=lA||(lA={}))[tA.texture=1]="texture",tA[tA.size=2]="size",tA[tA.atlasRotate=4]="atlasRotate",tA[tA.atlasRegion=8]="atlasRegion",tA[tA.atlasRegionOffset=16]="atlasRegionOffset",tA[tA.region=32]="region",tA[tA.pivot=64]="pivot",tA[tA.border=128]="border",tA[tA.destroy=256]="destroy";var uR=function(t){function r(n){var i;return(i=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,i._sprite=null,i._automaticWidth=0,i._automaticHeight=0,i._customWidth=void 0,i._customHeight=void 0,i._flipX=!1,i._flipY=!1,i._alphaCutoff=.5,i._verticesData=new uM(4,[],[]),uE.resetData(cp(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(r._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(cp(i)),i}cy(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?uE.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&lT.WorldVolume&&(uE.updatePositions(this),this._dirtyUpdateFlag&=~lT.WorldVolume),2&this._dirtyUpdateFlag&&(uE.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var i=n._spriteMaskRenderDataPool.getFromPool();i.set(this,r,this._verticesData);var a=n._renderElementPool.getFromPool();a.set(i,r.shader.subShaders[0].passes),this._maskElement=a}}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,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 lA.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case lA.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lT.WorldVolume);break;case lA.region:case lA.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lA.atlasRegion:this._dirtyUpdateFlag|=2;break;case lA.pivot:this._dirtyUpdateFlag|=lT.WorldVolume;break;case lA.destroy:this.sprite=null}},cg(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|=lT.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|=lT.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lT.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lT.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(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);uR._textureProperty=cq.getByName("renderer_MaskTexture"),uR._alphaCutoffProperty=cq.getByName("renderer_MaskAlphaCutoff"),cC([cE],uR.prototype,"influenceLayers",void 0),cC([cA],uR.prototype,"_verticesData",void 0),cC([cA],uR.prototype,"_sprite",void 0),cC([cA],uR.prototype,"_automaticWidth",void 0),cC([cA],uR.prototype,"_automaticHeight",void 0),cC([cE],uR.prototype,"_customWidth",void 0),cC([cE],uR.prototype,"_customHeight",void 0),cC([cE],uR.prototype,"_flipX",void 0),cC([cE],uR.prototype,"_flipY",void 0),cC([cE],uR.prototype,"_alphaCutoff",void 0),cC([cA],uR.prototype,"_onSpriteChange",null),(tE=lE||(lE={}))[tE.UV=2]="UV",tE[tE.RenderData=3]="RenderData",tE[tE.AutomaticSize=4]="AutomaticSize",tE[tE.All=7]="All",e.VertexElementFormat=void 0,(tM=e.VertexElementFormat||(e.VertexElementFormat={}))[tM.Float=0]="Float",tM[tM.Vector2=1]="Vector2",tM[tM.Vector3=2]="Vector3",tM[tM.Vector4=3]="Vector4",tM[tM.Byte4=4]="Byte4",tM[tM.UByte4=5]="UByte4",tM[tM.NormalizedByte4=6]="NormalizedByte4",tM[tM.NormalizedUByte4=7]="NormalizedUByte4",tM[tM.Short2=8]="Short2",tM[tM.UShort2=9]="UShort2",tM[tM.NormalizedShort2=10]="NormalizedShort2",tM[tM.NormalizedUShort2=11]="NormalizedUShort2",tM[tM.Short4=12]="Short4",tM[tM.UShort4=13]="UShort4",tM[tM.NormalizedShort4=14]="NormalizedShort4",tM[tM.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(tR=e.IndexFormat||(e.IndexFormat={}))[tR.UInt8=0]="UInt8",tR[tR.UInt16=1]="UInt16",tR[tR.UInt32=2]="UInt32";var uw=((tw=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}},tw._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tw._getElementInfo=function(t){var r,n,i,a=!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,a=!0,i=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,a=!0,i=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,a=!0,i=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,a=!0,i=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,a=!0,i=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,a=!0,i=1/65535}return{size:r,type:n,normalized:a,normalizedScaleFactor:i}},tw),ub=(cg(tb=function(e,t,r,n,i){void 0===i&&(i=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=uw._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)},[{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}}]),tb);e.BufferUsage=void 0,(tP=e.BufferUsage||(e.BufferUsage={}))[tP.Static=0]="Static",tP[tP.Dynamic=1]="Dynamic",tP[tP.Stream=2]="Stream",e.SetDataOptions=void 0,(tF=e.SetDataOptions||(e.SetDataOptions={}))[tF.None=0]="None",tF[tF.Discard=1]="Discard";var uP=(cy(tL=function(t,r,n,i,a){if(void 0===i&&(i=e.BufferUsage.Static),void 0===a&&(a=!1),(o=cL.call(this,t)||this)._dataUpdateManager=new c8,o._engine=t,o._type=r,o._bufferUsage=i,o._readable=a,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,i),a&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,i,n),a){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},cL),(tD=tL.prototype).bind=function(){this._platformBuffer.bind()},tD.setData=function(t,r,n,i,a){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,i,a),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=i?s*i:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,u=new Uint8Array(o,c,l);this._data.set(u,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},tD.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},tD.markAsUnreadable=function(){this._data=null,this._readable=!1},tD._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},tD._onDestroy=function(){cL.prototype._onDestroy.call(this),this._platformBuffer.destroy()},cg(tL,[{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."}}]),tL);e.BufferBindFlag=void 0,(tB=e.BufferBindFlag||(e.BufferBindFlag={}))[tB.VertexBuffer=0]="VertexBuffer",tB[tB.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(tI=e.MeshTopology||(e.MeshTopology={}))[tI.Points=0]="Points",tI[tI.Lines=1]="Lines",tI[tI.LineLoop=2]="LineLoop",tI[tI.LineStrip=3]="LineStrip",tI[tI.Triangles=4]="Triangles",tI[tI.TriangleStrip=5]="TriangleStrip",tI[tI.TriangleFan=6]="TriangleFan";var uF=(cg(tV=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tV),uL=((tO=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(){},tO),uD=(cy(tN=function(e){var t;return(t=cL.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(cp(t)),t},cL),(tz=tN.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,i=t[n];i&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(i),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},tz.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},tz.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},tz.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,i=n[e];i&&delete r[i.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},tz.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,i=r.length;n<i;n++){var a=r[n];delete t[a.attribute]}r.length=e},tz.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),i=this.vertexBufferBindings;n>0&&(null==(r=i[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),i[e]=t,this._bufferStructChanged=!0},tz.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,i=t+n;r.length<i&&(r.length=i);for(var a=0;a<n;a++)this.setVertexBufferBinding(t+a,e[a])},tz.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=uw._getGLIndexType(e.format),this._glIndexByteCount=uw._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},tz.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tz._addReferCount=function(e){cL.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,i=0,a=n.length;i<a;i++)null==(r=n[i])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},tz._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},tz._onDestroy=function(){cL.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},cg(tN,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),tN),uB=(cy(tU=function(e,t){(r=cP.call(this,e)||this)._updateFlagManager=new c8,r._bounds=new ct,r._subMeshes=[],r.name=t,r._primitive=new uD(e),r._onBoundsChanged=r._onBoundsChanged.bind(cp(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},cP),(tk=tU.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new uL(t,r,n)),this._subMeshes.push(t),t},tk.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},tk.clearSubMesh=function(){this._subMeshes.length=0},tk._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},tk._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},tk._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},tk._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},tk._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},tk._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},tk._addReferCount=function(e){cP.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},tk._onDestroy=function(){cP.prototype._onDestroy.call(this),this._primitive.destroy()},tk._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},tk._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},tk._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},cg(tU,[{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}}]),tU);(tG=lM||(lM={}))[tG.Bounds=1]="Bounds",tG[tG.VertexElements=2]="VertexElements";var uI=(cg(tH=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tH),uV=((tW=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new c8,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},cg(tW,[{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)}}]),tW);(tX=lR||(lR={}))[tX.Position=1]="Position",tX[tX.Normal=2]="Normal",tX[tX.Tangent=4]="Tangent",tX[tX.All=7]="All";var uO=((tj=(tK=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new c8,this._dataChangeManager=new c8,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var i=new uV(e,t,r,n);return this._addFrame(i),i}this._addFrame(e)},tj.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()},tj._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},tj._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(lR.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},tj._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))},tj._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},cg(tK,[{key:"frames",get:function(){return this._frames}}]),tK),uN=(cy(tY=function(){return uB.apply(this,arguments)},uB),(tq=tY.prototype).setVertexElements=function(e){this._setVertexElements(e)},tq.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,i=void 0!==n.buffer;i||(n=new uI(e,t));var a=this._primitive.vertexBufferBindings;a.length<=r&&(a.length=r+1),this._setVertexBufferBinding(i?t:r,n)},tq.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,i=t+n;r.length<i&&(r.length=i);for(var a=0;a<n;a++)this._setVertexBufferBinding(t+a,e[a])},tq.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new uF(e,t))),this._setIndexBufferBinding(r)},cg(tY,[{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}}]),tY),uz=(tQ=e.Renderer,cy(tZ=function(e){var t;return(t=tQ.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(cp(t)),t},tQ),(tJ=tZ.prototype)._onDestroy=function(){tQ.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},tJ._cloneTo=function(e,t,r){tQ.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},tJ._prepareRender=function(e){if(!this._mesh){cN.error("mesh is null.");return}if(this._mesh.destroyed){cN.error("mesh is destroyed.");return}tQ.prototype._prepareRender.call(this,e)},tJ._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;ct.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tJ._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(tZ._uvMacro),r.disableMacro(tZ._uv1Macro),r.disableMacro(tZ._normalMacro),r.disableMacro(tZ._tangentMacro),r.disableMacro(tZ._enableVertexColorMacro);for(var i=0,a=n.length;i<a;i++)switch(n[i].attribute){case"TEXCOORD_0":r.enableMacro(tZ._uvMacro);break;case"TEXCOORD_1":r.enableMacro(tZ._uv1Macro);break;case"NORMAL":r.enableMacro(tZ._normalMacro);break;case"TANGENT":r.enableMacro(tZ._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(tZ._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._renderDataPool,u=0,d=s.length;u<d;u++){var h=o[u];if(h){h.destroyed&&(h=this.engine._meshMagentaMaterial);var _=c.getFromPool();_.setX(this,h,t._primitive,s[u]),l.pushRenderData(e,_)}}},tJ._setMesh=function(e){var t=this._mesh;t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tJ._onMeshChanged=function(e){e&lM.Bounds&&(this._dirtyUpdateFlag|=lT.WorldVolume),e&lM.VertexElements&&(this._dirtyUpdateFlag|=2)},cg(tZ,[{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)}}]),tZ);uz._uvMacro=ut.getByName("RENDERER_HAS_UV"),uz._uv1Macro=ut.getByName("RENDERER_HAS_UV1"),uz._normalMacro=ut.getByName("RENDERER_HAS_NORMAL"),uz._tangentMacro=ut.getByName("RENDERER_HAS_TANGENT"),uz._enableVertexColorMacro=ut.getByName("RENDERER_ENABLE_VERTEXCOLOR"),cC([cA],uz.prototype,"_mesh",void 0),cC([cA],uz.prototype,"_onMeshChanged",null),(t$=lw||(lw={}))[t$.VertexElementMacro=2]="VertexElementMacro",t$[t$.All=3]="All";var uU=((t1=(t0=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 cu,this._canUseTextureStoreData=!0,this._dataTextureInfo=new l9,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(c5))},t1._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,i=0,a=n.length;i<a;i++)n[i].destroy();n.length=0},t1._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(t0._blendShapeMacro),this._useTextureMode())e.enableMacro(t0._blendShapeTextureMacro),e.setTexture(t0._blendShapeTextureProperty,this._vertexTexture),e.setVector3(t0._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(t0._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var i=t._condensedBlendShapeWeights;i||(i=new Float32Array(n),t._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,i),e.setFloatArray(t0._blendShapeWeightsProperty,i),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(t0._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(t0._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(t0._blendShapeNormalMacro):e.disableMacro(t0._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(t0._blendShapeTangentMacro):e.disableMacro(t0._blendShapeTangentMacro)}else e.disableMacro(t0._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},t1._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},t1._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},t1._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},t1._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},t1._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,i=Math.max(r.length,t+1);n<i&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},t1._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,i=0,a=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());a<o;a++)t._setVertexElement(r++,new ub("POSITION_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12,this._useBlendNormal&&(t._setVertexElement(r++,new ub("NORMAL_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12),this._useBlendTangent&&(t._setVertexElement(r++,new ub("TANGENT_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12);return r},t1._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))},t1._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},t1._createVertexBuffers=function(t,r){var n=this._engine,i=this._modelMesh,a=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),u=Math.ceil(a/c),d=s*t*Math.min(c,a);o.length=u,this._vertices=new Float32Array(d),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=a;for(var h=this._bufferBindingOffset,_=0;_<u;_++){var f=u-1,p=(_===f?a-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new uP(n,e.BufferBindFlag.VertexBuffer,m,g);i._setVertexBufferBinding(h+_,new uI(v,p)),o[_]=v}},t1._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,i=n*t,a=1;i>r&&(a=Math.ceil(i/r),i=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new cG(this._engine,i,a,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*i*a*4),this._vertexTexture=o,this._dataTextureInfo.set(n,i,a)},t1._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,i=this._vertices,a=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,d=0,h=r.length;d<h;d++){var _=s[d];if(t||_.flag){var f=r[d].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(d/n),v=d%n,y=a[g],x=y.byteLength/(4*e),S=v*l,C=o[d];C||(o[d]=C=new cc),C.set(u+g,v*c);for(var T=m.deltaPositions,A=0;A<e;A++){var E=S+x*A,M=T[A];M&&(i[E]=M.x,i[E+1]=M.y,i[E+2]=M.z)}if(S+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var w=0;w<e;w++){var b=S+x*w,P=R[w];P&&(i[b]=P.x,i[b+1]=P.y,i[b+2]=P.z)}S+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=S+x*L,B=F[L];B&&(i[D]=B.x,i[D+1]=B.y,i[D+2]=B.z)}S+=3}(v===n-1||d===h-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},t1._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,i=this._vertices,a=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=a[o],c=n.width*n.height*4;if(t||l.flag){var u=r[o].frames,d=u.length,h=u[d-1];if(d>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(i[m]=v.x,i[m+1]=v.y,i[m+2]=v.z,m+=4,f){var y=f[g];i[m]=y.x,i[m+1]=y.y,i[m+2]=y.z,m+=4}if(p){var x=p[g];i[m]=x.x,i[m+1]=x.y,i[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,i)},t1._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,i=t._useBlendShapeNormal,a=t._useBlendShapeTangent;r&&(i&&(i=this._useBlendNormal),a&&(a=this._useBlendTangent)),i&&n++,a&&n++,this._useBlendNormal=i,this._useBlendTangent=a,this._vertexElementCount=n},t1._attributeModeUpdateVertexElement=function(e,t,r,n){var i=this._vertexElementOffset+this._vertexElementCount*n,a=t[r],o=a.x,s=a.y,l=e[i];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++i];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++i];s+=12,u.bindingIndex=o,u.offset=s}},t1._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},t1._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,i=this._modelMesh._primitive.vertexElements,a=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(i,a,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(i,a,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<n;u++){var d=t[u];d<o&&(o=d,r=u)}}}},t0);uU._blendShapeMacro=ut.getByName("RENDERER_HAS_BLENDSHAPE"),uU._blendShapeTextureMacro=ut.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),uU._blendShapeNormalMacro=ut.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),uU._blendShapeTangentMacro=ut.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),uU._blendShapeWeightsProperty=cq.getByName("renderer_BlendShapeWeights"),uU._blendShapeTextureProperty=cq.getByName("renderer_BlendShapeTexture"),uU._blendShapeTextureInfoProperty=cq.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(t2=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",t2.Normal="NORMAL",t2.Color="COLOR_0",t2.Tangent="TANGENT",t2.BoneWeight="WEIGHTS_0",t2.BoneIndex="JOINTS_0",t2.UV="TEXCOORD_0",t2.UV1="TEXCOORD_1",t2.UV2="TEXCOORD_2",t2.UV3="TEXCOORD_3",t2.UV4="TEXCOORD_4",t2.UV5="TEXCOORD_5",t2.UV6="TEXCOORD_6",t2.UV7="TEXCOORD_7";var uk=(cy(t3=function(e,t){var r;return(r=uB.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 l9(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 uU(e,cp(r)),r},uB),(t4=t3.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)},t4.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},t4.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},t4.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},t4.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},t4.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},t4.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},t4.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},t4.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},t4.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},t4.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},t4.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},t4.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]."}},t4.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 i=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=i,i;case 3:var a=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=a,a;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]."},t4.setIndices=function(t){this._indices!==t&&(this._indices=t,cT(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:cT(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:cT(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},t4.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},t4.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,i=0;i<n;i++)this._addVertexElement(t[i]);var a=this._primitive._vertexElementMap;a[e.VertexAttribute.Position]||this.setPositions(null),a[e.VertexAttribute.Normal]||this.setNormals(null),a[e.VertexAttribute.Color]||this.setColors(null),a[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),a[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),a[e.VertexAttribute.Tangent]||this.setTangents(null),a[e.VertexAttribute.UV]||this.setUVs(null,0),a[e.VertexAttribute.UV1]||this.setUVs(null,1),a[e.VertexAttribute.UV2]||this.setUVs(null,2),a[e.VertexAttribute.UV3]||this.setUVs(null,3),a[e.VertexAttribute.UV4]||this.setUVs(null,4),a[e.VertexAttribute.UV5]||this.setUVs(null,5),a[e.VertexAttribute.UV6]||this.setUVs(null,6),a[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},t4.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,i=void 0!==n.buffer;i||(n=new uI(e,t));var a=i?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=a+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(a,n),a===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),a===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},t4.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,a=t+r;n.length<a&&(n.length=a,i.length=a);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},t4.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},t4.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},t4.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},t4.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},t4.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,i=0,a=n.length;i<a;i++){var o=r[i];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[i])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,u=null==(d=this._primitive.indexBufferBinding)?void 0:d._buffer;if(c){if(u&&c.byteLength==u.byteLength)u.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new uF(u,this._indicesFormat));else{null==u||u.destroy();var d,h=new uP(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new uF(h,this._indicesFormat))}}else u&&(u.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var _=this._blendShapeManager;_._blendShapeCount>0&&_._update(t),t&&(this._accessible=!1,this._releaseCache(!1))},t4.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,i=this.vertexCount,a=t3._tempVec0,o=t3._tempVec1,s=t3._tempVec2,l=t3._tempVec3,c=t3._tempVec4,u=n?n.length/3:e.length/3,d=Array(i),h=Array(i),_=0;_<i;_++)d[_]=new cu,h[_]=new l9;for(var f=0;f<u;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],S=r[p],C=r[m],T=r[g];l9.subtract(y,v,a),l9.subtract(x,v,o);var A=C.x-S.x,E=T.x-S.x,M=C.y-S.y,R=T.y-S.y,w=1/(A*R-E*M);l9.scale(a,R*w,s),l9.scale(o,M*w,c),l9.subtract(s,c,s),l9.scale(o,A*w,l),l9.scale(a,E*w,c),l9.subtract(l,c,l);var b=d[p];b.set(b.x+s.x,b.y+s.y,b.z+s.z,1),(b=d[m]).set(b.x+s.x,b.y+s.y,b.z+s.z,1),(b=d[g]).set(b.x+s.x,b.y+s.y,b.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<i;P++){var F=t[P],L=h[P],D=d[P];s.set(D.x,D.y,D.z),l9.cross(s,L,c);var B=l9.dot(c,F)>0?1:-1;l9.scale(F,l9.dot(s,F),c),l9.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,B)}this.setTangents(d)},t4._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,a=function(){r._advancedDataSyncToBuffer||(i[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(a),uB.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(a),(i[e]||(i[e]=new uG)).reset(),a()):e+1==n.length&&n.length--},t4._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)}},t4._onDestroy=function(){uB.prototype._onDestroy.call(this),this._releaseCache(!0)},t4._getVertexElementData=function(e,t,r,n){var i,a=this._advancedVertexDataVersions,o=null!=(i=a[r])?i:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(a[r]=l,n.call(this,t))},t4._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)},t4._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},t4._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,i=this._internalVertexBufferCreatedInfo,a=r*n;if(i.x*i.y!==a){var o,s=i.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 u=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,d=new uP(this._engine,e.BufferBindFlag.VertexBuffer,a,u,!0);this._setVertexBufferBinding(l,new uI(d,r))}i.set(r,n,c?l:-1)}},t4._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new cc(e[t],e[t+1])})},t4._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new l9(e[t],e[t+1],e[t+2])})},t4._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new cu(e[t],e[t+1],e[t+2],e[t+3])})},t4._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new cd(e[t],e[t+1],e[t+2],e[t+3])})},t4._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var i=r.vertexBufferBindings[n.bindingIndex],a=null==i?void 0:i.buffer;if(!a)return null;if(!a.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(a.data.buffer,s.type),u=n.offset,d=i.stride,h=0;h<o;h++){var _=(h*d+u)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},t4._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var i=this._getAttributeFormat(t),a=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new ub(t,a,i,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)}}},t4._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)},t4._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 i=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||i&&t._blendShapeCount>0){var a=t._addVertexElements(this);a<r&&this._setVertexElementsLength(a)}},t4._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y)})},t4._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z)})},t4._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z,e[t+3]=i.w)})},t4._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.r,e[t+1]=i.g,e[t+2]=i.b,e[t+3]=i.a)})},t4._writeAdvancedVertexData=function(e,t,r){var n,i=this._primitive,a=i._vertexElementMap[e],o=a.bindingIndex,s=i.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,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=a._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=a.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=d.normalized,g=d.size,v=d.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var S=(y*f+_)/p;if(r(h,S,y),m)for(var C=0;C<g;C++)h[S+C]/=v}u.uploadAdvancedData=!0}}},t4._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,i=this._advancedDataUpdateFlag,a=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,u=this._uv2,d=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&i&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&i&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&i&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),a&&16&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,a),o&&32&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),u&&256&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,u),d&&512&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,d),h&&1024&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},t4._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},t4._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}},t4._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}},t4._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,i=0,a=n.length;i<a;i++){var o=n[i];o&&(o.dataVersion=r)}}},cg(t3,[{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}}]),t3);uk._tempVec0=new l9,uk._tempVec1=new l9,uk._tempVec2=new l9,uk._tempVec3=new l9,uk._tempVec4=new l9;var uG=((t5=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},t5);(t8=lb||(lb={}))[t8.None=0]="None",t8[t8.Position=1]="Position",t8[t8.Normal=2]="Normal",t8[t8.Color=4]="Color",t8[t8.Tangent=8]="Tangent",t8[t8.BoneWeight=16]="BoneWeight",t8[t8.BoneIndex=32]="BoneIndex",t8[t8.UV=64]="UV",t8[t8.UV1=128]="UV1",t8[t8.UV2=256]="UV2",t8[t8.UV3=512]="UV3",t8[t8.UV4=1024]="UV4",t8[t8.UV5=2048]="UV5",t8[t8.UV6=4096]="UV6",t8[t8.UV7=8192]="UV7",t8[t8.All=65535]="All",(t6=lP||(lP={}))[t6.Position=0]="Position",t6[t6.Normal=1]="Normal",t6[t6.Color=2]="Color",t6[t6.Tangent=3]="Tangent",t6[t6.BoneWeight=4]="BoneWeight",t6[t6.BoneIndex=5]="BoneIndex",t6[t6.UV=6]="UV",t6[t6.UV1=7]="UV1",t6[t6.UV2=8]="UV2",t6[t6.UV3=9]="UV3",t6[t6.UV4=10]="UV4",t6[t6.UV5=11]="UV5",t6[t6.UV6=12]="UV6",t6[t6.UV7=13]="UV7";var uH=(cy(t7=function(e,t){var r;return(r=cF.call(this,e)||this).primitiveInfo=t,r},cF),t7.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:u$._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:u$._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:u$._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:u$._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:u$._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:u$._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:u$._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:u$._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t7);(t9=lF||(lF={}))[t9.Sphere=0]="Sphere",t9[t9.Cuboid=1]="Cuboid",t9[t9.Plane=2]="Plane",t9[t9.Cylinder=3]="Cylinder",t9[t9.Torus=4]="Torus",t9[t9.Cone=5]="Cone",t9[t9.Capsule=6]="Capsule",t9[t9.CCSphere=7]="CCSphere";var uW=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},uX=(cy(re=function(e,t,r,n){var i;return(i=uW.call(this,0,r,n)||this).radius=e,i.segments=t,i},uW),re),uK=(cy(rt=function(e,t,r,n){var i;return(i=uW.call(this,7,r,n)||this).radius=e,i.step=t,i},uW),rt),uj=(cy(rr=function(e,t,r,n,i){var a;return(a=uW.call(this,1,n,i)||this).width=e,a.height=t,a.depth=r,a},uW),rr),uY=(cy(rn=function(e,t,r,n,i,a){var o;return(o=uW.call(this,2,i,a)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},uW),rn),uq=(cy(ri=function(e,t,r,n,i,a,o){var s;return(s=uW.call(this,3,a,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=i,s},uW),ri),uQ=(cy(ra=function(e,t,r,n,i,a,o){var s;return(s=uW.call(this,4,a,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=i,s},uW),ra),uZ=(cy(ro=function(e,t,r,n,i,a){var o;return(o=uW.call(this,5,i,a)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},uW),ro),uJ=(cy(rs=function(e,t,r,n,i,a){var o;return(o=uW.call(this,6,i,a)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},uW),rs),u$=((rl=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var i=new uk(e);rl._setSphereData(i,t,r,n,!1);var a=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(i,new uX(t,r,a,n))),i},rl.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var i=new uk(e);rl._setSubdivisionSurfaceSphereData(i,t,r,n,!1);var a=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(i,new uK(t,r,a,n))),i},rl.createCuboid=function(e,t,r,n,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===i&&(i=!0);var a=new uk(e);rl._setCuboidData(a,t,r,n,i,!1);var o=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(a,new uj(t,r,n,o,i))),a},rl.createPlane=function(e,t,r,n,i,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uk(e);rl._setPlaneData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(o,new uY(t,r,n,i,s,a))),o},rl.createCylinder=function(e,t,r,n,i,a,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===i&&(i=20),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new uk(e);rl._setCylinderData(s,t,r,n,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(s,new uq(t,r,n,i,a,l,o))),s},rl.createTorus=function(e,t,r,n,i,a,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===i&&(i=30),void 0===a&&(a=360),void 0===o&&(o=!0);var s=new uk(e);rl._setTorusData(s,t,r,n,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(s,new uQ(t,r,n,i,a,l,o))),s},rl.createCone=function(e,t,r,n,i,a){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uk(e);rl._setConeData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(o,new uZ(t,r,n,i,s,a))),o},rl.createCapsule=function(e,t,r,n,i,a){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uk(e);rl._setCapsuleData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uH(o,new uJ(t,r,n,i,s,a))),o},rl._setSubdivisionSurfaceSphereData=function(e,t,r,n,i,a){r=l7.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));rl._subdiveCatmullClark(r,o,s);for(var l=o.length/3,c=s.length/4,u=l+Math.pow(2,r+1)-1,d=u+16,h=new Float32Array(8*d),_=rl._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],S=1/Math.sqrt(v*v+y*y+x*x);if(v*=S,y*=S,x*=S,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 C=8*(l+f++);h.set(h.subarray(g,g+8),C),h[C+6]=1,p[g/8]=C/8}}var T=0;this._spherePoleIdx=0;for(var A=0;A<c;A++){var E=4*A,M=s[E],R=s[E+1],w=s[E+2],b=s[E+3],P=8*M,F=8*R,L=8*w,D=8*b;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(M=p[M]),0===h[F+6]&&(R=p[R]),0===h[L+6]&&(w=p[w]),0===h[D+6]&&(b=p[b])),_[T]=M,_[T+1]=R,_[T+2]=w,this._generateAndReplacePoleUV(_,h,T,u),_[T+3]=M,_[T+4]=w,_[T+5]=b,this._generateAndReplacePoleUV(_,h,T+3,u),T+=6}if(!i){var B=e.bounds;B.min.set(-t,-t,-t),B.max.set(t,t,t)}rl._initialize(e,h,_,n,i,a)},rl._setSphereData=function(e,t,r,n,i,a){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=rl._generateIndices(e.engine,s,6*l),u=Math.PI,d=2*u,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*d,y=g*u,x=Math.sin(y),S=-t*Math.cos(v)*x,C=t*Math.cos(y),T=t*Math.sin(v)*x,A=8*p;f[A++]=S,f[A++]=C,f[A++]=T,f[A++]=S,f[A++]=C,f[A++]=T,f[A++]=m,f[A++]=g}for(var E=0,M=0;M<l;++M){var R=M%r,w=(M*_|0)*o+R,b=w+1,P=w+o,F=P+1;c[E++]=b,c[E++]=w,c[E++]=F,c[E++]=w,c[E++]=P,c[E++]=F}if(!i){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}rl._initialize(e,f,c,n,i,a)},rl._subdiveCatmullClark=function(e,t,r){var n=new Map,i=[];t.set(rl._sphereSeedPositions),r.set(rl._sphereSeedCells);for(var a=0;a<e;a++){var o=6*Math.pow(4,a),s=4*o+2;n.clear(),i.length=0;for(var l=0;l<o;l++){for(var c=i[l]={facePoint:new l9,adjacentEdges:[,,,,]},u=0;u<4;u++){var d=3*r[4*l+u];c.facePoint.x+=.25*t[d],c.facePoint.y+=.25*t[d+1],c.facePoint.z+=.25*t[d+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 l9,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,S=c.facePoint;x.x+=.25*S.x,x.y+=.25*S.y,x.z+=.25*S.z}}var C=o+2,T=C+o,A=0;this._sphereEdgeIdx=0;for(var E=r.slice(0,4*o),M=0;M<o;M++){var R=i[M];R.facePoint.copyToArray(t,3*(C+M));for(var w=C+M,b=void 0,P=void 0,F=void 0,L=0;L<4;L++){var D=E[A++];switch(L){case 0:var B=R.adjacentEdges[L%4],I=R.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,B,T),F=b=this._calculateEdgeIndex(t,I,T);break;case 1:case 2:var V=R.adjacentEdges[L%4];b=P,P=this._calculateEdgeIndex(t,V,T);break;case 3:b=P,P=F}var O=4*(4*M+L);r[O]=D,r[O+1]=P,r[O+2]=w,r[O+3]=b}}}},rl._generateAndReplacePoleUV=function(e,t,r,n){var i=t[8*e[r]+7];if(0===i||1===i){var a=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(a,a+8),o),t[o+6]=.5*(t[a+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},rl._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+rl._sphereEdgeIdx));var n=r+rl._sphereEdgeIdx++;return t.edgePointIndex=n,n},rl._setCuboidData=function(e,t,r,n,i,a,o){var s=t/2,l=r/2,c=n/2,u=new Float32Array(192);u[0]=-s,u[1]=l,u[2]=-c,u[6]=0,u[7]=0,u[8]=s,u[9]=l,u[10]=-c,u[14]=1,u[15]=0,u[16]=s,u[17]=l,u[18]=c,u[22]=1,u[23]=1,u[24]=-s,u[25]=l,u[26]=c,u[30]=0,u[31]=1;for(var d=0;d<4;d++){var h=8*d+3;u[h++]=0,u[h++]=1,u[h++]=0}u[32]=-s,u[33]=-l,u[34]=-c,u[38]=0,u[39]=1,u[40]=s,u[41]=-l,u[42]=-c,u[46]=1,u[47]=1,u[48]=s,u[49]=-l,u[50]=c,u[54]=1,u[55]=0,u[56]=-s,u[57]=-l,u[58]=c,u[62]=0,u[63]=0;for(var _=0;_<4;_++){var f=8*_+35;u[f++]=0,u[f++]=-1,u[f++]=0}u[64]=-s,u[65]=l,u[66]=-c,u[70]=0,u[71]=0,u[72]=-s,u[73]=l,u[74]=c,u[78]=1,u[79]=0,u[80]=-s,u[81]=-l,u[82]=c,u[86]=1,u[87]=1,u[88]=-s,u[89]=-l,u[90]=-c,u[94]=0,u[95]=1;for(var p=0;p<4;p++){var m=8*p+67;u[m++]=-1,u[m++]=0,u[m++]=0}u[96]=s,u[97]=l,u[98]=-c,u[102]=1,u[103]=0,u[104]=s,u[105]=l,u[106]=c,u[110]=0,u[111]=0,u[112]=s,u[113]=-l,u[114]=c,u[118]=0,u[119]=1,u[120]=s,u[121]=-l,u[122]=-c,u[126]=1,u[127]=1;for(var g=0;g<4;g++){var v=8*g+99;u[v++]=1,u[v++]=0,u[v++]=0}u[128]=-s,u[129]=l,u[130]=c,u[134]=0,u[135]=0,u[136]=s,u[137]=l,u[138]=c,u[142]=1,u[143]=0,u[144]=s,u[145]=-l,u[146]=c,u[150]=1,u[151]=1,u[152]=-s,u[153]=-l,u[154]=c,u[158]=0,u[159]=1;for(var y=0;y<4;y++){var x=8*y+131;u[x++]=0,u[x++]=0,u[x++]=1}u[160]=-s,u[161]=l,u[162]=-c,u[166]=1,u[167]=0,u[168]=s,u[169]=l,u[170]=-c,u[174]=0,u[175]=0,u[176]=s,u[177]=-l,u[178]=-c,u[182]=0,u[183]=1,u[184]=-s,u[185]=-l,u[186]=-c,u[190]=1,u[191]=1;for(var S=0;S<4;S++){var C=8*S+163;u[C++]=0,u[C++]=0,u[C++]=-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,!a){var A=e.bounds;A.min.set(-s,-l,-c),A.max.set(s,l,c)}rl._initialize(e,u,T,i,a,o)},rl._setPlaneData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(i=Math.max(1,Math.floor(i)))+1,u=t/2,d=r/2,h=t/n,_=r/i,f=l*c,p=i*n,m=rl._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/i,x=new Float32Array(8*f),S=0;S<f;++S){var C=S%l,T=S*g|0,A=8*S;x[A++]=C*h-u,x[A++]=0,x[A++]=T*_-d,x[A++]=0,x[A++]=1,x[A++]=0,x[A++]=C*v,x[A++]=T*y}for(var E=0,M=0;M<p;++M){var R=M%n,w=(M*v|0)*l+R,b=w+1,P=w+l,F=P+1;m[E++]=w,m[E++]=P,m[E++]=b,m[E++]=P,m[E++]=F,m[E++]=b}if(!o){var L=e.bounds;L.min.set(-u,0,-d),L.max.set(u,0,d)}rl._initialize(e,x,m,a,o,s)},rl._setCylinderData=function(e,t,r,n,i,a,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===i&&(i=20),void 0===a&&(a=1);for(var c=(i=Math.floor(i))+1,u=(a=Math.floor(a))+1,d=.5*n,h=n/a,_=c*u,f=i*a,p=2*i,m=_+2+p,g=rl._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/i,x=1/a,S=new Float32Array(8*m),C=0,T=Math.PI,A=2*Math.PI,E=r-t,M=E/n,R=E/a,w=0;w<_;++w){var b=w%c,P=w*v|0,F=b*y,L=P*x,D=T+F*A,B=Math.sin(D),I=Math.cos(D),V=r-P*R,O=V*B,N=P*h-d,z=V*I,U=8*w;S[U++]=O,S[U++]=N,S[U++]=z,S[U++]=B,S[U++]=M,S[U++]=I,S[U++]=F,S[U++]=1-L}for(var k=0;k<f;++k){var G=k%i,H=(k*y|0)*c+G,W=H+1,X=H+c,K=X+1;g[C++]=W,g[C++]=X,g[C++]=H,g[C++]=W,g[C++]=K,g[C++]=X}var j=8*_;S[j++]=0,S[j++]=-d,S[j++]=0,S[j++]=0,S[j++]=-1,S[j++]=0,S[j++]=.5,S[j++]=.5,S[j++]=0,S[j++]=d,S[j++]=0,S[j++]=0,S[j++]=1,S[j++]=0,S[j++]=.5,S[j++]=.5,j=(_+2)*8;for(var Y=1/(2*t),q=1/(2*r),Q=c*a,Z=0;Z<i;++Z){var J=8*Z,$=S[J],ee=S[J+2];S[j++]=$,S[j++]=-d,S[j++]=ee,S[j++]=0,S[j++]=-1,S[j++]=0,S[j++]=$*q+.5,S[j++]=.5-ee*q;var et=(Z+Q)*8;$=S[et],ee=S[et+2],S[j++]=$,S[j++]=d,S[j++]=ee,S[j++]=0,S[j++]=1,S[j++]=0,S[j++]=$*Y+.5,S[j++]=.5-ee*Y}for(var er=_+1,en=_+2,ei=en+1,ea=0;ea<i;++ea){var eo=2*ea,es=ea===i-1?0:eo+2;g[C++]=_,g[C++]=en+es,g[C++]=en+eo,g[C++]=er,g[C++]=ei+eo,g[C++]=ei+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-d,-ec),el.max.set(ec,d,ec)}rl._initialize(e,S,g,o,s,l)},rl._setTorusData=function(e,t,r,n,i,a,o,s,l){var c=((n=Math.floor(n))+1)*((i=Math.floor(i))+1),u=n*i,d=rl._generateIndices(e.engine,c,6*u),h=new Float32Array(8*c);a=a/180*Math.PI;for(var _=0,f=rl._tempVec30,p=0;p<=n;p++)for(var m=0;m<=i;m++){var g=m/i*a,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),S=Math.sin(g),C=(t+r*y)*x,T=(t+r*y)*S,A=r*Math.sin(v);h[_++]=C,h[_++]=T,h[_++]=A;var E=t*x,M=t*S;f.set(C-E,T-M,A).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/i,h[_++]=p/n}_=0;for(var R=1;R<=n;R++)for(var w=1;w<=i;w++){var b=(i+1)*R+w-1,P=(i+1)*(R-1)+w-1,F=(i+1)*(R-1)+w,L=(i+1)*R+w;d[_++]=b,d[_++]=P,d[_++]=L,d[_++]=P,d[_++]=F,d[_++]=L}if(!s){var D=e.bounds,B=t+r;D.min.set(-B,-B,-r),D.max.set(B,B,r)}rl._initialize(e,h,d,o,s,l)},rl._setConeData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.floor(n))+1,c=(i=Math.floor(i))+1,u=.5*r,d=r/i,h=l*c,_=n*i,f=h+1+n,p=rl._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/i,y=new Float32Array(8*f),x=0,S=Math.PI,C=2*Math.PI,T=t/r,A=0;A<h;++A){var E=A%l,M=A*m|0,R=E*g,w=M*v,b=S+R*C,P=Math.sin(b),F=Math.cos(b),L=t-w*t,D=L*P,B=M*d-u,I=L*F,V=8*A;y[V++]=D,y[V++]=B,y[V++]=I,y[V++]=P,y[V++]=T,y[V++]=F,y[V++]=R,y[V++]=1-w}for(var O=0;O<_;++O){var N=O%n,z=(O*g|0)*l+N,U=z+1,k=z+l,G=k+1;p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=U,p[x++]=G,p[x++]=k}var H=8*h;y[H++]=0,y[H++]=-u,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),X=0;X<n;++X){var K=y[8*X],j=y[8*X+2];y[H++]=K,y[H++]=-u,y[H++]=j,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=K*W+.5,y[H++]=.5-j*W}for(var Y=h+1,q=0;q<n;++q){var Q=q,Z=q===n-1?0:Q+1;p[x++]=h,p[x++]=Y+Z,p[x++]=Y+Q}if(!o){var J=e.bounds;J.min.set(-t,-u,-t),J.max.set(t,u,t)}rl._initialize(e,y,p,a,o,s)},rl._setCapsuleData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(i=Math.floor(i))+1,u=.5*r,d=r/i,h=l*c,_=n*i,f=l*l,p=n*n,m=h+2*f,g=rl._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/i,S=Math.PI,C=2*Math.PI,T=new Float32Array(8*m),A=0,E=0;E<h;++E){var M=E%l,R=E*v|0,w=M*y,b=R*x,P=S+w*C,F=Math.sin(P),L=Math.cos(P),D=8*E;T[D++]=t*F,T[D++]=R*d-u,T[D++]=t*L,T[D++]=F,T[D++]=0,T[D++]=L,T[D++]=w,T[D++]=1-b}for(var B=0;B<_;++B){var I=B%n,V=(B*y|0)*l+I,O=V+1,N=V+l,z=N+1;g[A++]=O,g[A++]=N,g[A++]=V,g[A++]=O,g[A++]=z,g[A++]=N}if(rl._createCapsuleCap(t,r,n,S,C,h,1,T,g,A),rl._createCapsuleCap(t,r,n,S,-C,h+f,-1,T,g,A+6*p),!o){var U=e.bounds;U.min.set(-t,-t-u,-t),U.max.set(t,t+u,t)}rl._initialize(e,T,g,a,o,s)},rl._initialize=function(t,r,n,i,a,o){if(a)o.setData(r),t.setIndices(n),t.uploadData(i);else{var s=[new ub(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new ub(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new ub(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new uP(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(i),t.addSubMesh(0,n.length)}},rl._generateIndices=function(t,r,n){var i=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))i=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else i=new Uint16Array(n);return i},rl._createCapsuleCap=function(e,t,r,n,i,a,o,s,l,c){for(var u=r+1,d=.5*t*o,h=u*u,_=r*r,f=1/u,p=1/r,m=0;m<h;++m){var g=m%u*p,v=(m*f|0)*p,y=n+g*i,x=v*Math.PI*.5,S=Math.sin(x),C=e*Math.sin(y)*S,T=e*Math.cos(x)*o+d,A=e*Math.cos(y)*S,E=(m+a)*8;s[E++]=C,s[E++]=T,s[E++]=A,s[E++]=C,s[E++]=T-d,s[E++]=A,s[E++]=g,s[E++]=v}for(var M=0;M<_;++M){var R=M%r,w=(M*p|0)*u+R+a,b=w+1,P=w+u,F=P+1;l[c++]=b,l[c++]=w,l[c++]=F,l[c++]=w,l[c++]=P,l[c++]=F}},rl);u$._tempVec30=new l9,u$._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]),u$._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]),u$._sphereEdgeIdx=0,u$._spherePoleIdx=0;var u0=(cy(rc=function(e){var t;return(t=cb.call(this,null)||this).name=e,t._bones=[],t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},cb),rc),u1=(cy(ru=function(e){(t=uz.call(this,e)||this)._localBounds=new ct,t._jointDataCreateCache=new cc(-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(cp(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},uz),(rd=ru.prototype).update=function(){var e=this._skin,t=this._bones;if(e&&t)for(var r,n=this._jointMatrices,i=e.inverseBindMatrices,a=(null!=(r=this._rootBone)?r:this.entity).getInvModelMatrix(),o=t.length-1;o>=0;o--){var s=t[o],l=16*o;s?c1._floatMatrixMultiply(s.transform.worldMatrix,i[o].elements,0,n,l):n.set(i[o].elements,l),c1._floatMatrixMultiply(a,n,l,n,l)}},rd._updateShaderData=function(t){var r=this.entity,n=(null!=(d=this._rootBone)?d:r).transform.worldMatrix;this._updateTransformShaderData(t,n);var i=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(i,this);var o=this._bones;if(o){var s=a._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h,_=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>_){var f,p=this.engine;p._hardwareRenderer.canIUseMoreJoints?(u&&(null==(f=this._jointTexture)||f.destroy(),this._jointTexture=new ck(p,4,l,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(ru._jointSamplerProperty,this._jointTexture)):cN.error("component's joints count("+l+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+_+".",this)}else null==(h=this._jointTexture)||h.destroy(),i.disableMacro("RENDERER_USE_JOINT_TEXTURE"),i.enableMacro("RENDERER_JOINTS_NUM",_.toString()),i.setFloatArray(ru._jointMatrixProperty,this._jointMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var m=r.layer;this._rendererLayer.set(65535&m,m>>>16&65535,0,0)},rd._onDestroy=function(){var e;uz.prototype._onDestroy.call(this),this._rootBone=null,this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,this._jointMatrices=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null,this._bones=null},rd._cloneTo=function(e,t,r){uz.prototype._cloneTo.call(this,e,t,r);var n=[];if(this.rootBone){var i=this._getEntityHierarchyPath(t,this.rootBone,n);e.rootBone=i?this._getEntityByHierarchyPath(r,n):this.rootBone}var a=this._bones;if(a){for(var o=a.length,s=Array(o),l=0;l<o;l++){var c=a[l],u=this._getEntityHierarchyPath(t,c,n);s[l]=u?this._getEntityByHierarchyPath(r,n):c}e.bones=s}this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},rd._registerEntityTransformListener=function(){var e;(null!=(e=this._rootBone)?e:this._entity).transform._updateFlagManager.addListener(this._onTransformChanged)},rd._unRegisterEntityTransformListener=function(){var e;(null!=(e=this._rootBone)?e:this._entity).transform._updateFlagManager.removeListener(this._onTransformChanged)},rd._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,r=this._rootBone.transform.worldMatrix;ct.transform(t,r,e)}else uz.prototype._updateBounds.call(this,e)},rd._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var i=new Float32Array(t);if(t>n)i.set(r);else for(var a=0;a<t;a++)i[a]=r[a];this._blendShapeWeights=i}}else this._blendShapeWeights=new Float32Array(t)},rd._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=lT.WorldVolume},rd._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},rd._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},cg(ru,[{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._rootBone},set:function(e){this._rootBone!==e&&(this._unRegisterEntityTransformListener(),this._rootBone=e,this._registerEntityTransformListener(),this._dirtyUpdateFlag|=lT.WorldVolume)}},{key:"bones",get:function(){return this._bones},set:function(e){if(this._bones!==e){var t,r,n,i=null!=(r=null==(t=this._bones)?void 0:t.length)?r:0,a=null!=(n=null==e?void 0:e.length)?n:0;if(i!==a){var o=this.shaderData;a>0?(this._jointMatrices=new Float32Array(16*a),o.enableMacro("RENDERER_HAS_SKIN"),o.setInt(ru._jointCountProperty,a)):(this._jointMatrices=null,o.disableMacro("RENDERER_HAS_SKIN"))}this._bones=e}}},{key:"skin",get:function(){return this._skin},set:function(e){this._skin=e}}]),ru);u1._jointCountProperty=cq.getByName("renderer_JointCount"),u1._jointSamplerProperty=cq.getByName("renderer_JointSampler"),u1._jointMatrixProperty=cq.getByName("renderer_JointMatrix"),cC([cR],u1.prototype,"_localBounds",void 0),cC([cA],u1.prototype,"_jointDataCreateCache",void 0),cC([cA],u1.prototype,"_blendShapeWeights",void 0),cC([cA],u1.prototype,"_maxVertexUniformVectors",void 0),cC([cA],u1.prototype,"_rootBone",void 0),cC([cA],u1.prototype,"_jointMatrices",void 0),cC([cA],u1.prototype,"_jointTexture",void 0),cC([cA],u1.prototype,"_bones",void 0),cC([cA],u1.prototype,"_condensedBlendShapeWeights",void 0),cC([cA],u1.prototype,"_onLocalBoundsChanged",null);var u2=((r_=(rh=function(e){this._subMeshPool=new ue(uL),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,i=t.engine._renderElementPool,a=0,o=n.length;a<o;++a){var s=i.getFromPool();s.set(n[a],e.shaderPasses),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},r_._initMeshes=function(e){var t=rh.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var r=this._meshes,n=this._meshCount,i=0;i<n;i++)r[i]=this._createMesh(e,i)},r_.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rh._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},r_.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},r_.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,i=e.length;n<i;++n){var a=e[n];a._addReferCount(-1),a.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},r_._drawSubElement=function(e,t){var r=e.data.verticesData.vertexCount;this._vertexCount+r>rh.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=e},r_._createMesh=function(t,r){var n=rh.MAX_VERTEX_COUNT,i=new uN(t,"BufferMesh"+r);i._addReferCount(1);var a=[],o=this.createVertexElements(a),s=this._vertexBuffers[r]=new uP(t,e.BufferBindFlag.VertexBuffer,n*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[r]=new uP(t,e.BufferBindFlag.IndexBuffer,6*n,e.BufferUsage.Dynamic);return l.isGCIgnored=!0,i.setVertexBufferBinding(s,o),i.setIndexBufferBinding(l,e.IndexFormat.UInt16),i.setVertexElements(a),i},r_._updateData=function(t){var r=this._meshes,n=this._flushId;!rh._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,r[n]=this._createMesh(t,n));var i=this._batchedQueue,a=this._vertices,o=this._indices,s=r[n];s.clearSubMesh();for(var l=0,c=0,u=0,d=0,h=0,_=0,f=null,p=0,m=i.length;p<m;p++){var g=i[p],v=g.data;l=this.updateVertices(v,a,l);for(var y=v.verticesData.triangles,x=y.length,S=0;S<x;S++)o[c++]=y[S]+h;h+=v.verticesData.vertexCount,null===f?d+=x:this.canBatch(f,g)?d+=x:(s.addSubMesh(this._getSubMeshFromPool(u,d)),u+=d,d=x,i[_++]=f),f=g}s.addSubMesh(this._getSubMeshFromPool(u,d)),i[_]=f,this._vertexBuffers[n].setData(a,0,0,l,e.SetDataOptions.Discard),this._indiceBuffers[n].setData(o,0,0,c,e.SetDataOptions.Discard)},r_._getSubMeshFromPool=function(t,r){var n=this._subMeshPool.getFromPool();return n.start=t,n.count=r,n.topology=e.MeshTopology.Triangles,n},rh);u2._disableBatchTag=uo.getByName("spriteDisableBatching"),u2.MAX_VERTEX_COUNT=4096,u2._canUploadSameBuffer=!0;var u3=(cy(rf=function(){return u2.apply(this,arguments)},u2),(rp=rf.prototype).createVertexElements=function(t){return t[0]=new ub("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ub("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},rp.canBatch=function(e,t){var r=e.data,n=t.data;if(r.isAdd!==n.isAdd)return!1;var i=r.component.shaderData,a=n.component.shaderData,o=uR._textureProperty,s=uR._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},rp.updateVertices=function(e,t,r){for(var n=e.verticesData,i=n.positions,a=n.uvs,o=n.vertexCount,s=0;s<o;s++){var l=i[s],c=a[s];t[r++]=l.x,t[r++]=l.y,t[r++]=l.z,t[r++]=c.x,t[r++]=c.y}return r},rp.drawBatches=function(t){for(var r=this._engine,n=this._batchedQueue,i=this._meshes[this._flushId],a=i.subMeshes,o=i._primitive,s=t.scene.shaderData,l=t.shaderData,c=0,u=a.length;c<u;c++){var d=a[c],h=n[c],_=h.data;if(!d||!h)return;var f=_.component,p=_.material,m=uy._compileMacros;ur.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,d,x)}},rf),u4=((rg=(rm=function(e){this._preMaskLayer=0,this._batcher=new u3(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rg.preRender=function(t,r){r.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,r),this._batcher.flush(t))},rg.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rg.destroy=function(){this._batcher.destroy(),this._batcher=null},rg._processMasksDiff=function(e,t){var r=this._preMaskLayer,n=t.maskLayer;if(r!==n)for(var i=e._renderPipeline._allSpriteMasks,a=r&n,o=n&~r,s=r&~n,l=i._elements,c=0,u=i.length;c<u;c++){var d=l[c],h=d.influenceLayers;if(!(h&a)){if(h&o){var _=d._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(h&s){var f=d._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},rm),u5=(cy(rv=function(){var e;return(e=uC.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},uC),(ry=rv.prototype).set=function(e,t,r){this.component=e,this.material=t,this.verticesData=r},ry.dispose=function(){this.component=this.material=this.verticesData=null},rv),u8=(cy(rx=function(){var e;return(e=uC.call(this)||this).multiRenderData=!1,e},uC),(rS=rx.prototype).set=function(e,t,r,n,i){void 0===i&&(i=0),this.component=e,this.material=t,this.verticesData=r,this.texture=n,this.dataIndex=i},rS.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rx),u6=(cy(rC=function(){var e;return(e=uC.call(this)||this).charsData=[],e.multiRenderData=!0,e},uC),rC.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},rC);e.AssetType=void 0,(rT=e.AssetType||(e.AssetType={})).Text="Text",rT.JSON="JSON",rT.Buffer="Buffer",rT.Texture2D="Texture2D",rT.TextureCube="TextureCube",rT.Material="Material",rT.Mesh="Mesh",rT.AnimationClip="AnimationClip",rT.AnimatorController="AnimatorController",rT.GLTF="GLTF",rT.KTX="KTX",rT.KTXCube="KTXCube",rT.KTX2="KTX2",rT.Sprite="Sprite",rT.SpriteAtlas="SpriteAtlas",rT.Env="Environment",rT.Scene="Scene",rT.HDR="HDR",rT.Font="Font",rT.SourceFont="SourceFont",rT.Project="project";var u7=((rE=(rA=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},rE.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},rE.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},rE.indexOf=function(e){return this._array.indexOf(e)},rE.getArray=function(){return this._array},rE.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},cg(rA,[{key:"length",get:function(){return this._array.length}}]),rA),u9=((rR=(rM=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new u7}).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 i=n.indexOf(t);i!==r&&(n.removeByIndex(i),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},rR.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)}},rR.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,i=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return i.then(function(e){if(r)for(var t=n._scenes.getArray(),i=0,a=t.length;i<a;i++)t[i].destroy();n.addScene(e)}),i},rR.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},rR._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},cg(rM,[{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)}}]),rM),de=((rb=(rw=function(e){var t=this;this._state="pending",this._progress=0,this._onProgressCallback=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(t._progress=e,t._onProgressCallback.forEach(function(t){return t(e)}))},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e){return this._progress&&e(this._progress),"pending"===this._state&&this._onProgressCallback.push(e),this},rb.then=function(e,t){var r=this;return new rw(function(n,i){r._promise.then(e,t).then(n).catch(i)})},rb.catch=function(e){var t=this;return new rw(function(r,n){t._promise.catch(e).then(r).catch(n)})},rb.finally=function(e){return this._promise.finally(e)},rb.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},rw.all=function(e){return new rw(function(t,r,n){var i=function(e,r){l++,s[e]=r,n(l/o),l===o&&t(s)},a=function(e,t){cT(e,Promise)||cT(e,rw)?e.then(function(e){i(t,e)},r):Promise.resolve().then(function(){i(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)a(e[c],c)})},cg(rw,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),rw);(rP=lL||(lL={})).Pending="pending",rP.Fulfilled="fulfilled",rP.Rejected="rejected",rP.Canceled="canceled";var dt=((rL=(rF=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,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 de.all(r)},rL.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},rL.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var i=r[n];cT(i,e)&&t.push(i)}return t},rL.getAssetPath=function(e){return this._assetPool[e]},rL.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()}):c1.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},rL.gc=function(){this._gc(!1),this.engine._pendingGC()},rL.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},rL._onSubAssetSuccess=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.resolve(t),delete this._subAssetPromiseCallbacks[e]},rL._onSubAssetFail=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.reject(t),delete this._subAssetPromiseCallbacks[e]},rL._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},rL._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},rL._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},rL._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},rL._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},rL._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},rL._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},rL._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},rL._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},rL._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)},rL._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},rL._assignDefaultOptions=function(e){var t,r,n,i,a;if(e.type=null!=(t=e.type)?t:rF._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!=(i=e.retryInterval)?i:this.retryInterval,e.url=null!=(a=e.url)?a:e.urls.join(","),e},rL._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),i=n.url,a=this._virtualPathMap[i]?this._virtualPathMap[i]:i,o=this._parseURL(a),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=this._assetUrlPool[s];if(u)return new de(function(e,t,n){n(1),e(r._getResolveResource(u,c))});var d=s;if(l)for(d+="?q="+c.shift();t=c.shift();)d+="["+t+"]";var h=this._loadingPromises,_=h[d];if(_)return new de(function(e,t,r){_.onProgress(function(e){r(e)}).then(function(t){e(t)}).catch(function(e){t(e)})});var f=rF._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 de(function(e,t){r._pushSubAssetPromiseCallback(d,e,t)});return h[d]=m,m.then(function(){delete h[d]},function(){return delete h[d]}),p.catch(function(e){r._onSubAssetFail(d,e)}),m}return p},rL._pushSubAssetPromiseCallback=function(e,t,r){this._subAssetPromiseCallbacks[e]={resolve:t,reject:r}},rL._gc=function(e){for(var t=c1.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++)(!t[r].isGCIgnored||e)&&t[r].destroy(e)},rL._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,i=t.length;n<i;n++)r=r[t[n]];return r},rL._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],i=void 0,a=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){i=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}a=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:a,queryPath:i}},rL._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===dn&&t.push(""),e.replace(da,function(e,r,n,i){var a=e;n?a=i.replace(di,"$1"):r&&(a=r.trim()),t.push(a)}),t},rL.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,i=this._objectPool[t];if(i)a=Promise.resolve(i);else{var a,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return cN.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,a=this.load({url:s,type:this._editorResourceConfig[t].type})}return a.then(function(e){return n?e.clone():e})},rL.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},rF._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,i=r.length;n<i;n++)this._extTypeMapping[r[n].toLowerCase()]=e},rF._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},rF);function dr(e,t,r){return void 0===r&&(r=!0),function(n){var i=new n(r);dt._addLoader(e,i,t)}}dt._loaders={},dt._extTypeMapping={};var dn=46,di=/\\(\\)?/g,da=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(rD=e.PointerPhase||(e.PointerPhase={}))[rD.Down=0]="Down",rD[rD.Move=1]="Move",rD[rD.Stationary=2]="Stationary",rD[rD.Up=3]="Up",rD[rD.Leave=4]="Leave";var ds=((rI=(rB=function(t){this.phase=e.PointerPhase.Leave,this.position=new cc,this.deltaPosition=new cc,this._events=[],this._upMap=[],this._downMap=[],this._upList=new c0,this._downList=new c0,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)},rI._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},rI._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},rI._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}},rB);e.PointerButton=void 0,(rV=e.PointerButton||(e.PointerButton={}))[rV.None=0]="None",rV[rV.Primary=1]="Primary",rV[rV.Secondary=2]="Secondary",rV[rV.Auxiliary=4]="Auxiliary",rV[rV.XButton1=8]="XButton1",rV[rV.XButton2=16]="XButton2",rV[rV.XButton3=32]="XButton3",rV[rV.XButton4=64]="XButton4",rV[rV.XButton5=128]="XButton5",rV[rV.XButton6=256]="XButton6",rV[rV.XButton7=512]="XButton7",rV[rV.XButton8=1024]="XButton8";var dl=[1,4,2,8,16,32,64,128,256,512,1024],dc={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},du=((rO=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?rO.platform=e.Platform.IPhone:/iPad/i.test(r)?rO.platform=e.Platform.IPad:/Android/i.test(r)?rO.platform=e.Platform.Android:/Macintosh/i.test(r)&&(rO.platform=e.Platform.Mac),rO.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"}}},cg(rO,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),rO);du.platform=e.Platform.Unknown,du.operatingSystem="",du._initialize(),e.Keys=void 0,(rN=e.Keys||(e.Keys={}))[rN.Backquote=0]="Backquote",rN[rN.Backslash=1]="Backslash",rN[rN.Backspace=2]="Backspace",rN[rN.BracketLeft=3]="BracketLeft",rN[rN.BracketRight=4]="BracketRight",rN[rN.Comma=5]="Comma",rN[rN.Digit0=6]="Digit0",rN[rN.Digit1=7]="Digit1",rN[rN.Digit2=8]="Digit2",rN[rN.Digit3=9]="Digit3",rN[rN.Digit4=10]="Digit4",rN[rN.Digit5=11]="Digit5",rN[rN.Digit6=12]="Digit6",rN[rN.Digit7=13]="Digit7",rN[rN.Digit8=14]="Digit8",rN[rN.Digit9=15]="Digit9",rN[rN.Equal=16]="Equal",rN[rN.IntlBackslash=17]="IntlBackslash",rN[rN.IntlRo=18]="IntlRo",rN[rN.IntlYen=19]="IntlYen",rN[rN.KeyA=20]="KeyA",rN[rN.KeyB=21]="KeyB",rN[rN.KeyC=22]="KeyC",rN[rN.KeyD=23]="KeyD",rN[rN.KeyE=24]="KeyE",rN[rN.KeyF=25]="KeyF",rN[rN.KeyG=26]="KeyG",rN[rN.KeyH=27]="KeyH",rN[rN.KeyI=28]="KeyI",rN[rN.KeyJ=29]="KeyJ",rN[rN.KeyK=30]="KeyK",rN[rN.KeyL=31]="KeyL",rN[rN.KeyM=32]="KeyM",rN[rN.KeyN=33]="KeyN",rN[rN.KeyO=34]="KeyO",rN[rN.KeyP=35]="KeyP",rN[rN.KeyQ=36]="KeyQ",rN[rN.KeyR=37]="KeyR",rN[rN.KeyS=38]="KeyS",rN[rN.KeyT=39]="KeyT",rN[rN.KeyU=40]="KeyU",rN[rN.KeyV=41]="KeyV",rN[rN.KeyW=42]="KeyW",rN[rN.KeyX=43]="KeyX",rN[rN.KeyY=44]="KeyY",rN[rN.KeyZ=45]="KeyZ",rN[rN.Minus=46]="Minus",rN[rN.Period=47]="Period",rN[rN.Quote=48]="Quote",rN[rN.Semicolon=49]="Semicolon",rN[rN.Slash=50]="Slash",rN[rN.AltLeft=51]="AltLeft",rN[rN.AltRight=52]="AltRight",rN[rN.CapsLock=53]="CapsLock",rN[rN.ContextMenu=54]="ContextMenu",rN[rN.ControlLeft=55]="ControlLeft",rN[rN.ControlRight=56]="ControlRight",rN[rN.Enter=57]="Enter",rN[rN.MetaLeft=58]="MetaLeft",rN[rN.MetaRight=59]="MetaRight",rN[rN.ShiftLeft=60]="ShiftLeft",rN[rN.ShiftRight=61]="ShiftRight",rN[rN.Space=62]="Space",rN[rN.Tab=63]="Tab",rN[rN.Convert=64]="Convert",rN[rN.KanaMode=65]="KanaMode",rN[rN.Lang1=66]="Lang1",rN[rN.Lang2=67]="Lang2",rN[rN.Lang3=68]="Lang3",rN[rN.Lang4=69]="Lang4",rN[rN.Lang5=70]="Lang5",rN[rN.NonConvert=71]="NonConvert",rN[rN.Delete=72]="Delete",rN[rN.End=73]="End",rN[rN.Help=74]="Help",rN[rN.Home=75]="Home",rN[rN.Insert=76]="Insert",rN[rN.PageDown=77]="PageDown",rN[rN.PageUp=78]="PageUp",rN[rN.ArrowDown=79]="ArrowDown",rN[rN.ArrowLeft=80]="ArrowLeft",rN[rN.ArrowRight=81]="ArrowRight",rN[rN.ArrowUp=82]="ArrowUp",rN[rN.NumLock=83]="NumLock",rN[rN.Numpad0=84]="Numpad0",rN[rN.Numpad1=85]="Numpad1",rN[rN.Numpad2=86]="Numpad2",rN[rN.Numpad3=87]="Numpad3",rN[rN.Numpad4=88]="Numpad4",rN[rN.Numpad5=89]="Numpad5",rN[rN.Numpad6=90]="Numpad6",rN[rN.Numpad7=91]="Numpad7",rN[rN.Numpad8=92]="Numpad8",rN[rN.Numpad9=93]="Numpad9",rN[rN.NumpadAdd=94]="NumpadAdd",rN[rN.NumpadBackspace=95]="NumpadBackspace",rN[rN.NumpadClear=96]="NumpadClear",rN[rN.NumpadClearEntry=97]="NumpadClearEntry",rN[rN.NumpadComma=98]="NumpadComma",rN[rN.NumpadDecimal=99]="NumpadDecimal",rN[rN.NumpadDivide=100]="NumpadDivide",rN[rN.NumpadEnter=101]="NumpadEnter",rN[rN.NumpadEqual=102]="NumpadEqual",rN[rN.NumpadHash=103]="NumpadHash",rN[rN.NumpadMemoryAdd=104]="NumpadMemoryAdd",rN[rN.NumpadMemoryClear=105]="NumpadMemoryClear",rN[rN.NumpadMemoryRecall=106]="NumpadMemoryRecall",rN[rN.NumpadMemoryStore=107]="NumpadMemoryStore",rN[rN.NumpadMemorySubtract=108]="NumpadMemorySubtract",rN[rN.NumpadMultiply=109]="NumpadMultiply",rN[rN.NumpadParenLeft=110]="NumpadParenLeft",rN[rN.NumpadParenRight=111]="NumpadParenRight",rN[rN.NumpadStar=112]="NumpadStar",rN[rN.NumpadSubtract=113]="NumpadSubtract",rN[rN.Escape=114]="Escape",rN[rN.F1=115]="F1",rN[rN.F2=116]="F2",rN[rN.F3=117]="F3",rN[rN.F4=118]="F4",rN[rN.F5=119]="F5",rN[rN.F6=120]="F6",rN[rN.F7=121]="F7",rN[rN.F8=122]="F8",rN[rN.F9=123]="F9",rN[rN.F10=124]="F10",rN[rN.F11=125]="F11",rN[rN.F12=126]="F12",rN[rN.F13=127]="F13",rN[rN.F14=128]="F14",rN[rN.F15=129]="F15",rN[rN.Fn=130]="Fn",rN[rN.FnLock=131]="FnLock",rN[rN.PrintScreen=132]="PrintScreen",rN[rN.ScrollLock=133]="ScrollLock",rN[rN.Pause=134]="Pause",rN[rN.BrowserBack=135]="BrowserBack",rN[rN.BrowserFavorites=136]="BrowserFavorites",rN[rN.BrowserForward=137]="BrowserForward",rN[rN.BrowserHome=138]="BrowserHome",rN[rN.BrowserRefresh=139]="BrowserRefresh",rN[rN.BrowserSearch=140]="BrowserSearch",rN[rN.BrowserStop=141]="BrowserStop",rN[rN.Eject=142]="Eject",rN[rN.LaunchApp1=143]="LaunchApp1",rN[rN.LaunchApp2=144]="LaunchApp2",rN[rN.LaunchMail=145]="LaunchMail",rN[rN.MediaPlayPause=146]="MediaPlayPause",rN[rN.MediaSelect=147]="MediaSelect",rN[rN.MediaStop=148]="MediaStop",rN[rN.MediaTrackNext=149]="MediaTrackNext",rN[rN.MediaTrackPrevious=150]="MediaTrackPrevious",rN[rN.Power=151]="Power",rN[rN.Sleep=152]="Sleep",rN[rN.AudioVolumeDown=153]="AudioVolumeDown",rN[rN.AudioVolumeMute=154]="AudioVolumeMute",rN[rN.AudioVolumeUp=155]="AudioVolumeUp",rN[rN.WakeUp=156]="WakeUp",rN[rN.Hyper=157]="Hyper",rN[rN.Super=158]="Super",rN[rN.Turbo=159]="Turbo",rN[rN.Abort=160]="Abort",rN[rN.Resume=161]="Resume",rN[rN.Suspend=162]="Suspend",rN[rN.Again=163]="Again",rN[rN.Copy=164]="Copy",rN[rN.Cut=165]="Cut",rN[rN.Find=166]="Find",rN[rN.Open=167]="Open",rN[rN.Paste=168]="Paste",rN[rN.Props=169]="Props",rN[rN.Select=170]="Select",rN[rN.Undo=171]="Undo",rN[rN.Hiragana=172]="Hiragana",rN[rN.Katakana=173]="Katakana",rN[rN.Unidentified=174]="Unidentified";var dd=((rU=(rz=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new c0,this._curFrameDownList=new c0,this._curFrameUpList=new c0,this._nativeEvents=[],this._hadListener=!1;var t=e._canvas._webCanvas;this._engine=e,this._htmlCanvas=t,t.tabIndex=t.tabIndex,this._onKeyEvent=this._onKeyEvent.bind(this),t.addEventListener("keydown",this._onKeyEvent),t.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0}).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 i=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,u=t.length;c<u;c++){var d=t[c],h=e.Keys[d.code];switch(d.type){case"keydown":null==a[h]&&(r.add(h),o.add(h),a[h]=o.length-1,s[h]=i);break;case"keyup":var _=a[h];if(null!=_){a[h]=null;var f=o.deleteByIndex(_);f&&(a[f]=_)}if(n.add(h),l[h]=i,du.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)a[o.get(p)]=null;o.length=0}}}t.length=0}},rU._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},rU._onBlur=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0,this._hadListener=!1)},rU._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),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._htmlCanvas=null,this._engine=null},rU._onKeyEvent=function(e){this._nativeEvents.push(e)},rz);e.CameraClearFlags=void 0,(rk=e.CameraClearFlags||(e.CameraClearFlags={}))[rk.None=0]="None",rk[rk.Color=1]="Color",rk[rk.Depth=2]="Depth",rk[rk.Stencil=4]="Stencil",rk[rk.ColorDepth=3]="ColorDepth",rk[rk.ColorStencil=5]="ColorStencil",rk[rk.DepthStencil=6]="DepthStencil",rk[rk.All=7]="All",e.Collider=(cy(rG=function(e){var t;return(t=cZ.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},cZ),(rH=rG.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))},rH.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))},rH.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},rH._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}},rH._onLateUpdate=function(){},rH._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])},rH._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])},rH._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},rH._onDestroy=function(){cZ.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},rH._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},cg(rG,[{key:"shapes",get:function(){return this._shapes}}]),rG),cC([cA],e.Collider.prototype,"_index",void 0),cC([cA],e.Collider.prototype,"_nativeCollider",void 0),cC([cA],e.Collider.prototype,"_updateFlag",void 0),cC([cR],e.Collider.prototype,"_shapes",void 0),e.Collider=cC([c$(c6,e.DependentMode.CheckOnly)],e.Collider);var dh=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new c0,this._gravity=new l9(0,-9.81,0),this._onContactEnter=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},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,i){var a,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(a=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(a=n),i&&(a=i);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var i=o._scene.engine._physicalObjectsMap[e];a.entity=i._collider.entity,a.shape=i,a.distance=t,a.normal.copyFrom(n),a.point.copyFrom(r)})||(a.entity=null,a.shape=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,i=this._restTime+e,a=Math.floor(i/t);this._restTime=i-a*t;for(var o=0;o<a;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)},cg(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,l7.zeroTolerance)}}]),t}();dh._collision=new function(){},e.ControllerNonWalkableMode=void 0,(rW=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[rW.PreventClimbing=0]="PreventClimbing",rW[rW.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var d_=(rX=e.Collider,cy(rK=function(t){var r;return(r=rX.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new l9(0,1,0),r._slopeLimit=.707,r._nativeCollider=dh._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(cp(r)),r._upDirection._onValueChanged=r._setUpDirection,r},rX),(rj=rK.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},rj.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";rX.prototype.addShape.call(this,e),this._updateFlag.flag=!0},rj.clearShapes=function(){this._shapes.length>0&&rX.prototype.removeShape.call(this,this._shapes[0])},rj._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,i=t.length;n<i;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},rj._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},rj._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])},rj._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])},rj._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},cg(rK,[{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))}}]),rK),df=(rY=e.Collider,cy(rq=function(e){(t=rY.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new l9,t._angularVelocity=new l9,t._mass=1,t._centerOfMass=new l9,t._inertiaTensor=new l9(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=dh._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(cp(t)),t._setAngularVelocity=t._setAngularVelocity.bind(cp(t)),t._setCenterOfMass=t._setCenterOfMass.bind(cp(t)),t._setInertiaTensor=t._setInertiaTensor.bind(cp(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},rY),(rQ=rq.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},rQ.applyTorque=function(e){this._nativeCollider.addTorque(e)},rQ.move=function(e,t){this._nativeCollider.move(e,t)},rQ.sleep=function(){this._nativeCollider.sleep()},rQ.wakeUp=function(){this._nativeCollider.wakeUp()},rQ._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},rQ._cloneTo=function(e){rY.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},rQ._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},rQ._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},rQ._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},rQ._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},cg(rq,[{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))}}]),rq);cC([cA],df.prototype,"_linearDamping",void 0),cC([cA],df.prototype,"_angularDamping",void 0),cC([cA],df.prototype,"_linearVelocity",void 0),cC([cA],df.prototype,"_angularVelocity",void 0),cC([cA],df.prototype,"_mass",void 0),cC([cA],df.prototype,"_centerOfMass",void 0),cC([cA],df.prototype,"_inertiaTensor",void 0),cC([cA],df.prototype,"_maxAngularVelocity",void 0),cC([cA],df.prototype,"_maxDepenetrationVelocity",void 0),cC([cA],df.prototype,"_solverIterations",void 0),cC([cA],df.prototype,"_isKinematic",void 0),cC([cA],df.prototype,"_constraints",void 0),cC([cA],df.prototype,"_collisionDetectionMode",void 0),cC([cA],df.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(rZ=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[rZ.Discrete=0]="Discrete",rZ[rZ.Continuous=1]="Continuous",rZ[rZ.ContinuousDynamic=2]="ContinuousDynamic",rZ[rZ.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(rJ=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[rJ.None=0]="None",rJ[rJ.FreezePositionX=1]="FreezePositionX",rJ[rJ.FreezePositionY=2]="FreezePositionY",rJ[rJ.FreezePositionZ=4]="FreezePositionZ",rJ[rJ.FreezeRotationX=8]="FreezeRotationX",rJ[rJ.FreezeRotationY=16]="FreezeRotationY",rJ[rJ.FreezeRotationZ=32]="FreezeRotationZ";var dp=function(){this.entity=null,this.distance=0,this.point=new l9,this.normal=new l9,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(r$=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[r$.Average=0]="Average",r$[r$.Minimum=1]="Minimum",r$[r$.Multiply=2]="Multiply",r$[r$.Maximum=3]="Maximum";var dm=((r0=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=dh._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},cg(r0,[{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))}}]),r0),dg=(r1=e.Collider,cy(r2=function(e){var t,r=(t=r1.call(this,e)||this).entity.transform;return t._nativeCollider=dh._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},r1),r2);e.ColliderShapeUpAxis=void 0,(r3=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[r3.X=0]="X",r3[r3.Y=1]="Y",r3[r3.Z=2]="Z",e.ControllerCollisionFlag=void 0,(r4=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[r4.Sides=1]="Sides",r4[r4.Up=2]="Up",r4[r4.Down=4]="Down",e.Joint=(cy(r5=function(e){var t;return(t=cZ.call(this,e)||this)._colliderInfo=new dv,t._connectedColliderInfo=new dv,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new l9,t},cZ),r5.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},cg(r5,[{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))}}]),r5),cC([cA],e.Joint.prototype,"_colliderInfo",void 0),cC([cA],e.Joint.prototype,"_connectedColliderInfo",void 0),cC([cA],e.Joint.prototype,"_nativeJoint",void 0),cC([cA],e.Joint.prototype,"_force",void 0),cC([cA],e.Joint.prototype,"_torque",void 0),e.Joint=cC([c$(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var dv=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},dy=(r8=e.Joint,cy(r6=function(){return r8.apply(this,arguments)},r8),r6.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=dh._nativePhysics.createFixedJoint(t.collider._nativeCollider)},r6);(r7=lD||(lD={}))[r7.None=0]="None",r7[r7.LimitEnabled=1]="LimitEnabled",r7[r7.DriveEnabled=2]="DriveEnabled",r7[r7.DriveFreeSpin=4]="DriveFreeSpin";var dx=(r9=e.Joint,cy(ne=function(){var e;return e=r9.apply(this,arguments)||this,e._axis=new l9(1,0,0),e._hingeFlags=lD.None,e._useSpring=!1,e},r9),(nt=ne.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new l9,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=dh._nativePhysics.createHingeJoint(t.collider._nativeCollider)},nt._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},cg(ne,[{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&lD.LimitEnabled)==lD.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=lD.LimitEnabled:this._hingeFlags&=~lD.LimitEnabled,this._nativeJoint.setHingeJointFlag(lD.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&lD.DriveEnabled)==lD.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=lD.DriveEnabled:this._hingeFlags&=~lD.DriveEnabled,this._nativeJoint.setHingeJointFlag(lD.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(lD.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))}}]),ne);cC([cA],dx.prototype,"_axis",void 0),cC([cA],dx.prototype,"_hingeFlags",void 0),cC([cA],dx.prototype,"_useSpring",void 0),cC([cA],dx.prototype,"_jointMonitor",void 0),cC([cA],dx.prototype,"_limits",void 0);var dS=(nr=e.Joint,cy(nn=function(){var e;return e=nr.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},nr),(ni=nn.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new l9,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=dh._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},cg(nn,[{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))}}]),nn),dC=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},dT=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},dA=function(){function e(){this._isTrigger=!1,this._rotation=new l9,this._position=new l9,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new dm,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)},cg(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}();dA._idGenerator=0,cC([cA],dA.prototype,"_collider",void 0),cC([cA],dA.prototype,"_nativeShape",void 0),cC([cA],dA.prototype,"_id",void 0),cC([cA],dA.prototype,"_material",void 0),cC([cA],dA.prototype,"_isTrigger",void 0),cC([cA],dA.prototype,"_rotation",void 0),cC([cA],dA.prototype,"_position",void 0),cC([cA],dA.prototype,"_contactOffset",void 0);var dE=(cy(na=function(){var e;return(e=dA.call(this)||this)._size=new l9(1,1,1),e._nativeShape=dh._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(cp(e)),e._size._onValueChanged=e._setSize,e},dA),(no=na.prototype)._cloneTo=function(e){dA.prototype._cloneTo.call(this,e),e.size=this.size},no._setSize=function(){this._nativeShape.setSize(this._size)},cg(na,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),na);cC([cA],dE.prototype,"_size",void 0);var dM=(cy(ns=function(){var e;return(e=dA.call(this)||this)._radius=1,e._nativeShape=dh._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},dA),ns.prototype._cloneTo=function(e){dA.prototype._cloneTo.call(this,e),e.radius=this.radius},cg(ns,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),ns);cC([cA],dM.prototype,"_radius",void 0);var dR=(cy(nl=function(){var e;return(e=dA.call(this)||this)._nativeShape=dh._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},dA),nl),dw=(cy(nc=function(){var t;return(t=dA.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=dh._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},dA),nc.prototype._cloneTo=function(e){dA.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},cg(nc,[{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))}}]),nc);cC([cA],dw.prototype,"_radius",void 0),cC([cA],dw.prototype,"_height",void 0),cC([cA],dw.prototype,"_upAxis",void 0);var db=((nd=(nu=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new c0,this._downList=new c0,this._nativeEvents=[],this._hadListener=!1;var r=t._canvas._webCanvas;this._engine=t,this._canvas=t.canvas,this._htmlCanvas=r,this._onPointerEvent=this._onPointerEvent.bind(this),this._onFocus(),this._pointerPool=Array(11)}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,i=this._canvas,a=i.width,o=i.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),u=c.left,d=c.top,h=a/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 S,C=this._pointerPool,T=0;T<x&&!(t[T].id>T);T++);(y=C[S=T]||(C[S]=new ds(T)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-u)*h,(g.clientY-d)*_),t.splice(T,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var A=this._engine.time.frameCount,E=0,M=t.length;E<M;E++){var R=t[E];R._upList.length=R._downList.length=0,this._updatePointerInfo(A,R,u,d,h,_),this._buttons|=R.pressedButtons}},nd._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,i=0,a=r.length;i<a;i++){var o=r[i],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 u=s.length;if(u>0){for(var d=0;d<u;d++)switch(s[d].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}}},nd._onFocus=function(){if(!this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t),this._hadListener=!0}},nd._onBlur=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1,this._pointers.length=0,this._downList.length=0,this._upList.length=0,this._nativeEvents.length=0}},nd._destroy=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1}this._pointerPool.length=0,this._pointerPool=null,this._pointers.length=0,this._pointers=null,this._downList.length=0,this._downList=null,this._upList.length=0,this._upList=null,this._nativeEvents.length=0,this._nativeEvents=null,this._upMap.length=0,this._upMap=null,this._downMap.length=0,this._downMap=null,this._htmlCanvas=null,this._canvas=null,this._engine=null},nd._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},nd._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},nd._updatePointerInfo=function(t,r,n,i,a,o){var s=r._events,l=r.position,c=s.length;if(c>0){var u=this._upList,d=this._upMap,h=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-n)*a,m=(f.clientY-i)*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=dl[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":u.add(y),d[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},nd._pointerRayCast=function(t,r,n){for(var i=nu._tempPoint,a=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._activeCameras,u=c.length-1;u>=0;u--){var d=c[u];if(d.enabled&&!d.renderTarget){var h=d.viewport,_=h.x,f=h.y,p=h.z,m=h.w;if(r>=_&&n>=f&&r-_<=p&&n-f<=m){if(i.set((r-_)/p,(n-f)/m),l.physics.raycast(d.viewportPointToRay(i,a),Number.MAX_VALUE,d.cullingMask,o))return o.entity;if(d.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},nu);db._tempRay=new cl,db._tempPoint=new cc,db._tempHitResult=new dp;var dP=((n_=(nh=function(e){this._delta=new l9,this._nativeEvents=[];var t=e._canvas._webCanvas;this._onWheelEvent=this._onWheelEvent.bind(this),t.addEventListener("wheel",this._onWheelEvent),this._canvas=t,this._hadListener=!0}).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}},n_._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},n_._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},n_._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null,this._canvas=null,this._delta=null},n_._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},nh),dF=((np=(nf=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&cT(t,OffscreenCanvas)||(this._wheelManager=new dP(e),this._pointerManager=new db(e),this._keyboardManager=new dd(e),this._onBlur=this._onBlur.bind(this),window.addEventListener("blur",this._onBlur),this._onFocus=this._onFocus.bind(this),window.addEventListener("focus",this._onFocus),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},np.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},np.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},np.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},np.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[dc[e]]===this._engine.time.frameCount)},np.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[dc[e]]===this._engine.time.frameCount)},np._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},np._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},np._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},np._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},np._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},cg(nf,[{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}}]),nf),dL=(cy(nm=function(e,t){var r;return(r=cP.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new ux(lC.Material),r.shader=t,r},cP),(ng=nm.prototype).clone=function(){var e=new nm(this._engine,this.shader);return this.cloneTo(e),e},ng.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),cw.deepCloneObject(this.renderStates,e.renderStates)},ng._addReferCount=function(e){this._destroyed||(cP.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e))},ng._onDestroy=function(){cP.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},cg(nm,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){this._shader=e;for(var t=this._renderStates,r=t.length,n=0,i=e.subShaders,a=0;a<i.length;a++)n=Math.max(i[a].passes.length,n);if(r<n)for(var o=r;o<n;o++)t.push(new uv);else t.length=n}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),nm);(lB||(lB={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(nv=lI||(lI={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",nv.DirectionTime="a_DirectionTime",nv.StartColor="a_StartColor",nv.StartSize="a_StartSize",nv.StartRotation0="a_StartRotation0",nv.StartSpeed="a_StartSpeed",nv.Random0="a_Random0",nv.Random1="a_Random1",nv.SimulationWorldPosition="a_SimulationWorldPosition",nv.SimulationWorldRotation="a_SimulationWorldRotation",nv.SimulationUV="a_SimulationUV";var dD=((ny=function(t){this.billboardVertexElement=new ub(lB.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new ub(lI.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new ub(lI.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new ub(lI.StartColor,32,e.VertexElementFormat.Vector4,1,1),new ub(lI.StartSize,48,e.VertexElementFormat.Vector3,1,1),new ub(lI.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new ub(lI.StartSpeed,72,e.VertexElementFormat.Float,1,1),new ub(lI.Random0,76,e.VertexElementFormat.Vector4,1,1),new ub(lI.Random1,92,e.VertexElementFormat.Vector4,1,1),new ub(lI.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new ub(lI.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new ub(lI.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=new uP(t,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);this.billboardVertexBufferBinding=new uI(r,16);var n=new uP(t,e.BufferBindFlag.IndexBuffer,this.billboardIndexCount,e.BufferUsage.Static,!1);this.billboardIndexBufferBinding=new uF(n,e.IndexFormat.UInt8),this.setBufferData()}).prototype.setBufferData=function(){this.billboardVertexBufferBinding.buffer.setData(new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0])),this.billboardIndexBufferBinding.buffer.setData(new Uint8Array([0,2,3,0,1,2]))},ny),dB="#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}",dI=((nx=function(){}).init=function(){var t=new ud("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 ud("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],i={pipelineStage:e.PipelineStage.Forward};uy.create("blinn-phong",[].concat(new ud("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}",i),n)),uy.create("pbr",[].concat(new ud("Forward",dB,"#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}",i),n)),uy.create("pbr-specular",[].concat(new ud("Forward",dB,"#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}",i),n)),uy.create("unlit",[].concat(new ud("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}",i),n)),uy.create("skybox",[new ud("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}",i)]),uy.create("SkyProcedural",[new ud("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}",i)]),uy.create("particle-shader",[new ud("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}",i)]),uy.create("SpriteMask",[new ud("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;}",i)]),uy.create("Sprite",[new ud("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;}",i)]),uy.create("background-texture",[new ud("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);}",i)])},nx),dV=((nC=(nS=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 i=e._mask,a=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=a<s?0:i[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=a<o?0:i[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},nC.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},nC._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var i in e){for(var a=e[i],o=e,s=0;s<n;s++)o[0==s?i:0]=o=Object.create(null);o[0]=a}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},nS);e.TextHorizontalAlignment=void 0,(nT=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[nT.Left=0]="Left",nT[nT.Center=1]="Center",nT[nT.Right=2]="Right",e.TextVerticalAlignment=void 0,(nA=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[nA.Top=0]="Top",nA[nA.Center=1]="Center",nA[nA.Bottom=2]="Bottom";var dO=(cy(nE=function(e){var t;return(t=cP.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},cP),(nM=nE.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},nM.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 i=n[r];i.name===e&&t.push(i)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},nM._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},nM._onDestroy=function(){cP.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},cg(nE,[{key:"sprites",get:function(){return this._sprites}}]),nE);e.SpriteDrawMode=void 0,(nR=e.SpriteDrawMode||(e.SpriteDrawMode={}))[nR.Simple=0]="Simple",nR[nR.Sliced=1]="Sliced",nR[nR.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(nw=e.SpriteTileMode||(e.SpriteTileMode={}))[nw.Continuous=0]="Continuous",nw[nw.Adaptive=1]="Adaptive";var dN=(cy(nb=function(e,t,r,n,i,a){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null),(o=cP.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new cc,new cc,new cc,new cc],o._uvs=[new cc,new cc,new cc,new cc],o._bounds=new ct,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new ch(0,0,1,1),o._atlasRegionOffset=new cu(0,0,0,0),o._region=new ch(0,0,1,1),o._pivot=new cc(.5,.5),o._border=new cu(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new c8,o._texture=t,o._onRegionChange=o._onRegionChange.bind(cp(o)),o._onPivotChange=o._onPivotChange.bind(cp(o)),o._onBorderChange=o._onBorderChange.bind(cp(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),i&&o._border.copyFrom(i),o.name=a,o},cP),(nP=nb.prototype).clone=function(){var e=new nb(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},nP._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},nP._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},nP._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},nP._addReferCount=function(e){var t;cP.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},nP._onDestroy=function(){this._dispatchSpriteChange(lA.destroy),cP.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},nP._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,i=1/dX._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*i,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*i}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},nP._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,i=t.width,a=t.height,o=Math.max(e.x-r,0)/i,s=Math.max(e.w-n,0)/a,l=1-Math.max(e.z-(1-r-i),0)/i,c=1-Math.max(e.y-(1-n-a),0)/a,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var d=this._bounds,h=d.min,_=d.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},nP._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,i=r.y,a=r.width,o=r.height,s=1-n-a,l=1-i-o,c=this._atlasRegion,u=c.x,d=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+u,S=Math.max(l-p,0)*y+d,C=h+u-Math.max(s-m,0)*v,T=_+d-Math.max(i-g,0)*y,A=this._border,E=A.x,M=A.y,R=A.z,w=A.w;e[0].set(x,T),e[1].set((n-f+E*a)*v+u,_+d-(i-g+M*o)*y),e[2].set(h+u-(s-m+R*a)*v,(l-p+w*o)*y+d),e[3].set(C,S),this._dirtyUpdateFlag&=-3},nP._dispatchSpriteChange=function(e){switch(e){case lA.texture:this._dirtyUpdateFlag|=4;break;case lA.atlasRegionOffset:case lA.region:this._dirtyUpdateFlag|=7;break;case lA.atlasRegion:this._dirtyUpdateFlag|=6;break;case lA.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},nP._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=l7.clamp(e.x,0,1),r=l7.clamp(e.y,0,1);e.set(t,r,l7.clamp(e.width,0,1-t),l7.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lA.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lA.size),e._onValueChanged=this._onRegionChange},nP._onPivotChange=function(){this._dispatchSpriteChange(lA.pivot)},nP._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=l7.clamp(e.x,0,1),r=l7.clamp(e.y,0,1);e.set(t,r,l7.clamp(e.z,0,1-t),l7.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lA.border),e._onValueChanged=this._onBorderChange},cg(nb,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(lA.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lA.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(lA.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(lA.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=l7.clamp(e.x,0,1),r=l7.clamp(e.y,0,1);this._atlasRegion.set(t,r,l7.clamp(e.width,0,1-t),l7.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lA.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lA.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=l7.clamp(e.x,0,1),r=l7.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,l7.clamp(e.z,0,1-t),l7.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lA.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lA.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)}}]),nb);(nF=lV||(lV={}))[nF.positions=1]="positions",nF[nF.uvs=2]="uvs",nF[nF.automaticSize=4]="automaticSize",nF[nF.all=7]="all";var dz=((nL=function(){}).resetData=function(e){var t,r,n=e._verticesData,i=n.positions,a=n.uvs;n.vertexCount=i.length=a.length=16;for(var o=0;o<16;o++)i[t=o]||(i[t]=new l9),a[r=o]||(a[r]=new cc);n.triangles=dz._rectangleTriangles},nL.updatePositions=function(e){var t,r,n=e.width,i=e.height,a=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=a.border,u=a._getUVs(),d=a._getPositions(),h=d[0],_=h.x,f=h.y,p=d[3],m=p.x,g=p.y,v=a.width,y=a.height,x=v*c.x,S=y*c.y,C=v*c.z,T=y*c.w;if(x+C>n){var A=n/(x+C);t=[v*_*A,x*A,x*A,n-v*(1-m)*A]}else t=[v*_,x,n-C,n-v*(1-m)];if(T+S>i){var E=i/(T+S);r=[y*f*E,S*E,S*E,i-y*(1-g)*E]}else r=[y*f,S,i-T,i-y*(1-g)];var M=e.sprite.pivot,R=M.x,w=M.y,b=e.width*R,P=e.height*w,F=dz._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]-b*L[0]-P*L[4],L[13]=D[13]-b*L[1]-P*L[5],L[14]=D[14]-b*L[2]-P*L[6];for(var V=0;V<4;V++)for(var O=t[V],N=u[V].x,z=0;z<4;z++){var U=r[z],k=4*V+z;s[k].set(L[0]*O+L[4]*U+L[12],L[1]*O+L[5]*U+L[13],L[2]*O+L[6]*U+L[14]),l[k].set(N,u[z].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)},nL.updateUVs=function(e){},nL._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],nL._worldMatrix=new cs,nL);dz=cC([uA()],dz);var dU=((nD=function(){}).resetData=function(e){e._verticesData.triangles=[]},nD.updatePositions=function(t){var r,n,i,a,o,s,l=t.width,c=t.height,u=t.sprite,d=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,d===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(u,l,c,h,g,v,y,x):this._calculateContinuousDividing(u,l,c,g,v,y,x);var S=t.sprite.pivot,C=S.x,T=S.y,A=t.width*C,E=t.height*T,M=dU._worldMatrix,R=M.elements,w=t.entity.transform.worldMatrix.elements,b=t.flipX?-1:1,P=t.flipY?-1:1;r=R[0]=w[0]*b,n=R[1]=w[1]*b,i=R[2]=w[2]*b,a=R[4]=w[4]*P,o=R[5]=w[5]*P,s=R[6]=w[6]*P,R[8]=w[8],R[9]=w[9],R[10]=w[10];for(var F=R[12]=w[12]-A*R[0]-E*R[4],L=R[13]=w[13]-A*R[1]-E*R[5],D=R[14]=w[14]-A*R[2]-E*R[6],B=g.length-1,I=v.length-1,V=0,O=0,N=0;N<I;N++)for(var z=2*N,U=0;U<B;U++){var k=y.get(2*U),G=x.get(z),H=y.get(2*U+1),W=x.get(z+1);if(!(isNaN(k)||isNaN(k)||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 X=g.get(U),K=v.get(N),j=g.get(U+1),Y=v.get(N+1);p[V]?p[V].set(k,G):p[V]=new cc(k,G);var q=f[V];q?q.set(r*X+a*K+F,n*X+o*K+L,i*X+s*K+D):f[V]=new l9(r*X+a*K+F,n*X+o*K+L,i*X+s*K+D),p[++V]?p[V].set(H,G):p[V]=new cc(H,G),(q=f[V])?q.set(r*j+a*K+F,n*j+o*K+L,i*j+s*K+D):f[V]=new l9(r*j+a*K+F,n*j+o*K+L,i*j+s*K+D),p[++V]?p[V].set(k,W):p[V]=new cc(k,W),(q=f[V])?q.set(r*X+a*Y+F,n*X+o*Y+L,i*X+s*Y+D):f[V]=new l9(r*X+a*Y+F,n*X+o*Y+L,i*X+s*Y+D),p[++V]?p[V].set(H,W):p[V]=new cc(H,W),(q=f[V])?q.set(r*j+a*Y+F,n*j+o*Y+L,i*j+s*Y+D):f[V]=new l9(r*j+a*Y+F,n*j+o*Y+L,i*j+s*Y+D),V++}}t._verticesData.vertexCount=V,m.length=O;var Q=t._bounds,Z=Q.min,J=Q.max;Z.set(g.get(0),v.get(0),0),J.set(g.get(B),v.get(I),0),t._bounds.transform(M)},nD.updateUVs=function(e){},nD._calculateAdaptiveDividing=function(e,t,r,n,i,a,o,s){var l,c,u,d,h,_,f,p=e.border,m=e._getPositions(),g=m[0],v=g.x,y=g.y,x=m[3],S=x.x,C=x.y,T=e._getUVs(),A=T[0],E=T[1],M=T[2],R=T[3],w=e.width,b=e.height,P=w*p.x,F=w*p.z,L=P+F,D=w-L,B=b*p.w,I=b*p.y,V=B+I,O=b-V;if(L>=t?(d=3,c=0):D>l7.zeroTolerance?(d=4+(_=(_=(t-L)/D)%1>=n?Math.ceil(_):Math.floor(_))-1,c=2):(d=4,c=1),V>=r?(h=3,u=0):O>l7.zeroTolerance?(h=4+(f=(f=(r-V)/O)%1>=n?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),(d-1)*(h-1)*4>u2.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*S),a.add(r*y),a.add(r*C),o.add(A.x),o.add(R.x),s.add(A.y),s.add(R.y),cN.warn("The number of vertices exceeds the upper limit("+u2.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,i.add(w*v*l),i.add(P*l),i.add(t-w*(1-S)*l),o.add(A.x),o.add(E.x),o.add(M.x),o.add(R.x);break;case 1:i.add(w*v),i.add(P),i.add(t-F),i.add(t-w*(1-S)),o.add(A.x),o.add(E.x),o.add(NaN),o.add(NaN),o.add(M.x),o.add(R.x);break;case 2:l=t/(L+_*D),i.add(w*v*l),i.add(P*l),o.add(A.x),o.add(E.x),o.add(E.x);for(var N=0,z=_-1;N<z;N++)i.add(P+(N+1)*D*l),o.add(M.x),o.add(E.x);i.add(t-F*l),i.add(t-w*(1-S)*l),o.add(M.x),o.add(M.x),o.add(R.x)}switch(u){case 0:l=r/V,a.add(b*y*l),a.add(I*l),a.add(r-b*(1-C)*l),s.add(A.y),s.add(E.y),s.add(M.y),s.add(R.y);break;case 1:a.add(b*y),a.add(I),a.add(r-B),a.add(r-b*(1-C)),s.add(A.y),s.add(E.y),s.add(NaN),s.add(NaN),s.add(M.y),s.add(R.y);break;case 2:l=r/(V+f*O),a.add(b*y*l),a.add(I*l),s.add(A.y),s.add(E.y),s.add(E.y);for(var U=0,k=f-1;U<k;U++)a.add(I+(U+1)*O*l),s.add(M.y),s.add(E.y);a.add(r-B*l),a.add(r-b*(1-C)*l),s.add(M.y),s.add(M.y),s.add(R.y)}},nD._calculateContinuousDividing=function(e,t,r,n,i,a,o){var s,l,c,u,d,h,_=e.border,f=e._getPositions(),p=f[0],m=p.x,g=p.y,v=f[3],y=v.x,x=v.y,S=e._getUVs(),C=S[0],T=S[1],A=S[2],E=S[3],M=e.width,R=e.height,w=M*_.x,b=M*_.z,P=w+b,F=M-P,L=R*_.w,D=R*_.y,B=L+D,I=R-B;if(P>=t?(c=3,s=0):F>l7.zeroTolerance?(c=4+(0|(d=(t-P)/F)),s=2):(c=4,s=1),B>=r?(u=3,l=0):I>l7.zeroTolerance?(u=4+(0|(h=(r-B)/I)),l=2):(u=4,l=1),(c-1)*(u-1)*4>u2.MAX_VERTEX_COUNT){n.add(t*m),n.add(t*y),i.add(r*g),i.add(r*x),a.add(C.x),a.add(E.x),o.add(C.y),o.add(E.y),cN.warn("The number of vertices exceeds the upper limit("+u2.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var V=t/P;n.add(M*m*V),n.add(w*V),n.add(t-M*(1-y)*V),a.add(C.x),a.add(T.x),a.add(A.x),a.add(E.x);break;case 1:n.add(M*m),n.add(w),n.add(t-b),n.add(t-M*(1-y)),a.add(C.x),a.add(T.x),a.add(NaN),a.add(NaN),a.add(A.x),a.add(E.x);break;case 2:n.add(M*m),n.add(w),a.add(C.x),a.add(T.x),a.add(T.x);for(var O=0|d,N=0;N<O;N++)n.add(w+(N+1)*F),a.add(A.x),a.add(T.x);n.add(t-b),n.add(t-M*(1-y)),a.add((A.x-T.x)*(d-O)+T.x),a.add(A.x),a.add(E.x)}switch(l){case 0:var z=r/B;i.add(R*g*z),i.add(D*z),i.add(r-R*(1-x)*z),o.add(C.y),o.add(T.y),o.add(A.y),o.add(E.y);break;case 1:i.add(R*g),i.add(D),i.add(r-L),i.add(r-R*(1-x)),o.add(C.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(E.y);break;case 2:i.add(R*g),i.add(D),o.add(C.y),o.add(T.y),o.add(T.y);for(var U=0|h,k=0;k<U;k++)i.add(D+(k+1)*I),o.add(A.y),o.add(T.y);i.add(r-L),i.add(r-R*(1-x)),o.add((A.y-T.y)*(h-U)+T.y),o.add(A.y),o.add(E.y)}},nD._worldMatrix=new cs,nD._posRow=new c0,nD._posColumn=new c0,nD._uvRow=new c0,nD._uvColumn=new c0,nD);dU=cC([uA()],dU),(nB=lO||(lO={}))[nB.Compressed=0]="Compressed",nB[nB.WithoutTiled=1]="WithoutTiled",nB[nB.WithTiled=2]="WithTiled";var dk=(nI=e.Renderer,cy(nV=function(t){var r;return(r=nI.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new cd(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 uM(4,[],[],null,r._color),r.drawMode=e.SpriteDrawMode.Simple,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(cp(r)),r},nI),(nO=nV.prototype)._cloneTo=function(e,t,r){nI.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},nO._updateShaderData=function(e){this._updateTransformShaderData(e,cs._identity)},nO._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},nO._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&lT.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~lT.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var n=this.sprite.texture,i=this._engine._spriteRenderDataPool.getFromPool();i.set(this,r,this._verticesData,n),e.camera._renderPipeline.pushRenderData(e,i)}}},nO._onDestroy=function(){nI.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},nO._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},nO._updateStencilState=function(t,r){var n=this.getMaterial(),i=this._engine._spriteDefaultMaterials;if(n===i[t])this.setMaterial(i[r]);else{var a=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(a.enabled=!1,a.writeMask=255,a.referenceValue=0,a.compareFunctionFront=a.compareFunctionBack=e.CompareFunction.Always):(a.enabled=!0,a.writeMask=0,a.referenceValue=1,a.compareFunctionFront=a.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},nO._onSpriteChange=function(t){switch(t){case lA.texture:this.shaderData.setTexture(nV._textureProperty,this.sprite.texture);break;case lA.size:var r=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=lT.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lT.WorldVolume);break;case lA.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case lA.region:case lA.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lA.atlasRegion:this._dirtyUpdateFlag|=2;break;case lA.pivot:this._dirtyUpdateFlag|=lT.WorldVolume;break;case lA.destroy:this.sprite=null}},cg(nV,[{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=uE;break;case e.SpriteDrawMode.Sliced:this._assembler=dz;break;case e.SpriteDrawMode.Tiled:this._assembler=dU}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=l7.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&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(nV._textureProperty,e.texture)):this.shaderData.setTexture(nV._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|=lT.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|=lT.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lT.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lT.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)}}]),nV);dk._textureProperty=cq.getByName("renderer_SpriteTexture"),cC([cA],dk.prototype,"_verticesData",void 0),cC([cA],dk.prototype,"_drawMode",void 0),cC([cE],dk.prototype,"_assembler",void 0),cC([cE],dk.prototype,"_tileMode",void 0),cC([cE],dk.prototype,"_tiledAdaptiveThreshold",void 0),cC([cR],dk.prototype,"_color",void 0),cC([cA],dk.prototype,"_sprite",void 0),cC([cA],dk.prototype,"_automaticWidth",void 0),cC([cA],dk.prototype,"_automaticHeight",void 0),cC([cE],dk.prototype,"_customWidth",void 0),cC([cE],dk.prototype,"_customHeight",void 0),cC([cE],dk.prototype,"_flipX",void 0),cC([cE],dk.prototype,"_flipY",void 0),cC([cE],dk.prototype,"_maskLayer",void 0),cC([cE],dk.prototype,"_maskInteraction",void 0),cC([cA],dk.prototype,"_onSpriteChange",null),(nN=lN||(lN={}))[nN.UV=2]="UV",nN[nN.RenderData=3]="RenderData",nN[nN.AutomaticSize=4]="AutomaticSize",nN[nN.All=7]="All";var dG=function e(){this.localPositions=new cu;var t=[new l9,new l9,new l9,new l9];this.renderData=new uM(4,t,null,e.triangles,null)};dG.triangles=[0,2,1,2,0,3];var dH=((nU=(nz=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},nU.put=function(e){this._elements.push(e)},nz),dW=(nk=e.Renderer,cy(nG=function(t){var r;return(r=nk.call(this,t)||this)._subFont=null,r._charRenderDatas=[],r._dirtyFlag=15,r._color=new cd(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new ct,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},nk),(nH=nG.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},nH._onDestroy=function(){nk.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,r=e.length;t<r;++t)nG._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},nH._cloneTo=function(e,t,r){nk.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},nH._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},nH._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},nH._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},nH._updateShaderData=function(e){this._updateTransformShaderData(e,cs._identity)},nH._updateBounds=function(e){ct.transform(this._localBounds,this._entity.transform.worldMatrix,e)},nH._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,i=this.getMaterial(),a=this._charRenderDatas,o=a.length;r.component=this,r.material=i,n.length=o;for(var s=0;s<o;++s){var l=a[s],c=t.getFromPool();c.set(this,i,l.renderData,l.texture,s),n[s]=c}e.camera._renderPipeline.pushRenderData(e,r)}},nH._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}},nH._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=cX.getNativeFontString(e.name,this.fontSize,this.fontStyle)},nH._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,r=e[0],n=e[1],i=e[2],a=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=nG._tempVec31.set(a,o,s),h=nG._tempVec30.set(r,n,i),_=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*a+l,x.y=v*n+y*o+c,x.z=v*i+y*s+u;var S=g[1];l9.scale(h,m.z-v,S),l9.add(x,S,S);var C=g[2];l9.scale(d,m.w-y,C),l9.add(x,C,g[3]),l9.add(S,C,C)}},nH._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,i=this.color,a=this._charRenderDatas,o=this._subFont,s=this.enableWrapping?cX.measureTextWithWrap(this):cX.measureTextWithoutWrap(this),l=s.height,c=s.lines,u=s.lineWidths,d=s.lineHeight,h=s.lineMaxSizes,_=nG._charRenderDataPool,f=c.length,p=0;if(f>0){var m=dX._pixelsPerUnit,g=this.horizontalAlignment,v=1/m,y=.5*(this.width*m),x=this.height*m,S=.5*d,C=0,T=.5*d-h[0].ascent,A=.5*d-h[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:C=.5*x-S+T;break;case e.TextVerticalAlignment.Center:C=.5*l-S-(A-T)*.5;break;case e.TextVerticalAlignment.Bottom:C=l-.5*x-S-A}for(var E=-1,M=Number.MAX_SAFE_INTEGER,R=Number.MAX_SAFE_INTEGER,w=Number.MIN_SAFE_INTEGER,b=Number.MIN_SAFE_INTEGER,P=0;P<f;++P){var F=u[P];if(F>0){var L=c[P],D=0,B=-1;switch(E<0&&(E=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 z,U=a[z=p++]||(a[z]=_.get()),k=U.renderData,G=U.localPositions;U.texture=o._getTextureByIndex(N.index),k.color=i,k.uvs=N.uvs;var H=N.w,W=N.ascent,X=N.descent,K=D*v,j=(D+H)*v,Y=(C+W)*v,q=(C-X)*v;G.set(K,Y,j,q),P===E&&(b=Math.max(b,Y)),R=Math.min(R,q),I===B&&(M=Math.min(M,K)),w=Math.max(w,j)}D+=N.xAdvance}}C-=d}E<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(M,R,0),n.set(w,b,0))}else r.set(0,0,0),n.set(0,0,0);var Q=a.length;if(Q>p){for(var Z=p;Z<Q;++Z)_.put(a[Z]);a.length=p}o._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},nH._onTransformChanged=function(e){nk.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},nH._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},cg(nG,[{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&&t._addReferCount(-1),e&&e._addReferCount(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}}]),nG);dW._charRenderDataPool=new dH(dG,50),dW._tempVec30=new l9,dW._tempVec31=new l9,cC([cE],dW.prototype,"_subFont",void 0),cC([cA],dW.prototype,"_charRenderDatas",void 0),cC([cA],dW.prototype,"_dirtyFlag",void 0),cC([cR],dW.prototype,"_color",void 0),cC([cE],dW.prototype,"_text",void 0),cC([cE],dW.prototype,"_width",void 0),cC([cE],dW.prototype,"_height",void 0),cC([cA],dW.prototype,"_localBounds",void 0),cC([cE],dW.prototype,"_font",void 0),cC([cE],dW.prototype,"_fontSize",void 0),cC([cE],dW.prototype,"_fontStyle",void 0),cC([cE],dW.prototype,"_lineSpacing",void 0),cC([cE],dW.prototype,"_horizontalAlignment",void 0),cC([cE],dW.prototype,"_verticalAlignment",void 0),cC([cE],dW.prototype,"_enableWrapping",void 0),cC([cE],dW.prototype,"_overflowMode",void 0),cC([cE],dW.prototype,"_maskInteraction",void 0),cC([cE],dW.prototype,"_maskLayer",void 0),(nW=lz||(lz={}))[nW.SubFont=1]="SubFont",nW[nW.LocalPositionBounds=2]="LocalPositionBounds",nW[nW.WorldPosition=4]="WorldPosition",nW[nW.WorldBounds=8]="WorldBounds",nW[nW.MaskInteraction=16]="MaskInteraction",nW[nW.Position=14]="Position",nW[nW.Font=15]="Font",dI.init();var dX=function(t){function r(n,i,a){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new uv,o._renderElementPool=new ue(uT),o._renderDataPool=new ue(uC),o._spriteRenderDataPool=new ue(u8),o._spriteMaskRenderDataPool=new ue(u5),o._textRenderDataPool=new ue(u6),o._spriteDefaultMaterials=[],o._renderContext=new uS,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new ur,o._settings={},o._resourceManager=new dt(cp(o)),o._sceneManager=new u9(cp(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new cQ,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(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=i,o._hardwareRenderer.init(n,o._onDeviceLost.bind(cp(o)),o._onDeviceRestored.bind(cp(o))),o._canvas=n,o._spriteMaskManager=new u4(cp(o));var o,s=cp(o)._spriteDefaultMaterials;if(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=cj.createFromOS(cp(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new dF(cp(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var l=new ck(cp(o),1,1,e.TextureFormat.Depth16,!1);l.isGCIgnored=!0,o._depthTexture2D=l}else o._macroCollection.enable(r._noDepthTextureMacro);var c=new dL(cp(o),uy.find("unlit"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new cS(1,0,1.01,1)),o._meshMagentaMaterial=c;var u=new dL(cp(o),uy.find("particle-shader"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new cS(1,0,1.01,1)),o._particleMagentaMaterial=u;var d=o._settings,h=a.colorSpace||e.ColorSpace.Linear;return h===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),d.colorSpace=h,o._particleBufferUtils=new dD(cp(o)),o}cy(r,t);var n=r.prototype;return n.createEntity=function(e){return new c9(this,e)},n.pause=function(){this._isPaused=!0,cancelAnimationFrame(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){this._isPaused&&(this._isPaused=!1,this.time._reset(),this._requestId=requestAnimationFrame(this._animate))},n.update=function(){var e=this._time;e._update();var t=e.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._renderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool();var r=this.inputManager,n=this._physicsInitialized;r._update();for(var i=this._sceneManager._scenes.getLoopArray(),a=i.length,o=0;o<a;o++){var s=i[o];s.isActive&&!s.destroyed&&(s._cameraNeedSorting&&s._sortCameras(),s._componentsManager.callScriptOnStart())}if(n)for(var l=0;l<a;l++){var c=i[l];c.isActive&&!c.destroyed&&c.physics._update(t)}n&&r._firePointerScript(i);for(var u=0;u<a;u++){var d=i[u];d.isActive&&!d.destroyed&&d._componentsManager.callScriptOnUpdate(t)}for(var h=0;h<a;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callAnimationUpdate(t)}for(var f=0;f<a;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callScriptOnLateUpdate(t)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var m=0;m<a;m++){var g=i[m];g.isActive&&!g.destroyed&&g._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(){this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._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 i=t+1;i>r.length&&(r.length=i),r[t]=n=new dV}return n},n._render=function(e){for(var t=this.time.deltaTime,r=0,n=e.length;r<n;r++){var i=e[r];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(t),i._updateShaderData())}for(var a=0,o=e.length;a<o;a++){var s=e[a];if(s.isActive&&!s.destroyed){var l=s._activeCameras,c=l.length;if(c>0)for(var u=0;u<c;u++){var d=l[u],h=s._componentsManager;h.callCameraOnBeginRender(d),d.render(),h.callCameraOnEndRender(d),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else cN.debug("No active camera in scene.")}}},n._initMagentaTextures=function(t){var r=new Uint8Array([255,255,255,255]),n=new ck(this,1,1,e.TextureFormat.R8G8B8A8,!1);n.setPixelBuffer(r),n.isGCIgnored=!0;var i=new Uint8Array([255,0,255,255]),a=new ck(this,1,1,e.TextureFormat.R8G8B8A8,!1);a.setPixelBuffer(i),a.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cy(l=function(){return cF.call(this,a)},cF),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(i)},l));for(var o=new cH(this,1,e.TextureFormat.R8G8B8A8,!1),s=0;s<6;s++)o.setPixelBuffer(e.TextureCubeFace.PositiveX+s,i);if(o.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cy(c=function(){return cF.call(this,o)},cF),c.prototype.restoreContent=function(){for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,i)},c)),this._whiteTexture2D=n,this._magentaTexture2D=a,this._magentaTextureCube=o,t.isWebGL2){var l,c,u,d=new cG(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);d.setPixelBuffer(0,i),d.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cy(u=function(){return cF.call(this,d)},cF),u.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,i)},u)),this._magentaTexture2DArray=d}},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&(uy._shaderLab=r);var i=[];n&&i.push(n.initialize().then(function(){return dh._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var a=dt._loaders;for(var o in a){var s=a[o];s.initialize&&i.push(s.initialize(this,e))}return Promise.all(i).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new dL(this,uy.find("Sprite")),n=r.renderState,i=n.blendState.targetBlendState;if(i.enabled=!0,i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var a=n.stencilState;a.enabled=!0,a.writeMask=0,a.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;a.compareFunctionFront=o,a.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 dL(this,uy.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 uv,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),this._particleBufferUtils.setBufferData(),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()},cg(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}(cY);dX._gammaMacro=ut.getByName("ENGINE_IS_COLORSPACE_GAMMA"),dX._noDepthTextureMacro=ut.getByName("ENGINE_NO_DEPTH_TEXTURE"),dX._pixelsPerUnit=100;var dK=(cg(nX=function(){this._sizeUpdateFlagManager=new c8},[{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())}}]),nX);e.BackgroundMode=void 0,(nK=e.BackgroundMode||(e.BackgroundMode={}))[nK.SolidColor=0]="SolidColor",nK[nK.Sky=1]="Sky",nK[nK.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(nj=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[nj.AspectFitWidth=0]="AspectFitWidth",nj[nj.AspectFitHeight=1]="AspectFitHeight",nj[nj.Fill=2]="Fill";var dj=((nq=(nY=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},nq._render=function(e){var t=this.material,r=this.mesh;if(!t){cN.warn("The material of sky is not defined.");return}if(t.destroyed){cN.warn("The material of sky is destroyed.");return}if(!r){cN.warn("The mesh of sky is not defined.");return}if(r.destroyed){cN.warn("The mesh of sky is destroyed.");return}var n=e.camera,i=n.engine,a=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,u=a.shaderData,d=nY._viewProjMatrix,h=nY._projectionMatrix,_=i._hardwareRenderer,f=t.shaderData,p=t.shader,m=t.renderState;d.copyFrom(l);var g=d.elements;g[12]=g[13]=g[14]=0;var v=1/Math.tan(l7.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,cs.multiply(h,d,d);var y=c.getMatrix(uS.vpMatrixProperty);c.setMatrix(uS.vpMatrixProperty,d);var x=uy._compileMacros;ur.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var S=p.subShaders[0].passes[0],C=S._getShaderProgram(i,x);C.bind(),C.groupingOtherUniformBlock(),C.uploadAll(C.sceneUniformBlock,u),C.uploadAll(C.cameraUniformBlock,c),C.uploadAll(C.materialUniformBlock,f),C.uploadUnGroupTextures(),m._apply(i,!1,S._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,C),c.setMatrix(uS.vpMatrixProperty,y)},cg(nY,[{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}}}]),nY);dj._epsilon=1e-6,dj._viewProjMatrix=new cs,dj._projectionMatrix=new cs(1,0,0,0,0,1,0,0,0,0,dj._epsilon-1,-1,0,0,0,0);var dY=((nZ=(nQ=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new cd(.25,.25,.25,1),this.sky=new dj,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()},nZ._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,i=n.width,a=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*i/t.width/a;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*a/t.height/i;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)}},nZ._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},nZ._initMaterial=function(t){var r=this._material=new dL(t,uy.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},nZ._createPlane=function(e){var t=new uk(e);t.isGCIgnored=!0;for(var r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],i=[,,,,],a=0;a<4;++a)n[a]=new l9,i[a]=new cc(a%2,1-(.5*a|0));return t.setPositions(n),t.setUVs(i),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},cg(nQ,[{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())}}]),nQ),dq=((n$=(nJ=function(){this._renderers=new c0,this._onStartScripts=new c0,this._onUpdateScripts=new c0,this._onLateUpdateScripts=new c0,this._onPhysicsUpdateScripts=new c0,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new c0,this._onUpdateRenderers=new c0,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},n$.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},n$.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},n$.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},n$.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},n$.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},n$.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},n$.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},n$.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},n$.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},n$.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},n$.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},n$.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()})},n$.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},n$.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},n$.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},n$.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.engine.time.frameCount>t._playFrameCount&&t.update(e)},function(e,t){e._onUpdateIndex=t})},n$.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},n$.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}},n$.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},n$.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},n$.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},n$.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},n$._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},nJ);e.FogMode=void 0,(n0=e.FogMode||(e.FogMode={}))[n0.None=0]="None",n0[n0.Linear=1]="Linear",n0[n0.Exponential=2]="Exponential",n0[n0.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n1=e.DiffuseMode||(e.DiffuseMode={}))[n1.SolidColor=0]="SolidColor",n1[n1.SphericalHarmonics=1]="SphericalHarmonics";var dQ=(cy(n2=function(t){var r;return(r=cP.call(this,t)||this)._diffuseSolidColor=new cd(.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},cP),(n3=n2.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(n2._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(n2._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(n2._specularIntensityProperty,this._specularIntensity),t.setFloatArray(n2._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},n3._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(n2._specularTextureProperty,null),n.disableMacro(n2._specularMacro)},n3._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(n2._shMacro):t.disableMacro(n2._shMacro)},n3._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(n2._specularTextureProperty,this._specularTexture),e.setFloat(n2._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(n2._specularMacro)):e.disableMacro(n2._specularMacro)},n3._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(n2._decodeRGBMMacro):e.disableMacro(n2._decodeRGBMMacro)},n3._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]},cg(n2,[{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(n2._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(n2._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(n2._specularIntensityProperty,e)}}]),n2);dQ._shMacro=ut.getByName("SCENE_USE_SH"),dQ._specularMacro=ut.getByName("SCENE_USE_SPECULAR_ENV"),dQ._decodeRGBMMacro=ut.getByName("SCENE_IS_DECODE_ENV_RGBM"),dQ._diffuseColorProperty=cq.getByName("scene_EnvMapLight.diffuse"),dQ._diffuseSHProperty=cq.getByName("scene_EnvSH"),dQ._diffuseIntensityProperty=cq.getByName("scene_EnvMapLight.diffuseIntensity"),dQ._specularTextureProperty=cq.getByName("scene_EnvSpecularSampler"),dQ._specularIntensityProperty=cq.getByName("scene_EnvMapLight.specularIntensity"),dQ._mipLevelProperty=cq.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(n4=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[n4.NoCascades=1]="NoCascades",n4[n4.TwoCascades=2]="TwoCascades",n4[n4.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(n5=e.ShadowResolution||(e.ShadowResolution={}))[n5.Low=0]="Low",n5[n5.Medium=1]="Medium",n5[n5.High=2]="High",n5[n5.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(n8=e.ShadowType||(e.ShadowType={}))[n8.None=0]="None",n8[n8.Hard=1]="Hard",n8[n8.SoftLow=2]="SoftLow",n8[n8.SoftHigh=3]="SoftHigh";var dZ=(cy(n6=function(){var t;return t=cZ.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._color=new cd(1,1,1,1),t._lightColor=new cd,t},cZ),n6.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},cg(n6,[{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 cs),cs.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new cs),cs.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),n6);cC([cA],dZ.prototype,"_lightIndex",void 0);var dJ=(cy(n7=function(){var e;return e=dZ.apply(this,arguments)||this,e._reverseDirection=new l9,e},dZ),(n9=n7.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=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[i]=cd.gammaToLinearSpace(o.r),r.color[i+1]=cd.gammaToLinearSpace(o.g),r.color[i+2]=cd.gammaToLinearSpace(o.b)):(r.color[i]=o.r,r.color[i+1]=o.g,r.color[i+2]=o.b),r.direction[a]=s.x,r.direction[a+1]=s.y,r.direction[a+2]=s.z},n9._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},n9._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},n7._updateShaderData=function(e,t){e.setIntArray(n7._cullingMaskProperty,t.cullingMask),e.setFloatArray(n7._colorProperty,t.color),e.setFloatArray(n7._directionProperty,t.direction)},cg(n7,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return l9.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),n7);dJ._cullingMaskProperty=cq.getByName("scene_DirectLightCullingMask"),dJ._colorProperty=cq.getByName("scene_DirectLightColor"),dJ._directionProperty=cq.getByName("scene_DirectLightDirection");var d$=(cy(ie=function(){var e;return e=dZ.apply(this,arguments)||this,e.distance=100,e},dZ),(it=ie.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=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[i]=cd.gammaToLinearSpace(o.r),r.color[i+1]=cd.gammaToLinearSpace(o.g),r.color[i+2]=cd.gammaToLinearSpace(o.b)):(r.color[i]=o.r,r.color[i+1]=o.g,r.color[i+2]=o.b),r.position[a]=s.x,r.position[a+1]=s.y,r.position[a+2]=s.z,r.distance[t]=this.distance},it._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},it._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},ie._updateShaderData=function(e,t){e.setIntArray(ie._cullingMaskProperty,t.cullingMask),e.setFloatArray(ie._colorProperty,t.color),e.setFloatArray(ie._positionProperty,t.position),e.setFloatArray(ie._distanceProperty,t.distance)},cg(ie,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),ie);d$._cullingMaskProperty=cq.getByName("scene_PointLightCullingMask"),d$._colorProperty=cq.getByName("scene_PointLightColor"),d$._positionProperty=cq.getByName("scene_PointLightPosition"),d$._distanceProperty=cq.getByName("scene_PointLightDistance");var d0=(cy(ir=function(){var e;return e=dZ.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new l9,e._projectMatrix=new cs,e},dZ),(ii=ir.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,u=this.cullingMask;r.cullingMask[n]=65535&u,r.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[i]=cd.gammaToLinearSpace(s.r),r.color[i+1]=cd.gammaToLinearSpace(s.g),r.color[i+2]=cd.gammaToLinearSpace(s.b)):(r.color[i]=s.r,r.color[i+1]=s.g,r.color[i+2]=s.b),r.position[a]=l.x,r.position[a+1]=l.y,r.position[a+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)},ii._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},ii._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},ir._updateShaderData=function(e,t){e.setIntArray(ir._cullingMaskProperty,t.cullingMask),e.setFloatArray(ir._colorProperty,t.color),e.setFloatArray(ir._positionProperty,t.position),e.setFloatArray(ir._directionProperty,t.direction),e.setFloatArray(ir._distanceProperty,t.distance),e.setFloatArray(ir._angleCosProperty,t.angleCos),e.setFloatArray(ir._penumbraCosProperty,t.penumbraCos)},cg(ir,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return l9.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 cs.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),ir);d0._cullingMaskProperty=cq.getByName("scene_SpotLightCullingMask"),d0._colorProperty=cq.getByName("scene_SpotLightColor"),d0._positionProperty=cq.getByName("scene_SpotLightPosition"),d0._directionProperty=cq.getByName("scene_SpotLightDirection"),d0._distanceProperty=cq.getByName("scene_SpotLightDistance"),d0._angleCosProperty=cq.getByName("scene_SpotLightAngleCos"),d0._penumbraCosProperty=cq.getByName("scene_SpotLightPenumbraCos");var d1=function(){function t(){this._spotLights=new c0,this._pointLights=new c0,this._directLights=new c0,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._updateSunLightIndex=function(){var e=this._directLights,t=this._getSunLightIndex();if(t>0){var r=e.get(0),n=e.get(t);e.set(0,n),e.set(t,r),n._lightIndex=0,r._lightIndex=t}},r._updateShaderData=function(e){for(var t=this._spotLights,r=this._pointLights,n=this._directLights,i=this._spotData,a=this._pointData,o=this._directData,s=t.length,l=r.length,c=n.length,u=0;u<s;u++)t.get(u)._appendData(u,i);for(var d=0;d<l;d++)r.get(d)._appendData(d,a);for(var h=0;h<c;h++)n.get(h)._appendData(h,o);c?(dJ._updateShaderData(e,o),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),l?(d$._updateShaderData(e,a),e.enableMacro("SCENE_POINT_LIGHT_COUNT",l.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),s?(d0._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",s.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._getSunLightIndex=function(){for(var t=this._directLights,r=-1,n=Number.NEGATIVE_INFINITY,i=!1,a=0,o=t.length;a<o;a++){var s=t.get(a);s.shadowType===e.ShadowType.None||i||(n=Number.NEGATIVE_INFINITY,i=!0);var l=s.intensity*s.color.getBrightness();i?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=a):n<l&&(n=l,r=a)}return r},t}();d1._maxLight=10;var d2=function(t){function r(n,i){(a=t.call(this,n)||this).physics=new dh(cp(a)),a.castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new l9(1/15,.2,7/15),a.shadowDistance=50,a._cameraNeedSorting=!1,a._lightManager=new d1,a._componentsManager=new dq,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new ur,a._rootEntities=[],a._background=new dY(a._engine),a._shaderData=new ux(lC.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new cd(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new cu,a._isActive=!0,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new dQ(n),n.sceneManager._allCreatedScenes.push(cp(a)),o.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),o.setColor(r._fogColorProperty,a._fogColor),o.setVector4(r._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}cy(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new c9(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 i=t._scene;i!==this?(i&&n&&i._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var a=lx.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(a|=lx.Hierarchy)),t._isActiveInScene&&i!==this&&(a|=lx.Scene),a&&t._processInActive(a),i!==this&&c9._traverseSetOwnerScene(t,this);var o=lx.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=lx.Hierarchy)),t._isActiveInScene&&i===this||(o|=lx.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=lx.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=lx.Hierarchy),e._isActiveInScene&&(t|=lx.Scene),t&&e._processInActive(t),c9._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 i=t[r].findByName(e);if(i)return i}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var i=this.getRootEntity(r);if(i.name==t[0]){for(var a=1,o=t.length;a<o&&(i=c9._findChildByName(i,t[a]));++a);return i}}return null},n._sortCameras=function(){this._activeCameras.sort(function(e,t){return e.priority-t.priority}),this._cameraNeedSorting=!1},n._attachRenderCamera=function(e){var t=this._activeCameras;-1===t.indexOf(e)?(t.push(e),this._cameraNeedSorting=!0):cN.warn("Camera already attached.")},n._detachRenderCamera=function(e){var t=this._activeCameras,r=t.indexOf(e);-1!==r&&t.splice(r,1)},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(lx.Hierarchy):n._processInActive(lx.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,n=this._engine,i=this._lightManager;if(n.time._updateSceneShaderData(t),i._updateShaderData(this.shaderData),i._updateSunLightIndex(),i._directLights.length>0){var a=i._directLights.get(0);t.setColor(r._sunlightColorProperty,a._getLightIntensityColor()),t.setVector3(r._sunlightDirectionProperty,a.direction),this._sunLight=a}else this._sunLight=null;this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),ur.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._activeCameras.length=0,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 i=e+1,a=n+1;i<a;i++)r[i]._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)},cg(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){cN.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}}]),r}(cb);d2._fogColorProperty=cq.getByName("scene_FogColor"),d2._fogParamsProperty=cq.getByName("scene_FogParams"),d2._sunlightColorProperty=cq.getByName("scene_SunlightColor"),d2._sunlightDirectionProperty=cq.getByName("scene_SunlightDirection");var d3=(cy(ia=function(){var e;return e=cZ.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},cZ),(io=ia.prototype).onAwake=function(){},io.onEnable=function(){},io.onStart=function(){},io.onUpdate=function(e){},io.onLateUpdate=function(e){},io.onBeginRender=function(e){},io.onEndRender=function(e){},io.onPhysicsUpdate=function(){},io.onTriggerEnter=function(e){},io.onTriggerExit=function(e){},io.onTriggerStay=function(e){},io.onCollisionEnter=function(e){},io.onCollisionExit=function(e){},io.onCollisionStay=function(e){},io.onPointerDown=function(e){},io.onPointerUp=function(e){},io.onPointerClick=function(e){},io.onPointerEnter=function(e){},io.onPointerExit=function(e){},io.onPointerDrag=function(e){},io.onDisable=function(){},io.onDestroy=function(){},io._onAwake=function(){this.onAwake()},io._onEnable=function(){this.onEnable()},io._onDisable=function(){this.onDisable()},io._onEnableInScene=function(){var e=this.scene._componentsManager,t=ia.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)},io._onDisableInScene=function(){var e=this.scene._componentsManager,t=ia.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)},io._onDestroy=function(){cZ.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},ia);cC([cA],d3.prototype,"_started",void 0),cC([cA],d3.prototype,"_onStartIndex",void 0),cC([cA],d3.prototype,"_onUpdateIndex",void 0),cC([cA],d3.prototype,"_onLateUpdateIndex",void 0),cC([cA],d3.prototype,"_onPhysicsUpdateIndex",void 0),cC([cA],d3.prototype,"_onPreRenderIndex",void 0),cC([cA],d3.prototype,"_onPostRenderIndex",void 0),cC([cA],d3.prototype,"_entityScriptsIndex",void 0),e.DepthTextureMode=void 0,(is=e.DepthTextureMode||(e.DepthTextureMode={}))[is.None=0]="None",is[is.PrePass=1]="PrePass";var d4=0,d5=((ic=(il=function(t,r,n,i,a){void 0===t&&(t="RENDER_PASS"+d4++),void 0===r&&(r=0),void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null),this.name=t,this.enabled=!0,this.priority=r,this.renderTarget=n,this.replaceMaterial=i,this.mask=a||e.Layer.Everything,this.renderOverride=!1}).prototype).render=function(e,t,r,n){},ic.preRender=function(e,t,r,n){},ic.postRender=function(e,t,r,n){},il),d8=(cy(iu=function(){return u2.apply(this,arguments)},u2),(id=iu.prototype).createVertexElements=function(t){return t[0]=new ub("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ub("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new ub("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},id.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPasses[0].getTagValue(u2._disableBatchTag))return!1;var r=e.data,n=t.data,i=r.component,a=n.component;return!!this.checkBatchWithMask(i,a)&&r.texture===n.texture&&r.material===n.material},id.checkBatchWithMask=function(t,r){var n=t.maskInteraction;return n===r.maskInteraction&&(n===e.SpriteMaskInteraction.None||t.maskLayer===r.maskLayer)},id.updateVertices=function(e,t,r){for(var n=e.verticesData,i=n.positions,a=n.uvs,o=n.color,s=n.vertexCount,l=0;l<s;l++){var c=i[l],u=a[l];t[r++]=c.x,t[r++]=c.y,t[r++]=c.z,t[r++]=u.x,t[r++]=u.y,t[r++]=o.r,t[r++]=o.g,t[r++]=o.b,t[r++]=o.a}return r},id.drawBatches=function(e){for(var t=this._engine,r=this._batchedQueue,n=this._meshes[this._flushId],i=n.subMeshes,a=n._primitive,o=t._spriteMaskManager,s=e.scene.shaderData,l=e.shaderData,c=0,u=i.length;c<u;c++){var d=i[c],h=r[c],_=h.data;if(!d||!h)return;var f=_.component,p=_.material;o.preRender(e,f);var m=uy._compileMacros;ur.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=h.shaderPasses[0],v=g._getShaderProgram(t,m);if(!v.isValid)return;f.shaderData.setTexture(iu._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(a,d,v),o.postRender(f)}},id.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,i=e.length;n<i;++n)e[n].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=r.length;s<l;++s)r[s].destroy();this._indiceBuffers=null},iu);d8._textureProperty=cq.getByName("renderer_SpriteTexture");var d6=((i_=(ih=function(e,t){this.elements=[],this._initSpriteBatcher(e),this._renderQueueType=t}).prototype).pushRenderElement=function(e){this.elements.push(e)},i_.render=function(e,t,r){var n=this.elements;if(0!==n.length){for(var i=e.engine,a=e.scene,o=i._renderCount,s=i._hardwareRenderer,l=a.shaderData,c=e.shaderData,u=uS.pipelineStageKey,d=this._renderQueueType,h=0,_=n.length;h<_;h++){var f=n[h],p=f.data,m=f.shaderPasses;if(p.component.entity.layer&t){if(p.primitive){this._spriteBatcher.flush(e);var g=uy._compileMacros,v=p.primitive,y=p.component,x=p.material,S=y.shaderData,C=x.shaderData,T=x.renderStates;ur.unionCollection(y._globalShaderMacro,C._macroCollection,g);for(var A=0,E=m.length;A<E;A++){var M,R,w=m[A];if(w.getTagValue(u)===r&&(null!=(M=w._renderState)?M:T[A]).renderQueueType===d){var b=w._getShaderProgram(i,g);if(b.isValid){var P=b.bind();o!==b._uploadRenderCount?(b.groupingOtherUniformBlock(),b.uploadAll(b.sceneUniformBlock,l),b.uploadAll(b.cameraUniformBlock,c),b.uploadAll(b.rendererUniformBlock,S),b.uploadAll(b.materialUniformBlock,C),b.uploadUnGroupTextures(),b._uploadScene=a,b._uploadCamera=e,b._uploadRenderer=y,b._uploadMaterial=x,b._uploadRenderCount=o):(b._uploadScene!==a?(b.uploadAll(b.sceneUniformBlock,l),b._uploadScene=a):P&&b.uploadTextures(b.sceneUniformBlock,l),b._uploadCamera!==e?(b.uploadAll(b.cameraUniformBlock,c),b._uploadCamera=e):P&&b.uploadTextures(b.cameraUniformBlock,c),b._uploadRenderer!==y?(b.uploadAll(b.rendererUniformBlock,S),b._uploadRenderer=y):P&&b.uploadTextures(b.rendererUniformBlock,S),b._uploadMaterial!==x?(b.uploadAll(b.materialUniformBlock,C),b._uploadMaterial=x):P&&b.uploadTextures(b.materialUniformBlock,C),P&&b.uploadUnGroupTextures()),(null!=(R=w._renderState)?R:T[A])._apply(i,y.entity.transform._isFrontFaceInvert(),w._renderStateDataMap,x.shaderData),s.drawPrimitive(v,p.subPrimitive,b)}}}}else this._spriteBatcher.drawElement(f,e)}}this._spriteBatcher.flush(e)}},i_.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},i_.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},i_.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},i_._initSpriteBatcher=function(e){this._spriteBatcher=new d8(e)},i_._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var i=t+r>>1,a=e[t],o=e[r-1],s=e[i];if(n(a,o)>0){var l=a;a=o,o=l}if(n(a,s)>=0){var c=a;a=s,s=o,o=c}else if(n(o,s)>0){var u=o;o=s,s=u}e[t]=a,e[r-1]=s;var d=o,h=t+1,_=r-1;e[i]=e[h],e[h]=d;e:for(var f=h+1;f<_;f++){var p=e[f],m=n(p,d);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=n(e[_],d)}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=_)}},i_._insertionSort=function(e,t,r,n){for(var i=t+1;i<r;i++){var a=void 0,o=e[i];for(a=i-1;a>=t;a--){var s=e[a];if(n(s,o)>0)e[a+1]=s;else break}e[a+1]=o}},ih._compareFromNearToFar=function(e,t){var r=e.data,n=t.data,i=r.component,a=n.component,o=i.priority-a.priority;if(0!==o)return o;if(i.instanceId===a.instanceId)return r.material._priority-n.material._priority;var s=i._distanceForSort-a._distanceForSort;return 0===s?i.instanceId-a.instanceId:s},ih._compareFromFarToNear=function(e,t){var r=e.data,n=t.data,i=r.component,a=n.component,o=i.priority-a.priority;if(0!==o)return o;if(i.instanceId===a.instanceId)return r.material._priority-n.material._priority;var s=a._distanceForSort-i._distanceForSort;return 0===s?i.instanceId-a.instanceId:s},ih),d7=((ip=function(){}).recreateTextureIfNeeded=function(e,t,r,n,i,a){if(t){if(t.width===r&&t.height===n&&t.format===i&&t.mipmapCount>1===a)return t;t.destroy();var o=new ck(e,r,n,i,a);return o.isGCIgnored=!0,o}var s=new ck(e,r,n,i,a);return s.isGCIgnored=!0,s},ip.recreateRenderTargetIfNeeded=function(e,t,r,n,i,a,o){var s,l,c,u=null==(s=t)?void 0:s.getColorTexture(0),d=null==(l=t)?void 0:l.depthTexture,h=i?ip.recreateTextureIfNeeded(e,u,r,n,i,o):null,_=a?ip.recreateTextureIfNeeded(e,d,r,n,a,o):null;return(u!==h||d!==_)&&(null==(c=t)||c.destroy(),(t=new cU(e,r,n,h,_)).isGCIgnored=!0),t},ip),d9=function(){this.position=new l9,this.isOrthographic=!1,this.viewMatrix=new cs,this.projectionMatrix=new cs,this.viewProjectionMatrix=new cs,this.forward=new l9},he=function(){this.virtualCamera=new d9,this.cullPlanes=[new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9),new cn(new l9)],this.splitBoundSphere=new ce(new l9,0)};(im=lU||(lU={}))[im.FarBottomLeft=0]="FarBottomLeft",im[im.FarTopLeft=1]="FarTopLeft",im[im.FarTopRight=2]="FarTopRight",im[im.FarBottomRight=3]="FarBottomRight",im[im.nearBottomLeft=4]="nearBottomLeft",im[im.nearTopLeft=5]="nearTopLeft",im[im.nearTopRight=6]="nearTopRight",im[im.nearBottomRight=7]="nearBottomRight",im[im.unknown=8]="unknown";var ht=((ig=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}},ig.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},ig.cullingRenderBounds=function(e,t,r){for(var n=e.min,i=e.max,a=0;a<t;a++){var o=r[a],s=o.normal;if(s.x*(s.x>=0?i.x:n.x)+s.y*(s.y>=0?i.y:n.y)+s.z*(s.z>=0?i.z:n.z)<-o.distance)return!1}return!0},ig.shadowCullFrustum=function(e,t,r,n){var i=r._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&r.castShadows&&ig.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._renderFrameCount=r.engine.time.frameCount,r._prepareRender(e))},ig.getBoundSphereByFrustum=function(e,t,r,n,i){var a,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(l7.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(a=t,o=t*c):(a=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=i.splitBoundSphere.center;i.splitBoundSphere.radius=o,l9.scale(n,a,_),l9.add(r.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},ig.getDirectionLightShadowCullPlanes=function(t,r,n,i,a){var o=ig._frustumCorners,s=ig._backPlaneFaces,l=ig._frustumPlaneNeighbors,c=ig._frustumTwoPlaneCorners,u=ig._edgePlanePoint2,d=a.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=ig._adjustNearPlane,y=ig._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+a.sphereCenterZ+a.splitBoundSphere.radius,_.distance),cr.intersectionPointThreePlanes(v,m,p,o[7]),cr.intersectionPointThreePlanes(v,g,p,o[6]),cr.intersectionPointThreePlanes(v,g,f,o[5]),cr.intersectionPointThreePlanes(v,m,f,o[4]),cr.intersectionPointThreePlanes(y,m,p,o[3]),cr.intersectionPointThreePlanes(y,g,p,o[2]),cr.intersectionPointThreePlanes(y,g,f,o[1]),cr.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,S=0;S<6;S++){var C=void 0;switch(S){case e.FrustumFace.Near:C=v;break;case e.FrustumFace.Far:C=y;break;default:C=t.getPlane(S)}0>l9.dot(C.normal,i)&&(d[x].copyFrom(C),s[x]=S,x++)}for(var T=x,A=0;A<x;A++)for(var E=s[A],M=l[E],R=0;R<4;R++){for(var w=M[R],b=!0,P=0;P<x;P++)if(w==s[P]){b=!1;break}if(b){var F=c[E][w],L=o[F[0]],D=o[F[1]];l9.add(L,i,u),cn.fromPoints(L,D,u,d[T++])}}a.cullPlaneCount=T},ig.getDirectionalLightMatrices=function(e,t,r,n,i,a,o,s){var l=o.splitBoundSphere;o.resolution=a;var c=l.center,u=l.radius,d=a/2,h=u*d/(d-ig.atlasBorderSize),_=2*h,f=a/_,p=_/a,m=Math.ceil(l9.dot(c,e)*f)*p,g=Math.ceil(l9.dot(c,t)*f)*p,v=l9.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,S=y.viewMatrix,C=y.projectionMatrix;l9.scale(r,u+i,x),l9.subtract(c,x,x),cs.lookAt(x,c,e,S),cs.ortho(-h,h,-h,h,0,2*u+i,C);var T=y.viewProjectionMatrix;cs.multiply(C,S,T),c1._floatMatrixMultiply(ig._shadowMapCoordMatrix,T.elements,0,s,16*n)},ig.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),i=Math.floor(e/n)*Math.floor(t/n);i<r;)i=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},ig.getShadowBias=function(t,r,n,i){var a=2/r.elements[0]/n,o=-t.shadowBias*a,s=-t.shadowNormalBias*a;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),i.set(o,s)},ig.applySliceTransform=function(e,t,r,n,i,a){var o=ig._tempMatrix0,s=o.elements,l=1/t,c=1/r,u=i.x*l,d=i.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]=u,s[13]=d,s[14]=0,s[15]=1;var h=16*n;c1._floatMatrixMultiply(o,a,h,a,h)},ig);ht._tempMatrix0=new cs,ht._shadowMapCoordMatrix=new cs(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),ht._frustumCorners=[new l9,new l9,new l9,new l9,new l9,new l9,new l9,new l9],ht._adjustNearPlane=new cn(new l9),ht._adjustFarPlane=new cn(new l9),ht._backPlaneFaces=[,,,,,],ht._edgePlanePoint2=new l9,ht._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]],ht._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]]],ht.atlasBorderSize=4;var hr=function(e){this._engine=e},hn=function(t){function r(n){var i;return(i=t.call(this,n.engine)||this)._shadowMapSize=new cu,i._shadowBias=new cc,i._shadowSliceData=new he,i._lightUp=new l9,i._lightSide=new l9,i._existShadowMap=!1,i._splitBoundSpheres=new Float32Array(4*r._maxCascades),i._shadowMatrices=new Float32Array((r._maxCascades+1)*16),i._shadowInfos=new l9,i._viewportOffsets=[new cc,new cc,new cc,new cc],i._camera=n,i._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),i._shadowSliceData.virtualCamera.isOrthographic=!0,i}cy(r,t);var n=r.prototype;return n.onRender=function(e){this._updateShadowSettings(),this._existShadowMap=!1,this._renderDirectShadowMap(e),this._existShadowMap&&this._updateReceiversShaderData()},n._renderDirectShadowMap=function(t){var n=this._engine,i=this._camera,a=this._viewportOffsets,o=this._shadowSliceData,s=this._splitBoundSpheres,l=this._shadowMatrices,c=i._renderPipeline._cullingResults,u=c.opaqueQueue,d=c.alphaTestQueue,h=c.transparentQueue,_=i.scene,f=_._componentsManager,p=n._hardwareRenderer,m=_.shadowCascades,g=r._cascadesSplitDistance,v=o.splitBoundSphere,y=r._tempMatrix0,x=y.elements,S=this._lightUp,C=this._lightSide,T=o.virtualCamera.forward,A=i.scene._sunLight;if(A){var E,M,R=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(R);var w=this._shadowMapSize,b=w.z,P=w.w,F=this._shadowMapFormat;(M=this._supportDepthTexture?(E=d7.recreateRenderTargetIfNeeded(n,this._renderTarget,b,P,null,F,!1)).depthTexture:(E=d7.recreateRenderTargetIfNeeded(n,this._renderTarget,b,P,F,null,!1)).getColorTexture(0)).wrapModeU=M.wrapModeV=e.TextureWrapMode.Clamp,n._hardwareRenderer._isWebGL2&&(M.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=E,this._depthTexture=M,p.activeRenderTarget(E,r._viewport,0),this._supportDepthTexture?p.clearRenderTarget(n,e.CameraClearFlags.Depth,null):p.clearRenderTarget(n,e.CameraClearFlags.All,r._clearColor),this._shadowInfos.x=A.shadowStrength,this._shadowInfos.z=0,cs.rotationQuaternion(A.entity.transform.worldRotationQuaternion,y),C.set(x[0],x[1],x[2]),S.set(x[4],x[5],x[6]),T.set(-x[8],-x[9],-x[10]);var L=r._tempVector;L.copyFrom(i.entity.transform.worldForward);for(var D=this._shadowTileResolution,B=0;B<m;B++){ht.getBoundSphereByFrustum(g[B],g[B+1],i,L,o),ht.getDirectionLightShadowCullPlanes(i._frustum,g[B],i.nearClipPlane,T,o),ht.getDirectionalLightMatrices(S,C,T,B,A.shadowNearPlane,D,o,l),m>1&&ht.applySliceTransform(D,b,P,B,this._viewportOffsets[B],l),this._updateSingleShadowCasterShaderData(A,o,t);var I=v.center,V=v.radius,O=4*B;s[O]=I.x,s[O+1]=I.y,s[O+2]=I.z,s[O+3]=V*V,u.clear(),d.clear(),h.clear();for(var N=f._renderers,z=N._elements,U=N.length-1;U>=0;--U)ht.shadowCullFrustum(t,A,z[U],o);if(u.elements.length||d.elements.length){u.sort(d6._compareFromNearToFar),d.sort(d6._compareFromNearToFar);var k=a[B],G=k.x,H=k.y;p.setGlobalDepthBias(1,1),p.viewport(G,H,D,D),p.scissor(G+1,H+1,D-2,D-2),n._renderCount++,u.render(i,e.Layer.Everything,e.PipelineStage.ShadowCaster),d.render(i,e.Layer.Everything,e.PipelineStage.ShadowCaster),p.setGlobalDepthBias(0,0)}}this._existShadowMap=!0}},n._updateReceiversShaderData=function(){var e=this._camera.scene,t=this._splitBoundSpheres,n=this._shadowMatrices,i=e.shadowCascades;if(i>1)for(var a=4*i,o=t.length;a<o;a++)t[a]=0;for(var s=16*i,l=n.length;s<l;s++)n[s]=0;var c=e.shaderData;c.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),c.setVector3(r._shadowInfosProperty,this._shadowInfos),c.setTexture(r._shadowMapsProperty,this._depthTexture),c.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),c.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,i=this._camera.scene,a=i.shadowTwoCascadeSplits,o=i.shadowFourCascadeSplits,s=i.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,d=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*l7.degreeToRadian(d)),f=1+_*_*(u*u+1);switch(s){case e.ShadowCascadesMode.NoCascades:n[1]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.TwoCascades:n[1]=this._getFarWithRadius(c+h*a,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.scene,r=ht.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),n=ht.shadowResolution(t.shadowResolution),i=t.shadowCascades;if(r!==this._shadowMapFormat||n!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=r,this._shadowMapResolution=n,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=n,this._shadowMapSize.set(1/n,1/n,n,n);else{var a=ht.getMaxTileResolutionInAtlas(n,n,i);this._shadowTileResolution=a;var o=2*a,s=i==e.ShadowCascadesMode.TwoCascades?a:2*a;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTarget=null;var l=this._viewportOffsets,c=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(c,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(c,0),l[2].set(0,c),l[3].set(c,c)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var i=t.virtualCamera;ht.getShadowBias(e,i.projectionMatrix,this._shadowTileResolution,this._shadowBias);var a=this._camera.scene.shaderData;a.setVector2(r._lightShadowBiasProperty,this._shadowBias),a.setVector3(r._lightDirectionProperty,e.direction),n.applyVirtualCamera(i)},r}(hr);hn._lightShadowBiasProperty=cq.getByName("scene_ShadowBias"),hn._lightDirectionProperty=cq.getByName("scene_LightDirection"),hn._shadowMatricesProperty=cq.getByName("scene_ShadowMatrices"),hn._shadowMapSize=cq.getByName("scene_ShadowMapSize"),hn._shadowInfosProperty=cq.getByName("scene_ShadowInfo"),hn._shadowMapsProperty=cq.getByName("scene_ShadowMap"),hn._shadowSplitSpheresProperty=cq.getByName("scene_ShadowSplitSpheres"),hn._maxCascades=4,hn._cascadesSplitDistance=Array(hn._maxCascades+1),hn._viewport=new cu(0,0,1,1),hn._clearColor=new cd(1,1,1,1),hn._tempVector=new l9,hn._tempMatrix0=new cs;var hi=((iy=(iv=function(t){this.opaqueQueue=new d6(t,e.RenderQueueType.Opaque),this.transparentQueue=new d6(t,e.RenderQueueType.Transparent),this.alphaTestQueue=new d6(t,e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},iy.sort=function(){this.opaqueQueue.sort(d6._compareFromNearToFar),this.alphaTestQueue.sort(d6._compareFromNearToFar),this.transparentQueue.sort(d6._compareFromFarToNear)},iy.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},iv),ha=(cy(ix=function(t){var r;return(r=hr.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},hr),(iS=ix.prototype).onConfig=function(t){var r=this._engine,n=t.pixelViewport,i=n.width,a=n.height,o=d7.recreateRenderTargetIfNeeded(r,this._renderTarget,i,a,null,e.TextureFormat.Depth16,!1),s=o.depthTexture;s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Clamp,s.filterMode=e.TextureFilterMode.Point,this._renderTarget=o},iS.onRender=function(t,r){var n=this._engine,i=this._renderTarget,a=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(i,a.viewport,0),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),o.viewport(0,0,i.width,i.height),o.scissor(0,0,i.width,i.height),r.opaqueQueue.render(a,e.Layer.Everything,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(a,e.Layer.Everything,e.PipelineStage.DepthOnly),a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},ix),ho=((iT=(iC=function(e){this._allSpriteMasks=new c0,this._lastCanvasSize=new cc,this._camera=e;var t=e.engine;this._cullingResults=new hi(t),this._cascadedShadowCaster=new hn(e),this._depthOnlyPass=new ha(t),this._renderPassArray=[],this._defaultPass=new d5("default",0,null,null,0),this.addRenderPass(this._defaultPass)}).prototype).addRenderPass=function(e,t,r,n,i){if(void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===i&&(i=null),"string"==typeof e){var a=new d5(e,t,r,n,i);this._renderPassArray.push(a)}else cT(e,d5)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},iT.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):cT(e,d5)&&(t=e),t){var r=this._renderPassArray.indexOf(t);this._renderPassArray.splice(r,1)}},iT.getRenderPass=function(e){for(var t=0,r=this._renderPassArray.length;t<r;t++){var n=this._renderPassArray[t];if(n.name===e)return n}return null},iT.destroy=function(){this._cullingResults.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},iT.render=function(t,r,n){var i,a=this._camera,o=a.scene,s=this._cullingResults;a.engine._spriteMaskManager.clear(),o.castShadows&&(null==(i=o._sunLight)?void 0:i.shadowType)!==e.ShadowType.None&&this._cascadedShadowCaster.onRender(t),s.reset(),this._allSpriteMasks.length=0,t.applyVirtualCamera(a._virtualCamera),this._callRender(t),s.sort();var l=this._depthOnlyPass;a.depthTextureMode===e.DepthTextureMode.PrePass&&l._supportDepthTexture?(l.onConfig(a),l.onRender(t,s)):a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,a.engine._whiteTexture2D);for(var c=0,u=this._renderPassArray.length;c<u;c++)this._drawRenderPass(t,this._renderPassArray[c],a,r,n)},iT._drawRenderPass=function(t,r,n,i,a){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue;if(r.preRender(n,s,l,c),r.enabled){var u,d,h=n.engine,_=n.scene.background,f=h._hardwareRenderer,p=n.renderTarget||r.renderTarget;f.activeRenderTarget(p,n.viewport,a),null==p||p._setRenderTargetInfo(i,a);var m=null!=(u=r.clearFlags)?u:n.clearFlags,g=null!=(d=r.clearColor)?d:_.solidColor;m!==e.CameraClearFlags.None&&f.clearRenderTarget(n.engine,m,g),r.renderOverride?r.render(n,s,l,c):(s.render(n,r.mask,e.PipelineStage.Forward),l.render(n,r.mask,e.PipelineStage.Forward),n.clearFlags&e.CameraClearFlags.Color&&(_.mode===e.BackgroundMode.Sky?_.sky._render(t):_.mode===e.BackgroundMode.Texture&&_.texture&&this._drawBackgroundTexture(h,_)),o.transparentQueue.render(n,r.mask,e.PipelineStage.Forward)),null==p||p._blitRenderTarget(),null==p||p.generateMipmaps()}r.postRender(n,o.opaqueQueue,o.alphaTestQueue,o.transparentQueue)},iT.pushRenderData=function(e,t){var r=t.material,n=r.renderStates,i=r.shader.subShaders[0],a=e.replacementShader;if(a){var o=a.subShaders,s=e.replacementTag;if(s)for(var l=0,c=o.length;l<c;l++){var u=o[l];if(u.getTagValue(s)===i.getTagValue(s)){this.pushRenderDataWithShader(e,t,u.passes,n);break}}else this.pushRenderDataWithShader(e,t,o[0].passes,n)}else this.pushRenderDataWithShader(e,t,i.passes,n)},iT.pushRenderDataWithShader=function(t,r,n,i){for(var a=this._cullingResults,o=a.opaqueQueue,s=a.alphaTestQueue,l=a.transparentQueue,c=t.camera.engine._renderElementPool,u=0,d=0,h=n.length;d<h;d++){var _,f=(null!=(_=n[d]._renderState)?_:i[d]).renderQueueType;if(!(u&1<<f)){var p=c.getFromPool();switch(p.set(r,n),f){case e.RenderQueueType.Opaque:o.pushRenderElement(p),u|=1;break;case e.RenderQueueType.AlphaTest:s.pushRenderElement(p),u|=2;break;case e.RenderQueueType.Transparent:l.pushRenderElement(p),u|=4}}}},iT._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,i=t.canvas,a=r._material,o=r._mesh;(this._lastCanvasSize.x!==i.width||this._lastCanvasSize.y!==i.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(i.width,i.height),r._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,uy._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,a.shaderData),l.uploadUnGroupTextures(),(s._renderState||a.renderState)._apply(t,!1,s._renderStateDataMap,a.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},iT._callRender=function(e){for(var t=e.camera.engine,r=e.camera,n=r.scene._componentsManager._renderers,i=n._elements,a=n.length-1;a>=0;--a){var o=i[a];r.cullingMask&o._entity.layer&&(!r.enableFrustumCulling||r._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},cg(iC,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),iC);(iA=lk||(lk={}))[iA.None=0]="None",iA[iA.Opaque=1]="Opaque",iA[iA.AlphaTest=2]="AlphaTest",iA[iA.Transparent=4]="Transparent";var hs=function(){};hs.tempVec4=new cu,hs.tempVec3=new l9,hs.tempVec2=new cc,e.Camera=(cy(iE=function(t){(r=cZ.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r._globalShaderMacro=new ur,r._frustum=new ci,r._virtualCamera=new d9,r._replacementShader=null,r._replacementSubShaderTag=null,r._priority=0,r._shaderData=new ux(lC.Camera),r._isProjMatSetting=!1,r._nearClipPlane=.1,r._farClipPlane=100,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._isFrustumProjectDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new cu,r._viewport=new cu(0,0,1,1),r._pixelViewport=new ch(0,0,0,0),r._inverseProjectionMatrix=new cs,r._invViewProjMat=new cs;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumViewChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new ho(cp(r)),r.shaderData._addReferCount(1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(cp(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},cZ),(iM=iE.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},iM.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},iM.worldToViewportPoint=function(e,t){var r=hs.tempVec3,n=hs.tempVec4;l9.transformCoordinate(e,this.viewMatrix,r),l9.transformToVec4(r,this.projectionMatrix,n);var i=n.w;return t.set((n.x/i+1)*.5,(1-n.y/i)*.5,-r.z),t},iM.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,i=this.farClipPlane,a=1/(n-i);if(this.isOrthographic)r=-(2*e.z)*a+(i+n)*a;else{var o=e.z;r=(-o*(n+i)*a+2*n*i*a)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},iM.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),i=this._innerViewportToWorldPoint(e.x,e.y,1-l7.zeroTolerance,r,t.direction);return l9.subtract(i,n,i),i.normalize(),t},iM.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},iM.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},iM.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},iM.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},iM.screenPointToRay=function(e,t){var r=hs.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},iM.render=function(e,t){void 0===t&&(t=0);var r=this.engine._renderContext,n=this._virtualCamera,i=this.entity.transform;cs.multiply(this.projectionMatrix,this.viewMatrix,n.viewProjectionMatrix),n.position.copyFrom(i.worldPosition),n.isOrthographic&&n.forward.copyFrom(i.worldForward),r.camera=this,r.virtualCamera=n,r.replacementShader=this._replacementShader,r.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&(this._frustumViewChangeFlag.flag||this._isFrustumProjectDirty)&&(this._frustum.calculateFromMatrix(n.viewProjectionMatrix),this._frustumViewChangeFlag.flag=!1,this._isFrustumProjectDirty=!1),this._updateShaderData(),ur.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,cN.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(r,e,t),this._engine._renderCount++},iM.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?uo.getByName(t):t},iM.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},iM._onEnableInScene=function(){this.scene._attachRenderCamera(this)},iM._onDisableInScene=function(){this.scene._detachRenderCamera(this)},iM._onDestroy=function(){var e;cZ.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addReferCount(-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._frustumViewChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},iM._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 i=this._viewport;this._pixelViewport.set(i.x*e,i.y*t,i.z*e,i.w*t)},iM._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},iM._innerViewportToWorldPoint=function(e,t,r,n,i){var a=hs.tempVec3;return a.set(2*e-1,1-2*t,2*r-1),l9.transformCoordinate(a,n,i),i},iM._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,i=this._farClipPlane/this._nearClipPlane;n.set(1-i,i,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},iM._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,cs.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},iM._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,cs.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},iM._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projMatChange()},cg(iE,[{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._nearClipPlane},set:function(e){this._nearClipPlane=e,this._projMatChange()}},{key:"farClipPlane",get:function(){return this._farClipPlane},set:function(e){this._farClipPlane=e,this._projMatChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projMatChange()}},{key:"aspectRatio",get:function(){var e,t=this._entity.engine.canvas;return null!=(e=this._customAspectRatio)?e:t.width*this._viewport.z/(t.height*this._viewport.w)},set:function(e){this._customAspectRatio=e,this._projMatChange()}},{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._entity._isActiveInScene&&this.enabled&&(this.scene._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projMatChange()}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projMatChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(this._isViewMatrixDirty.flag){this._isViewMatrixDirty.flag=!1;var t=this._transform;cs.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert()}return e}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isProjMatSetting)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,i=this._orthographicSize;cs.ortho(-n,n,-i,i,this._nearClipPlane,this._farClipPlane,t)}else cs.perspective(l7.degreeToRadian(this._fieldOfView),r,this._nearClipPlane,this._farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isProjMatSetting=!0,this._projMatChange()}},{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){if(this._renderTarget!==e){var t;null==e||e._addReferCount(1),null==(t=this._renderTarget)||t._addReferCount(-1),this._renderTarget=e,this._onPixelViewportChanged()}}}]),iE._cameraDepthTextureProperty=cq.getByName("camera_DepthTexture"),iE._inverseViewMatrixProperty=cq.getByName("camera_ViewInvMat"),iE._cameraPositionProperty=cq.getByName("camera_Position"),iE._cameraForwardProperty=cq.getByName("camera_Forward"),iE._cameraUpProperty=cq.getByName("camera_Up"),iE._cameraDepthBufferParamsProperty=cq.getByName("camera_DepthBufferParams"),iE),cC([cR],e.Camera.prototype,"_frustum",void 0),cC([cA],e.Camera.prototype,"_renderPipeline",void 0),cC([cA],e.Camera.prototype,"_virtualCamera",void 0),cC([cA],e.Camera.prototype,"_frustumViewChangeFlag",void 0),cC([cA],e.Camera.prototype,"_transform",void 0),cC([cA],e.Camera.prototype,"_isViewMatrixDirty",void 0),cC([cA],e.Camera.prototype,"_isInvViewProjDirty",void 0),cC([cR],e.Camera.prototype,"_viewport",void 0),cC([cR],e.Camera.prototype,"_pixelViewport",void 0),cC([cR],e.Camera.prototype,"_inverseProjectionMatrix",void 0),cC([cR],e.Camera.prototype,"_invViewProjMat",void 0),cC([cA],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=cC([c$(c6,e.DependentMode.CheckOnly)],e.Camera);var hl={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hc=1/0;function hu(e,t){return void 0===t&&(t={}),new de(function(r,n,i){var a,o,s,l,c=null!=(a=t.retryCount)?a:1,u=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:hc,t.type=null!=(l=t.type)?l:hl[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?hd:hh;new h_(function(){return d(e,t).onProgress(i)},c,u).start().onError(n).onComplete(r)})}function hd(e,t){return new de(function(r,n){var i,a=t.timeout,o=new Image,s=function(){n(Error("request "+e+" fail"))};o.onerror=s,o.onabort=s;var l=-1;a!=1/0&&(l=window.setTimeout(function(){n(Error("request "+e+" timeout"))},a)),o.onload=(i=l,function(){requestAnimationFrame(function(){r(o),o.onload=null,o.onerror=null,o.onabort=null}),clearTimeout(i)}),o.crossOrigin="anonymous",o.src=e})}function hh(e,t){return new de(function(r,n,i){var a,o=new XMLHttpRequest;o.timeout=t.timeout,t.method=null!=(a=t.method)?a:"get",o.onload=function(){var t;if(o.status<200||o.status>=300){n(Error("request failed from: "+e));return}r(null!=(t=o.response)?t:o.responseText)},o.onerror=function(){n(Error("request failed from: "+e))},o.ontimeout=function(){n(Error("request timeout from: "+e))},o.onprogress=function(e){i(e.loaded/e.total)},o.open(t.method,e,!0),o.withCredentials="include"===t.credentials,o.responseType=t.type;var s=t.headers;s&&Object.keys(s).forEach(function(e){o.setRequestHeader(e,s[e])}),o.send(t.body)})}var h_=((iw=(iR=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},iw.onComplete=function(e){return this._onComplete=e,this},iw.onError=function(e){return this._onError=e,this},iw.cancel=function(){window.clearTimeout(this._timeoutId)},iw.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)})},iR),hf=((ib=function(e){this.useCache=e,this.request=hu}).registerClass=function(e,t){this._engineObjects[e]=t},ib.getClass=function(e){return this._engineObjects[e]},ib);hf._engineObjects={},e.BlendMode=void 0,(iP=e.BlendMode||(e.BlendMode={}))[iP.Normal=0]="Normal",iP[iP.Additive=1]="Additive",e.RenderFace=void 0,(iF=e.RenderFace||(e.RenderFace={}))[iF.Front=0]="Front",iF[iF.Back=1]="Back",iF[iF.Double=2]="Double";var hp=function(t){function r(n,i){var a;return(a=t.call(this,n,i)||this)._renderFace=e.RenderFace.Front,a._isTransparent=!1,a._blendMode=e.BlendMode.Normal,a.shaderData.setFloat(r._alphaCutoffProp,0),a}cy(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var i=this.renderStates;if(i.length<t)throw"Pass should less than pass count.";var a=i[t];n?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(r._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.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 i=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.One,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.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},cg(r,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader=t;for(var r=this._renderStates,n=r.length,i=0,a=t.subShaders,o=0;o<a.length;o++)i=Math.max(a[o].passes.length,i);if(n<i)for(var s=n;s<i;s++)r.push(new uv),this.setBlendMode(s,e.BlendMode.Normal);else r.length=i}},{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 i=this.renderStates,a=0,o=i.length;a<o;a++){var s=i[a];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}(dL);hp._baseTextureMacro=ut.getByName("MATERIAL_HAS_BASETEXTURE"),hp._normalTextureMacro=ut.getByName("MATERIAL_HAS_NORMALTEXTURE"),hp._emissiveTextureMacro=ut.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),hp._transparentMacro=ut.getByName("MATERIAL_IS_TRANSPARENT"),hp._baseColorProp=cq.getByName("material_BaseColor"),hp._baseTextureProp=cq.getByName("material_BaseTexture"),hp._tilingOffsetProp=cq.getByName("material_TilingOffset"),hp._normalTextureProp=cq.getByName("material_NormalTexture"),hp._normalIntensityProp=cq.getByName("material_NormalIntensity"),hp._emissiveColorProp=cq.getByName("material_EmissiveColor"),hp._emissiveTextureProp=cq.getByName("material_EmissiveTexture"),hp._alphaCutoffProp=cq.getByName("material_AlphaCutoff"),hp._alphaCutoffMacro=ut.getByName("MATERIAL_IS_ALPHA_CUTOFF");var hm=function(e){function t(r){var n,i=(n=e.call(this,r,uy.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new cd(1,1,1,1)),i.setColor(t._specularColorProp,new cd(1,1,1,1)),i.setColor(t._emissiveColorProp,new cd(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new cu(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),n}return cy(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cg(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}(hp);hm._specularColorProp=cq.getByName("material_SpecularColor"),hm._shininessProp=cq.getByName("material_Shininess"),hm._specularTextureProp=cq.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(iL=e.TextureCoordinate||(e.TextureCoordinate={}))[iL.UV0=0]="UV0",iL[iL.UV1=1]="UV1",iL[iL.UV2=2]="UV2",iL[iL.UV3=3]="UV3",iL[iL.UV4=4]="UV4",iL[iL.UV5=5]="UV5",iL[iL.UV6=6]="UV6",iL[iL.UV7=7]="UV7";var hg=function(t){function r(n,i){var a,o=(a=t.call(this,n,i)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new cd(1,1,1,1)),o.setColor(r._emissiveColorProp,new cd(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new cu(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),a}return cy(r,t),cg(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&&cN.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}(hp);hg._occlusionTextureIntensityProp=cq.getByName("material_OcclusionIntensity"),hg._occlusionTextureCoordProp=cq.getByName("material_OcclusionTextureCoord"),hg._occlusionTextureProp=cq.getByName("material_OcclusionTexture"),hg._clearCoatProp=cq.getByName("material_ClearCoat"),hg._clearCoatTextureProp=cq.getByName("material_ClearCoatTexture"),hg._clearCoatRoughnessProp=cq.getByName("material_ClearCoatRoughness"),hg._clearCoatRoughnessTextureProp=cq.getByName("material_ClearCoatRoughnessTexture"),hg._clearCoatNormalTextureProp=cq.getByName("material_ClearCoatNormalTexture");var hv=function(e){function t(r){var n;return(n=e.call(this,r,uy.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),n.shaderData.setFloat(t._roughnessProp,1),n.shaderData.setFloat(t._iorProp,1.5),n}return cy(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cg(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")}}]),t}(hg);hv._metallicProp=cq.getByName("material_Metal"),hv._roughnessProp=cq.getByName("material_Roughness"),hv._roughnessMetallicTextureProp=cq.getByName("material_RoughnessMetallicTexture"),hv._iorProp=uy.getPropertyByName("material_IOR");var hy=function(e){function t(r){var n;return(n=e.call(this,r,uy.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new cd(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return cy(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cg(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}(hg);hy._specularColorProp=cq.getByName("material_PBRSpecularColor"),hy._glossinessProp=cq.getByName("material_Glossiness"),hy._specularGlossinessTextureProp=cq.getByName("material_SpecularGlossinessTexture"),hy._specularGlossinessTextureMacro=ut.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var hx=function(e){function t(r){var n,i=(n=e.call(this,r,uy.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new cd(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new cu(1,1,0,0)),n}return cy(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cg(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}(hp),hS=((iB=(iD=function(){}).prototype).initialize=function(e){for(var t=e.component,r=e.property.split("."),n=r.length-1,i=0;i<n;i++)t=t[r[i]];this._mounted=t,this._propertyName=r[n]},iB.getTargetValue=function(){return this._mounted[this._propertyName]},iB.setTargetValue=function(e){this._mounted[this._propertyName]=e},iD),hC=function(){function e(t,r,n,i,a){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=i,this.component=n,this.cureType=a,this._isBlendShape=cT(this.component,u1);var o=e.getAssemblerType(r,i);this._assembler=new o,this._assembler.initialize(this),a._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,i,a){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?a?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):a?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?a?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,i)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var i=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,a=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(i,a,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 i=this._assembler;if(n._isCopyMode){var a=n._additiveValue(e,t,this.referenceTargetValue);this._isBlendShape&&i.setTargetValue(a)}else{var o=i.getTargetValue(),s=n._additiveValue(e,t,o);i.setTargetValue(s)}}else if(1===t)n._isCopyMode?(n._setValue(e,this.referenceTargetValue),this._isBlendShape&&this._assembler.setTargetValue(this.referenceTargetValue)):this._assembler.setTargetValue(e);else if(n._isCopyMode){var l=this.referenceTargetValue;n._lerpValue(l,e,t,l),this._isBlendShape&&this._assembler.setTargetValue(l)}else{var c=this._assembler.getTargetValue(),u=n._lerpValue(c,e,t);this._assembler.setTargetValue(u)}},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 i=e._assemblerMap.get(t);i||(i={},e._assemblerMap.set(t,i)),i[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),i=n?n[r]:void 0;return null!=i?i:hS},e}();hC._assemblerMap=new Map;var hT=((iV=(iI=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iV.getTargetValue=function(){return this._transform.position},iV.setTargetValue=function(e){this._transform.position=e},iI);hC.registerAssembler(c6,"position",hT);var hA=((iN=(iO=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iN.getTargetValue=function(){return this._transform.rotationQuaternion},iN.setTargetValue=function(e){this._transform.rotationQuaternion=e},iO);hC.registerAssembler(c6,"rotationQuaternion",hA);var hE=((iU=(iz=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iU.getTargetValue=function(){return this._transform.scale},iU.setTargetValue=function(e){this._transform.scale=e},iz);hC.registerAssembler(c6,"scale",hE);var hM=((iG=(ik=function(){this._skinnedMeshRenderer=[]}).prototype).initialize=function(e){e.target.getComponents(u1,this._skinnedMeshRenderer)},iG.getTargetValue=function(){return this._skinnedMeshRenderer[0].blendShapeWeights},iG.setTargetValue=function(e){for(var t=this._skinnedMeshRenderer,r=0,n=t.length;r<n;r++)t[r].blendShapeWeights=e},ik);hC.registerAssembler(u1,"blendShapeWeights",hM);var hR=((iW=(iH=function(){this.crossCurveMark=0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},iW.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},iH),hw=((iK=(iX=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new hC(e,this.type,t,this.property,r);return r._initializeOwner(n),n.saveDefaultValue(),n},iK._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new hR;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},iK._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},iX),hb=function(){},hP=(cy(ij=function(e){var t;return(t=cb.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new c8,t._length=0,t._events=[],t},cb),(iY=ij.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,i=new hb;i.functionName=e,i.time=t,i.parameter=r,n=i}else n=e;var a=this._events,o=a.length,s=n.time;if(s>=(o?a[o-1].time:0))a.push(n);else{for(var l=o;--l>=0&&s<a[l].time;);a.splice(l+1,0,n)}this._updateFlagManager.dispatch()},iY.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},iY.addCurveBinding=function(e,t,r,n){var i=new hw;i.relativePath=e,i.type=t,i.property=r,i.curve=n,n.length>this._length&&(this._length=n.length),this._curveBindings.push(i)},iY.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iY._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var i=r[n],a=e.findByPath(i.relativePath);if(a){var o=a.getComponent(i.type);if(!o)continue;var s=i._getTempCurveOwner(a,o);if(s&&i.curve.keys.length){var l=s.evaluateValue(i.curve,t,!1);s.applyValue(l,1,!1)}}}},cg(ij,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),ij);e.InterpolationType=void 0,(iq=e.InterpolationType||(e.InterpolationType={}))[iq.Linear=0]="Linear",iq[iq.CubicSpine=1]="CubicSpine",iq[iq.Step=2]="Step",iq[iq.Hermite=3]="Hermite";var hF=((iZ=(iQ=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)}},iZ.evaluate=function(e){return this._evaluate(e,this._evaluateData)},iZ.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var i=t[n];i.time>this._length&&(r=i.time)}this._length=r},iZ._evaluate=function(t,r){var n,i=this.keys.length;if(!i){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=i||t<a[s].time)&&(s=-1);for(var l=s+1;l<i&&!(t<a[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(a[0].value,r.value);else if(l===i)n=this._type._setValue(a[s].value,r.value);else{var c=a[s],u=a[l],d=c.time,h=u.time-d,_=(t-d)/h;switch(o){case e.InterpolationType.Linear:n=this._type._lerpValue(c.value,u.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,u,_,h,r.value)}}return r.value=n,n},iZ._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},cg(iQ,[{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}}]),iQ);e.AnimationArrayCurve=(cy(iJ=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=[],e},hF),iJ._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iJ._initializeLayerOwner=function(e){e.finalValue=[]},iJ._lerpValue=function(e,t,r,n){for(var i=0,a=n.length;i<a;++i){var o=e[i];n[i]=o+(t[i]-o)*r}return n},iJ._subtractValue=function(e,t,r){for(var n=0,i=e.length;n<i;n++)r[n]=e[n]-t[n];return r},iJ._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},iJ._additiveValue=function(e,t,r){for(var n=0,i=r.length;n<i;++n)r[n]+=e[n]*t;return r},iJ._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},iJ._hermiteInterpolationValue=function(e,t,r,n,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*n+_*o[p]*n+f*l[p]:i[p]=e.value[p];return i},iJ._isCopyMode=!0,iJ._supportInterpolationMode=!0,iJ),e.AnimationArrayCurve=cC([uA()],e.AnimationArrayCurve),e.AnimationBoolCurve=(cy(i$=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=!1,e},hF),i$._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},i$._initializeLayerOwner=function(e){e.finalValue=!1},i$._lerpValue=function(e,t){return e},i$._subtractValue=function(e,t,r){return e},i$._getZeroValue=function(){return!1},i$._additiveValue=function(e,t,r){return e},i$._setValue=function(e){return e},i$._hermiteInterpolationValue=function(e){return e.value},i$._isCopyMode=!1,i$._supportInterpolationMode=!1,i$),e.AnimationBoolCurve=cC([uA()],e.AnimationBoolCurve),e.AnimationColorCurve=(cy(i0=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new cd,e},hF),i0._initializeOwner=function(e){e.defaultValue=new cd,e.fixedPoseValue=new cd,e.baseEvaluateData.value=new cd,e.crossEvaluateData.value=new cd},i0._initializeLayerOwner=function(e){e.finalValue=new cd},i0._lerpValue=function(e,t,r,n){return cd.lerp(e,t,r,n),n},i0._subtractValue=function(e,t,r){return cd.subtract(e,t,r),r},i0._getZeroValue=function(e){return e.set(0,0,0,0),e},i0._additiveValue=function(e,t,r){return cd.scale(e,t,e),cd.add(r,e,r),r},i0._setValue=function(e,t){return t.copyFrom(e),t},i0._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.r=d*a.r+h*p*n+_*m*n+f*s.r:i.r=a.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.g=d*a.g+h*p*n+_*m*n+f*s.g:i.g=a.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.b=d*a.b+h*p*n+_*m*n+f*s.b:i.b=a.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.a=d*a.a+h*p*n+_*m*n+f*s.a:i.a=a.a,i},i0._isCopyMode=!0,i0._supportInterpolationMode=!0,i0),e.AnimationColorCurve=cC([uA()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(cy(i1=function(){return hF.apply(this,arguments)},hF),i1.prototype.addKey=function(e){hF.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)}},i1._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)},i1._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},i1._lerpValue=function(e,t,r,n){for(var i=0,a=n.length;i<a;++i){var o=e[i];n[i]=o+(t[i]-o)*r}return n},i1._subtractValue=function(e,t,r){for(var n=0,i=e.length;n<i;n++)r[n]=e[n]-t[n];return r},i1._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},i1._additiveValue=function(e,t,r){for(var n=0,i=r.length;n<i;++n)r[n]+=e[n]*t;return r},i1._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},i1._hermiteInterpolationValue=function(e,t,r,n,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*n+_*o[p]*n+f*l[p]:i[p]=e.value[p];return i},i1._isCopyMode=!0,i1._supportInterpolationMode=!0,i1),e.AnimationFloatArrayCurve=cC([uA()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(cy(i2=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=0,e},hF),i2._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},i2._initializeLayerOwner=function(e){e.finalValue=0},i2._lerpValue=function(e,t,r){return e+(t-e)*r},i2._additiveValue=function(e,t,r){return r+e*t},i2._subtractValue=function(e,t){return e-t},i2._getZeroValue=function(){return 0},i2._setValue=function(e){return e},i2._hermiteInterpolationValue=function(e,t,r,n){var i=e.outTangent,a=t.inTangent;if(!(Number.isFinite(i)&&Number.isFinite(a)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*i*n+(s-o)*a*n+(-2*s+3*o)*t.value},i2._isCopyMode=!1,i2._supportInterpolationMode=!0,i2),e.AnimationFloatCurve=cC([uA()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(cy(i3=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new co,e},hF),i3._initializeOwner=function(e){e.defaultValue=new co,e.fixedPoseValue=new co,e.baseEvaluateData.value=new co,e.crossEvaluateData.value=new co},i3._initializeLayerOwner=function(e){e.finalValue=new co},i3._lerpValue=function(e,t,r,n){return co.slerp(e,t,r,n),n},i3._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},i3._subtractValue=function(t,r,n){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return co.conjugate(r,i),co.multiply(i,t,n),n},i3._getZeroValue=function(e){return e.set(0,0,0,1),e},i3._setValue=function(e,t){return t.copyFrom(e),t},i3._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*n+_*m*n+f*s.w:i.w=a.w,i},i3._supportInterpolationMode=!0,i3._isCopyMode=!0,i3._tempConjugateQuat=new co,i3),e.AnimationQuaternionCurve=cC([uA()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(cy(i4=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new cc,e},hF),i4._initializeOwner=function(e){e.defaultValue=new cc,e.fixedPoseValue=new cc,e.baseEvaluateData.value=new cc,e.crossEvaluateData.value=new cc},i4._initializeLayerOwner=function(e){e.finalValue=new cc},i4._lerpValue=function(e,t,r,n){return cc.lerp(e,t,r,n),n},i4._additiveValue=function(e,t,r){return cc.scale(e,t,e),cc.add(r,e,r),r},i4._subtractValue=function(e,t,r){return cc.subtract(e,t,r),r},i4._getZeroValue=function(e){return e.set(0,0),e},i4._setValue=function(e,t){return t.copyFrom(e),t},i4._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,i},i4._isCopyMode=!0,i4._supportInterpolationMode=!0,i4),e.AnimationVector2Curve=cC([uA()],e.AnimationVector2Curve),e.AnimationVector3Curve=(cy(i5=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new l9,e},hF),i5._initializeOwner=function(e){e.defaultValue=new l9,e.fixedPoseValue=new l9,e.baseEvaluateData.value=new l9,e.crossEvaluateData.value=new l9},i5._initializeLayerOwner=function(e){e.finalValue=new l9},i5._lerpValue=function(e,t,r,n){return l9.lerp(e,t,r,n),n},i5._relativeBaseValue=function(e,t){return l9.subtract(t,e,t),t},i5._additiveValue=function(e,t,r){return l9.scale(e,t,e),l9.add(r,e,r),r},i5._subtractValue=function(e,t,r){return l9.subtract(e,t,r),r},i5._getZeroValue=function(e){return e.set(0,0,0),e},i5._setValue=function(e,t){return t.copyFrom(e),t},i5._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,i},i5._isCopyMode=!0,i5._supportInterpolationMode=!0,i5),e.AnimationVector3Curve=cC([uA()],e.AnimationVector3Curve),e.AnimationVector4Curve=(cy(i8=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new cu,e},hF),i8._initializeOwner=function(e){e.defaultValue=new cu,e.fixedPoseValue=new cu,e.baseEvaluateData.value=new cu,e.crossEvaluateData.value=new cu},i8._initializeLayerOwner=function(e){e.finalValue=new cu},i8._lerpValue=function(e,t,r,n){return cu.lerp(e,t,r,n),n},i8._additiveValue=function(e,t,r){return cu.scale(e,t,e),cu.add(r,e,r),r},i8._subtractValue=function(e,t,r){return cu.subtract(e,t,r),r},i8._getZeroValue=function(e){return e.set(0,0,0,0),e},i8._setValue=function(e,t){return t.copyFrom(e),t},i8._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*n+_*m*n+f*s.w:i.w=a.w,i},i8._isCopyMode=!0,i8._supportInterpolationMode=!0,i8),e.AnimationVector4Curve=cC([uA()],e.AnimationVector4Curve),e.AnimationRefCurve=(cy(i6=function(){return hF.call(this)},hF),i6._initializeOwner=function(e){},i6._initializeLayerOwner=function(e){},i6._setValue=function(e){return e},i6._isCopyMode=!1,i6._supportInterpolationMode=!1,i6),e.AnimationRefCurve=cC([uA()],e.AnimationRefCurve),e.AnimationRectCurve=(cy(i7=function(){var e;return(e=hF.call(this)||this)._evaluateData.value=new ch,e},hF),i7._initializeOwner=function(e){e.defaultValue=new ch,e.fixedPoseValue=new ch,e.baseEvaluateData.value=new ch,e.crossEvaluateData.value=new ch},i7._initializeLayerOwner=function(e){e.finalValue=new ch},i7._setValue=function(e,t){return t.copyFrom(e),t},i7._isCopyMode=!0,i7._supportInterpolationMode=!1,i7),e.AnimationRectCurve=cC([uA()],e.AnimationRectCurve),e.AnimatorCullingMode=void 0,(i9=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[i9.None=0]="None",i9[i9.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(ae=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[ae.Override=0]="Override",ae[ae.Additive=1]="Additive",(at=lG||(lG={}))[at.UnStarted=0]="UnStarted",at[at.Playing=1]="Playing",at[at.Finished=2]="Finished",(ar=lH||(lH={}))[ar.Standby=0]="Standby",ar[ar.Playing=1]="Playing",ar[ar.CrossFading=2]="CrossFading",ar[ar.FixedCrossFading=3]="FixedCrossFading",ar[ar.Finished=4]="Finished";var hL=((an=function(){this.handlers=[]}).prototype.dispose=function(){},an),hD=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(ai=e.WrapMode||(e.WrapMode={}))[ai.Once=0]="Once",ai[ai.Loop=1]="Loop";var hB=((ao=(aa=function(){}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=lG.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0},ao.update=function(t){var r=this.state,n=this.frameTime,i=r._getDuration();this.playState=lG.Playing,r.wrapMode===e.WrapMode.Loop?n=i?n%i:0:Math.abs(n)>i&&(n=n<0?-i:i,this.playState=lG.Finished),t&&0===n?this.clipTime=r.clipEndTime*r.clip.length:(n<0&&(n+=i),this.clipTime=n+r.clipStartTime*r.clip.length)},aa),hI=((as=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new hB,this.destPlayData=new hB,this.layerState=lH.Standby,this.crossCurveMark=0,this.manuallyTransition=new hD,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},as),hV=function(){this.curveLayerOwner=[],this.eventHandlers=[]},hO=(cy(al=function(t){var r;return(r=cZ.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 ue(hL),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},cZ),(ac=al.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,i=this._getAnimatorStateInfo(e,t),a=i.state,o=i.layerIndex;if(a){if(!a.clip){cN.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,a,s,o);this._preparePlay(s,a),s.layerState=lH.Playing,s.srcPlayData.reset(a,l,a._getDuration()*r),this.update(0)}},ac.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var i,a=this._getAnimatorStateInfo(e,r),o=a.state,s=a.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._crossFadeByTransition(l,s)&&this.update(0)},ac.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,i=this._controlledRenderers,a=0,o=i.length;a<o;a++)if(!i[a].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!==lH.Standby&&this._updateLayer(l,0===l,t,n)}},ac.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},ac.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},ac._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},ac._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},ac._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},ac._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)},ac._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,i=null;if(r){var a=r.layers;if(-1===t){for(var o=0,s=a.length;o<s;o++)if(i=a[o].stateMachine.findStateByName(e)){t=o;break}}else i=a[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=i,n},ac._getAnimatorStateData=function(e,t,r,n){var i=r.animatorStateDataMap,a=i[e];return a||(a=new hV,i[e]=a,this._saveAnimatorStateData(t,a,r,n),this._saveAnimatorEventHandlers(t,a)),a},ac._saveAnimatorStateData=function(e,t,r,n){for(var i=this.entity,a=this._curveOwnerPool,o=t.curveLayerOwner,s=e.clip._curveBindings,l=r.curveOwnerPool,c=s.length-1;c>=0;c--){var u=s[c],d=""===u.relativePath?i:i.findByPath(u.relativePath);if(d){var h=d.getComponent(u.type);if(!h)continue;var _=u.property,f=d.instanceId,p=a[f]||(a[f]=Object.create(null)),m=p[_]||(p[_]=u._createCurveOwner(d,h)),g=l[f]||(l[f]=Object.create(null)),v=g[_]||(g[_]=u._createCurveLayerOwner(m));o[c]=v}else o[c]=null,cN.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},ac._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,i=[],a=t.eventHandlers,o=function(){r._entity.getComponents(d3,i);var t=i.length,o=e.clip.events;a.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.getFromPool(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=i[_][d];f&&h.push(f)}a.push(u)}};o(),e._updateFlagManager.addListener(o)},ac._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},ac._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},ac._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},ac._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},ac._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)},ac._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var i=r[n];i&&(i.crossCurveMark=e.crossCurveMark,t&&i.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,i,n,-1))}},ac._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var i=r[n];if(i){if(i.crossCurveMark===e.crossCurveMark)i.crossDestCurveIndex=n;else{var a=i.curveOwner;t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,n)}}}},ac._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new hI),t},ac._updateLayer=function(t,r,n,i){var a=this._animatorController.layers[t],o=a.blendingMode,s=a.weight,l=this._animatorLayersData[t],c=l.srcPlayData,u=l.destPlayData,d=o===e.AnimatorLayerBlendingMode.Additive;switch(r&&(s=1),l.layerState){case lH.Playing:this._updatePlayingState(c,l,t,s,n,d,i);break;case lH.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,n,d,i);break;case lH.CrossFading:this._updateCrossFade(c,u,l,t,s,n,d,i);break;case lH.Finished:this._updateFinishedState(c,s,d,i)}},ac._updatePlayingState=function(e,t,r,n,i,a,o){var s=e.stateData,l=s.curveLayerOwner,c=s.eventHandlers,u=e.state,d=e.playState,h=e.clipTime,_=u.transitions,f=u.clip._curveBindings,p=u.speed*this.speed;e.frameTime+=p*i,e.update(p<0);var m=e.clipTime,g=e.playState,v=g===lG.Finished;if(o||v)for(var y=f.length-1;y>=0;y--){var x=l[y],S=null==x?void 0:x.curveOwner;if(S){var C=f[y].curve;if(C.keys.length){this._checkRevertOwner(S,a);var T=S.evaluateValue(C,m,a);o&&S.applyValue(T,n,a),v&&x.saveFinalValue()}}}if(g===lG.Finished&&(t.layerState=lH.Finished),c.length&&this._fireAnimationEvents(e,c,h,m),d===lG.UnStarted&&this._callAnimatorScriptOnEnter(u,r),g===lG.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),_.length){var A=t.layerState;A!==lH.CrossFading&&A!==lH.FixedCrossFading&&this._checkTransition(e,_,r,h,m)}},ac._updateCrossFade=function(e,t,r,n,i,a,o,s){var l=this.speed,c=r.crossLayerOwnerCollection,u=e.state.clip._curveBindings,d=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,S=t.clipTime,C=p._getDuration()*r.crossFadeTransition.duration,T=Math.abs(t.frameTime)/C;(T>=1||0===C)&&(T=1);var A=d.speed*l,E=p.speed*l;e.frameTime+=A*a,t.frameTime+=E*a,e.update(A<0),t.update(E<0);var M=e.clipTime,R=e.playState,w=t.clipTime,b=t.playState,P=t.playState===lG.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?u[B].curve:null,I>=0?y[I].curve:null,M,w,T,o);s&&D.applyValue(V,i,o),P&&L.saveFinalValue()}}this._updateCrossFadeData(r,T),f.length&&this._fireAnimationEvents(e,f,x,M),v.length&&this._fireAnimationEvents(t,v,S,w),_===lG.UnStarted&&this._callAnimatorScriptOnEnter(d,n),1===T||R===lG.Finished?this._callAnimatorScriptOnExit(d,n):this._callAnimatorScriptOnUpdate(d,n),g===lG.UnStarted&&this._callAnimatorScriptOnEnter(p,n),b===lG.Finished?this._callAnimatorScriptOnExit(p,n):this._callAnimatorScriptOnUpdate(p,n)},ac._updateCrossFadeFromPose=function(e,t,r,n,i,a,o){var s=t.crossLayerOwnerCollection,l=e.state,c=e.stateData,u=e.playState,d=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*i,e.update(m<0);var g=e.clipTime,v=e.playState,y=v===lG.Finished;if(o||y)for(var x=s.length-1;x>=0;x--){var S=s[x],C=null==S?void 0:S.curveOwner;if(C){var T=S.crossDestCurveIndex;this._checkRevertOwner(C,a);var A=S.curveOwner.crossFadeFromPoseAndApplyValue(T>=0?h[T].curve:null,g,p,a);o&&C.applyValue(A,n,a),y&&S.saveFinalValue()}}this._updateCrossFadeData(t,p),d.length&&this._fireAnimationEvents(e,d,_,g),u===lG.UnStarted&&this._callAnimatorScriptOnEnter(l,r),v===lG.Finished?this._callAnimatorScriptOnExit(l,r):this._callAnimatorScriptOnUpdate(l,r)},ac._updateFinishedState=function(e,t,r,n){if(n)for(var i=e.stateData.curveLayerOwner,a=e.state.clip._curveBindings,o=a.length-1;o>=0;o--){var s=i[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},ac._updateCrossFadeData=function(e,t){var r=e.destPlayData;1===t&&(r.playState===lG.Finished?e.layerState=lH.Finished:e.layerState=lH.Playing,e.switchPlayData(),e.crossFadeTransition=null)},ac._preparePlay=function(e,t){if(e.layerState===lH.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,i=r.stateData.curveLayerOwner,a=i.length-1;a>=0;a--)null==(n=i[a])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},ac._checkTransition=function(e,t,r,n,i){var a=e.state,o=a.clip.length;this.speed*a.speed>=0?i<n?(this._checkSubTransition(e,t,r,n,a.clipEndTime*o),e.currentTransitionIndex=0,this._checkSubTransition(e,t,r,a.clipStartTime*o,i)):this._checkSubTransition(e,t,r,n,i):i>n?(this._checkBackwardsSubTransition(e,t,r,n,a.clipStartTime*o),e.currentTransitionIndex=t.length-1,this._checkBackwardsSubTransition(e,t,r,i,a.clipEndTime*o)):this._checkBackwardsSubTransition(e,t,r,n,i)},ac._checkSubTransition=function(e,t,r,n,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration(),s=t.length;a<s;a++){var l=t[a],c=l.exitTime*o;if(c>i)break;c>=n&&(this._crossFadeByTransition(l,r),e.currentTransitionIndex=Math.min(a+1,s-1))}},ac._checkBackwardsSubTransition=function(e,t,r,n,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration();a>=0;a--){var s=t[a],l=s.exitTime*o;if(l<i)break;l<=n&&(this._crossFadeByTransition(s,r),e.currentTransitionIndex=Math.max(a-1,0))}},ac._crossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return cN.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),i=n.layerState,a=n.destPlayData,o=this._getAnimatorStateData(r.name,r,n,t),s=r._getDuration()*e.offset;switch(a.reset(r,o,s),i){case lH.Standby:case lH.Finished:n.layerState=lH.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case lH.Playing:n.layerState=lH.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case lH.CrossFading:n.layerState=lH.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case lH.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},ac._fireAnimationEvents=function(e,t,r,n){var i=e.state,a=i.clip.length;this.speed*i.speed>=0?n<r?(this._fireSubAnimationEvents(e,t,r,i.clipEndTime*a),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,i.clipStartTime*a,n)):this._fireSubAnimationEvents(e,t,r,n):n>r?(this._fireBackwardSubAnimationEvents(e,t,r,i.clipStartTime*a),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,i.clipEndTime*a,n)):this._fireBackwardSubAnimationEvents(e,t,r,n)},ac._fireSubAnimationEvents=function(e,t,r,n){for(var i=e.currentEventIndex,a=t.length;i<a;i++){var o=t[i],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var u=o.handlers;if(l>=r){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(i+1,a-1)}}},ac._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var i=e.currentEventIndex;i>=0;i--){var a=t[i],o=a.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=a.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(i-1,0)}}},ac._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,i=r.length;n<i;n++)r[n].onStateEnter(this,e,t)},ac._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,i=r.length;n<i;n++)r[n].onStateUpdate(this,e,t)},ac._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,i=r.length;n<i;n++)r[n].onStateExit(this,e,t)},ac._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)}},ac._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},cg(al,[{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)}}]),al);cC([cE],hO.prototype,"speed",void 0),cC([cA],hO.prototype,"_controllerUpdateFlag",void 0),cC([cA],hO.prototype,"_updateMark",void 0),cC([cA],hO.prototype,"_animatorLayersData",void 0),cC([cA],hO.prototype,"_curveOwnerPool",void 0),cC([cA],hO.prototype,"_animationEventHandlerPool",void 0),cC([cA],hO.prototype,"_tempAnimatorStateInfo",void 0),cC([cA],hO.prototype,"_controlledRenderers",void 0);var hN=((ad=(au=function(){this._updateFlagManager=new c8,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},ad.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},ad.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},ad.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},ad._registerChangeFlag=function(){return this._updateFlagManager.createFlag(c5)},cg(au,[{key:"layers",get:function(){return this._layers}}]),au),hz=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},hU=((a_=(ah=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},a_.onStateUpdate=function(e,t,r){},a_.onStateExit=function(e,t,r){},a_.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},ah),hk=((ap=(af=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new c8,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 i=r;--i>=0&&n<t[i].exitTime;);t.splice(i+1,0,e)}},ap.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},ap.addStateMachineScript=function(e){var t=new e;t._state=this;var r=hU.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},ap.clearTransitions=function(){this._transitions.length=0},ap._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},ap._removeStateMachineScript=function(e){var t=hU.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 i=this._onStateExitScripts.indexOf(e);-1!==i&&this._onStateExitScripts.splice(i,1)}},ap._onClipChanged=function(){this._updateFlagManager.dispatch()},cg(af,[{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._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)}}]),af),hG=((ag=(am=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 hk(e),this.states.push(t),this._statesMap[e]=t),t},ag.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},ag.findStateByName=function(e){return this._statesMap[e]},ag.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},am);e.AnimatorConditionMode=void 0,(av=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[av.If=0]="If",av[av.IfNot=1]="IfNot",av[av.Greater=2]="Greater",av[av.Less=3]="Less",av[av.Equals=4]="Equals",av[av.NotEquals=5]="NotEquals";var hH=function(){},hW=function(t){function r(n){var i;return(i=t.call(this,n,uy.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new cd(1,1,1,1),i.renderState.rasterState.cullMode=e.CullMode.Off,i.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,i.shaderData.setFloat(r._rotationProp,0),i.shaderData.setFloat(r._exposureProp,1),i.shaderData.setColor(r._tintColorProp,i._tintColor),i}return cy(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},cg(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}(dL);hW._tintColorProp=cq.getByName("material_TintColor"),hW._textureCubeProp=cq.getByName("material_CubeTexture"),hW._rotationProp=cq.getByName("material_Rotation"),hW._exposureProp=cq.getByName("material_Exposure"),hW._decodeSkyRGBMMacro=ut.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(ay=e.SunMode||(e.SunMode={}))[ay.None=0]="None",ay[ay.Simple=1]="Simple",ay[ay.HighQuality=2]="HighQuality";var hX=(cy(ax=function(t){var r;return(r=dL.call(this,t,uy.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new cd(.5,.5,.5,1),r.groundTint=new cd(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},dL),ax.prototype.clone=function(){var e=new ax(this._engine);return this.cloneTo(e),e},cg(ax,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(ax._sunSimpleMacro),t.enableMacro(ax._sunHighQualityMacro);break;case 1:t.disableMacro(ax._sunHighQualityMacro),t.enableMacro(ax._sunSimpleMacro);break;case 0:t.disableMacro(ax._sunHighQualityMacro),t.disableMacro(ax._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(ax._sunSizeProp)},set:function(e){this.shaderData.setFloat(ax._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(ax._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(ax._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(ax._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(ax._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(ax._skyTintProp)},set:function(e){this.shaderData.setColor(ax._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(ax._groundTintProp)},set:function(e){this.shaderData.setColor(ax._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(ax._exposureProp)},set:function(e){this.shaderData.setFloat(ax._exposureProp,Math.min(Math.max(0,e),8))}}]),ax);hX._sunSizeProp=cq.getByName("material_SunSize"),hX._sunSizeConvergenceProp=cq.getByName("material_SunSizeConvergence"),hX._atmosphereThicknessProp=cq.getByName("material_AtmosphereThickness"),hX._skyTintProp=cq.getByName("material_SkyTint"),hX._groundTintProp=cq.getByName("material_GroundTint"),hX._exposureProp=cq.getByName("material_Exposure"),hX._sunHighQualityMacro=ut.getByName("MATERIAL_SUN_HIGH_QUALITY"),hX._sunSimpleMacro=ut.getByName("MATERIAL_SUN_SIMPLE");var hK=function(){};e.ParticleRenderMode=void 0,(aS=e.ParticleRenderMode||(e.ParticleRenderMode={}))[aS.Billboard=0]="Billboard",aS[aS.StretchBillboard=1]="StretchBillboard",aS[aS.HorizontalBillboard=2]="HorizontalBillboard",aS[aS.VerticalBillboard=3]="VerticalBillboard",aS[aS.Mesh=4]="Mesh",aS[aS.None=5]="None",e.ParticleStopMode=void 0,(aC=e.ParticleStopMode||(e.ParticleStopMode={}))[aC.StopEmittingAndClear=0]="StopEmittingAndClear",aC[aC.StopEmitting=1]="StopEmitting";var hj=function(t){function r(n){var i;return(i=t.call(this,n)||this).generator=new h9(cp(i)),i.velocityScale=0,i.lengthScale=2,i.pivot=new l9,i._currentRenderModeMacro=r._billboardModeMacro,i.shaderData.enableMacro(r._billboardModeMacro),i._supportInstancedArrays=i.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),i}cy(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){var t=this.shaderData;t.setFloat(r._lengthScale,this.lengthScale),t.setFloat(r._speedScale,this.velocityScale),t.setFloat(r._currentTime,this.generator._playTime),t.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(t)},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){r.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),this.generator._destroy()},cg(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var i=null,a=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:i=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:i=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==i&&(this._currentRenderModeMacro&&a.disableMacro(this._currentRenderModeMacro),i&&a.enableMacro(i),this._currentRenderModeMacro=i),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,null==r||r._addReferCount(-1),null==t||t._addReferCount(1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);hj._billboardModeMacro=ut.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),hj._stretchedBillboardModeMacro=ut.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),hj._horizontalBillboardModeMacro=ut.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),hj._verticalBillboardModeMacro=ut.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),hj._renderModeMeshMacro=ut.getByName("RENDERER_MODE_MESH"),hj._pivotOffsetProperty=cq.getByName("renderer_PivotOffset"),hj._lengthScale=cq.getByName("renderer_StretchedBillboardLengthScale"),hj._speedScale=cq.getByName("renderer_StretchedBillboardSpeedScale"),hj._currentTime=cq.getByName("renderer_CurrentTime"),cC([cR],hj.prototype,"generator",void 0),cC([cM],hj.prototype,"pivot",void 0),e.ParticleCurveMode=void 0,(aT=e.ParticleCurveMode||(e.ParticleCurveMode={}))[aT.Constant=0]="Constant",aT[aT.TwoConstants=1]="TwoConstants",aT[aT.Curve=2]="Curve",aT[aT.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(aA=e.ParticleGradientMode||(e.ParticleGradientMode={}))[aA.Constant=0]="Constant",aA[aA.TwoConstants=1]="TwoConstants",aA[aA.Gradient=2]="Gradient",aA[aA.TwoGradients=3]="TwoGradients",e.ParticleSimulationSpace=void 0,(aE=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[aE.Local=0]="Local",aE[aE.World=1]="World",(aM=lW||(lW={}))[aM.Burst=592910910]="Burst",aM[aM.StartDelay=322376503]="StartDelay",aM[aM.StartColor=306581307]="StartColor",aM[aM.StartSize=1793934638]="StartSize",aM[aM.StartRotation=3737431713]="StartRotation",aM[aM.randomizeRotationDirection=2527743459]="randomizeRotationDirection",aM[aM.StartLifetime=2368504881]="StartLifetime",aM[aM.StartSpeed=4085612399]="StartSpeed",aM[aM.VelocityOverLifetime=3774601268]="VelocityOverLifetime",aM[aM.ColorOverLifetime=326370691]="ColorOverLifetime",aM[aM.SizeOverLifetime=1494990940]="SizeOverLifetime",aM[aM.RotationOverLifetime=1089181156]="RotationOverLifetime",aM[aM.TextureSheetAnimation=197469413]="TextureSheetAnimation",aM[aM.Shape=2941263940]="Shape";var hY=((aw=(aR=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 i=e[r];this.addColorKey(i)}if(t)for(var a=0,o=t.length;a<o;a++){var s=t[a];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 hq(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},aw.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 hQ(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},aw.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},aw.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},aw.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,i=0,a=r.length;i<a;i++)r[i]._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 u=0,d=t.length;u<d;u++)this._addKey(n,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},aw._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,i=0,a=Math.min(n.length,4);i<a;i++){var o=4*i,s=n[i];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=cd.gammaToLinearSpace(l.r),r[o+2]=cd.gammaToLinearSpace(l.g),r[o+3]=cd.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},aw._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 i=2*r,a=t[r];e[i]=a.time,e[i+1]=a.alpha}this._alphaTypeArrayDirty=!1}return e},aw._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 i=n;--i>=0&&r<e[i].time;);e.splice(i+1,0,t)}},aw._removeKey=function(e,t){e.splice(t,1)},aw._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},aw._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},cg(aR,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),aR);cC([cR],hY.prototype,"_colorKeys",void 0),cC([cR],hY.prototype,"_alphaKeys",void 0),cC([cA],hY.prototype,"_colorTypeArray",void 0),cC([cA],hY.prototype,"_alphaTypeArray",void 0);var hq=(cg(ab=function(e,t){this._onValueChanged=null,this._color=new cd,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)}}]),ab),hQ=(cg(aP=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()}}]),aP),hZ=((aF=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new cd,this.constantMax=new cd,this.gradientMin=new hY,this.gradientMax=new hY,t.constructor===cd?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:cd.lerp(this.constantMin,this.constantMax,r,n)}},cg(aF,[{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}}]),aF);cC([cR],hZ.prototype,"constantMin",void 0),cC([cR],hZ.prototype,"constantMax",void 0),cC([cR],hZ.prototype,"gradientMin",void 0),cC([cR],hZ.prototype,"gradientMax",void 0);var hJ=((aL=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},aL);cC([cA],hJ.prototype,"_generator",void 0);var h$=(cy(aD=function(){var e;return e=hJ.apply(this,arguments)||this,e.color=new hZ(new hY([new hq(0,new cd(1,1,1)),new hq(1,new cd(1,1,1))],[new hQ(0,1),new hQ(1,1)])),e._colorGradientRand=new cf(0,lW.ColorOverLifetime),e._gradientKeysCount=new cu(0,0,0,0),e},hJ),(aB=aD.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 i=this.color,a=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(aD._maxGradientColor,i.gradientMax._getColorTypeArray(a)),t.setFloatArray(aD._maxGradientAlpha,i.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=aD._gradientMacro:(t.setFloatArray(aD._minGradientColor,i.gradientMin._getColorTypeArray(a)),t.setFloatArray(aD._minGradientAlpha,i.gradientMin._getAlphaTypeArray()),r=aD._randomGradientsMacro);var o=i.gradientMin.colorKeys,s=i.gradientMin.alphaKeys,l=i.gradientMax.colorKeys,c=i.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(aD._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},aB._resetRandomSeed=function(e){this._colorGradientRand.reset(e,lW.ColorOverLifetime)},aD);h$._gradientMacro=ut.getByName("RENDERER_COL_GRADIENT"),h$._randomGradientsMacro=ut.getByName("RENDERER_COL_RANDOM_GRADIENTS"),h$._minGradientColor=cq.getByName("renderer_COLMinGradientColor"),h$._minGradientAlpha=cq.getByName("renderer_COLMinGradientAlpha"),h$._maxGradientColor=cq.getByName("renderer_COLMaxGradientColor"),h$._maxGradientAlpha=cq.getByName("renderer_COLMaxGradientAlpha"),h$._gradientKeysCount=cq.getByName("renderer_COLGradientKeysMaxTime"),cC([cR],h$.prototype,"color",void 0),cC([cA],h$.prototype,"_colorGradientRand",void 0),cC([cA],h$.prototype,"_gradientKeysCount",void 0),cC([cA],h$.prototype,"_colorMacro",void 0);var h0=((aI=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}},cg(aI,[{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}}]),aI);cC([cR],h0.prototype,"curveMin",void 0),cC([cR],h0.prototype,"curveMax",void 0);var h1=(cy(aV=function(){var e;return e=hJ.apply(this,arguments)||this,e.rateOverTime=new h0(10),e.rateOverDistance=new h0(0),e._shapeRand=new cf(0,lW.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new cf(0,lW.Burst),e},hJ),(aO=aV.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)},aO.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},aO.removeBurstByIndex=function(e){this._bursts.splice(e,1)},aO.clearBurst=function(){this._bursts.length=0},aO._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},aO._resetRandomSeed=function(e){this._burstRand.reset(e,lW.Burst),this._shapeRand.reset(e,lW.Shape)},aO._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},aO._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,i=e-this._frameRateTime;i>=n;)i-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},aO._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,i=Math.floor((t-e)/n);if(r.isLoop&&(i>0||t%n<e%n)){var a=Math.ceil(e/n)*n;this._emitBySubBurst(e,a,n),this._currentBurstIndex=0;for(var o=0;o<i;o++){var s=a;a+=n,this._emitBySubBurst(s,a,n),this._currentBurstIndex=0}this._emitBySubBurst(a,t,n)}else this._emitBySubBurst(e,t,n)},aO._emitBySubBurst=function(e,t,r){for(var n=this._generator,i=this._burstRand,a=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,u=a.length;c<u;c++){var d=a[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,i.random());n._emit(o+h,_)}}this._currentBurstIndex=c},cg(aV,[{key:"bursts",get:function(){return this._bursts}}]),aV);cC([cR],h1.prototype,"rateOverTime",void 0),cC([cR],h1.prototype,"rateOverDistance",void 0),cC([cR],h1.prototype,"shape",void 0),cC([cA],h1.prototype,"_shapeRand",void 0),cC([cR],h1.prototype,"_bursts",void 0),cC([cA],h1.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(aN=e.ParticleScaleMode||(e.ParticleScaleMode={}))[aN.Hierarchy=0]="Hierarchy",aN[aN.Local=1]="Local",aN[aN.World=2]="World";var h2=((aU=(az=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new h0(0),this.startLifetime=new h0(5),this.startSpeed=new h0(5),this.startSize3D=!1,this.startSizeX=new h0(1),this.startSizeY=new h0(1),this.startSizeZ=new h0(1),this.startRotation3D=!1,this.startRotationX=new h0(0),this.startRotationY=new h0(0),this.startRotationZ=new h0(0),this.flipRotation=0,this.startColor=new hZ(new cd(1,1,1,1)),this.gravityModifier=new h0(0),this.simulationSpace=e.ParticleSimulationSpace.Local,this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new cf(0,lW.StartSpeed),this._startLifeTimeRand=new cf(0,lW.StartLifetime),this._startColorRand=new cf(0,lW.StartColor),this._startSizeRand=new cf(0,lW.StartSize),this._startRotationRand=new cf(0,lW.StartRotation),this._gravity=new l9,this._generator=t}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,lW.StartSpeed),this._startLifeTimeRand.reset(e,lW.StartLifetime),this._startColorRand.reset(e,lW.StartColor),this._startSizeRand.reset(e,lW.StartSize),this._startRotationRand.reset(e,lW.StartRotation)},aU._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}},aU._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(az._worldPosition,n.worldPosition);var i=n.worldRotationQuaternion,a=az._tempVector40;a.copyFrom(i),t.setVector4(az._worldRotation,a);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(az._positionScale,o),t.setVector3(az._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(az._positionScale,o),t.setVector3(az._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(az._positionScale,n.lossyWorldScale),t.setVector3(az._sizeScale,az._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,void 0);l9.scale(r.scene.physics.gravity,l,s),t.setVector3(az._gravity,s),t.setInt(az._simulationSpace,this.simulationSpace),t.setFloat(az._startRotation3D,+this.startRotation3D),t.setInt(az._scaleMode,this.scalingMode)},aU._cloneTo=function(e){e.maxParticles=this.maxParticles},cg(az,[{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}}]),az);h2._tempVector40=new cu,h2._vector3One=new l9(1,1,1),h2._positionScale=cq.getByName("renderer_PositionScale"),h2._sizeScale=cq.getByName("renderer_SizeScale"),h2._worldPosition=cq.getByName("renderer_WorldPosition"),h2._worldRotation=cq.getByName("renderer_WorldRotation"),h2._gravity=cq.getByName("renderer_Gravity"),h2._simulationSpace=cq.getByName("renderer_SimulationSpace"),h2._startRotation3D=cq.getByName("renderer_ThreeDStartRotation"),h2._scaleMode=cq.getByName("renderer_ScalingMode"),cC([cR],h2.prototype,"startDelay",void 0),cC([cR],h2.prototype,"startLifetime",void 0),cC([cR],h2.prototype,"startSpeed",void 0),cC([cR],h2.prototype,"startSizeX",void 0),cC([cR],h2.prototype,"startSizeY",void 0),cC([cR],h2.prototype,"startSizeZ",void 0),cC([cR],h2.prototype,"startRotationX",void 0),cC([cR],h2.prototype,"startRotationY",void 0),cC([cR],h2.prototype,"startRotationZ",void 0),cC([cR],h2.prototype,"startColor",void 0),cC([cR],h2.prototype,"gravityModifier",void 0),cC([cA],h2.prototype,"_maxParticleBuffer",void 0),cC([cA],h2.prototype,"_startSpeedRand",void 0),cC([cA],h2.prototype,"_startLifeTimeRand",void 0),cC([cA],h2.prototype,"_startColorRand",void 0),cC([cA],h2.prototype,"_startSizeRand",void 0),cC([cA],h2.prototype,"_startRotationRand",void 0),cC([cA],h2.prototype,"_generator",void 0),cC([cA],h2.prototype,"_gravity",void 0);var h3=(cy(ak=function(){var e;return e=hJ.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new h0(0),e.rotationY=new h0(0),e.rotationZ=new h0(45),e._rotationRand=new cf(0,lW.RotationOverLifetime),e._rotationMinConstant=new l9,e._rotationMaxConstant=new l9,e},hJ),(aG=ak.prototype)._updateShaderData=function(t){var r=null,n=null,i=null;if(this.enabled){var a=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?a.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?a.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(ak._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(ak._maxCurveXProperty,a.curveMax._getTypeArray()),t.setFloatArray(ak._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(ak._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(ak._minCurveXProperty,a.curveMin._getTypeArray()),t.setFloatArray(ak._minCurveYProperty,o.curveMin._getTypeArray())),i=ak._isRandomTwoMacro),n=ak._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(l7.degreeToRadian(a.constantMax),l7.degreeToRadian(o.constantMax),l7.degreeToRadian(s.constantMax)),t.setVector3(ak._maxConstantProperty,u),l?a.mode===e.ParticleCurveMode.TwoConstants&&o.mode===e.ParticleCurveMode.TwoConstants&&s.mode===e.ParticleCurveMode.TwoConstants:s.mode===e.ParticleCurveMode.TwoConstants){var d=this._rotationMinConstant;d.set(l7.degreeToRadian(a.constantMin),l7.degreeToRadian(o.constantMin),l7.degreeToRadian(s.constantMin)),t.setVector3(ak._minConstantProperty,d),i=ak._isRandomTwoMacro}n=ak._constantModeMacro}l&&(r=ak._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,i)},aG._resetRandomSeed=function(e){this._rotationRand.reset(e,lW.RotationOverLifetime)},ak);h3._constantModeMacro=ut.getByName("RENDERER_ROL_CONSTANT_MODE"),h3._curveModeMacro=ut.getByName("RENDERER_ROL_CURVE_MODE"),h3._isSeparateMacro=ut.getByName("RENDERER_ROL_IS_SEPARATE"),h3._isRandomTwoMacro=ut.getByName("RENDERER_ROL_IS_RANDOM_TWO"),h3._minConstantProperty=cq.getByName("renderer_ROLMinConst"),h3._minCurveXProperty=cq.getByName("renderer_ROLMinCurveX"),h3._minCurveYProperty=cq.getByName("renderer_ROLMinCurveY"),h3._minCurveZProperty=cq.getByName("renderer_ROLMinCurveZ"),h3._maxConstantProperty=cq.getByName("renderer_ROLMaxConst"),h3._maxCurveXProperty=cq.getByName("renderer_ROLMaxCurveX"),h3._maxCurveYProperty=cq.getByName("renderer_ROLMaxCurveY"),h3._maxCurveZProperty=cq.getByName("renderer_ROLMaxCurveZ"),cC([cR],h3.prototype,"rotationX",void 0),cC([cR],h3.prototype,"rotationY",void 0),cC([cR],h3.prototype,"rotationZ",void 0),cC([cA],h3.prototype,"_rotationRand",void 0),cC([cA],h3.prototype,"_rotationMinConstant",void 0),cC([cA],h3.prototype,"_rotationMaxConstant",void 0),cC([cA],h3.prototype,"_enableSeparateMacro",void 0),cC([cA],h3.prototype,"_isCurveMacro",void 0),cC([cA],h3.prototype,"_isRandomTwoMacro",void 0);var h4=((aW=(aH=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,i=t.length;n<i;n++){var a=t[n];this.addKey(a)}}).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 h5(e,t):e;this._addKey(r,n),this._typeArrayDirty=!0},aW.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0},aW.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},aW._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 i=2*r,a=t[r];e[i]=a.time,e[i+1]=a.value}this._typeArrayDirty=!1}return e},aW._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 i=r;--i>=0&&n<e[i].time;);e.splice(i+1,0,t)}},cg(aH,[{key:"keys",get:function(){return this._keys}}]),aH);cC([cR],h4.prototype,"_keys",void 0),cC([cA],h4.prototype,"_typeArray",void 0);var h5=function(e,t){this.time=e,this.value=t},h8=(cy(aX=function(){var e;return e=hJ.apply(this,arguments)||this,e.separateAxes=!1,e.sizeX=new h0(new h4(new h5(0,0),new h5(1,1))),e.sizeY=new h0(new h4(new h5(0,0),new h5(1,1))),e.sizeZ=new h0(new h4(new h5(0,0),new h5(1,1))),e},hJ),aX.prototype._updateShaderData=function(t){var r=null,n=null,i=null;if(this.enabled){var a=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?a.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:a.mode===e.ParticleCurveMode.TwoCurves;(c||l?a.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:a.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(aX._maxCurveXProperty,a.curveMax._getTypeArray()),l&&(t.setFloatArray(aX._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(aX._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(aX._minCurveXProperty,a.curveMin._getTypeArray()),l&&(t.setFloatArray(aX._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(aX._minCurveZProperty,s.curveMin._getTypeArray())),i=aX._isRandomTwoMacro),n=aX._curveModeMacro),l&&(r=aX._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,i)},cg(aX,[{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),aX);h8._curveModeMacro=ut.getByName("RENDERER_SOL_CURVE_MODE"),h8._isSeparateMacro=ut.getByName("RENDERER_SOL_IS_SEPARATE"),h8._isRandomTwoMacro=ut.getByName("RENDERER_SOL_IS_RANDOM_TWO"),h8._minCurveXProperty=cq.getByName("renderer_SOLMinCurveX"),h8._minCurveYProperty=cq.getByName("renderer_SOLMinCurveY"),h8._minCurveZProperty=cq.getByName("renderer_SOLMinCurveZ"),h8._maxCurveXProperty=cq.getByName("renderer_SOLMaxCurveX"),h8._maxCurveYProperty=cq.getByName("renderer_SOLMaxCurveY"),h8._maxCurveZProperty=cq.getByName("renderer_SOLMaxCurveZ"),cC([cR],h8.prototype,"sizeX",void 0),cC([cR],h8.prototype,"sizeY",void 0),cC([cR],h8.prototype,"sizeZ",void 0),cC([cA],h8.prototype,"_enableSeparateMacro",void 0),cC([cA],h8.prototype,"_isCurveMacro",void 0),cC([cA],h8.prototype,"_isRandomTwoMacro",void 0);var h6=(cy(aK=function(){var e;return e=hJ.apply(this,arguments)||this,e.startFrame=new h0(0),e.frameOverTime=new h0(new h4(new h5(0,0),new h5(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new l9(1,1,1),e._frameOverTimeRand=new cf(0,lW.TextureSheetAnimation),e._tiling=new cc(1,1),e},hJ),(aj=aK.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 i=this.frameOverTime;t.setFloatArray(aK._frameMaxCurveProperty,i.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=aK._frameCurveMacro:(t.setFloatArray(aK._frameMinCurveProperty,i.curveMin._getTypeArray()),r=aK._frameRandomCurvesMacro),t.setFloat(aK._cycleCountProperty,this.cycleCount),t.setVector3(aK._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},aj._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,lW.TextureSheetAnimation)},cg(aK,[{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)}}]),aK);h6._frameCurveMacro=ut.getByName("RENDERER_TSA_FRAME_CURVE"),h6._frameRandomCurvesMacro=ut.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),h6._cycleCountProperty=cq.getByName("renderer_TSACycles"),h6._tillingParamsProperty=cq.getByName("renderer_TSATillingParams"),h6._frameMinCurveProperty=cq.getByName("renderer_TSAFrameMinCurve"),h6._frameMaxCurveProperty=cq.getByName("renderer_TSAFrameMaxCurve"),cC([cR],h6.prototype,"startFrame",void 0),cC([cR],h6.prototype,"frameOverTime",void 0),cC([cM],h6.prototype,"_tillingInfo",void 0),cC([cA],h6.prototype,"_frameOverTimeRand",void 0),cC([cR],h6.prototype,"_tiling",void 0),cC([cA],h6.prototype,"_textureSheetMacro",void 0),(aY=lX||(lX={}))[aY.WholeSheet=0]="WholeSheet",aY[aY.SingleRow=1]="SingleRow";var h7=(cy(aq=function(){var t;return t=hJ.apply(this,arguments)||this,t.velocityX=new h0(0),t.velocityY=new h0(0),t.velocityZ=new h0(0),t.space=e.ParticleSimulationSpace.Local,t._velocityRand=new cf(0,lW.VelocityOverLifetime),t._velocityMinConstant=new l9,t._velocityMaxConstant=new l9,t},hJ),(aQ=aq.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,i=this.velocityY,a=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve)t.setFloatArray(aq._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(aq._maxGradientYProperty,i.curveMax._getTypeArray()),t.setFloatArray(aq._maxGradientZProperty,a.curveMax._getTypeArray()),o?(t.setFloatArray(aq._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(aq._minGradientYProperty,i.curveMin._getTypeArray()),t.setFloatArray(aq._minGradientZProperty,a.curveMin._getTypeArray()),r=aq._randomCurveMacro):r=aq._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,i.constantMax,a.constantMax),t.setVector3(aq._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,i.constantMin,a.constantMin),t.setVector3(aq._minConstantProperty,l),r=aq._randomConstantMacro}else r=aq._constantMacro}t.setInt(aq._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},aQ._resetRandomSeed=function(e){this._velocityRand.reset(e,lW.VelocityOverLifetime)},aq);h7._constantMacro=ut.getByName("RENDERER_VOL_CONSTANT"),h7._curveMacro=ut.getByName("RENDERER_VOL_CURVE"),h7._randomConstantMacro=ut.getByName("RENDERER_VOL_RANDOM_CONSTANT"),h7._randomCurveMacro=ut.getByName("RENDERER_VOL_RANDOM_CURVE"),h7._minConstantProperty=cq.getByName("renderer_VOLMinConst"),h7._maxConstantProperty=cq.getByName("renderer_VOLMaxConst"),h7._minGradientXProperty=cq.getByName("renderer_VOLMinGradientX"),h7._minGradientYProperty=cq.getByName("renderer_VOLMinGradientY"),h7._minGradientZProperty=cq.getByName("renderer_VOLMinGradientZ"),h7._maxGradientXProperty=cq.getByName("renderer_VOLMaxGradientX"),h7._maxGradientYProperty=cq.getByName("renderer_VOLMaxGradientY"),h7._maxGradientZProperty=cq.getByName("renderer_VOLMaxGradientZ"),h7._spaceProperty=cq.getByName("renderer_VOLSpace"),cC([cR],h7.prototype,"velocityX",void 0),cC([cR],h7.prototype,"velocityY",void 0),cC([cR],h7.prototype,"velocityZ",void 0),cC([cA],h7.prototype,"_velocityRand",void 0),cC([cA],h7.prototype,"_velocityMinConstant",void 0),cC([cA],h7.prototype,"_velocityMaxConstant",void 0),cC([cA],h7.prototype,"_velocityMacro",void 0);var h9=function(){function t(r){this.useAutoRandomSeed=!0,this.main=new h2(this),this.emission=new h1(this),this.velocityOverLifetime=new h7(this),this.sizeOverLifetime=new h8(this),this.rotationOverLifetime=new h3(this),this.colorOverLifetime=new h$(this),this.textureSheetAnimation=new h6(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new uL(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._renderer=r,new hK().start=0,this._primitive=new uD(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(hj,t._tempParticleRenderers),n=0,i=r.length;n<i;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 i=this._renderer.entity.getComponentsIncludeChildren(hj,t._tempParticleRenderers),a=0,o=i.length;a<o;a++)i[a].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,i=t._tempVector31,a=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(o){o._generatePositionAndDirection(this.emission._shapeRand,e,n,i);var l=this.main._getPositionScale();n.multiply(l),i.normalize().multiply(l)}else n.set(0,0,0),i.set(0,0,-1);this._addNewParticle(n,i,a,e)}},r._update=function(e){var t=this.main,r=this.emission,n=t.duration,i=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(i,this._playTime),!t.isLoop&&this._playTime>n&&(this._isPlaying=!1)),!this.isAlive){var a=Math.min(r._frameRateTime,Math.floor(this._playTime/n)*n);this._playTime-=a,r._frameRateTime-=a}(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,i=this._vertexBufferBindings;if(n.clearVertexElements(),i.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var a=t.mesh;if(!a)return;var o=a.getVertexElement(e.VertexAttribute.Position),s=a.getVertexElement(e.VertexAttribute.Color),l=a.getVertexElement(e.VertexAttribute.UV),c=o?a.vertexBufferBindings[o.bindingIndex]:null,u=s?a.vertexBufferBindings[s.bindingIndex]:null,d=l?a.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,i);n.addVertexElement(new ub(e.VertexAttribute.Position,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,i);n.addVertexElement(new ub(e.VertexAttribute.Color,s.offset,s.format,_))}if(d){var f=this._addVertexBufferBindingsFilterDuplicate(d,i);n.addVertexElement(new ub(e.VertexAttribute.UV,l.offset,l.format,f))}var p=a._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),i.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=r.billboardIndexCount;n.setVertexBufferBindings(i);for(var m=r.instanceVertexElements,g=i.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new ub(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,i=n.instanceVertexStride,a=t?this._currentParticleCount+r:this.main._maxParticleBuffer,o=i*a,s=this._renderer.engine,l=new uP(s,e.BufferBindFlag.VertexBuffer,o,e.BufferUsage.Dynamic,!1);l.isGCIgnored=!0;var c=this._primitive.vertexBufferBindings,u=new uI(l,i),d=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;d.set(new Float32Array(h.buffer,0,y));var x=(this._firstFreeElement+r)*m;d.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)),d.set(new Float32Array(h.buffer,v*m*4,f*m),p*m);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(h?c.length-1:c.length,u),this._instanceVertices=d,this._instanceVertexBufferBinding=u,this._currentParticleCount=a},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,i,a){var o,s,l=this._firstFreeElement,c=l+1;c>=this._currentParticleCount&&(c=0);var u=this.main;if(c===this._firstRetiredElement){var d=Math.min(t._particleIncreaseCount,u._maxParticleBuffer-this._currentParticleCount);if(0===d)return;this._resizeInstanceBuffer(!0,d),c=l+1}u.simulationSpace===e.ParticleSimulationSpace.World&&(o=i.worldPosition,s=i.worldRotationQuaternion);var h=this._renderer.engine._particleBufferUtils,_=u.startSpeed.evaluate(void 0,u._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]=u.startLifetime.evaluate(void 0,u._startLifeTimeRand.random()),f[p+4]=n.x,f[p+5]=n.y,f[p+6]=n.z,f[p+h.timeOffset]=a;var m=t._tempColor0;u.startColor.evaluate(void 0,u._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=u._startSizeRand;if(u.startSize3D)f[p+12]=u.startSizeX.evaluate(void 0,g.random()),f[p+13]=u.startSizeY.evaluate(void 0,g.random()),f[p+14]=u.startSizeZ.evaluate(void 0,g.random());else{var v=u.startSize.evaluate(void 0,g.random());f[p+12]=v,f[p+13]=v,f[p+14]=v}var y=u._startRotationRand;u.startRotation3D?(f[p+15]=l7.degreeToRadian(u.startRotationX.evaluate(void 0,y.random())),f[p+16]=l7.degreeToRadian(u.startRotationY.evaluate(void 0,y.random())),f[p+17]=l7.degreeToRadian(u.startRotationZ.evaluate(void 0,y.random()))):f[p+15]=l7.degreeToRadian(u.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 S=this.rotationOverLifetime;S.enabled&&S.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(f[p+22]=S._rotationRand.random());var C=this.textureSheetAnimation;C.enabled&&C.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(f[p+23]=C._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 A=T._velocityRand;f[p+24]=A.random(),f[p+25]=A.random(),f[p+26]=A.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 E=this.textureSheetAnimation._tillingInfo;f[p+h.simulationUVOffset]=E.x,f[p+35]=E.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 i=this._firstActiveElement*t.instanceVertexFloatStride,a=i+t.timeOffset;if(Math.fround(this._playTime-n[a])<n[i+t.startLifeTimeOffset])break;n[a]=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,i=t*n,a=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)a.setData(o,0,i,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;a.setData(o,0,i,s,e.SetDataOptions.Discard),r>0&&a.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},cg(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}();h9._tempVector30=new l9,h9._tempVector31=new l9,h9._tempColor0=new cd,h9._tempParticleRenderers=[],h9._particleIncreaseCount=128,cC([cR],h9.prototype,"main",void 0),cC([cR],h9.prototype,"emission",void 0),cC([cR],h9.prototype,"velocityOverLifetime",void 0),cC([cR],h9.prototype,"sizeOverLifetime",void 0),cC([cR],h9.prototype,"rotationOverLifetime",void 0),cC([cR],h9.prototype,"colorOverLifetime",void 0),cC([cR],h9.prototype,"textureSheetAnimation",void 0),cC([cA],h9.prototype,"_playTime",void 0),cC([cA],h9.prototype,"_firstNewElement",void 0),cC([cA],h9.prototype,"_firstActiveElement",void 0),cC([cA],h9.prototype,"_firstFreeElement",void 0),cC([cA],h9.prototype,"_firstRetiredElement",void 0),cC([cA],h9.prototype,"_primitive",void 0),cC([cA],h9.prototype,"_vertexBufferBindings",void 0),cC([cA],h9.prototype,"_subPrimitive",void 0),cC([cA],h9.prototype,"_renderer",void 0),cC([cA],h9.prototype,"_isPlaying",void 0),cC([cA],h9.prototype,"_instanceBufferResized",void 0),cC([cA],h9.prototype,"_waitProcessRetiredElementCount",void 0),cC([cA],h9.prototype,"_instanceVertexBufferBinding",void 0),cC([cA],h9.prototype,"_instanceVertices",void 0);var _e=(cy(aZ=function(e){var t;return(t=hp.call(this,e,uy.find("particle-shader"))||this).shaderData.setColor(hp._baseColorProp,new cd(1,1,1,1)),t.isTransparent=!0,t},hp),aZ.prototype.clone=function(){var e=new aZ(this._engine);return this.cloneTo(e),e},cg(aZ,[{key:"baseColor",get:function(){return this.shaderData.getColor(hp._baseColorProp)},set:function(e){var t=this.shaderData.getColor(hp._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(hp._baseTextureProp)},set:function(e){this.shaderData.setTexture(hp._baseTextureProp,e),e?this.shaderData.enableMacro(hp._baseTextureMacro):this.shaderData.disableMacro(hp._baseTextureMacro)}}]),aZ),_t=function(e,t){this.time=e,this.count=t};cC([cR],_t.prototype,"count",void 0);var _r=((aJ=function(){this.enable=!0,this.randomDirectionAmount=0}).prototype._generatePositionAndDirection=function(e,t,r,n){throw Error("BaseShape: must override it.")},aJ),_n=((a$=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},a$.randomPointInsideUnitArcCircle=function(e,t,r){a$.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},a$.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},a$.randomPointInsideUnitCircle=function(e,t){a$.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},a$._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,i=Math.sqrt(1-r*r);e.x=i*Math.cos(n),e.y=i*Math.sin(n),e.z=r},a$._randomPointInsideUnitSphere=function(e,t){a$._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},a$._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},a$);(a0=lK||(lK={}))[a0.Box=0]="Box",a0[a0.Circle=1]="Circle",a0[a0.Cone=2]="Cone",a0[a0.Hemisphere=3]="Hemisphere",a0[a0.Sphere=4]="Sphere";var _i=(cy(a1=function(){var e;return(e=_r.call(this)||this).size=new l9(1,1,1),e.shapeType=lK.Box,e},_r),a1.prototype._generatePositionAndDirection=function(e,t,r,n){_n._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var i=a1._tempVector30;i.set(0,0,-1),_n._randomPointUnitSphere(n,e),l9.lerp(i,n,this.randomDirectionAmount,n)},a1);_i._tempVector30=new l9,cC([cR],_i.prototype,"size",void 0),e.ParticleShapeArcMode=void 0,(a2=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[a2.Random=0]="Random",a2[a2.Loop=1]="Loop";var _a=(cy(a3=function(){var t;return(t=_r.call(this)||this).radius=1,t.arc=360,t.arcMode=e.ParticleShapeArcMode.Random,t.arcSpeed=1,t.shapeType=lK.Circle,t},_r),a3.prototype._generatePositionAndDirection=function(t,r,n,i){var a=a3._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=l7.degreeToRadian(this.arc*o);a.set(Math.cos(s),Math.sin(s)),a.scale(t.random());break;case e.ParticleShapeArcMode.Random:_n.randomPointInsideUnitArcCircle(l7.degreeToRadian(this.arc),a,t)}n.set(a.x,a.y,0),n.scale(this.radius),_n._randomPointUnitSphere(i,t),l9.lerp(n,i,this.randomDirectionAmount,i)},a3);_a._tempPositionPoint=new cc;var _o=(cy(a4=function(){var e;return(e=_r.call(this)||this).angle=25,e.radius=1,e.length=5,e.emitType=0,e.shapeType=lK.Cone,e},_r),a4.prototype._generatePositionAndDirection=function(e,t,r,n){var i=a4._tempVector20,a=l7.degreeToRadian(this.angle),o=Math.sin(a),s=Math.cos(a);switch(this.emitType){case 0:_n.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0);var l=a4._tempVector21;_n.randomPointInsideUnitCircle(l,e),cc.lerp(i,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:_n.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0),n.set(i.x*o,i.y*o,-s),n.normalize();var c=a4._tempVector30;l9.scale(n,this.length*e.random(),c),r.add(c);var u=a4._tempVector31;_n._randomPointUnitSphere(u,e),l9.lerp(n,u,this.randomDirectionAmount,n)}},a4);_o._tempVector20=new cc,_o._tempVector21=new cc,_o._tempVector30=new l9,_o._tempVector31=new l9,e.ConeEmitType=void 0,(a5=e.ConeEmitType||(e.ConeEmitType={}))[a5.Base=0]="Base",a5[a5.Volume=1]="Volume";var _s=(cy(a8=function(){var e;return(e=_r.call(this)||this).radius=1,e.shapeType=lK.Hemisphere,e},_r),a8.prototype._generatePositionAndDirection=function(e,t,r,n){_n._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var i=r.z;i>0&&(r.z=-i),_n._randomPointUnitSphere(n,e),l9.lerp(r,n,this.randomDirectionAmount,n)},a8),_l=(cy(a6=function(){var e;return(e=_r.call(this)||this).radius=1,e.shapeType=lK.Sphere,e},_r),a6.prototype._generatePositionAndDirection=function(e,t,r,n){_n._randomPointInsideUnitSphere(r,e),r.scale(this.radius),_n._randomPointUnitSphere(n,e),l9.lerp(r,n,this.randomDirectionAmount,n)},a6);uy.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 _c=(cy(a7=function(t){var r,n=(r=dL.call(this,t,uy.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},dL),a7),_u=new l9,_d=(cy(a9=function(e,t){(r=uz.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 l9),r._pointStates.push(r._lifetime),r._strapPoints.push(new l9),r._strapPoints.push(new l9);r._curPointNum=0;var i=t.material||new _c(r.engine);return r.setMaterial(i),r.setTexture(t.texture),r._initGeometry(),r},uz),(oe=a9.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 i=!0;if(this._curPointNum===this._maxPointNum)i=!1;else if(this._curPointNum>0){var a=this._points[this._points.length-1];l9.distance(this.entity.transform.worldPosition,a)<this._minSeg&&(i=!1)}i&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},oe.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},oe._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),uz.prototype._render.call(this,e)},oe._initGeometry=function(){var t=new uN(this._entity.engine),r=2*this._maxPointNum,n=20*r,i=new Float32Array(n),a=[new ub("POSITION",0,e.VertexElementFormat.Vector3,0),new ub("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new uP(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(a),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=i,this.mesh=t},oe._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new l9(r[0],r[4],r[8]),i=new l9(r[1],r[5],r[9]),a=new l9(r[2],r[6],r[10]),o=this._stroke;i.scale(o);var s=new l9,l=new l9,c=new co;l9.transformByQuat(n,c,n),l9.transformByQuat(i,c,i);var u=new l9,d=new l9,h=new l9;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?l9.subtract(p,t[f-1],h):l9.subtract(t[f+1],p,h),this._projectOnPlane(h,a,h),h.normalize();var m=Math.acos(l9.dot(n,h));l9.cross(n,h,d),0>=l9.dot(d,a)&&(m=2*Math.PI-m),co.rotationAxisAngle(a,m,c),l9.transformByQuat(i,c,u),l9.add(p,u,s),l9.subtract(p,u,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}},oe._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 i=1-n*t,a=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[a]=0,r[a+1]=i,r[o]=1,r[o+1]=i}}},oe._projectOnVector=function(e,t,r){var n=t.clone();l9.normalize(n,n);var i=l9.dot(e,n);r.x=n.x*i,r.y=n.y*i,r.z=n.z*i},oe._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,_u),l9.subtract(e,_u,r)},a9),_h=(cy(ot=function(){var t;return t=d3.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},d3),(or=ot.prototype).onTextureChange=function(e){},or.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 cU(this.engine,this.width,this.height,this._isCube?new cH(this.engine,this.width):new ck(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new cU(this.engine,this.width,this.height,this._isCube?new cH(this.engine,this.width):new ck(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},or.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},or._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},cg(ot,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),ot),__=new l9,_f=new l9,_p=new l9,_m=(cy(on=function(){var e;return e=_h.apply(this,arguments)||this,e.position=new l9(0,0,0),e._isCube=!0,e.oriViewMatrix=new cs,e},_h),(oi=on.prototype).onBeginRender=function(t){if(this.enabled){_h.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),_h.prototype._reset.call(this)}},oi._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},oi._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},oi._setCamera=function(e,t){switch(e){case 0:_f.set(0,-1,0),_p.set(1,0,0);break;case 1:_f.set(0,-1,0),_p.set(-1,0,0);break;case 2:_f.set(0,0,1),_p.set(0,1,0);break;case 3:_f.set(0,0,-1),_p.set(0,-1,0);break;case 4:_f.set(0,-1,0),_p.set(0,0,1);break;case 5:_f.set(0,-1,0),_p.set(0,0,-1)}l9.add(this.position,_p,__),cs.lookAt(this.position,__,_f,t.viewMatrix),t.fieldOfView=90},on),_g=Object.freeze({__proto__:null,AmbientLight:dQ,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:hP,AnimationClipCurveBinding:hw,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:hF,AnimationEvent:hb,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 AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:hO,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hN,AnimatorControllerLayer:hz,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:hk,AnimatorStateMachine:hG,AnimatorStateTransition:hD,AssetPromise:de,get AssetType(){return e.AssetType},Background:dY,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:hp,Basic2DBatcher:u2,BasicRenderPipeline:ho,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:uO,BlendShapeFrame:uV,BlendState:uf,BlinnPhongMaterial:hm,BoolUpdateFlag:c5,BoxColliderShape:dE,BoxShape:_i,Buffer:uP,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:uN,get BufferUsage(){return e.BufferUsage},BufferUtil:uw,Burst:_t,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},Canvas:dK,CapsuleColliderShape:dw,CharacterController:d_,CircleShape:_a,CloneManager:cw,get Collider(){return e.Collider},ColliderShape:dA,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:h$,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:cZ,get ConeEmitType(){return e.ConeEmitType},ConeShape:_o,ContentRestorer:cF,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:_m,get CullMode(){return e.CullMode},CurveKey:h5,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:up,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:dJ,DynamicCollider:df,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:h1,Engine:dX,EngineObject:cb,Entity:c9,EventDispatcher:cY,FixedJoint:dy,get FogMode(){return e.FogMode},Font:cj,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:hQ,GradientColorKey:hq,HemisphereShape:_s,HingeJoint:dx,HitResult:dp,IndexBufferBinding:uF,get IndexFormat(){return e.IndexFormat},InputManager:dF,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:dC,JointMotor:dT,Keyframe:hH,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:dZ,Loader:hf,Logger:cN,MainModule:h2,Material:dL,Mesh:uB,MeshRenderer:uz,get MeshTopology(){return e.MeshTopology},ModelMesh:uk,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:hg,PBRMaterial:hv,PBRSpecularMaterial:hy,ParticleCompositeCurve:h0,ParticleCompositeGradient:hZ,ParticleCurve:h4,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:h9,ParticleGradient:hY,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_e,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:hj,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:dm,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:dh,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:dR,get Platform(){return e.Platform},PointLight:d$,Pointer:ds,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:uD,PrimitiveMesh:u$,Probe:_h,RasterState:um,ReferResource:cP,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:d5,RenderQueue:d6,get RenderQueueType(){return e.RenderQueueType},RenderState:uv,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:cU,RenderTargetBlendState:u_,get Renderer(){return e.Renderer},ResourceManager:dt,RotationOverLifetimeModule:h3,Scene:d2,SceneManager:u9,Script:d3,get SetDataOptions(){return e.SetDataOptions},Shader:uy,ShaderData:ux,ShaderFactory:ua,ShaderMacro:ut,ShaderMacroCollection:ur,ShaderPass:ud,ShaderProperty:cq,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:uo,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:h8,Skin:u0,SkinnedMeshRenderer:u1,Sky:dj,SkyBoxMaterial:hW,SkyProceduralMaterial:hX,SphereColliderShape:dM,SphereShape:_l,SpotLight:d0,SpringJoint:dS,Sprite:dN,SpriteAtlas:dO,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:uR,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:dk,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:hU,StaticCollider:dg,get StencilOperation(){return e.StencilOperation},StencilState:ug,SubMesh:uL,SubShader:uh,get SunMode(){return e.SunMode},SystemInfo:du,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:dW,TextUtils:cX,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:cz,Texture2D:ck,Texture2DArray:cG,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:cH,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:h6,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:cQ,TrailMaterial:_c,TrailRenderer:_d,Transform:c6,UnlitMaterial:hx,Utils:c1,VelocityOverLifetimeModule:h7,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:uI,VertexElement:ub,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:cE,deepClone:cR,dependentComponents:c$,ignoreClone:cA,request:hu,resourceLoader:dr,shallowClone:cM});function _v(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 _y(e,t,r){return t&&_v(e.prototype,t),r&&_v(e,r),e}function _x(e,t){return(_x=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _S(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&&_x(e,t)}function _C(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oa=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oa.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oa[oa.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oa[oa.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oa[oa.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oa[oa.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oa[oa.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oa[oa.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oa[oa.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oa[oa.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oa[oa.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oa[oa.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oa[oa.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oa[oa.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oa[oa.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oa[oa.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oa[oa.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oa[oa.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oa[oa.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oa[oa.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oa[oa.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oa[oa.R11_EAC=37488]="R11_EAC",oa[oa.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oa[oa.RG11_EAC=37490]="RG11_EAC",oa[oa.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oa[oa.RGB8_ETC2=37492]="RGB8_ETC2",oa[oa.SRGB8_ETC2=37493]="SRGB8_ETC2",oa[oa.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oa[oa.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oa[oa.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oa[oa.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oa[oa.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oa[oa.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oa[oa.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oa[oa.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oa[oa.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oa[oa.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oa[oa.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oa[oa.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oa[oa.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oa[oa.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oa[oa.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oa[oa.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var _T=(_S(oo=function(e){(t=dK.call(this)||this)._scale=new cc;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},dK),(os=oo.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&_C(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},os.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},os._onWidthChanged=function(e){this._webCanvas.width=e},os._onHeightChange=function(e){this._webCanvas.height=e},_y(oo,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&_C(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&&_C(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),oo),_A=(_S(ol=function(){return dX.apply(this,arguments)},dX),ol.create=function(e){var t=e.canvas,r=new _T("string"==typeof t?document.getElementById(t):t),n=new _V(e.graphicDeviceOptions),i=new ol(r,n,e);return i._initialize(e).then(function(){return i.sceneManager.addScene(new d2(i,"DefaultScene")),i})},_y(ol,[{key:"canvas",get:function(){return this._canvas}}]),ol);function _E(){return(_E=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 _M=((ou=(oc=function(t,r,n,i,a){void 0===i&&(i=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,i),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(),a?o.bufferData(c,a,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},ou.setData=function(t,r,n,i,a,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,u=a?c*a:r.byteLength;if(0!==i||u<r.byteLength){var d=void 0!==r.byteOffset;if(this._isWebGL2&&d)s.bufferSubData(l,n,r,i,u/c);else{var h=new Uint8Array(d?r.buffer:r,i*c,u);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},ou.getData=function(e,t,r,n){if(this._isWebGL2){var i=this._gl;this.bind(),i.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},ou.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},ou._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),_R=((oh=(od=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oh.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,a=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,u=e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,d=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>=i&&t<=a?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=u?this.canIUse(e.GLCapabilityType.pvrtc):t>=d&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oh._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),i=e.GLCapabilityType.shaderVertexID,a=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,u=e.GLCapabilityType.instancedArrays,d=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,S=e.GLCapabilityType.pvrtc_webkit,C=e.GLCapabilityType.s3tc,T=e.GLCapabilityType.s3tc_webkit,A=e.GLCapabilityType.bptc,E=e.GLCapabilityType.textureFloat,M=e.GLCapabilityType.textureHalfFloat,R=e.GLCapabilityType.textureFloatLinear,w=e.GLCapabilityType.textureHalfFloatLinear,b=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic;t.set(i,r),t.set(a,r||!!n(a)),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(u,r||!!n(u)),t.set(d,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(E,r||!!n(E)),t.set(M,r||!!n(M)),t.set(R,!!n(R)),t.set(w,r||!!n(w)),t.set(P,r&&!!n(P)||!!n(b)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),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(S))),t.set(C,!!(n(C)||n(T))),t.set(A,!!n(A))},oh._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,i=null;if(i=r.requireExtension(e))for(var a in t){var o=i[t[a]];(null==o?void 0:o.bind)?n[a]=o.bind(i):n[a]=o}},oh._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,i=e.GLCapabilityType.drawBuffers,a=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(i,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var u={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var d=this.maxDrawBuffers,h=0;h<d;h++)0!=h&&(u["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),u["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(i,_E({drawBuffers:"drawBuffersWEBGL"},u))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},_y(od,[{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}}]),od),_w=((o_=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]},o_),_b=((op=(of=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,i=this._isSupportVAO&&n.enableVAO;if(i){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var a=this._vaoMap.get(e.id);r.bindVertexArray(a)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)r.drawElementsInstanced(u,h,l,d*c,s);else{var _=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,_),r.drawElementsInstanced(u,h,l,d*c,s),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArraysInstanced(u,d,h,s)}else cN.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(i)r.drawElements(u,h,l,d*c);else{var f=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,f),r.drawElements(u,h,l,d*c),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArrays(u,d,h);i?r.bindVertexArray(null):this._disableAttrib()},op.destroy=function(){this._isSupportVAO&&this._clearVAO()},op._bindBufferAndAttrib=function(e){var t,r,n=this._gl,i=this._primitive,a=i.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=i._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=a[u.bindingIndex],h=d.buffer,_=d.stride;r!==(t=h._platformBuffer._glBuffer)&&(r=t,n.bindBuffer(n.ARRAY_BUFFER,t)),n.enableVertexAttribArray(c);var f=u._formatMetaInfo;n.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&n.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else cN.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},op._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},op._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)},op._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},of),_P=((om=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]},om),_F=((ov=(og=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},ov.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},ov.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},ov._bind=function(){this._rhi.bindTexture(this)},ov._init=function(t){var r=this._gl,n=this._isWebGL2,i=this._formatDetail,a=i.internalFormat,o=i.baseFormat,s=i.dataType,l=this._texture,c=l.mipmapCount,u=l.width,d=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,a,u,d);else if(t)for(var f=0;f<c;f++)for(var p=Math.max(1,u>>f),m=0;m<6;m++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+m,f,a,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,a,u,d,0,o,s,null);else for(var g=0;g<c;g++){var v=Math.max(1,u>>g),y=Math.max(1,d>>g);r.texImage2D(this._target,g,a,v,y,0,o,s,null)}},ov._getPixelBuffer=function(e,t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,cN.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,a):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,a),s.readPixels(t,r,n,i,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},ov._setWrapMode=function(t,r){var n=this._gl,i=this._isWebGL2,a=this._target,o=this._texture,s=o.width,l=o.height;switch(i||t===e.TextureWrapMode.Clamp||og._isPowerOf2(s)&&og._isPowerOf2(l)||(cN.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(a,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(a,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(a,r,n.MIRRORED_REPEAT)}},ov._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},og._isPowerOf2=function(e){return(e&e-1)==0},og._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.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)}},og._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.RenderBufferDepthFormat.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.RenderBufferDepthFormat.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.RenderBufferDepthFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.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.RenderBufferDepthFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.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)}},og._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.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},og._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},og._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.RenderBufferDepthFormat.Depth24:case e.RenderBufferDepthFormat.Depth32:case e.RenderBufferDepthFormat.Depth32Stencil8:return!1}return!0},_y(og,[{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,i=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,i?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,i?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,i?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)}}}]),og),_L=((ox=(oy=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,i=r._depth,a=r.width,o=r.height,s=_C(i,cz),l=0,c=n.length;l<c;l++){var u=n[l]._format;if(!_F._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!_F._supportRenderBufferDepthFormat(i,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[i]+" 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!==a||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(i.width!==a||i.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return _C(e,cH)}))throw Error("MRT+Cube+[,MSAA] is not supported");var d=t.capability.maxAntiAliasing;r.antiAliasing>d&&(cN.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+d),r._antiAliasing=d),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),r.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).setRenderTargetInfo=function(e,t){var r=this._gl,n=this._target,i=n.depthTexture,a=n.getColorTexture(0),o=t!==this._curMipLevel;if(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),a){var s=_C(a,cH);(o||s)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+e:r.TEXTURE_2D,a._platformTexture._glTexture,t)}if(i){var l=_C(i,cH);if(o||l){var c=i._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,c._formatDetail.attachment,l?r.TEXTURE_CUBE_MAP_POSITIVE_X+e:r.TEXTURE_2D,c._glTexture,t)}}else if(o){var u=_F._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,u,n.width>>t,n.height>>t)}this._curMipLevel=t,this._activeRenderTarget()},ox.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,i=r.width,a=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,i,a,0,0,i,a,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},ox.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},ox._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},ox._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,i=r.colorTextureCount,a=r.width,o=r.height,s=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<i;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,_C(c,cH)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(_C(n,cz)&&!_C(n,cH)){var d=n._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=_F._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},ox._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,i=n._depth,a=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(a),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<a;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var d=_C(i,cz)?i._platformTexture._formatDetail:_F._getRenderBufferDepthFormatDetail(i,e,t),h=d.internalFormat,_=d.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)},ox._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.")},oy),_D=(_S(oS=function(t,r){(n=_F.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,i=r.format,a=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!_F._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||_F._isPowerOf2(o)&&_F._isPowerOf2(s)||(cN.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=_F._getFormatDetail(i,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},_F),(oC=oS.prototype).setPixelBuffer=function(e,t,r,n,i,a){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(i=i||_-r,a=a||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,i,a,c,e):(o.compressedTexImage2D(this._target,t,c,i,a,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,i,a,u,d,e)},oC.setImageSource=function(t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,u,d,t):s.texSubImage2D(this._target,r,a||0,o||0,u,d,t)},oC.getPixelBuffer=function(e,t,r,n,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_F.prototype._getPixelBuffer.call(this,null,e,t,r,n,i,a)},oS),_B=(_S(oT=function(t,r){n=_F.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,i=r.format,a=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(!_F._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return n._bind(),n._formatDetail=_F._getFormatDetail(i,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,a,o,s),n},_F),(oA=oT.prototype).setPixelBuffer=function(e,t,r,n,i,a,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;a=a||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-i,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,i,e,a,o,s,d,t):c.texSubImage3D(l,r,n,i,e,a,o,s,h,_,t)},oA.setImageSource=function(e,t,r,n,i,a,o){var s,l,c=this._gl,u=this._formatDetail,d=u.baseFormat,h=u.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+n),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),c.texSubImage3D(this._target,r,a,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},oA.getPixelBuffer=function(e,t,r,n,i,a,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,a,e),s.readPixels(t,r,n,i,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oT),_I=(_S(oE=function(t,r){(n=_F.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,i=r.format,a=r._mipmap,o=r.width,s=n._isWebGL2;if(!_F._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||_F._isPowerOf2(o)||(cN.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=_F._getFormatDetail(i,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},_F),(oM=oE.prototype).setPixelBuffer=function(e,t,r,n,i,a,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,d=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>r);if(a=a||f-n,o=o||f-i,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,i,a,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,u,a,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,i,a,o,d,h,t)},oM.setImageSource=function(e,t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,a||0,o||0,c,u,t)},oM.getPixelBuffer=function(e,t,r,n,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_F.prototype._getPixelBuffer.call(this,e,t,r,n,i,a,o)},oE);e.WebGLMode=void 0,(oR=e.WebGLMode||(e.WebGLMode={}))[oR.Auto=0]="Auto",oR[oR.WebGL2=1]="WebGL2",oR[oR.WebGL1=2]="WebGL1";var _V=((ob=(ow=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new cu(null,null,null,null),this._lastScissor=new cu(null,null,null,null),this._lastClearColor=new cd(null,null,null,null),this._scissorEnable=!1;var r=_E({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(du.platform===e.Platform.IPhone||du.platform===e.Platform.IPad){var n=du.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var i=parseInt(n[1]),a=parseInt(n[2]);15===i&&a>=0&&a<=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,i=this._options,a=e._webCanvas,o=i.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,a.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),a.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),a.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=a,(0==o||1==o)&&((n=a.getContext("webgl2",i))||"undefined"!=typeof OffscreenCanvas&&_C(a,OffscreenCanvas)||(n=a.getContext("experimental-webgl2",i)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=a.getContext("webgl",i))||"undefined"!=typeof OffscreenCanvas&&_C(a,OffscreenCanvas)||(n=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},ob.createPlatformPrimitive=function(e){return new _b(this,e)},ob.createPlatformTexture2D=function(e){return new _D(this,e)},ob.createPlatformTexture2DArray=function(e){return new _B(this,e)},ob.createPlatformTextureCube=function(e){return new _I(this,e)},ob.createPlatformRenderTarget=function(e){return new _L(this,e)},ob.createPlatformBuffer=function(t,r,n,i){return void 0===n&&(n=e.BufferUsage.Static),new _M(this,t,r,n,i)},ob.requireExtension=function(e){return this._extensions.requireExtension(e)},ob.canIUse=function(e){return this.capability.canIUse(e)},ob.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},ob.viewport=function(e,t,r,n){var i=this._gl,a=this._lastViewport;(e!==a.x||t!==a.y||r!==a.z||n!==a.w)&&(i.viewport(e,t,r,n),a.set(e,t,r,n))},ob.scissor=function(e,t,r,n){var i=this._gl,a=this._lastScissor;if(e!==a.x||t!==a.y||r!==a.z||n!==a.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(i.disable(i.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(i.enable(i.SCISSOR_TEST),this._scissorEnable=!0),i.scissor(e,t,r,n)),a.set(e,t,r,n)}},ob.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},ob.clearRenderTarget=function(t,r,n){var i=this._gl,a=t._lastRenderState,o=a.blendState.targetBlendState,s=a.depthState,l=a.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=i.COLOR_BUFFER_BIT;var u=this._lastClearColor,d=n.r,h=n.g,_=n.b,f=n.a;n&&(d!==u.r||h!==u.g||_!==u.b||f!==u.a)&&(i.clearColor(d,h,_,f),u.set(d,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(i.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=i.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(i.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=i.STENCIL_BUFFER_BIT,255!==l.writeMask&&(i.stencilMask(255),l.writeMask=255)),i.clear(c)},ob.drawPrimitive=function(e,t,r){e?e.draw(r,t):cN.error("draw primitive failed.")},ob.activeRenderTarget=function(e,t,r){var n,i,a,o=this._gl;e?(null==(a=e._platformRenderTarget)||a._activeRenderTarget(),n=e.width>>r,i=e.height>>r):(o.bindFramebuffer(o.FRAMEBUFFER,null),n=o.drawingBufferWidth,i=o.drawingBufferHeight);var s=n*t.z,l=i*t.w,c=t.x*n,u=i-t.y*i-l;this.viewport(c,u,s,l),this.scissor(c,u,s,l)},ob.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},ob.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)},ob.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},ob.flush=function(){this._gl.flush()},ob.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},ob.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},ob.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)},ob._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new _P(e),this._extensions=new _w(this),this._capability=new _R(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},ob.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},ob._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},ob._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},ob._onWebGLContextRestored=function(e){this._onDeviceRestored()},_y(ow,[{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}}]),ow);function _O(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)}}var _N=((oF=(oP=function(e,t){var r=this;this._costs={},this._currentLoad=0,this._callbacks={},this._worker=new Worker(e),this._worker.onmessage=function(e){var t=e.data;switch(t.type){case"decode":r._callbacks[t.id].resolve(t.geometry);break;case"error":r._callbacks[t.id].reject(t);break;default:cN.error('DRACOWorker: Unexpected message, "'+t.type+'"')}},t?this._worker.postMessage({type:"init",decoderConfig:{wasmBinary:t}}):this._worker.postMessage({type:"init",decoderConfig:{}})}).prototype).setCosts=function(e,t){this._costs[e]=t},oF.addCurrentLoad=function(e){this._currentLoad+=e},oF.setCallback=function(e,t,r){this._callbacks[e]={resolve:t,reject:r}},oF.decode=function(e,t,r){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:r},[r])},oF.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},_O(oP.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),oL&&_O(oP,oL),oP),_z='let decoderPending;\nlet decoderConfig;\n\nonmessage = function(e) {\n const message = e.data;\n\n switch (message.type) {\n case "init":\n decoderConfig = message.decoderConfig;\n decoderPending = new Promise(function(resolve /*, reject*/) {\n decoderConfig.onModuleLoaded = function(draco) {\n // Module is Promise-like. Wrap before resolving to avoid loop.\n resolve({ draco: draco });\n };\n DracoDecoderModule(decoderConfig);\n });\n break;\n\n case "decode":\n const buffer = message.buffer;\n const taskConfig = message.taskConfig;\n decoderPending.then(module => {\n const draco = module.draco;\n const decoder = new draco.Decoder();\n const decoderBuffer = new draco.DecoderBuffer();\n decoderBuffer.Init(new Int8Array(buffer), buffer.byteLength);\n try {\n const geometry = decodeGeometry(draco, decoder, decoderBuffer, taskConfig);\n const buffers = geometry.attributes.map(attr => attr.array.buffer);\n if (geometry.index) buffers.push(geometry.index.array.buffer);\n self.postMessage({ type: "decode", id: message.id, geometry }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n } finally {\n draco.destroy(decoderBuffer);\n draco.destroy(decoder);\n }\n });\n break;\n }\n};\n\nfunction decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {\n const attributeIDs = taskConfig.attributeIDs;\n const attributeTypes = taskConfig.attributeTypes;\n\n let dracoGeometry;\n let decodingStatus;\n\n const geometryType = decoder.GetEncodedGeometryType(decoderBuffer);\n if (geometryType === draco.TRIANGULAR_MESH) {\n dracoGeometry = new draco.Mesh();\n decodingStatus = decoder.DecodeBufferToMesh(decoderBuffer, dracoGeometry);\n } else {\n throw new Error("DRACODecoder worker: Unexpected geometry type.");\n }\n\n if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {\n throw new Error("DRACODecoder worker: Decoding failed: " + decodingStatus.error_msg());\n }\n\n const geometry = { index: null, attributes: [] };\n\n // Gather all vertex attributes.\n for (let attributeName in attributeIDs) {\n const attributeType = self[attributeTypes[attributeName]];\n\n let attribute;\n let attributeID;\n\n // A Draco file may be created with default vertex attributes, whose attribute IDs\n // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,\n // a Draco file may contain a custom set of attributes, identified by known unique\n // IDs. glTF files always do the latter, and .drc files typically do the former.\n if (taskConfig.useUniqueIDs) {\n attributeID = attributeIDs[attributeName];\n attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);\n } else {\n attributeID = decoder.GetAttributeId(dracoGeometry, draco[attributeIDs[attributeName]]);\n if (attributeID === -1) continue;\n attribute = decoder.GetAttribute(dracoGeometry, attributeID);\n }\n geometry.attributes.push(decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute));\n }\n // Add index.\n if (geometryType === draco.TRIANGULAR_MESH) {\n // Generate mesh faces.\n const numFaces = dracoGeometry.num_faces();\n const numIndices = numFaces * 3;\n let dataSize;\n let ptr;\n let index;\n const indexType = self[taskConfig.indexType];\n\n switch (indexType) {\n case Uint16Array:\n dataSize = numIndices * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt16Array(dracoGeometry, dataSize, ptr);\n index = new Uint16Array(draco.HEAPU16.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n case Uint32Array:\n dataSize = numIndices * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt32Array(dracoGeometry, dataSize, ptr);\n index = new Uint32Array(draco.HEAPU32.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n default:\n throw new Error("DRACODecoder: Unexpected index type.");\n }\n geometry.index = { array: index, itemSize: 1 };\n }\n draco.destroy(dracoGeometry);\n return geometry;\n}\n\nfunction decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute) {\n const numComponents = attribute.num_components();\n const numPoints = dracoGeometry.num_points();\n const numValues = numPoints * numComponents;\n let ptr;\n let array;\n let dataSize;\n switch (attributeType) {\n case Float32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_FLOAT32, dataSize, ptr);\n array = new Float32Array(draco.HEAPF32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT8, numValues, ptr);\n array = new Int8Array(draco.HEAP8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT16, dataSize, ptr);\n array = new Int16Array(draco.HEAP16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT32, dataSize, ptr);\n array = new Int32Array(draco.HEAP32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT8, numValues, ptr);\n array = new Uint8Array(draco.HEAPU8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT16, dataSize, ptr);\n array = new Uint16Array(draco.HEAPU16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT32, dataSize, ptr);\n array = new Uint32Array(draco.HEAPU32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n default:\n throw new Error("DRACODecoder: Unexpected attribute type.");\n }\n\n return {\n name: attributeName,\n array: array,\n itemSize: numComponents\n };\n}\n',_U="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",_k=((oB=(oD=function(e){if(void 0===e&&(e={type:"wasm",workerLimit:4}),this.pool=[],this.workerLimit=Math.min(navigator.hardwareConcurrency||4,4),this.currentTaskId=1,this.taskCache=new WeakMap,e.workerLimit>this.workerLimit)cN.warn("DRACOWorkerPool: Can not initialize worker pool with limit:"+e.workerLimit);else{var t;this.workerLimit=null!=(t=e.workerLimit)?t:4}this.useJS="object"!=typeof WebAssembly||"js"===e.type,this.loadLibPromise=this.preloadLib()}).prototype).preloadLib=function(){var e=this;return this.loadLibPromise?this.loadLibPromise:new Promise(function(t,r){e.useJS?hu(""+_U+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var r=[e,_z].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([r])),decoderWASMBinary:null})}).catch(function(e){r(e)}):Promise.all([hu(""+_U+"draco_wasm_wrapper_gltf.js",{type:"text"}),hu(""+_U+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var r=e[0],n=e[1],i=[r,_z].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:n})}).catch(function(e){r(e)})})},oB.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var r=new _N(t.workerSourceURL,t.decoderWASMBinary);e.pool.push(r)}else e.pool.sort(function(e,t){return e.currentLoad>t.currentLoad?-1:1});return e.pool[e.pool.length-1]})},oB.decode=function(e,t){var r,n=this,i=JSON.stringify(t);if(this.taskCache.has(e)){var a=this.taskCache.get(e);if(a.key===i)return a.promise;if(0===e.byteLength)throw Error("DRACODecoder: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var o=this.currentTaskId++,s=e.byteLength,l=new Promise(function(i,a){n.getWorker().then(function(n){r=n,n.setCosts(o,s),n.addCurrentLoad(s),n.setCallback(o,i,a),n.decode(o,t,e)}).catch(function(e){a(e)})});return l.finally(function(){r&&o&&r.releaseTask(o)}),this.taskCache.set(e,{key:i,promise:l}),l},oD);function _G(){return(_G=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 _H(e,t){return(_H=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _W(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&&_H(e,t)}function _X(e,t,r,n){var i,a=arguments.length,o=a<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--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function _K(e,t){var r,n,i,a,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=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(!(i=(i=l.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=i=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&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a}function _j(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 _Y(e,t,r){return t&&_j(e.prototype,t),r&&_j(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var _q=((oV=(oI=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},oV.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},oV.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},oV.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},oV.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},oV.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},oV.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},oV.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,c1.decodeText(t)},oV.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},oV.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 i=[],a=0;a<e;a++){var o=t[a],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,i.push(s)}return i},oV.skip=function(e){return this._position+=e,this},oV.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)},_Y(oI,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),oI),_Q={};function _Z(e){return function(t){_Q[e]=t}}var _J=((oO=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),i=t.getUint16(5,!0),a=new Uint8Array(e,7,i),o=t.getUint16(7+i,!0),s=new Uint8Array(e,9+i,o),l=c1.decodeText(s),c=c1.decodeText(a),u=new oO;return u.totalLength=r,u.name=l,u.type=c,u.version=n,u.headerLength=s.byteLength+a.byteLength+9,u},_Y(oO,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oO);function _$(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cu(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function _0(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new l9(e[3*n],e[3*n+1],e[3*n+2]);return r}function _1(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cc(e[2*n],e[2*n+1]);return r}function _2(e,t,r){return(_2=!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 i=new(Function.bind.apply(e,n));return r&&_H(i,r.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oN=function(){}).decode=function(e,t){return new Promise(function(r){var n=new uk(e),i=JSON.parse(t.nextStr());i.bounds&&n.bounds.copyFrom(i.bounds);var a=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,i.positions.start+a,(i.positions.end-i.positions.start)/4),l=s.length/3,c=_0(s,l);if(n.setPositions(c),i.normals){var u=_0(new Float32Array(o,i.normals.start+a,(i.normals.end-i.normals.start)/4),l);n.setNormals(u)}if(i.uvs){var d=new Float32Array(o,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);n.setUVs(_1(d,l))}if(i.uv1){var h=new Float32Array(o,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);n.setUVs(_1(h,l),1)}if(i.uv2){var _=new Float32Array(o,i.uv2.start+a,(i.uv2.end-i.uv2.start)/4);n.setUVs(_1(_,l),2)}if(i.uv3){var f=new Float32Array(o,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);n.setUVs(_1(f,l),3)}if(i.uv4){var p=new Float32Array(o,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);n.setUVs(_1(p,l),4)}if(i.uv5){var m=new Float32Array(o,i.uv5.start+a,(i.uv5.end-i.uv5.start)/4);n.setUVs(_1(m,l),5)}if(i.uv6){var g=new Float32Array(o,i.uv6.start+a,(i.uv6.end-i.uv6.start)/4);n.setUVs(_1(g,l),6)}if(i.uv7){var v=new Float32Array(o,i.uv7.start+a,(i.uv7.end-i.uv7.start)/4);n.setUVs(_1(v,l),7)}if(i.colors){var y=new Float32Array(o,i.colors.start+a,(i.colors.end-i.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cd(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(i.boneWeights){var x=new Float32Array(o,i.boneWeights.start+a,(i.boneWeights.end-i.boneWeights.start)/4);n.setBoneWeights(_$(x,l))}if(i.boneIndices){var S=new Float32Array(o,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);n.setBoneIndices(_$(S,l))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var t=new uO(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+a,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,i=_0(r,n);e.deltaNormals&&_0(new Float32Array(o,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&_$(new Float32Array(o,e.deltaTangents.start+a,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,i)}),n.addBlendShape(t)}),i.indices){var C=null;C=0===i.indices.type?new Uint16Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/2):new Uint32Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/4),n.setIndices(C)}i.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},oN),e.MeshDecoder=_X([_Z("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oz=function(){}).decode=function(e,t){return new Promise(function(r,n){var i=t.nextStr(),a=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new ck(e,d,h,u,a);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),a){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[i]=m,r(m)}else{var x=new window.Blob([p[0]]),S=new Image;S.onload=function(){m.setImageSource(S);var e=0,t=function(){++e>=f&&r(m)};if(t(),a){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 i=1;i<f;i++)n(i)}},S.src=URL.createObjectURL(x)}})},oz),e.Texture2DDecoder=_X([_Z("Texture2D")],e.Texture2DDecoder);var _3=((ok=(oU=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,i=e.position,a=e.rotation,o=e.scale;return i&&t.transform.position.copyFrom(i),a&&t.transform.rotation.copyFrom(a),o&&t.transform.scale.copyFrom(o),t.layer=null!=(n=e.layer)?n:t.layer,t})},ok.parseClassObject=function(e){var t,r=this,n=hf.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return _2(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},ok.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var i=t.methods[n],a=0,o=i.length;a<o;a++)r.push(this.parseMethod(e,n,i[a]));if(t.props){var s=this,l=function(n){var i=t.props[n],a=s.parseBasicType(i,e[n]).then(function(t){return e[n]=t});r.push(a)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=oU.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},ok.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))})},ok.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(oU._isClass(e))return this.parseClassObject(e);if(oU._isAssetRef(e))return this._context.resourceManager.getResourceByRef(e);if(oU._isEntityRef(e))return Promise.resolve(this._context.entityMap.get(e.entityId));if(t){var n=this,i=function(r){if("methods"===r){var i=e[r];for(var o in i)for(var s=i[o],l=0,c=s.length;l<c;l++){var u=s[l];a.push(n.parseMethod(t,o,u))}}else a.push(n.parseBasicType(e[r],t[r]).then(function(e){return t[r]=e}))},a=[];for(var o in e)i(o);return Promise.all(a).then(function(){return t})}}return Promise.resolve(e)},ok._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 c9(r,e.name))},oU.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oU._isClass=function(e){return void 0!=e.class},oU._isAssetRef=function(e){return void 0!=e.refId},oU._isEntityRef=function(e){return void 0!=e.entityId},oU);_3.customParseComponentHandles=new Map;var _4=((oG=function(){}).parseChildren=function(e,t,r){var n=e.get(r).children;if(n&&n.length>0)for(var i=t.get(r),a=0;a<n.length;a++){var o=n[a],s=t.get(o);i.addChild(s),this.parseChildren(e,t,o)}},oG),_5={Transform:c6,Animator:hO,DirectLight:dJ,Camera:e.Camera,MeshRenderer:uz,ParticleRenderer:hj,PointLight:d$,SpotLight:d0,Script:d3,SpriteMask:uR,SpriteRenderer:dk,TextRenderer:dW};function _8(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 _6(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 _8(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 _8(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.")}e.InterpolableValueType=void 0,(oH=e.InterpolableValueType||(e.InterpolableValueType={}))[oH.Float=0]="Float",oH[oH.FloatArray=1]="FloatArray",oH[oH.Vector2=2]="Vector2",oH[oH.Vector3=3]="Vector3",oH[oH.Vector4=4]="Vector4",oH[oH.Quaternion=5]="Quaternion",oH[oH.Color=6]="Color",oH[oH.Array=7]="Array",oH[oH.Boolean=8]="Boolean",oH[oH.Rect=9]="Rect",oH[oH.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((oW=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),i=new hP(n),a=r.nextUint16(),o=0;o<a;++o){var s=new hb;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,i.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var u=r.nextStr(),d=_5[r.nextStr()],h=r.nextStr(),_=void 0,f=r.nextUint8(),p=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(_=new e.AnimationFloatCurve).interpolation=f;for(var m=0;m<p;++m){var g=new hH;g.time=r.nextFloat32(),g.value=r.nextFloat32(),g.inTangent=r.nextFloat32(),g.outTangent=r.nextFloat32(),_.addKey(g)}break;case"AnimationArrayCurve":(_=new e.AnimationArrayCurve).interpolation=f;for(var v=0;v<p;++v){var y=new hH;y.time=r.nextFloat32();var x=r.nextUint16();y.value=Array.from(r.nextFloat32Array(x)),y.inTangent=Array.from(r.nextFloat32Array(x)),y.outTangent=Array.from(r.nextFloat32Array(x)),_.addKey(y)}break;case"AnimationFloatArrayCurve":(_=new e.AnimationFloatArrayCurve).interpolation=f;for(var S=0;S<p;++S){var C=new hH;C.time=r.nextFloat32();var T=r.nextUint16();C.value=r.nextFloat32Array(T),C.inTangent=Array.from(r.nextFloat32Array(T)),C.outTangent=Array.from(r.nextFloat32Array(T)),_.addKey(C)}break;case"AnimationVector2Curve":(_=new e.AnimationVector2Curve).interpolation=f;for(var A=0;A<p;++A){var E=new hH;E.time=r.nextFloat32(),E.value=new cc(r.nextFloat32(),r.nextFloat32()),E.inTangent=new cc(r.nextFloat32(),r.nextFloat32()),E.outTangent=new cc(r.nextFloat32(),r.nextFloat32()),_.addKey(E)}break;case"AnimationVector3Curve":(_=new e.AnimationVector3Curve).interpolation=f;for(var M=0;M<p;++M){var R=new hH;R.time=r.nextFloat32(),R.value=new l9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),R.inTangent=new l9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),R.outTangent=new l9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(R)}break;case"AnimationVector4Curve":(_=new e.AnimationVector4Curve).interpolation=f;var w=new hH;w.time=r.nextFloat32(),w.value=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(w);break;case"AnimationColorCurve":(_=new e.AnimationColorCurve).interpolation=f;for(var b=0;b<p;++b){var P=new hH;P.time=r.nextFloat32(),P.value=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(P)}break;case"AnimationQuaternionCurve":(_=new e.AnimationQuaternionCurve).interpolation=f;for(var F=0;F<p;++F){var L=new hH;L.time=r.nextFloat32(),L.value=new co(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new cu(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(L)}break;case"AnimationRefCurve":(_=new e.AnimationRefCurve).interpolation=f;for(var D=0;D<p;++D){var B=new hH;B.time=r.nextFloat32(),B.value=JSON.parse(r.nextStr()),_.addKey(B)}}i.addCurveBinding(u,d,h,_)}t(i)})},oW),e.AnimationClipDecoder=_X([_Z("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(oX=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",oX.Custom="Custom";var _7=((oK=function(e,t){this.originalData=e,this.scene=t,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[],this.engine=t.engine,this.resourceManager=t.engine.resourceManager}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},oK),_9=((oY=(oj=function(e){var t=this;this.context=e,this._engine=e.scene.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._clearAndResolveScene=this._clearAndResolveScene.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new _3(e)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject)},oY._parseEntities=function(){var e=this,t=this.context.originalData.entities,r=this.context.entityConfigMap,n=this.context.entityMap,i=this.context.rootIds;return this._engine,Promise.all(t.map(function(t){return r.set(t.id,t),t.parent||i.push(t.id),e._reflectionParser.parseEntity(t)})).then(function(e){for(var r=0,i=e.length;r<i;r++)n.set(t[r].id,e[r]);return e})},oY._organizeEntities=function(){for(var e,t=this.context,r=t.entityConfigMap,n=t.entityMap,i=t.scene,a=t.rootIds,o=_6(a);!(e=o()).done;){var s=e.value;_4.parseChildren(r,n,s)}for(var l=a.map(function(e){return n.get(e)}),c=0;c<l.length;c++)i.addRootEntity(l[c])},oY._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,r=[],n=0,i=e.length;n<i;n++)for(var a=e[n],o=t.get(a.id),s=0;s<a.components.length;s++){var l=a.components[s],c=l.refId?l.refId:l.class,u=void 0;"Animator"===c&&(u=o.getComponent(hf.getClass(c))),u=u||o.addComponent(hf.getClass(c));var d=this._reflectionParser.parsePropsAndMethods(u,l);r.push(d)}return Promise.all(r)},oY._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oj.parse=function(e,t){var r=new d2(e),n=new _7(t,r),i=new oj(n);return i.start(),i.promise},oj);function fe(e,t){var r=_J.decode(e),n=new _q(new Uint8Array(e),r.headerLength,r.dataLength);return _Q[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(_W(oq=function(){return hf.apply(this,arguments)},hf),oq.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,{type:"arraybuffer"}).then(function(e){fe(e,t.engine).then(function(e){n(e)})}).catch(i)})},oq),e.MeshLoader=_X([dr("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(_W(oQ=function(){return hf.apply(this,arguments)},hf),oQ.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,{type:"arraybuffer"}).then(function(e){fe(e,t.engine).then(function(e){n(e)})}).catch(i)})},oQ),e.EditorTextureLoader=_X([dr("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var ft=(_W(oZ=function(){return hf.apply(this,arguments)},hf),oZ.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,_G({},e,{type:"arraybuffer"})).then(function(e){return fe(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){var r=e.value;if("object"==typeof r&&r.refId)return new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e)}).catch(i)})}))})).then(function(){n(e)})})}).catch(i)})},oZ);ft=_X([dr(e.AssetType.AnimationClip,["ani"])],ft);var fr=(_W(oJ=function(){return hf.apply(this,arguments)},hf),oJ.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,_G({},e,{type:"json"})).then(function(e){var r=new hN,i=e.layers,a=[];i.forEach(function(e,n){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hz(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,d=c.stateMachine=new hG;u.forEach(function(e,r){var i=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,u=e.isDefaultState,h=e.clip,_=e.scripts,f=d.addState(i);u&&(d.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(hf.getClass(e))}),h&&a.push(new Promise(function(e){t.getResourceByRef(h).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),u.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var r=e.targetStateName,n=e.duration,i=e.offset,a=e.exitTime,o=d.findStateByName(t),s=d.findStateByName(r),l=new hD;l.destinationState=s,l.duration=n,l.exitTime=a,l.offset=i,o.addTransition(l)})})}r.addLayer(c)}),Promise.all(a).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,i=e.clip;r.layers[t].stateMachine.states[n].clip=i}),n(r)})}).catch(i)})},oJ);fr=_X([dr(e.AssetType.AnimatorController,["json"],!1)],fr);var fn=(_W(o$=function(){return hf.apply(this,arguments)},hf),o$.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new de(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,_G({},e,{type:"arraybuffer"}))},o$);fn=_X([dr(e.AssetType.Buffer,["bin","r3bin"],!1)],fn);var fi=(_W(o0=function(){return hf.apply(this,arguments)},hf),o0.prototype.load=function(t,r){var n=this;return new de(function(i,a){n.request(t.url,{type:"arraybuffer"}).then(function(t){var n=new Float32Array(t,0,27),a=new Uint16Array(t,108,1)[0],o=r.engine,s=new cH(o,a);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var d=a>>u,h=0;h<6;h++){var _=d*d*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+h,f,u)}var p=new dQ(o),m=new c_;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,i(p)}).catch(function(e){a(e)})})},o0);function fa(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function fo(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){fa(a,n,i,o,s,"next",e)}function s(e){fa(a,n,i,o,s,"throw",e)}o(void 0)})}}fi=_X([dr(e.AssetType.Env,["env"])],fi);var fs=(_W(o1=function(){return hf.apply(this,arguments)},hf),(o2=o1.prototype).load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,{type:"json"}).then(function(e){var a=e.fontName,o=e.fontUrl;o?r._registerFont(a,o).then(function(){n(new cj(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):n(new cj(t.engine,a))}).catch(function(e){i(e)})})},o2._registerFont=function(e,t){return fo(function(){var r;return _K(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]}})})()},o1);fs=_X([dr(e.AssetType.Font,["font"],!1)],fs);var fl=(_W(o3=function(e,t){var r;return(r=cP.call(this,e)||this).url=t,r},cP),o3);(o4=lj||(lj={}))[o4.BYTE=5120]="BYTE",o4[o4.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",o4[o4.SHORT=5122]="SHORT",o4[o4.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",o4[o4.UNSIGNED_INT=5125]="UNSIGNED_INT",o4[o4.FLOAT=5126]="FLOAT",(o5=lY||(lY={})).SCALAR="SCALAR",o5.VEC2="VEC2",o5.VEC3="VEC3",o5.VEC4="VEC4",o5.MAT2="MAT2",o5.MAT3="MAT3",o5.MAT4="MAT4",(o8=lq||(lq={})).TRANSLATION="translation",o8.ROTATION="rotation",o8.SCALE="scale",o8.WEIGHTS="weights",(o6=lQ||(lQ={})).Linear="LINEAR",o6.Step="STEP",o6.CubicSpine="CUBICSPLINE",(o7=lZ||(lZ={})).PERSPECTIVE="perspective",o7.ORTHOGRAPHIC="orthographic",(o9=lJ||(lJ={})).JPEG="image/jpeg",o9.PNG="image/png",(se=l$||(l$={})).OPAQUE="OPAQUE",se.MASK="MASK",se.BLEND="BLEND",(st=l0||(l0={}))[st.NEAREST=9728]="NEAREST",st[st.LINEAR=9729]="LINEAR",(sr=l1||(l1={}))[sr.NEAREST=9728]="NEAREST",sr[sr.LINEAR=9729]="LINEAR",sr[sr.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sr[sr.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sr[sr.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sr[sr.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sn=l2||(l2={}))[sn.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sn[sn.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sn[sn.REPEAT=10497]="REPEAT";var fc=((sa=(si=function(e,t,r){this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this._resourceCache=new Map,this.contentRestorer=new fA(e)}).prototype).get=function(e,t){var r=this,n=si._parsers[e];if(!n)return Promise.resolve(null);var i=this._resourceCache,a=0===e||1===e,o=a||void 0===t?""+e:e+":"+t,s=i.get(o);if(s)return s;if(a)s=n.parse(this);else{var l=this.glTF[fd[e]];l&&(void 0===t||l[t])?void 0===t?s=7===e?l.map(function(t,n){return r.get(e,n)}):Promise.all(l.map(function(t,n){return r.get(e,n)})):(s=n.parse(this,t),this._handleSubAsset(s,e,t)):s=Promise.resolve(null)}return i.set(o,s),s},sa.parse=function(){var e=this;return this.get(0).then(function(t){return e.glTF=t,Promise.all([e.get(1),e.get(4),e.get(5),e.get(6),e.get(8),e.get(9),e.get(2)]).then(function(){var t=e.glTFResource;return(t.skins||t.animations)&&e._createAnimator(e,t.animations),e.resourceManager.addContentRestorer(e.contentRestorer),t})})},sa._createAnimator=function(e,t){var r=e.glTFResource.defaultSceneRoot.addComponent(hO),n=new hN,i=new hz("layer"),a=new hG;if(n.addLayer(i),r.animatorController=n,i.stateMachine=a,t)for(var o=0;o<t.length;o++){var s=t[o],l=s.name,c=a.makeUniqueStateName(l);c!==l&&console.warn("AnimatorState name is existed, name: "+l+" reset to "+c),a.addState(c).clip=s}},sa._handleSubAsset=function(e,t,r){var n,i=this,a=fh[t];if(a){if(7===t)((n=this.glTFResource)[a]||(n[a]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(((n=i.glTFResource)[a]||(n[a]=[]))[r]=e,6===t)for(var n,s,l=0,c=e.length;l<c;l++){var u=e[l];i.resourceManager._onSubAssetSuccess(o+"?q="+a+"["+r+"]["+l+"]",u)}else i.resourceManager._onSubAssetSuccess(o+"?q="+a+"["+r+"]",e),2===t&&(null!=(s=i.glTF.scene)?s:0)===r&&i.resourceManager._onSubAssetSuccess(""+o+"?q=defaultSceneRoot",e)})}}},si.addParser=function(e,t){this._parsers[e]=t},si);fc._parsers={};var fu=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(so=e.GLTFParserType||(e.GLTFParserType={}))[so.Schema=0]="Schema",so[so.Validator=1]="Validator",so[so.Scene=2]="Scene",so[so.Buffer=3]="Buffer",so[so.Texture=4]="Texture",so[so.Material=5]="Material",so[so.Mesh=6]="Mesh",so[so.Entity=7]="Entity",so[so.Skin=8]="Skin",so[so.Animation=9]="Animation";var fd=((l3={})[2]="scenes",l3[3]="buffers",l3[4]="textures",l3[5]="materials",l3[6]="meshes",l3[7]="nodes",l3[8]="skins",l3[9]="animations",l3),fh=((l4={})[2]="sceneRoots",l4[4]="textures",l4[5]="materials",l4[6]="meshes",l4[7]="entities",l4[8]="skins",l4[9]="animations",l4);function f_(e){return function(t){var r=new t;fc.addParser(e,r)}}var ff=((ss=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new cc(e[n],e[n+1]);return r},ss.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new l9(e[n],e[n+1],e[n+2]);return r},ss.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new cu(e[n],e[n+1],e[n+2],e[n+3]);return r},ss.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var i=0;i<r;i+=3)n[i/3]=new cd(e[i],e[i+1],e[i+2],1);else for(var a=0;a<r;a+=4)n[a/4]=new cd(e[a],e[a+1],e[a+2],e[a+3]);return n},ss.getAccessorTypeSize=function(e){switch(e){case lY.SCALAR:return 1;case lY.VEC2:return 2;case lY.VEC3:return 3;case lY.VEC4:case lY.MAT2:return 4;case lY.MAT3:return 9;case lY.MAT4:return 16}},ss.getComponentType=function(e){switch(e){case lj.BYTE:return Int8Array;case lj.UNSIGNED_BYTE:return Uint8Array;case lj.SHORT:return Int16Array;case lj.UNSIGNED_SHORT:return Uint16Array;case lj.UNSIGNED_INT:return Uint32Array;case lj.FLOAT:return Float32Array}},ss.getNormalizedComponentScale=function(e){switch(e){case lj.BYTE:return 1/127;case lj.UNSIGNED_BYTE:return 1/255;case lj.SHORT:return 1/32767;case lj.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},ss.getAccessorBuffer=function(t,r,n){var i,a=n.componentType,o=null!=(i=n.bufferView)?i:0,s=r[o];return t.get(e.GLTFParserType.Buffer).then(function(e){var i,l,c,u=s.buffer,d=e[u],h=null!=(i=s.byteOffset)?i:0,_=null!=(l=n.byteOffset)?l:0,f=ss.getComponentType(a),p=ss.getAccessorTypeSize(n.type),m=f.BYTES_PER_ELEMENT,g=p*m,v=n.count,y=s.byteStride;if(void 0!==y&&y!==g){var x=Math.floor(_/y),S=o+":"+a+":"+x+":"+v,C=t.accessorBufferCache;if(!(c=C[S])){var T=h+x*y,A=v*(y/m),E=new f(d,T,A);C[S]=c=new fu(E,!0,y),c.restoreInfo=new fb(new fP(u,f,T,A))}}else{var M=h+_,R=v*p,w=new f(d,M,R);(c=new fu(w,!1,g)).restoreInfo=new fb(new fP(u,f,M,R))}return n.sparse&&ss.processingSparseData(r,n,e,c),c})},ss.bufferToVector3Array=function(e,t,r,n){for(var i=e.BYTES_PER_ELEMENT,a=r%t/i,o=t/i,s=Array(n),l=0;l<n;l++){var c=a+l*o;s[l]=new l9(e[c],e[c+1],e[c+2])}return s},ss.getAccessorData=function(e,t,r){var n=e.bufferViews,i=n[null!=(v=t.bufferView)?v:0],a=r[i.buffer],o=t.hasOwnProperty("byteOffset")?t.byteOffset:0,s=i.hasOwnProperty("byteOffset")?i.byteOffset:0,l=o+s,c=ss.getAccessorTypeSize(t.type),u=c*t.count,d=null!=(y=i.byteStride)?y:0,h=ss.getComponentType(t.componentType);if(d){var _=c*h.BYTES_PER_ELEMENT;x=new Uint8Array(t.count*_);for(var f=new Uint8Array(a,s,i.byteLength),p=0;p<t.count;p++)for(var m=0;m<_;m++)x[p*_+m]=f[p*d+o+m]}else x=new Uint8Array(a.slice(l,l+u*h.BYTES_PER_ELEMENT));var g=new h(x.buffer);if(t.sparse)for(var v,y,x,S,C,T,A,E=t.sparse,M=E.count,R=E.indices,w=E.values,b=n[R.bufferView],P=n[w.bufferView],F=r[b.buffer],L=r[P.buffer],D=(null!=(S=R.byteOffset)?S:0)+(null!=(C=b.byteOffset)?C:0),B=b.byteLength,I=(null!=(T=w.byteOffset)?T:0)+(null!=(A=P.byteOffset)?A:0),V=P.byteLength,O=ss.getComponentType(R.componentType),N=new O(F,D,B/O.BYTES_PER_ELEMENT),z=new h(L,I,V/h.BYTES_PER_ELEMENT),U=0;U<M;U++)for(var k=N[U],G=0;G<c;G++)g[k*c+G]=z[U*c+G];return g},ss.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},ss.processingSparseData=function(e,t,r,n){var i,a,o,s,l=n.restoreInfo,c=ss.getAccessorTypeSize(t.type),u=ss.getComponentType(t.componentType),d=n.data.slice(),h=t.sparse,_=h.count,f=h.indices,p=h.values,m=e[f.bufferView],g=e[p.bufferView],v=m.buffer,y=g.buffer,x=r[v],S=r[y],C=(null!=(i=f.byteOffset)?i:0)+(null!=(a=m.byteOffset)?a:0),T=m.byteLength,A=(null!=(o=p.byteOffset)?o:0)+(null!=(s=g.byteOffset)?s:0),E=g.byteLength;l.typeSize=c,l.sparseCount=_;var M=ss.getComponentType(f.componentType),R=T/M.BYTES_PER_ELEMENT,w=new M(x,C,R);l.sparseIndices=new fP(v,M,C,R);var b=E/u.BYTES_PER_ELEMENT,P=new u(S,A,b);l.sparseValues=new fP(y,u,A,b);for(var F=0;F<_;F++)for(var L=w[F],D=0;D<c;D++)d[L*c+D]=P[F*c+D];n.data=d},ss.getIndexFormat=function(t){switch(t){case lj.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case lj.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case lj.UNSIGNED_INT:return e.IndexFormat.UInt32}},ss.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==lj.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==lj.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==lj.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==lj.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==lj.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},ss.loadImageBuffer=function(e,t){return new Promise(function(r,n){var i=new window.Blob([e],{type:t}),a=new Image;a.onerror=function(){n(Error("Failed to load image buffer"))},a.onload=function(){requestAnimationFrame(function(){r(a),a.onload=null,a.onerror=null,a.onabort=null})},a.crossOrigin="anonymous",a.src=URL.createObjectURL(i)})},ss.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),i={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==i.magic)return{originBuffer:t};var a=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,a),l=JSON.parse(c1.decodeText(s)),c=[],u=20+a,d=e.contentRestorer.glbBufferSlices;u<i.length;){if(a=n.getUint32(u,!0),(o=n.getUint32(u+4,!0))!==r.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=u+8,_=t.slice(h,h+a);c.push(_),d.push(new cc(h,a)),u+=a+8}return{glTF:l,buffers:c}},ss.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,i=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==i&&(e.wrapModeV=i)},ss.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,i=t.wrapS,a=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=l1.NEAREST_MIPMAP_NEAREST,n===l0.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=l1.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),i&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[i]),a&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[a]),o},ss);(sl=l5||(l5={}))[sl.linear=1]="linear",sl[sl.sRGB=2]="sRGB",(sc=l8||(l8={}))[sc.ETC1S=163]="ETC1S",sc[sc.UASTC=166]="UASTC",(su=l6||(l6={}))[su.None=0]="None",su[su.BasisLZ=1]="BasisLZ",su[su.Zstd=2]="Zstd",su[su.ZLib=3]="ZLib";var fp=((sd=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 _q(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 i=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var a=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),u=n.nextUint64(),d=Array(i),h=24*i,_=new _q(e,n.offset,h);this.levels=d;for(var f=0;f<i;f++)d[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new _q(e,a,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 _q(e,s,l,!0);x.position<l;){var S=x.nextUint32(),C=x.scan(S),T=c1.decodeText(C),A=x.nextUint8Array(S-C.byteLength-1);this.keyValue[T]=T.match(/^ktx/i)?c1.decodeText(A).replace(/^(.*)\x00$/,"$1"):A;var E=S%4?4-S%4:0;x.skip(E)}if(u<=0)return this;for(var M=new _q(e,c,u,!0),R=M.nextUint16(),w=M.nextUint16(),b=M.nextUint32(),P=M.nextUint32(),F=M.nextUint32(),L=M.nextUint32(),D=Array(i),B=0;B<i;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+b,O=V+P,N=O+F,z=new Uint8Array(t,r+I,b),U=new Uint8Array(t,r+V,P),k=new Uint8Array(t,r+O,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:R,selectorCount:w,imageDescs:D,endpointsData:z,selectorsData:U,tablesData:k,extendedData:G}},_Y(sd,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sd);e.KTX2TargetFormat=void 0,(sh=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sh.ASTC=0]="ASTC",sh[sh.BC7=1]="BC7",sh[sh.BC1_BC3=2]="BC1_BC3",sh[sh.PVRTC=3]="PVRTC",sh[sh.ETC=4]="ETC",sh[sh.R8=5]="R8",sh[sh.R8G8=6]="R8G8",sh[sh.R8G8B8A8=7]="R8G8B8A8";var fm=((sf=(s_=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)},sf.postMessage=function(e){var t=this;return new Promise(function(r,n){var i=t._getIdleWorkerId();if(-1!==i){t._workerStatus|=1<<i;var a,o=t._workerItems;Promise.resolve(null!=(a=o[i])?a:t._initWorker(i)).then(function(){var t=o[i];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sf.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},sf._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})},sf._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sf._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sf._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},s_),fg=((sm=(sp=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sm.destroy=function(){this._transcodeWorkerPool.destroy()},sm._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new fm(this.workerLimitCount,function(){return new Promise(function(r,n){var i=new Worker(e);i.addEventListener("message",function(e){e.data.error?n(e.data.error):r(i)}),i.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sp);function fv(){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=fx(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var fy=function(e){return sg||(sg=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})),sg};function fx(e,t,r){var n,i,a,o,s=function(){l.close(),l.delete()};(a=n||(n={}))[a.ETC1=0]="ETC1",a[a.ETC2=1]="ETC2",a[a.BC1=2]="BC1",a[a.BC3=3]="BC3",a[a.BC4=4]="BC4",a[a.BC5=5]="BC5",a[a.BC7=7]="BC7",a[a.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",a[a.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",a[a.ASTC_4x4=10]="ASTC_4x4",a[a.RGBA8=13]="RGBA8",(o=i||(i={}))[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(),u=l.getHeight(),d=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 S=Array(d),C=void 0,T=void 0,A=0;A<d;A++){var E=l.getImageLevelInfo(x,A,v);g&&0===x&&(c!==E.width||u!==E.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=C=E.width)+", height: "+(u=T=E.height)+". You'd better use an image whose size if multiple of 4."):(C=E.origWidth,T=E.origHeight);var M=new Uint8Array(l.getImageTranscodedSizeInBytes(x,A,0,p));if(!l.transcodeImage(M,x,A,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");S[A]=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),i=0,a=0;a<e.length;a++)n.set(e[a],i),i+=e[a].byteLength;return n}(S),width:C,height:T}}m[v]=y}return s(),{faces:m,width:c,height:u,hasAlpha:_,faceCount:f,format:p}}var fS=(_W(sv=function(e){return fg.call(this,e)},fg),(sy=sv.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 i=document.createElement("script");i.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(i),i.onload=function(){fy(n).then(function(){e(null)})},i.onerror=function(){t()}});var i=fv.toString(),a=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1),o="\n "+r+"\n "+fx.toString()+"\n "+a+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},sy.transcode=function(e,t){return 0===this.workerLimitCount?fy().then(function(r){return fx(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},sv);function fC(){var e,t,r,n=function(e,t,r,n){var i=(r+3>>2)*(n+3>>2),a=16*i+65535>>16,o=e.memory,s=a+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*i);return l.set(t),0===e.transcode(i)?l:null},i=function(e,t,r){var i=e.length,a=Array(i),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<i;s++){for(var l=e[s].length,c=Array(l),u=0;u<l;u++){var d=e[s][u],h=d.buffer,_=d.levelHeight,f=d.levelWidth,p=d.uncompressedByteLength;t&&(h=o.decode(h.slice(),p));var m=h.byteLength/i,g=h.byteOffset,v=n(r,new Uint8Array(h.buffer,g+s*m,m),f,_);if(v)c[u]={data:v.slice(),width:f,height:_};else throw"buffer decoded error"}a[s]=c}return a})},a=((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,i=t.byteLength,a=n.malloc(i);e.heap.set(t,a),r=r||Number(n.ZSTD_findDecompressedSize(a,i));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,a,i),l=e.heap.slice(o,o+s);return n.free(a),n.free(o),l},e);a.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){a.heap=new Uint8Array(a.instance.exports.memory.buffer)}}},a.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new a;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){i(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var fT=(_W(sx=function(e,t){var r;return(r=fg.call(this,e)||this).type=t,r},fg),(sS=sx.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(sx.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=fC.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},sS.transcode=function(e){for(var t=e.supercompressionScheme===l6.Zstd,r=e.levels.length,n=e.faceCount,i={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},a={type:"transcode",format:0,needZstd:t,data:Array(n)},o=a.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var u=e.levels[c],d=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=u.levelData.buffer,f=u.levelData.byteOffset,p=u.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:d,levelHeight:h,uncompressedByteLength:u.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(a).then(function(e){return i.faces=e,i.hasAlpha=!0,i})},sx);fT.transcoderMap=((sC={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",sC),e.KTX2Loader=(_W(sT=function(){return hf.apply(this,arguments)},hf),(sA=sT.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()}},sA.load=function(t,r){return this.request(t.url,{type:"arraybuffer"}).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,i=t.targetFormat,a=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,i,a)})})},sT.destroy=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},sT._parseBuffer=function(t,r,n){var i,a,o=new fp(t),s=null!=(i=null==n?void 0:n.priorityFormats)?i:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&fT.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();a=c.init().then(function(){return c.transcode(o)})}else{var u=e.KTX2Loader._getBinomialLLCTranscoder();a=u.init().then(function(){return u.transcode(t,l)})}return a.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},sT._createTextureByBuffer=function(t,r,n,i){var a,o=r.width,s=r.height,l=r.faces,c=l.length,u=l[0],d=u.length>1,h=this._getEngineTextureFormat(n,r);if(6!==c){a=new ck(t,o,s,h,d);for(var _=0;_<u.length;_++){var f=u[_].data;a.setPixelBuffer(f,_)}}else{a=new cH(t,s,h,d);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<u.length;g++)a.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return i&&(a.wrapModeU=i[0],a.wrapModeV=i[1],a.filterMode=i[2],a.anisoLevel=i[3]),a},sT._decideTargetFormat=function(t,r,n){var i=t._hardwareRenderer,a=this._detectSupportedFormat(i,n);return a!==e.KTX2TargetFormat.PVRTC||l7.isPowerOf2(r.pixelWidth)&&l7.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===a?(cN.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):a:(cN.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},sT._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var i=r[n],a=this._supportedMap[i];if(a){for(var o=0;o<a.length;o++)if(t.canIUse(a[o]))return i}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return i;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return i}}return null},sT._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new fS(t)},sT._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new fT(t,e.KTX2TargetFormat.ASTC)},sT._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}},sT._isBinomialInit=!1,sT._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]},sT._supportedMap=((sE={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],sE[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],sE[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],sE[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],sE[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],sE),sT),e.KTX2Loader=_X([dr(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(sM=e.KTX2Transcoder||(e.KTX2Transcoder={}))[sM.BinomialLLC=0]="BinomialLLC",sM[sM.Khronos=1]="Khronos";var fA=(_W(sR=function(){var e;return e=cF.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},cF),(sw=sR.prototype).restoreContent=function(){var t=this;return new de(function(r,n){Promise.all(t.bufferRequests.map(function(e){return hu(e.url,e.config)})).then(function(i){if(t.isGLB){var a=t.glbBufferSlices,o=i[0],s=a.length;i.length=s;for(var l=0;l<s;l++){var c=a[l];i[l]=o.slice(c.x,c.x+c.y)}}de.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,a=i[n.buffer],o=new Uint8Array(a,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)}):ff.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=_6(t.meshes);!(e=n()).done;){for(var a,o=e.value,s=o.mesh,l=_6(o.vertexBuffers);!(a=l()).done;){var c=a.value,u=t._getBufferData(i,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(i,o.indexBuffer);s.setIndices(d)}for(var h,_=_6(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(i,m.buffer);if(p.deltaPositions=ff.bufferToVector3Array(g,m.stride,m.byteOffset,m.count),f.normal){var v=f.normal,y=t._getBufferData(i,v.buffer);p.deltaNormals=ff.bufferToVector3Array(y,v.stride,v.byteOffset,v.count)}if(f.tangent){var x=f.tangent,S=t._getBufferData(i,x.buffer);p.deltaTangents=ff.bufferToVector3Array(S,x.stride,x.byteOffset,x.count)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},sw._getBufferData=function(e,t){var r=t.main,n=e[r.bufferIndex],i=new r.TypedArray(n,r.byteOffset,r.length),a=t.sparseCount;if(a)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<a;_++)for(var f=l[_],p=0;p<h;p++)i[f*h+p]=d[_*h+p];return i},sR),fE=function(e,t){this.url=e,this.config=t},fM=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},fR=function(){this.vertexBuffers=[],this.blendShapes=[]},fw=function(e,t){this.buffer=e,this.data=t},fb=function(e,t,r,n,i){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=i},fP=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},fF=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},fL=function(e,t,r,n){this.buffer=e,this.stride=t,this.byteOffset=r,this.count=n},fD=((sP=(sb=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,i=Array(n>3?n-3:0),a=3;a<n;a++)i[a-3]=arguments[a];throw"Not implemented."},sP.additiveParse=function(e,t,r,n){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];throw"Not implemented."},sb);e.GLTFExtensionMode=void 0,(sF=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[sF.CreateAndParse=0]="CreateAndParse",sF[sF.AdditiveParse=1]="AdditiveParse";var fB=((sL=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,i=Array(n>3?n-3:0),a=3;a<n;a++)i[a-3]=arguments[a];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],u=e[c];if(o=sL._createAndParse.apply(sL,[].concat(c,t,u,r,i)))return o}},sL.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];for(var s in e){var l=e[s];sL._additiveParse.apply(sL,[].concat(s,t,r,l,n,a))}},sL.hasExtensionParser=function(e){var t;return!!(null==(t=sL._extensionParsers[e])?void 0:t.length)},sL.getExtensionParser=function(e,t){var r=sL._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var i=n-1;i>=0;--i){var a=r[i];if(a._mode===t)return a}},sL._addExtensionParser=function(e,t){sL._extensionParsers[e]||(sL._extensionParsers[e]=[]),sL._extensionParsers[e].push(t)},sL._createAndParse=function(t,r,n,i){for(var a=arguments.length,o=Array(a>4?a-4:0),s=4;s<a;s++)o[s-4]=arguments[s];var l=sL.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,i,o))},sL._additiveParse=function(t,r,n,i,a){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=sL.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,i,a,s))},sL);function fI(e,t){return function(r){var n=new r;n._mode=t,fB._addExtensionParser(e,n)}}function fV(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}fB._extensionParsers={},e.GLTFSchemaParser=(_W(sD=function(){return fB.apply(this,arguments)},fB),sD.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,i=r.bufferRequests,a={type:"arraybuffer"};return hu(n,a).then(function(t){return i.push(new fE(n,a)),ff.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(c1.decodeText(new Uint8Array(t.originBuffer))))})},sD),e.GLTFSchemaParser=_X([f_(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(_W(sB=function(){return fB.apply(this,arguments)},fB),sB.prototype.parse=function(t,r){var n=t.glTF.animations[r],i=n.name,a=void 0===i?"AnimationClip"+r:i;return Promise.resolve(fB.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new hP(a),n)).then(function(e){return fB.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},sB._parseStandardProperty=function(t,r,n){for(var i=this,a=t.glTF,o=a.accessors,s=a.bufferViews,l=n.channels,c=n.samplers,u=[],d=t.get(e.GLTFParserType.Entity),h=[],_=0,f=c.length;_<f;_++)!function(r,n){var i=c[r],a=o[i.input],l=o[i.output],d=Promise.all([ff.getAccessorBuffer(t,s,a),ff.getAccessorBuffer(t,s,l)]).then(function(t){var r,n,a=t[0].data,o=t[1].data;if(l.normalized){for(var s=ff.getNormalizedComponentScale(l.componentType),c=new Float32Array(o.length),d=0,h=o.length;d<h;d++)c[d]=o[d]*s;o=c}var _=o.length/a.length;switch(null!=(r=i.interpolation)?r:lQ.Linear){case lQ.CubicSpine:n=e.InterpolationType.CubicSpine;break;case lQ.Step:n=e.InterpolationType.Step;break;case lQ.Linear:n=e.InterpolationType.Linear}a[a.length-1],u.push({type:l.type,interpolation:n,input:a,output:o,outputSize:_})});h.push(d)}(_);return h.push(t.get(e.GLTFParserType.Scene)),Promise.all(h).then(function(){for(var e=0,n=l.length;e<n;e++){for(var a=l[e],o=a.target,s=d[o.node],c="",h=s;h.parent;)c=""===c?""+h.name:h.name+"/"+c,h=h.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(h)){var _=void 0,f=void 0;switch(o.path){case lq.TRANSLATION:_=c6,f="position";break;case lq.ROTATION:_=c6,f="rotationQuaternion";break;case lq.SCALE:_=c6,f="scale";break;case lq.WEIGHTS:_=u1,f="blendShapeWeights"}var p=i._addCurve(o.path,a,u);r.addCurveBinding(c,_,f,p)}}return r})},sB._addCurve=function(t,r,n){var i=n[r.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case lq.TRANSLATION:case lq.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,d=0,h=a.length;d<h;d++){var _=new hH;_.time=a[d],c===e.InterpolationType.CubicSpine?(_.inTangent=new l9(o[u++],o[u++],o[u++]),_.value=new l9(o[u++],o[u++],o[u++]),_.outTangent=new l9(o[u++],o[u++],o[u++])):_.value=new l9(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lq.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=i.interpolation,m=0,g=0,v=a.length;g<v;g++){var y=new hH;y.time=a[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new cu(o[m++],o[m++],o[m++],o[m++]),y.value=new co(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new cu(o[m++],o[m++],o[m++],o[m++])):y.value=new co(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lq.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var S=0,C=0,T=a.length;C<T;C++){var A=new hH;A.time=a[C],x.interpolation===e.InterpolationType.CubicSpine?(A.inTangent=Array.from(o.subarray(S,S+s)),S+=s,A.value=o.slice(S,S+s),S+=s,A.outTangent=Array.from(o.subarray(S,S+s))):A.value=o.slice(S,S+s),S+=s,x.addKey(A)}return x}},sB),e.GLTFAnimationParser=_X([f_(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(_W(sI=function(){return fB.apply(this,arguments)},fB),(sV=sI.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},sV._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,i=r.url,a=n.bufferRequests,o={type:"arraybuffer"},s=c1.resolveAbsoluteUrl(i,t.uri);return a.push(new fE(s,o)),hu(s,o)},sI),e.GLTFBufferParser=_X([f_(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(_W(sO=function(){return fB.apply(this,arguments)},fB),sO.prototype.parse=function(t,r){var n=t.glTF.nodes[r],i=t.glTFResource.engine,a=n.matrix,o=n.translation,s=n.rotation,l=n.scale,c=n.extensions,u=new c9(i,n.name||"_GLTF_ENTITY_"+r),d=u.transform;if(a){var h=d.localMatrix;h.copyFromArray(a),d.localMatrix=h}else o&&d.setPosition(o[0],o[1],o[2]),s&&d.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&d.setScale(l[0],l[1],l[2]);var _=n.children;if(_)for(var f=0;f<_.length;f++){var p=_[f],m=t.get(e.GLTFParserType.Entity,p);u.addChild(m)}return fB.executeExtensionsAdditiveAndParse(c,t,u,n),u},sO),e.GLTFEntityParser=_X([f_(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(_W(sN=function(){return fB.apply(this,arguments)},fB),sN.prototype.parse=function(t,r){var n=t.glTF.materials[r],i=t.glTFResource.engine,a=fB.executeExtensionsCreateAndParse(n.extensions,t,n);return a||((a=new hv(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n)),Promise.resolve(a).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),fB.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r})},sN._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new hm(t))},sN._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&cN.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},sN._parseStandardProperty=function(t,r,n){var i=n.pbrMetallicRoughness,a=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,u=n.alphaCutoff,d=n.doubleSided;if(i){var h=i.baseColorFactor,_=i.baseColorTexture,f=i.metallicFactor,p=i.roughnessFactor,m=i.metallicRoughnessTexture;h&&(r.baseColor=new cd(cd.linearToGammaSpace(h[0]),cd.linearToGammaSpace(h[1]),cd.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,fB.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===hv&&(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===hv||r.constructor===hy){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new cd(cd.linearToGammaSpace(l[0]),cd.linearToGammaSpace(l[1]),cd.linearToGammaSpace(l[2]))),a){var g=a.index,v=a.scale;e.GLTFMaterialParser._checkOtherTextureTransform(a,"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,S=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),S===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:S>e.TextureCoordinate.UV1&&cN.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case l$.OPAQUE:r.isTransparent=!1;break;case l$.BLEND:r.isTransparent=!0;break;case l$.MASK:r.alphaCutoff=null!=u?u:.5}},sN),e.GLTFMaterialParser=_X([f_(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(_W(sz=function(){return fB.apply(this,arguments)},fB),sz.prototype.parse=function(t,r){for(var n=function(r,n){var l=i.primitives[r];s[r]=new Promise(function(n){var s=fB.executeExtensionsCreateAndParse(l.extensions,t,l,i);if(s)fV(s,uk)?n(s):s.then(function(e){return n(e)});else{var c=new uk(o,i.name||r+""),u=new fR;u.mesh=c,t.contentRestorer.meshes.push(u),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,c,u,i,l,a,function(e){return null},function(e,r){var n=l.targets[r][e];if(!n)return null;var i=a.accessors[n];return ff.getAccessorBuffer(t,t.glTF.bufferViews,i)},function(){var r=a.accessors[l.indices];return t.get(e.GLTFParserType.Buffer).then(function(e){return ff.getAccessorData(a,r,e)})},t.params.keepMeshData).then(n)}})},i=t.glTF.meshes[r],a=t.glTF,o=t.glTFResource.engine,s=[],l=0,c=i.primitives.length;l<c;l++)n(l);return Promise.all(s)},sz._parseMeshFromGLTFPrimitive=function(t,r,n,i,a,o,s,l,c,u){var d,h=function(i){var a=_[f[i]],s=ff.getAccessorBuffer(t,o.bufferViews,a).then(function(t){var o,s,l,c=ff.getAccessorTypeSize(a.type),h=a.count,_=t.data,f=r.instanceId,p=t.vertexBindingInfos,m=a.normalized,g=ff.getElementFormat(a.componentType,c,m);if(m&&(s=ff.getNormalizedComponentScale(a.componentType)),t.interleaved){var S=a.byteOffset||0,C=t.stride;if(l=S%C,void 0===p[f]){o=new ub(i,l,g,x);var T=t.vertexBuffer;T||(T=new uP(v,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,u),t.vertexBuffer=T,n.vertexBuffers.push(new fw(T,t.restoreInfo))),r.setVertexBufferBinding(T,C,x),p[f]=x++}else o=new ub(i,l,g,p[f])}else{l=0,o=new ub(i,l,g,x);var A=t.vertexBuffer;A||(A=new uP(v,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,u),n.vertexBuffers.push(new fw(A,t.restoreInfo))),r.setVertexBufferBinding(A,t.stride,x),p[f]=x++}if(y.push(o),"POSITION"===i){d=h;var E=r.bounds,M=E.min,R=E.max;if(a.min&&a.max)M.copyFromArray(a.min),R.copyFromArray(a.max);else{var w=e.GLTFMeshParser._tempVector3;M.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var b=l/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=b+F*P;w.copyFromArray(_,L),l9.min(M,w,M),l9.max(R,w,R)}}m&&(M.scale(s),R.scale(s))}});S.push(s)},_=o.accessors,f=a.attributes,p=a.targets,m=a.indices,g=a.mode,v=r.engine,y=[],x=0,S=[];for(var C in f)h(C);return Promise.all(S).then(function(){if(r.setVertexElements(y),void 0!==m){var a=o.accessors[m],s=ff.getAccessorBuffer(t,o.bufferViews,a).then(function(e){r.setIndices(e.data),r.addSubMesh(0,a.count,g),n.indexBuffer=e.restoreInfo});S.push(s)}else r.addSubMesh(0,d,g);return p&&S.push(e.GLTFMeshParser._createBlendShape(r,n,i,_,p,l)),Promise.all(S).then(function(){return r.uploadData(!u),Promise.resolve(r)})})},sz._createBlendShape=function(e,t,r,n,i,a){for(var o=function(r,o){var c=s?s[r]:"blendShape"+r;l.push(Promise.all([a("POSITION",r),a("NORMAL",r),a("TANGENT",r)]).then(function(a){var o,s,l,u,d,h,_,f,p,m=a[0],g=a[1],v=a[2],y=i[r],x=null;m&&(o=n[y.POSITION],x=ff.bufferToVector3Array(m.data,m.stride,null!=(u=o.byteOffset)?u:0,o.count));var S=null;g&&(s=n[y.NORMAL],S=ff.bufferToVector3Array(g.data,g.stride,null!=(d=s.byteOffset)?d:0,s.count));var C=null;v&&(l=n[y.NORMAL],C=ff.bufferToVector3Array(v.data,v.stride,null!=(h=l.byteOffset)?h:0,l.count));var T=new uO(c);T.addFrame(1,x,S,C),e.addBlendShape(T),t.blendShapes.push(new fF(T,new fL(m.restoreInfo,m.stride,null!=(_=o.byteOffset)?_:0,o.count),g?new fL(g.restoreInfo,g.stride,null!=(f=s.byteOffset)?f:0,s.count):null,v?new fL(v.restoreInfo,v.stride,null!=(p=l.byteOffset)?p:0,l.count):null))}))},s=r.extras?r.extras.targetNames:null,l=[],c=0,u=i.length;c<u;c++)o(c);return Promise.all(l)},sz._tempVector3=new l9,sz),e.GLTFMeshParser=_X([f_(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(_W(sU=function(){return fB.apply(this,arguments)},fB),(sk=sU.prototype).parse=function(t,r){var n,i=t.glTF,a=i.scene,o=t.glTFResource,s=i.scenes[r],l=s.extensions,c=o.engine,u=s.nodes;if(1===u.length)n=t.get(e.GLTFParserType.Entity,u[0]);else{n=new c9(c,"GLTF_ROOT");for(var d=0;d<u.length;d++){var h=t.get(e.GLTFParserType.Entity,u[d]);n.addChild(h)}}n._hookResource=o,o._addReferCount(1),(void 0===a?0:a)===r&&(o.defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(t,u[f]));return Promise.all(_).then(function(){return fB.executeExtensionsAdditiveAndParse(l,t,n,s),n})},sk._parseEntityComponent=function(t,r){var n,i=this,a=t.glTF,o=t.glTFResource,s=a.nodes[r],l=s.camera,c=s.mesh,u=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,a.cameras[l],u),void 0!==c&&(n=this._createRenderer(t,s,u)),Promise.resolve(n).then(function(){var e=[],r=s.children;if(r)for(var n=0;n<r.length;n++)e.push(i._parseEntityComponent(t,r[n]));return Promise.all(e)})},sk._createCamera=function(t,r,n){var i=r.orthographic,a=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===lZ.ORTHOGRAPHIC){var l=i.xmag,c=i.ymag,u=i.zfar,d=i.znear;s.isOrthographic=!0,void 0!==d&&(s.nearClipPlane=d),void 0!==u&&(s.farClipPlane=u),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===lZ.PERSPECTIVE){var h=a.aspectRatio,_=a.yfov,f=a.zfar,p=a.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},sk._createRenderer=function(t,r,n){for(var i=function(r){var i=c[r],l=i.material;d.push(Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),void 0!==l&&t.get(e.GLTFParserType.Material,l)]).then(function(o){var s,l=o[1],c=o[2],d=o[0][r];if(c||(c=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),l||u){var h=n.addComponent(u1);h.mesh=d,l&&(h.rootBone=l._rootBone,h.bones=l._bones,a._computeLocalBounds(h,d,l._bones,l._rootBone,l.inverseBindMatrices),h.skin=l),u&&(h.blendShapeWeights=new Float32Array(u)),s=h}else(s=n.addComponent(uz)).mesh=d;s.setMaterial(c),d.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(s.enableVertexColor=!0)}),fB.executeExtensionsAdditiveAndParse(i.extensions,t,s,i)}))},a=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,u=r.weights||l.weights,d=[],h=0;h<c.length;h++)i(h);return Promise.all(d)},sk._computeLocalBounds=function(e,t,r,n,i){var a=r.indexOf(n);if(-1!==a)ct.transform(t.bounds,i[a],e.localBounds);else{var o=new cs(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,i,n,o);0!==s?(cs.multiplyScalar(o,1/s,o),ct.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},sk._computeApproximateBindMatrix=function(e,t,r,n){for(var i=0,a=r.children,o=0,s=a.length;o<s;o++){var l=a[o],c=e.indexOf(l);-1!==c?(cs.add(n,t[c],n),i++):i+=this._computeApproximateBindMatrix(e,t,l,n)}return i},sU),e.GLTFSceneParser=_X([f_(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(_W(sG=function(){return fB.apply(this,arguments)},fB),(sH=sG.prototype).parse=function(t,r){var n=this,i=t.glTF,a=i.skins[r],o=a.inverseBindMatrices,s=a.skeleton,l=a.joints,c=a.name,u=l.length,d=new u0(void 0===c?"SKIN_"+r:c);d.inverseBindMatrices.length=u,d._bones.length=u;var h=i.accessors[o];return Promise.resolve(ff.getAccessorBuffer(t,i.bufferViews,h).then(function(r){for(var i=t.get(e.GLTFParserType.Entity),a=r.data,o=0;o<u;o++){var c=new cs;c.copyFromArray(a,16*o),d.inverseBindMatrices[o]=c;var h=i[l[o]];if(d._bones[o]=h,d.joints[o]=h.name,void 0!==s){var _=i[s];d._rootBone=_,d.skeleton=_.name}else{var f=n._findSkeletonRootBone(l,i);if(f)d._rootBone=f,d.skeleton=f.name;else throw"Failed to find skeleton root bone."}}return d}))},sH._findSkeletonRootBone=function(e,t){for(var r,n={},i=_6(e);!(r=i()).done;){for(var a=r.value,o=[],s=t[a];s;)o.unshift(s),s=s.parent;n[a]=o}for(var l=null,c=0;;c++){var u=n[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=n[e[h]]).length||d!==u[c])return l;l=d}},sG),e.GLTFSkinParser=_X([f_(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(_W(sW=function(){return fB.apply(this,arguments)},fB),sW.prototype.parse=function(t,r){var n=t.glTF.textures[r],i=t.glTFResource,a=t.glTF,o=i.engine,s=i.url,l=n.sampler,c=n.source,u=n.name,d=n.extensions,h=a.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=fB.executeExtensionsCreateAndParse(d,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&ff.getSamplerInfo(a.samplers[l]);if(_){var x=_.lastIndexOf("."),S=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:c1.resolveAbsoluteUrl(s,_),type:S,params:{mipmap:null==y?void 0:y.mipmap}}).then(function(e){return e.name=u||m||e.name||"texture_"+r,v&&ff.parseSampler(e,y),e})}else{var C=a.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[C.buffer],i=new Uint8Array(n,C.byteOffset,C.byteLength);return ff.loadImageBuffer(i,p).then(function(e){var n=new ck(o,e.width,e.height,void 0,null==y?void 0:y.mipmap);n.setImageSource(e),n.generateMipmaps(),n.name=u||m||"texture_"+r,v&&ff.parseSampler(n,y);var i=new fM(n,C,p);return t.contentRestorer.bufferTextures.push(i),n})})}}return Promise.resolve(g).then(function(e){return fB.executeExtensionsAdditiveAndParse(d,t,e,n),e})},sW._wrapMap=((sX={})[l2.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,sX[l2.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,sX[l2.REPEAT]=e.TextureWrapMode.Repeat,sX),sW),e.GLTFTextureParser=_X([f_(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(_W(sK=function(){return fB.apply(this,arguments)},fB),sK.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,i=t.extensionsRequired,a=Number(r);if(!(a>=2&&a<3))throw"Only support glTF 2.x.";if(n){cN.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];fB.hasExtensionParser(s)||cN.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(i){cN.info("extensionsRequired: "+i);for(var l=0;l<i.length;l++){var c=i[l];fB.hasExtensionParser(c)||cN.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},sK),e.GLTFValidator=_X([f_(e.GLTFParserType.Validator)],e.GLTFValidator);var fO=(_W(sj=function(){return hf.apply(this,arguments)},hf),sj.prototype.load=function(e,t){var r=e.url,n=e.params,i=new fl(t.engine,r);return new fc(i,t,_G({keepMeshData:!1},n)).parse()},sj);fO=_X([dr(e.AssetType.GLTF,["gltf","glb"])],fO);var fN=Math.PI,fz=(_W(sY=function(){return hf.apply(this,arguments)},hf),sY.prototype.load=function(t,r){var n=this;return new de(function(i,a){var o=r.engine;n.request(t.url,{type:"arraybuffer"}).then(function(t){for(var r=new Uint8Array(t),n=fz._parseHeader(r),a=n.width,s=n.height,l=n.dataPosition,c=fz._readPixels(r.subarray(l),a,s),u=s>>1,d=fz._convertToCubemap(c,a,s,u),h=new cH(o,u),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,d[_],0);h.generateMipmaps(),i(h)}).catch(a)})},sY._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)]},sY._createCubemapData=function(e,t,r,n,i){for(var a=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,u=0;u<e;u++){for(var d=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(d).scale(c).add(d);f.normalize();var p=this._calcProjectionSpherical(f,r,n,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;a[m]=p.r,a[m+1]=p.g,a[m+2]=p.b,a[m+3]=p.a,d.add(o),h.add(s)}c+=l}return a},sY._calcProjectionSpherical=function(e,t,r,n){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-fN;)i+=2*fN;for(;i>fN;)i-=2*fN;var o=i/fN,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(a/fN*n);l<0?l=0:l>=n&&(l=n-1);var c=(n-l-1)*r*4+4*s,u=t[c],d=t[c+1],h=t[c+2],_=t[c+3];return new cd(u,d,h,_)},sY._readStringLine=function(e,t){for(var r="",n="",i=t;i<e.length-t&&"\n"!=(n=String.fromCharCode(e[i]));i++)r+=n;return r},sY._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var i=!1,a=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?a=!0:0==n.length&&(i=!0);while(!i);if(!a)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}},sY._readPixels=function(e,t,r){for(var n=e.byteLength,i=new Uint8Array(4*t*r),a=0,o=0,s=4*t,l=new Uint8Array(4),c=new Uint8Array(s),u=r;u>0&&o<n;){if(l[0]=e[o++],l[1]=e[o++],l[2]=e[o++],l[3]=e[o++],2!=l[0]||2!=l[1]||(l[2]<<8|l[3])!=t)throw"HDR Bad header format, wrong scan line width";for(var d=0,h=void 0;d<s&&o<n;){var _=(h=e[o++])>128;if(_&&(h-=128),0===h||d+h>s)throw"HDR Bad Format, bad scanline data (run)";if(_)for(var f=e[o++],p=0;p<h;p++)c[d++]=f;else c.set(e.subarray(o,o+h),d),d+=h,o+=h}for(var m=0;m<t;m++){var g=0;i[a]=c[m+g],g+=t,i[a+1]=c[m+g],g+=t,i[a+2]=c[m+g],g+=t,i[a+3]=c[m+g],a+=4}u--}return i},sY._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},sY._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},sY._rightBottomBack=new l9(1,-1,-1),sY._rightBottomFront=new l9(1,-1,1),sY._rightUpBack=new l9(1,1,-1),sY._rightUpFront=new l9(1,1,1),sY._leftBottomBack=new l9(-1,-1,-1),sY._leftBottomFront=new l9(-1,-1,1),sY._leftUpBack=new l9(-1,1,-1),sY._leftUpFront=new l9(-1,1,1),sY._faceRight=[sY._rightBottomBack,sY._rightBottomFront,sY._rightUpBack,sY._rightUpFront],sY._faceLeft=[sY._leftBottomFront,sY._leftBottomBack,sY._leftUpFront,sY._leftUpBack],sY._faceUp=[sY._leftBottomFront,sY._rightBottomFront,sY._leftBottomBack,sY._rightBottomBack],sY._faceBottom=[sY._leftUpBack,sY._rightUpBack,sY._leftUpFront,sY._rightUpFront],sY._faceFront=[sY._leftBottomBack,sY._rightBottomBack,sY._leftUpBack,sY._rightUpBack],sY._faceBack=[sY._rightBottomFront,sY._leftBottomFront,sY._rightUpFront,sY._leftUpFront],sY._tempVector3=new l9,sY._temp2Vector3=new l9,sY._temp3Vector3=new l9,sY._temp4Vector3=new l9,sY._temp5Vector3=new l9,sY);fz=_X([dr(e.AssetType.HDR,["hdr"])],fz);var fU=(_W(sq=function(){return hf.apply(this,arguments)},hf),sq.prototype.load=function(e){return this.request(e.url,_G({},e,{type:"json"}))},sq);fU=_X([dr(e.AssetType.JSON,["json"],!1)],fU);var fk={parse:function(t,r,n,i){if(void 0===i&&(i=!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 a=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*a),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*a,s),glTypeSize:o.getUint32(2*a,s),glFormat:o.getUint32(3*a,s),glInternalFormat:o.getUint32(4*a,s),glBaseInternalFormat:o.getUint32(5*a,s),pixelWidth:o.getUint32(6*a,s),pixelHeight:o.getUint32(7*a,s),pixelDepth:o.getUint32(8*a,s),numberOfArrayElements:o.getUint32(9*a,s),numberOfFaces:o.getUint32(10*a,s),numberOfMipmapLevels:o.getUint32(11*a,s),bytesOfKeyValueData:o.getUint32(12*a,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,i=e.pixelWidth,a=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 u=new Uint8Array(e.buffer,n,l);r.push({data:u,width:i,height:a}),n+=l+(3-(l+3)%4)}i=Math.max(1,.5*i),a=Math.max(1,.5*a)}return r}(l,!0)),i&&(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 fG(e){var t=fk.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var fH=(_W(sQ=function(){return hf.apply(this,arguments)},hf),sQ.prototype.load=function(t,r){var n=this;return new de(function(i,a){Promise.all(t.urls.map(function(e){return n.request(e,_G({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,i,a=[],o=0;o<e.length;o++){var s=fk.parse(e[o],1,!0,!0);a.push(s.mipmaps),0===o&&(n=s.pixelWidth,i=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:a,engineFormat:r,internalFormat:t,width:n,height:i}}(t),a=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new cH(r.engine,a,s,l),u=0;u<6;u++)for(var d=o[u].length,h=0;h<d;h++){var _=o[u][h],f=_.data,p=_.width,m=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,f,h,0,0,p,m)}i(c)}).catch(function(e){a(e)})})},sQ);fH=_X([dr(e.AssetType.KTXCube,[])],fH);var fW=(_W(sZ=function(){return hf.apply(this,arguments)},hf),sZ.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,_G({},e,{type:"arraybuffer"})).then(function(e){for(var r=fG(e),i=r.width,a=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new ck(t.engine,i,a,s,l),u=0;u<o.length;u++){var d=o[u],h=d.width,_=d.height,f=d.data;c.setPixelBuffer(f,u,0,0,h,_)}n(c)}).catch(function(e){i(e)})})},sZ);fW=_X([dr(e.AssetType.KTX,["ktx"])],fW);var fX=(_W(sJ=function(){return hf.apply(this,arguments)},hf),sJ.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,_G({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,i=r.value;switch(n){case"Vector2":h.setVector2(e,new cc(i.x,i.y));break;case"Vector3":h.setVector3(e,new l9(i.x,i.y,i.z));break;case"Vector4":h.setVector4(e,new cu(i.x,i.y,i.z,i.w));break;case"Color":h.setColor(e,new cd(i.r,i.g,i.b,i.a));break;case"Float":h.setFloat(e,i);break;case"Texture":d.push(t.getResourceByRef(i).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,i?1:0);break;case"Integer":h.setInt(e,Number(i))}},i=t.engine,a=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new dL(i,uy.find(o));u.name=a;var d=[],h=u.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 i in n)e(t[r],i,n[i]);else t[r]=n}(u,"renderState",c),Promise.all(d).then(function(){n(u)})}).catch(i)})},sJ);fX=_X([dr(e.AssetType.Material,["json"])],fX);var fK=(_W(s$=function(){return hf.apply(this,arguments)},hf),s$.prototype.load=function(e,t){var r=this;return new de(function(n,i){r.request(e.url,_G({},e,{type:"arraybuffer"})).then(function(e){return fe(e,t.engine)}).then(function(e){n(e)}).catch(i)})},s$);fK=_X([dr(e.AssetType.Mesh,["mesh"])],fK);var fj=(_W(s0=function(){return hf.apply(this,arguments)},hf),(s1=s0.prototype).load=function(e,t){var r=this;return new de(function(n,i){var a=e.url;r._registerFont(a,a).then(function(){n(new cj(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},s1._registerFont=function(e,t){return fo(function(){var r;return _K(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]}})})()},s0);fj=_X([dr(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],fj);var fY=(_W(s2=function(){var e;return e=hf.apply(this,arguments)||this,e._tempRect=new ch,e._tempVec2=new cc,e._tempVec4=new cu,e},hf),(s3=s2.prototype).load=function(t,r){var n=this;return new de(function(i,a,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=n.request(t.url,_G({},t,{type:"json"}));l.push(c),c.then(function(o){var s=o.atlasItems,c=o.mipmap,u=o.anisoLevel,d=o.filterMode,h=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,m=r.engine,g=new dO(m);if(p<0){i(g);return}l.length=0;for(var v=0;v<s.length;v++)!function(i){var o,p=s[i];if(p.img)l.push(r.load({url:c1.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:c}}).then(function(e){u&&(e.anisoLevel=u),void 0!==d&&(e.filterMode=d),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(a));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);de.all(l).then(function(){i(g)}).catch(a)}).catch(a)})},s3._makeSprite=function(e,t,r){var n=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new dN(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 d=1/r.width,h=1/r.height;if(u.atlasRegion.set(a.x*d,a.y*h,a.w*d,a.h*h),i){var _=i.x,f=i.y,p=i.z,m=i.w;u.atlasRegionOffset.set(_*d,f*h,p*d,m*h)}t.atlasRotated&&(u.atlasRotated=!0)}return isNaN(l)||(u.width=l),isNaN(c)||(u.height=c),u},s2);fY=_X([dr(e.AssetType.SpriteAtlas,["atlas"],!1)],fY);var fq=(_W(s4=function(){return hf.apply(this,arguments)},hf),(s5=s4.prototype).load=function(e,t){var r=this;return this.request(e.url,_G({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},s5._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},s5._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new dN(e.engine,r,t.region,t.pivot,t.border),i=t.width,a=t.height;return isNaN(i)||(n.width=i),isNaN(a)||(n.height=a),n}):new de(function(r){var n=new dN(e.engine,null,t.region,t.pivot,t.border),i=t.width,a=t.height;isNaN(i)||(n.width=i),isNaN(a)||(n.height=a),r(n)})},s4);fq=_X([dr(e.AssetType.Sprite,["sprite"],!1)],fq);var fQ=(_W(s8=function(e,t,r){var n;return(n=cF.call(this,e)||this).url=t,n.requestConfig=r,n},cF),s8.prototype.restoreContent=function(){var e=this;return hu(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},s8),fZ=(_W(s6=function(){return hf.apply(this,arguments)},hf),s6.prototype.load=function(e,t){var r=this;return new de(function(n,i){var a=e.url,o=_G({},e,{type:"image"});r.request(a,o).then(function(r){var i,s=null!=(i=e.params)?i:{},l=s.format,c=s.mipmap,u=s.anisoLevel,d=s.wrapModeU,h=s.wrapModeV,_=s.filterMode,f=new ck(t.engine,r.width,r.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==a.indexOf("data:")){var p=a.lastIndexOf("/");f.name=a.substring(p+1)}t.addContentRestorer(new fQ(f,a,o)),n(f)}).catch(function(e){i(e)})})},s6);fZ=_X([dr(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],fZ);var fJ=(_W(s7=function(e,t,r){var n;return(n=cF.call(this,e)||this).urls=t,n.requestConfig=r,n},cF),s7.prototype.restoreContent=function(){var t=this;return new de(function(r,n){Promise.all(t.urls.map(function(e){return hu(e,t.requestConfig)})).then(function(n){for(var i=t.resource,a=0;a<6;a++)i.setImageSource(e.TextureCubeFace.PositiveX+a,n[a],0);i.generateMipmaps(),r(i)}).catch(function(e){n(e)})})},s7),f$=(_W(s9=function(){return hf.apply(this,arguments)},hf),s9.prototype.load=function(t,r){var n=this;return new de(function(i,a){var o=t.urls,s=_G({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],a=n.width;if(a!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new cH(r.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new fJ(l,o,s)),i(l)}).catch(function(e){a(e)})})},s9);f$=_X([dr(e.AssetType.TextureCube,[""])],f$);var f0=(_W(le=function(){return hf.apply(this,arguments)},hf),le.prototype.load=function(t,r){var n=this,i=r.engine;return new de(function(a,o){n.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){i.sceneManager.activeScene=e,a()})}).catch(o)})},le);f0=_X([dr(e.AssetType.Project,["proj"],!1)],f0);var f1=(_W(lt=function(){return hf.apply(this,arguments)},hf),lt.prototype.load=function(t,r){var n=this,i=r.engine;return new de(function(a,o){n.request(t.url,{type:"json"}).then(function(t){return _9.parse(i,t).then(function(n){var i,o=[],s=t.scene.ambient;if(s){var l="Custom"===s.specularMode,c=s.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=s.diffuseIntensity,n.ambientLight.specularIntensity=s.specularIntensity,n.ambientLight.diffuseMode=s.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,l&&s.customAmbientLight&&o.push(r.getResourceByRef(s.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&o.push(r.getResourceByRef(s.ambientLight).then(function(e){l||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(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 d=r.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),h=r.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});o.push(d,h)}else cN.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var _=r.getResourceByRef(u.texture).then(function(e){n.background.texture=e});o.push(_)}}var f=t.scene.shadow;return f&&(void 0!=f.castShadows&&(n.castShadows=f.castShadows),void 0!=f.shadowResolution&&(n.shadowResolution=f.shadowResolution),void 0!=f.shadowDistance&&(n.shadowDistance=f.shadowDistance),void 0!=f.shadowCascades&&(n.shadowCascades=f.shadowCascades),n.shadowTwoCascadeSplits=null!=(i=f.shadowTwoCascadeSplits)?i:n.shadowTwoCascadeSplits,f.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(f.shadowFourCascadeSplits)),Promise.all(o).then(function(){a(n)})})}).catch(o)})},lt);f1=_X([dr(e.AssetType.Scene,["scene"],!0)],f1),_3.registerCustomParseComponent("TextRenderer",fo(function(e,t){var r;return _K(this,function(n){return(r=t.props).font||(e.font=cj.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var f2=(_W(lr=function(){return fD.apply(this,arguments)},fD),(ln=lr.prototype).createAndParse=function(t,r,n,i){var a=this;this._initialize();var o=t.glTF,s=t.glTFResource.engine,l=o.bufferViews,c=o.accessors,u=r.bufferView,d=r.attributes,h={},_={};for(var f in d)h[f]=d[f];for(var p in n.attributes)if(void 0!==d[p]){var m=c[n.attributes[p]];_[p]=ff.getComponentType(m.componentType).name}var g=c[n.indices],v={attributeIDs:h,attributeTypes:_,useUniqueIDs:!0,indexType:ff.getComponentType(g.componentType).name};return t.get(e.GLTFParserType.Buffer).then(function(e){var r=ff.getBufferViewData(l[u],e);return f2._decoder.decode(r,v).then(function(e){var r=new uk(s,i.name);return a._parseMeshFromGLTFPrimitiveDraco(r,i,n,o,function(t){for(var r=0;r<e.attributes.length;r++)if(e.attributes[r].name===t)return e.attributes[r].array;return null},function(e,t){throw"BlendShape animation is not supported when using draco."},function(){return e.index.array},t.params.keepMeshData)})})},ln._initialize=function(){f2._decoder||(f2._decoder=new _k)},ln._parseMeshFromGLTFPrimitiveDraco=function(t,r,n,i,a,o,s,l){var c,u=n.attributes,d=n.targets,h=n.indices,_=n.mode,f=i.accessors,p=f[u.POSITION],m=a("POSITION"),g=ff.floatBufferToVector3Array(m);t.setPositions(g);var v=t.bounds;if(c=p.count,p.min&&p.max)v.min.copyFromArray(p.min),v.max.copyFromArray(p.max);else{var y=f2._tempVector3,x=v.min,S=v.max;x.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),S.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var C=m.length/c,T=0;T<c;T++){var A=T*C;y.copyFromArray(m,A),l9.min(x,y,x),l9.max(S,y,S)}}for(var E in u)if("POSITION"!==E){var M=a(E);switch(E){case"NORMAL":var R=ff.floatBufferToVector3Array(M);t.setNormals(R);break;case"TEXCOORD_0":var w=ff.floatBufferToVector2Array(M);t.setUVs(w,0);break;case"TEXCOORD_1":var b=ff.floatBufferToVector2Array(M);t.setUVs(b,1);break;case"TEXCOORD_2":var P=ff.floatBufferToVector2Array(M);t.setUVs(P,2);break;case"TEXCOORD_3":var F=ff.floatBufferToVector2Array(M);t.setUVs(F,3);break;case"TEXCOORD_4":var L=ff.floatBufferToVector2Array(M);t.setUVs(L,4);break;case"TEXCOORD_5":var D=ff.floatBufferToVector2Array(M);t.setUVs(D,5);break;case"TEXCOORD_6":var B=ff.floatBufferToVector2Array(M);t.setUVs(B,6);break;case"TEXCOORD_7":var I=ff.floatBufferToVector2Array(M);t.setUVs(I,7);break;case"COLOR_0":var V=ff.floatBufferToColorArray(M,f[u.COLOR_0].type===lY.VEC3);t.setColors(V);break;case"TANGENT":var O=ff.floatBufferToVector4Array(M);t.setTangents(O);break;case"JOINTS_0":var N=ff.floatBufferToVector4Array(M);t.setBoneIndices(N);break;case"WEIGHTS_0":var z=ff.floatBufferToVector4Array(M);t.setBoneWeights(z)}}if(void 0!==h){var U=i.accessors[h],k=s();t.setIndices(k),t.addSubMesh(0,U.count,_)}else t.addSubMesh(0,c,_);return d&&e.GLTFMeshParser._createBlendShape(t,null,r,f,d,o),t.uploadData(!l),Promise.resolve(t)},lr._tempVector3=new l9,lr);f2=_X([fI("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],f2);var f3=(_W(li=function(){return fD.apply(this,arguments)},fD),li.prototype.additiveParse=function(e,t,r){var n,i=e.glTF.extensions.KHR_lights_punctual.lights[r.light],a=i.color,o=i.intensity,s=i.type,l=i.range,c=i.spot,u=e.glTFResource;if("directional"===s?n=t.addComponent(dJ):"point"===s?n=t.addComponent(d$):"spot"===s&&(n=t.addComponent(d0)),a&&n.color.set(a[0],a[1],a[2],1),n.intensity=void 0===o?1:o,l&&!fV(n,dJ)&&(n.distance=l),c&&fV(n,d0)){var d=c.innerConeAngle,h=void 0===d?0:d,_=c.outerConeAngle;n.angle=h,n.penumbra=(void 0===_?Math.PI/4:_)-h}u.lights||(u.lights=[]),u.lights.push(n)},li);f3=_X([fI("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],f3);var f4=(_W(la=function(){return fD.apply(this,arguments)},fD),la.prototype.additiveParse=function(t,r,n){var i=n.clearcoatFactor,a=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===i?0:i,r.clearCoatRoughness=void 0===o?0:o,a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Clear coat"),t.get(e.GLTFParserType.Texture,a.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}))},la);f4=_X([fI("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],f4);var f5=(_W(lo=function(){return fD.apply(this,arguments)},fD),lo.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},lo);f5=_X([fI("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],f5);var f8=(_W(ls=function(){return fD.apply(this,arguments)},fD),ls.prototype.createAndParse=function(t,r,n){var i=t.glTFResource.engine,a=new hy(i),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,u=r.specularGlossinessTexture;return o&&(a.baseColor=new cd(cd.linearToGammaSpace(o[0]),cd.linearToGammaSpace(o[1]),cd.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){a.baseTexture=e,fB.executeExtensionsAdditiveAndParse(s.extensions,t,a,s)}),l&&(a.specularColor=new cd(cd.linearToGammaSpace(l[0]),cd.linearToGammaSpace(l[1]),cd.linearToGammaSpace(l[2]))),void 0!==c&&(a.glossiness=c),u&&(e.GLTFMaterialParser._checkOtherTextureTransform(u,"Specular glossiness"),t.get(e.GLTFParserType.Texture,u.index).then(function(e){a.specularGlossinessTexture=e})),a.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n),a},ls);f8=_X([fI("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],f8);var f6=(_W(ll=function(){return fD.apply(this,arguments)},fD),ll.prototype.createAndParse=function(t,r,n){var i=t.glTFResource.engine,a=new hx(i);return a.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n),a},ll);f6=_X([fI("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],f6);var f7=(_W(lc=function(){return fD.apply(this,arguments)},fD),lc.prototype.additiveParse=function(t,r,n){var i=t.glTF.extensions.KHR_materials_variants.variants,a=t.glTFResource,o=n.mappings;a.extensionsData||(a.extensionsData={});var s=[];a.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var a=o[n],l=a.material,c=a.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return i[e].name})})})}(l)},lc);f7=_X([fI("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],f7);var f9=(_W(lu=function(){return fD.apply(this,arguments)},fD),lu);f9=_X([fI("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],f9);var pe=(_W(ld=function(){return fD.apply(this,arguments)},fD),ld.prototype.createAndParse=function(t,r,n){return fo(function(){var i,a,o,s,l,c,u,d,h,_,f,p,m,g,v;return _K(this,function(y){return(i=t.glTF,o=(a=t.glTFResource).engine,s=a.url,l=n.sampler,c=n.name,u=r.source,h=(d=i.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&ff.getSamplerInfo(i.samplers[l]),h)?(g=h.lastIndexOf("."),[2,o.resourceManager.load({url:c1.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&ff.parseSampler(e,m),e})]):(v=i.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,v.buffer).then(function(r){var n=new Uint8Array(r,v.byteOffset,v.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,i=t.targetFormat,a=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,i,a)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&ff.parseSampler(e,m);var r=new fM(e,v,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},ld);pe=_X([fI("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],pe);var pt=(_W(lh=function(){return fD.apply(this,arguments)},fD),lh.prototype.additiveParse=function(e,t,r){var n=r.offset,i=r.rotation,a=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&cN.warn("rotation in KHR_texture_transform is not supported now"),o&&cN.warn("texCoord in KHR_texture_transform is not supported now")},lh);pt=_X([fI("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],pt);var pr=(_W(l_=function(){return fD.apply(this,arguments)},fD),l_.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},l_);pr=_X([fI("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],pr);var pn=(_W(lf=function(){return fD.apply(this,arguments)},fD),lf.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new hb;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},lf);pn=_X([fI("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],pn);var pi="1.1.2";for(var pa in console.log("Galacean engine version: "+pi),_g)hf.registerClass(pa,_g[pa]);e.AmbientLight=dQ,e.AnimationClip=hP,e.AnimationClipCurveBinding=hw,e.AnimationCurve=hF,e.AnimationEvent=hb,e.Animator=hO,e.AnimatorController=hN,e.AnimatorControllerLayer=hz,e.AnimatorState=hk,e.AnimatorStateMachine=hG,e.AnimatorStateTransition=hD,e.AssetPromise=de,e.Background=dY,e.BaseMaterial=hp,e.Basic2DBatcher=u2,e.BasicRenderPipeline=ho,e.BlendShape=uO,e.BlendShapeFrame=uV,e.BlendState=uf,e.BlinnPhongMaterial=hm,e.BoolUpdateFlag=c5,e.BoundingBox=ct,e.BoundingFrustum=ci,e.BoundingSphere=ce,e.BoxColliderShape=dE,e.BoxShape=_i,e.Buffer=uP,e.BufferMesh=uN,e.BufferUtil=uw,e.Burst=_t,e.Canvas=dK,e.CapsuleColliderShape=dw,e.CharacterController=d_,e.CircleShape=_a,e.CloneManager=cw,e.ColliderShape=dA,e.CollisionUtil=cr,e.Color=cd,e.ColorOverLifetimeModule=h$,e.Component=cZ,e.ComponentMap=_5,e.ConeShape=_o,e.ContentRestorer=cF,e.CubeProbe=_m,e.CurveKey=h5,e.DepthState=up,e.DirectLight=dJ,e.DynamicCollider=df,e.EmissionModule=h1,e.Engine=dX,e.EngineObject=cb,e.Entity=c9,e.EventDispatcher=cY,e.FixedJoint=dy,e.Font=cj,e.GLTFExtensionParser=fD,e.GLTFParser=fB,e.GLTFParserContext=fc,e.GLTFResource=fl,e.GLTFUtils=ff,e.GradientAlphaKey=hQ,e.GradientColorKey=hq,e.HemisphereShape=_s,e.HingeJoint=dx,e.HitResult=dp,e.IndexBufferBinding=uF,e.InputManager=dF,e.JointLimits=dC,e.JointMotor=dT,e.Keyframe=hH,e.Light=dZ,e.Loader=hf,e.Logger=cN,e.MainModule=h2,e.Material=dL,e.MathUtil=l7,e.Matrix=cs,e.Matrix3x3=ca,e.Mesh=uB,e.MeshRenderer=uz,e.ModelMesh=uk,e.PBRBaseMaterial=hg,e.PBRMaterial=hv,e.PBRSpecularMaterial=hy,e.ParticleCompositeCurve=h0,e.ParticleCompositeGradient=hZ,e.ParticleCurve=h4,e.ParticleGenerator=h9,e.ParticleGradient=hY,e.ParticleMaterial=_e,e.ParticleRenderer=hj,e.PhysicsMaterial=dm,e.PhysicsScene=dh,e.Plane=cn,e.PlaneColliderShape=dR,e.PointLight=d$,e.Pointer=ds,e.PrefabParser=_4,e.Primitive=uD,e.PrimitiveMesh=u$,e.Probe=_h,e.Quaternion=co,e.Rand=cf,e.RasterState=um,e.Ray=cl,e.Rect=ch,e.ReferResource=cP,e.ReflectionParser=_3,e.RenderPass=d5,e.RenderQueue=d6,e.RenderState=uv,e.RenderTarget=cU,e.RenderTargetBlendState=u_,e.ResourceManager=dt,e.RotationOverLifetimeModule=h3,e.Scene=d2,e.SceneManager=u9,e.SceneParser=_9,e.Script=d3,e.Shader=uy,e.ShaderData=ux,e.ShaderFactory=ua,e.ShaderMacro=ut,e.ShaderMacroCollection=ur,e.ShaderPass=ud,e.ShaderProperty=cq,e.ShaderTagKey=uo,e.SizeOverLifetimeModule=h8,e.Skin=u0,e.SkinnedMeshRenderer=u1,e.Sky=dj,e.SkyBoxMaterial=hW,e.SkyProceduralMaterial=hX,e.SphereColliderShape=dM,e.SphereShape=_l,e.SphericalHarmonics3=c_,e.SpotLight=d0,e.SpringJoint=dS,e.Sprite=dN,e.SpriteAtlas=dO,e.SpriteMask=uR,e.SpriteRenderer=dk,e.StateMachineScript=hU,e.StaticCollider=dg,e.StencilState=ug,e.SubMesh=uL,e.SubShader=uh,e.SystemInfo=du,e.TextRenderer=dW,e.TextUtils=cX,e.Texture=cz,e.Texture2D=ck,e.Texture2DArray=cG,e.TextureCube=cH,e.TextureSheetAnimationModule=h6,e.Time=cQ,e.TrailMaterial=_c,e.TrailRenderer=_d,e.Transform=c6,e.UnlitMaterial=hx,e.Utils=c1,e.Vector2=cc,e.Vector3=l9,e.Vector4=cu,e.VelocityOverLifetimeModule=h7,e.VertexBufferBinding=uI,e.VertexElement=ub,e.WebCanvas=_T,e.WebGLEngine=_A,e.WebGLGraphicDevice=_V,e.assignmentClone=cE,e.decode=fe,e.deepClone=cR,e.dependentComponents=c$,e.ignoreClone=cA,e.parseSingleKTX=fG,e.registerGLTFExtension=fI,e.registerGLTFParser=f_,e.request=hu,e.resourceLoader=dr,e.shallowClone=cM,e.version=pi,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,(lm=e.ContainmentType||(e.ContainmentType={}))[lm.Disjoint=0]="Disjoint",lm[lm.Contains=1]="Contains",lm[lm.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(lg=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[lg.Back=0]="Back",lg[lg.Front=1]="Front",lg[lg.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(lv=e.FrustumFace||(e.FrustumFace={}))[lv.Near=0]="Near",lv[lv.Far=1]="Far",lv[lv.Left=2]="Left",lv[lv.Right=3]="Right",lv[lv.Bottom=4]="Bottom",lv[lv.Top=5]="Top";var i,a,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,S,C,T,A,E,M,R,w,b,P,F,L,D,B,I,V,O,N,z,U,k,G,H,W,X,K,j,Y,q,Q,Z,J,$,ee,et,er,en,ei,ea,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eS,eC,eT,eA,eE,eM,eR,ew,eb,eP,eF,eL,eD,eB,eI,eV,eO,eN,ez,eU,ek,eG,eH,eW,eX,eK,ej,eY,eq,eQ,eZ,eJ,e$,e0,e1,e2,e3,e4,e5,e8,e6,e7,e9,te,tt,tr,tn,ti,ta,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv,ty,tx,tS,tC,tT,tA,tE,tM,tR,tw,tb,tP,tF,tL,tD,tB,tI,tV,tO,tN,tz,tU,tk,tG,tH,tW,tX,tK,tj,tY,tq,tQ,tZ,tJ,t$,t0,t1,t2,t3,t4,t5,t8,t6,t7,t9,re,rt,rr,rn,ri,ra,ro,rs,rl,rc,ru,rd,rh,r_,rf,rp,rm,rg,rv,ry,rx,rS,rC,rT,rA,rE,rM,rR,rw,rb,rP,rF,rL,rD,rB,rI,rV,rO,rN,rz,rU,rk,rG,rH,rW,rX,rK,rj,rY,rq,rQ,rZ,rJ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ne,nt,nr,nn,ni,na,no,ns,nl,nc,nu,nd,nh,n_,nf,np,nm,ng,nv,ny,nx,nS,nC,nT,nA,nE,nM,nR,nw,nb,nP,nF,nL,nD,nB,nI,nV,nO,nN,nz,nU,nk,nG,nH,nW,nX,nK,nj,nY,nq,nQ,nZ,nJ,n$,n0,n1,n2,n3,n4,n5,n8,n6,n7,n9,ie,it,ir,ii,ia,io,is,il,ic,iu,id,ih,i_,ip,im,ig,iv,iy,ix,iS,iC,iT,iA,iE,iM,iR,iw,ib,iP,iF,iL,iD,iB,iI,iV,iO,iN,iz,iU,ik,iG,iH,iW,iX,iK,ij,iY,iq,iQ,iZ,iJ,i$,i0,i1,i2,i3,i4,i5,i8,i6,i7,i9,ae,at,ar,an,ai,aa,ao,as,al,ac,au,ad,ah,a_,af,ap,am,ag,av,ay,ax,aS,aC,aT,aA,aE,aM,aR,aw,ab,aP,aF,aL,aD,aB,aI,aV,aO,aN,az,aU,ak,aG,aH,aW,aX,aK,aj,aY,aq,aQ,aZ,aJ,a$,a0,a1,a2,a3,a4,a5,a8,a6,a7,a9,oe,ot,or,on,oi,oa,oo,os,ol,oc,ou,od,oh,o_,of,op,om,og,ov,oy,ox,oS,oC,oT,oA,oE,oM,oR,ow,ob,oP,oF,oL,oD,oB,oI,oV,oO,oN,oz,oU,ok,oG,oH,oW,oX,oK,oj,oY,oq,oQ,oZ,oJ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st,sr,sn,si,sa,so,ss,sl,sc,su,sd,sh,s_,sf,sp,sm,sg,sv,sy,sx,sS,sC,sT,sA,sE,sM,sR,sw,sb,sP,sF,sL,sD,sB,sI,sV,sO,sN,sz,sU,sk,sG,sH,sW,sX,sK,sj,sY,sq,sQ,sZ,sJ,s$,s0,s1,s2,s3,s4,s5,s8,s6,s7,s9,le,lt,lr,ln,li,la,lo,ls,ll,lc,lu,ld,lh,l_,lf,lp,lm,lg,lv,ly,lx,lS,lC,lT,lA,lE,lM,lR,lw,lb,lP,lF,lL,lD,lB,lI,lV,lO,lN,lz,lU,lk,lG,lH,lW,lX,lK,lj,lY,lq,lQ,lZ,lJ,l$,l0,l1,l2,l3,l4,l5,l8,l6,l7,l9=((ly=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},ly.equals=function(e,t){return Math.abs(e-t)<=ly.zeroTolerance},ly.isPowerOf2=function(e){return(e&e-1)==0},ly.radianToDegree=function(e){return e*ly.radToDegreeFactor},ly.degreeToRadian=function(e){return e*ly.degreeToRadFactor},ly);l9.zeroTolerance=1e-6,l9.radToDegreeFactor=180/Math.PI,l9.degreeToRadFactor=Math.PI/180;var ce=((a=(i=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},a.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},a.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},a.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},a.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},a.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},a.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},a.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},a.normalize=function(){return i.normalize(this,this),this},a.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},a.transformNormal=function(e){return i.transformNormal(this,e,this),this},a.transformToVec3=function(e){return i.transformToVec3(this,e,this),this},a.transformCoordinate=function(e){return i.transformCoordinate(this,e,this),this},a.transformByQuat=function(e){return i.transformByQuat(this,e,this),this},a.clone=function(){return new i(this._x,this._y,this._z)},a.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},a.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},a.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},a.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},i.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()},i.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()},i.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()},i.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()},i.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},i.cross=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z;r.set(i*l-a*s,a*o-n*l,n*s-i*o)},i.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z;return Math.sqrt(r*r+n*n+i*i)},i.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z;return r*r+n*n+i*i},i.equals=function(e,t){return l9.equals(e._x,t._x)&&l9.equals(e._y,t._y)&&l9.equals(e._z,t._z)},i.lerp=function(e,t,r,n){var i=e._x,a=e._y,o=e._z;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},i.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()},i.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()},i.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},i.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=Math.sqrt(r*r+n*n+i*i);a>l9.zeroTolerance&&(a=1/a,t.set(r*a,n*a,i*a))},i.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},i.transformNormal=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8],r._y=n*o[1]+i*o[5]+a*o[9],r._z=n*o[2]+i*o[6]+a*o[10],r._onValueChanged&&r._onValueChanged()},i.transformToVec3=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8]+o[12],r._y=n*o[1]+i*o[5]+a*o[9]+o[13],r._z=n*o[2]+i*o[6]+a*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},i.transformToVec4=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements;r._x=n*o[0]+i*o[4]+a*o[8]+o[12],r._y=n*o[1]+i*o[5]+a*o[9]+o[13],r._z=n*o[2]+i*o[6]+a*o[10]+o[14],r._w=n*o[3]+i*o[7]+a*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},i.transformCoordinate=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t.elements,s=n*o[3]+i*o[7]+a*o[11]+o[15];s=1/s,r._x=(n*o[0]+i*o[4]+a*o[8]+o[12])*s,r._y=(n*o[1]+i*o[5]+a*o[9]+o[13])*s,r._z=(n*o[2]+i*o[6]+a*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},i.transformByQuat=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*n+s*a-l*i,d=c*i+l*n-o*a,h=c*a+o*i-s*n,_=-o*n-s*i-l*a;r._x=u*c-_*o-d*l+h*s,r._y=d*c-_*s-h*o+u*l,r._z=h*c-_*l-u*s+d*o,r._onValueChanged&&r._onValueChanged()},n(i,[{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()}}]),i);ce._zero=new ce(0,0,0),ce._one=new ce(1,1,1);var ct=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new ce,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 i=0;i<r;++i)ce.add(e[i],n,n);ce.scale(n,1/r,t.center);for(var a=0,s=0;s<r;++s){var l=ce.distanceSquared(n,e[s]);l>a&&(a=l)}t.radius=Math.sqrt(a)},o.fromBox=function(e,t){var r=t.center,n=e.min,i=e.max;r.x=(n.x+i.x)*.5,r.y=(n.y+i.y)*.5,r.z=(n.z+i.z)*.5,t.radius=ce.distance(r,i)},o);ct._tempVec30=new ce;var cr=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new ce,this.max=new ce,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,i=r._y+t._y,a=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,i=r._y-t._y,a=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(i)?0:.5*i,isNaN(a)?0:.5*a),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,i=t.y,a=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new ce;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,i,l),e[3].set(n,i,l),e[4].set(n,s,a),e[5].set(o,s,a),e[6].set(o,i,a),e[7].set(n,i,a),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){ce.subtract(e,t,r.min),ce.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 i=0,a=e.length;i<a;++i){var o=e[i];ce.min(r,o,r),ce.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,i=t.min,a=t.max;i.x=r.x-n,i.y=r.y-n,i.z=r.z-n,a.x=r.x+n,a.y=r.y+n,a.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,i=l._tempVec31;e.getCenter(n),e.getExtent(i),ce.transformCoordinate(n,t,n);var a=i.x,o=i.y,s=i.z,c=t.elements,u=c[0],d=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];i.set((0===u?0:Math.abs(a*u))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===d?0:Math.abs(a*d))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(a*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),ce.subtract(n,i,r.min),ce.add(n,i,r.max)},l.merge=function(e,t,r){return ce.min(e.min,t.min,r.min),ce.max(e.max,t.max,r.max),r},l);cr._tempVec30=new ce,cr._tempVec31=new ce;var cn=((u=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var i=e.normal,a=t.normal,o=r.normal;ce.cross(a,o,u._tempVec30),ce.cross(o,i,u._tempVec31),ce.cross(i,a,u._tempVec32);var s=-ce.dot(i,u._tempVec30),l=-ce.dot(a,u._tempVec31),c=-ce.dot(o,u._tempVec32);ce.scale(u._tempVec30,e.distance/s,u._tempVec30),ce.scale(u._tempVec31,t.distance/l,u._tempVec31),ce.scale(u._tempVec32,r.distance/c,u._tempVec32),ce.add(u._tempVec30,u._tempVec31,n),ce.add(n,u._tempVec32,n)},u.distancePlaneAndPoint=function(e,t){return ce.dot(e.normal,t)+e.distance},u.intersectsPlaneAndPoint=function(t,r){var n=u.distancePlaneAndPoint(t,r);return n>0?e.PlaneIntersectionType.Front:n<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndBox=function(t,r){var n=r.min,i=r.max,a=t.normal,o=u._tempVec30,s=u._tempVec31;return(a.x>=0?(o.x=i.x,s.x=n.x):(o.x=n.x,s.x=i.x),a.y>=0?(o.y=i.y,s.y=n.y):(o.y=n.y,s.y=i.y),a.z>=0?(o.z=i.z,s.z=n.z):(o.z=n.z,s.z=i.z),0>u.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:u.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndSphere=function(t,r){var n=r.center,i=r.radius,a=u.distancePlaneAndPoint(t,n);return a>i?e.PlaneIntersectionType.Front:a<-i?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var r=t.normal,n=l9.zeroTolerance,i=ce.dot(r,e.direction);if(Math.abs(i)<n)return -1;var a=ce.dot(r,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-n)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var r=l9.zeroTolerance,n=e.origin,i=e.direction,a=t.min,o=t.max,s=i.x,l=i.y,c=i.z,u=n.x,d=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(u<a.x||u>o.x)return -1}else{var p=1/s,m=(a.x-u)*p,g=(o.x-u)*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(d<a.y||d>o.y)return -1}else{var y=1/l,x=(a.y-d)*y,S=(o.y-d)*y;if(x>S){var C=x;x=S,S=C}if((_=Math.max(x,_))>(f=Math.min(S,f)))return -1}if(Math.abs(c)<r){if(h<a.z||h>o.z)return -1}else{var T=1/c,A=(a.z-h)*T,E=(o.z-h)*T;if(A>E){var M=A;A=E,E=M}if((_=Math.max(A,_))>(f=Math.min(E,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,i=t.center,a=t.radius,o=u._tempVec30;ce.subtract(r,i,o);var s=ce.dot(o,n),l=ce.dot(o,o)-a*a;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var d=-s-Math.sqrt(c);return d<0&&(d=0),d},u.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)},u.intersectsSphereAndSphere=function(e,t){var r=e.radius+t.radius;return ce.distanceSquared(e.center,t.center)<r*r},u.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,i=t.min,a=u._tempVec30;return a.set(Math.max(i.x,Math.min(r.x,n.x)),Math.max(i.y,Math.min(r.y,n.y)),Math.max(i.z,Math.min(r.z,n.z))),ce.distanceSquared(r,a)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,i=u._tempVec30,a=0;a<6;++a){var o=e.getPlane(a),s=o.normal;if(i.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),ce.dot(s,i)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,r){var n=u.distancePlaneAndPoint(t.near,r);return Math.abs(n)<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.far,r))<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.left,r))<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.right,r))<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.top,r))<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.bottom,r))<l9.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,r){for(var n=r.min,i=r.max,a=u._tempVec30,o=u._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),d=c.normal;if(d.x>=0?(a.x=i.x,o.x=n.x):(a.x=n.x,o.x=i.x),d.y>=0?(a.y=i.y,o.y=n.y):(a.y=n.y,o.y=i.y),d.z>=0?(a.z=i.z,o.z=n.z):(a.z=n.z,o.z=i.z),u.intersectsPlaneAndPoint(c,a)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;u.intersectsPlaneAndPoint(c,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},u.frustumContainsSphere=function(t,r){for(var n=e.ContainmentType.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=u.intersectsPlaneAndSphere(a,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},u);cn._tempVec30=new ce,cn._tempVec31=new ce,cn._tempVec32=new ce;var ci=((h=(d=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new ce,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return d.normalize(this,this),this},h.clone=function(){var e=new d;return e.copyFrom(this),e},h.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},d.normalize=function(e,t){var r=e.normal,n=1/r.length();ce.scale(r,n,t.normal),t.distance=e.distance*n},d.fromPoints=function(e,t,r,n){var i=e.x,a=e.y,o=e.z,s=t.x-i,l=t.y-a,c=t.z-o,u=r.x-i,d=r.y-a,h=r.z-o,_=l*h-c*d,f=c*u-s*h,p=s*d-l*u,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*i+v*a+y*o)},d),ca=((f=(_=function(e){void 0===e&&(e=null),this.near=new ci,this.far=new ci,this.left=new ci,this.right=new ci,this.top=new ci,this.bottom=new ci,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],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],d=t[9],h=t[10],_=t[11],f=t[12],p=t[13],m=t[14],g=t[15];this.near.normal.set(a+i,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(a-i,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(a+r,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(a-r,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(a+n,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(a-n,c-s,_-d),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return cn.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return cn.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},_),co=((m=(p=function(e,t,r,n,i,a,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===i&&(i=1),void 0===a&&(a=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]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=i,c[5]=a,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],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*a-o*l)+r*(-c*i+o*s)+n*(l*i-a*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,i=t.elements,a=r.elements;a[0]=n[0]+i[0],a[1]=n[1]+i[1],a[2]=n[2]+i[2],a[3]=n[3]+i[3],a[4]=n[4]+i[4],a[5]=n[5]+i[5],a[6]=n[6]+i[6],a[7]=n[7]+i[7],a[8]=n[8]+i[8]},p.subtract=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements;a[0]=n[0]-i[0],a[1]=n[1]-i[1],a[2]=n[2]-i[2],a[3]=n[3]-i[3],a[4]=n[4]-i[4],a[5]=n[5]-i[5],a[6]=n[6]-i[6],a[7]=n[7]-i[7],a[8]=n[8]-i[8]},p.multiply=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=n[5],h=n[6],_=n[7],f=n[8],p=i[0],m=i[1],g=i[2],v=i[3],y=i[4],x=i[5],S=i[6],C=i[7],T=i[8];a[0]=o*p+c*m+h*g,a[1]=s*p+u*m+_*g,a[2]=l*p+d*m+f*g,a[3]=o*v+c*y+h*x,a[4]=s*v+u*y+_*x,a[5]=l*v+d*y+f*x,a[6]=o*S+c*C+h*T,a[7]=s*S+u*C+_*T,a[8]=l*S+d*C+f*T},p.equals=function(e,t){var r=e.elements,n=t.elements;return l9.equals(r[0],n[0])&&l9.equals(r[1],n[1])&&l9.equals(r[2],n[2])&&l9.equals(r[3],n[3])&&l9.equals(r[4],n[4])&&l9.equals(r[5],n[5])&&l9.equals(r[6],n[6])&&l9.equals(r[7],n[7])&&l9.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var i=e.elements,a=t.elements,o=n.elements,s=1-r;o[0]=i[0]*s+a[0]*r,o[1]=i[1]*s+a[1]*r,o[2]=i[2]*s+a[2]*r,o[3]=i[3]*s+a[3]*r,o[4]=i[4]*s+a[4]*r,o[5]=i[5]*s+a[5]*r,o[6]=i[6]*s+a[6]*r,o[7]=i[7]*s+a[7]*r,o[8]=i[8]*s+a[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,i=e._y,a=e._z,o=e._w,s=n+n,l=i+i,c=a+a,u=n*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=d-v,r[6]=_+g,r[1]=d+v,r[4]=1-u-p,r[7]=f-m,r[2]=_-g,r[5]=f+m,r[8]=1-u-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,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=r[7],h=r[8],_=h*l-c*d,f=-h*s+c*u,p=d*s-l*u,m=i*_+a*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*a+o*d)*m,n[2]=(c*a-o*l)*m,n[3]=f*m,n[4]=(h*i-o*u)*m,n[5]=(-c*i+o*s)*m,n[6]=p*m,n[7]=(-d*i+a*u)*m,n[8]=(l*i-a*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=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=i*c-a*l,S=i*u-o*l,C=i*d-s*l,T=a*u-o*c,A=a*d-s*c,E=o*d-s*u,M=h*g-_*m,R=h*v-f*m,w=h*y-p*m,b=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-S*P+C*b+T*w-A*R+E*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*b)*L,n[1]=(u*w-l*F-d*R)*L,n[2]=(l*P-c*w+d*M)*L,n[3]=(o*P-a*F-s*b)*L,n[4]=(i*F-o*w+s*R)*L,n[5]=(a*w-i*P-s*M)*L,n[6]=(g*E-v*A+y*T)*L,n[7]=(v*C-m*E-y*S)*L,n[8]=(m*A-g*C+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,i=r.elements,a=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],u=n[3],d=n[4],h=n[5],_=n[6],f=n[7],p=n[8];i[0]=o*s+a*u,i[1]=o*l+a*d,i[2]=o*c+a*h,i[3]=o*u-a*s,i[4]=o*d-a*l,i[5]=o*h-a*c,i[6]=_,i[7]=f,i[8]=p},p.scale=function(e,t,r){var n=t._x,i=t._y,a=e.elements,o=r.elements;o[0]=n*a[0],o[1]=n*a[1],o[2]=n*a[2],o[3]=i*a[3],o[4]=i*a[4],o[5]=i*a[5],o[6]=a[6],o[7]=a[7],o[8]=a[8]},p.translate=function(e,t,r){var n=t._x,i=t._y,a=e.elements,o=r.elements,s=a[0],l=a[1],c=a[2],u=a[3],d=a[4],h=a[5],_=a[6],f=a[7],p=a[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=n*s+i*u+_,o[7]=n*l+i*d+f,o[8]=n*c+i*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var i=r[1],a=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=i,n[5]=r[7],n[6]=a,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),cs=((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,i=t*t+r*r+n*n;if(i<l9.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var a=1/i;return e._x=this._x*a,e._y=this._y*a,e._z=this._z*a,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,i=this._w,a=t*t,o=r*r,s=n*n,l=i*i,c=a+o+s+l,u=2*(t*i-r*n);u>(1-l9.zeroTolerance)*c?(e._x=Math.atan2(2*(i*r-t*n),s+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-l9.zeroTolerance)*c?(e._x=Math.atan2(2*(i*r-t*n),s+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*i),s+l-o-a),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*r+n*i),o+l-s-a))},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,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;r._x=n*u+o*s+i*c-a*l,r._y=i*u+o*l+a*s-n*c,r._z=a*u+o*c+n*l-i*s,r._w=o*u-n*s-i*l-a*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 l9.equals(e._x,t._x)&&l9.equals(e._y,t._y)&&l9.equals(e._z,t._z)&&l9.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;ce.normalize(e,n);var i=Math.sin(t*=.5);r._x=n._x*i,r._y=n._y*i,r._z=n._z*i,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 i=.5*r,a=.5*t,o=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(a),u=Math.cos(a),d=Math.sin(o),h=Math.cos(o),_=h*u,f=d*c;n._x=h*c*l+d*u*s,n._y=d*u*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,i=e.elements,a=i[0],o=i[1],s=i[2],l=i[3],c=i[4],u=i[5],d=i[6],h=i[7],_=i[8],f=a+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(u-h)*r,t._y=(d-s)*r,t._z=(o-l)*r):a>=c&&a>=_?(n=.5/(r=Math.sqrt(1+a-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+d)*n,t._w=(u-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-a-_)),t._x=(l+o)*n,t._y=.5*r,t._z=(h+u)*n,t._w=(d-s)*n):(n=.5/(r=Math.sqrt(1+_-a-c)),t._x=(s+d)*n,t._y=(u+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,i=e._z,a=e._w,o=r*r+n*n+i*i+a*a;if(o>l9.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-i*s,t._w=a*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var i=1-r;g.dot(e,t)>=0?(n._x=e._x*i+t._x*r,n._y=e._y*i+t._y*r,n._z=e._z*i+t._z*r,n._w=e._w*i+t._w*r):(n._x=e._x*i-t._x*r,n._y=e._y*i-t._y*r,n._z=e._z*i-t._z*r,n._w=e._w*i-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var i,a,o=g.dot(e,t);if(Math.abs(o)>1-l9.zeroTolerance)a=1-r,i=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);a=Math.sin((1-r)*s)*l,i=Math.sin(r*s)*l*Math.sign(o)}n.x=a*e.x+i*t.x,n.y=a*e.y+i*t.y,n.z=a*e.z+i*t.z,n.w=a*e.w+i*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,o=Math.sqrt(r*r+n*n+i*i+a*a);o>l9.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=i*o,t._w=a*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,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=i*l+a*s,r._z=a*l-i*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-a*s,r._y=i*l+o*s,r._z=a*l+n*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+i*s,r._y=i*l-n*s,r._z=a*l+o*s,r._w=o*l-a*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)<l9.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);cs._tempVector3=new ce,cs._tempQuat1=new cs;var cl=((x=(y=function(e,t,r,n,i,a,o,s,l,c,u,d,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===i&&(i=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===d&&(d=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]=i,m[5]=a,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,m[12]=h,m[13]=_,m[14]=f,m[15]=p}).prototype).set=function(e,t,r,n,i,a,o,s,l,c,u,d,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=i,m[5]=a,m[6]=o,m[7]=s,m[8]=l,m[9]=c,m[10]=u,m[11]=d,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],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],_=e[12],f=e[13],p=e[14],m=e[15];return(t*o-r*a)*(d*m-h*p)-(t*s-n*a)*(u*m-h*f)+(t*l-i*a)*(u*p-d*f)+(r*s-n*o)*(c*m-h*_)-(r*l-i*o)*(c*p-d*_)+(n*l-i*s)*(c*f-u*_)},x.decompose=function(e,t,r){var n=y._tempMat30,i=this.elements,a=n.elements,o=i[0],s=i[1],l=i[2],c=i[4],u=i[5],d=i[6],h=i[8],_=i[9],f=i[10];e.set(i[12],i[13],i[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+u*u+d*d),g=Math.sqrt(h*h+_*_+f*f);if(0>this.determinant()&&(p=-p),r.set(p,m,g),Math.abs(p)<l9.zeroTolerance||Math.abs(m)<l9.zeroTolerance||Math.abs(g)<l9.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,S=1/g;return a[0]=o*v,a[1]=s*v,a[2]=l*v,a[3]=c*x,a[4]=u*x,a[5]=d*x,a[6]=h*S,a[7]=_*S,a[8]=f*S,cs.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>l9.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 i=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/i,e._x=.25*i,e._y=(t[1]+t[4])/i,e._z=(t[8]+t[2])/i}else if(t[5]>t[10]){var a=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/a,e._x=(t[1]+t[4])/a,e._y=.25*a,e._z=(t[6]+t[9])/a}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],i=t[2],a=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(r*r+n*n+i*i),Math.sqrt(a*a+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),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,i=t.elements,a=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=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],S=n[15],C=i[0],T=i[1],A=i[2],E=i[3],M=i[4],R=i[5],w=i[6],b=i[7],P=i[8],F=i[9],L=i[10],D=i[11],B=i[12],I=i[13],V=i[14],O=i[15];a[0]=o*C+u*T+f*A+v*E,a[1]=s*C+d*T+p*A+y*E,a[2]=l*C+h*T+m*A+x*E,a[3]=c*C+_*T+g*A+S*E,a[4]=o*M+u*R+f*w+v*b,a[5]=s*M+d*R+p*w+y*b,a[6]=l*M+h*R+m*w+x*b,a[7]=c*M+_*R+g*w+S*b,a[8]=o*P+u*F+f*L+v*D,a[9]=s*P+d*F+p*L+y*D,a[10]=l*P+h*F+m*L+x*D,a[11]=c*P+_*F+g*L+S*D,a[12]=o*B+u*I+f*V+v*O,a[13]=s*B+d*I+p*V+y*O,a[14]=l*B+h*I+m*V+x*O,a[15]=c*B+_*I+g*V+S*O},y.equals=function(e,t){var r=e.elements,n=t.elements;return l9.equals(r[0],n[0])&&l9.equals(r[1],n[1])&&l9.equals(r[2],n[2])&&l9.equals(r[3],n[3])&&l9.equals(r[4],n[4])&&l9.equals(r[5],n[5])&&l9.equals(r[6],n[6])&&l9.equals(r[7],n[7])&&l9.equals(r[8],n[8])&&l9.equals(r[9],n[9])&&l9.equals(r[10],n[10])&&l9.equals(r[11],n[11])&&l9.equals(r[12],n[12])&&l9.equals(r[13],n[13])&&l9.equals(r[14],n[14])&&l9.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var i=e.elements,a=t.elements,o=n.elements,s=1-r;o[0]=i[0]*s+a[0]*r,o[1]=i[1]*s+a[1]*r,o[2]=i[2]*s+a[2]*r,o[3]=i[3]*s+a[3]*r,o[4]=i[4]*s+a[4]*r,o[5]=i[5]*s+a[5]*r,o[6]=i[6]*s+a[6]*r,o[7]=i[7]*s+a[7]*r,o[8]=i[8]*s+a[8]*r,o[9]=i[9]*s+a[9]*r,o[10]=i[10]*s+a[10]*r,o[11]=i[11]*s+a[11]*r,o[12]=i[12]*s+a[12]*r,o[13]=i[13]*s+a[13]*r,o[14]=i[14]*s+a[14]*r,o[15]=i[15]*s+a[15]*r},y.add=function(e,t,r){var n=e.elements,i=t.elements,a=r.elements;a[0]=n[0]+i[0],a[1]=n[1]+i[1],a[2]=n[2]+i[2],a[3]=n[3]+i[3],a[4]=n[4]+i[4],a[5]=n[5]+i[5],a[6]=n[6]+i[6],a[7]=n[7]+i[7],a[8]=n[8]+i[8],a[9]=n[9]+i[9],a[10]=n[10]+i[10],a[11]=n[11]+i[11],a[12]=n[12]+i[12],a[13]=n[13]+i[13],a[14]=n[14]+i[14],a[15]=n[15]+i[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,i=r.elements;i[0]=n[0]*t,i[1]=n[1]*t,i[2]=n[2]*t,i[3]=n[3]*t,i[4]=n[4]*t,i[5]=n[5]*t,i[6]=n[6]*t,i[7]=n[7]*t,i[8]=n[8]*t,i[9]=n[9]*t,i[10]=n[10]*t,i[11]=n[11]*t,i[12]=n[12]*t,i[13]=n[13]*t,i[14]=n[14]*t,i[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,i=e._y,a=e._z,o=e._w,s=n+n,l=i+i,c=a+a,u=n*s,d=i*s,h=i*l,_=a*s,f=a*l,p=a*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=d+v,r[2]=_-g,r[3]=0,r[4]=d-v,r[5]=1-u-p,r[6]=f+m,r[7]=0,r[8]=_+g,r[9]=f-m,r[10]=1-u-h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.rotationAxisAngle=function(e,t,r){var n,i,a,o=r.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<l9.zeroTolerance||(s*=u=1/u,l*=u,c*=u,n=Math.sin(t),a=1-(i=Math.cos(t)),o[0]=s*s*a+i,o[1]=l*s*a+c*n,o[2]=c*s*a-l*n,o[3]=0,o[4]=s*l*a-c*n,o[5]=l*l*a+i,o[6]=c*l*a+s*n,o[7]=0,o[8]=s*c*a+l*n,o[9]=l*c*a-s*n,o[10]=c*c*a+i,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 i=n.elements,a=t._x,o=t._y,s=t._z,l=t._w,c=a+a,u=o+o,d=s+s,h=a*c,_=a*u,f=a*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,S=e._x,C=e._y,T=e._z;i[0]=(1-(p+g))*S,i[1]=(_+x)*S,i[2]=(f-y)*S,i[3]=0,i[4]=(_-x)*C,i[5]=(1-(h+g))*C,i[6]=(m+v)*C,i[7]=0,i[8]=(f+y)*T,i[9]=(m-v)*T,i[10]=(1-(h+p))*T,i[11]=0,i[12]=r._x,i[13]=r._y,i[14]=r._z,i[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,i=r[0],a=r[1],o=r[2],s=r[3],l=r[4],c=r[5],u=r[6],d=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=i*c-a*l,S=i*u-o*l,C=i*d-s*l,T=a*u-o*c,A=a*d-s*c,E=o*d-s*u,M=h*g-_*m,R=h*v-f*m,w=h*y-p*m,b=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-S*P+C*b+T*w-A*R+E*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*b)*L,n[1]=(o*P-a*F-s*b)*L,n[2]=(g*E-v*A+y*T)*L,n[3]=(f*A-_*E-p*T)*L,n[4]=(u*w-l*F-d*R)*L,n[5]=(i*F-o*w+s*R)*L,n[6]=(v*C-m*E-y*S)*L,n[7]=(h*E-f*C+p*S)*L,n[8]=(l*P-c*w+d*M)*L,n[9]=(a*w-i*P-s*M)*L,n[10]=(m*A-g*C+y*x)*L,n[11]=(_*C-h*A-p*x)*L,n[12]=(c*R-l*b-u*M)*L,n[13]=(i*b-a*R+o*M)*L,n[14]=(g*S-m*T-v*x)*L,n[15]=(h*T-_*S+f*x)*L},y.lookAt=function(e,t,r,n){var i=n.elements,a=y._tempVec30,o=y._tempVec31,s=y._tempVec32;ce.subtract(e,t,s),s.normalize(),ce.cross(r,s,a),a.normalize(),ce.cross(s,a,o),i[0]=a._x,i[1]=o._x,i[2]=s._x,i[3]=0,i[4]=a._y,i[5]=o._y,i[6]=s._y,i[7]=0,i[8]=a._z,i[9]=o._z,i[10]=s._z,i[11]=0,i[12]=-ce.dot(a,e),i[13]=-ce.dot(o,e),i[14]=-ce.dot(s,e),i[15]=1},y.ortho=function(e,t,r,n,i,a,o){var s=o.elements,l=1/(e-t),c=1/(r-n),u=1/(i-a);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*u,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(a+i)*u,s[15]=1},y.perspective=function(e,t,r,n,i){var a=i.elements,o=1/Math.tan(e/2),s=1/(r-n);a[0]=o/t,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(n+r)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*n*r*s,a[15]=0},y.rotateAxisAngle=function(e,t,r,n){var i,a,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<l9.zeroTolerance)){var d=e.elements,h=n.elements;s*=u=1/u,l*=u,c*=u,i=Math.sin(r),o=1-(a=Math.cos(r));var _=d[0],f=d[1],p=d[2],m=d[3],g=d[4],v=d[5],y=d[6],x=d[7],S=d[8],C=d[9],T=d[10],A=d[11],E=s*s*o+a,M=l*s*o+c*i,R=c*s*o-l*i,w=s*l*o-c*i,b=l*l*o+a,P=c*l*o+s*i,F=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;h[0]=_*E+g*M+S*R,h[1]=f*E+v*M+C*R,h[2]=p*E+y*M+T*R,h[3]=m*E+x*M+A*R,h[4]=_*w+g*b+S*P,h[5]=f*w+v*b+C*P,h[6]=p*w+y*b+T*P,h[7]=m*w+x*b+A*P,h[8]=_*F+g*L+S*D,h[9]=f*F+v*L+C*D,h[10]=p*F+y*L+T*D,h[11]=m*F+x*L+A*D,e!==n&&(h[12]=d[12],h[13]=d[13],h[14]=d[14],h[15]=d[15])}},y.scale=function(e,t,r){var n=e.elements,i=r.elements,a=t._x,o=t._y,s=t._z;i[0]=n[0]*a,i[1]=n[1]*a,i[2]=n[2]*a,i[3]=n[3]*a,i[4]=n[4]*o,i[5]=n[5]*o,i[6]=n[6]*o,i[7]=n[7]*o,i[8]=n[8]*s,i[9]=n[9]*s,i[10]=n[10]*s,i[11]=n[11]*s,i[12]=n[12],i[13]=n[13],i[14]=n[14],i[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,i=r.elements,a=t._x,o=t._y,s=t._z;if(e===r)i[12]=n[0]*a+n[4]*o+n[8]*s+n[12],i[13]=n[1]*a+n[5]*o+n[9]*s+n[13],i[14]=n[2]*a+n[6]*o+n[10]*s+n[14],i[15]=n[3]*a+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],u=n[2],d=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];i[0]=l,i[1]=c,i[2]=u,i[3]=d,i[4]=h,i[5]=_,i[6]=f,i[7]=p,i[8]=m,i[9]=g,i[10]=v,i[11]=y,i[12]=l*a+h*o+m*s+n[12],i[13]=c*a+_*o+g*s+n[13],i[14]=u*a+f*o+v*s+n[14],i[15]=d*a+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var i=r[1],a=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]=i,n[6]=r[9],n[7]=r[13],n[8]=a,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);cl._tempVec30=new ce,cl._tempVec31=new ce,cl._tempVec32=new ce,cl._tempMat30=new co,cl._identity=new cl(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var cc=((C=(S=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new ce,this.direction=new ce,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return cn.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return cn.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return cn.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return ce.scale(this.direction,e,t),t.add(this.origin)},S),cu=((A=(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},A.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},A.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},A.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},A.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},A.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},A.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},A.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},A.normalize=function(){return T.normalize(this,this),this},A.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},A.clone=function(){return new T(this._x,this._y)},A.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},A.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},A.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},A.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 l9.equals(e._x,t._x)&&l9.equals(e._y,t._y)},T.lerp=function(e,t,r,n){var i=e._x,a=e._y;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*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,i=Math.sqrt(r*r+n*n);i>l9.zeroTolerance&&(i=1/i,t._x=r*i,t._y=n*i,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);cu._zero=new cu(0,0),cu._one=new cu(1,1);var cd=((M=(E=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 E.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 E(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}},E.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()},E.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()},E.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()},E.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()},E.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},E.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return Math.sqrt(r*r+n*n+i*i+a*a)},E.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return r*r+n*n+i*i+a*a},E.equals=function(e,t){return l9.equals(e._x,t._x)&&l9.equals(e._y,t._y)&&l9.equals(e._z,t._z)&&l9.equals(e._w,t._w)},E.lerp=function(e,t,r,n){var i=e._x,a=e._y,o=e._z,s=e._w;n._x=i+(t._x-i)*r,n._y=a+(t._y-a)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},E.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()},E.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()},E.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},E.normalize=function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,o=Math.sqrt(r*r+n*n+i*i+a*a);o>l9.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},E.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()},E.transform=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=t.elements;r._x=n*s[0]+i*s[4]+a*s[8]+o*s[12],r._y=n*s[1]+i*s[5]+a*s[9]+o*s[13],r._z=n*s[2]+i*s[6]+a*s[10]+o*s[14],r._w=n*s[3]+i*s[7]+a*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},E.transformByQuat=function(e,t,r){var n=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*n+l*a-c*i,h=u*i+c*n-s*a,_=u*a+s*i-l*n,f=-s*n-l*i-c*a;r._x=d*u-f*s-h*c+_*l,r._y=h*u-f*l-_*s+d*c,r._z=_*u-f*c-d*l+h*s,r._w=o,r._onValueChanged&&r._onValueChanged()},n(E,[{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()}}]),E);cd._zero=new cd(0,0,0,0),cd._one=new cd(1,1,1,1);var ch=((w=(R=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},w.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},w.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},w.clone=function(){return new R(this._r,this._g,this._b,this._a)},w.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},w.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},w.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},w.toLinear=function(e){return e._r=R.gammaToLinearSpace(this._r),e._g=R.gammaToLinearSpace(this._g),e._b=R.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},w.toGamma=function(e){return e._r=R.linearToGammaSpace(this._r),e._g=R.linearToGammaSpace(this._g),e._b=R.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},w.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,i=e;return t>n&&(n=t),r>n&&(n=r),t<i&&(i=t),r<i&&(i=r),(n+i)/2},w.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},R.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)},R.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)},R.equals=function(e,t){return l9.equals(e._r,t._r)&&l9.equals(e._g,t._g)&&l9.equals(e._b,t._b)&&l9.equals(e._a,t._a)},R.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},R.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()},R.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},R.lerp=function(e,t,r,n){var i=e._r,a=e._g,o=e._b,s=e._a;return n._r=i+(t._r-i)*r,n._g=a+(t._g-a)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(R,[{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()}}]),R),c_=((P=(b=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 b(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(b,[{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()}}]),b),cf=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,i=e._x,a=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*a,d=.488603*o,h=-.488603*i,_=1.092548*(i*a),f=-1.092548*(a*o),p=.315392*(3*o*o-1),m=-1.092548*(i*o),g=.546274*(i*i-a*a);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*u,n[4]+=l*u,n[5]+=c*u,n[6]+=s*d,n[7]+=l*d,n[8]+=c*d,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,i=e._y,a=e._z,o=-1.023327*i,s=1.023327*a,l=-1.023327*n,c=.858086*i*n,u=-.858086*i*a,d=.247708*(3*a*a-1),h=-.858086*a*n,_=.429042*(n*n-i*i),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]*u+r[18]*d+r[21]*h+r[24]*_,p+=r[13]*c+r[16]*u+r[19]*d+r[22]*h+r[25]*_,m+=r[14]*c+r[17]*u+r[20]*d+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),cp=((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 cm(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cg(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 cv(e,t,r){return t&&cg(e.prototype,t),r&&cg(e,r),e}function cy(e,t){return(cy=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cx(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&&cy(e,t)}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";var cS=((V=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},V.equals=function(e,t){return Math.abs(e-t)<=V.zeroTolerance},V.isPowerOf2=function(e){return(e&e-1)==0},V.radianToDegree=function(e){return e*V.radToDegreeFactor},V.degreeToRadian=function(e){return e*V.degreeToRadFactor},V);cS.zeroTolerance=1e-6,cS.radToDegreeFactor=180/Math.PI,cS.degreeToRadFactor=Math.PI/180;var cC=((N=(O=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},N.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},N.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},N.clone=function(){return new O(this._r,this._g,this._b,this._a)},N.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},N.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},N.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},N.toLinear=function(e){return e._r=O.gammaToLinearSpace(this._r),e._g=O.gammaToLinearSpace(this._g),e._b=O.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.toGamma=function(e){return e._r=O.linearToGammaSpace(this._r),e._g=O.linearToGammaSpace(this._g),e._b=O.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,i=e;return t>n&&(n=t),r>n&&(n=r),t<i&&(i=t),r<i&&(i=r),(n+i)/2},N.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},O.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)},O.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)},O.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)},O.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},O.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()},O.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},O.lerp=function(e,t,r,n){var i=e._r,a=e._g,o=e._b,s=e._a;return n._r=i+(t._r-i)*r,n._g=a+(t._g-a)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},cv(O,[{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()}}]),O);function cT(e,t,r,n){var i,a=arguments.length,o=a<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--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function cA(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function cE(e,t){cb.registerCloneMode(e,t,lx.Ignore)}function cM(e,t){cb.registerCloneMode(e,t,lx.Assignment)}function cR(e,t){cb.registerCloneMode(e,t,lx.Shallow)}function cw(e,t){cb.registerCloneMode(e,t,lx.Deep)}"function"==typeof SuppressedError&&SuppressedError,(z=lx||(lx={}))[z.Ignore=0]="Ignore",z[z.Assignment=1]="Assignment",z[z.Shallow=2]="Shallow",z[z.Deep=3]="Deep";var cb=((U=function(){}).registerCloneMode=function(e,t,r){var n=U._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),U._subCloneModeMap.set(e.constructor,n)),n[t]=r},U.getCloneMode=function(e){var t=U._cloneModeMap.get(e);if(!t){t=Object.create(null),U._cloneModeMap.set(e,t);for(var r=U._objectType,n=U._subCloneModeMap;e!==r;){var i=n.get(e);i&&Object.assign(t,i),e=Object.getPrototypeOf(e)}}return t},U.cloneProperty=function(e,t,r,n){if(n!==lx.Ignore){var i=e[r];if(cA(i,Object)){if(void 0===n||n===lx.Assignment){t[r]=i;return}switch(i.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var a=t[r];null==a||a.length!==i.length?t[r]=i.slice():a.set(i);break;case Array:var o=t[r],s=i.length;null==o?t[r]=o=Array(s):o.length=s;for(var l=0;l<s;l++)U.cloneProperty(i,o,l,n);break;default:var c=t[r]||(t[r]=new i.constructor),u=U.getCloneMode(i.constructor);for(var d in i)U.cloneProperty(i,c,d,u[d]);i._cloneTo&&i._cloneTo(c),i.copyFrom&&c.copyFrom(i)}}else t[r]=i}},U.deepCloneObject=function(e,t){for(var r in e)U.cloneProperty(e,t,r,lx.Deep)},U);cb._subCloneModeMap=new Map,cb._cloneModeMap=new Map,cb._objectType=Object.getPrototypeOf(Object);var cP=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)},cv(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();cP._instanceIdCounter=0,cT([cE],cP.prototype,"instanceId",void 0),cT([cE],cP.prototype,"_engine",void 0);var cF=(cx(k=function(e){var t;return(t=cP.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(cm(t)),t},cP),(G=k.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(cP.prototype.destroy.call(this),!0)},G._getReferCount=function(){return this._refCount},G._addReferCount=function(e){this._refCount+=e},G._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},G._onDestroy=function(){cP.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},cv(k,[{key:"refCount",get:function(){return this._refCount}}]),k),cL=function(e){this.resource=e};e.RenderBufferDepthFormat=void 0,(H=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[H.Depth=0]="Depth",H[H.DepthStencil=1]="DepthStencil",H[H.Stencil=2]="Stencil",H[H.Depth16=3]="Depth16",H[H.Depth24=4]="Depth24",H[H.Depth32=5]="Depth32",H[H.Depth24Stencil8=6]="Depth24Stencil8",H[H.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(W=e.TextureCubeFace||(e.TextureCubeFace={}))[W.PositiveX=0]="PositiveX",W[W.NegativeX=1]="NegativeX",W[W.PositiveY=2]="PositiveY",W[W.NegativeY=3]="NegativeY",W[W.PositiveZ=4]="PositiveZ",W[W.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(X=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[X.Never=0]="Never",X[X.Less=1]="Less",X[X.Equal=2]="Equal",X[X.LessEqual=3]="LessEqual",X[X.Greater=4]="Greater",X[X.NotEqual=5]="NotEqual",X[X.GreaterEqual=6]="GreaterEqual",X[X.Always=7]="Always",e.TextureFilterMode=void 0,(K=e.TextureFilterMode||(e.TextureFilterMode={}))[K.Point=0]="Point",K[K.Bilinear=1]="Bilinear",K[K.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(j=e.TextureFormat||(e.TextureFormat={}))[j.R8G8B8=0]="R8G8B8",j[j.R8G8B8A8=1]="R8G8B8A8",j[j.R4G4B4A4=2]="R4G4B4A4",j[j.R5G5B5A1=3]="R5G5B5A1",j[j.R5G6B5=4]="R5G6B5",j[j.Alpha8=5]="Alpha8",j[j.LuminanceAlpha=6]="LuminanceAlpha",j[j.R16G16B16A16=7]="R16G16B16A16",j[j.R32G32B32A32=8]="R32G32B32A32",j[j.BC1=9]="BC1",j[j.BC3=10]="BC3",j[j.BC7=11]="BC7",j[j.ETC1_RGB=12]="ETC1_RGB",j[j.ETC2_RGB=13]="ETC2_RGB",j[j.ETC2_RGBA5=14]="ETC2_RGBA5",j[j.ETC2_RGBA8=15]="ETC2_RGBA8",j[j.PVRTC_RGB2=16]="PVRTC_RGB2",j[j.PVRTC_RGBA2=17]="PVRTC_RGBA2",j[j.PVRTC_RGB4=18]="PVRTC_RGB4",j[j.PVRTC_RGBA4=19]="PVRTC_RGBA4",j[j.ASTC_4x4=20]="ASTC_4x4",j[j.ASTC_5x5=21]="ASTC_5x5",j[j.ASTC_6x6=22]="ASTC_6x6",j[j.ASTC_8x8=23]="ASTC_8x8",j[j.ASTC_10x10=24]="ASTC_10x10",j[j.ASTC_12x12=25]="ASTC_12x12",j[j.Depth=26]="Depth",j[j.DepthStencil=27]="DepthStencil",j[j.Depth16=28]="Depth16",j[j.Depth24=29]="Depth24",j[j.Depth32=30]="Depth32",j[j.Depth24Stencil8=31]="Depth24Stencil8",j[j.Depth32Stencil8=32]="Depth32Stencil8",j[j.DXT1=33]="DXT1",j[j.DXT5=34]="DXT5",e.TextureUsage=void 0,(Y=e.TextureUsage||(e.TextureUsage={}))[Y.Static=0]="Static",Y[Y.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(q=e.TextureWrapMode||(e.TextureWrapMode={}))[q.Clamp=0]="Clamp",q[q.Repeat=1]="Repeat",q[q.Mirror=2]="Mirror";var cD=(cx(Q=function(e){var t;return(t=cF.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(cm(t)),t},cF),Q.prototype._onDestroy=function(){cF.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},cv(Q,[{key:"isContentLost",get:function(){return this._isContentLost}}]),Q),cB=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},cI=console.log.bind(console),cV=console.info.bind(console),cO=console.warn.bind(console),cN=console.error.bind(console),cz={debug:cB,info:cB,warn:cB,error:cB,isEnabled:!1,enable:function(){this.debug=cI,this.info=cV,this.warn=cO,this.error=cN,this.isEnabled=!0},disable:function(){this.debug=cB,this.info=cB,this.warn=cB,this.error=cB,this.isEnabled=!1}},cU=(cx(Z=function(){var e;return e=cD.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},cD),(J=Z.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},J._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},J._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))},J._onDestroy=function(){cD.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},J._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},J._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},cv(Z,[{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(e){e!==this._filterMode&&(this._filterMode=e,this._platformTexture.filterMode=e)}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(cz.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(cz.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)}}]),Z),ck=(cx($=function(t,r,n,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=cD.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=r,s._height=n,s._antiAliasing=o,s._depth=a,i){for(var s,l=cA(i,Array)?i.slice():[i],c=0,u=l.length;c<u;c++){var d=l[c];if(d._isDepthTexture)throw"Render texture can't use depth format.";d._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(cA(a,cU)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(cm(s)),s},cD),(ee=$.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},ee.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()}},ee._onDestroy=function(){cD.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},ee._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t),this._isContentLost=!1},ee._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},ee._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},cv($,[{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}}]),$),cG=(cx(et=function(t,r,n,i,a,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=e.TextureUsage.Static),(s=cU.call(this,t)||this)._mipmap=a,s._width=r,s._height=n,s._usage=o,s._format=i,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(cm(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},cU),(er=et.prototype).setPixelBuffer=function(e,t,r,n,i,a){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a),this._isContentLost=!1},er.setImageSource=function(e,t,r,n,i,a){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===a&&(a=0),this._platformTexture.setImageSource(e,t,r,n,i,a),this._isContentLost=!1},er.getPixelBuffer=function(e,t,r,n,i,a){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,i):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a)},er._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),cU.prototype._rebuild.call(this)},et),cH=(cx(en=function(t,r,n,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=cU.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=i,s._format=a,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(cm(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},cU),(ei=en.prototype).setPixelBuffer=function(e,t,r,n,i,a,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a,o,s),this._isContentLost=!1},ei.setImageSource=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,i,a,o),this._isContentLost=!1},ei.getPixelBuffer=function(e,t,r,n,i,a,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,i,0,a):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a,o)},ei._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),cU.prototype._rebuild.call(this)},cv(en,[{key:"length",get:function(){return this._length}}]),en),cW=(cx(ea=function(t,r,n,i){var a;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=cU.call(this,t)||this)._mipmap=i,a._width=r,a._height=r,a._format=n,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(cm(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},cU),(eo=ea.prototype).setPixelBuffer=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,r,n,i,a,o),this._isContentLost=!1},eo.setImageSource=function(e,t,r,n,i,a,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,i,a,o),this._isContentLost=!1},eo.getPixelBuffer=function(e,t,r,n,i,a,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,i,0,a):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,i,a,o)},eo._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),cU.prototype._rebuild.call(this)},ea),cX=(cx(es=function(e){var t;return(t=cF.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},cF),(el=es.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,i=this._space,a=this.texture,o=a.width,s=t+i,l=r+i;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=i,this._curY=this._nextY+i);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new cu(this._curX,this._curY),a.setPixelBuffer(n,0,this._curX,this._curY,t,r),a.generateMipmaps());var u=1/o,d=this._curX,h=this._curY,_=d*u,f=(d+t)*u,p=h*u,m=(h+r)*u;e.x=d,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+i,!0},el.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},el.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},el._onDestroy=function(){cF.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},es);e.FontStyle=void 0,(ec=e.FontStyle||(e.FontStyle={}))[ec.None=0]="None",ec[ec.Bold=1]="Bold",ec[ec.Italic=2]="Italic",e.OverflowMode=void 0,(eu=e.OverflowMode||(e.OverflowMode={}))[eu.Overflow=0]="Overflow",eu[eu.Truncate=1]="Truncate";var cK=((ed=function(){}).textContext=function(){var e=ed._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},ed._textContext=e}return e},ed.measureFont=function(e){var t=ed._fontSizeInfoCache,r=t[e];return r||(r=ed._measureFontOrChar(e),t[e]=r),r},ed.getNativeFontString=function(t,r,n){var i=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ed._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=r+"px "+t},ed.measureChar=function(e,t){return ed._measureFontOrChar(t,e)},ed.measureTextWithWrap=function(t){var r=t._subFont,n=r.nativeFontString,i=ed.measureFont(n),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=dK._pixelsPerUnit,u=i.size+t.lineSpacing*c,d=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=a.length;_<f;_++){var p=a[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",S=0,C=0,T=0,A=!1,E=0,M=p.length;E<M;++E){var R=p[E],w=ed._getCharInfo(R,n,r),b=R.charCodeAt(0),P=32===b;if(!P||!A||0!==x.length||0!==m.length){var F=P||b>=19968&&b<=40959,L=w.w,D=w.offsetY,B=.5*w.h,I=B+D,V=B-D;F?(m.length>0&&(S+g>d?(S>0&&this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),A=!0,x=m,S=g,C=v,T=y):(x+=m,S+=g,C=Math.max(C,v),T=Math.max(T,y)),m="",g=v=y=0),S+L>d&&S>0?(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),A=!0,P?(x="",S=C=T=0):(x=R,S=w.xAdvance,C=I,T=V)):(x+=R,S+=w.xAdvance,C=Math.max(C,I),T=Math.max(T,V))):g+w.w>d?(S>0&&(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),x="",S=C=T=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),A=!0,m=R,g=w.xAdvance,v=I,y=V):(m+=R,g+=w.xAdvance,v=Math.max(v,I),y=Math.max(y,V))}}g>0&&(S+g>d?(S>0&&this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S),S=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,S+=g,C=Math.max(C,v),T=Math.max(T,y))),S>0&&(this._pushLine(o,s,l,x,S,C,T),h=Math.max(h,S))}var O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=u*o.length),{width:h,height:O,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},ed.measureTextWithoutWrap=function(t){var r=t._subFont,n=r.nativeFontString,i=ed.measureFont(n),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=[],u=dK._pixelsPerUnit,d=i.size+t.lineSpacing*u,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=a[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=ed._getCharInfo(f[v],n,r);p+=x.xAdvance;var S=x.offsetY,C=.5*x.h,T=C+S,A=C-S;m<T&&(m=T),g<A&&(g=A)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var E=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(E=d*s.length),{width:h,height:E,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},ed.getNativeFontHash=function(t,r,n){var i=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ed._genericFontFamilies.indexOf(t)||(t=""+t),i+=r+"px"+t},ed._measureFontOrChar=function(e,t){void 0===t&&(t="");var r,n=ed.textContext(),i=n.canvas,a=n.context;a.font=e;var o=t||ed._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(ed._measureBaseline).width),c=l*ed._heightMultiplier;l=ed._baselineMultiplier*l|0;var u=ed._extendHeight;c+=u,l+=.5*u,i.width=s,i.height=c,a.font=e,a.fillStyle="#000",a.clearRect(0,0,s,c),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var d=a.getImageData(0,0,s,c).data,h=d.length,_=-1,f=-1,p=0,m=0,g=0,v=i.width,y=1/v,x=0;x<h;x+=4)0!==d[x+3]?(r=~~(.25*x*y),-1===_&&(_=r),r>f&&(f=r)):d[x]=d[x+1]=d[x+2]=255;-1!==_&&-1!==f&&(g=(p=l-_)+(m=f-l+1));var S={ascent:p,descent:m,size:g};if(!t)return S;var C=null;if(g>0){var T=4*v;C=new Uint8Array(d.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 cu,new cu,new cu,new cu],ascent:p,descent:m,index:0,data:C}},ed._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=ed.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},ed._pushLine=function(e,t,r,n,i,a,o){e.push(n),t.push(i),r.push({ascent:a,descent:o,size:a+o})},ed);cK._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],cK._extendHeight=0,cK._measureString="|\xc9q\xc5",cK._measureBaseline="M",cK._heightMultiplier=2,cK._baselineMultiplier=1.4,cK._fontSizeInfoCache={},cK._textContext=null;var cj=((e_=(eh=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},e_._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},e_._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},e_._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var i=t[r].getCharInfo(e);if(i)return i}return null},e_._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},e_._getLastIndex=function(){return this._lastIndex},e_._createFontAtlas=function(){var t,r=this._engine,n=new cX(r),i=new cG(r,256,256,e.TextureFormat.R8G8B8A8,!1);i.filterMode=e.TextureFilterMode.Bilinear,n.texture=i,n.isGCIgnored=i.isGCIgnored=!0,this._fontAtlases.push(n);var a=this.nativeFontString;return r.resourceManager.addContentRestorer(new(cx(t=function(){return cL.call(this,n)},cL),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var i=t[n],o=cK.measureChar(i.char,a).data;if(i.w>0&&i.h>0&&o){var s=i.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,i.w,i.h)}}r.generateMipmaps()},t)),n},eh),cY=(cx(ef=function(e,t){var r;return void 0===t&&(t=""),(r=cF.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},cF),(ep=ef.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,i=n[r];return i||(i=new cj(this.engine),n[r]=i),i},ep._onDestroy=function(){cF.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]},ef.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new ef(e,t),r[t]=n),n}return null},cv(ef,[{key:"name",get:function(){return this._name}}]),ef),cq=((eg=(em=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},eg.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},eg.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},eg.dispatch=function(e,t){if(!this._events[e])return!1;var r=this._events[e];if(Array.isArray(r)){var n=r.length,i=em._dispatchingListenersPool,a=i.length>0?i.pop():[];a.length=n;for(var o=0;o<n;o++)a[o]=r[o];for(var s=0;s<n;s++){var l=a[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}a.length=0,i.push(a)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},eg.on=function(e,t){return this._addEventListener(e,t)},eg.once=function(e,t){return this._addEventListener(e,t,!0)},eg.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 i=r.length-1;i>=0;i--)r[i].fn===t&&(r[i].destroyed=!0,r.splice(i,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},eg.removeEventListener=function(e,t){return this.off(e,t)},eg.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},eg._addEventListener=function(e,t,r){var n={fn:t,once:r},i=this._events,a=i[e];return a?Array.isArray(a)?a.push(n):i[e]=[a,n]:(i[e]=n,this._eventCount++),this},eg._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},em);cq._dispatchingListenersPool=[];var cQ=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},cv(e,[{key:"type",get:function(){return this._type}}]),e}();cQ._propertyIdMap=Object.create(null),cQ._propertyNameCounter=0,cQ._propertyNameMap=Object.create(null);var cZ=((ey=(ev=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new cd,this._deltaTimeValue=new cd,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},ey._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},ey._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(ev._elapsedTimeProperty,t),r.set(this._deltaTime,0,0,0),e.setVector4(ev._deltaTimeProperty,r)},cv(ev,[{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}}]),ev);cZ._elapsedTimeProperty=cQ.getByName("scene_ElapsedTime"),cZ._deltaTimeProperty=cQ.getByName("scene_DeltaTime"),e.DataType=void 0,(ex=e.DataType||(e.DataType={}))[ex.FLOAT=5126]="FLOAT",ex[ex.FLOAT_VEC2=35664]="FLOAT_VEC2",ex[ex.FLOAT_VEC3=35665]="FLOAT_VEC3",ex[ex.FLOAT_VEC4=35666]="FLOAT_VEC4",ex[ex.INT=5124]="INT",ex[ex.INT_VEC2=35667]="INT_VEC2",ex[ex.INT_VEC3=35668]="INT_VEC3",ex[ex.INT_VEC4=35669]="INT_VEC4",ex[ex.BOOL=35670]="BOOL",ex[ex.BOOL_VEC2=35671]="BOOL_VEC2",ex[ex.BOOL_VEC3=35672]="BOOL_VEC3",ex[ex.BOOL_VEC4=35673]="BOOL_VEC4",ex[ex.FLOAT_MAT2=35674]="FLOAT_MAT2",ex[ex.FLOAT_MAT3=35675]="FLOAT_MAT3",ex[ex.FLOAT_MAT4=35676]="FLOAT_MAT4",ex[ex.FLOAT_ARRAY=35677]="FLOAT_ARRAY",ex[ex.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",ex[ex.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",ex[ex.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",ex[ex.INT_ARRAY=100003]="INT_ARRAY",ex[ex.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",ex[ex.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",ex[ex.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",ex[ex.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",ex[ex.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",ex[ex.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",ex[ex.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",ex[ex.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",ex[ex.SAMPLER_2D=35678]="SAMPLER_2D",ex[ex.SAMPLER_CUBE=35680]="SAMPLER_CUBE",ex[ex.BYTE=5120]="BYTE",ex[ex.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ex[ex.SHORT=5122]="SHORT",ex[ex.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ex[ex.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(eS=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",eS.standardDerivatives="OES_standard_derivatives",eS.shaderTextureLod="EXT_shader_texture_lod",eS.elementIndexUint="OES_element_index_uint",eS.depthTexture="WEBGL_depth_texture",eS.drawBuffers="WEBGL_draw_buffers",eS.vertexArrayObject="OES_vertex_array_object",eS.instancedArrays="ANGLE_instanced_arrays",eS.multipleSample="multipleSampleOnlySupportedInWebGL2",eS.textureFloat="OES_texture_float",eS.textureFloatLinear="OES_texture_float_linear",eS.textureHalfFloat="OES_texture_half_float",eS.textureHalfFloatLinear="OES_texture_half_float_linear",eS.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",eS.colorBufferFloat="EXT_color_buffer_float",eS.colorBufferHalfFloat="EXT_color_buffer_half_float",eS.textureFilterAnisotropic="EXT_texture_filter_anisotropic",eS.blendMinMax="EXT_blend_minmax",eS.astc="WEBGL_compressed_texture_astc",eS.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",eS.etc="WEBGL_compressed_texture_etc",eS.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",eS.etc1="WEBGL_compressed_texture_etc1",eS.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",eS.pvrtc="WEBGL_compressed_texture_pvrtc",eS.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",eS.s3tc="WEBGL_compressed_texture_s3tc",eS.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",eS.bptc="EXT_texture_compression_bptc",eS.WEBGL_lose_context="WEBGL_lose_context",(eC=lS||(lS={}))[eC.None=0]="None",eC[eC.Scene=1]="Scene",eC[eC.Hierarchy=2]="Hierarchy",eC[eC.All=3]="All";var cJ=(cx(eT=function(e){var t;return(t=cP.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},cP),(eA=eT.prototype)._onAwake=function(){},eA._onEnable=function(){},eA._onDisable=function(){},eA._onEnableInScene=function(){},eA._onDisableInScene=function(){},eA._setActive=function(e,t){var r=this._entity;t&lS.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&lS.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()))},eA._onDestroy=function(){cP.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},cv(eT,[{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}}]),eT);cT([cE],cJ.prototype,"_entity",void 0),cT([cE],cJ.prototype,"_awoken",void 0),cT([cE],cJ.prototype,"_phasedActiveInScene",void 0),cT([cE],cJ.prototype,"_phasedActive",void 0),cT([cM],cJ.prototype,"_enabled",void 0);var c$=((eE=function(){})._addCheck=function(e,t){for(;t!==cJ;){var r=eE._dependenciesMap.get(t);if(r)for(var n=r.components,i=r.mode,a=0,o=n.length;a<o;a++){var s=n[a];if(!e.getComponent(s)){if(1===i)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},eE._removeCheck=function(e,t){for(;t!==cJ;){var r=eE._invDependenciesMap.get(t);if(r){for(var n=0,i=r.length;n<i;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eE._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eE._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},eE);function c0(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){c$._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return c$._addInvDependency(t,e)})}}c$._invDependenciesMap=new Map,c$._dependenciesMap=new Map,e.DependentMode=void 0,(eM=e.DependentMode||(e.DependentMode={}))[eM.CheckOnly=0]="CheckOnly",eM[eM.AutoAdd=1]="AutoAdd";var c1=((ew=(eR=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++},ew.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ew.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},ew.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ew.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},ew.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0;n<this.length;n++){var i=r[n];i&&e(i)}this._endLoop(t)},ew.forEachAndClean=function(e){this._startLoop();for(var t=this._elements,r=0;r<this.length;r++){var n=t[r];n&&e(n)}this._endLoopAndClear()},ew.garbageCollection=function(){this._elements.length=this.length},ew._startLoop=function(){this._isLooping=!0},ew._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 i=n[r];e(i,t),n[t++]=i,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},ew._endLoopAndClear=function(){this._isLooping=!1,this.length=0,this._blankCount=0},eR);e.Layer=void 0,(eb=e.Layer||(e.Layer={}))[eb.Layer0=1]="Layer0",eb[eb.Layer1=2]="Layer1",eb[eb.Layer2=4]="Layer2",eb[eb.Layer3=8]="Layer3",eb[eb.Layer4=16]="Layer4",eb[eb.Layer5=32]="Layer5",eb[eb.Layer6=64]="Layer6",eb[eb.Layer7=128]="Layer7",eb[eb.Layer8=256]="Layer8",eb[eb.Layer9=512]="Layer9",eb[eb.Layer10=1024]="Layer10",eb[eb.Layer11=2048]="Layer11",eb[eb.Layer12=4096]="Layer12",eb[eb.Layer13=8192]="Layer13",eb[eb.Layer14=16384]="Layer14",eb[eb.Layer15=32768]="Layer15",eb[eb.Layer16=65536]="Layer16",eb[eb.Layer17=131072]="Layer17",eb[eb.Layer18=262144]="Layer18",eb[eb.Layer19=524288]="Layer19",eb[eb.Layer20=1048576]="Layer20",eb[eb.Layer21=2097152]="Layer21",eb[eb.Layer22=4194304]="Layer22",eb[eb.Layer23=8388608]="Layer23",eb[eb.Layer24=16777216]="Layer24",eb[eb.Layer25=33554432]="Layer25",eb[eb.Layer26=67108864]="Layer26",eb[eb.Layer27=134217728]="Layer27",eb[eb.Layer28=268435456]="Layer28",eb[eb.Layer29=536870912]="Layer29",eb[eb.Layer30=1073741824]="Layer30",eb[eb.Layer31=2147483648]="Layer31",eb[eb.Everything=4294967295]="Everything",eb[eb.Nothing=0]="Nothing";var c2=((eP=function(){})._floatMatrixMultiply=function(e,t,r,n,i){var a=e.elements,o=a[0],s=a[1],l=a[2],c=a[3],u=a[4],d=a[5],h=a[6],_=a[7],f=a[8],p=a[9],m=a[10],g=a[11],v=a[12],y=a[13],x=a[14],S=a[15],C=t[r],T=t[r+1],A=t[r+2],E=t[r+3],M=t[r+4],R=t[r+5],w=t[r+6],b=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[i]=o*C+u*T+f*A+v*E,n[i+1]=s*C+d*T+p*A+y*E,n[i+2]=l*C+h*T+m*A+x*E,n[i+3]=c*C+_*T+g*A+S*E,n[i+4]=o*M+u*R+f*w+v*b,n[i+5]=s*M+d*R+p*w+y*b,n[i+6]=l*M+h*R+m*w+x*b,n[i+7]=c*M+_*R+g*w+S*b,n[i+8]=o*P+u*F+f*L+v*D,n[i+9]=s*P+d*F+p*L+y*D,n[i+10]=l*P+h*F+m*L+x*D,n[i+11]=c*P+_*F+g*L+S*D,n[i+12]=o*B+u*I+f*V+v*O,n[i+13]=s*B+d*I+p*V+y*O,n[i+14]=l*B+h*I+m*V+x*O,n[i+15]=c*B+_*I+g*V+S*O},eP._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,i=0,a=r.length;null!=n&&i<a;)n=n[r[i++]];return i&&i==a?n:void 0},eP.removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var i=e[n];e[r]=i}return e.length--,!0},eP.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))},eP.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eP.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eP.resolveAbsoluteUrl=function(e,t){return eP.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+this._formatRelativePath(t)},eP._stringToPath=function(e){var t=[];return e.charCodeAt(0)===c3&&t.push(""),e.replace(c5,function(e,r,n,i){var a=e;n?a=i.replace(c4,"$1"):r&&(a=r.trim()),t.push(a)}),t},eP._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},eP),c3=46,c4=/\\(\\)?/g,c5=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),c8=((eL=(eF=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eL.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eL._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)c2.removeFromArray(e[t]._updateFlags,this)},cx(eD=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eD.prototype.dispatch=function(){this.flag=!0},eD),c6=((eI=(eB=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eI.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eI.removeFlag=function(e){c2.removeFromArray(this._updateFlags,e)&&c2.removeFromArray(e._flagManagers,this)},eI.addListener=function(e){this._listeners.push(e)},eI.removeListener=function(e){c2.removeFromArray(this._listeners,e)},eI.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var i=this._listeners,a=i.length-1;a>=0;a--)i[a](e,t)},eB),c7=(cx(eV=function(e){var t;return(t=cJ.call(this,e)||this)._position=new ce,t._rotation=new ce,t._rotationQuaternion=new cs,t._scale=new ce(1,1,1),t._worldPosition=new ce,t._worldRotation=new ce,t._worldRotationQuaternion=new cs,t._lossyWorldScale=new ce(1,1,1),t._localMatrix=new cl,t._worldMatrix=new cl,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new c6,t._onPositionChanged=t._onPositionChanged.bind(cm(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(cm(t)),t._onRotationChanged=t._onRotationChanged.bind(cm(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(cm(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(cm(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(cm(t)),t._onScaleChanged=t._onScaleChanged.bind(cm(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},cJ),(eO=eV.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},eO.setRotation=function(e,t,r){this._rotation.set(e,t,r)},eO.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},eO.setScale=function(e,t,r){this._scale.set(e,t,r)},eO.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},eO.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},eO.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},eO.translate=function(e,t,r,n){if("number"==typeof e){var i=eV._tempVec30;i.set(e,t,r),this._translate(i,n)}else this._translate(e,t)},eO.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},eO.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*l9.degreeToRadFactor;cs.rotationAxisAngle(e,n,eV._tempQuat0),this._rotateByQuat(eV._tempQuat0,r)},eO.lookAt=function(e,t){var r=eV._tempVec30;ce.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=l9.zeroTolerance)){r.scale(1/n);var i=eV._tempVec31;if(t?ce.cross(t,r,i):i.set(r.z,0,-r.x),!((n=i.length())<=l9.zeroTolerance)){i.scale(1/n);var a=eV._tempVec32;ce.cross(r,i,a);var o=eV._tempMat41,s=o.elements;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[4]=a.x,s[5]=a.y,s[6]=a.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},eO.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(c8)},eO._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eO._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eO._onDestroy=function(){cJ.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},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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()}},eO._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},eO._getScaleMatrix=function(){var e=eV._tempQuat0,t=eV._tempMat30,r=eV._tempMat31,n=eV._tempMat32;return r.copyFromMatrix(this.worldMatrix),cs.invert(this.worldRotationQuaternion,e),co.rotationQuaternion(e,t),co.multiply(t,r,n),n},eO._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eO._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eO._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eO._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eO._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eO._rotateByQuat=function(e,t){t?cs.multiply(this.rotationQuaternion,e,this._rotationQuaternion):cs.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eO._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=eV._tempVec30;ce.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},eO._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var i=l9.degreeToRadFactor,a=eV._tempQuat0;cs.rotationEuler(e*i,t*i,r*i,a),this._rotateByQuat(a,n)},eO._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eO._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(cl.invert(t.worldMatrix,eV._tempMat41),ce.transformCoordinate(e,eV._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eO._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eO._onWorldRotationChanged=function(){var e=this._worldRotation;cs.rotationEuler(l9.degreeToRadian(e.x),l9.degreeToRadian(e.y),l9.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eO._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eO._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=eV._tempQuat0;cs.invert(t.worldRotationQuaternion,r),cs.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eO._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},cv(eV,[{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(l9.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(l9.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,cs.rotationEuler(l9.degreeToRadian(this._rotation.x),l9.degreeToRadian(this._rotation.y),l9.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):cs.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?cs.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):cs.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)&&(cl.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?cl.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?(cl.invert(t.worldMatrix,eV._tempMat42),cl.multiply(eV._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 ce),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 ce),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 ce),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eV);c7._tempQuat0=new cs,c7._tempVec30=new ce,c7._tempVec31=new ce,c7._tempVec32=new ce,c7._tempMat30=new co,c7._tempMat31=new co,c7._tempMat32=new co,c7._tempMat41=new cl,c7._tempMat42=new cl,cT([cw],c7.prototype,"_position",void 0),cT([cw],c7.prototype,"_rotation",void 0),cT([cw],c7.prototype,"_rotationQuaternion",void 0),cT([cw],c7.prototype,"_scale",void 0),cT([cw],c7.prototype,"_worldPosition",void 0),cT([cw],c7.prototype,"_worldRotation",void 0),cT([cw],c7.prototype,"_worldRotationQuaternion",void 0),cT([cw],c7.prototype,"_lossyWorldScale",void 0),cT([cw],c7.prototype,"_localMatrix",void 0),cT([cw],c7.prototype,"_worldMatrix",void 0),cT([cE],c7.prototype,"_worldForward",void 0),cT([cE],c7.prototype,"_worldRight",void 0),cT([cE],c7.prototype,"_worldUp",void 0),cT([cE],c7.prototype,"_isParentDirty",void 0),cT([cE],c7.prototype,"_parentTransformCache",void 0),cT([cE],c7.prototype,"_updateFlagManager",void 0),cT([cE],c7.prototype,"_onPositionChanged",null),cT([cE],c7.prototype,"_onWorldPositionChanged",null),cT([cE],c7.prototype,"_onRotationChanged",null),cT([cE],c7.prototype,"_onWorldRotationChanged",null),cT([cE],c7.prototype,"_onRotationQuaternionChanged",null),cT([cE],c7.prototype,"_onWorldRotationQuaternionChanged",null),cT([cE],c7.prototype,"_onScaleChanged",null),(eN=lC||(lC={}))[eN.LocalEuler=1]="LocalEuler",eN[eN.LocalQuat=2]="LocalQuat",eN[eN.WorldPosition=4]="WorldPosition",eN[eN.WorldEuler=8]="WorldEuler",eN[eN.WorldQuat=16]="WorldQuat",eN[eN.WorldScale=32]="WorldScale",eN[eN.LocalMatrix=64]="LocalMatrix",eN[eN.WorldMatrix=128]="WorldMatrix",eN[eN.WmWp=132]="WmWp",eN[eN.WmWeWq=152]="WmWeWq",eN[eN.WmWpWeWq=156]="WmWpWeWq",eN[eN.WmWs=160]="WmWs",eN[eN.WmWpWs=164]="WmWpWs",eN[eN.WmWpWeWqWs=188]="WmWpWeWqWs";var c9=((ez=function(){}).cloneComponent=function(e,t,r,n){var i=cb.getCloneMode(e.constructor);for(var a in e)cb.cloneProperty(e,t,a,i[a]);e._cloneTo&&e._cloneTo(t,r,n)},ez),ue=(cx(eU=function(t,r){var n;return(n=cP.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new c1,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._parent=null,n._invModelMatrix=new cl,n.name=r,n.transform=n.addComponent(c7),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},cP),(ek=eU.prototype).addComponent=function(e){c$._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0,lS.All),t},ek.getComponent=function(e){for(var t=this._components,r=t.length-1;r>=0;r--){var n=t[r];if(cA(n,e))return n}return null},ek.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,i=r.length;n<i;n++){var a=r[n];cA(a,e)&&t.push(a)}return t},ek.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},ek.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,i=this._scene,a=lS.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(a|=lS.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==i&&(a|=lS.Scene):a|=lS.Scene),a&&t._processInActive(a),t._scene!==i&&eU._traverseSetOwnerScene(t,i);var o=lS.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=lS.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===i||(o|=lS.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},ek.removeChild=function(e){e._setParent(null)},ek.getChild=function(e){return this._children[e]},ek.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var i=t[r].findByName(e);if(i)return i}return null},ek.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,i=t.length;n<i;++n){var a=t[n];if(a&&!(r=eU._findChildByName(r,a)))return null}return r},ek.createChild=function(e){var t=new eU(this.engine,e);return t.layer=this.layer,t.parent=this,t},ek.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=lS.None;r._isActiveInHierarchy&&(n|=lS.Hierarchy),r._isActiveInScene&&(n|=lS.Scene),n&&r._processInActive(n),eU._traverseSetOwnerScene(r,null)}e.length=0},ek.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e),e},ek._createCloneEntity=function(e){var t=new eU(e._engine,e.name),r=this._hookResource;r&&(t._hookResource=r,r._addReferCount(1)),t.layer=e.layer,t._isActive=e._isActive;var n=t.transform,i=e.transform;n.position=i.position,n.rotation=i.rotation,n.scale=i.scale;for(var a=e._children,o=0,s=e._children.length;o<s;o++)t.addChild(this._createCloneEntity(a[o]));return t},ek._parseCloneEntity=function(e,t,r,n){for(var i=e._children,a=t._children,o=0,s=i.length;o<s;o++)this._parseCloneEntity(i[o],a[o],r,n);for(var l=e._components,c=0,u=l.length;c<u;c++){var d=l[c];if(!cA(d,c7)){var h=t.addComponent(d.constructor);c9.cloneComponent(d,h,r,n)}}},ek.destroy=function(){if(!this._destroyed){cP.prototype.destroy.call(this),this._hookResource&&(this._hookResource._addReferCount(-1),this._hookResource=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}},ek._removeComponent=function(e){c$._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},ek._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},ek._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},ek._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}},ek._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)},ek._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)},ek._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 i=e+1,a=n+1;i<a;i++)r[i]._siblingIndex++}},ek._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,i=e._scene,a=lS.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(a|=lS.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==i&&(a|=lS.Scene):this._isActiveInScene&&(a|=lS.Scene),a&&this._processInActive(a),n!==i&&eU._traverseSetOwnerScene(this,i);var o=lS.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=lS.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===i||(o|=lS.Scene))),o&&this._processActive(o)}else{var s=lS.None;this._isActiveInHierarchy&&(s|=lS.Hierarchy),this._isActiveInScene&&(s|=lS.Scene),s&&this._processInActive(s),r&&eU._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},ek._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];cA(n,e)&&t.push(n)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},ek._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,i=r.length;n<i;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},ek._setActiveInHierarchy=function(e,t){t&lS.Hierarchy&&(this._isActiveInHierarchy=!0),t&lS.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=r.length-1;n>=0;n--){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setActiveInHierarchy(e,t)}},ek._setInActiveInHierarchy=function(e,t){t&lS.Hierarchy&&(this._isActiveInHierarchy=!1),t&lS.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=r.length-1;n>=0;n--){var i=r[n];i.enabled&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setInActiveInHierarchy(e,t)}},ek._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},ek._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 i=n==t?this:e[n-1];e[n]=i,i._siblingIndex=n}else for(var a=r;a<=t;a++){var o=a==t?this:e[a+1];e[a]=o,o._siblingIndex=a}}},ek.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(cl.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eU._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var i=r[n];if(i.name===t)return i}return null},eU._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},cv(eU,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=lS.None;this._isRoot&&this._scene._isActiveInEngine?r|=lS.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=lS.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=lS.Scene)),r&&this._processActive(r)}else{var n=lS.None;this._isActiveInHierarchy&&(n|=lS.Hierarchy),this._isActiveInScene&&(n|=lS.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)}}]),eU),ut=((eH=(eG=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},eH.resetPool=function(){this._elementPoolIndex=0},eH.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},eG);e.BlendFactor=void 0,(eW=e.BlendFactor||(e.BlendFactor={}))[eW.Zero=0]="Zero",eW[eW.One=1]="One",eW[eW.SourceColor=2]="SourceColor",eW[eW.OneMinusSourceColor=3]="OneMinusSourceColor",eW[eW.DestinationColor=4]="DestinationColor",eW[eW.OneMinusDestinationColor=5]="OneMinusDestinationColor",eW[eW.SourceAlpha=6]="SourceAlpha",eW[eW.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eW[eW.DestinationAlpha=8]="DestinationAlpha",eW[eW.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eW[eW.SourceAlphaSaturate=10]="SourceAlphaSaturate",eW[eW.BlendColor=11]="BlendColor",eW[eW.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eX=e.BlendOperation||(e.BlendOperation={}))[eX.Add=0]="Add",eX[eX.Subtract=1]="Subtract",eX[eX.ReverseSubtract=2]="ReverseSubtract",eX[eX.Min=3]="Min",eX[eX.Max=4]="Max",e.ColorWriteMask=void 0,(eK=e.ColorWriteMask||(e.ColorWriteMask={}))[eK.None=0]="None",eK[eK.Red=1]="Red",eK[eK.Green=2]="Green",eK[eK.Blue=4]="Blue",eK[eK.Alpha=8]="Alpha",eK[eK.All=15]="All",e.CompareFunction=void 0,(ej=e.CompareFunction||(e.CompareFunction={}))[ej.Never=0]="Never",ej[ej.Less=1]="Less",ej[ej.Equal=2]="Equal",ej[ej.LessEqual=3]="LessEqual",ej[ej.Greater=4]="Greater",ej[ej.NotEqual=5]="NotEqual",ej[ej.GreaterEqual=6]="GreaterEqual",ej[ej.Always=7]="Always",e.CullMode=void 0,(eY=e.CullMode||(e.CullMode={}))[eY.Off=0]="Off",eY[eY.Front=1]="Front",eY[eY.Back=2]="Back",e.RenderStateDataKey=void 0,(eq=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eq.BlendStateEnabled0=0]="BlendStateEnabled0",eq[eq.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eq[eq.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eq[eq.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eq[eq.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eq[eq.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eq[eq.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eq[eq.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eq[eq.BlendStateBlendColor=8]="BlendStateBlendColor",eq[eq.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eq[eq.DepthStateEnabled=10]="DepthStateEnabled",eq[eq.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eq[eq.DepthStateCompareFunction=12]="DepthStateCompareFunction",eq[eq.StencilStateEnabled=13]="StencilStateEnabled",eq[eq.StencilStateReferenceValue=14]="StencilStateReferenceValue",eq[eq.StencilStateMask=15]="StencilStateMask",eq[eq.StencilStateWriteMask=16]="StencilStateWriteMask",eq[eq.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eq[eq.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eq[eq.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eq[eq.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eq[eq.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eq[eq.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eq[eq.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eq[eq.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eq[eq.RasterStateCullMode=25]="RasterStateCullMode",eq[eq.RasterStateDepthBias=26]="RasterStateDepthBias",eq[eq.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",eq[eq.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(eQ=e.RenderQueueType||(e.RenderQueueType={}))[eQ.Opaque=0]="Opaque",eQ[eQ.AlphaTest=1]="AlphaTest",eQ[eQ.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eZ=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eZ.Float=0]="Float",eZ[eZ.Int=1]="Int",eZ[eZ.Vector2=2]="Vector2",eZ[eZ.Vector3=3]="Vector3",eZ[eZ.Vector4=4]="Vector4",eZ[eZ.Matrix=5]="Matrix",eZ[eZ.Color=6]="Color",eZ[eZ.Texture=7]="Texture",eZ[eZ.FloatArray=8]="FloatArray",eZ[eZ.IntArray=9]="IntArray",eZ[eZ.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eJ=e.StencilOperation||(e.StencilOperation={}))[eJ.Keep=0]="Keep",eJ[eJ.Zero=1]="Zero",eJ[eJ.Replace=2]="Replace",eJ[eJ.IncrementSaturate=3]="IncrementSaturate",eJ[eJ.DecrementSaturate=4]="DecrementSaturate",eJ[eJ.Invert=5]="Invert",eJ[eJ.IncrementWrap=6]="IncrementWrap",eJ[eJ.DecrementWrap=7]="DecrementWrap";var ur=function(){function e(t,r,n,i){this.name=t,this._maskIndex=n,this._maskValue=i,this.value=r;var a=e._macroNameIdMap,o=a[t];void 0===a[t]&&(a[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,i=e._macroMap[n];if(!i){var a=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;i=new e(t,r,s,1<<l),e._macroMap[n]=i,s==a.length&&(a.length++,a[s]=Array(32)),a[s][l]=n,e._macroCounter++}return i},e._getNamesByMacros=function(t,r){var n=e._macroMaskMap,i=t._mask;r.length=0;for(var a=0,o=t._length;a<o;a++)for(var s=n[a],l=i[a],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&r.push(s[u])},e}();ur._macroMaskMap=[],ur._macroNameIdMap=Object.create(null),ur._macroNameCounter=0,ur._macroCounter=0,ur._macroMap=Object.create(null);var un=((e0=(e$=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,i=this._length;if(i<r){for(n.length<r&&(n.length=r);i<t;i++)n[i]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},e0.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var i=r[t]&~e._maskValue;t==n&&0===i?this._length--:r[t]=i}},e0.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,i=this._length;if(i<r){n.length<r&&(n.length=r);for(var a=0;a<i;a++)n[a]|=t[a];for(;a<r;a++)n[a]=t[a];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},e0.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,i=Math.min(e._length-1,n);i>=0;i--){var a=r[i]&~t[i];i==n&&0===a?(n--,this._length--):r[i]=a}},e0.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var i=r[n]&t[n];0==i&&n==this._length-1?this._length--:r[n]=i}},e0.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},e0.clear=function(){this._length=0},e$.unionCollection=function(e,t,r){var n,i,a,o,s=r._mask;e._length<t._length?(n=e._length,i=t._length,a=e._mask,o=t._mask):(n=t._length,i=e._length,a=t._mask,o=e._mask);var l=0;for(s.length<i&&(s.length=i);l<n;l++)s[l]=a[l]|o[l];for(;l<i;l++)s[l]=o[l];r._length=i},e$);function ui(){return(ui=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,(e1=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",e1.ShadowCaster="ShadowCaster",e1.Forward="Forward";var ua=ui({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;",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) )\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) )\nvec3 normalW=normalize(mat3(renderer_NormalMat)*normal.xyz);vec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\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 MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\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 vec3 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 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\nattenuation=mix(1.0,attenuation,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\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;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\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\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\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};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\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 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\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}void initMaterial(out Material material,const in 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));\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}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+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);}float 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);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}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.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(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.viewDir,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 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,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.viewDir,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.viewDir,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(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));\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) )\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 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*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"}),uo=((e2=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},e2.registerInclude=function(e,t){if(ua[e])throw'The "'+e+'" shader include already exist';ua[e]=t},e2.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var r=ua[t];return void 0===r?(cz.error('Shader slice "'+e.trim()+'" not founded.'),""):e2.parseIncludes(r)})},e2.convertTo300=function(e,t){if(e=(e=(e=(e=e.replace(/\battribute\b/g,"in")).replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),t){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")}return e},e2._replaceMRTShader=function(e,t){for(var r="",n=new Set,i=0;i<t.length;i++){var a=t[i].match(/\bgl_FragData\[(.+?)\]/);n.add(a[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)},e2);uo._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"].map(function(e){return"#extension "+e+" : enable\n"}).join("");var us=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}();us._nameCounter=0,us._nameMap=Object.create(null);var ul=((e4=(e3=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?us.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&cz.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},e4.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?us.getByName(e):e)._uniqueId]},e4.getTagValue=function(e){return this._tagsMap["string"==typeof e?us.getByName(e)._uniqueId:e._uniqueId]},cv(e3,[{key:"name",get:function(){return this._name}}]),e3);(e5=lT||(lT={}))[e5.Scene=0]="Scene",e5[e5.Camera=1]="Camera",e5[e5.Renderer=2]="Renderer",e5[e5.Material=3]="Material",e.ColorSpace=void 0,(e8=e.ColorSpace||(e.ColorSpace={}))[e8.Linear=0]="Linear",e8[e8.Gamma=1]="Gamma";var uc=((e7=(e6=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)},e7.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},e7.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,ch.gammaToLinearSpace(r.r),ch.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)},e7.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},e7.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,ch.gammaToLinearSpace(r.r),ch.gammaToLinearSpace(r.g),ch.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)},e7.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},e7.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,ch.gammaToLinearSpace(r.r),ch.gammaToLinearSpace(r.g),ch.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)},e7.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},e7.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},e7.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},e7.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)},e7.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},e7.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)},e7.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},e7.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)},e7.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},e7.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},e7.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},e7.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},e7.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,i=0;i<t.length;i++){var a=t[i];r.activeTexture(n[i]),r.bindTexture(a._platformTexture),a._setUseDepthCompareMode(e.textureUseCompareMode)}},e6),uu=function(){this.constUniforms=[],this.textureUniforms=[]},ud=function(){function e(t,r,n){this.sceneUniformBlock=new uu,this.cameraUniformBlock=new uu,this.rendererUniformBlock=new uu,this.materialUniformBlock=new uu,this.otherUniformBlock=new uu,this._uploadRenderCount=-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,i=0,a=n.length;i<a;i++){var o=n[i],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 i=0,a=n.length;i<a;i++){var o=n[i],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],i=cQ._getShaderPropertyGroup(n.name);void 0!==i&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,i,t))}},t._groupingUniform=function(e,t,r){switch(t){case lT.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case lT.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case lT.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case lT.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 i=this._createShader(r.FRAGMENT_SHADER,t);if(!i)return null;var a=r.createProgram();return a?(r.attachShader(a,n),r.attachShader(a,i),r.linkProgram(a),r.validateProgram(a),r.deleteShader(n),r.deleteShader(i),!cz.isEnabled||r.getProgramParameter(a,r.LINK_STATUS)||r.isContextLost())?a:(cz.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(a,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(a)),r.deleteProgram(a),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,i=n.createShader(t);return i?(n.shaderSource(i,r),n.compileShader(i),!cz.isEnabled||n.getShaderParameter(i,n.COMPILE_STATUS)||n.isContextLost())?i:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(i)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(i),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),i=this._getAttributeInfos();n.forEach(function(n){var i,a=n.name,o=n.size,s=n.type,l=new uc(e._engine),c=!1,u=!1;a.indexOf("[0]")>0&&(a=a.substr(0,a.length-3),c=!0);var d=t.getUniformLocation(r,a);switch(l.name=a,l.propertyId=cQ.getByName(a)._uniqueId,l.location=d,s){case t.FLOAT:c?l.applyFunc=l.upload1fv:(l.applyFunc=l.upload1f,l.cacheValue=0);break;case t.FLOAT_VEC2:c?l.applyFunc=l.upload2fv:(l.applyFunc=l.upload2f,l.cacheValue=new cu(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new ce(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new cd(0,0,0,0));break;case t.BOOL:case t.INT:c?l.applyFunc=l.upload1iv:(l.applyFunc=l.upload1i,l.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:c?l.applyFunc=l.upload2iv:(l.applyFunc=l.upload2i,l.cacheValue=new cu(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:c?l.applyFunc=l.upload3iv:(l.applyFunc=l.upload3i,l.cacheValue=new ce(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new cd(0,0,0));break;case t.FLOAT_MAT4:l.applyFunc=c?l.uploadMat4v:l.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(s){case t.SAMPLER_2D:i=e._engine._magentaTexture2D;break;case t.SAMPLER_CUBE:i=e._engine._magentaTextureCube;break;case t.SAMPLER_2D_ARRAY:i=e._engine._magentaTexture2DArray;break;case t.SAMPLER_2D_SHADOW:i=e._engine._depthTexture2D,l.textureUseCompareMode=!0}if(u=!0,c){for(var h=Array(o),_=new Int32Array(o),f=Array(o),p=0;p<o;p++)h[p]=i,_[p]=e._activeTextureUint,f[p]=t.TEXTURE0+e._activeTextureUint++;l.textureDefault=h,l.textureIndex=f,l.applyFunc=l.uploadTextureArray,e.bind(),t.uniform1iv(d,_)}else{var m=t.TEXTURE0+e._activeTextureUint;l.textureDefault=i,l.textureIndex=m,l.applyFunc=l.uploadTexture,e.bind(),t.uniform1i(d,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var g=cQ._getShaderPropertyGroup(a);e._groupingUniform(l,g,u)}),i.forEach(function(n){var i=n.name;e.attributeLocation[i]=t.getAttribLocation(r,i)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),i=0;i<r;++i){var a=e.getActiveUniform(t,i);n[i]=a}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<n;++i){var a=e.getActiveAttrib(t,i);r[i]=a}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 i=0;i<n-t.length;i++)t+=" ";return t+e}).join("\n")},cv(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();ud._counter=0;var uh=function(t){function r(n,i,a,o){var s;for(var l in(s=t.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderPassId=r._shaderPassCounter++,"string"==typeof a?(s._name=n,s._vertexSource=i,s._fragmentSource=a,o=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=i,o=null!=a?a:{pipelineStage:e.PipelineStage.Forward}),o)s.setTag(l,o[l]);return s}return cx(r,t),r.prototype._getShaderProgram=function(t,r){var n=t._getShaderProgramPool(this),i=n.get(r);if(i)return i;var a=t._hardwareRenderer.isWebGL2,o=[];ur._getNamesByMacros(r,o);var s=uo.parseCustomMacros(o),l=a?"#version 300 es":"#version 100",c=a?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",u="\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)&&(u+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(u+="#define HAS_DERIVATIVES\n");var d=" "+l+"\n "+c+"\n "+s+"\n "+uo.parseIncludes(this._vertexSource),h=" "+l+"\n "+c+"\n "+(a?"":uo._shaderExtension)+"\n "+u+"\n "+s+"\n "+uo.parseIncludes(this._fragmentSource);return a&&(d=uo.convertTo300(d),h=uo.convertTo300(h,!0)),i=new ud(t,d,h),n.cache(i),i},r}(ul);uh._shaderPassCounter=0;var u_=(cx(e9=function(e,t,r){var n;if((n=ul.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var i in n._passes=t.slice(),r)n.setTag(i,r[i]);return n},ul),cv(e9,[{key:"passes",get:function(){return this._passes}}]),e9),uf=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},up=((tt=(te=function(){this.targetBlendState=new uf,this.blendColor=new ch(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,i,a,o,s,l,c,u=this.targetBlendState,d=t[e.RenderStateDataKey.BlendStateEnabled0];if(void 0!==d){var h=r.getFloat(d);u.enabled=void 0!==h&&!!h}var _=t[e.RenderStateDataKey.BlendStateColorBlendOperation0];void 0!==_&&(u.colorBlendOperation=null!=(n=r.getFloat(_))?n:e.BlendOperation.Add);var f=t[e.RenderStateDataKey.BlendStateAlphaBlendOperation0];void 0!==f&&(u.alphaBlendOperation=null!=(i=r.getFloat(f))?i:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(u.sourceColorBlendFactor=null!=(a=r.getFloat(p))?a:e.BlendFactor.One);var m=t[e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0];void 0!==m&&(u.sourceAlphaBlendFactor=null!=(o=r.getFloat(m))?o:e.BlendFactor.One);var g=t[e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0];void 0!==g&&(u.destinationColorBlendFactor=null!=(s=r.getFloat(g))?s:e.BlendFactor.Zero);var v=t[e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0];void 0!==v&&(u.destinationAlphaBlendFactor=null!=(l=r.getFloat(v))?l:e.BlendFactor.Zero);var y=t[e.RenderStateDataKey.BlendStateColorWriteMask0];void 0!==y&&(u.colorWriteMask=null!=(c=r.getFloat(y))?c:e.ColorWriteMask.All);var x=t[e.RenderStateDataKey.BlendStateBlendColor];if(void 0!==x){var S=r.getColor(x);void 0!==S&&this.blendColor.copyFrom(S)}var C=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==C){var T=r.getFloat(C);this.alphaToCoverage=void 0!==T&&!!T}},tt._apply=function(e,t){this._platformApply(e,t.blendState)},tt._platformApply=function(t,r){var n=t.gl,i=r.targetBlendState,a=this.targetBlendState,o=a.enabled,s=a.colorBlendOperation,l=a.alphaBlendOperation,c=a.sourceColorBlendFactor,u=a.destinationColorBlendFactor,d=a.sourceAlphaBlendFactor,h=a.destinationAlphaBlendFactor,_=a.colorWriteMask;if(o!==i.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),i.enabled=o),o){(c!==i.sourceColorBlendFactor||u!==i.destinationColorBlendFactor||d!==i.sourceAlphaBlendFactor||h!==i.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(te._getGLBlendFactor(t,c),te._getGLBlendFactor(t,u),te._getGLBlendFactor(t,d),te._getGLBlendFactor(t,h)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=d,i.destinationAlphaBlendFactor=h),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(n.blendEquationSeparate(te._getGLBlendOperation(t,s),te._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;ch.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==i.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),i.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)},te._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}},te._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}},te);cT([cw],up.prototype,"targetBlendState",void 0),cT([cw],up.prototype,"blendColor",void 0);var um=((tn=(tr=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._applyShaderDataValue=function(t,r){var n,i=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==i){var a=r.getFloat(i);this.enabled=void 0!==a&&!!a}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)},tn._apply=function(e,t){this._platformApply(e,t.depthState)},tn._platformApply=function(e,t){var r=e.gl,n=this.enabled,i=this.compareFunction,a=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&(i!=t.compareFunction&&(r.depthFunc(tr._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(r.depthMask(a),t.writeEnabled=a))},tr._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}},tr),ug=((ta=(ti=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,i,a,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!=(i=r.getFloat(s))?i:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(a=r.getFloat(l))?a:0)},ta._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},ta._platformApply=function(t,r,n){var i=t.gl,a=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=a!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),r._cullFaceEnable=l),l&&a!==r.cullMode&&(a==e.CullMode.Back?i.cullFace(i.BACK):i.cullFace(i.FRONT),r.cullMode=a),n!==r._frontFaceInvert&&(n?i.frontFace(i.CW):i.frontFace(i.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset(s,o)):i.disable(i.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},ti),uv=((ts=(to=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,i,a,o,s,l,c,u,d,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!=(i=r.getFloat(g))?i:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(a=r.getFloat(v))?a: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 S=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==S&&(this.passOperationFront=null!=(l=r.getFloat(S))?l:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==C&&(this.passOperationBack=null!=(c=r.getFloat(C))?c:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==T&&(this.failOperationFront=null!=(u=r.getFloat(T))?u:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==A&&(this.failOperationBack=null!=(d=r.getFloat(A))?d:e.StencilOperation.Keep);var E=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==E&&(this.zFailOperationFront=null!=(h=r.getFloat(E))?h:e.StencilOperation.Keep);var M=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==M&&(this.zFailOperationBack=null!=(_=r.getFloat(M))?_:e.StencilOperation.Keep)},ts._apply=function(e,t){this._platformApply(e,t.stencilState)},ts._platformApply=function(e,t){var r=e.gl,n=this.enabled,i=this.referenceValue,a=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,u=this.passOperationFront,d=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=i!==t.referenceValue||a!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,to._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,to._getGLCompareFunction(e,s),i,a),t.compareFunctionBack=this.compareFunctionBack),p&&(t.referenceValue=this.referenceValue,t.mask=this.mask),(l!==t.failOperationFront||c!==t.zFailOperationFront||u!==t.passOperationFront)&&(r.stencilOpSeparate(r.FRONT,to._getGLStencilOperation(e,l),to._getGLStencilOperation(e,c),to._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(d!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,to._getGLStencilOperation(e,d),to._getGLStencilOperation(e,h),to._getGLStencilOperation(e,_)),t.failOperationBack=d,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},to._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}},to._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}},to),uy=((tc=(tl=function(){this.blendState=new up,this.depthState=new um,this.stencilState=new uv,this.rasterState=new ug,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,i=t[e.RenderStateDataKey.RenderQueueType];void 0!==i&&(this.renderQueueType=null!=(n=r.getFloat(i))?n:e.RenderQueueType.Opaque)},tc._apply=function(e,t,r,n){r&&this._applyShaderDataValue(r,n);var i=e._hardwareRenderer,a=e._lastRenderState;this.blendState._apply(i,a),this.depthState._apply(i,a),this.stencilState._apply(i,a),this.rasterState._apply(i,a,t)},tl);cT([cw],uy.prototype,"blendState",void 0),cT([cw],uy.prototype,"depthState",void 0),cT([cw],uy.prototype,"stencilState",void 0),cT([cw],uy.prototype,"rasterState",void 0);var ux=((tu=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var r=tu._compileMacros;r.clear();for(var n=0,i=t.length;n<i;n++)r.enable(ur.getByName(t[n]));for(var a=this._subShaders,o=0,s=a.length;o<s;o++){for(var l=void 0,c=a[o].passes,u=0,d=c.length;u<d;u++)void 0===l?l=c[u]._getShaderProgram(e,r).isValid:l&&(l=c[u]._getShaderProgram(e,r).isValid);if(l)return!0}return!1},tu.create=function(e,t,r){var n,i=tu._shaderMap;if(t){if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new uh(t,r);n=new tu(e,[new u_("Default",[a])])}else if(t.length>0)n=t[0].constructor===uh?new tu(e,[new u_("Default",t)]):new tu(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!tu._shaderLab)throw"ShaderLab has not been set up yet.";var o=tu._shaderLab.parseShader(e);if(i[o.name])throw'Shader named "'+o.name+'" already exists.';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=tu.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 i=new uh(e.name,e.vertexSource,e.fragmentSource,e.tags),a=e.renderStates,o=new uy;i._renderState=o;var s=a[0];for(var l in s)tu._applyConstRenderStates(o,parseInt(l),s[l]);var c=a[1],u={};for(var d in c)u[d]=cQ.getByName(c[d]);return i._renderStateDataMap=u,i});return new u_(o.name,t,e.tags)});return n=new tu(o.name,s),i[o.name]=n,n}return i[e]=n,n},tu.find=function(e){return tu._shaderMap[e]},tu._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}},tu.getMacroByName=function(e,t){return ur.getByName(e,t)},tu.getPropertyByName=function(e){return cQ.getByName(e)},cv(tu,[{key:"subShaders",get:function(){return this._subShaders}}]),tu);ux._compileMacros=new un,ux._shaderMap=Object.create(null);var uS=((th=(td=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new un,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},th.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},th.getInt=function(e){return this.getPropertyValue(e)},th.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},th.getFloatArray=function(e){return this.getPropertyValue(e)},th.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},th.getIntArray=function(e){return this.getPropertyValue(e)},th.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},th.getVector2=function(e){return this.getPropertyValue(e)},th.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},th.getVector3=function(e){return this.getPropertyValue(e)},th.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},th.getVector4=function(e){return this.getPropertyValue(e)},th.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},th.getMatrix=function(e){return this.getPropertyValue(e)},th.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},th.getColor=function(e){return this.getPropertyValue(e)},th.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},th.getTexture=function(e){return this.getPropertyValue(e)},th.setTexture=function(t,r){var n=this._refCount;if(n>0){var i=this.getPropertyValue(t);i&&i._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},th.getTextureArray=function(e){return this.getPropertyValue(e)},th.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var i=this.getPropertyValue(t);if(i)for(var a=0,o=i.length;a<o;a++)i[a]._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)},th.getPropertyValue=function(e){return"string"==typeof e&&(e=cQ.getByName(e)),this._propertyValueMap[e._uniqueId]},th.enableMacro=function(e,t){"string"==typeof e&&(e=ur.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var i=this._macroCollection;n&&i.disable(n),i.enable(e),this._macroMap[r]=e}},th.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=ur._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},th.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])},th.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=cQ._propertyIdMap;for(var i in r)t.push(n[i]);if(!e)return t},th.clone=function(){var e=new td(this._group);return this.cloneTo(e),e},th.cloneTo=function(e){cb.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,i=Object.keys(r),a=0,o=i.length;a<o;a++){var s=i[a],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(cA(l,cU))n[s]=l,t>0&&l._addReferCount(t);else if(cA(l,Array)||cA(l,Float32Array)||cA(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},th._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=cQ.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 "+lT[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},th._getReferCount=function(){return this._refCount},th._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&cA(n,cU)&&n._addReferCount(e)}},td);cT([cE],uS.prototype,"_group",void 0),cT([cE],uS.prototype,"_propertyValueMap",void 0),cT([cE],uS.prototype,"_macroCollection",void 0),cT([cE],uS.prototype,"_macroMap",void 0),cT([cE],uS.prototype,"_refCount",void 0);var uC=((t_=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(t_._viewMatrixProperty,e.viewMatrix),t.setMatrix(t_._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(t_.vpMatrixProperty,e.viewProjectionMatrix)},t_);uC.vpMatrixProperty=cQ.getByName("camera_VPMat"),uC.pipelineStageKey=us.getByName("pipelineStage"),uC._viewMatrixProperty=cQ.getByName("camera_ViewMat"),uC._projectionMatrixProperty=cQ.getByName("camera_ProjMat");var uT=((tp=(tf=function(){}).prototype).setX=function(e,t,r,n){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n},tp.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null},tf),uA=((tg=(tm=function(){}).prototype).set=function(e,t){this.data=e,this.shaderPasses=t},tg.dispose=function(){this.data=this.shaderPasses=null},tm);function uE(){return function(e){}}e.SpriteMaskInteraction=void 0,(tv=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[tv.None=0]="None",tv[tv.VisibleInsideMask=1]="VisibleInsideMask",tv[tv.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(cx(ty=function(t){(r=cJ.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new un,r._bounds=new cr,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._shaderData=new uS(lT.Renderer),r._mvMatrix=new cl,r._mvpMatrix=new cl,r._mvInvMatrix=new cl,r._normalMatrix=new cl,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r._rendererLayer=new cd,r.castShadows=!0;var r,n=e.Renderer.prototype,i=r.shaderData;return r._overrideUpdate=r.update!==n.update,i._addReferCount(1),r._onTransformChanged=r._onTransformChanged.bind(cm(r)),r._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},cJ),(tx=ty.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},tx.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},tx.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},tx.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},tx.getMaterials=function(){return this._materials},tx.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,i=t,a=r.length;i<a;i++){var o=r[i];o&&o._addReferCount(-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&&l._addReferCount(-1),c&&c._addReferCount(1))}},tx.update=function(e){},tx._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},tx._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},tx._prepareRender=function(t){var r=t.virtualCamera,n=r.position,i=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(ce.subtract(i,n,i),this._distanceForSort=ce.dot(i,r.forward)):this._distanceForSort=ce.distanceSquared(i,n),this._updateShaderData(t),this._render(t),un.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},tx._cloneTo=function(e,t,r){for(var n=this._materials,i=0,a=n.length;i<a;i++)e._setMaterial(i,n[i])},tx._onDestroy=function(){cJ.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this.shaderData._addReferCount(-1);for(var e,t=this._materials,r=0,n=t.length;r<n;r++)null==(e=t[r])||e._addReferCount(-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},tx._updateShaderData=function(e){var t=this.entity,r=t.transform.worldMatrix;this._updateTransformShaderData(e,r);var n=t.layer;this._rendererLayer.set(65535&n,n>>>16&65535,0,0)},tx._updateTransformShaderData=function(t,r){var n=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;cl.multiply(i.viewMatrix,r,a),cl.multiply(i.viewProjectionMatrix,r,o),cl.invert(a,s),cl.invert(r,l),l.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._mvpMatrixProperty,o),n.setMatrix(e.Renderer._mvInvMatrixProperty,s),n.setMatrix(e.Renderer._normalMatrixProperty,l)},tx._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},tx._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},tx._updateBounds=function(e){},tx._render=function(e){throw"not implement"},tx._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",e._addReferCount(-1),r._addReferCount(1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},tx._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var i=this._materialsInstanced;e<i.length&&(i[e]=!1),n&&n._addReferCount(-1),t&&t._addReferCount(1),r[e]=t}},tx._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},cv(ty,[{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}}]),ty._tempVector0=new ce,ty._receiveShadowMacro=ur.getByName("RENDERER_IS_RECEIVE_SHADOWS"),ty._localMatrixProperty=cQ.getByName("renderer_LocalMat"),ty._worldMatrixProperty=cQ.getByName("renderer_ModelMat"),ty._mvMatrixProperty=cQ.getByName("renderer_MVMat"),ty._mvpMatrixProperty=cQ.getByName("renderer_MVPMat"),ty._mvInvMatrixProperty=cQ.getByName("renderer_MVInvMat"),ty._normalMatrixProperty=cQ.getByName("renderer_NormalMat"),ty._rendererLayerProperty=cQ.getByName("renderer_Layer"),ty),cT([cE],e.Renderer.prototype,"_distanceForSort",void 0),cT([cE],e.Renderer.prototype,"_onUpdateIndex",void 0),cT([cE],e.Renderer.prototype,"_rendererIndex",void 0),cT([cE],e.Renderer.prototype,"_globalShaderMacro",void 0),cT([cE],e.Renderer.prototype,"_bounds",void 0),cT([cE],e.Renderer.prototype,"_renderFrameCount",void 0),cT([cE],e.Renderer.prototype,"_overrideUpdate",void 0),cT([cE],e.Renderer.prototype,"_materials",void 0),cT([cE],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),cT([cw],e.Renderer.prototype,"_shaderData",void 0),cT([cE],e.Renderer.prototype,"_mvMatrix",void 0),cT([cE],e.Renderer.prototype,"_mvpMatrix",void 0),cT([cE],e.Renderer.prototype,"_mvInvMatrix",void 0),cT([cE],e.Renderer.prototype,"_normalMatrix",void 0),cT([cE],e.Renderer.prototype,"_materialsInstanced",void 0),cT([cM],e.Renderer.prototype,"_priority",void 0),cT([cM],e.Renderer.prototype,"_receiveShadows",void 0),cT([cE],e.Renderer.prototype,"_rendererLayer",void 0),cT([cE],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=cT([c0(c7,e.DependentMode.CheckOnly)],e.Renderer),(tS=lA||(lA={}))[tS.WorldVolume=1]="WorldVolume";var uM=((tC=function(){}).resetData=function(e){var t,r,n=e._verticesData,i=n.positions,a=n.uvs;n.vertexCount=i.length=a.length=4;for(var o=0;o<4;o++)i[t=o]||(i[t]=new ce),a[r=o]||(a[r]=new cu);n.triangles=uM._rectangleTriangles},tC.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,i=n.pivot,a=i.x,o=i.y,s=uM._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,u=e.flipX?-t:t,d=e.flipY?-r:r;l[0]=c[0]*u,l[1]=c[1]*u,l[2]=c[2]*u,l[4]=c[4]*d,l[5]=c[5]*d,l[6]=c[6]*d,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-a*l[0]-o*l[4],l[13]=c[13]-a*l[1]-o*l[5],l[14]=c[14]-a*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])}cr.transform(n._getBounds(),s,e._bounds)},tC.updateUVs=function(e){var t=e.sprite._getUVs(),r=e._verticesData.uvs,n=t[0],i=n.x,a=n.y,o=t[3],s=o.x,l=o.y;r[0].set(i,a),r[1].set(s,a),r[2].set(i,l),r[3].set(s,l)},tC._rectangleTriangles=[0,1,2,2,1,3],tC._worldMatrix=new cl,tC);uM=cT([uE()],uM);var uR=function(e,t,r,n,i){void 0===n&&(n=null),void 0===i&&(i=null),this.vertexCount=e,this.positions=t,this.uvs=r,this.triangles=n,this.color=i};e.SpriteMaskLayer=void 0,(tT=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[tT.Layer0=1]="Layer0",tT[tT.Layer1=2]="Layer1",tT[tT.Layer2=4]="Layer2",tT[tT.Layer3=8]="Layer3",tT[tT.Layer4=16]="Layer4",tT[tT.Layer5=32]="Layer5",tT[tT.Layer6=64]="Layer6",tT[tT.Layer7=128]="Layer7",tT[tT.Layer8=256]="Layer8",tT[tT.Layer9=512]="Layer9",tT[tT.Layer10=1024]="Layer10",tT[tT.Layer11=2048]="Layer11",tT[tT.Layer12=4096]="Layer12",tT[tT.Layer13=8192]="Layer13",tT[tT.Layer14=16384]="Layer14",tT[tT.Layer15=32768]="Layer15",tT[tT.Layer16=65536]="Layer16",tT[tT.Layer17=131072]="Layer17",tT[tT.Layer18=262144]="Layer18",tT[tT.Layer19=524288]="Layer19",tT[tT.Layer20=1048576]="Layer20",tT[tT.Layer21=2097152]="Layer21",tT[tT.Layer22=4194304]="Layer22",tT[tT.Layer23=8388608]="Layer23",tT[tT.Layer24=16777216]="Layer24",tT[tT.Layer25=33554432]="Layer25",tT[tT.Layer26=67108864]="Layer26",tT[tT.Layer27=134217728]="Layer27",tT[tT.Layer28=268435456]="Layer28",tT[tT.Layer29=536870912]="Layer29",tT[tT.Layer30=1073741824]="Layer30",tT[tT.Layer31=2147483648]="Layer31",tT[tT.Everything=4294967295]="Everything",(tA=lE||(lE={}))[tA.texture=1]="texture",tA[tA.size=2]="size",tA[tA.atlasRotate=4]="atlasRotate",tA[tA.atlasRegion=8]="atlasRegion",tA[tA.atlasRegionOffset=16]="atlasRegionOffset",tA[tA.region=32]="region",tA[tA.pivot=64]="pivot",tA[tA.border=128]="border",tA[tA.destroy=256]="destroy";var uw=function(t){function r(n){var i;return(i=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,i._sprite=null,i._automaticWidth=0,i._automaticHeight=0,i._customWidth=void 0,i._customHeight=void 0,i._flipX=!1,i._flipY=!1,i._alphaCutoff=.5,i._verticesData=new uR(4,[],[]),uM.resetData(cm(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(r._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(cm(i)),i}cx(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?uM.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&lA.WorldVolume&&(uM.updatePositions(this),this._dirtyUpdateFlag&=~lA.WorldVolume),2&this._dirtyUpdateFlag&&(uM.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var i=n._spriteMaskRenderDataPool.getFromPool();i.set(this,r,this._verticesData);var a=n._renderElementPool.getFromPool();a.set(i,r.shader.subShaders[0].passes),this._maskElement=a}}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,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 lE.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case lE.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lA.WorldVolume);break;case lE.region:case lE.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lE.atlasRegion:this._dirtyUpdateFlag|=2;break;case lE.pivot:this._dirtyUpdateFlag|=lA.WorldVolume;break;case lE.destroy:this.sprite=null}},cv(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|=lA.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|=lA.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lA.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lA.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(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);uw._textureProperty=cQ.getByName("renderer_MaskTexture"),uw._alphaCutoffProperty=cQ.getByName("renderer_MaskAlphaCutoff"),cT([cM],uw.prototype,"influenceLayers",void 0),cT([cE],uw.prototype,"_verticesData",void 0),cT([cE],uw.prototype,"_sprite",void 0),cT([cE],uw.prototype,"_automaticWidth",void 0),cT([cE],uw.prototype,"_automaticHeight",void 0),cT([cM],uw.prototype,"_customWidth",void 0),cT([cM],uw.prototype,"_customHeight",void 0),cT([cM],uw.prototype,"_flipX",void 0),cT([cM],uw.prototype,"_flipY",void 0),cT([cM],uw.prototype,"_alphaCutoff",void 0),cT([cE],uw.prototype,"_onSpriteChange",null),(tE=lM||(lM={}))[tE.UV=2]="UV",tE[tE.RenderData=3]="RenderData",tE[tE.AutomaticSize=4]="AutomaticSize",tE[tE.All=7]="All",e.VertexElementFormat=void 0,(tM=e.VertexElementFormat||(e.VertexElementFormat={}))[tM.Float=0]="Float",tM[tM.Vector2=1]="Vector2",tM[tM.Vector3=2]="Vector3",tM[tM.Vector4=3]="Vector4",tM[tM.Byte4=4]="Byte4",tM[tM.UByte4=5]="UByte4",tM[tM.NormalizedByte4=6]="NormalizedByte4",tM[tM.NormalizedUByte4=7]="NormalizedUByte4",tM[tM.Short2=8]="Short2",tM[tM.UShort2=9]="UShort2",tM[tM.NormalizedShort2=10]="NormalizedShort2",tM[tM.NormalizedUShort2=11]="NormalizedUShort2",tM[tM.Short4=12]="Short4",tM[tM.UShort4=13]="UShort4",tM[tM.NormalizedShort4=14]="NormalizedShort4",tM[tM.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(tR=e.IndexFormat||(e.IndexFormat={}))[tR.UInt8=0]="UInt8",tR[tR.UInt16=1]="UInt16",tR[tR.UInt32=2]="UInt32";var ub=((tw=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}},tw._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tw._getElementInfo=function(t){var r,n,i,a=!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,a=!0,i=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,a=!0,i=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,a=!0,i=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,a=!0,i=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,a=!0,i=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,a=!0,i=1/65535}return{size:r,type:n,normalized:a,normalizedScaleFactor:i}},tw),uP=(cv(tb=function(e,t,r,n,i){void 0===i&&(i=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=ub._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)},[{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}}]),tb);e.BufferUsage=void 0,(tP=e.BufferUsage||(e.BufferUsage={}))[tP.Static=0]="Static",tP[tP.Dynamic=1]="Dynamic",tP[tP.Stream=2]="Stream",e.SetDataOptions=void 0,(tF=e.SetDataOptions||(e.SetDataOptions={}))[tF.None=0]="None",tF[tF.Discard=1]="Discard";var uF=(cx(tL=function(t,r,n,i,a){if(void 0===i&&(i=e.BufferUsage.Static),void 0===a&&(a=!1),(o=cD.call(this,t)||this)._dataUpdateManager=new c6,o._engine=t,o._type=r,o._bufferUsage=i,o._readable=a,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,i),a&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,i,n),a){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},cD),(tD=tL.prototype).bind=function(){this._platformBuffer.bind()},tD.setData=function(t,r,n,i,a){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,i,a),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=i?s*i:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,u=new Uint8Array(o,c,l);this._data.set(u,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},tD.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},tD.markAsUnreadable=function(){this._data=null,this._readable=!1},tD._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},tD._onDestroy=function(){cD.prototype._onDestroy.call(this),this._platformBuffer.destroy()},cv(tL,[{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."}}]),tL);e.BufferBindFlag=void 0,(tB=e.BufferBindFlag||(e.BufferBindFlag={}))[tB.VertexBuffer=0]="VertexBuffer",tB[tB.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(tI=e.MeshTopology||(e.MeshTopology={}))[tI.Points=0]="Points",tI[tI.Lines=1]="Lines",tI[tI.LineLoop=2]="LineLoop",tI[tI.LineStrip=3]="LineStrip",tI[tI.Triangles=4]="Triangles",tI[tI.TriangleStrip=5]="TriangleStrip",tI[tI.TriangleFan=6]="TriangleFan";var uL=(cv(tV=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tV),uD=((tO=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(){},tO),uB=(cx(tN=function(e){var t;return(t=cD.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(cm(t)),t},cD),(tz=tN.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,i=t[n];i&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(i),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},tz.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},tz.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},tz.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,i=n[e];i&&delete r[i.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},tz.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,i=r.length;n<i;n++){var a=r[n];delete t[a.attribute]}r.length=e},tz.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),i=this.vertexBufferBindings;n>0&&(null==(r=i[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),i[e]=t,this._bufferStructChanged=!0},tz.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,i=t+n;r.length<i&&(r.length=i);for(var a=0;a<n;a++)this.setVertexBufferBinding(t+a,e[a])},tz.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=ub._getGLIndexType(e.format),this._glIndexByteCount=ub._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},tz.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tz._addReferCount=function(e){cD.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,i=0,a=n.length;i<a;i++)null==(r=n[i])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},tz._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},tz._onDestroy=function(){cD.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},cv(tN,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),tN),uI=(cx(tU=function(e,t){(r=cF.call(this,e)||this)._updateFlagManager=new c6,r._bounds=new cr,r._subMeshes=[],r.name=t,r._primitive=new uB(e),r._onBoundsChanged=r._onBoundsChanged.bind(cm(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},cF),(tk=tU.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new uD(t,r,n)),this._subMeshes.push(t),t},tk.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},tk.clearSubMesh=function(){this._subMeshes.length=0},tk._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},tk._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},tk._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},tk._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},tk._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},tk._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},tk._addReferCount=function(e){cF.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},tk._onDestroy=function(){cF.prototype._onDestroy.call(this),this._primitive.destroy()},tk._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},tk._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},tk._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},cv(tU,[{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}}]),tU);(tG=lR||(lR={}))[tG.Bounds=1]="Bounds",tG[tG.VertexElements=2]="VertexElements";var uV=(cv(tH=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tH),uO=((tW=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new c6,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},cv(tW,[{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)}}]),tW);(tX=lw||(lw={}))[tX.Position=1]="Position",tX[tX.Normal=2]="Normal",tX[tX.Tangent=4]="Tangent",tX[tX.All=7]="All";var uN=((tj=(tK=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new c6,this._dataChangeManager=new c6,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var i=new uO(e,t,r,n);return this._addFrame(i),i}this._addFrame(e)},tj.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()},tj._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},tj._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(lw.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},tj._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))},tj._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},cv(tK,[{key:"frames",get:function(){return this._frames}}]),tK),uz=(cx(tY=function(){return uI.apply(this,arguments)},uI),(tq=tY.prototype).setVertexElements=function(e){this._setVertexElements(e)},tq.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,i=void 0!==n.buffer;i||(n=new uV(e,t));var a=this._primitive.vertexBufferBindings;a.length<=r&&(a.length=r+1),this._setVertexBufferBinding(i?t:r,n)},tq.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,i=t+n;r.length<i&&(r.length=i);for(var a=0;a<n;a++)this._setVertexBufferBinding(t+a,e[a])},tq.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new uL(e,t))),this._setIndexBufferBinding(r)},cv(tY,[{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}}]),tY),uU=(tQ=e.Renderer,cx(tZ=function(e){var t;return(t=tQ.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(cm(t)),t},tQ),(tJ=tZ.prototype)._onDestroy=function(){tQ.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},tJ._cloneTo=function(e,t,r){tQ.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},tJ._prepareRender=function(e){if(!this._mesh){cz.error("mesh is null.");return}if(this._mesh.destroyed){cz.error("mesh is destroyed.");return}tQ.prototype._prepareRender.call(this,e)},tJ._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;cr.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tJ._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(tZ._uvMacro),r.disableMacro(tZ._uv1Macro),r.disableMacro(tZ._normalMacro),r.disableMacro(tZ._tangentMacro),r.disableMacro(tZ._enableVertexColorMacro);for(var i=0,a=n.length;i<a;i++)switch(n[i].attribute){case"TEXCOORD_0":r.enableMacro(tZ._uvMacro);break;case"TEXCOORD_1":r.enableMacro(tZ._uv1Macro);break;case"NORMAL":r.enableMacro(tZ._normalMacro);break;case"TANGENT":r.enableMacro(tZ._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(tZ._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._renderDataPool,u=0,d=s.length;u<d;u++){var h=o[u];if(h){h.destroyed&&(h=this.engine._meshMagentaMaterial);var _=c.getFromPool();_.setX(this,h,t._primitive,s[u]),l.pushRenderData(e,_)}}},tJ._setMesh=function(e){var t=this._mesh;t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tJ._onMeshChanged=function(e){e&lR.Bounds&&(this._dirtyUpdateFlag|=lA.WorldVolume),e&lR.VertexElements&&(this._dirtyUpdateFlag|=2)},cv(tZ,[{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)}}]),tZ);uU._uvMacro=ur.getByName("RENDERER_HAS_UV"),uU._uv1Macro=ur.getByName("RENDERER_HAS_UV1"),uU._normalMacro=ur.getByName("RENDERER_HAS_NORMAL"),uU._tangentMacro=ur.getByName("RENDERER_HAS_TANGENT"),uU._enableVertexColorMacro=ur.getByName("RENDERER_ENABLE_VERTEXCOLOR"),cT([cE],uU.prototype,"_mesh",void 0),cT([cE],uU.prototype,"_onMeshChanged",null),(t$=lb||(lb={}))[t$.VertexElementMacro=2]="VertexElementMacro",t$[t$.All=3]="All";var uk=((t1=(t0=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 cd,this._canUseTextureStoreData=!0,this._dataTextureInfo=new ce,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(c8))},t1._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,i=0,a=n.length;i<a;i++)n[i].destroy();n.length=0},t1._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(t0._blendShapeMacro),this._useTextureMode())e.enableMacro(t0._blendShapeTextureMacro),e.setTexture(t0._blendShapeTextureProperty,this._vertexTexture),e.setVector3(t0._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(t0._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var i=t._condensedBlendShapeWeights;i||(i=new Float32Array(n),t._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,i),e.setFloatArray(t0._blendShapeWeightsProperty,i),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(t0._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(t0._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(t0._blendShapeNormalMacro):e.disableMacro(t0._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(t0._blendShapeTangentMacro):e.disableMacro(t0._blendShapeTangentMacro)}else e.disableMacro(t0._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},t1._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},t1._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},t1._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},t1._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},t1._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,i=Math.max(r.length,t+1);n<i&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},t1._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,i=0,a=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());a<o;a++)t._setVertexElement(r++,new uP("POSITION_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12,this._useBlendNormal&&(t._setVertexElement(r++,new uP("NORMAL_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12),this._useBlendTangent&&(t._setVertexElement(r++,new uP("TANGENT_BS"+a,i,e.VertexElementFormat.Vector3,n)),i+=12);return r},t1._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))},t1._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},t1._createVertexBuffers=function(t,r){var n=this._engine,i=this._modelMesh,a=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),u=Math.ceil(a/c),d=s*t*Math.min(c,a);o.length=u,this._vertices=new Float32Array(d),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=a;for(var h=this._bufferBindingOffset,_=0;_<u;_++){var f=u-1,p=(_===f?a-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new uF(n,e.BufferBindFlag.VertexBuffer,m,g);i._setVertexBufferBinding(h+_,new uV(v,p)),o[_]=v}},t1._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,i=n*t,a=1;i>r&&(a=Math.ceil(i/r),i=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new cH(this._engine,i,a,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*i*a*4),this._vertexTexture=o,this._dataTextureInfo.set(n,i,a)},t1._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,i=this._vertices,a=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,d=0,h=r.length;d<h;d++){var _=s[d];if(t||_.flag){var f=r[d].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(d/n),v=d%n,y=a[g],x=y.byteLength/(4*e),S=v*l,C=o[d];C||(o[d]=C=new cu),C.set(u+g,v*c);for(var T=m.deltaPositions,A=0;A<e;A++){var E=S+x*A,M=T[A];M&&(i[E]=M.x,i[E+1]=M.y,i[E+2]=M.z)}if(S+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var w=0;w<e;w++){var b=S+x*w,P=R[w];P&&(i[b]=P.x,i[b+1]=P.y,i[b+2]=P.z)}S+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=S+x*L,B=F[L];B&&(i[D]=B.x,i[D+1]=B.y,i[D+2]=B.z)}S+=3}(v===n-1||d===h-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},t1._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,i=this._vertices,a=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=a[o],c=n.width*n.height*4;if(t||l.flag){var u=r[o].frames,d=u.length,h=u[d-1];if(d>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(i[m]=v.x,i[m+1]=v.y,i[m+2]=v.z,m+=4,f){var y=f[g];i[m]=y.x,i[m+1]=y.y,i[m+2]=y.z,m+=4}if(p){var x=p[g];i[m]=x.x,i[m+1]=x.y,i[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,i)},t1._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,i=t._useBlendShapeNormal,a=t._useBlendShapeTangent;r&&(i&&(i=this._useBlendNormal),a&&(a=this._useBlendTangent)),i&&n++,a&&n++,this._useBlendNormal=i,this._useBlendTangent=a,this._vertexElementCount=n},t1._attributeModeUpdateVertexElement=function(e,t,r,n){var i=this._vertexElementOffset+this._vertexElementCount*n,a=t[r],o=a.x,s=a.y,l=e[i];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++i];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++i];s+=12,u.bindingIndex=o,u.offset=s}},t1._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},t1._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,i=this._modelMesh._primitive.vertexElements,a=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(i,a,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(i,a,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<n;u++){var d=t[u];d<o&&(o=d,r=u)}}}},t0);uk._blendShapeMacro=ur.getByName("RENDERER_HAS_BLENDSHAPE"),uk._blendShapeTextureMacro=ur.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),uk._blendShapeNormalMacro=ur.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),uk._blendShapeTangentMacro=ur.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),uk._blendShapeWeightsProperty=cQ.getByName("renderer_BlendShapeWeights"),uk._blendShapeTextureProperty=cQ.getByName("renderer_BlendShapeTexture"),uk._blendShapeTextureInfoProperty=cQ.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(t2=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",t2.Normal="NORMAL",t2.Color="COLOR_0",t2.Tangent="TANGENT",t2.BoneWeight="WEIGHTS_0",t2.BoneIndex="JOINTS_0",t2.UV="TEXCOORD_0",t2.UV1="TEXCOORD_1",t2.UV2="TEXCOORD_2",t2.UV3="TEXCOORD_3",t2.UV4="TEXCOORD_4",t2.UV5="TEXCOORD_5",t2.UV6="TEXCOORD_6",t2.UV7="TEXCOORD_7";var uG=(cx(t3=function(e,t){var r;return(r=uI.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 ce(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 uk(e,cm(r)),r},uI),(t4=t3.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)},t4.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},t4.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},t4.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},t4.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},t4.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},t4.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},t4.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},t4.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},t4.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},t4.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},t4.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},t4.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]."}},t4.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 i=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=i,i;case 3:var a=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=a,a;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]."},t4.setIndices=function(t){this._indices!==t&&(this._indices=t,cA(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:cA(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:cA(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},t4.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},t4.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,i=0;i<n;i++)this._addVertexElement(t[i]);var a=this._primitive._vertexElementMap;a[e.VertexAttribute.Position]||this.setPositions(null),a[e.VertexAttribute.Normal]||this.setNormals(null),a[e.VertexAttribute.Color]||this.setColors(null),a[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),a[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),a[e.VertexAttribute.Tangent]||this.setTangents(null),a[e.VertexAttribute.UV]||this.setUVs(null,0),a[e.VertexAttribute.UV1]||this.setUVs(null,1),a[e.VertexAttribute.UV2]||this.setUVs(null,2),a[e.VertexAttribute.UV3]||this.setUVs(null,3),a[e.VertexAttribute.UV4]||this.setUVs(null,4),a[e.VertexAttribute.UV5]||this.setUVs(null,5),a[e.VertexAttribute.UV6]||this.setUVs(null,6),a[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},t4.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,i=void 0!==n.buffer;i||(n=new uV(e,t));var a=i?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=a+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(a,n),a===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),a===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},t4.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,a=t+r;n.length<a&&(n.length=a,i.length=a);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},t4.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},t4.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},t4.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},t4.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},t4.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,i=0,a=n.length;i<a;i++){var o=r[i];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[i])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,u=null==(d=this._primitive.indexBufferBinding)?void 0:d._buffer;if(c){if(u&&c.byteLength==u.byteLength)u.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new uL(u,this._indicesFormat));else{null==u||u.destroy();var d,h=new uF(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new uL(h,this._indicesFormat))}}else u&&(u.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var _=this._blendShapeManager;_._blendShapeCount>0&&_._update(t),t&&(this._accessible=!1,this._releaseCache(!1))},t4.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,i=this.vertexCount,a=t3._tempVec0,o=t3._tempVec1,s=t3._tempVec2,l=t3._tempVec3,c=t3._tempVec4,u=n?n.length/3:e.length/3,d=Array(i),h=Array(i),_=0;_<i;_++)d[_]=new cd,h[_]=new ce;for(var f=0;f<u;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],S=r[p],C=r[m],T=r[g];ce.subtract(y,v,a),ce.subtract(x,v,o);var A=C.x-S.x,E=T.x-S.x,M=C.y-S.y,R=T.y-S.y,w=1/(A*R-E*M);ce.scale(a,R*w,s),ce.scale(o,M*w,c),ce.subtract(s,c,s),ce.scale(o,A*w,l),ce.scale(a,E*w,c),ce.subtract(l,c,l);var b=d[p];b.set(b.x+s.x,b.y+s.y,b.z+s.z,1),(b=d[m]).set(b.x+s.x,b.y+s.y,b.z+s.z,1),(b=d[g]).set(b.x+s.x,b.y+s.y,b.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<i;P++){var F=t[P],L=h[P],D=d[P];s.set(D.x,D.y,D.z),ce.cross(s,L,c);var B=ce.dot(c,F)>0?1:-1;ce.scale(F,ce.dot(s,F),c),ce.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,B)}this.setTangents(d)},t4._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,a=function(){r._advancedDataSyncToBuffer||(i[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(a),uI.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(a),(i[e]||(i[e]=new uH)).reset(),a()):e+1==n.length&&n.length--},t4._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)}},t4._onDestroy=function(){uI.prototype._onDestroy.call(this),this._releaseCache(!0)},t4._getVertexElementData=function(e,t,r,n){var i,a=this._advancedVertexDataVersions,o=null!=(i=a[r])?i:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(a[r]=l,n.call(this,t))},t4._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)},t4._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},t4._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,i=this._internalVertexBufferCreatedInfo,a=r*n;if(i.x*i.y!==a){var o,s=i.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 u=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,d=new uF(this._engine,e.BufferBindFlag.VertexBuffer,a,u,!0);this._setVertexBufferBinding(l,new uV(d,r))}i.set(r,n,c?l:-1)}},t4._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new cu(e[t],e[t+1])})},t4._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new ce(e[t],e[t+1],e[t+2])})},t4._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new cd(e[t],e[t+1],e[t+2],e[t+3])})},t4._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new ch(e[t],e[t+1],e[t+2],e[t+3])})},t4._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var i=r.vertexBufferBindings[n.bindingIndex],a=null==i?void 0:i.buffer;if(!a)return null;if(!a.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(a.data.buffer,s.type),u=n.offset,d=i.stride,h=0;h<o;h++){var _=(h*d+u)/c.BYTES_PER_ELEMENT,f=t(c,_);s.normalized&&f.scale(s.normalizedScaleFactor),l[h]=f}return l},t4._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var i=this._getAttributeFormat(t),a=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new uP(t,a,i,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)}}},t4._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)},t4._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 i=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||i&&t._blendShapeCount>0){var a=t._addVertexElements(this);a<r&&this._setVertexElementsLength(a)}},t4._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y)})},t4._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z)})},t4._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.x,e[t+1]=i.y,e[t+2]=i.z,e[t+3]=i.w)})},t4._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var i=r[n];i&&(e[t]=i.r,e[t+1]=i.g,e[t+2]=i.b,e[t+3]=i.a)})},t4._writeAdvancedVertexData=function(e,t,r){var n,i=this._primitive,a=i._vertexElementMap[e],o=a.bindingIndex,s=i.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,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=a._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=a.offset,f=s.stride,p=h.BYTES_PER_ELEMENT,m=d.normalized,g=d.size,v=d.normalizedScaleFactor,y=0,x=this._vertexCount;y<x;y++){var S=(y*f+_)/p;if(r(h,S,y),m)for(var C=0;C<g;C++)h[S+C]/=v}u.uploadAdvancedData=!0}}},t4._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,i=this._advancedDataUpdateFlag,a=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,u=this._uv2,d=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&i&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&i&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&i&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),a&&16&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,a),o&&32&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&i&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),u&&256&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,u),d&&512&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,d),h&&1024&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&i&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},t4._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},t4._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}},t4._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}},t4._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,i=0,a=n.length;i<a;i++){var o=n[i];o&&(o.dataVersion=r)}}},cv(t3,[{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}}]),t3);uG._tempVec0=new ce,uG._tempVec1=new ce,uG._tempVec2=new ce,uG._tempVec3=new ce,uG._tempVec4=new ce;var uH=((t5=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},t5);(t8=lP||(lP={}))[t8.None=0]="None",t8[t8.Position=1]="Position",t8[t8.Normal=2]="Normal",t8[t8.Color=4]="Color",t8[t8.Tangent=8]="Tangent",t8[t8.BoneWeight=16]="BoneWeight",t8[t8.BoneIndex=32]="BoneIndex",t8[t8.UV=64]="UV",t8[t8.UV1=128]="UV1",t8[t8.UV2=256]="UV2",t8[t8.UV3=512]="UV3",t8[t8.UV4=1024]="UV4",t8[t8.UV5=2048]="UV5",t8[t8.UV6=4096]="UV6",t8[t8.UV7=8192]="UV7",t8[t8.All=65535]="All",(t6=lF||(lF={}))[t6.Position=0]="Position",t6[t6.Normal=1]="Normal",t6[t6.Color=2]="Color",t6[t6.Tangent=3]="Tangent",t6[t6.BoneWeight=4]="BoneWeight",t6[t6.BoneIndex=5]="BoneIndex",t6[t6.UV=6]="UV",t6[t6.UV1=7]="UV1",t6[t6.UV2=8]="UV2",t6[t6.UV3=9]="UV3",t6[t6.UV4=10]="UV4",t6[t6.UV5=11]="UV5",t6[t6.UV6=12]="UV6",t6[t6.UV7=13]="UV7";var uW=(cx(t7=function(e,t){var r;return(r=cL.call(this,e)||this).primitiveInfo=t,r},cL),t7.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:u0._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:u0._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:u0._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:u0._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:u0._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:u0._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:u0._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:u0._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t7);(t9=lL||(lL={}))[t9.Sphere=0]="Sphere",t9[t9.Cuboid=1]="Cuboid",t9[t9.Plane=2]="Plane",t9[t9.Cylinder=3]="Cylinder",t9[t9.Torus=4]="Torus",t9[t9.Cone=5]="Cone",t9[t9.Capsule=6]="Capsule",t9[t9.CCSphere=7]="CCSphere";var uX=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},uK=(cx(re=function(e,t,r,n){var i;return(i=uX.call(this,0,r,n)||this).radius=e,i.segments=t,i},uX),re),uj=(cx(rt=function(e,t,r,n){var i;return(i=uX.call(this,7,r,n)||this).radius=e,i.step=t,i},uX),rt),uY=(cx(rr=function(e,t,r,n,i){var a;return(a=uX.call(this,1,n,i)||this).width=e,a.height=t,a.depth=r,a},uX),rr),uq=(cx(rn=function(e,t,r,n,i,a){var o;return(o=uX.call(this,2,i,a)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},uX),rn),uQ=(cx(ri=function(e,t,r,n,i,a,o){var s;return(s=uX.call(this,3,a,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=i,s},uX),ri),uZ=(cx(ra=function(e,t,r,n,i,a,o){var s;return(s=uX.call(this,4,a,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=i,s},uX),ra),uJ=(cx(ro=function(e,t,r,n,i,a){var o;return(o=uX.call(this,5,i,a)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},uX),ro),u$=(cx(rs=function(e,t,r,n,i,a){var o;return(o=uX.call(this,6,i,a)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},uX),rs),u0=((rl=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var i=new uG(e);rl._setSphereData(i,t,r,n,!1);var a=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(i,new uK(t,r,a,n))),i},rl.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var i=new uG(e);rl._setSubdivisionSurfaceSphereData(i,t,r,n,!1);var a=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(i,new uj(t,r,a,n))),i},rl.createCuboid=function(e,t,r,n,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===i&&(i=!0);var a=new uG(e);rl._setCuboidData(a,t,r,n,i,!1);var o=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(a,new uY(t,r,n,o,i))),a},rl.createPlane=function(e,t,r,n,i,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uG(e);rl._setPlaneData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(o,new uq(t,r,n,i,s,a))),o},rl.createCylinder=function(e,t,r,n,i,a,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===i&&(i=20),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new uG(e);rl._setCylinderData(s,t,r,n,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(s,new uQ(t,r,n,i,a,l,o))),s},rl.createTorus=function(e,t,r,n,i,a,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===i&&(i=30),void 0===a&&(a=360),void 0===o&&(o=!0);var s=new uG(e);rl._setTorusData(s,t,r,n,i,a,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(s,new uZ(t,r,n,i,a,l,o))),s},rl.createCone=function(e,t,r,n,i,a){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uG(e);rl._setConeData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(o,new uJ(t,r,n,i,s,a))),o},rl.createCapsule=function(e,t,r,n,i,a){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new uG(e);rl._setCapsuleData(o,t,r,n,i,a,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new uW(o,new u$(t,r,n,i,s,a))),o},rl._setSubdivisionSurfaceSphereData=function(e,t,r,n,i,a){r=l9.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));rl._subdiveCatmullClark(r,o,s);for(var l=o.length/3,c=s.length/4,u=l+Math.pow(2,r+1)-1,d=u+16,h=new Float32Array(8*d),_=rl._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],S=1/Math.sqrt(v*v+y*y+x*x);if(v*=S,y*=S,x*=S,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 C=8*(l+f++);h.set(h.subarray(g,g+8),C),h[C+6]=1,p[g/8]=C/8}}var T=0;this._spherePoleIdx=0;for(var A=0;A<c;A++){var E=4*A,M=s[E],R=s[E+1],w=s[E+2],b=s[E+3],P=8*M,F=8*R,L=8*w,D=8*b;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(M=p[M]),0===h[F+6]&&(R=p[R]),0===h[L+6]&&(w=p[w]),0===h[D+6]&&(b=p[b])),_[T]=M,_[T+1]=R,_[T+2]=w,this._generateAndReplacePoleUV(_,h,T,u),_[T+3]=M,_[T+4]=w,_[T+5]=b,this._generateAndReplacePoleUV(_,h,T+3,u),T+=6}if(!i){var B=e.bounds;B.min.set(-t,-t,-t),B.max.set(t,t,t)}rl._initialize(e,h,_,n,i,a)},rl._setSphereData=function(e,t,r,n,i,a){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=rl._generateIndices(e.engine,s,6*l),u=Math.PI,d=2*u,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*d,y=g*u,x=Math.sin(y),S=-t*Math.cos(v)*x,C=t*Math.cos(y),T=t*Math.sin(v)*x,A=8*p;f[A++]=S,f[A++]=C,f[A++]=T,f[A++]=S,f[A++]=C,f[A++]=T,f[A++]=m,f[A++]=g}for(var E=0,M=0;M<l;++M){var R=M%r,w=(M*_|0)*o+R,b=w+1,P=w+o,F=P+1;c[E++]=b,c[E++]=w,c[E++]=F,c[E++]=w,c[E++]=P,c[E++]=F}if(!i){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}rl._initialize(e,f,c,n,i,a)},rl._subdiveCatmullClark=function(e,t,r){var n=new Map,i=[];t.set(rl._sphereSeedPositions),r.set(rl._sphereSeedCells);for(var a=0;a<e;a++){var o=6*Math.pow(4,a),s=4*o+2;n.clear(),i.length=0;for(var l=0;l<o;l++){for(var c=i[l]={facePoint:new ce,adjacentEdges:[,,,,]},u=0;u<4;u++){var d=3*r[4*l+u];c.facePoint.x+=.25*t[d],c.facePoint.y+=.25*t[d+1],c.facePoint.z+=.25*t[d+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 ce,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,S=c.facePoint;x.x+=.25*S.x,x.y+=.25*S.y,x.z+=.25*S.z}}var C=o+2,T=C+o,A=0;this._sphereEdgeIdx=0;for(var E=r.slice(0,4*o),M=0;M<o;M++){var R=i[M];R.facePoint.copyToArray(t,3*(C+M));for(var w=C+M,b=void 0,P=void 0,F=void 0,L=0;L<4;L++){var D=E[A++];switch(L){case 0:var B=R.adjacentEdges[L%4],I=R.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,B,T),F=b=this._calculateEdgeIndex(t,I,T);break;case 1:case 2:var V=R.adjacentEdges[L%4];b=P,P=this._calculateEdgeIndex(t,V,T);break;case 3:b=P,P=F}var O=4*(4*M+L);r[O]=D,r[O+1]=P,r[O+2]=w,r[O+3]=b}}}},rl._generateAndReplacePoleUV=function(e,t,r,n){var i=t[8*e[r]+7];if(0===i||1===i){var a=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(a,a+8),o),t[o+6]=.5*(t[a+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},rl._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+rl._sphereEdgeIdx));var n=r+rl._sphereEdgeIdx++;return t.edgePointIndex=n,n},rl._setCuboidData=function(e,t,r,n,i,a,o){var s=t/2,l=r/2,c=n/2,u=new Float32Array(192);u[0]=-s,u[1]=l,u[2]=-c,u[6]=0,u[7]=0,u[8]=s,u[9]=l,u[10]=-c,u[14]=1,u[15]=0,u[16]=s,u[17]=l,u[18]=c,u[22]=1,u[23]=1,u[24]=-s,u[25]=l,u[26]=c,u[30]=0,u[31]=1;for(var d=0;d<4;d++){var h=8*d+3;u[h++]=0,u[h++]=1,u[h++]=0}u[32]=-s,u[33]=-l,u[34]=-c,u[38]=0,u[39]=1,u[40]=s,u[41]=-l,u[42]=-c,u[46]=1,u[47]=1,u[48]=s,u[49]=-l,u[50]=c,u[54]=1,u[55]=0,u[56]=-s,u[57]=-l,u[58]=c,u[62]=0,u[63]=0;for(var _=0;_<4;_++){var f=8*_+35;u[f++]=0,u[f++]=-1,u[f++]=0}u[64]=-s,u[65]=l,u[66]=-c,u[70]=0,u[71]=0,u[72]=-s,u[73]=l,u[74]=c,u[78]=1,u[79]=0,u[80]=-s,u[81]=-l,u[82]=c,u[86]=1,u[87]=1,u[88]=-s,u[89]=-l,u[90]=-c,u[94]=0,u[95]=1;for(var p=0;p<4;p++){var m=8*p+67;u[m++]=-1,u[m++]=0,u[m++]=0}u[96]=s,u[97]=l,u[98]=-c,u[102]=1,u[103]=0,u[104]=s,u[105]=l,u[106]=c,u[110]=0,u[111]=0,u[112]=s,u[113]=-l,u[114]=c,u[118]=0,u[119]=1,u[120]=s,u[121]=-l,u[122]=-c,u[126]=1,u[127]=1;for(var g=0;g<4;g++){var v=8*g+99;u[v++]=1,u[v++]=0,u[v++]=0}u[128]=-s,u[129]=l,u[130]=c,u[134]=0,u[135]=0,u[136]=s,u[137]=l,u[138]=c,u[142]=1,u[143]=0,u[144]=s,u[145]=-l,u[146]=c,u[150]=1,u[151]=1,u[152]=-s,u[153]=-l,u[154]=c,u[158]=0,u[159]=1;for(var y=0;y<4;y++){var x=8*y+131;u[x++]=0,u[x++]=0,u[x++]=1}u[160]=-s,u[161]=l,u[162]=-c,u[166]=1,u[167]=0,u[168]=s,u[169]=l,u[170]=-c,u[174]=0,u[175]=0,u[176]=s,u[177]=-l,u[178]=-c,u[182]=0,u[183]=1,u[184]=-s,u[185]=-l,u[186]=-c,u[190]=1,u[191]=1;for(var S=0;S<4;S++){var C=8*S+163;u[C++]=0,u[C++]=0,u[C++]=-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,!a){var A=e.bounds;A.min.set(-s,-l,-c),A.max.set(s,l,c)}rl._initialize(e,u,T,i,a,o)},rl._setPlaneData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(i=Math.max(1,Math.floor(i)))+1,u=t/2,d=r/2,h=t/n,_=r/i,f=l*c,p=i*n,m=rl._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/i,x=new Float32Array(8*f),S=0;S<f;++S){var C=S%l,T=S*g|0,A=8*S;x[A++]=C*h-u,x[A++]=0,x[A++]=T*_-d,x[A++]=0,x[A++]=1,x[A++]=0,x[A++]=C*v,x[A++]=T*y}for(var E=0,M=0;M<p;++M){var R=M%n,w=(M*v|0)*l+R,b=w+1,P=w+l,F=P+1;m[E++]=w,m[E++]=P,m[E++]=b,m[E++]=P,m[E++]=F,m[E++]=b}if(!o){var L=e.bounds;L.min.set(-u,0,-d),L.max.set(u,0,d)}rl._initialize(e,x,m,a,o,s)},rl._setCylinderData=function(e,t,r,n,i,a,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===i&&(i=20),void 0===a&&(a=1);for(var c=(i=Math.floor(i))+1,u=(a=Math.floor(a))+1,d=.5*n,h=n/a,_=c*u,f=i*a,p=2*i,m=_+2+p,g=rl._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/i,x=1/a,S=new Float32Array(8*m),C=0,T=Math.PI,A=2*Math.PI,E=r-t,M=E/n,R=E/a,w=0;w<_;++w){var b=w%c,P=w*v|0,F=b*y,L=P*x,D=T+F*A,B=Math.sin(D),I=Math.cos(D),V=r-P*R,O=V*B,N=P*h-d,z=V*I,U=8*w;S[U++]=O,S[U++]=N,S[U++]=z,S[U++]=B,S[U++]=M,S[U++]=I,S[U++]=F,S[U++]=1-L}for(var k=0;k<f;++k){var G=k%i,H=(k*y|0)*c+G,W=H+1,X=H+c,K=X+1;g[C++]=W,g[C++]=X,g[C++]=H,g[C++]=W,g[C++]=K,g[C++]=X}var j=8*_;S[j++]=0,S[j++]=-d,S[j++]=0,S[j++]=0,S[j++]=-1,S[j++]=0,S[j++]=.5,S[j++]=.5,S[j++]=0,S[j++]=d,S[j++]=0,S[j++]=0,S[j++]=1,S[j++]=0,S[j++]=.5,S[j++]=.5,j=(_+2)*8;for(var Y=1/(2*t),q=1/(2*r),Q=c*a,Z=0;Z<i;++Z){var J=8*Z,$=S[J],ee=S[J+2];S[j++]=$,S[j++]=-d,S[j++]=ee,S[j++]=0,S[j++]=-1,S[j++]=0,S[j++]=$*q+.5,S[j++]=.5-ee*q;var et=(Z+Q)*8;$=S[et],ee=S[et+2],S[j++]=$,S[j++]=d,S[j++]=ee,S[j++]=0,S[j++]=1,S[j++]=0,S[j++]=$*Y+.5,S[j++]=.5-ee*Y}for(var er=_+1,en=_+2,ei=en+1,ea=0;ea<i;++ea){var eo=2*ea,es=ea===i-1?0:eo+2;g[C++]=_,g[C++]=en+es,g[C++]=en+eo,g[C++]=er,g[C++]=ei+eo,g[C++]=ei+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-d,-ec),el.max.set(ec,d,ec)}rl._initialize(e,S,g,o,s,l)},rl._setTorusData=function(e,t,r,n,i,a,o,s,l){var c=((n=Math.floor(n))+1)*((i=Math.floor(i))+1),u=n*i,d=rl._generateIndices(e.engine,c,6*u),h=new Float32Array(8*c);a=a/180*Math.PI;for(var _=0,f=rl._tempVec30,p=0;p<=n;p++)for(var m=0;m<=i;m++){var g=m/i*a,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),S=Math.sin(g),C=(t+r*y)*x,T=(t+r*y)*S,A=r*Math.sin(v);h[_++]=C,h[_++]=T,h[_++]=A;var E=t*x,M=t*S;f.set(C-E,T-M,A).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/i,h[_++]=p/n}_=0;for(var R=1;R<=n;R++)for(var w=1;w<=i;w++){var b=(i+1)*R+w-1,P=(i+1)*(R-1)+w-1,F=(i+1)*(R-1)+w,L=(i+1)*R+w;d[_++]=b,d[_++]=P,d[_++]=L,d[_++]=P,d[_++]=F,d[_++]=L}if(!s){var D=e.bounds,B=t+r;D.min.set(-B,-B,-r),D.max.set(B,B,r)}rl._initialize(e,h,d,o,s,l)},rl._setConeData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.floor(n))+1,c=(i=Math.floor(i))+1,u=.5*r,d=r/i,h=l*c,_=n*i,f=h+1+n,p=rl._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/i,y=new Float32Array(8*f),x=0,S=Math.PI,C=2*Math.PI,T=t/r,A=0;A<h;++A){var E=A%l,M=A*m|0,R=E*g,w=M*v,b=S+R*C,P=Math.sin(b),F=Math.cos(b),L=t-w*t,D=L*P,B=M*d-u,I=L*F,V=8*A;y[V++]=D,y[V++]=B,y[V++]=I,y[V++]=P,y[V++]=T,y[V++]=F,y[V++]=R,y[V++]=1-w}for(var O=0;O<_;++O){var N=O%n,z=(O*g|0)*l+N,U=z+1,k=z+l,G=k+1;p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=U,p[x++]=G,p[x++]=k}var H=8*h;y[H++]=0,y[H++]=-u,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),X=0;X<n;++X){var K=y[8*X],j=y[8*X+2];y[H++]=K,y[H++]=-u,y[H++]=j,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=K*W+.5,y[H++]=.5-j*W}for(var Y=h+1,q=0;q<n;++q){var Q=q,Z=q===n-1?0:Q+1;p[x++]=h,p[x++]=Y+Z,p[x++]=Y+Q}if(!o){var J=e.bounds;J.min.set(-t,-u,-t),J.max.set(t,u,t)}rl._initialize(e,y,p,a,o,s)},rl._setCapsuleData=function(e,t,r,n,i,a,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(i=Math.floor(i))+1,u=.5*r,d=r/i,h=l*c,_=n*i,f=l*l,p=n*n,m=h+2*f,g=rl._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/i,S=Math.PI,C=2*Math.PI,T=new Float32Array(8*m),A=0,E=0;E<h;++E){var M=E%l,R=E*v|0,w=M*y,b=R*x,P=S+w*C,F=Math.sin(P),L=Math.cos(P),D=8*E;T[D++]=t*F,T[D++]=R*d-u,T[D++]=t*L,T[D++]=F,T[D++]=0,T[D++]=L,T[D++]=w,T[D++]=1-b}for(var B=0;B<_;++B){var I=B%n,V=(B*y|0)*l+I,O=V+1,N=V+l,z=N+1;g[A++]=O,g[A++]=N,g[A++]=V,g[A++]=O,g[A++]=z,g[A++]=N}if(rl._createCapsuleCap(t,r,n,S,C,h,1,T,g,A),rl._createCapsuleCap(t,r,n,S,-C,h+f,-1,T,g,A+6*p),!o){var U=e.bounds;U.min.set(-t,-t-u,-t),U.max.set(t,t+u,t)}rl._initialize(e,T,g,a,o,s)},rl._initialize=function(t,r,n,i,a,o){if(a)o.setData(r),t.setIndices(n),t.uploadData(i);else{var s=[new uP(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new uP(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new uP(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new uF(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(i),t.addSubMesh(0,n.length)}},rl._generateIndices=function(t,r,n){var i=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))i=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else i=new Uint16Array(n);return i},rl._createCapsuleCap=function(e,t,r,n,i,a,o,s,l,c){for(var u=r+1,d=.5*t*o,h=u*u,_=r*r,f=1/u,p=1/r,m=0;m<h;++m){var g=m%u*p,v=(m*f|0)*p,y=n+g*i,x=v*Math.PI*.5,S=Math.sin(x),C=e*Math.sin(y)*S,T=e*Math.cos(x)*o+d,A=e*Math.cos(y)*S,E=(m+a)*8;s[E++]=C,s[E++]=T,s[E++]=A,s[E++]=C,s[E++]=T-d,s[E++]=A,s[E++]=g,s[E++]=v}for(var M=0;M<_;++M){var R=M%r,w=(M*p|0)*u+R+a,b=w+1,P=w+u,F=P+1;l[c++]=b,l[c++]=w,l[c++]=F,l[c++]=w,l[c++]=P,l[c++]=F}},rl);u0._tempVec30=new ce,u0._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]),u0._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]),u0._sphereEdgeIdx=0,u0._spherePoleIdx=0;var u1=(cx(rc=function(e){var t;return(t=cP.call(this,null)||this).name=e,t._bones=[],t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},cP),rc),u2=(cx(ru=function(e){(t=uU.call(this,e)||this)._localBounds=new cr,t._jointDataCreateCache=new cu(-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(cm(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},uU),(rd=ru.prototype).update=function(){var e=this._skin,t=this._bones;if(e&&t)for(var r,n=this._jointMatrices,i=e.inverseBindMatrices,a=(null!=(r=this._rootBone)?r:this.entity).getInvModelMatrix(),o=t.length-1;o>=0;o--){var s=t[o],l=16*o;s?c2._floatMatrixMultiply(s.transform.worldMatrix,i[o].elements,0,n,l):n.set(i[o].elements,l),c2._floatMatrixMultiply(a,n,l,n,l)}},rd._updateShaderData=function(t){var r=this.entity,n=(null!=(d=this._rootBone)?d:r).transform.worldMatrix;this._updateTransformShaderData(t,n);var i=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(i,this);var o=this._bones;if(o){var s=a._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h,_=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>_){var f,p=this.engine;p._hardwareRenderer.canIUseMoreJoints?(u&&(null==(f=this._jointTexture)||f.destroy(),this._jointTexture=new cG(p,4,l,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(ru._jointSamplerProperty,this._jointTexture)):cz.error("component's joints count("+l+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+_+".",this)}else null==(h=this._jointTexture)||h.destroy(),i.disableMacro("RENDERER_USE_JOINT_TEXTURE"),i.enableMacro("RENDERER_JOINTS_NUM",_.toString()),i.setFloatArray(ru._jointMatrixProperty,this._jointMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var m=r.layer;this._rendererLayer.set(65535&m,m>>>16&65535,0,0)},rd._onDestroy=function(){var e;uU.prototype._onDestroy.call(this),this._rootBone=null,this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,this._jointMatrices=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null,this._bones=null},rd._cloneTo=function(e,t,r){uU.prototype._cloneTo.call(this,e,t,r);var n=[];if(this.rootBone){var i=this._getEntityHierarchyPath(t,this.rootBone,n);e.rootBone=i?this._getEntityByHierarchyPath(r,n):this.rootBone}var a=this._bones;if(a){for(var o=a.length,s=Array(o),l=0;l<o;l++){var c=a[l],u=this._getEntityHierarchyPath(t,c,n);s[l]=u?this._getEntityByHierarchyPath(r,n):c}e.bones=s}this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},rd._registerEntityTransformListener=function(){var e;(null!=(e=this._rootBone)?e:this._entity).transform._updateFlagManager.addListener(this._onTransformChanged)},rd._unRegisterEntityTransformListener=function(){var e;(null!=(e=this._rootBone)?e:this._entity).transform._updateFlagManager.removeListener(this._onTransformChanged)},rd._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,r=this._rootBone.transform.worldMatrix;cr.transform(t,r,e)}else uU.prototype._updateBounds.call(this,e)},rd._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var i=new Float32Array(t);if(t>n)i.set(r);else for(var a=0;a<t;a++)i[a]=r[a];this._blendShapeWeights=i}}else this._blendShapeWeights=new Float32Array(t)},rd._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=lA.WorldVolume},rd._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},rd._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},cv(ru,[{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._rootBone},set:function(e){this._rootBone!==e&&(this._unRegisterEntityTransformListener(),this._rootBone=e,this._registerEntityTransformListener(),this._dirtyUpdateFlag|=lA.WorldVolume)}},{key:"bones",get:function(){return this._bones},set:function(e){if(this._bones!==e){var t,r,n,i=null!=(r=null==(t=this._bones)?void 0:t.length)?r:0,a=null!=(n=null==e?void 0:e.length)?n:0;if(i!==a){var o=this.shaderData;a>0?(this._jointMatrices=new Float32Array(16*a),o.enableMacro("RENDERER_HAS_SKIN"),o.setInt(ru._jointCountProperty,a)):(this._jointMatrices=null,o.disableMacro("RENDERER_HAS_SKIN"))}this._bones=e}}},{key:"skin",get:function(){return this._skin},set:function(e){this._skin=e}}]),ru);u2._jointCountProperty=cQ.getByName("renderer_JointCount"),u2._jointSamplerProperty=cQ.getByName("renderer_JointSampler"),u2._jointMatrixProperty=cQ.getByName("renderer_JointMatrix"),cT([cw],u2.prototype,"_localBounds",void 0),cT([cE],u2.prototype,"_jointDataCreateCache",void 0),cT([cE],u2.prototype,"_blendShapeWeights",void 0),cT([cE],u2.prototype,"_maxVertexUniformVectors",void 0),cT([cE],u2.prototype,"_rootBone",void 0),cT([cE],u2.prototype,"_jointMatrices",void 0),cT([cE],u2.prototype,"_jointTexture",void 0),cT([cE],u2.prototype,"_bones",void 0),cT([cE],u2.prototype,"_condensedBlendShapeWeights",void 0),cT([cE],u2.prototype,"_onLocalBoundsChanged",null);var u3=((r_=(rh=function(e){this._subMeshPool=new ut(uD),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,i=t.engine._renderElementPool,a=0,o=n.length;a<o;++a){var s=i.getFromPool();s.set(n[a],e.shaderPasses),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},r_._initMeshes=function(e){var t=rh.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var r=this._meshes,n=this._meshCount,i=0;i<n;i++)r[i]=this._createMesh(e,i)},r_.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rh._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},r_.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},r_.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,i=e.length;n<i;++n){var a=e[n];a._addReferCount(-1),a.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},r_._drawSubElement=function(e,t){var r=e.data.verticesData.vertexCount;this._vertexCount+r>rh.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=r,this._batchedQueue[this._elementCount++]=e},r_._createMesh=function(t,r){var n=rh.MAX_VERTEX_COUNT,i=new uz(t,"BufferMesh"+r);i._addReferCount(1);var a=[],o=this.createVertexElements(a),s=this._vertexBuffers[r]=new uF(t,e.BufferBindFlag.VertexBuffer,n*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[r]=new uF(t,e.BufferBindFlag.IndexBuffer,6*n,e.BufferUsage.Dynamic);return l.isGCIgnored=!0,i.setVertexBufferBinding(s,o),i.setIndexBufferBinding(l,e.IndexFormat.UInt16),i.setVertexElements(a),i},r_._updateData=function(t){var r=this._meshes,n=this._flushId;!rh._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,r[n]=this._createMesh(t,n));var i=this._batchedQueue,a=this._vertices,o=this._indices,s=r[n];s.clearSubMesh();for(var l=0,c=0,u=0,d=0,h=0,_=0,f=null,p=0,m=i.length;p<m;p++){var g=i[p],v=g.data;l=this.updateVertices(v,a,l);for(var y=v.verticesData.triangles,x=y.length,S=0;S<x;S++)o[c++]=y[S]+h;h+=v.verticesData.vertexCount,null===f?d+=x:this.canBatch(f,g)?d+=x:(s.addSubMesh(this._getSubMeshFromPool(u,d)),u+=d,d=x,i[_++]=f),f=g}s.addSubMesh(this._getSubMeshFromPool(u,d)),i[_]=f,this._vertexBuffers[n].setData(a,0,0,l,e.SetDataOptions.Discard),this._indiceBuffers[n].setData(o,0,0,c,e.SetDataOptions.Discard)},r_._getSubMeshFromPool=function(t,r){var n=this._subMeshPool.getFromPool();return n.start=t,n.count=r,n.topology=e.MeshTopology.Triangles,n},rh);u3._disableBatchTag=us.getByName("spriteDisableBatching"),u3.MAX_VERTEX_COUNT=4096,u3._canUploadSameBuffer=!0;var u4=(cx(rf=function(){return u3.apply(this,arguments)},u3),(rp=rf.prototype).createVertexElements=function(t){return t[0]=new uP("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new uP("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},rp.canBatch=function(e,t){var r=e.data,n=t.data;if(r.isAdd!==n.isAdd)return!1;var i=r.component.shaderData,a=n.component.shaderData,o=uw._textureProperty,s=uw._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},rp.updateVertices=function(e,t,r){for(var n=e.verticesData,i=n.positions,a=n.uvs,o=n.vertexCount,s=0;s<o;s++){var l=i[s],c=a[s];t[r++]=l.x,t[r++]=l.y,t[r++]=l.z,t[r++]=c.x,t[r++]=c.y}return r},rp.drawBatches=function(t){for(var r=this._engine,n=this._batchedQueue,i=this._meshes[this._flushId],a=i.subMeshes,o=i._primitive,s=t.scene.shaderData,l=t.shaderData,c=0,u=a.length;c<u;c++){var d=a[c],h=n[c],_=h.data;if(!d||!h)return;var f=_.component,p=_.material,m=ux._compileMacros;un.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,d,x)}},rf),u5=((rg=(rm=function(e){this._preMaskLayer=0,this._batcher=new u4(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rg.preRender=function(t,r){r.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,r),this._batcher.flush(t))},rg.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rg.destroy=function(){this._batcher.destroy(),this._batcher=null},rg._processMasksDiff=function(e,t){var r=this._preMaskLayer,n=t.maskLayer;if(r!==n)for(var i=e._renderPipeline._allSpriteMasks,a=r&n,o=n&~r,s=r&~n,l=i._elements,c=0,u=i.length;c<u;c++){var d=l[c],h=d.influenceLayers;if(!(h&a)){if(h&o){var _=d._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(h&s){var f=d._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},rm),u8=(cx(rv=function(){var e;return(e=uT.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},uT),(ry=rv.prototype).set=function(e,t,r){this.component=e,this.material=t,this.verticesData=r},ry.dispose=function(){this.component=this.material=this.verticesData=null},rv),u6=(cx(rx=function(){var e;return(e=uT.call(this)||this).multiRenderData=!1,e},uT),(rS=rx.prototype).set=function(e,t,r,n,i){void 0===i&&(i=0),this.component=e,this.material=t,this.verticesData=r,this.texture=n,this.dataIndex=i},rS.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rx),u7=(cx(rC=function(){var e;return(e=uT.call(this)||this).charsData=[],e.multiRenderData=!0,e},uT),rC.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},rC);e.AssetType=void 0,(rT=e.AssetType||(e.AssetType={})).Text="Text",rT.JSON="JSON",rT.Buffer="Buffer",rT.Texture2D="Texture2D",rT.TextureCube="TextureCube",rT.Material="Material",rT.Mesh="Mesh",rT.AnimationClip="AnimationClip",rT.AnimatorController="AnimatorController",rT.GLTF="GLTF",rT.KTX="KTX",rT.KTXCube="KTXCube",rT.KTX2="KTX2",rT.Sprite="Sprite",rT.SpriteAtlas="SpriteAtlas",rT.Env="Environment",rT.Scene="Scene",rT.HDR="HDR",rT.Font="Font",rT.SourceFont="SourceFont",rT.Project="project";var u9=((rE=(rA=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},rE.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},rE.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},rE.indexOf=function(e){return this._array.indexOf(e)},rE.getArray=function(){return this._array},rE.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},cv(rA,[{key:"length",get:function(){return this._array.length}}]),rA),de=((rR=(rM=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new u9}).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 i=n.indexOf(t);i!==r&&(n.removeByIndex(i),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},rR.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)}},rR.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,i=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return i.then(function(e){if(r)for(var t=n._scenes.getArray(),i=0,a=t.length;i<a;i++)t[i].destroy();n.addScene(e)}),i},rR.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},rR._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},cv(rM,[{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)}}]),rM),dt=((rb=(rw=function(e){var t=this;this._state="pending",this._progress=0,this._onProgressCallback=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(t._progress=e,t._onProgressCallback.forEach(function(t){return t(e)}))},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e){return this._progress&&e(this._progress),"pending"===this._state&&this._onProgressCallback.push(e),this},rb.then=function(e,t){var r=this;return new rw(function(n,i){r._promise.then(e,t).then(n).catch(i)})},rb.catch=function(e){var t=this;return new rw(function(r,n){t._promise.catch(e).then(r).catch(n)})},rb.finally=function(e){return this._promise.finally(e)},rb.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},rw.all=function(e){return new rw(function(t,r,n){var i=function(e,r){l++,s[e]=r,n(l/o),l===o&&t(s)},a=function(e,t){cA(e,Promise)||cA(e,rw)?e.then(function(e){i(t,e)},r):Promise.resolve().then(function(){i(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)a(e[c],c)})},cv(rw,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),rw);(rP=lD||(lD={})).Pending="pending",rP.Fulfilled="fulfilled",rP.Rejected="rejected",rP.Canceled="canceled";var dr=((rL=(rF=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,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 dt.all(r)},rL.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},rL.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var i=r[n];cA(i,e)&&t.push(i)}return t},rL.getAssetPath=function(e){return this._assetPool[e]},rL.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()}):c2.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},rL.gc=function(){this._gc(!1),this.engine._pendingGC()},rL.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},rL._onSubAssetSuccess=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.resolve(t),delete this._subAssetPromiseCallbacks[e]},rL._onSubAssetFail=function(e,t){var r;null==(r=this._subAssetPromiseCallbacks[e])||r.reject(t),delete this._subAssetPromiseCallbacks[e]},rL._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},rL._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},rL._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},rL._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},rL._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},rL._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},rL._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},rL._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},rL._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},rL._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)},rL._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},rL._assignDefaultOptions=function(e){var t,r,n,i,a;if(e.type=null!=(t=e.type)?t:rF._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!=(i=e.retryInterval)?i:this.retryInterval,e.url=null!=(a=e.url)?a:e.urls.join(","),e},rL._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),i=n.url,a=this._virtualPathMap[i]?this._virtualPathMap[i]:i,o=this._parseURL(a),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=this._assetUrlPool[s];if(u)return new dt(function(e,t,n){n(1),e(r._getResolveResource(u,c))});var d=s;if(l)for(d+="?q="+c.shift();t=c.shift();)d+="["+t+"]";var h=this._loadingPromises,_=h[d];if(_)return new dt(function(e,t,r){_.onProgress(function(e){r(e)}).then(function(t){e(t)}).catch(function(e){t(e)})});var f=rF._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 dt(function(e,t){r._pushSubAssetPromiseCallback(d,e,t)});return h[d]=m,m.then(function(){delete h[d]},function(){return delete h[d]}),p.catch(function(e){r._onSubAssetFail(d,e)}),m}return p},rL._pushSubAssetPromiseCallback=function(e,t,r){this._subAssetPromiseCallbacks[e]={resolve:t,reject:r}},rL._gc=function(e){for(var t=c2.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++)(!t[r].isGCIgnored||e)&&t[r].destroy(e)},rL._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,i=t.length;n<i;n++)r=r[t[n]];return r},rL._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],i=void 0,a=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){i=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}a=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:a,queryPath:i}},rL._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===di&&t.push(""),e.replace(ds,function(e,r,n,i){var a=e;n?a=i.replace(da,"$1"):r&&(a=r.trim()),t.push(a)}),t},rL.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,i=this._objectPool[t];if(i)a=Promise.resolve(i);else{var a,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return cz.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,a=this.load({url:s,type:this._editorResourceConfig[t].type})}return a.then(function(e){return n?e.clone():e})},rL.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},rF._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,i=r.length;n<i;n++)this._extTypeMapping[r[n].toLowerCase()]=e},rF._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},rF);function dn(e,t,r){return void 0===r&&(r=!0),function(n){var i=new n(r);dr._addLoader(e,i,t)}}dr._loaders={},dr._extTypeMapping={};var di=46,da=/\\(\\)?/g,ds=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(rD=e.PointerPhase||(e.PointerPhase={}))[rD.Down=0]="Down",rD[rD.Move=1]="Move",rD[rD.Stationary=2]="Stationary",rD[rD.Up=3]="Up",rD[rD.Leave=4]="Leave";var dl=((rI=(rB=function(t){this.phase=e.PointerPhase.Leave,this.position=new cu,this.deltaPosition=new cu,this._events=[],this._upMap=[],this._downMap=[],this._upList=new c1,this._downList=new c1,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)},rI._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},rI._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},rI._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}},rB);e.PointerButton=void 0,(rV=e.PointerButton||(e.PointerButton={}))[rV.None=0]="None",rV[rV.Primary=1]="Primary",rV[rV.Secondary=2]="Secondary",rV[rV.Auxiliary=4]="Auxiliary",rV[rV.XButton1=8]="XButton1",rV[rV.XButton2=16]="XButton2",rV[rV.XButton3=32]="XButton3",rV[rV.XButton4=64]="XButton4",rV[rV.XButton5=128]="XButton5",rV[rV.XButton6=256]="XButton6",rV[rV.XButton7=512]="XButton7",rV[rV.XButton8=1024]="XButton8";var dc=[1,4,2,8,16,32,64,128,256,512,1024],du={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},dd=((rO=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?rO.platform=e.Platform.IPhone:/iPad/i.test(r)?rO.platform=e.Platform.IPad:/Android/i.test(r)?rO.platform=e.Platform.Android:/Macintosh/i.test(r)&&(rO.platform=e.Platform.Mac),rO.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"}}},cv(rO,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),rO);dd.platform=e.Platform.Unknown,dd.operatingSystem="",dd._initialize(),e.Keys=void 0,(rN=e.Keys||(e.Keys={}))[rN.Backquote=0]="Backquote",rN[rN.Backslash=1]="Backslash",rN[rN.Backspace=2]="Backspace",rN[rN.BracketLeft=3]="BracketLeft",rN[rN.BracketRight=4]="BracketRight",rN[rN.Comma=5]="Comma",rN[rN.Digit0=6]="Digit0",rN[rN.Digit1=7]="Digit1",rN[rN.Digit2=8]="Digit2",rN[rN.Digit3=9]="Digit3",rN[rN.Digit4=10]="Digit4",rN[rN.Digit5=11]="Digit5",rN[rN.Digit6=12]="Digit6",rN[rN.Digit7=13]="Digit7",rN[rN.Digit8=14]="Digit8",rN[rN.Digit9=15]="Digit9",rN[rN.Equal=16]="Equal",rN[rN.IntlBackslash=17]="IntlBackslash",rN[rN.IntlRo=18]="IntlRo",rN[rN.IntlYen=19]="IntlYen",rN[rN.KeyA=20]="KeyA",rN[rN.KeyB=21]="KeyB",rN[rN.KeyC=22]="KeyC",rN[rN.KeyD=23]="KeyD",rN[rN.KeyE=24]="KeyE",rN[rN.KeyF=25]="KeyF",rN[rN.KeyG=26]="KeyG",rN[rN.KeyH=27]="KeyH",rN[rN.KeyI=28]="KeyI",rN[rN.KeyJ=29]="KeyJ",rN[rN.KeyK=30]="KeyK",rN[rN.KeyL=31]="KeyL",rN[rN.KeyM=32]="KeyM",rN[rN.KeyN=33]="KeyN",rN[rN.KeyO=34]="KeyO",rN[rN.KeyP=35]="KeyP",rN[rN.KeyQ=36]="KeyQ",rN[rN.KeyR=37]="KeyR",rN[rN.KeyS=38]="KeyS",rN[rN.KeyT=39]="KeyT",rN[rN.KeyU=40]="KeyU",rN[rN.KeyV=41]="KeyV",rN[rN.KeyW=42]="KeyW",rN[rN.KeyX=43]="KeyX",rN[rN.KeyY=44]="KeyY",rN[rN.KeyZ=45]="KeyZ",rN[rN.Minus=46]="Minus",rN[rN.Period=47]="Period",rN[rN.Quote=48]="Quote",rN[rN.Semicolon=49]="Semicolon",rN[rN.Slash=50]="Slash",rN[rN.AltLeft=51]="AltLeft",rN[rN.AltRight=52]="AltRight",rN[rN.CapsLock=53]="CapsLock",rN[rN.ContextMenu=54]="ContextMenu",rN[rN.ControlLeft=55]="ControlLeft",rN[rN.ControlRight=56]="ControlRight",rN[rN.Enter=57]="Enter",rN[rN.MetaLeft=58]="MetaLeft",rN[rN.MetaRight=59]="MetaRight",rN[rN.ShiftLeft=60]="ShiftLeft",rN[rN.ShiftRight=61]="ShiftRight",rN[rN.Space=62]="Space",rN[rN.Tab=63]="Tab",rN[rN.Convert=64]="Convert",rN[rN.KanaMode=65]="KanaMode",rN[rN.Lang1=66]="Lang1",rN[rN.Lang2=67]="Lang2",rN[rN.Lang3=68]="Lang3",rN[rN.Lang4=69]="Lang4",rN[rN.Lang5=70]="Lang5",rN[rN.NonConvert=71]="NonConvert",rN[rN.Delete=72]="Delete",rN[rN.End=73]="End",rN[rN.Help=74]="Help",rN[rN.Home=75]="Home",rN[rN.Insert=76]="Insert",rN[rN.PageDown=77]="PageDown",rN[rN.PageUp=78]="PageUp",rN[rN.ArrowDown=79]="ArrowDown",rN[rN.ArrowLeft=80]="ArrowLeft",rN[rN.ArrowRight=81]="ArrowRight",rN[rN.ArrowUp=82]="ArrowUp",rN[rN.NumLock=83]="NumLock",rN[rN.Numpad0=84]="Numpad0",rN[rN.Numpad1=85]="Numpad1",rN[rN.Numpad2=86]="Numpad2",rN[rN.Numpad3=87]="Numpad3",rN[rN.Numpad4=88]="Numpad4",rN[rN.Numpad5=89]="Numpad5",rN[rN.Numpad6=90]="Numpad6",rN[rN.Numpad7=91]="Numpad7",rN[rN.Numpad8=92]="Numpad8",rN[rN.Numpad9=93]="Numpad9",rN[rN.NumpadAdd=94]="NumpadAdd",rN[rN.NumpadBackspace=95]="NumpadBackspace",rN[rN.NumpadClear=96]="NumpadClear",rN[rN.NumpadClearEntry=97]="NumpadClearEntry",rN[rN.NumpadComma=98]="NumpadComma",rN[rN.NumpadDecimal=99]="NumpadDecimal",rN[rN.NumpadDivide=100]="NumpadDivide",rN[rN.NumpadEnter=101]="NumpadEnter",rN[rN.NumpadEqual=102]="NumpadEqual",rN[rN.NumpadHash=103]="NumpadHash",rN[rN.NumpadMemoryAdd=104]="NumpadMemoryAdd",rN[rN.NumpadMemoryClear=105]="NumpadMemoryClear",rN[rN.NumpadMemoryRecall=106]="NumpadMemoryRecall",rN[rN.NumpadMemoryStore=107]="NumpadMemoryStore",rN[rN.NumpadMemorySubtract=108]="NumpadMemorySubtract",rN[rN.NumpadMultiply=109]="NumpadMultiply",rN[rN.NumpadParenLeft=110]="NumpadParenLeft",rN[rN.NumpadParenRight=111]="NumpadParenRight",rN[rN.NumpadStar=112]="NumpadStar",rN[rN.NumpadSubtract=113]="NumpadSubtract",rN[rN.Escape=114]="Escape",rN[rN.F1=115]="F1",rN[rN.F2=116]="F2",rN[rN.F3=117]="F3",rN[rN.F4=118]="F4",rN[rN.F5=119]="F5",rN[rN.F6=120]="F6",rN[rN.F7=121]="F7",rN[rN.F8=122]="F8",rN[rN.F9=123]="F9",rN[rN.F10=124]="F10",rN[rN.F11=125]="F11",rN[rN.F12=126]="F12",rN[rN.F13=127]="F13",rN[rN.F14=128]="F14",rN[rN.F15=129]="F15",rN[rN.Fn=130]="Fn",rN[rN.FnLock=131]="FnLock",rN[rN.PrintScreen=132]="PrintScreen",rN[rN.ScrollLock=133]="ScrollLock",rN[rN.Pause=134]="Pause",rN[rN.BrowserBack=135]="BrowserBack",rN[rN.BrowserFavorites=136]="BrowserFavorites",rN[rN.BrowserForward=137]="BrowserForward",rN[rN.BrowserHome=138]="BrowserHome",rN[rN.BrowserRefresh=139]="BrowserRefresh",rN[rN.BrowserSearch=140]="BrowserSearch",rN[rN.BrowserStop=141]="BrowserStop",rN[rN.Eject=142]="Eject",rN[rN.LaunchApp1=143]="LaunchApp1",rN[rN.LaunchApp2=144]="LaunchApp2",rN[rN.LaunchMail=145]="LaunchMail",rN[rN.MediaPlayPause=146]="MediaPlayPause",rN[rN.MediaSelect=147]="MediaSelect",rN[rN.MediaStop=148]="MediaStop",rN[rN.MediaTrackNext=149]="MediaTrackNext",rN[rN.MediaTrackPrevious=150]="MediaTrackPrevious",rN[rN.Power=151]="Power",rN[rN.Sleep=152]="Sleep",rN[rN.AudioVolumeDown=153]="AudioVolumeDown",rN[rN.AudioVolumeMute=154]="AudioVolumeMute",rN[rN.AudioVolumeUp=155]="AudioVolumeUp",rN[rN.WakeUp=156]="WakeUp",rN[rN.Hyper=157]="Hyper",rN[rN.Super=158]="Super",rN[rN.Turbo=159]="Turbo",rN[rN.Abort=160]="Abort",rN[rN.Resume=161]="Resume",rN[rN.Suspend=162]="Suspend",rN[rN.Again=163]="Again",rN[rN.Copy=164]="Copy",rN[rN.Cut=165]="Cut",rN[rN.Find=166]="Find",rN[rN.Open=167]="Open",rN[rN.Paste=168]="Paste",rN[rN.Props=169]="Props",rN[rN.Select=170]="Select",rN[rN.Undo=171]="Undo",rN[rN.Hiragana=172]="Hiragana",rN[rN.Katakana=173]="Katakana",rN[rN.Unidentified=174]="Unidentified";var dh=((rU=(rz=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new c1,this._curFrameDownList=new c1,this._curFrameUpList=new c1,this._nativeEvents=[],this._hadListener=!1;var t=e._canvas._webCanvas;this._engine=e,this._htmlCanvas=t,t.tabIndex=t.tabIndex,this._onKeyEvent=this._onKeyEvent.bind(this),t.addEventListener("keydown",this._onKeyEvent),t.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0}).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 i=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,u=t.length;c<u;c++){var d=t[c],h=e.Keys[d.code];switch(d.type){case"keydown":null==a[h]&&(r.add(h),o.add(h),a[h]=o.length-1,s[h]=i);break;case"keyup":var _=a[h];if(null!=_){a[h]=null;var f=o.deleteByIndex(_);f&&(a[f]=_)}if(n.add(h),l[h]=i,dd.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)a[o.get(p)]=null;o.length=0}}}t.length=0}},rU._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},rU._onBlur=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0,this._hadListener=!1)},rU._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),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._htmlCanvas=null,this._engine=null},rU._onKeyEvent=function(e){this._nativeEvents.push(e)},rz);e.CameraClearFlags=void 0,(rk=e.CameraClearFlags||(e.CameraClearFlags={}))[rk.None=0]="None",rk[rk.Color=1]="Color",rk[rk.Depth=2]="Depth",rk[rk.Stencil=4]="Stencil",rk[rk.ColorDepth=3]="ColorDepth",rk[rk.ColorStencil=5]="ColorStencil",rk[rk.DepthStencil=6]="DepthStencil",rk[rk.All=7]="All",e.Collider=(cx(rG=function(e){var t;return(t=cJ.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},cJ),(rH=rG.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))},rH.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))},rH.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},rH._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}},rH._onLateUpdate=function(){},rH._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])},rH._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])},rH._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},rH._onDestroy=function(){cJ.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},rH._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},cv(rG,[{key:"shapes",get:function(){return this._shapes}}]),rG),cT([cE],e.Collider.prototype,"_index",void 0),cT([cE],e.Collider.prototype,"_nativeCollider",void 0),cT([cE],e.Collider.prototype,"_updateFlag",void 0),cT([cw],e.Collider.prototype,"_shapes",void 0),e.Collider=cT([c0(c7,e.DependentMode.CheckOnly)],e.Collider);var d_=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new c1,this._gravity=new ce(0,-9.81,0),this._onContactEnter=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var i=r._scene.engine._physicalObjectsMap,a=i[e],o=i[n];a.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=a,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,i=n[e],a=n[t];i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},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,i){var a,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(a=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(a=n),i&&(a=i);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var i=o._scene.engine._physicalObjectsMap[e];a.entity=i._collider.entity,a.shape=i,a.distance=t,a.normal.copyFrom(n),a.point.copyFrom(r)})||(a.entity=null,a.shape=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,i=this._restTime+e,a=Math.floor(i/t);this._restTime=i-a*t;for(var o=0;o<a;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)},cv(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,l9.zeroTolerance)}}]),t}();d_._collision=new function(){},e.ControllerNonWalkableMode=void 0,(rW=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[rW.PreventClimbing=0]="PreventClimbing",rW[rW.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var df=(rX=e.Collider,cx(rK=function(t){var r;return(r=rX.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new ce(0,1,0),r._slopeLimit=.707,r._nativeCollider=d_._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(cm(r)),r._upDirection._onValueChanged=r._setUpDirection,r},rX),(rj=rK.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},rj.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";rX.prototype.addShape.call(this,e),this._updateFlag.flag=!0},rj.clearShapes=function(){this._shapes.length>0&&rX.prototype.removeShape.call(this,this._shapes[0])},rj._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,i=t.length;n<i;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},rj._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},rj._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])},rj._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])},rj._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},cv(rK,[{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))}}]),rK),dp=(rY=e.Collider,cx(rq=function(e){(t=rY.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new ce,t._angularVelocity=new ce,t._mass=1,t._centerOfMass=new ce,t._inertiaTensor=new ce(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=d_._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(cm(t)),t._setAngularVelocity=t._setAngularVelocity.bind(cm(t)),t._setCenterOfMass=t._setCenterOfMass.bind(cm(t)),t._setInertiaTensor=t._setInertiaTensor.bind(cm(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},rY),(rQ=rq.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},rQ.applyTorque=function(e){this._nativeCollider.addTorque(e)},rQ.move=function(e,t){this._nativeCollider.move(e,t)},rQ.sleep=function(){this._nativeCollider.sleep()},rQ.wakeUp=function(){this._nativeCollider.wakeUp()},rQ._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},rQ._cloneTo=function(e){rY.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},rQ._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},rQ._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},rQ._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},rQ._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},cv(rq,[{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))}}]),rq);cT([cE],dp.prototype,"_linearDamping",void 0),cT([cE],dp.prototype,"_angularDamping",void 0),cT([cE],dp.prototype,"_linearVelocity",void 0),cT([cE],dp.prototype,"_angularVelocity",void 0),cT([cE],dp.prototype,"_mass",void 0),cT([cE],dp.prototype,"_centerOfMass",void 0),cT([cE],dp.prototype,"_inertiaTensor",void 0),cT([cE],dp.prototype,"_maxAngularVelocity",void 0),cT([cE],dp.prototype,"_maxDepenetrationVelocity",void 0),cT([cE],dp.prototype,"_solverIterations",void 0),cT([cE],dp.prototype,"_isKinematic",void 0),cT([cE],dp.prototype,"_constraints",void 0),cT([cE],dp.prototype,"_collisionDetectionMode",void 0),cT([cE],dp.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(rZ=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[rZ.Discrete=0]="Discrete",rZ[rZ.Continuous=1]="Continuous",rZ[rZ.ContinuousDynamic=2]="ContinuousDynamic",rZ[rZ.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(rJ=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[rJ.None=0]="None",rJ[rJ.FreezePositionX=1]="FreezePositionX",rJ[rJ.FreezePositionY=2]="FreezePositionY",rJ[rJ.FreezePositionZ=4]="FreezePositionZ",rJ[rJ.FreezeRotationX=8]="FreezeRotationX",rJ[rJ.FreezeRotationY=16]="FreezeRotationY",rJ[rJ.FreezeRotationZ=32]="FreezeRotationZ";var dm=function(){this.entity=null,this.distance=0,this.point=new ce,this.normal=new ce,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(r$=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[r$.Average=0]="Average",r$[r$.Minimum=1]="Minimum",r$[r$.Multiply=2]="Multiply",r$[r$.Maximum=3]="Maximum";var dg=((r0=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=d_._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},cv(r0,[{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))}}]),r0),dv=(r1=e.Collider,cx(r2=function(e){var t,r=(t=r1.call(this,e)||this).entity.transform;return t._nativeCollider=d_._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},r1),r2);e.ColliderShapeUpAxis=void 0,(r3=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[r3.X=0]="X",r3[r3.Y=1]="Y",r3[r3.Z=2]="Z",e.ControllerCollisionFlag=void 0,(r4=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[r4.Sides=1]="Sides",r4[r4.Up=2]="Up",r4[r4.Down=4]="Down",e.Joint=(cx(r5=function(e){var t;return(t=cJ.call(this,e)||this)._colliderInfo=new dy,t._connectedColliderInfo=new dy,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new ce,t},cJ),r5.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},cv(r5,[{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))}}]),r5),cT([cE],e.Joint.prototype,"_colliderInfo",void 0),cT([cE],e.Joint.prototype,"_connectedColliderInfo",void 0),cT([cE],e.Joint.prototype,"_nativeJoint",void 0),cT([cE],e.Joint.prototype,"_force",void 0),cT([cE],e.Joint.prototype,"_torque",void 0),e.Joint=cT([c0(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var dy=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},dx=(r8=e.Joint,cx(r6=function(){return r8.apply(this,arguments)},r8),r6.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=d_._nativePhysics.createFixedJoint(t.collider._nativeCollider)},r6);(r7=lB||(lB={}))[r7.None=0]="None",r7[r7.LimitEnabled=1]="LimitEnabled",r7[r7.DriveEnabled=2]="DriveEnabled",r7[r7.DriveFreeSpin=4]="DriveFreeSpin";var dS=(r9=e.Joint,cx(ne=function(){var e;return e=r9.apply(this,arguments)||this,e._axis=new ce(1,0,0),e._hingeFlags=lB.None,e._useSpring=!1,e},r9),(nt=ne.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new ce,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=d_._nativePhysics.createHingeJoint(t.collider._nativeCollider)},nt._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},cv(ne,[{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&lB.LimitEnabled)==lB.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=lB.LimitEnabled:this._hingeFlags&=~lB.LimitEnabled,this._nativeJoint.setHingeJointFlag(lB.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&lB.DriveEnabled)==lB.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=lB.DriveEnabled:this._hingeFlags&=~lB.DriveEnabled,this._nativeJoint.setHingeJointFlag(lB.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(lB.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))}}]),ne);cT([cE],dS.prototype,"_axis",void 0),cT([cE],dS.prototype,"_hingeFlags",void 0),cT([cE],dS.prototype,"_useSpring",void 0),cT([cE],dS.prototype,"_jointMonitor",void 0),cT([cE],dS.prototype,"_limits",void 0);var dC=(nr=e.Joint,cx(nn=function(){var e;return e=nr.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},nr),(ni=nn.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new ce,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=d_._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},cv(nn,[{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))}}]),nn),dT=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},dA=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},dE=function(){function e(){this._isTrigger=!1,this._rotation=new ce,this._position=new ce,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new dg,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)},cv(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}();dE._idGenerator=0,cT([cE],dE.prototype,"_collider",void 0),cT([cE],dE.prototype,"_nativeShape",void 0),cT([cE],dE.prototype,"_id",void 0),cT([cE],dE.prototype,"_material",void 0),cT([cE],dE.prototype,"_isTrigger",void 0),cT([cE],dE.prototype,"_rotation",void 0),cT([cE],dE.prototype,"_position",void 0),cT([cE],dE.prototype,"_contactOffset",void 0);var dM=(cx(na=function(){var e;return(e=dE.call(this)||this)._size=new ce(1,1,1),e._nativeShape=d_._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(cm(e)),e._size._onValueChanged=e._setSize,e},dE),(no=na.prototype)._cloneTo=function(e){dE.prototype._cloneTo.call(this,e),e.size=this.size},no._setSize=function(){this._nativeShape.setSize(this._size)},cv(na,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),na);cT([cE],dM.prototype,"_size",void 0);var dR=(cx(ns=function(){var e;return(e=dE.call(this)||this)._radius=1,e._nativeShape=d_._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},dE),ns.prototype._cloneTo=function(e){dE.prototype._cloneTo.call(this,e),e.radius=this.radius},cv(ns,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),ns);cT([cE],dR.prototype,"_radius",void 0);var dw=(cx(nl=function(){var e;return(e=dE.call(this)||this)._nativeShape=d_._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},dE),nl),db=(cx(nc=function(){var t;return(t=dE.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=d_._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},dE),nc.prototype._cloneTo=function(e){dE.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},cv(nc,[{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))}}]),nc);cT([cE],db.prototype,"_radius",void 0),cT([cE],db.prototype,"_height",void 0),cT([cE],db.prototype,"_upAxis",void 0);var dP=((nd=(nu=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new c1,this._downList=new c1,this._nativeEvents=[],this._hadListener=!1;var r=t._canvas._webCanvas;this._engine=t,this._canvas=t.canvas,this._htmlCanvas=r,this._onPointerEvent=this._onPointerEvent.bind(this),this._onFocus(),this._pointerPool=Array(11)}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,i=this._canvas,a=i.width,o=i.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),u=c.left,d=c.top,h=a/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 S,C=this._pointerPool,T=0;T<x&&!(t[T].id>T);T++);(y=C[S=T]||(C[S]=new dl(T)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-u)*h,(g.clientY-d)*_),t.splice(T,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var A=this._engine.time.frameCount,E=0,M=t.length;E<M;E++){var R=t[E];R._upList.length=R._downList.length=0,this._updatePointerInfo(A,R,u,d,h,_),this._buttons|=R.pressedButtons}},nd._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,i=0,a=r.length;i<a;i++){var o=r[i],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 u=s.length;if(u>0){for(var d=0;d<u;d++)switch(s[d].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}}},nd._onFocus=function(){if(!this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t),this._hadListener=!0}},nd._onBlur=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1,this._pointers.length=0,this._downList.length=0,this._upList.length=0,this._nativeEvents.length=0}},nd._destroy=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1}this._pointerPool.length=0,this._pointerPool=null,this._pointers.length=0,this._pointers=null,this._downList.length=0,this._downList=null,this._upList.length=0,this._upList=null,this._nativeEvents.length=0,this._nativeEvents=null,this._upMap.length=0,this._upMap=null,this._downMap.length=0,this._downMap=null,this._htmlCanvas=null,this._canvas=null,this._engine=null},nd._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},nd._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},nd._updatePointerInfo=function(t,r,n,i,a,o){var s=r._events,l=r.position,c=s.length;if(c>0){var u=this._upList,d=this._upMap,h=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-n)*a,m=(f.clientY-i)*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=dc[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":u.add(y),d[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},nd._pointerRayCast=function(t,r,n){for(var i=nu._tempPoint,a=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._activeCameras,u=c.length-1;u>=0;u--){var d=c[u];if(d.enabled&&!d.renderTarget){var h=d.viewport,_=h.x,f=h.y,p=h.z,m=h.w;if(r>=_&&n>=f&&r-_<=p&&n-f<=m){if(i.set((r-_)/p,(n-f)/m),l.physics.raycast(d.viewportPointToRay(i,a),Number.MAX_VALUE,d.cullingMask,o))return o.entity;if(d.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},nu);dP._tempRay=new cc,dP._tempPoint=new cu,dP._tempHitResult=new dm;var dF=((n_=(nh=function(e){this._delta=new ce,this._nativeEvents=[];var t=e._canvas._webCanvas;this._onWheelEvent=this._onWheelEvent.bind(this),t.addEventListener("wheel",this._onWheelEvent),this._canvas=t,this._hadListener=!0}).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}},n_._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},n_._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},n_._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null,this._canvas=null,this._delta=null},n_._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},nh),dL=((np=(nf=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&cA(t,OffscreenCanvas)||(this._wheelManager=new dF(e),this._pointerManager=new dP(e),this._keyboardManager=new dh(e),this._onBlur=this._onBlur.bind(this),window.addEventListener("blur",this._onBlur),this._onFocus=this._onFocus.bind(this),window.addEventListener("focus",this._onFocus),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},np.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},np.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},np.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},np.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[du[e]]===this._engine.time.frameCount)},np.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[du[e]]===this._engine.time.frameCount)},np._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},np._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},np._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},np._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},np._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},cv(nf,[{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}}]),nf),dD=(cx(nm=function(e,t){var r;return(r=cF.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new uS(lT.Material),r.shader=t,r},cF),(ng=nm.prototype).clone=function(){var e=new nm(this._engine,this.shader);return this.cloneTo(e),e},ng.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),cb.deepCloneObject(this.renderStates,e.renderStates)},ng._addReferCount=function(e){this._destroyed||(cF.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e))},ng._onDestroy=function(){cF.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},cv(nm,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){this._shader=e;for(var t=this._renderStates,r=t.length,n=0,i=e.subShaders,a=0;a<i.length;a++)n=Math.max(i[a].passes.length,n);if(r<n)for(var o=r;o<n;o++)t.push(new uy);else t.length=n}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),nm);(lI||(lI={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(nv=lV||(lV={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",nv.DirectionTime="a_DirectionTime",nv.StartColor="a_StartColor",nv.StartSize="a_StartSize",nv.StartRotation0="a_StartRotation0",nv.StartSpeed="a_StartSpeed",nv.Random0="a_Random0",nv.Random1="a_Random1",nv.SimulationWorldPosition="a_SimulationWorldPosition",nv.SimulationWorldRotation="a_SimulationWorldRotation",nv.SimulationUV="a_SimulationUV";var dB=((ny=function(t){this.billboardVertexElement=new uP(lI.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new uP(lV.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new uP(lV.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new uP(lV.StartColor,32,e.VertexElementFormat.Vector4,1,1),new uP(lV.StartSize,48,e.VertexElementFormat.Vector3,1,1),new uP(lV.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new uP(lV.StartSpeed,72,e.VertexElementFormat.Float,1,1),new uP(lV.Random0,76,e.VertexElementFormat.Vector4,1,1),new uP(lV.Random1,92,e.VertexElementFormat.Vector4,1,1),new uP(lV.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new uP(lV.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new uP(lV.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=new uF(t,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);this.billboardVertexBufferBinding=new uV(r,16);var n=new uF(t,e.BufferBindFlag.IndexBuffer,this.billboardIndexCount,e.BufferUsage.Static,!1);this.billboardIndexBufferBinding=new uL(n,e.IndexFormat.UInt8),this.setBufferData()}).prototype.setBufferData=function(){this.billboardVertexBufferBinding.buffer.setData(new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0])),this.billboardIndexBufferBinding.buffer.setData(new Uint8Array([0,2,3,0,1,2]))},ny),dI="#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}",dV=((nx=function(){}).init=function(){var t=new uh("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 uh("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],i={pipelineStage:e.PipelineStage.Forward};ux.create("blinn-phong",[].concat(new uh("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}",i),n)),ux.create("pbr",[].concat(new uh("Forward",dI,"#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}",i),n)),ux.create("pbr-specular",[].concat(new uh("Forward",dI,"#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}",i),n)),ux.create("unlit",[].concat(new uh("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}",i),n)),ux.create("skybox",[new uh("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}",i)]),ux.create("SkyProcedural",[new uh("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}",i)]),ux.create("particle-shader",[new uh("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}",i)]),ux.create("SpriteMask",[new uh("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;}",i)]),ux.create("Sprite",[new uh("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;}",i)]),ux.create("background-texture",[new uh("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);}",i)])},nx),dO=((nC=(nS=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 i=e._mask,a=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=a<s?0:i[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=a<o?0:i[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},nC.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},nC._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var i in e){for(var a=e[i],o=e,s=0;s<n;s++)o[0==s?i:0]=o=Object.create(null);o[0]=a}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},nS);e.TextHorizontalAlignment=void 0,(nT=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[nT.Left=0]="Left",nT[nT.Center=1]="Center",nT[nT.Right=2]="Right",e.TextVerticalAlignment=void 0,(nA=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[nA.Top=0]="Top",nA[nA.Center=1]="Center",nA[nA.Bottom=2]="Bottom";var dN=(cx(nE=function(e){var t;return(t=cF.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},cF),(nM=nE.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},nM.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 i=n[r];i.name===e&&t.push(i)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},nM._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},nM._onDestroy=function(){cF.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},cv(nE,[{key:"sprites",get:function(){return this._sprites}}]),nE);e.SpriteDrawMode=void 0,(nR=e.SpriteDrawMode||(e.SpriteDrawMode={}))[nR.Simple=0]="Simple",nR[nR.Sliced=1]="Sliced",nR[nR.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(nw=e.SpriteTileMode||(e.SpriteTileMode={}))[nw.Continuous=0]="Continuous",nw[nw.Adaptive=1]="Adaptive";var dz=(cx(nb=function(e,t,r,n,i,a){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null),(o=cF.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new cu,new cu,new cu,new cu],o._uvs=[new cu,new cu,new cu,new cu],o._bounds=new cr,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new c_(0,0,1,1),o._atlasRegionOffset=new cd(0,0,0,0),o._region=new c_(0,0,1,1),o._pivot=new cu(.5,.5),o._border=new cd(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new c6,o._texture=t,o._onRegionChange=o._onRegionChange.bind(cm(o)),o._onPivotChange=o._onPivotChange.bind(cm(o)),o._onBorderChange=o._onBorderChange.bind(cm(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),i&&o._border.copyFrom(i),o.name=a,o},cF),(nP=nb.prototype).clone=function(){var e=new nb(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},nP._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},nP._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},nP._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},nP._addReferCount=function(e){var t;cF.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},nP._onDestroy=function(){this._dispatchSpriteChange(lE.destroy),cF.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},nP._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,i=1/dK._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*i,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*i}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},nP._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,i=t.width,a=t.height,o=Math.max(e.x-r,0)/i,s=Math.max(e.w-n,0)/a,l=1-Math.max(e.z-(1-r-i),0)/i,c=1-Math.max(e.y-(1-n-a),0)/a,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var d=this._bounds,h=d.min,_=d.max;h.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},nP._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,i=r.y,a=r.width,o=r.height,s=1-n-a,l=1-i-o,c=this._atlasRegion,u=c.x,d=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+u,S=Math.max(l-p,0)*y+d,C=h+u-Math.max(s-m,0)*v,T=_+d-Math.max(i-g,0)*y,A=this._border,E=A.x,M=A.y,R=A.z,w=A.w;e[0].set(x,T),e[1].set((n-f+E*a)*v+u,_+d-(i-g+M*o)*y),e[2].set(h+u-(s-m+R*a)*v,(l-p+w*o)*y+d),e[3].set(C,S),this._dirtyUpdateFlag&=-3},nP._dispatchSpriteChange=function(e){switch(e){case lE.texture:this._dirtyUpdateFlag|=4;break;case lE.atlasRegionOffset:case lE.region:this._dirtyUpdateFlag|=7;break;case lE.atlasRegion:this._dirtyUpdateFlag|=6;break;case lE.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},nP._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=l9.clamp(e.x,0,1),r=l9.clamp(e.y,0,1);e.set(t,r,l9.clamp(e.width,0,1-t),l9.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lE.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lE.size),e._onValueChanged=this._onRegionChange},nP._onPivotChange=function(){this._dispatchSpriteChange(lE.pivot)},nP._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=l9.clamp(e.x,0,1),r=l9.clamp(e.y,0,1);e.set(t,r,l9.clamp(e.z,0,1-t),l9.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lE.border),e._onValueChanged=this._onBorderChange},cv(nb,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(lE.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lE.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(lE.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(lE.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=l9.clamp(e.x,0,1),r=l9.clamp(e.y,0,1);this._atlasRegion.set(t,r,l9.clamp(e.width,0,1-t),l9.clamp(e.height,0,1-r)),this._dispatchSpriteChange(lE.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lE.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=l9.clamp(e.x,0,1),r=l9.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,l9.clamp(e.z,0,1-t),l9.clamp(e.w,0,1-r)),this._dispatchSpriteChange(lE.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(lE.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)}}]),nb);(nF=lO||(lO={}))[nF.positions=1]="positions",nF[nF.uvs=2]="uvs",nF[nF.automaticSize=4]="automaticSize",nF[nF.all=7]="all";var dU=((nL=function(){}).resetData=function(e){var t,r,n=e._verticesData,i=n.positions,a=n.uvs;n.vertexCount=i.length=a.length=16;for(var o=0;o<16;o++)i[t=o]||(i[t]=new ce),a[r=o]||(a[r]=new cu);n.triangles=dU._rectangleTriangles},nL.updatePositions=function(e){var t,r,n=e.width,i=e.height,a=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=a.border,u=a._getUVs(),d=a._getPositions(),h=d[0],_=h.x,f=h.y,p=d[3],m=p.x,g=p.y,v=a.width,y=a.height,x=v*c.x,S=y*c.y,C=v*c.z,T=y*c.w;if(x+C>n){var A=n/(x+C);t=[v*_*A,x*A,x*A,n-v*(1-m)*A]}else t=[v*_,x,n-C,n-v*(1-m)];if(T+S>i){var E=i/(T+S);r=[y*f*E,S*E,S*E,i-y*(1-g)*E]}else r=[y*f,S,i-T,i-y*(1-g)];var M=e.sprite.pivot,R=M.x,w=M.y,b=e.width*R,P=e.height*w,F=dU._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]-b*L[0]-P*L[4],L[13]=D[13]-b*L[1]-P*L[5],L[14]=D[14]-b*L[2]-P*L[6];for(var V=0;V<4;V++)for(var O=t[V],N=u[V].x,z=0;z<4;z++){var U=r[z],k=4*V+z;s[k].set(L[0]*O+L[4]*U+L[12],L[1]*O+L[5]*U+L[13],L[2]*O+L[6]*U+L[14]),l[k].set(N,u[z].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)},nL.updateUVs=function(e){},nL._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],nL._worldMatrix=new cl,nL);dU=cT([uE()],dU);var dk=((nD=function(){}).resetData=function(e){e._verticesData.triangles=[]},nD.updatePositions=function(t){var r,n,i,a,o,s,l=t.width,c=t.height,u=t.sprite,d=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,d===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(u,l,c,h,g,v,y,x):this._calculateContinuousDividing(u,l,c,g,v,y,x);var S=t.sprite.pivot,C=S.x,T=S.y,A=t.width*C,E=t.height*T,M=dk._worldMatrix,R=M.elements,w=t.entity.transform.worldMatrix.elements,b=t.flipX?-1:1,P=t.flipY?-1:1;r=R[0]=w[0]*b,n=R[1]=w[1]*b,i=R[2]=w[2]*b,a=R[4]=w[4]*P,o=R[5]=w[5]*P,s=R[6]=w[6]*P,R[8]=w[8],R[9]=w[9],R[10]=w[10];for(var F=R[12]=w[12]-A*R[0]-E*R[4],L=R[13]=w[13]-A*R[1]-E*R[5],D=R[14]=w[14]-A*R[2]-E*R[6],B=g.length-1,I=v.length-1,V=0,O=0,N=0;N<I;N++)for(var z=2*N,U=0;U<B;U++){var k=y.get(2*U),G=x.get(z),H=y.get(2*U+1),W=x.get(z+1);if(!(isNaN(k)||isNaN(k)||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 X=g.get(U),K=v.get(N),j=g.get(U+1),Y=v.get(N+1);p[V]?p[V].set(k,G):p[V]=new cu(k,G);var q=f[V];q?q.set(r*X+a*K+F,n*X+o*K+L,i*X+s*K+D):f[V]=new ce(r*X+a*K+F,n*X+o*K+L,i*X+s*K+D),p[++V]?p[V].set(H,G):p[V]=new cu(H,G),(q=f[V])?q.set(r*j+a*K+F,n*j+o*K+L,i*j+s*K+D):f[V]=new ce(r*j+a*K+F,n*j+o*K+L,i*j+s*K+D),p[++V]?p[V].set(k,W):p[V]=new cu(k,W),(q=f[V])?q.set(r*X+a*Y+F,n*X+o*Y+L,i*X+s*Y+D):f[V]=new ce(r*X+a*Y+F,n*X+o*Y+L,i*X+s*Y+D),p[++V]?p[V].set(H,W):p[V]=new cu(H,W),(q=f[V])?q.set(r*j+a*Y+F,n*j+o*Y+L,i*j+s*Y+D):f[V]=new ce(r*j+a*Y+F,n*j+o*Y+L,i*j+s*Y+D),V++}}t._verticesData.vertexCount=V,m.length=O;var Q=t._bounds,Z=Q.min,J=Q.max;Z.set(g.get(0),v.get(0),0),J.set(g.get(B),v.get(I),0),t._bounds.transform(M)},nD.updateUVs=function(e){},nD._calculateAdaptiveDividing=function(e,t,r,n,i,a,o,s){var l,c,u,d,h,_,f,p=e.border,m=e._getPositions(),g=m[0],v=g.x,y=g.y,x=m[3],S=x.x,C=x.y,T=e._getUVs(),A=T[0],E=T[1],M=T[2],R=T[3],w=e.width,b=e.height,P=w*p.x,F=w*p.z,L=P+F,D=w-L,B=b*p.w,I=b*p.y,V=B+I,O=b-V;if(L>=t?(d=3,c=0):D>l9.zeroTolerance?(d=4+(_=(_=(t-L)/D)%1>=n?Math.ceil(_):Math.floor(_))-1,c=2):(d=4,c=1),V>=r?(h=3,u=0):O>l9.zeroTolerance?(h=4+(f=(f=(r-V)/O)%1>=n?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),(d-1)*(h-1)*4>u3.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*S),a.add(r*y),a.add(r*C),o.add(A.x),o.add(R.x),s.add(A.y),s.add(R.y),cz.warn("The number of vertices exceeds the upper limit("+u3.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,i.add(w*v*l),i.add(P*l),i.add(t-w*(1-S)*l),o.add(A.x),o.add(E.x),o.add(M.x),o.add(R.x);break;case 1:i.add(w*v),i.add(P),i.add(t-F),i.add(t-w*(1-S)),o.add(A.x),o.add(E.x),o.add(NaN),o.add(NaN),o.add(M.x),o.add(R.x);break;case 2:l=t/(L+_*D),i.add(w*v*l),i.add(P*l),o.add(A.x),o.add(E.x),o.add(E.x);for(var N=0,z=_-1;N<z;N++)i.add(P+(N+1)*D*l),o.add(M.x),o.add(E.x);i.add(t-F*l),i.add(t-w*(1-S)*l),o.add(M.x),o.add(M.x),o.add(R.x)}switch(u){case 0:l=r/V,a.add(b*y*l),a.add(I*l),a.add(r-b*(1-C)*l),s.add(A.y),s.add(E.y),s.add(M.y),s.add(R.y);break;case 1:a.add(b*y),a.add(I),a.add(r-B),a.add(r-b*(1-C)),s.add(A.y),s.add(E.y),s.add(NaN),s.add(NaN),s.add(M.y),s.add(R.y);break;case 2:l=r/(V+f*O),a.add(b*y*l),a.add(I*l),s.add(A.y),s.add(E.y),s.add(E.y);for(var U=0,k=f-1;U<k;U++)a.add(I+(U+1)*O*l),s.add(M.y),s.add(E.y);a.add(r-B*l),a.add(r-b*(1-C)*l),s.add(M.y),s.add(M.y),s.add(R.y)}},nD._calculateContinuousDividing=function(e,t,r,n,i,a,o){var s,l,c,u,d,h,_=e.border,f=e._getPositions(),p=f[0],m=p.x,g=p.y,v=f[3],y=v.x,x=v.y,S=e._getUVs(),C=S[0],T=S[1],A=S[2],E=S[3],M=e.width,R=e.height,w=M*_.x,b=M*_.z,P=w+b,F=M-P,L=R*_.w,D=R*_.y,B=L+D,I=R-B;if(P>=t?(c=3,s=0):F>l9.zeroTolerance?(c=4+(0|(d=(t-P)/F)),s=2):(c=4,s=1),B>=r?(u=3,l=0):I>l9.zeroTolerance?(u=4+(0|(h=(r-B)/I)),l=2):(u=4,l=1),(c-1)*(u-1)*4>u3.MAX_VERTEX_COUNT){n.add(t*m),n.add(t*y),i.add(r*g),i.add(r*x),a.add(C.x),a.add(E.x),o.add(C.y),o.add(E.y),cz.warn("The number of vertices exceeds the upper limit("+u3.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var V=t/P;n.add(M*m*V),n.add(w*V),n.add(t-M*(1-y)*V),a.add(C.x),a.add(T.x),a.add(A.x),a.add(E.x);break;case 1:n.add(M*m),n.add(w),n.add(t-b),n.add(t-M*(1-y)),a.add(C.x),a.add(T.x),a.add(NaN),a.add(NaN),a.add(A.x),a.add(E.x);break;case 2:n.add(M*m),n.add(w),a.add(C.x),a.add(T.x),a.add(T.x);for(var O=0|d,N=0;N<O;N++)n.add(w+(N+1)*F),a.add(A.x),a.add(T.x);n.add(t-b),n.add(t-M*(1-y)),a.add((A.x-T.x)*(d-O)+T.x),a.add(A.x),a.add(E.x)}switch(l){case 0:var z=r/B;i.add(R*g*z),i.add(D*z),i.add(r-R*(1-x)*z),o.add(C.y),o.add(T.y),o.add(A.y),o.add(E.y);break;case 1:i.add(R*g),i.add(D),i.add(r-L),i.add(r-R*(1-x)),o.add(C.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(E.y);break;case 2:i.add(R*g),i.add(D),o.add(C.y),o.add(T.y),o.add(T.y);for(var U=0|h,k=0;k<U;k++)i.add(D+(k+1)*I),o.add(A.y),o.add(T.y);i.add(r-L),i.add(r-R*(1-x)),o.add((A.y-T.y)*(h-U)+T.y),o.add(A.y),o.add(E.y)}},nD._worldMatrix=new cl,nD._posRow=new c1,nD._posColumn=new c1,nD._uvRow=new c1,nD._uvColumn=new c1,nD);dk=cT([uE()],dk),(nB=lN||(lN={}))[nB.Compressed=0]="Compressed",nB[nB.WithoutTiled=1]="WithoutTiled",nB[nB.WithTiled=2]="WithTiled";var dG=(nI=e.Renderer,cx(nV=function(t){var r;return(r=nI.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new ch(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 uR(4,[],[],null,r._color),r.drawMode=e.SpriteDrawMode.Simple,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(cm(r)),r},nI),(nO=nV.prototype)._cloneTo=function(e,t,r){nI.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},nO._updateShaderData=function(e){this._updateTransformShaderData(e,cl._identity)},nO._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},nO._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&lA.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~lA.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var n=this.sprite.texture,i=this._engine._spriteRenderDataPool.getFromPool();i.set(this,r,this._verticesData,n),e.camera._renderPipeline.pushRenderData(e,i)}}},nO._onDestroy=function(){nI.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},nO._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},nO._updateStencilState=function(t,r){var n=this.getMaterial(),i=this._engine._spriteDefaultMaterials;if(n===i[t])this.setMaterial(i[r]);else{var a=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(a.enabled=!1,a.writeMask=255,a.referenceValue=0,a.compareFunctionFront=a.compareFunctionBack=e.CompareFunction.Always):(a.enabled=!0,a.writeMask=0,a.referenceValue=1,a.compareFunctionFront=a.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},nO._onSpriteChange=function(t){switch(t){case lE.texture:this.shaderData.setTexture(nV._textureProperty,this.sprite.texture);break;case lE.size:var r=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=lA.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=lA.WorldVolume);break;case lE.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case lE.region:case lE.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case lE.atlasRegion:this._dirtyUpdateFlag|=2;break;case lE.pivot:this._dirtyUpdateFlag|=lA.WorldVolume;break;case lE.destroy:this.sprite=null}},cv(nV,[{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=uM;break;case e.SpriteDrawMode.Sliced:this._assembler=dU;break;case e.SpriteDrawMode.Tiled:this._assembler=dk}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=l9.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&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(nV._textureProperty,e.texture)):this.shaderData.setTexture(nV._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|=lA.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|=lA.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=lA.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=lA.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)}}]),nV);dG._textureProperty=cQ.getByName("renderer_SpriteTexture"),cT([cE],dG.prototype,"_verticesData",void 0),cT([cE],dG.prototype,"_drawMode",void 0),cT([cM],dG.prototype,"_assembler",void 0),cT([cM],dG.prototype,"_tileMode",void 0),cT([cM],dG.prototype,"_tiledAdaptiveThreshold",void 0),cT([cw],dG.prototype,"_color",void 0),cT([cE],dG.prototype,"_sprite",void 0),cT([cE],dG.prototype,"_automaticWidth",void 0),cT([cE],dG.prototype,"_automaticHeight",void 0),cT([cM],dG.prototype,"_customWidth",void 0),cT([cM],dG.prototype,"_customHeight",void 0),cT([cM],dG.prototype,"_flipX",void 0),cT([cM],dG.prototype,"_flipY",void 0),cT([cM],dG.prototype,"_maskLayer",void 0),cT([cM],dG.prototype,"_maskInteraction",void 0),cT([cE],dG.prototype,"_onSpriteChange",null),(nN=lz||(lz={}))[nN.UV=2]="UV",nN[nN.RenderData=3]="RenderData",nN[nN.AutomaticSize=4]="AutomaticSize",nN[nN.All=7]="All";var dH=function e(){this.localPositions=new cd;var t=[new ce,new ce,new ce,new ce];this.renderData=new uR(4,t,null,e.triangles,null)};dH.triangles=[0,2,1,2,0,3];var dW=((nU=(nz=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},nU.put=function(e){this._elements.push(e)},nz),dX=(nk=e.Renderer,cx(nG=function(t){var r;return(r=nk.call(this,t)||this)._subFont=null,r._charRenderDatas=[],r._dirtyFlag=15,r._color=new ch(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new cr,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},nk),(nH=nG.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},nH._onDestroy=function(){nk.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,r=e.length;t<r;++t)nG._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},nH._cloneTo=function(e,t,r){nk.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},nH._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},nH._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},nH._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},nH._updateShaderData=function(e){this._updateTransformShaderData(e,cl._identity)},nH._updateBounds=function(e){cr.transform(this._localBounds,this._entity.transform.worldMatrix,e)},nH._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,i=this.getMaterial(),a=this._charRenderDatas,o=a.length;r.component=this,r.material=i,n.length=o;for(var s=0;s<o;++s){var l=a[s],c=t.getFromPool();c.set(this,i,l.renderData,l.texture,s),n[s]=c}e.camera._renderPipeline.pushRenderData(e,r)}},nH._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}},nH._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=cK.getNativeFontString(e.name,this.fontSize,this.fontStyle)},nH._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,r=e[0],n=e[1],i=e[2],a=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=nG._tempVec31.set(a,o,s),h=nG._tempVec30.set(r,n,i),_=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*a+l,x.y=v*n+y*o+c,x.z=v*i+y*s+u;var S=g[1];ce.scale(h,m.z-v,S),ce.add(x,S,S);var C=g[2];ce.scale(d,m.w-y,C),ce.add(x,C,g[3]),ce.add(S,C,C)}},nH._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,i=this.color,a=this._charRenderDatas,o=this._subFont,s=this.enableWrapping?cK.measureTextWithWrap(this):cK.measureTextWithoutWrap(this),l=s.height,c=s.lines,u=s.lineWidths,d=s.lineHeight,h=s.lineMaxSizes,_=nG._charRenderDataPool,f=c.length,p=0;if(f>0){var m=dK._pixelsPerUnit,g=this.horizontalAlignment,v=1/m,y=.5*(this.width*m),x=this.height*m,S=.5*d,C=0,T=.5*d-h[0].ascent,A=.5*d-h[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:C=.5*x-S+T;break;case e.TextVerticalAlignment.Center:C=.5*l-S-(A-T)*.5;break;case e.TextVerticalAlignment.Bottom:C=l-.5*x-S-A}for(var E=-1,M=Number.MAX_SAFE_INTEGER,R=Number.MAX_SAFE_INTEGER,w=Number.MIN_SAFE_INTEGER,b=Number.MIN_SAFE_INTEGER,P=0;P<f;++P){var F=u[P];if(F>0){var L=c[P],D=0,B=-1;switch(E<0&&(E=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 z,U=a[z=p++]||(a[z]=_.get()),k=U.renderData,G=U.localPositions;U.texture=o._getTextureByIndex(N.index),k.color=i,k.uvs=N.uvs;var H=N.w,W=N.ascent,X=N.descent,K=D*v,j=(D+H)*v,Y=(C+W)*v,q=(C-X)*v;G.set(K,Y,j,q),P===E&&(b=Math.max(b,Y)),R=Math.min(R,q),I===B&&(M=Math.min(M,K)),w=Math.max(w,j)}D+=N.xAdvance}}C-=d}E<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(M,R,0),n.set(w,b,0))}else r.set(0,0,0),n.set(0,0,0);var Q=a.length;if(Q>p){for(var Z=p;Z<Q;++Z)_.put(a[Z]);a.length=p}o._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},nH._onTransformChanged=function(e){nk.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},nH._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},cv(nG,[{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&&t._addReferCount(-1),e&&e._addReferCount(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}}]),nG);dX._charRenderDataPool=new dW(dH,50),dX._tempVec30=new ce,dX._tempVec31=new ce,cT([cM],dX.prototype,"_subFont",void 0),cT([cE],dX.prototype,"_charRenderDatas",void 0),cT([cE],dX.prototype,"_dirtyFlag",void 0),cT([cw],dX.prototype,"_color",void 0),cT([cM],dX.prototype,"_text",void 0),cT([cM],dX.prototype,"_width",void 0),cT([cM],dX.prototype,"_height",void 0),cT([cE],dX.prototype,"_localBounds",void 0),cT([cM],dX.prototype,"_font",void 0),cT([cM],dX.prototype,"_fontSize",void 0),cT([cM],dX.prototype,"_fontStyle",void 0),cT([cM],dX.prototype,"_lineSpacing",void 0),cT([cM],dX.prototype,"_horizontalAlignment",void 0),cT([cM],dX.prototype,"_verticalAlignment",void 0),cT([cM],dX.prototype,"_enableWrapping",void 0),cT([cM],dX.prototype,"_overflowMode",void 0),cT([cM],dX.prototype,"_maskInteraction",void 0),cT([cM],dX.prototype,"_maskLayer",void 0),(nW=lU||(lU={}))[nW.SubFont=1]="SubFont",nW[nW.LocalPositionBounds=2]="LocalPositionBounds",nW[nW.WorldPosition=4]="WorldPosition",nW[nW.WorldBounds=8]="WorldBounds",nW[nW.MaskInteraction=16]="MaskInteraction",nW[nW.Position=14]="Position",nW[nW.Font=15]="Font",dV.init();var dK=function(t){function r(n,i,a){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new uy,o._renderElementPool=new ut(uA),o._renderDataPool=new ut(uT),o._spriteRenderDataPool=new ut(u6),o._spriteMaskRenderDataPool=new ut(u8),o._textRenderDataPool=new ut(u7),o._spriteDefaultMaterials=[],o._renderContext=new uC,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new un,o._settings={},o._resourceManager=new dr(cm(o)),o._sceneManager=new de(cm(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new cZ,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(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=i,o._hardwareRenderer.init(n,o._onDeviceLost.bind(cm(o)),o._onDeviceRestored.bind(cm(o))),o._canvas=n,o._spriteMaskManager=new u5(cm(o));var o,s=cm(o)._spriteDefaultMaterials;if(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=cY.createFromOS(cm(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new dL(cm(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var l=new cG(cm(o),1,1,e.TextureFormat.Depth16,!1);l.isGCIgnored=!0,o._depthTexture2D=l}else o._macroCollection.enable(r._noDepthTextureMacro);var c=new dD(cm(o),ux.find("unlit"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new cC(1,0,1.01,1)),o._meshMagentaMaterial=c;var u=new dD(cm(o),ux.find("particle-shader"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new cC(1,0,1.01,1)),o._particleMagentaMaterial=u;var d=o._settings,h=a.colorSpace||e.ColorSpace.Linear;return h===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),d.colorSpace=h,o._particleBufferUtils=new dB(cm(o)),o}cx(r,t);var n=r.prototype;return n.createEntity=function(e){return new ue(this,e)},n.pause=function(){this._isPaused=!0,cancelAnimationFrame(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){this._isPaused&&(this._isPaused=!1,this.time._reset(),this._requestId=requestAnimationFrame(this._animate))},n.update=function(){var e=this._time;e._update();var t=e.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._renderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool();var r=this.inputManager,n=this._physicsInitialized;r._update();for(var i=this._sceneManager._scenes.getLoopArray(),a=i.length,o=0;o<a;o++){var s=i[o];s.isActive&&!s.destroyed&&(s._cameraNeedSorting&&s._sortCameras(),s._componentsManager.callScriptOnStart())}if(n)for(var l=0;l<a;l++){var c=i[l];c.isActive&&!c.destroyed&&c.physics._update(t)}n&&r._firePointerScript(i);for(var u=0;u<a;u++){var d=i[u];d.isActive&&!d.destroyed&&d._componentsManager.callScriptOnUpdate(t)}for(var h=0;h<a;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callAnimationUpdate(t)}for(var f=0;f<a;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callScriptOnLateUpdate(t)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var m=0;m<a;m++){var g=i[m];g.isActive&&!g.destroyed&&g._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(){this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._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 i=t+1;i>r.length&&(r.length=i),r[t]=n=new dO}return n},n._render=function(e){for(var t=this.time.deltaTime,r=0,n=e.length;r<n;r++){var i=e[r];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(t),i._updateShaderData())}for(var a=0,o=e.length;a<o;a++){var s=e[a];if(s.isActive&&!s.destroyed){var l=s._activeCameras,c=l.length;if(c>0)for(var u=0;u<c;u++){var d=l[u],h=s._componentsManager;h.callCameraOnBeginRender(d),d.render(),h.callCameraOnEndRender(d),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else cz.debug("No active camera in scene.")}}},n._initMagentaTextures=function(t){var r=new Uint8Array([255,255,255,255]),n=new cG(this,1,1,e.TextureFormat.R8G8B8A8,!1);n.setPixelBuffer(r),n.isGCIgnored=!0;var i=new Uint8Array([255,0,255,255]),a=new cG(this,1,1,e.TextureFormat.R8G8B8A8,!1);a.setPixelBuffer(i),a.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cx(l=function(){return cL.call(this,a)},cL),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(i)},l));for(var o=new cW(this,1,e.TextureFormat.R8G8B8A8,!1),s=0;s<6;s++)o.setPixelBuffer(e.TextureCubeFace.PositiveX+s,i);if(o.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cx(c=function(){return cL.call(this,o)},cL),c.prototype.restoreContent=function(){for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,i)},c)),this._whiteTexture2D=n,this._magentaTexture2D=a,this._magentaTextureCube=o,t.isWebGL2){var l,c,u,d=new cH(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);d.setPixelBuffer(0,i),d.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(cx(u=function(){return cL.call(this,d)},cL),u.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,i)},u)),this._magentaTexture2DArray=d}},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&(ux._shaderLab=r);var i=[];n&&i.push(n.initialize().then(function(){return d_._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var a=dr._loaders;for(var o in a){var s=a[o];s.initialize&&i.push(s.initialize(this,e))}return Promise.all(i).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new dD(this,ux.find("Sprite")),n=r.renderState,i=n.blendState.targetBlendState;if(i.enabled=!0,i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var a=n.stencilState;a.enabled=!0,a.writeMask=0,a.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;a.compareFunctionFront=o,a.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 dD(this,ux.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 uy,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),this._particleBufferUtils.setBufferData(),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()},cv(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}(cq);dK._gammaMacro=ur.getByName("ENGINE_IS_COLORSPACE_GAMMA"),dK._noDepthTextureMacro=ur.getByName("ENGINE_NO_DEPTH_TEXTURE"),dK._pixelsPerUnit=100;var dj=(cv(nX=function(){this._sizeUpdateFlagManager=new c6},[{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())}}]),nX);e.BackgroundMode=void 0,(nK=e.BackgroundMode||(e.BackgroundMode={}))[nK.SolidColor=0]="SolidColor",nK[nK.Sky=1]="Sky",nK[nK.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(nj=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[nj.AspectFitWidth=0]="AspectFitWidth",nj[nj.AspectFitHeight=1]="AspectFitHeight",nj[nj.Fill=2]="Fill";var dY=((nq=(nY=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},nq._render=function(e){var t=this.material,r=this.mesh;if(!t){cz.warn("The material of sky is not defined.");return}if(t.destroyed){cz.warn("The material of sky is destroyed.");return}if(!r){cz.warn("The mesh of sky is not defined.");return}if(r.destroyed){cz.warn("The mesh of sky is destroyed.");return}var n=e.camera,i=n.engine,a=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,u=a.shaderData,d=nY._viewProjMatrix,h=nY._projectionMatrix,_=i._hardwareRenderer,f=t.shaderData,p=t.shader,m=t.renderState;d.copyFrom(l);var g=d.elements;g[12]=g[13]=g[14]=0;var v=1/Math.tan(l9.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,cl.multiply(h,d,d);var y=c.getMatrix(uC.vpMatrixProperty);c.setMatrix(uC.vpMatrixProperty,d);var x=ux._compileMacros;un.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var S=p.subShaders[0].passes[0],C=S._getShaderProgram(i,x);C.bind(),C.groupingOtherUniformBlock(),C.uploadAll(C.sceneUniformBlock,u),C.uploadAll(C.cameraUniformBlock,c),C.uploadAll(C.materialUniformBlock,f),C.uploadUnGroupTextures(),m._apply(i,!1,S._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,C),c.setMatrix(uC.vpMatrixProperty,y)},cv(nY,[{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}}}]),nY);dY._epsilon=1e-6,dY._viewProjMatrix=new cl,dY._projectionMatrix=new cl(1,0,0,0,0,1,0,0,0,0,dY._epsilon-1,-1,0,0,0,0);var dq=((nZ=(nQ=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new ch(.25,.25,.25,1),this.sky=new dY,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()},nZ._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,i=n.width,a=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*i/t.width/a;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*a/t.height/i;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)}},nZ._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},nZ._initMaterial=function(t){var r=this._material=new dD(t,ux.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},nZ._createPlane=function(e){var t=new uG(e);t.isGCIgnored=!0;for(var r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],i=[,,,,],a=0;a<4;++a)n[a]=new ce,i[a]=new cu(a%2,1-(.5*a|0));return t.setPositions(n),t.setUVs(i),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},cv(nQ,[{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())}}]),nQ),dQ=((n$=(nJ=function(){this._renderers=new c1,this._onStartScripts=new c1,this._onUpdateScripts=new c1,this._onLateUpdateScripts=new c1,this._onPhysicsUpdateScripts=new c1,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new c1,this._onUpdateRenderers=new c1,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},n$.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},n$.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},n$.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},n$.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},n$.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},n$.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},n$.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},n$.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},n$.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},n$.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},n$.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},n$.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},n$.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()})},n$.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},n$.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},n$.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},n$.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.engine.time.frameCount>t._playFrameCount&&t.update(e)},function(e,t){e._onUpdateIndex=t})},n$.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},n$.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}},n$.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},n$.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},n$.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},n$.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},n$._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},nJ);e.FogMode=void 0,(n0=e.FogMode||(e.FogMode={}))[n0.None=0]="None",n0[n0.Linear=1]="Linear",n0[n0.Exponential=2]="Exponential",n0[n0.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n1=e.DiffuseMode||(e.DiffuseMode={}))[n1.SolidColor=0]="SolidColor",n1[n1.SphericalHarmonics=1]="SphericalHarmonics";var dZ=(cx(n2=function(t){var r;return(r=cF.call(this,t)||this)._diffuseSolidColor=new ch(.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},cF),(n3=n2.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(n2._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(n2._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(n2._specularIntensityProperty,this._specularIntensity),t.setFloatArray(n2._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},n3._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(n2._specularTextureProperty,null),n.disableMacro(n2._specularMacro)},n3._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(n2._shMacro):t.disableMacro(n2._shMacro)},n3._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(n2._specularTextureProperty,this._specularTexture),e.setFloat(n2._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(n2._specularMacro)):e.disableMacro(n2._specularMacro)},n3._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(n2._decodeRGBMMacro):e.disableMacro(n2._decodeRGBMMacro)},n3._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]},cv(n2,[{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(n2._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(n2._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(n2._specularIntensityProperty,e)}}]),n2);dZ._shMacro=ur.getByName("SCENE_USE_SH"),dZ._specularMacro=ur.getByName("SCENE_USE_SPECULAR_ENV"),dZ._decodeRGBMMacro=ur.getByName("SCENE_IS_DECODE_ENV_RGBM"),dZ._diffuseColorProperty=cQ.getByName("scene_EnvMapLight.diffuse"),dZ._diffuseSHProperty=cQ.getByName("scene_EnvSH"),dZ._diffuseIntensityProperty=cQ.getByName("scene_EnvMapLight.diffuseIntensity"),dZ._specularTextureProperty=cQ.getByName("scene_EnvSpecularSampler"),dZ._specularIntensityProperty=cQ.getByName("scene_EnvMapLight.specularIntensity"),dZ._mipLevelProperty=cQ.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(n4=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[n4.NoCascades=1]="NoCascades",n4[n4.TwoCascades=2]="TwoCascades",n4[n4.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(n5=e.ShadowResolution||(e.ShadowResolution={}))[n5.Low=0]="Low",n5[n5.Medium=1]="Medium",n5[n5.High=2]="High",n5[n5.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(n8=e.ShadowType||(e.ShadowType={}))[n8.None=0]="None",n8[n8.Hard=1]="Hard",n8[n8.SoftLow=2]="SoftLow",n8[n8.SoftHigh=3]="SoftHigh";var dJ=(cx(n6=function(){var t;return t=cJ.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._color=new ch(1,1,1,1),t._lightColor=new ch,t},cJ),n6.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},cv(n6,[{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 cl),cl.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new cl),cl.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),n6);cT([cE],dJ.prototype,"_lightIndex",void 0);var d$=(cx(n7=function(){var e;return e=dJ.apply(this,arguments)||this,e._reverseDirection=new ce,e},dJ),(n9=n7.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=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[i]=ch.gammaToLinearSpace(o.r),r.color[i+1]=ch.gammaToLinearSpace(o.g),r.color[i+2]=ch.gammaToLinearSpace(o.b)):(r.color[i]=o.r,r.color[i+1]=o.g,r.color[i+2]=o.b),r.direction[a]=s.x,r.direction[a+1]=s.y,r.direction[a+2]=s.z},n9._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},n9._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},n7._updateShaderData=function(e,t){e.setIntArray(n7._cullingMaskProperty,t.cullingMask),e.setFloatArray(n7._colorProperty,t.color),e.setFloatArray(n7._directionProperty,t.direction)},cv(n7,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return ce.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),n7);d$._cullingMaskProperty=cQ.getByName("scene_DirectLightCullingMask"),d$._colorProperty=cQ.getByName("scene_DirectLightColor"),d$._directionProperty=cQ.getByName("scene_DirectLightDirection");var d0=(cx(ie=function(){var e;return e=dJ.apply(this,arguments)||this,e.distance=100,e},dJ),(it=ie.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=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[i]=ch.gammaToLinearSpace(o.r),r.color[i+1]=ch.gammaToLinearSpace(o.g),r.color[i+2]=ch.gammaToLinearSpace(o.b)):(r.color[i]=o.r,r.color[i+1]=o.g,r.color[i+2]=o.b),r.position[a]=s.x,r.position[a+1]=s.y,r.position[a+2]=s.z,r.distance[t]=this.distance},it._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},it._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},ie._updateShaderData=function(e,t){e.setIntArray(ie._cullingMaskProperty,t.cullingMask),e.setFloatArray(ie._colorProperty,t.color),e.setFloatArray(ie._positionProperty,t.position),e.setFloatArray(ie._distanceProperty,t.distance)},cv(ie,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),ie);d0._cullingMaskProperty=cQ.getByName("scene_PointLightCullingMask"),d0._colorProperty=cQ.getByName("scene_PointLightColor"),d0._positionProperty=cQ.getByName("scene_PointLightPosition"),d0._distanceProperty=cQ.getByName("scene_PointLightDistance");var d1=(cx(ir=function(){var e;return e=dJ.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new ce,e._projectMatrix=new cl,e},dJ),(ii=ir.prototype)._appendData=function(t,r){var n=2*t,i=3*t,a=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,u=this.cullingMask;r.cullingMask[n]=65535&u,r.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[i]=ch.gammaToLinearSpace(s.r),r.color[i+1]=ch.gammaToLinearSpace(s.g),r.color[i+2]=ch.gammaToLinearSpace(s.b)):(r.color[i]=s.r,r.color[i+1]=s.g,r.color[i+2]=s.b),r.position[a]=l.x,r.position[a+1]=l.y,r.position[a+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)},ii._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},ii._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},ir._updateShaderData=function(e,t){e.setIntArray(ir._cullingMaskProperty,t.cullingMask),e.setFloatArray(ir._colorProperty,t.color),e.setFloatArray(ir._positionProperty,t.position),e.setFloatArray(ir._directionProperty,t.direction),e.setFloatArray(ir._distanceProperty,t.distance),e.setFloatArray(ir._angleCosProperty,t.angleCos),e.setFloatArray(ir._penumbraCosProperty,t.penumbraCos)},cv(ir,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return ce.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 cl.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),ir);d1._cullingMaskProperty=cQ.getByName("scene_SpotLightCullingMask"),d1._colorProperty=cQ.getByName("scene_SpotLightColor"),d1._positionProperty=cQ.getByName("scene_SpotLightPosition"),d1._directionProperty=cQ.getByName("scene_SpotLightDirection"),d1._distanceProperty=cQ.getByName("scene_SpotLightDistance"),d1._angleCosProperty=cQ.getByName("scene_SpotLightAngleCos"),d1._penumbraCosProperty=cQ.getByName("scene_SpotLightPenumbraCos");var d2=function(){function t(){this._spotLights=new c1,this._pointLights=new c1,this._directLights=new c1,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._updateSunLightIndex=function(){var e=this._directLights,t=this._getSunLightIndex();if(t>0){var r=e.get(0),n=e.get(t);e.set(0,n),e.set(t,r),n._lightIndex=0,r._lightIndex=t}},r._updateShaderData=function(e){for(var t=this._spotLights,r=this._pointLights,n=this._directLights,i=this._spotData,a=this._pointData,o=this._directData,s=t.length,l=r.length,c=n.length,u=0;u<s;u++)t.get(u)._appendData(u,i);for(var d=0;d<l;d++)r.get(d)._appendData(d,a);for(var h=0;h<c;h++)n.get(h)._appendData(h,o);c?(d$._updateShaderData(e,o),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),l?(d0._updateShaderData(e,a),e.enableMacro("SCENE_POINT_LIGHT_COUNT",l.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),s?(d1._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",s.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._getSunLightIndex=function(){for(var t=this._directLights,r=-1,n=Number.NEGATIVE_INFINITY,i=!1,a=0,o=t.length;a<o;a++){var s=t.get(a);s.shadowType===e.ShadowType.None||i||(n=Number.NEGATIVE_INFINITY,i=!0);var l=s.intensity*s.color.getBrightness();i?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=a):n<l&&(n=l,r=a)}return r},t}();d2._maxLight=10;var d3=function(t){function r(n,i){(a=t.call(this,n)||this).physics=new d_(cm(a)),a.castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new ce(1/15,.2,7/15),a.shadowDistance=50,a._cameraNeedSorting=!1,a._lightManager=new d2,a._componentsManager=new dQ,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new un,a._rootEntities=[],a._background=new dq(a._engine),a._shaderData=new uS(lT.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new ch(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new cd,a._isActive=!0,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new dZ(n),n.sceneManager._allCreatedScenes.push(cm(a)),o.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),o.setColor(r._fogColorProperty,a._fogColor),o.setVector4(r._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}cx(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new ue(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 i=t._scene;i!==this?(i&&n&&i._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var a=lS.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(a|=lS.Hierarchy)),t._isActiveInScene&&i!==this&&(a|=lS.Scene),a&&t._processInActive(a),i!==this&&ue._traverseSetOwnerScene(t,this);var o=lS.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=lS.Hierarchy)),t._isActiveInScene&&i===this||(o|=lS.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=lS.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=lS.Hierarchy),e._isActiveInScene&&(t|=lS.Scene),t&&e._processInActive(t),ue._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 i=t[r].findByName(e);if(i)return i}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var i=this.getRootEntity(r);if(i.name==t[0]){for(var a=1,o=t.length;a<o&&(i=ue._findChildByName(i,t[a]));++a);return i}}return null},n._sortCameras=function(){this._activeCameras.sort(function(e,t){return e.priority-t.priority}),this._cameraNeedSorting=!1},n._attachRenderCamera=function(e){var t=this._activeCameras;-1===t.indexOf(e)?(t.push(e),this._cameraNeedSorting=!0):cz.warn("Camera already attached.")},n._detachRenderCamera=function(e){var t=this._activeCameras,r=t.indexOf(e);-1!==r&&t.splice(r,1)},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(lS.Hierarchy):n._processInActive(lS.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,n=this._engine,i=this._lightManager;if(n.time._updateSceneShaderData(t),i._updateShaderData(this.shaderData),i._updateSunLightIndex(),i._directLights.length>0){var a=i._directLights.get(0);t.setColor(r._sunlightColorProperty,a._getLightIntensityColor()),t.setVector3(r._sunlightDirectionProperty,a.direction),this._sunLight=a}else this._sunLight=null;this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),un.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._activeCameras.length=0,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 i=e+1,a=n+1;i<a;i++)r[i]._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)},cv(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){cz.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}}]),r}(cP);d3._fogColorProperty=cQ.getByName("scene_FogColor"),d3._fogParamsProperty=cQ.getByName("scene_FogParams"),d3._sunlightColorProperty=cQ.getByName("scene_SunlightColor"),d3._sunlightDirectionProperty=cQ.getByName("scene_SunlightDirection");var d4=(cx(ia=function(){var e;return e=cJ.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},cJ),(io=ia.prototype).onAwake=function(){},io.onEnable=function(){},io.onStart=function(){},io.onUpdate=function(e){},io.onLateUpdate=function(e){},io.onBeginRender=function(e){},io.onEndRender=function(e){},io.onPhysicsUpdate=function(){},io.onTriggerEnter=function(e){},io.onTriggerExit=function(e){},io.onTriggerStay=function(e){},io.onCollisionEnter=function(e){},io.onCollisionExit=function(e){},io.onCollisionStay=function(e){},io.onPointerDown=function(e){},io.onPointerUp=function(e){},io.onPointerClick=function(e){},io.onPointerEnter=function(e){},io.onPointerExit=function(e){},io.onPointerDrag=function(e){},io.onDisable=function(){},io.onDestroy=function(){},io._onAwake=function(){this.onAwake()},io._onEnable=function(){this.onEnable()},io._onDisable=function(){this.onDisable()},io._onEnableInScene=function(){var e=this.scene._componentsManager,t=ia.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)},io._onDisableInScene=function(){var e=this.scene._componentsManager,t=ia.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)},io._onDestroy=function(){cJ.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},ia);cT([cE],d4.prototype,"_started",void 0),cT([cE],d4.prototype,"_onStartIndex",void 0),cT([cE],d4.prototype,"_onUpdateIndex",void 0),cT([cE],d4.prototype,"_onLateUpdateIndex",void 0),cT([cE],d4.prototype,"_onPhysicsUpdateIndex",void 0),cT([cE],d4.prototype,"_onPreRenderIndex",void 0),cT([cE],d4.prototype,"_onPostRenderIndex",void 0),cT([cE],d4.prototype,"_entityScriptsIndex",void 0),e.DepthTextureMode=void 0,(is=e.DepthTextureMode||(e.DepthTextureMode={}))[is.None=0]="None",is[is.PrePass=1]="PrePass";var d5=0,d8=((ic=(il=function(t,r,n,i,a){void 0===t&&(t="RENDER_PASS"+d5++),void 0===r&&(r=0),void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null),this.name=t,this.enabled=!0,this.priority=r,this.renderTarget=n,this.replaceMaterial=i,this.mask=a||e.Layer.Everything,this.renderOverride=!1}).prototype).render=function(e,t,r,n){},ic.preRender=function(e,t,r,n){},ic.postRender=function(e,t,r,n){},il),d6=(cx(iu=function(){return u3.apply(this,arguments)},u3),(id=iu.prototype).createVertexElements=function(t){return t[0]=new uP("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new uP("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new uP("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},id.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPasses[0].getTagValue(u3._disableBatchTag))return!1;var r=e.data,n=t.data,i=r.component,a=n.component;return!!this.checkBatchWithMask(i,a)&&r.texture===n.texture&&r.material===n.material},id.checkBatchWithMask=function(t,r){var n=t.maskInteraction;return n===r.maskInteraction&&(n===e.SpriteMaskInteraction.None||t.maskLayer===r.maskLayer)},id.updateVertices=function(e,t,r){for(var n=e.verticesData,i=n.positions,a=n.uvs,o=n.color,s=n.vertexCount,l=0;l<s;l++){var c=i[l],u=a[l];t[r++]=c.x,t[r++]=c.y,t[r++]=c.z,t[r++]=u.x,t[r++]=u.y,t[r++]=o.r,t[r++]=o.g,t[r++]=o.b,t[r++]=o.a}return r},id.drawBatches=function(e){for(var t=this._engine,r=this._batchedQueue,n=this._meshes[this._flushId],i=n.subMeshes,a=n._primitive,o=t._spriteMaskManager,s=e.scene.shaderData,l=e.shaderData,c=0,u=i.length;c<u;c++){var d=i[c],h=r[c],_=h.data;if(!d||!h)return;var f=_.component,p=_.material;o.preRender(e,f);var m=ux._compileMacros;un.unionCollection(f._globalShaderMacro,p.shaderData._macroCollection,m);var g=h.shaderPasses[0],v=g._getShaderProgram(t,m);if(!v.isValid)return;f.shaderData.setTexture(iu._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(a,d,v),o.postRender(f)}},id.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,r=this._indiceBuffers,n=0,i=e.length;n<i;++n)e[n].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=r.length;s<l;++s)r[s].destroy();this._indiceBuffers=null},iu);d6._textureProperty=cQ.getByName("renderer_SpriteTexture");var d7=((i_=(ih=function(e,t){this.elements=[],this._initSpriteBatcher(e),this._renderQueueType=t}).prototype).pushRenderElement=function(e){this.elements.push(e)},i_.render=function(e,t,r){var n=this.elements;if(0!==n.length){for(var i=e.engine,a=e.scene,o=i._renderCount,s=i._hardwareRenderer,l=a.shaderData,c=e.shaderData,u=uC.pipelineStageKey,d=this._renderQueueType,h=0,_=n.length;h<_;h++){var f=n[h],p=f.data,m=f.shaderPasses;if(p.component.entity.layer&t){if(p.primitive){this._spriteBatcher.flush(e);var g=ux._compileMacros,v=p.primitive,y=p.component,x=p.material,S=y.shaderData,C=x.shaderData,T=x.renderStates;un.unionCollection(y._globalShaderMacro,C._macroCollection,g);for(var A=0,E=m.length;A<E;A++){var M,R,w=m[A];if(w.getTagValue(u)===r&&(null!=(M=w._renderState)?M:T[A]).renderQueueType===d){var b=w._getShaderProgram(i,g);if(b.isValid){var P=b.bind();o!==b._uploadRenderCount?(b.groupingOtherUniformBlock(),b.uploadAll(b.sceneUniformBlock,l),b.uploadAll(b.cameraUniformBlock,c),b.uploadAll(b.rendererUniformBlock,S),b.uploadAll(b.materialUniformBlock,C),b.uploadUnGroupTextures(),b._uploadScene=a,b._uploadCamera=e,b._uploadRenderer=y,b._uploadMaterial=x,b._uploadRenderCount=o):(b._uploadScene!==a?(b.uploadAll(b.sceneUniformBlock,l),b._uploadScene=a):P&&b.uploadTextures(b.sceneUniformBlock,l),b._uploadCamera!==e?(b.uploadAll(b.cameraUniformBlock,c),b._uploadCamera=e):P&&b.uploadTextures(b.cameraUniformBlock,c),b._uploadRenderer!==y?(b.uploadAll(b.rendererUniformBlock,S),b._uploadRenderer=y):P&&b.uploadTextures(b.rendererUniformBlock,S),b._uploadMaterial!==x?(b.uploadAll(b.materialUniformBlock,C),b._uploadMaterial=x):P&&b.uploadTextures(b.materialUniformBlock,C),P&&b.uploadUnGroupTextures()),(null!=(R=w._renderState)?R:T[A])._apply(i,y.entity.transform._isFrontFaceInvert(),w._renderStateDataMap,x.shaderData),s.drawPrimitive(v,p.subPrimitive,b)}}}}else this._spriteBatcher.drawElement(f,e)}}this._spriteBatcher.flush(e)}},i_.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},i_.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},i_.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},i_._initSpriteBatcher=function(e){this._spriteBatcher=new d6(e)},i_._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var i=t+r>>1,a=e[t],o=e[r-1],s=e[i];if(n(a,o)>0){var l=a;a=o,o=l}if(n(a,s)>=0){var c=a;a=s,s=o,o=c}else if(n(o,s)>0){var u=o;o=s,s=u}e[t]=a,e[r-1]=s;var d=o,h=t+1,_=r-1;e[i]=e[h],e[h]=d;e:for(var f=h+1;f<_;f++){var p=e[f],m=n(p,d);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=n(e[_],d)}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=_)}},i_._insertionSort=function(e,t,r,n){for(var i=t+1;i<r;i++){var a=void 0,o=e[i];for(a=i-1;a>=t;a--){var s=e[a];if(n(s,o)>0)e[a+1]=s;else break}e[a+1]=o}},ih._compareFromNearToFar=function(e,t){var r=e.data,n=t.data,i=r.component,a=n.component,o=i.priority-a.priority;if(0!==o)return o;if(i.instanceId===a.instanceId)return r.material._priority-n.material._priority;var s=i._distanceForSort-a._distanceForSort;return 0===s?i.instanceId-a.instanceId:s},ih._compareFromFarToNear=function(e,t){var r=e.data,n=t.data,i=r.component,a=n.component,o=i.priority-a.priority;if(0!==o)return o;if(i.instanceId===a.instanceId)return r.material._priority-n.material._priority;var s=a._distanceForSort-i._distanceForSort;return 0===s?i.instanceId-a.instanceId:s},ih),d9=((ip=function(){}).recreateTextureIfNeeded=function(e,t,r,n,i,a){if(t){if(t.width===r&&t.height===n&&t.format===i&&t.mipmapCount>1===a)return t;t.destroy();var o=new cG(e,r,n,i,a);return o.isGCIgnored=!0,o}var s=new cG(e,r,n,i,a);return s.isGCIgnored=!0,s},ip.recreateRenderTargetIfNeeded=function(e,t,r,n,i,a,o){var s,l,c,u=null==(s=t)?void 0:s.getColorTexture(0),d=null==(l=t)?void 0:l.depthTexture,h=i?ip.recreateTextureIfNeeded(e,u,r,n,i,o):null,_=a?ip.recreateTextureIfNeeded(e,d,r,n,a,o):null;return(u!==h||d!==_)&&(null==(c=t)||c.destroy(),(t=new ck(e,r,n,h,_)).isGCIgnored=!0),t},ip),he=function(){this.position=new ce,this.isOrthographic=!1,this.viewMatrix=new cl,this.projectionMatrix=new cl,this.viewProjectionMatrix=new cl,this.forward=new ce},ht=function(){this.virtualCamera=new he,this.cullPlanes=[new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce),new ci(new ce)],this.splitBoundSphere=new ct(new ce,0)};(im=lk||(lk={}))[im.FarBottomLeft=0]="FarBottomLeft",im[im.FarTopLeft=1]="FarTopLeft",im[im.FarTopRight=2]="FarTopRight",im[im.FarBottomRight=3]="FarBottomRight",im[im.nearBottomLeft=4]="nearBottomLeft",im[im.nearTopLeft=5]="nearTopLeft",im[im.nearTopRight=6]="nearTopRight",im[im.nearBottomRight=7]="nearBottomRight",im[im.unknown=8]="unknown";var hr=((ig=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}},ig.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},ig.cullingRenderBounds=function(e,t,r){for(var n=e.min,i=e.max,a=0;a<t;a++){var o=r[a],s=o.normal;if(s.x*(s.x>=0?i.x:n.x)+s.y*(s.y>=0?i.y:n.y)+s.z*(s.z>=0?i.z:n.z)<-o.distance)return!1}return!0},ig.shadowCullFrustum=function(e,t,r,n){var i=r._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&r.castShadows&&ig.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._renderFrameCount=r.engine.time.frameCount,r._prepareRender(e))},ig.getBoundSphereByFrustum=function(e,t,r,n,i){var a,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(l9.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(a=t,o=t*c):(a=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=i.splitBoundSphere.center;i.splitBoundSphere.radius=o,ce.scale(n,a,_),ce.add(r.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},ig.getDirectionLightShadowCullPlanes=function(t,r,n,i,a){var o=ig._frustumCorners,s=ig._backPlaneFaces,l=ig._frustumPlaneNeighbors,c=ig._frustumTwoPlaneCorners,u=ig._edgePlanePoint2,d=a.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=ig._adjustNearPlane,y=ig._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+a.sphereCenterZ+a.splitBoundSphere.radius,_.distance),cn.intersectionPointThreePlanes(v,m,p,o[7]),cn.intersectionPointThreePlanes(v,g,p,o[6]),cn.intersectionPointThreePlanes(v,g,f,o[5]),cn.intersectionPointThreePlanes(v,m,f,o[4]),cn.intersectionPointThreePlanes(y,m,p,o[3]),cn.intersectionPointThreePlanes(y,g,p,o[2]),cn.intersectionPointThreePlanes(y,g,f,o[1]),cn.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,S=0;S<6;S++){var C=void 0;switch(S){case e.FrustumFace.Near:C=v;break;case e.FrustumFace.Far:C=y;break;default:C=t.getPlane(S)}0>ce.dot(C.normal,i)&&(d[x].copyFrom(C),s[x]=S,x++)}for(var T=x,A=0;A<x;A++)for(var E=s[A],M=l[E],R=0;R<4;R++){for(var w=M[R],b=!0,P=0;P<x;P++)if(w==s[P]){b=!1;break}if(b){var F=c[E][w],L=o[F[0]],D=o[F[1]];ce.add(L,i,u),ci.fromPoints(L,D,u,d[T++])}}a.cullPlaneCount=T},ig.getDirectionalLightMatrices=function(e,t,r,n,i,a,o,s){var l=o.splitBoundSphere;o.resolution=a;var c=l.center,u=l.radius,d=a/2,h=u*d/(d-ig.atlasBorderSize),_=2*h,f=a/_,p=_/a,m=Math.ceil(ce.dot(c,e)*f)*p,g=Math.ceil(ce.dot(c,t)*f)*p,v=ce.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,S=y.viewMatrix,C=y.projectionMatrix;ce.scale(r,u+i,x),ce.subtract(c,x,x),cl.lookAt(x,c,e,S),cl.ortho(-h,h,-h,h,0,2*u+i,C);var T=y.viewProjectionMatrix;cl.multiply(C,S,T),c2._floatMatrixMultiply(ig._shadowMapCoordMatrix,T.elements,0,s,16*n)},ig.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),i=Math.floor(e/n)*Math.floor(t/n);i<r;)i=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},ig.getShadowBias=function(t,r,n,i){var a=2/r.elements[0]/n,o=-t.shadowBias*a,s=-t.shadowNormalBias*a;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),i.set(o,s)},ig.applySliceTransform=function(e,t,r,n,i,a){var o=ig._tempMatrix0,s=o.elements,l=1/t,c=1/r,u=i.x*l,d=i.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]=u,s[13]=d,s[14]=0,s[15]=1;var h=16*n;c2._floatMatrixMultiply(o,a,h,a,h)},ig);hr._tempMatrix0=new cl,hr._shadowMapCoordMatrix=new cl(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),hr._frustumCorners=[new ce,new ce,new ce,new ce,new ce,new ce,new ce,new ce],hr._adjustNearPlane=new ci(new ce),hr._adjustFarPlane=new ci(new ce),hr._backPlaneFaces=[,,,,,],hr._edgePlanePoint2=new ce,hr._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]],hr._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]]],hr.atlasBorderSize=4;var hn=function(e){this._engine=e},hi=function(t){function r(n){var i;return(i=t.call(this,n.engine)||this)._shadowMapSize=new cd,i._shadowBias=new cu,i._shadowSliceData=new ht,i._lightUp=new ce,i._lightSide=new ce,i._existShadowMap=!1,i._splitBoundSpheres=new Float32Array(4*r._maxCascades),i._shadowMatrices=new Float32Array((r._maxCascades+1)*16),i._shadowInfos=new ce,i._viewportOffsets=[new cu,new cu,new cu,new cu],i._camera=n,i._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),i._shadowSliceData.virtualCamera.isOrthographic=!0,i}cx(r,t);var n=r.prototype;return n.onRender=function(e){this._updateShadowSettings(),this._existShadowMap=!1,this._renderDirectShadowMap(e),this._existShadowMap&&this._updateReceiversShaderData()},n._renderDirectShadowMap=function(t){var n=this._engine,i=this._camera,a=this._viewportOffsets,o=this._shadowSliceData,s=this._splitBoundSpheres,l=this._shadowMatrices,c=i._renderPipeline._cullingResults,u=c.opaqueQueue,d=c.alphaTestQueue,h=c.transparentQueue,_=i.scene,f=_._componentsManager,p=n._hardwareRenderer,m=_.shadowCascades,g=r._cascadesSplitDistance,v=o.splitBoundSphere,y=r._tempMatrix0,x=y.elements,S=this._lightUp,C=this._lightSide,T=o.virtualCamera.forward,A=i.scene._sunLight;if(A){var E,M,R=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(R);var w=this._shadowMapSize,b=w.z,P=w.w,F=this._shadowMapFormat;(M=this._supportDepthTexture?(E=d9.recreateRenderTargetIfNeeded(n,this._renderTarget,b,P,null,F,!1)).depthTexture:(E=d9.recreateRenderTargetIfNeeded(n,this._renderTarget,b,P,F,null,!1)).getColorTexture(0)).wrapModeU=M.wrapModeV=e.TextureWrapMode.Clamp,n._hardwareRenderer._isWebGL2&&(M.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=E,this._depthTexture=M,p.activeRenderTarget(E,r._viewport,0),this._supportDepthTexture?p.clearRenderTarget(n,e.CameraClearFlags.Depth,null):p.clearRenderTarget(n,e.CameraClearFlags.All,r._clearColor),this._shadowInfos.x=A.shadowStrength,this._shadowInfos.z=0,cl.rotationQuaternion(A.entity.transform.worldRotationQuaternion,y),C.set(x[0],x[1],x[2]),S.set(x[4],x[5],x[6]),T.set(-x[8],-x[9],-x[10]);var L=r._tempVector;L.copyFrom(i.entity.transform.worldForward);for(var D=this._shadowTileResolution,B=0;B<m;B++){hr.getBoundSphereByFrustum(g[B],g[B+1],i,L,o),hr.getDirectionLightShadowCullPlanes(i._frustum,g[B],i.nearClipPlane,T,o),hr.getDirectionalLightMatrices(S,C,T,B,A.shadowNearPlane,D,o,l),m>1&&hr.applySliceTransform(D,b,P,B,this._viewportOffsets[B],l),this._updateSingleShadowCasterShaderData(A,o,t);var I=v.center,V=v.radius,O=4*B;s[O]=I.x,s[O+1]=I.y,s[O+2]=I.z,s[O+3]=V*V,u.clear(),d.clear(),h.clear();for(var N=f._renderers,z=N._elements,U=N.length-1;U>=0;--U)hr.shadowCullFrustum(t,A,z[U],o);if(u.elements.length||d.elements.length){u.sort(d7._compareFromNearToFar),d.sort(d7._compareFromNearToFar);var k=a[B],G=k.x,H=k.y;p.setGlobalDepthBias(1,1),p.viewport(G,H,D,D),p.scissor(G+1,H+1,D-2,D-2),n._renderCount++,u.render(i,e.Layer.Everything,e.PipelineStage.ShadowCaster),d.render(i,e.Layer.Everything,e.PipelineStage.ShadowCaster),p.setGlobalDepthBias(0,0)}}this._existShadowMap=!0}},n._updateReceiversShaderData=function(){var e=this._camera.scene,t=this._splitBoundSpheres,n=this._shadowMatrices,i=e.shadowCascades;if(i>1)for(var a=4*i,o=t.length;a<o;a++)t[a]=0;for(var s=16*i,l=n.length;s<l;s++)n[s]=0;var c=e.shaderData;c.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),c.setVector3(r._shadowInfosProperty,this._shadowInfos),c.setTexture(r._shadowMapsProperty,this._depthTexture),c.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),c.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,i=this._camera.scene,a=i.shadowTwoCascadeSplits,o=i.shadowFourCascadeSplits,s=i.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,d=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*l9.degreeToRadian(d)),f=1+_*_*(u*u+1);switch(s){case e.ShadowCascadesMode.NoCascades:n[1]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.TwoCascades:n[1]=this._getFarWithRadius(c+h*a,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.scene,r=hr.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),n=hr.shadowResolution(t.shadowResolution),i=t.shadowCascades;if(r!==this._shadowMapFormat||n!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=r,this._shadowMapResolution=n,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=n,this._shadowMapSize.set(1/n,1/n,n,n);else{var a=hr.getMaxTileResolutionInAtlas(n,n,i);this._shadowTileResolution=a;var o=2*a,s=i==e.ShadowCascadesMode.TwoCascades?a:2*a;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTarget=null;var l=this._viewportOffsets,c=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(c,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(c,0),l[2].set(0,c),l[3].set(c,c)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var i=t.virtualCamera;hr.getShadowBias(e,i.projectionMatrix,this._shadowTileResolution,this._shadowBias);var a=this._camera.scene.shaderData;a.setVector2(r._lightShadowBiasProperty,this._shadowBias),a.setVector3(r._lightDirectionProperty,e.direction),n.applyVirtualCamera(i)},r}(hn);hi._lightShadowBiasProperty=cQ.getByName("scene_ShadowBias"),hi._lightDirectionProperty=cQ.getByName("scene_LightDirection"),hi._shadowMatricesProperty=cQ.getByName("scene_ShadowMatrices"),hi._shadowMapSize=cQ.getByName("scene_ShadowMapSize"),hi._shadowInfosProperty=cQ.getByName("scene_ShadowInfo"),hi._shadowMapsProperty=cQ.getByName("scene_ShadowMap"),hi._shadowSplitSpheresProperty=cQ.getByName("scene_ShadowSplitSpheres"),hi._maxCascades=4,hi._cascadesSplitDistance=Array(hi._maxCascades+1),hi._viewport=new cd(0,0,1,1),hi._clearColor=new ch(1,1,1,1),hi._tempVector=new ce,hi._tempMatrix0=new cl;var ha=((iy=(iv=function(t){this.opaqueQueue=new d7(t,e.RenderQueueType.Opaque),this.transparentQueue=new d7(t,e.RenderQueueType.Transparent),this.alphaTestQueue=new d7(t,e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},iy.sort=function(){this.opaqueQueue.sort(d7._compareFromNearToFar),this.alphaTestQueue.sort(d7._compareFromNearToFar),this.transparentQueue.sort(d7._compareFromFarToNear)},iy.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},iv),ho=(cx(ix=function(t){var r;return(r=hn.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},hn),(iS=ix.prototype).onConfig=function(t){var r=this._engine,n=t.pixelViewport,i=n.width,a=n.height,o=d9.recreateRenderTargetIfNeeded(r,this._renderTarget,i,a,null,e.TextureFormat.Depth16,!1),s=o.depthTexture;s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Clamp,s.filterMode=e.TextureFilterMode.Point,this._renderTarget=o},iS.onRender=function(t,r){var n=this._engine,i=this._renderTarget,a=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(i,a.viewport,0),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),o.viewport(0,0,i.width,i.height),o.scissor(0,0,i.width,i.height),r.opaqueQueue.render(a,e.Layer.Everything,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(a,e.Layer.Everything,e.PipelineStage.DepthOnly),a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},ix),hs=((iT=(iC=function(e){this._allSpriteMasks=new c1,this._lastCanvasSize=new cu,this._camera=e;var t=e.engine;this._cullingResults=new ha(t),this._cascadedShadowCaster=new hi(e),this._depthOnlyPass=new ho(t),this._renderPassArray=[],this._defaultPass=new d8("default",0,null,null,0),this.addRenderPass(this._defaultPass)}).prototype).addRenderPass=function(e,t,r,n,i){if(void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===i&&(i=null),"string"==typeof e){var a=new d8(e,t,r,n,i);this._renderPassArray.push(a)}else cA(e,d8)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},iT.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):cA(e,d8)&&(t=e),t){var r=this._renderPassArray.indexOf(t);this._renderPassArray.splice(r,1)}},iT.getRenderPass=function(e){for(var t=0,r=this._renderPassArray.length;t<r;t++){var n=this._renderPassArray[t];if(n.name===e)return n}return null},iT.destroy=function(){this._cullingResults.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},iT.render=function(t,r,n){var i,a=this._camera,o=a.scene,s=this._cullingResults;a.engine._spriteMaskManager.clear(),o.castShadows&&(null==(i=o._sunLight)?void 0:i.shadowType)!==e.ShadowType.None&&this._cascadedShadowCaster.onRender(t),s.reset(),this._allSpriteMasks.length=0,t.applyVirtualCamera(a._virtualCamera),this._callRender(t),s.sort();var l=this._depthOnlyPass;a.depthTextureMode===e.DepthTextureMode.PrePass&&l._supportDepthTexture?(l.onConfig(a),l.onRender(t,s)):a.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,a.engine._whiteTexture2D);for(var c=0,u=this._renderPassArray.length;c<u;c++)this._drawRenderPass(t,this._renderPassArray[c],a,r,n)},iT._drawRenderPass=function(t,r,n,i,a){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue;if(r.preRender(n,s,l,c),r.enabled){var u,d,h=n.engine,_=n.scene.background,f=h._hardwareRenderer,p=n.renderTarget||r.renderTarget;f.activeRenderTarget(p,n.viewport,a),null==p||p._setRenderTargetInfo(i,a);var m=null!=(u=r.clearFlags)?u:n.clearFlags,g=null!=(d=r.clearColor)?d:_.solidColor;m!==e.CameraClearFlags.None&&f.clearRenderTarget(n.engine,m,g),r.renderOverride?r.render(n,s,l,c):(s.render(n,r.mask,e.PipelineStage.Forward),l.render(n,r.mask,e.PipelineStage.Forward),n.clearFlags&e.CameraClearFlags.Color&&(_.mode===e.BackgroundMode.Sky?_.sky._render(t):_.mode===e.BackgroundMode.Texture&&_.texture&&this._drawBackgroundTexture(h,_)),o.transparentQueue.render(n,r.mask,e.PipelineStage.Forward)),null==p||p._blitRenderTarget(),null==p||p.generateMipmaps()}r.postRender(n,o.opaqueQueue,o.alphaTestQueue,o.transparentQueue)},iT.pushRenderData=function(e,t){var r=t.material,n=r.renderStates,i=r.shader.subShaders[0],a=e.replacementShader;if(a){var o=a.subShaders,s=e.replacementTag;if(s)for(var l=0,c=o.length;l<c;l++){var u=o[l];if(u.getTagValue(s)===i.getTagValue(s)){this.pushRenderDataWithShader(e,t,u.passes,n);break}}else this.pushRenderDataWithShader(e,t,o[0].passes,n)}else this.pushRenderDataWithShader(e,t,i.passes,n)},iT.pushRenderDataWithShader=function(t,r,n,i){for(var a=this._cullingResults,o=a.opaqueQueue,s=a.alphaTestQueue,l=a.transparentQueue,c=t.camera.engine._renderElementPool,u=0,d=0,h=n.length;d<h;d++){var _,f=(null!=(_=n[d]._renderState)?_:i[d]).renderQueueType;if(!(u&1<<f)){var p=c.getFromPool();switch(p.set(r,n),f){case e.RenderQueueType.Opaque:o.pushRenderElement(p),u|=1;break;case e.RenderQueueType.AlphaTest:s.pushRenderElement(p),u|=2;break;case e.RenderQueueType.Transparent:l.pushRenderElement(p),u|=4}}}},iT._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,i=t.canvas,a=r._material,o=r._mesh;(this._lastCanvasSize.x!==i.width||this._lastCanvasSize.y!==i.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(i.width,i.height),r._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,ux._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,a.shaderData),l.uploadUnGroupTextures(),(s._renderState||a.renderState)._apply(t,!1,s._renderStateDataMap,a.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},iT._callRender=function(e){for(var t=e.camera.engine,r=e.camera,n=r.scene._componentsManager._renderers,i=n._elements,a=n.length-1;a>=0;--a){var o=i[a];r.cullingMask&o._entity.layer&&(!r.enableFrustumCulling||r._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},cv(iC,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),iC);(iA=lG||(lG={}))[iA.None=0]="None",iA[iA.Opaque=1]="Opaque",iA[iA.AlphaTest=2]="AlphaTest",iA[iA.Transparent=4]="Transparent";var hl=function(){};hl.tempVec4=new cd,hl.tempVec3=new ce,hl.tempVec2=new cu,e.Camera=(cx(iE=function(t){(r=cJ.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r._globalShaderMacro=new un,r._frustum=new ca,r._virtualCamera=new he,r._replacementShader=null,r._replacementSubShaderTag=null,r._priority=0,r._shaderData=new uS(lT.Camera),r._isProjMatSetting=!1,r._nearClipPlane=.1,r._farClipPlane=100,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._isFrustumProjectDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new cd,r._viewport=new cd(0,0,1,1),r._pixelViewport=new c_(0,0,0,0),r._inverseProjectionMatrix=new cl,r._invViewProjMat=new cl;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumViewChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new hs(cm(r)),r.shaderData._addReferCount(1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(cm(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},cJ),(iM=iE.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},iM.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},iM.worldToViewportPoint=function(e,t){var r=hl.tempVec3,n=hl.tempVec4;ce.transformCoordinate(e,this.viewMatrix,r),ce.transformToVec4(r,this.projectionMatrix,n);var i=n.w;return t.set((n.x/i+1)*.5,(1-n.y/i)*.5,-r.z),t},iM.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,i=this.farClipPlane,a=1/(n-i);if(this.isOrthographic)r=-(2*e.z)*a+(i+n)*a;else{var o=e.z;r=(-o*(n+i)*a+2*n*i*a)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},iM.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),i=this._innerViewportToWorldPoint(e.x,e.y,1-l9.zeroTolerance,r,t.direction);return ce.subtract(i,n,i),i.normalize(),t},iM.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},iM.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},iM.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},iM.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},iM.screenPointToRay=function(e,t){var r=hl.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},iM.render=function(e,t){void 0===t&&(t=0);var r=this.engine._renderContext,n=this._virtualCamera,i=this.entity.transform;cl.multiply(this.projectionMatrix,this.viewMatrix,n.viewProjectionMatrix),n.position.copyFrom(i.worldPosition),n.isOrthographic&&n.forward.copyFrom(i.worldForward),r.camera=this,r.virtualCamera=n,r.replacementShader=this._replacementShader,r.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&(this._frustumViewChangeFlag.flag||this._isFrustumProjectDirty)&&(this._frustum.calculateFromMatrix(n.viewProjectionMatrix),this._frustumViewChangeFlag.flag=!1,this._isFrustumProjectDirty=!1),this._updateShaderData(),un.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,cz.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(r,e,t),this._engine._renderCount++},iM.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?us.getByName(t):t},iM.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},iM._onEnableInScene=function(){this.scene._attachRenderCamera(this)},iM._onDisableInScene=function(){this.scene._detachRenderCamera(this)},iM._onDestroy=function(){var e;cJ.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addReferCount(-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._frustumViewChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},iM._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 i=this._viewport;this._pixelViewport.set(i.x*e,i.y*t,i.z*e,i.w*t)},iM._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},iM._innerViewportToWorldPoint=function(e,t,r,n,i){var a=hl.tempVec3;return a.set(2*e-1,1-2*t,2*r-1),ce.transformCoordinate(a,n,i),i},iM._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,i=this._farClipPlane/this._nearClipPlane;n.set(1-i,i,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},iM._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,cl.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},iM._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,cl.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},iM._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projMatChange()},cv(iE,[{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._nearClipPlane},set:function(e){this._nearClipPlane=e,this._projMatChange()}},{key:"farClipPlane",get:function(){return this._farClipPlane},set:function(e){this._farClipPlane=e,this._projMatChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projMatChange()}},{key:"aspectRatio",get:function(){var e,t=this._entity.engine.canvas;return null!=(e=this._customAspectRatio)?e:t.width*this._viewport.z/(t.height*this._viewport.w)},set:function(e){this._customAspectRatio=e,this._projMatChange()}},{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._entity._isActiveInScene&&this.enabled&&(this.scene._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projMatChange()}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projMatChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(this._isViewMatrixDirty.flag){this._isViewMatrixDirty.flag=!1;var t=this._transform;cl.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert()}return e}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isProjMatSetting)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,i=this._orthographicSize;cl.ortho(-n,n,-i,i,this._nearClipPlane,this._farClipPlane,t)}else cl.perspective(l9.degreeToRadian(this._fieldOfView),r,this._nearClipPlane,this._farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isProjMatSetting=!0,this._projMatChange()}},{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){if(this._renderTarget!==e){var t;null==e||e._addReferCount(1),null==(t=this._renderTarget)||t._addReferCount(-1),this._renderTarget=e,this._onPixelViewportChanged()}}}]),iE._cameraDepthTextureProperty=cQ.getByName("camera_DepthTexture"),iE._inverseViewMatrixProperty=cQ.getByName("camera_ViewInvMat"),iE._cameraPositionProperty=cQ.getByName("camera_Position"),iE._cameraForwardProperty=cQ.getByName("camera_Forward"),iE._cameraUpProperty=cQ.getByName("camera_Up"),iE._cameraDepthBufferParamsProperty=cQ.getByName("camera_DepthBufferParams"),iE),cT([cw],e.Camera.prototype,"_frustum",void 0),cT([cE],e.Camera.prototype,"_renderPipeline",void 0),cT([cE],e.Camera.prototype,"_virtualCamera",void 0),cT([cE],e.Camera.prototype,"_frustumViewChangeFlag",void 0),cT([cE],e.Camera.prototype,"_transform",void 0),cT([cE],e.Camera.prototype,"_isViewMatrixDirty",void 0),cT([cE],e.Camera.prototype,"_isInvViewProjDirty",void 0),cT([cw],e.Camera.prototype,"_viewport",void 0),cT([cw],e.Camera.prototype,"_pixelViewport",void 0),cT([cw],e.Camera.prototype,"_inverseProjectionMatrix",void 0),cT([cw],e.Camera.prototype,"_invViewProjMat",void 0),cT([cE],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=cT([c0(c7,e.DependentMode.CheckOnly)],e.Camera);var hc={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hu=1/0;function hd(e,t){return void 0===t&&(t={}),new dt(function(r,n,i){var a,o,s,l,c=null!=(a=t.retryCount)?a:1,u=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:hu,t.type=null!=(l=t.type)?l:hc[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?hh:h_;new hf(function(){return d(e,t).onProgress(i)},c,u).start().onError(n).onComplete(r)})}function hh(e,t){return new dt(function(r,n){var i,a=t.timeout,o=new Image,s=function(){n(Error("request "+e+" fail"))};o.onerror=s,o.onabort=s;var l=-1;a!=1/0&&(l=window.setTimeout(function(){n(Error("request "+e+" timeout"))},a)),o.onload=(i=l,function(){requestAnimationFrame(function(){r(o),o.onload=null,o.onerror=null,o.onabort=null}),clearTimeout(i)}),o.crossOrigin="anonymous",o.src=e})}function h_(e,t){return new dt(function(r,n,i){var a,o=new XMLHttpRequest;o.timeout=t.timeout,t.method=null!=(a=t.method)?a:"get",o.onload=function(){var t;if(o.status<200||o.status>=300){n(Error("request failed from: "+e));return}r(null!=(t=o.response)?t:o.responseText)},o.onerror=function(){n(Error("request failed from: "+e))},o.ontimeout=function(){n(Error("request timeout from: "+e))},o.onprogress=function(e){i(e.loaded/e.total)},o.open(t.method,e,!0),o.withCredentials="include"===t.credentials,o.responseType=t.type;var s=t.headers;s&&Object.keys(s).forEach(function(e){o.setRequestHeader(e,s[e])}),o.send(t.body)})}var hf=((iw=(iR=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},iw.onComplete=function(e){return this._onComplete=e,this},iw.onError=function(e){return this._onError=e,this},iw.cancel=function(){window.clearTimeout(this._timeoutId)},iw.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)})},iR),hp=((ib=function(e){this.useCache=e,this.request=hd}).registerClass=function(e,t){this._engineObjects[e]=t},ib.getClass=function(e){return this._engineObjects[e]},ib);hp._engineObjects={},e.BlendMode=void 0,(iP=e.BlendMode||(e.BlendMode={}))[iP.Normal=0]="Normal",iP[iP.Additive=1]="Additive",e.RenderFace=void 0,(iF=e.RenderFace||(e.RenderFace={}))[iF.Front=0]="Front",iF[iF.Back=1]="Back",iF[iF.Double=2]="Double";var hm=function(t){function r(n,i){var a;return(a=t.call(this,n,i)||this)._renderFace=e.RenderFace.Front,a._isTransparent=!1,a._blendMode=e.BlendMode.Normal,a.shaderData.setFloat(r._alphaCutoffProp,0),a}cx(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var i=this.renderStates;if(i.length<t)throw"Pass should less than pass count.";var a=i[t];n?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(r._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.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 i=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.One,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.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},cv(r,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader=t;for(var r=this._renderStates,n=r.length,i=0,a=t.subShaders,o=0;o<a.length;o++)i=Math.max(a[o].passes.length,i);if(n<i)for(var s=n;s<i;s++)r.push(new uy),this.setBlendMode(s,e.BlendMode.Normal);else r.length=i}},{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 i=this.renderStates,a=0,o=i.length;a<o;a++){var s=i[a];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}(dD);hm._baseTextureMacro=ur.getByName("MATERIAL_HAS_BASETEXTURE"),hm._normalTextureMacro=ur.getByName("MATERIAL_HAS_NORMALTEXTURE"),hm._emissiveTextureMacro=ur.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),hm._transparentMacro=ur.getByName("MATERIAL_IS_TRANSPARENT"),hm._baseColorProp=cQ.getByName("material_BaseColor"),hm._baseTextureProp=cQ.getByName("material_BaseTexture"),hm._tilingOffsetProp=cQ.getByName("material_TilingOffset"),hm._normalTextureProp=cQ.getByName("material_NormalTexture"),hm._normalIntensityProp=cQ.getByName("material_NormalIntensity"),hm._emissiveColorProp=cQ.getByName("material_EmissiveColor"),hm._emissiveTextureProp=cQ.getByName("material_EmissiveTexture"),hm._alphaCutoffProp=cQ.getByName("material_AlphaCutoff"),hm._alphaCutoffMacro=ur.getByName("MATERIAL_IS_ALPHA_CUTOFF");var hg=function(e){function t(r){var n,i=(n=e.call(this,r,ux.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new ch(1,1,1,1)),i.setColor(t._specularColorProp,new ch(1,1,1,1)),i.setColor(t._emissiveColorProp,new ch(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new cd(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),n}return cx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cv(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}(hm);hg._specularColorProp=cQ.getByName("material_SpecularColor"),hg._shininessProp=cQ.getByName("material_Shininess"),hg._specularTextureProp=cQ.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(iL=e.TextureCoordinate||(e.TextureCoordinate={}))[iL.UV0=0]="UV0",iL[iL.UV1=1]="UV1",iL[iL.UV2=2]="UV2",iL[iL.UV3=3]="UV3",iL[iL.UV4=4]="UV4",iL[iL.UV5=5]="UV5",iL[iL.UV6=6]="UV6",iL[iL.UV7=7]="UV7";var hv=function(t){function r(n,i){var a,o=(a=t.call(this,n,i)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new ch(1,1,1,1)),o.setColor(r._emissiveColorProp,new ch(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new cd(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),a}return cx(r,t),cv(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&&cz.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}(hm);hv._occlusionTextureIntensityProp=cQ.getByName("material_OcclusionIntensity"),hv._occlusionTextureCoordProp=cQ.getByName("material_OcclusionTextureCoord"),hv._occlusionTextureProp=cQ.getByName("material_OcclusionTexture"),hv._clearCoatProp=cQ.getByName("material_ClearCoat"),hv._clearCoatTextureProp=cQ.getByName("material_ClearCoatTexture"),hv._clearCoatRoughnessProp=cQ.getByName("material_ClearCoatRoughness"),hv._clearCoatRoughnessTextureProp=cQ.getByName("material_ClearCoatRoughnessTexture"),hv._clearCoatNormalTextureProp=cQ.getByName("material_ClearCoatNormalTexture");var hy=function(e){function t(r){var n;return(n=e.call(this,r,ux.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),n.shaderData.setFloat(t._roughnessProp,1),n.shaderData.setFloat(t._iorProp,1.5),n}return cx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cv(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")}}]),t}(hv);hy._metallicProp=cQ.getByName("material_Metal"),hy._roughnessProp=cQ.getByName("material_Roughness"),hy._roughnessMetallicTextureProp=cQ.getByName("material_RoughnessMetallicTexture"),hy._iorProp=ux.getPropertyByName("material_IOR");var hx=function(e){function t(r){var n;return(n=e.call(this,r,ux.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new ch(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return cx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cv(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}(hv);hx._specularColorProp=cQ.getByName("material_PBRSpecularColor"),hx._glossinessProp=cQ.getByName("material_Glossiness"),hx._specularGlossinessTextureProp=cQ.getByName("material_SpecularGlossinessTexture"),hx._specularGlossinessTextureMacro=ur.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var hS=function(e){function t(r){var n,i=(n=e.call(this,r,ux.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new ch(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new cd(1,1,0,0)),n}return cx(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},cv(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}(hm),hC=((iB=(iD=function(){}).prototype).initialize=function(e){for(var t=e.component,r=e.property.split("."),n=r.length-1,i=0;i<n;i++)t=t[r[i]];this._mounted=t,this._propertyName=r[n]},iB.getTargetValue=function(){return this._mounted[this._propertyName]},iB.setTargetValue=function(e){this._mounted[this._propertyName]=e},iD),hT=function(){function e(t,r,n,i,a){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=i,this.component=n,this.cureType=a,this._isBlendShape=cA(this.component,u2);var o=e.getAssemblerType(r,i);this._assembler=new o,this._assembler.initialize(this),a._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,i,a){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?a?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):a?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?a?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,i)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var i=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,a=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(i,a,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 i=this._assembler;if(n._isCopyMode){var a=n._additiveValue(e,t,this.referenceTargetValue);this._isBlendShape&&i.setTargetValue(a)}else{var o=i.getTargetValue(),s=n._additiveValue(e,t,o);i.setTargetValue(s)}}else if(1===t)n._isCopyMode?(n._setValue(e,this.referenceTargetValue),this._isBlendShape&&this._assembler.setTargetValue(this.referenceTargetValue)):this._assembler.setTargetValue(e);else if(n._isCopyMode){var l=this.referenceTargetValue;n._lerpValue(l,e,t,l),this._isBlendShape&&this._assembler.setTargetValue(l)}else{var c=this._assembler.getTargetValue(),u=n._lerpValue(c,e,t);this._assembler.setTargetValue(u)}},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 i=e._assemblerMap.get(t);i||(i={},e._assemblerMap.set(t,i)),i[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),i=n?n[r]:void 0;return null!=i?i:hC},e}();hT._assemblerMap=new Map;var hA=((iV=(iI=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iV.getTargetValue=function(){return this._transform.position},iV.setTargetValue=function(e){this._transform.position=e},iI);hT.registerAssembler(c7,"position",hA);var hE=((iN=(iO=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iN.getTargetValue=function(){return this._transform.rotationQuaternion},iN.setTargetValue=function(e){this._transform.rotationQuaternion=e},iO);hT.registerAssembler(c7,"rotationQuaternion",hE);var hM=((iU=(iz=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iU.getTargetValue=function(){return this._transform.scale},iU.setTargetValue=function(e){this._transform.scale=e},iz);hT.registerAssembler(c7,"scale",hM);var hR=((iG=(ik=function(){this._skinnedMeshRenderer=[]}).prototype).initialize=function(e){e.target.getComponents(u2,this._skinnedMeshRenderer)},iG.getTargetValue=function(){return this._skinnedMeshRenderer[0].blendShapeWeights},iG.setTargetValue=function(e){for(var t=this._skinnedMeshRenderer,r=0,n=t.length;r<n;r++)t[r].blendShapeWeights=e},ik);hT.registerAssembler(u2,"blendShapeWeights",hR);var hw=((iW=(iH=function(){this.crossCurveMark=0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},iW.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},iH),hb=((iK=(iX=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new hT(e,this.type,t,this.property,r);return r._initializeOwner(n),n.saveDefaultValue(),n},iK._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new hw;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},iK._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},iX),hP=function(){},hF=(cx(ij=function(e){var t;return(t=cP.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new c6,t._length=0,t._events=[],t},cP),(iY=ij.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,i=new hP;i.functionName=e,i.time=t,i.parameter=r,n=i}else n=e;var a=this._events,o=a.length,s=n.time;if(s>=(o?a[o-1].time:0))a.push(n);else{for(var l=o;--l>=0&&s<a[l].time;);a.splice(l+1,0,n)}this._updateFlagManager.dispatch()},iY.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},iY.addCurveBinding=function(e,t,r,n){var i=new hb;i.relativePath=e,i.type=t,i.property=r,i.curve=n,n.length>this._length&&(this._length=n.length),this._curveBindings.push(i)},iY.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iY._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var i=r[n],a=e.findByPath(i.relativePath);if(a){var o=a.getComponent(i.type);if(!o)continue;var s=i._getTempCurveOwner(a,o);if(s&&i.curve.keys.length){var l=s.evaluateValue(i.curve,t,!1);s.applyValue(l,1,!1)}}}},cv(ij,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),ij);e.InterpolationType=void 0,(iq=e.InterpolationType||(e.InterpolationType={}))[iq.Linear=0]="Linear",iq[iq.CubicSpine=1]="CubicSpine",iq[iq.Step=2]="Step",iq[iq.Hermite=3]="Hermite";var hL=((iZ=(iQ=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)}},iZ.evaluate=function(e){return this._evaluate(e,this._evaluateData)},iZ.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var i=t[n];i.time>this._length&&(r=i.time)}this._length=r},iZ._evaluate=function(t,r){var n,i=this.keys.length;if(!i){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=i||t<a[s].time)&&(s=-1);for(var l=s+1;l<i&&!(t<a[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(a[0].value,r.value);else if(l===i)n=this._type._setValue(a[s].value,r.value);else{var c=a[s],u=a[l],d=c.time,h=u.time-d,_=(t-d)/h;switch(o){case e.InterpolationType.Linear:n=this._type._lerpValue(c.value,u.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,u,_,h,r.value)}}return r.value=n,n},iZ._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},cv(iQ,[{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}}]),iQ);e.AnimationArrayCurve=(cx(iJ=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=[],e},hL),iJ._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iJ._initializeLayerOwner=function(e){e.finalValue=[]},iJ._lerpValue=function(e,t,r,n){for(var i=0,a=n.length;i<a;++i){var o=e[i];n[i]=o+(t[i]-o)*r}return n},iJ._subtractValue=function(e,t,r){for(var n=0,i=e.length;n<i;n++)r[n]=e[n]-t[n];return r},iJ._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},iJ._additiveValue=function(e,t,r){for(var n=0,i=r.length;n<i;++n)r[n]+=e[n]*t;return r},iJ._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},iJ._hermiteInterpolationValue=function(e,t,r,n,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*n+_*o[p]*n+f*l[p]:i[p]=e.value[p];return i},iJ._isCopyMode=!0,iJ._supportInterpolationMode=!0,iJ),e.AnimationArrayCurve=cT([uE()],e.AnimationArrayCurve),e.AnimationBoolCurve=(cx(i$=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=!1,e},hL),i$._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},i$._initializeLayerOwner=function(e){e.finalValue=!1},i$._lerpValue=function(e,t){return e},i$._subtractValue=function(e,t,r){return e},i$._getZeroValue=function(){return!1},i$._additiveValue=function(e,t,r){return e},i$._setValue=function(e){return e},i$._hermiteInterpolationValue=function(e){return e.value},i$._isCopyMode=!1,i$._supportInterpolationMode=!1,i$),e.AnimationBoolCurve=cT([uE()],e.AnimationBoolCurve),e.AnimationColorCurve=(cx(i0=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new ch,e},hL),i0._initializeOwner=function(e){e.defaultValue=new ch,e.fixedPoseValue=new ch,e.baseEvaluateData.value=new ch,e.crossEvaluateData.value=new ch},i0._initializeLayerOwner=function(e){e.finalValue=new ch},i0._lerpValue=function(e,t,r,n){return ch.lerp(e,t,r,n),n},i0._subtractValue=function(e,t,r){return ch.subtract(e,t,r),r},i0._getZeroValue=function(e){return e.set(0,0,0,0),e},i0._additiveValue=function(e,t,r){return ch.scale(e,t,e),ch.add(r,e,r),r},i0._setValue=function(e,t){return t.copyFrom(e),t},i0._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.r=d*a.r+h*p*n+_*m*n+f*s.r:i.r=a.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.g=d*a.g+h*p*n+_*m*n+f*s.g:i.g=a.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.b=d*a.b+h*p*n+_*m*n+f*s.b:i.b=a.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.a=d*a.a+h*p*n+_*m*n+f*s.a:i.a=a.a,i},i0._isCopyMode=!0,i0._supportInterpolationMode=!0,i0),e.AnimationColorCurve=cT([uE()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(cx(i1=function(){return hL.apply(this,arguments)},hL),i1.prototype.addKey=function(e){hL.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)}},i1._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)},i1._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},i1._lerpValue=function(e,t,r,n){for(var i=0,a=n.length;i<a;++i){var o=e[i];n[i]=o+(t[i]-o)*r}return n},i1._subtractValue=function(e,t,r){for(var n=0,i=e.length;n<i;n++)r[n]=e[n]-t[n];return r},i1._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},i1._additiveValue=function(e,t,r){for(var n=0,i=r.length;n<i;++n)r[n]+=e[n]*t;return r},i1._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},i1._hermiteInterpolationValue=function(e,t,r,n,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=0,m=s.length;p<m;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=d*s[p]+h*a[p]*n+_*o[p]*n+f*l[p]:i[p]=e.value[p];return i},i1._isCopyMode=!0,i1._supportInterpolationMode=!0,i1),e.AnimationFloatArrayCurve=cT([uE()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(cx(i2=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=0,e},hL),i2._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},i2._initializeLayerOwner=function(e){e.finalValue=0},i2._lerpValue=function(e,t,r){return e+(t-e)*r},i2._additiveValue=function(e,t,r){return r+e*t},i2._subtractValue=function(e,t){return e-t},i2._getZeroValue=function(){return 0},i2._setValue=function(e){return e},i2._hermiteInterpolationValue=function(e,t,r,n){var i=e.outTangent,a=t.inTangent;if(!(Number.isFinite(i)&&Number.isFinite(a)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*i*n+(s-o)*a*n+(-2*s+3*o)*t.value},i2._isCopyMode=!1,i2._supportInterpolationMode=!0,i2),e.AnimationFloatCurve=cT([uE()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(cx(i3=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new cs,e},hL),i3._initializeOwner=function(e){e.defaultValue=new cs,e.fixedPoseValue=new cs,e.baseEvaluateData.value=new cs,e.crossEvaluateData.value=new cs},i3._initializeLayerOwner=function(e){e.finalValue=new cs},i3._lerpValue=function(e,t,r,n){return cs.slerp(e,t,r,n),n},i3._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},i3._subtractValue=function(t,r,n){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return cs.conjugate(r,i),cs.multiply(i,t,n),n},i3._getZeroValue=function(e){return e.set(0,0,0,1),e},i3._setValue=function(e,t){return t.copyFrom(e),t},i3._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*n+_*m*n+f*s.w:i.w=a.w,i},i3._supportInterpolationMode=!0,i3._isCopyMode=!0,i3._tempConjugateQuat=new cs,i3),e.AnimationQuaternionCurve=cT([uE()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(cx(i4=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new cu,e},hL),i4._initializeOwner=function(e){e.defaultValue=new cu,e.fixedPoseValue=new cu,e.baseEvaluateData.value=new cu,e.crossEvaluateData.value=new cu},i4._initializeLayerOwner=function(e){e.finalValue=new cu},i4._lerpValue=function(e,t,r,n){return cu.lerp(e,t,r,n),n},i4._additiveValue=function(e,t,r){return cu.scale(e,t,e),cu.add(r,e,r),r},i4._subtractValue=function(e,t,r){return cu.subtract(e,t,r),r},i4._getZeroValue=function(e){return e.set(0,0),e},i4._setValue=function(e,t){return t.copyFrom(e),t},i4._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,i},i4._isCopyMode=!0,i4._supportInterpolationMode=!0,i4),e.AnimationVector2Curve=cT([uE()],e.AnimationVector2Curve),e.AnimationVector3Curve=(cx(i5=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new ce,e},hL),i5._initializeOwner=function(e){e.defaultValue=new ce,e.fixedPoseValue=new ce,e.baseEvaluateData.value=new ce,e.crossEvaluateData.value=new ce},i5._initializeLayerOwner=function(e){e.finalValue=new ce},i5._lerpValue=function(e,t,r,n){return ce.lerp(e,t,r,n),n},i5._relativeBaseValue=function(e,t){return ce.subtract(t,e,t),t},i5._additiveValue=function(e,t,r){return ce.scale(e,t,e),ce.add(r,e,r),r},i5._subtractValue=function(e,t,r){return ce.subtract(e,t,r),r},i5._getZeroValue=function(e){return e.set(0,0,0),e},i5._setValue=function(e,t){return t.copyFrom(e),t},i5._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,i},i5._isCopyMode=!0,i5._supportInterpolationMode=!0,i5),e.AnimationVector3Curve=cT([uE()],e.AnimationVector3Curve),e.AnimationVector4Curve=(cx(i8=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new cd,e},hL),i8._initializeOwner=function(e){e.defaultValue=new cd,e.fixedPoseValue=new cd,e.baseEvaluateData.value=new cd,e.crossEvaluateData.value=new cd},i8._initializeLayerOwner=function(e){e.finalValue=new cd},i8._lerpValue=function(e,t,r,n){return cd.lerp(e,t,r,n),n},i8._additiveValue=function(e,t,r){return cd.scale(e,t,e),cd.add(r,e,r),r},i8._subtractValue=function(e,t,r){return cd.subtract(e,t,r),r},i8._getZeroValue=function(e){return e.set(0,0,0,0),e},i8._setValue=function(e,t){return t.copyFrom(e),t},i8._hermiteInterpolationValue=function(e,t,r,n,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,u=c*r,d=2*u-3*c+1,h=u-2*c+r,_=u-c,f=-2*u+3*c,p=o.x,m=l.x;return Number.isFinite(p)&&Number.isFinite(m)?i.x=d*a.x+h*p*n+_*m*n+f*s.x:i.x=a.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?i.y=d*a.y+h*p*n+_*m*n+f*s.y:i.y=a.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?i.z=d*a.z+h*p*n+_*m*n+f*s.z:i.z=a.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?i.w=d*a.w+h*p*n+_*m*n+f*s.w:i.w=a.w,i},i8._isCopyMode=!0,i8._supportInterpolationMode=!0,i8),e.AnimationVector4Curve=cT([uE()],e.AnimationVector4Curve),e.AnimationRefCurve=(cx(i6=function(){return hL.call(this)},hL),i6._initializeOwner=function(e){},i6._initializeLayerOwner=function(e){},i6._setValue=function(e){return e},i6._isCopyMode=!1,i6._supportInterpolationMode=!1,i6),e.AnimationRefCurve=cT([uE()],e.AnimationRefCurve),e.AnimationRectCurve=(cx(i7=function(){var e;return(e=hL.call(this)||this)._evaluateData.value=new c_,e},hL),i7._initializeOwner=function(e){e.defaultValue=new c_,e.fixedPoseValue=new c_,e.baseEvaluateData.value=new c_,e.crossEvaluateData.value=new c_},i7._initializeLayerOwner=function(e){e.finalValue=new c_},i7._setValue=function(e,t){return t.copyFrom(e),t},i7._isCopyMode=!0,i7._supportInterpolationMode=!1,i7),e.AnimationRectCurve=cT([uE()],e.AnimationRectCurve),e.AnimatorCullingMode=void 0,(i9=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[i9.None=0]="None",i9[i9.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(ae=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[ae.Override=0]="Override",ae[ae.Additive=1]="Additive",(at=lH||(lH={}))[at.UnStarted=0]="UnStarted",at[at.Playing=1]="Playing",at[at.Finished=2]="Finished",(ar=lW||(lW={}))[ar.Standby=0]="Standby",ar[ar.Playing=1]="Playing",ar[ar.CrossFading=2]="CrossFading",ar[ar.FixedCrossFading=3]="FixedCrossFading",ar[ar.Finished=4]="Finished";var hD=((an=function(){this.handlers=[]}).prototype.dispose=function(){},an),hB=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(ai=e.WrapMode||(e.WrapMode={}))[ai.Once=0]="Once",ai[ai.Loop=1]="Loop";var hI=((ao=(aa=function(){}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=lH.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0},ao.update=function(t){var r=this.state,n=this.frameTime,i=r._getDuration();this.playState=lH.Playing,r.wrapMode===e.WrapMode.Loop?n=i?n%i:0:Math.abs(n)>i&&(n=n<0?-i:i,this.playState=lH.Finished),t&&0===n?this.clipTime=r.clipEndTime*r.clip.length:(n<0&&(n+=i),this.clipTime=n+r.clipStartTime*r.clip.length)},aa),hV=((as=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new hI,this.destPlayData=new hI,this.layerState=lW.Standby,this.crossCurveMark=0,this.manuallyTransition=new hB,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},as),hO=function(){this.curveLayerOwner=[],this.eventHandlers=[]},hN=(cx(al=function(t){var r;return(r=cJ.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 ut(hD),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},cJ),(ac=al.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,i=this._getAnimatorStateInfo(e,t),a=i.state,o=i.layerIndex;if(a){if(!a.clip){cz.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,a,s,o);this._preparePlay(s,a),s.layerState=lW.Playing,s.srcPlayData.reset(a,l,a._getDuration()*r),this.update(0)}},ac.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var i,a=this._getAnimatorStateInfo(e,r),o=a.state,s=a.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._crossFadeByTransition(l,s)&&this.update(0)},ac.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,i=this._controlledRenderers,a=0,o=i.length;a<o;a++)if(!i[a].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!==lW.Standby&&this._updateLayer(l,0===l,t,n)}},ac.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},ac.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},ac._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},ac._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},ac._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},ac._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)},ac._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,i=null;if(r){var a=r.layers;if(-1===t){for(var o=0,s=a.length;o<s;o++)if(i=a[o].stateMachine.findStateByName(e)){t=o;break}}else i=a[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=i,n},ac._getAnimatorStateData=function(e,t,r,n){var i=r.animatorStateDataMap,a=i[e];return a||(a=new hO,i[e]=a,this._saveAnimatorStateData(t,a,r,n),this._saveAnimatorEventHandlers(t,a)),a},ac._saveAnimatorStateData=function(e,t,r,n){for(var i=this.entity,a=this._curveOwnerPool,o=t.curveLayerOwner,s=e.clip._curveBindings,l=r.curveOwnerPool,c=s.length-1;c>=0;c--){var u=s[c],d=""===u.relativePath?i:i.findByPath(u.relativePath);if(d){var h=d.getComponent(u.type);if(!h)continue;var _=u.property,f=d.instanceId,p=a[f]||(a[f]=Object.create(null)),m=p[_]||(p[_]=u._createCurveOwner(d,h)),g=l[f]||(l[f]=Object.create(null)),v=g[_]||(g[_]=u._createCurveLayerOwner(m));o[c]=v}else o[c]=null,cz.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},ac._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,i=[],a=t.eventHandlers,o=function(){r._entity.getComponents(d4,i);var t=i.length,o=e.clip.events;a.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.getFromPool(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=i[_][d];f&&h.push(f)}a.push(u)}};o(),e._updateFlagManager.addListener(o)},ac._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},ac._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},ac._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},ac._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},ac._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)},ac._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var i=r[n];i&&(i.crossCurveMark=e.crossCurveMark,t&&i.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,i,n,-1))}},ac._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var i=r[n];if(i){if(i.crossCurveMark===e.crossCurveMark)i.crossDestCurveIndex=n;else{var a=i.curveOwner;t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,n)}}}},ac._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new hV),t},ac._updateLayer=function(t,r,n,i){var a=this._animatorController.layers[t],o=a.blendingMode,s=a.weight,l=this._animatorLayersData[t],c=l.srcPlayData,u=l.destPlayData,d=o===e.AnimatorLayerBlendingMode.Additive;switch(r&&(s=1),l.layerState){case lW.Playing:this._updatePlayingState(c,l,t,s,n,d,i);break;case lW.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,n,d,i);break;case lW.CrossFading:this._updateCrossFade(c,u,l,t,s,n,d,i);break;case lW.Finished:this._updateFinishedState(c,s,d,i)}},ac._updatePlayingState=function(e,t,r,n,i,a,o){var s=e.stateData,l=s.curveLayerOwner,c=s.eventHandlers,u=e.state,d=e.playState,h=e.clipTime,_=u.transitions,f=u.clip._curveBindings,p=u.speed*this.speed;e.frameTime+=p*i,e.update(p<0);var m=e.clipTime,g=e.playState,v=g===lH.Finished;if(o||v)for(var y=f.length-1;y>=0;y--){var x=l[y],S=null==x?void 0:x.curveOwner;if(S){var C=f[y].curve;if(C.keys.length){this._checkRevertOwner(S,a);var T=S.evaluateValue(C,m,a);o&&S.applyValue(T,n,a),v&&x.saveFinalValue()}}}if(g===lH.Finished&&(t.layerState=lW.Finished),c.length&&this._fireAnimationEvents(e,c,h,m),d===lH.UnStarted&&this._callAnimatorScriptOnEnter(u,r),g===lH.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),_.length){var A=t.layerState;A!==lW.CrossFading&&A!==lW.FixedCrossFading&&this._checkTransition(e,_,r,h,m)}},ac._updateCrossFade=function(e,t,r,n,i,a,o,s){var l=this.speed,c=r.crossLayerOwnerCollection,u=e.state.clip._curveBindings,d=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,S=t.clipTime,C=p._getDuration()*r.crossFadeTransition.duration,T=Math.abs(t.frameTime)/C;(T>=1||0===C)&&(T=1);var A=d.speed*l,E=p.speed*l;e.frameTime+=A*a,t.frameTime+=E*a,e.update(A<0),t.update(E<0);var M=e.clipTime,R=e.playState,w=t.clipTime,b=t.playState,P=t.playState===lH.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?u[B].curve:null,I>=0?y[I].curve:null,M,w,T,o);s&&D.applyValue(V,i,o),P&&L.saveFinalValue()}}this._updateCrossFadeData(r,T),f.length&&this._fireAnimationEvents(e,f,x,M),v.length&&this._fireAnimationEvents(t,v,S,w),_===lH.UnStarted&&this._callAnimatorScriptOnEnter(d,n),1===T||R===lH.Finished?this._callAnimatorScriptOnExit(d,n):this._callAnimatorScriptOnUpdate(d,n),g===lH.UnStarted&&this._callAnimatorScriptOnEnter(p,n),b===lH.Finished?this._callAnimatorScriptOnExit(p,n):this._callAnimatorScriptOnUpdate(p,n)},ac._updateCrossFadeFromPose=function(e,t,r,n,i,a,o){var s=t.crossLayerOwnerCollection,l=e.state,c=e.stateData,u=e.playState,d=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*i,e.update(m<0);var g=e.clipTime,v=e.playState,y=v===lH.Finished;if(o||y)for(var x=s.length-1;x>=0;x--){var S=s[x],C=null==S?void 0:S.curveOwner;if(C){var T=S.crossDestCurveIndex;this._checkRevertOwner(C,a);var A=S.curveOwner.crossFadeFromPoseAndApplyValue(T>=0?h[T].curve:null,g,p,a);o&&C.applyValue(A,n,a),y&&S.saveFinalValue()}}this._updateCrossFadeData(t,p),d.length&&this._fireAnimationEvents(e,d,_,g),u===lH.UnStarted&&this._callAnimatorScriptOnEnter(l,r),v===lH.Finished?this._callAnimatorScriptOnExit(l,r):this._callAnimatorScriptOnUpdate(l,r)},ac._updateFinishedState=function(e,t,r,n){if(n)for(var i=e.stateData.curveLayerOwner,a=e.state.clip._curveBindings,o=a.length-1;o>=0;o--){var s=i[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},ac._updateCrossFadeData=function(e,t){var r=e.destPlayData;1===t&&(r.playState===lH.Finished?e.layerState=lW.Finished:e.layerState=lW.Playing,e.switchPlayData(),e.crossFadeTransition=null)},ac._preparePlay=function(e,t){if(e.layerState===lW.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,i=r.stateData.curveLayerOwner,a=i.length-1;a>=0;a--)null==(n=i[a])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},ac._checkTransition=function(e,t,r,n,i){var a=e.state,o=a.clip.length;this.speed*a.speed>=0?i<n?(this._checkSubTransition(e,t,r,n,a.clipEndTime*o),e.currentTransitionIndex=0,this._checkSubTransition(e,t,r,a.clipStartTime*o,i)):this._checkSubTransition(e,t,r,n,i):i>n?(this._checkBackwardsSubTransition(e,t,r,n,a.clipStartTime*o),e.currentTransitionIndex=t.length-1,this._checkBackwardsSubTransition(e,t,r,i,a.clipEndTime*o)):this._checkBackwardsSubTransition(e,t,r,n,i)},ac._checkSubTransition=function(e,t,r,n,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration(),s=t.length;a<s;a++){var l=t[a],c=l.exitTime*o;if(c>i)break;c>=n&&(this._crossFadeByTransition(l,r),e.currentTransitionIndex=Math.min(a+1,s-1))}},ac._checkBackwardsSubTransition=function(e,t,r,n,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration();a>=0;a--){var s=t[a],l=s.exitTime*o;if(l<i)break;l<=n&&(this._crossFadeByTransition(s,r),e.currentTransitionIndex=Math.max(a-1,0))}},ac._crossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return cz.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),i=n.layerState,a=n.destPlayData,o=this._getAnimatorStateData(r.name,r,n,t),s=r._getDuration()*e.offset;switch(a.reset(r,o,s),i){case lW.Standby:case lW.Finished:n.layerState=lW.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case lW.Playing:n.layerState=lW.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case lW.CrossFading:n.layerState=lW.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case lW.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},ac._fireAnimationEvents=function(e,t,r,n){var i=e.state,a=i.clip.length;this.speed*i.speed>=0?n<r?(this._fireSubAnimationEvents(e,t,r,i.clipEndTime*a),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,i.clipStartTime*a,n)):this._fireSubAnimationEvents(e,t,r,n):n>r?(this._fireBackwardSubAnimationEvents(e,t,r,i.clipStartTime*a),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,i.clipEndTime*a,n)):this._fireBackwardSubAnimationEvents(e,t,r,n)},ac._fireSubAnimationEvents=function(e,t,r,n){for(var i=e.currentEventIndex,a=t.length;i<a;i++){var o=t[i],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var u=o.handlers;if(l>=r){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(i+1,a-1)}}},ac._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var i=e.currentEventIndex;i>=0;i--){var a=t[i],o=a.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=a.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(i-1,0)}}},ac._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,i=r.length;n<i;n++)r[n].onStateEnter(this,e,t)},ac._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,i=r.length;n<i;n++)r[n].onStateUpdate(this,e,t)},ac._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,i=r.length;n<i;n++)r[n].onStateExit(this,e,t)},ac._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)}},ac._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},cv(al,[{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)}}]),al);cT([cM],hN.prototype,"speed",void 0),cT([cE],hN.prototype,"_controllerUpdateFlag",void 0),cT([cE],hN.prototype,"_updateMark",void 0),cT([cE],hN.prototype,"_animatorLayersData",void 0),cT([cE],hN.prototype,"_curveOwnerPool",void 0),cT([cE],hN.prototype,"_animationEventHandlerPool",void 0),cT([cE],hN.prototype,"_tempAnimatorStateInfo",void 0),cT([cE],hN.prototype,"_controlledRenderers",void 0);var hz=((ad=(au=function(){this._updateFlagManager=new c6,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},ad.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},ad.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},ad.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},ad._registerChangeFlag=function(){return this._updateFlagManager.createFlag(c8)},cv(au,[{key:"layers",get:function(){return this._layers}}]),au),hU=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},hk=((a_=(ah=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},a_.onStateUpdate=function(e,t,r){},a_.onStateExit=function(e,t,r){},a_.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},ah),hG=((ap=(af=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new c6,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 i=r;--i>=0&&n<t[i].exitTime;);t.splice(i+1,0,e)}},ap.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},ap.addStateMachineScript=function(e){var t=new e;t._state=this;var r=hk.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},ap.clearTransitions=function(){this._transitions.length=0},ap._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},ap._removeStateMachineScript=function(e){var t=hk.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 i=this._onStateExitScripts.indexOf(e);-1!==i&&this._onStateExitScripts.splice(i,1)}},ap._onClipChanged=function(){this._updateFlagManager.dispatch()},cv(af,[{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._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)}}]),af),hH=((ag=(am=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 hG(e),this.states.push(t),this._statesMap[e]=t),t},ag.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},ag.findStateByName=function(e){return this._statesMap[e]},ag.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},am);e.AnimatorConditionMode=void 0,(av=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[av.If=0]="If",av[av.IfNot=1]="IfNot",av[av.Greater=2]="Greater",av[av.Less=3]="Less",av[av.Equals=4]="Equals",av[av.NotEquals=5]="NotEquals";var hW=function(){},hX=function(t){function r(n){var i;return(i=t.call(this,n,ux.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new ch(1,1,1,1),i.renderState.rasterState.cullMode=e.CullMode.Off,i.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,i.shaderData.setFloat(r._rotationProp,0),i.shaderData.setFloat(r._exposureProp,1),i.shaderData.setColor(r._tintColorProp,i._tintColor),i}return cx(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},cv(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}(dD);hX._tintColorProp=cQ.getByName("material_TintColor"),hX._textureCubeProp=cQ.getByName("material_CubeTexture"),hX._rotationProp=cQ.getByName("material_Rotation"),hX._exposureProp=cQ.getByName("material_Exposure"),hX._decodeSkyRGBMMacro=ur.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(ay=e.SunMode||(e.SunMode={}))[ay.None=0]="None",ay[ay.Simple=1]="Simple",ay[ay.HighQuality=2]="HighQuality";var hK=(cx(ax=function(t){var r;return(r=dD.call(this,t,ux.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new ch(.5,.5,.5,1),r.groundTint=new ch(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},dD),ax.prototype.clone=function(){var e=new ax(this._engine);return this.cloneTo(e),e},cv(ax,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(ax._sunSimpleMacro),t.enableMacro(ax._sunHighQualityMacro);break;case 1:t.disableMacro(ax._sunHighQualityMacro),t.enableMacro(ax._sunSimpleMacro);break;case 0:t.disableMacro(ax._sunHighQualityMacro),t.disableMacro(ax._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(ax._sunSizeProp)},set:function(e){this.shaderData.setFloat(ax._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(ax._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(ax._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(ax._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(ax._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(ax._skyTintProp)},set:function(e){this.shaderData.setColor(ax._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(ax._groundTintProp)},set:function(e){this.shaderData.setColor(ax._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(ax._exposureProp)},set:function(e){this.shaderData.setFloat(ax._exposureProp,Math.min(Math.max(0,e),8))}}]),ax);hK._sunSizeProp=cQ.getByName("material_SunSize"),hK._sunSizeConvergenceProp=cQ.getByName("material_SunSizeConvergence"),hK._atmosphereThicknessProp=cQ.getByName("material_AtmosphereThickness"),hK._skyTintProp=cQ.getByName("material_SkyTint"),hK._groundTintProp=cQ.getByName("material_GroundTint"),hK._exposureProp=cQ.getByName("material_Exposure"),hK._sunHighQualityMacro=ur.getByName("MATERIAL_SUN_HIGH_QUALITY"),hK._sunSimpleMacro=ur.getByName("MATERIAL_SUN_SIMPLE");var hj=function(){};e.ParticleRenderMode=void 0,(aS=e.ParticleRenderMode||(e.ParticleRenderMode={}))[aS.Billboard=0]="Billboard",aS[aS.StretchBillboard=1]="StretchBillboard",aS[aS.HorizontalBillboard=2]="HorizontalBillboard",aS[aS.VerticalBillboard=3]="VerticalBillboard",aS[aS.Mesh=4]="Mesh",aS[aS.None=5]="None",e.ParticleStopMode=void 0,(aC=e.ParticleStopMode||(e.ParticleStopMode={}))[aC.StopEmittingAndClear=0]="StopEmittingAndClear",aC[aC.StopEmitting=1]="StopEmitting";var hY=function(t){function r(n){var i;return(i=t.call(this,n)||this).generator=new _e(cm(i)),i.velocityScale=0,i.lengthScale=2,i.pivot=new ce,i._currentRenderModeMacro=r._billboardModeMacro,i.shaderData.enableMacro(r._billboardModeMacro),i._supportInstancedArrays=i.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),i}cx(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){var t=this.shaderData;t.setFloat(r._lengthScale,this.lengthScale),t.setFloat(r._speedScale,this.velocityScale),t.setFloat(r._currentTime,this.generator._playTime),t.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(t)},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){r.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),this.generator._destroy()},cv(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var i=null,a=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:i=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:i=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==i&&(this._currentRenderModeMacro&&a.disableMacro(this._currentRenderModeMacro),i&&a.enableMacro(i),this._currentRenderModeMacro=i),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,null==r||r._addReferCount(-1),null==t||t._addReferCount(1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);hY._billboardModeMacro=ur.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),hY._stretchedBillboardModeMacro=ur.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),hY._horizontalBillboardModeMacro=ur.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),hY._verticalBillboardModeMacro=ur.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),hY._renderModeMeshMacro=ur.getByName("RENDERER_MODE_MESH"),hY._pivotOffsetProperty=cQ.getByName("renderer_PivotOffset"),hY._lengthScale=cQ.getByName("renderer_StretchedBillboardLengthScale"),hY._speedScale=cQ.getByName("renderer_StretchedBillboardSpeedScale"),hY._currentTime=cQ.getByName("renderer_CurrentTime"),cT([cw],hY.prototype,"generator",void 0),cT([cR],hY.prototype,"pivot",void 0),e.ParticleCurveMode=void 0,(aT=e.ParticleCurveMode||(e.ParticleCurveMode={}))[aT.Constant=0]="Constant",aT[aT.TwoConstants=1]="TwoConstants",aT[aT.Curve=2]="Curve",aT[aT.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(aA=e.ParticleGradientMode||(e.ParticleGradientMode={}))[aA.Constant=0]="Constant",aA[aA.TwoConstants=1]="TwoConstants",aA[aA.Gradient=2]="Gradient",aA[aA.TwoGradients=3]="TwoGradients",e.ParticleSimulationSpace=void 0,(aE=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[aE.Local=0]="Local",aE[aE.World=1]="World",(aM=lX||(lX={}))[aM.Burst=592910910]="Burst",aM[aM.StartDelay=322376503]="StartDelay",aM[aM.StartColor=306581307]="StartColor",aM[aM.StartSize=1793934638]="StartSize",aM[aM.StartRotation=3737431713]="StartRotation",aM[aM.randomizeRotationDirection=2527743459]="randomizeRotationDirection",aM[aM.StartLifetime=2368504881]="StartLifetime",aM[aM.StartSpeed=4085612399]="StartSpeed",aM[aM.VelocityOverLifetime=3774601268]="VelocityOverLifetime",aM[aM.ColorOverLifetime=326370691]="ColorOverLifetime",aM[aM.SizeOverLifetime=1494990940]="SizeOverLifetime",aM[aM.RotationOverLifetime=1089181156]="RotationOverLifetime",aM[aM.TextureSheetAnimation=197469413]="TextureSheetAnimation",aM[aM.Shape=2941263940]="Shape";var hq=((aw=(aR=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 i=e[r];this.addColorKey(i)}if(t)for(var a=0,o=t.length;a<o;a++){var s=t[a];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 hQ(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},aw.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 hZ(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},aw.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},aw.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},aw.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,i=0,a=r.length;i<a;i++)r[i]._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 u=0,d=t.length;u<d;u++)this._addKey(n,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},aw._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,i=0,a=Math.min(n.length,4);i<a;i++){var o=4*i,s=n[i];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=ch.gammaToLinearSpace(l.r),r[o+2]=ch.gammaToLinearSpace(l.g),r[o+3]=ch.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},aw._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 i=2*r,a=t[r];e[i]=a.time,e[i+1]=a.alpha}this._alphaTypeArrayDirty=!1}return e},aw._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 i=n;--i>=0&&r<e[i].time;);e.splice(i+1,0,t)}},aw._removeKey=function(e,t){e.splice(t,1)},aw._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},aw._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},cv(aR,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),aR);cT([cw],hq.prototype,"_colorKeys",void 0),cT([cw],hq.prototype,"_alphaKeys",void 0),cT([cE],hq.prototype,"_colorTypeArray",void 0),cT([cE],hq.prototype,"_alphaTypeArray",void 0);var hQ=(cv(ab=function(e,t){this._onValueChanged=null,this._color=new ch,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)}}]),ab),hZ=(cv(aP=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()}}]),aP),hJ=((aF=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new ch,this.constantMax=new ch,this.gradientMin=new hq,this.gradientMax=new hq,t.constructor===ch?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:ch.lerp(this.constantMin,this.constantMax,r,n)}},cv(aF,[{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}}]),aF);cT([cw],hJ.prototype,"constantMin",void 0),cT([cw],hJ.prototype,"constantMax",void 0),cT([cw],hJ.prototype,"gradientMin",void 0),cT([cw],hJ.prototype,"gradientMax",void 0);var h$=((aL=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},aL);cT([cE],h$.prototype,"_generator",void 0);var h0=(cx(aD=function(){var e;return e=h$.apply(this,arguments)||this,e.color=new hJ(new hq([new hQ(0,new ch(1,1,1)),new hQ(1,new ch(1,1,1))],[new hZ(0,1),new hZ(1,1)])),e._colorGradientRand=new cp(0,lX.ColorOverLifetime),e._gradientKeysCount=new cd(0,0,0,0),e},h$),(aB=aD.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 i=this.color,a=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(aD._maxGradientColor,i.gradientMax._getColorTypeArray(a)),t.setFloatArray(aD._maxGradientAlpha,i.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=aD._gradientMacro:(t.setFloatArray(aD._minGradientColor,i.gradientMin._getColorTypeArray(a)),t.setFloatArray(aD._minGradientAlpha,i.gradientMin._getAlphaTypeArray()),r=aD._randomGradientsMacro);var o=i.gradientMin.colorKeys,s=i.gradientMin.alphaKeys,l=i.gradientMax.colorKeys,c=i.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(aD._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},aB._resetRandomSeed=function(e){this._colorGradientRand.reset(e,lX.ColorOverLifetime)},aD);h0._gradientMacro=ur.getByName("RENDERER_COL_GRADIENT"),h0._randomGradientsMacro=ur.getByName("RENDERER_COL_RANDOM_GRADIENTS"),h0._minGradientColor=cQ.getByName("renderer_COLMinGradientColor"),h0._minGradientAlpha=cQ.getByName("renderer_COLMinGradientAlpha"),h0._maxGradientColor=cQ.getByName("renderer_COLMaxGradientColor"),h0._maxGradientAlpha=cQ.getByName("renderer_COLMaxGradientAlpha"),h0._gradientKeysCount=cQ.getByName("renderer_COLGradientKeysMaxTime"),cT([cw],h0.prototype,"color",void 0),cT([cE],h0.prototype,"_colorGradientRand",void 0),cT([cE],h0.prototype,"_gradientKeysCount",void 0),cT([cE],h0.prototype,"_colorMacro",void 0);var h1=((aI=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}},cv(aI,[{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}}]),aI);cT([cw],h1.prototype,"curveMin",void 0),cT([cw],h1.prototype,"curveMax",void 0);var h2=(cx(aV=function(){var e;return e=h$.apply(this,arguments)||this,e.rateOverTime=new h1(10),e.rateOverDistance=new h1(0),e._shapeRand=new cp(0,lX.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new cp(0,lX.Burst),e},h$),(aO=aV.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)},aO.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},aO.removeBurstByIndex=function(e){this._bursts.splice(e,1)},aO.clearBurst=function(){this._bursts.length=0},aO._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},aO._resetRandomSeed=function(e){this._burstRand.reset(e,lX.Burst),this._shapeRand.reset(e,lX.Shape)},aO._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},aO._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,i=e-this._frameRateTime;i>=n;)i-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},aO._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,i=Math.floor((t-e)/n);if(r.isLoop&&(i>0||t%n<e%n)){var a=Math.ceil(e/n)*n;this._emitBySubBurst(e,a,n),this._currentBurstIndex=0;for(var o=0;o<i;o++){var s=a;a+=n,this._emitBySubBurst(s,a,n),this._currentBurstIndex=0}this._emitBySubBurst(a,t,n)}else this._emitBySubBurst(e,t,n)},aO._emitBySubBurst=function(e,t,r){for(var n=this._generator,i=this._burstRand,a=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,u=a.length;c<u;c++){var d=a[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,i.random());n._emit(o+h,_)}}this._currentBurstIndex=c},cv(aV,[{key:"bursts",get:function(){return this._bursts}}]),aV);cT([cw],h2.prototype,"rateOverTime",void 0),cT([cw],h2.prototype,"rateOverDistance",void 0),cT([cw],h2.prototype,"shape",void 0),cT([cE],h2.prototype,"_shapeRand",void 0),cT([cw],h2.prototype,"_bursts",void 0),cT([cE],h2.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(aN=e.ParticleScaleMode||(e.ParticleScaleMode={}))[aN.Hierarchy=0]="Hierarchy",aN[aN.Local=1]="Local",aN[aN.World=2]="World";var h3=((aU=(az=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new h1(0),this.startLifetime=new h1(5),this.startSpeed=new h1(5),this.startSize3D=!1,this.startSizeX=new h1(1),this.startSizeY=new h1(1),this.startSizeZ=new h1(1),this.startRotation3D=!1,this.startRotationX=new h1(0),this.startRotationY=new h1(0),this.startRotationZ=new h1(0),this.flipRotation=0,this.startColor=new hJ(new ch(1,1,1,1)),this.gravityModifier=new h1(0),this.simulationSpace=e.ParticleSimulationSpace.Local,this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new cp(0,lX.StartSpeed),this._startLifeTimeRand=new cp(0,lX.StartLifetime),this._startColorRand=new cp(0,lX.StartColor),this._startSizeRand=new cp(0,lX.StartSize),this._startRotationRand=new cp(0,lX.StartRotation),this._gravity=new ce,this._generator=t}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,lX.StartSpeed),this._startLifeTimeRand.reset(e,lX.StartLifetime),this._startColorRand.reset(e,lX.StartColor),this._startSizeRand.reset(e,lX.StartSize),this._startRotationRand.reset(e,lX.StartRotation)},aU._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}},aU._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(az._worldPosition,n.worldPosition);var i=n.worldRotationQuaternion,a=az._tempVector40;a.copyFrom(i),t.setVector4(az._worldRotation,a);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(az._positionScale,o),t.setVector3(az._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(az._positionScale,o),t.setVector3(az._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(az._positionScale,n.lossyWorldScale),t.setVector3(az._sizeScale,az._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,void 0);ce.scale(r.scene.physics.gravity,l,s),t.setVector3(az._gravity,s),t.setInt(az._simulationSpace,this.simulationSpace),t.setFloat(az._startRotation3D,+this.startRotation3D),t.setInt(az._scaleMode,this.scalingMode)},aU._cloneTo=function(e){e.maxParticles=this.maxParticles},cv(az,[{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}}]),az);h3._tempVector40=new cd,h3._vector3One=new ce(1,1,1),h3._positionScale=cQ.getByName("renderer_PositionScale"),h3._sizeScale=cQ.getByName("renderer_SizeScale"),h3._worldPosition=cQ.getByName("renderer_WorldPosition"),h3._worldRotation=cQ.getByName("renderer_WorldRotation"),h3._gravity=cQ.getByName("renderer_Gravity"),h3._simulationSpace=cQ.getByName("renderer_SimulationSpace"),h3._startRotation3D=cQ.getByName("renderer_ThreeDStartRotation"),h3._scaleMode=cQ.getByName("renderer_ScalingMode"),cT([cw],h3.prototype,"startDelay",void 0),cT([cw],h3.prototype,"startLifetime",void 0),cT([cw],h3.prototype,"startSpeed",void 0),cT([cw],h3.prototype,"startSizeX",void 0),cT([cw],h3.prototype,"startSizeY",void 0),cT([cw],h3.prototype,"startSizeZ",void 0),cT([cw],h3.prototype,"startRotationX",void 0),cT([cw],h3.prototype,"startRotationY",void 0),cT([cw],h3.prototype,"startRotationZ",void 0),cT([cw],h3.prototype,"startColor",void 0),cT([cw],h3.prototype,"gravityModifier",void 0),cT([cE],h3.prototype,"_maxParticleBuffer",void 0),cT([cE],h3.prototype,"_startSpeedRand",void 0),cT([cE],h3.prototype,"_startLifeTimeRand",void 0),cT([cE],h3.prototype,"_startColorRand",void 0),cT([cE],h3.prototype,"_startSizeRand",void 0),cT([cE],h3.prototype,"_startRotationRand",void 0),cT([cE],h3.prototype,"_generator",void 0),cT([cE],h3.prototype,"_gravity",void 0);var h4=(cx(ak=function(){var e;return e=h$.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new h1(0),e.rotationY=new h1(0),e.rotationZ=new h1(45),e._rotationRand=new cp(0,lX.RotationOverLifetime),e._rotationMinConstant=new ce,e._rotationMaxConstant=new ce,e},h$),(aG=ak.prototype)._updateShaderData=function(t){var r=null,n=null,i=null;if(this.enabled){var a=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?a.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?a.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(ak._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(ak._maxCurveXProperty,a.curveMax._getTypeArray()),t.setFloatArray(ak._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(ak._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(ak._minCurveXProperty,a.curveMin._getTypeArray()),t.setFloatArray(ak._minCurveYProperty,o.curveMin._getTypeArray())),i=ak._isRandomTwoMacro),n=ak._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(l9.degreeToRadian(a.constantMax),l9.degreeToRadian(o.constantMax),l9.degreeToRadian(s.constantMax)),t.setVector3(ak._maxConstantProperty,u),l?a.mode===e.ParticleCurveMode.TwoConstants&&o.mode===e.ParticleCurveMode.TwoConstants&&s.mode===e.ParticleCurveMode.TwoConstants:s.mode===e.ParticleCurveMode.TwoConstants){var d=this._rotationMinConstant;d.set(l9.degreeToRadian(a.constantMin),l9.degreeToRadian(o.constantMin),l9.degreeToRadian(s.constantMin)),t.setVector3(ak._minConstantProperty,d),i=ak._isRandomTwoMacro}n=ak._constantModeMacro}l&&(r=ak._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,i)},aG._resetRandomSeed=function(e){this._rotationRand.reset(e,lX.RotationOverLifetime)},ak);h4._constantModeMacro=ur.getByName("RENDERER_ROL_CONSTANT_MODE"),h4._curveModeMacro=ur.getByName("RENDERER_ROL_CURVE_MODE"),h4._isSeparateMacro=ur.getByName("RENDERER_ROL_IS_SEPARATE"),h4._isRandomTwoMacro=ur.getByName("RENDERER_ROL_IS_RANDOM_TWO"),h4._minConstantProperty=cQ.getByName("renderer_ROLMinConst"),h4._minCurveXProperty=cQ.getByName("renderer_ROLMinCurveX"),h4._minCurveYProperty=cQ.getByName("renderer_ROLMinCurveY"),h4._minCurveZProperty=cQ.getByName("renderer_ROLMinCurveZ"),h4._maxConstantProperty=cQ.getByName("renderer_ROLMaxConst"),h4._maxCurveXProperty=cQ.getByName("renderer_ROLMaxCurveX"),h4._maxCurveYProperty=cQ.getByName("renderer_ROLMaxCurveY"),h4._maxCurveZProperty=cQ.getByName("renderer_ROLMaxCurveZ"),cT([cw],h4.prototype,"rotationX",void 0),cT([cw],h4.prototype,"rotationY",void 0),cT([cw],h4.prototype,"rotationZ",void 0),cT([cE],h4.prototype,"_rotationRand",void 0),cT([cE],h4.prototype,"_rotationMinConstant",void 0),cT([cE],h4.prototype,"_rotationMaxConstant",void 0),cT([cE],h4.prototype,"_enableSeparateMacro",void 0),cT([cE],h4.prototype,"_isCurveMacro",void 0),cT([cE],h4.prototype,"_isRandomTwoMacro",void 0);var h5=((aW=(aH=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,i=t.length;n<i;n++){var a=t[n];this.addKey(a)}}).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 h8(e,t):e;this._addKey(r,n),this._typeArrayDirty=!0},aW.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0},aW.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},aW._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 i=2*r,a=t[r];e[i]=a.time,e[i+1]=a.value}this._typeArrayDirty=!1}return e},aW._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 i=r;--i>=0&&n<e[i].time;);e.splice(i+1,0,t)}},cv(aH,[{key:"keys",get:function(){return this._keys}}]),aH);cT([cw],h5.prototype,"_keys",void 0),cT([cE],h5.prototype,"_typeArray",void 0);var h8=function(e,t){this.time=e,this.value=t},h6=(cx(aX=function(){var e;return e=h$.apply(this,arguments)||this,e.separateAxes=!1,e.sizeX=new h1(new h5(new h8(0,0),new h8(1,1))),e.sizeY=new h1(new h5(new h8(0,0),new h8(1,1))),e.sizeZ=new h1(new h5(new h8(0,0),new h8(1,1))),e},h$),aX.prototype._updateShaderData=function(t){var r=null,n=null,i=null;if(this.enabled){var a=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?a.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:a.mode===e.ParticleCurveMode.TwoCurves;(c||l?a.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:a.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(aX._maxCurveXProperty,a.curveMax._getTypeArray()),l&&(t.setFloatArray(aX._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(aX._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(aX._minCurveXProperty,a.curveMin._getTypeArray()),l&&(t.setFloatArray(aX._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(aX._minCurveZProperty,s.curveMin._getTypeArray())),i=aX._isRandomTwoMacro),n=aX._curveModeMacro),l&&(r=aX._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,i)},cv(aX,[{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),aX);h6._curveModeMacro=ur.getByName("RENDERER_SOL_CURVE_MODE"),h6._isSeparateMacro=ur.getByName("RENDERER_SOL_IS_SEPARATE"),h6._isRandomTwoMacro=ur.getByName("RENDERER_SOL_IS_RANDOM_TWO"),h6._minCurveXProperty=cQ.getByName("renderer_SOLMinCurveX"),h6._minCurveYProperty=cQ.getByName("renderer_SOLMinCurveY"),h6._minCurveZProperty=cQ.getByName("renderer_SOLMinCurveZ"),h6._maxCurveXProperty=cQ.getByName("renderer_SOLMaxCurveX"),h6._maxCurveYProperty=cQ.getByName("renderer_SOLMaxCurveY"),h6._maxCurveZProperty=cQ.getByName("renderer_SOLMaxCurveZ"),cT([cw],h6.prototype,"sizeX",void 0),cT([cw],h6.prototype,"sizeY",void 0),cT([cw],h6.prototype,"sizeZ",void 0),cT([cE],h6.prototype,"_enableSeparateMacro",void 0),cT([cE],h6.prototype,"_isCurveMacro",void 0),cT([cE],h6.prototype,"_isRandomTwoMacro",void 0);var h7=(cx(aK=function(){var e;return e=h$.apply(this,arguments)||this,e.startFrame=new h1(0),e.frameOverTime=new h1(new h5(new h8(0,0),new h8(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new ce(1,1,1),e._frameOverTimeRand=new cp(0,lX.TextureSheetAnimation),e._tiling=new cu(1,1),e},h$),(aj=aK.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 i=this.frameOverTime;t.setFloatArray(aK._frameMaxCurveProperty,i.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=aK._frameCurveMacro:(t.setFloatArray(aK._frameMinCurveProperty,i.curveMin._getTypeArray()),r=aK._frameRandomCurvesMacro),t.setFloat(aK._cycleCountProperty,this.cycleCount),t.setVector3(aK._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},aj._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,lX.TextureSheetAnimation)},cv(aK,[{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)}}]),aK);h7._frameCurveMacro=ur.getByName("RENDERER_TSA_FRAME_CURVE"),h7._frameRandomCurvesMacro=ur.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),h7._cycleCountProperty=cQ.getByName("renderer_TSACycles"),h7._tillingParamsProperty=cQ.getByName("renderer_TSATillingParams"),h7._frameMinCurveProperty=cQ.getByName("renderer_TSAFrameMinCurve"),h7._frameMaxCurveProperty=cQ.getByName("renderer_TSAFrameMaxCurve"),cT([cw],h7.prototype,"startFrame",void 0),cT([cw],h7.prototype,"frameOverTime",void 0),cT([cR],h7.prototype,"_tillingInfo",void 0),cT([cE],h7.prototype,"_frameOverTimeRand",void 0),cT([cw],h7.prototype,"_tiling",void 0),cT([cE],h7.prototype,"_textureSheetMacro",void 0),(aY=lK||(lK={}))[aY.WholeSheet=0]="WholeSheet",aY[aY.SingleRow=1]="SingleRow";var h9=(cx(aq=function(){var t;return t=h$.apply(this,arguments)||this,t.velocityX=new h1(0),t.velocityY=new h1(0),t.velocityZ=new h1(0),t.space=e.ParticleSimulationSpace.Local,t._velocityRand=new cp(0,lX.VelocityOverLifetime),t._velocityMinConstant=new ce,t._velocityMaxConstant=new ce,t},h$),(aQ=aq.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,i=this.velocityY,a=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve)t.setFloatArray(aq._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(aq._maxGradientYProperty,i.curveMax._getTypeArray()),t.setFloatArray(aq._maxGradientZProperty,a.curveMax._getTypeArray()),o?(t.setFloatArray(aq._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(aq._minGradientYProperty,i.curveMin._getTypeArray()),t.setFloatArray(aq._minGradientZProperty,a.curveMin._getTypeArray()),r=aq._randomCurveMacro):r=aq._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,i.constantMax,a.constantMax),t.setVector3(aq._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,i.constantMin,a.constantMin),t.setVector3(aq._minConstantProperty,l),r=aq._randomConstantMacro}else r=aq._constantMacro}t.setInt(aq._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},aQ._resetRandomSeed=function(e){this._velocityRand.reset(e,lX.VelocityOverLifetime)},aq);h9._constantMacro=ur.getByName("RENDERER_VOL_CONSTANT"),h9._curveMacro=ur.getByName("RENDERER_VOL_CURVE"),h9._randomConstantMacro=ur.getByName("RENDERER_VOL_RANDOM_CONSTANT"),h9._randomCurveMacro=ur.getByName("RENDERER_VOL_RANDOM_CURVE"),h9._minConstantProperty=cQ.getByName("renderer_VOLMinConst"),h9._maxConstantProperty=cQ.getByName("renderer_VOLMaxConst"),h9._minGradientXProperty=cQ.getByName("renderer_VOLMinGradientX"),h9._minGradientYProperty=cQ.getByName("renderer_VOLMinGradientY"),h9._minGradientZProperty=cQ.getByName("renderer_VOLMinGradientZ"),h9._maxGradientXProperty=cQ.getByName("renderer_VOLMaxGradientX"),h9._maxGradientYProperty=cQ.getByName("renderer_VOLMaxGradientY"),h9._maxGradientZProperty=cQ.getByName("renderer_VOLMaxGradientZ"),h9._spaceProperty=cQ.getByName("renderer_VOLSpace"),cT([cw],h9.prototype,"velocityX",void 0),cT([cw],h9.prototype,"velocityY",void 0),cT([cw],h9.prototype,"velocityZ",void 0),cT([cE],h9.prototype,"_velocityRand",void 0),cT([cE],h9.prototype,"_velocityMinConstant",void 0),cT([cE],h9.prototype,"_velocityMaxConstant",void 0),cT([cE],h9.prototype,"_velocityMacro",void 0);var _e=function(){function t(r){this.useAutoRandomSeed=!0,this.main=new h3(this),this.emission=new h2(this),this.velocityOverLifetime=new h9(this),this.sizeOverLifetime=new h6(this),this.rotationOverLifetime=new h4(this),this.colorOverLifetime=new h0(this),this.textureSheetAnimation=new h7(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new uD(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._renderer=r,new hj().start=0,this._primitive=new uB(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(hY,t._tempParticleRenderers),n=0,i=r.length;n<i;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 i=this._renderer.entity.getComponentsIncludeChildren(hY,t._tempParticleRenderers),a=0,o=i.length;a<o;a++)i[a].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,i=t._tempVector31,a=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(o){o._generatePositionAndDirection(this.emission._shapeRand,e,n,i);var l=this.main._getPositionScale();n.multiply(l),i.normalize().multiply(l)}else n.set(0,0,0),i.set(0,0,-1);this._addNewParticle(n,i,a,e)}},r._update=function(e){var t=this.main,r=this.emission,n=t.duration,i=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(i,this._playTime),!t.isLoop&&this._playTime>n&&(this._isPlaying=!1)),!this.isAlive){var a=Math.min(r._frameRateTime,Math.floor(this._playTime/n)*n);this._playTime-=a,r._frameRateTime-=a}(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,i=this._vertexBufferBindings;if(n.clearVertexElements(),i.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var a=t.mesh;if(!a)return;var o=a.getVertexElement(e.VertexAttribute.Position),s=a.getVertexElement(e.VertexAttribute.Color),l=a.getVertexElement(e.VertexAttribute.UV),c=o?a.vertexBufferBindings[o.bindingIndex]:null,u=s?a.vertexBufferBindings[s.bindingIndex]:null,d=l?a.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,i);n.addVertexElement(new uP(e.VertexAttribute.Position,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,i);n.addVertexElement(new uP(e.VertexAttribute.Color,s.offset,s.format,_))}if(d){var f=this._addVertexBufferBindingsFilterDuplicate(d,i);n.addVertexElement(new uP(e.VertexAttribute.UV,l.offset,l.format,f))}var p=a._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),i.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=r.billboardIndexCount;n.setVertexBufferBindings(i);for(var m=r.instanceVertexElements,g=i.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new uP(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,i=n.instanceVertexStride,a=t?this._currentParticleCount+r:this.main._maxParticleBuffer,o=i*a,s=this._renderer.engine,l=new uF(s,e.BufferBindFlag.VertexBuffer,o,e.BufferUsage.Dynamic,!1);l.isGCIgnored=!0;var c=this._primitive.vertexBufferBindings,u=new uV(l,i),d=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;d.set(new Float32Array(h.buffer,0,y));var x=(this._firstFreeElement+r)*m;d.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)),d.set(new Float32Array(h.buffer,v*m*4,f*m),p*m);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(h?c.length-1:c.length,u),this._instanceVertices=d,this._instanceVertexBufferBinding=u,this._currentParticleCount=a},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,i,a){var o,s,l=this._firstFreeElement,c=l+1;c>=this._currentParticleCount&&(c=0);var u=this.main;if(c===this._firstRetiredElement){var d=Math.min(t._particleIncreaseCount,u._maxParticleBuffer-this._currentParticleCount);if(0===d)return;this._resizeInstanceBuffer(!0,d),c=l+1}u.simulationSpace===e.ParticleSimulationSpace.World&&(o=i.worldPosition,s=i.worldRotationQuaternion);var h=this._renderer.engine._particleBufferUtils,_=u.startSpeed.evaluate(void 0,u._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]=u.startLifetime.evaluate(void 0,u._startLifeTimeRand.random()),f[p+4]=n.x,f[p+5]=n.y,f[p+6]=n.z,f[p+h.timeOffset]=a;var m=t._tempColor0;u.startColor.evaluate(void 0,u._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=u._startSizeRand;if(u.startSize3D)f[p+12]=u.startSizeX.evaluate(void 0,g.random()),f[p+13]=u.startSizeY.evaluate(void 0,g.random()),f[p+14]=u.startSizeZ.evaluate(void 0,g.random());else{var v=u.startSize.evaluate(void 0,g.random());f[p+12]=v,f[p+13]=v,f[p+14]=v}var y=u._startRotationRand;u.startRotation3D?(f[p+15]=l9.degreeToRadian(u.startRotationX.evaluate(void 0,y.random())),f[p+16]=l9.degreeToRadian(u.startRotationY.evaluate(void 0,y.random())),f[p+17]=l9.degreeToRadian(u.startRotationZ.evaluate(void 0,y.random()))):f[p+15]=l9.degreeToRadian(u.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 S=this.rotationOverLifetime;S.enabled&&S.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(f[p+22]=S._rotationRand.random());var C=this.textureSheetAnimation;C.enabled&&C.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(f[p+23]=C._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 A=T._velocityRand;f[p+24]=A.random(),f[p+25]=A.random(),f[p+26]=A.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 E=this.textureSheetAnimation._tillingInfo;f[p+h.simulationUVOffset]=E.x,f[p+35]=E.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 i=this._firstActiveElement*t.instanceVertexFloatStride,a=i+t.timeOffset;if(Math.fround(this._playTime-n[a])<n[i+t.startLifeTimeOffset])break;n[a]=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,i=t*n,a=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)a.setData(o,0,i,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;a.setData(o,0,i,s,e.SetDataOptions.Discard),r>0&&a.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},cv(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}();_e._tempVector30=new ce,_e._tempVector31=new ce,_e._tempColor0=new ch,_e._tempParticleRenderers=[],_e._particleIncreaseCount=128,cT([cw],_e.prototype,"main",void 0),cT([cw],_e.prototype,"emission",void 0),cT([cw],_e.prototype,"velocityOverLifetime",void 0),cT([cw],_e.prototype,"sizeOverLifetime",void 0),cT([cw],_e.prototype,"rotationOverLifetime",void 0),cT([cw],_e.prototype,"colorOverLifetime",void 0),cT([cw],_e.prototype,"textureSheetAnimation",void 0),cT([cE],_e.prototype,"_playTime",void 0),cT([cE],_e.prototype,"_firstNewElement",void 0),cT([cE],_e.prototype,"_firstActiveElement",void 0),cT([cE],_e.prototype,"_firstFreeElement",void 0),cT([cE],_e.prototype,"_firstRetiredElement",void 0),cT([cE],_e.prototype,"_primitive",void 0),cT([cE],_e.prototype,"_vertexBufferBindings",void 0),cT([cE],_e.prototype,"_subPrimitive",void 0),cT([cE],_e.prototype,"_renderer",void 0),cT([cE],_e.prototype,"_isPlaying",void 0),cT([cE],_e.prototype,"_instanceBufferResized",void 0),cT([cE],_e.prototype,"_waitProcessRetiredElementCount",void 0),cT([cE],_e.prototype,"_instanceVertexBufferBinding",void 0),cT([cE],_e.prototype,"_instanceVertices",void 0);var _t=(cx(aZ=function(e){var t;return(t=hm.call(this,e,ux.find("particle-shader"))||this).shaderData.setColor(hm._baseColorProp,new ch(1,1,1,1)),t.isTransparent=!0,t},hm),aZ.prototype.clone=function(){var e=new aZ(this._engine);return this.cloneTo(e),e},cv(aZ,[{key:"baseColor",get:function(){return this.shaderData.getColor(hm._baseColorProp)},set:function(e){var t=this.shaderData.getColor(hm._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(hm._baseTextureProp)},set:function(e){this.shaderData.setTexture(hm._baseTextureProp,e),e?this.shaderData.enableMacro(hm._baseTextureMacro):this.shaderData.disableMacro(hm._baseTextureMacro)}}]),aZ),_r=function(e,t){this.time=e,this.count=t};cT([cw],_r.prototype,"count",void 0);var _n=((aJ=function(){this.enable=!0,this.randomDirectionAmount=0}).prototype._generatePositionAndDirection=function(e,t,r,n){throw Error("BaseShape: must override it.")},aJ),_i=((a$=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},a$.randomPointInsideUnitArcCircle=function(e,t,r){a$.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},a$.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},a$.randomPointInsideUnitCircle=function(e,t){a$.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},a$._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,i=Math.sqrt(1-r*r);e.x=i*Math.cos(n),e.y=i*Math.sin(n),e.z=r},a$._randomPointInsideUnitSphere=function(e,t){a$._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},a$._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},a$);(a0=lj||(lj={}))[a0.Box=0]="Box",a0[a0.Circle=1]="Circle",a0[a0.Cone=2]="Cone",a0[a0.Hemisphere=3]="Hemisphere",a0[a0.Sphere=4]="Sphere";var _a=(cx(a1=function(){var e;return(e=_n.call(this)||this).size=new ce(1,1,1),e.shapeType=lj.Box,e},_n),a1.prototype._generatePositionAndDirection=function(e,t,r,n){_i._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var i=a1._tempVector30;i.set(0,0,-1),_i._randomPointUnitSphere(n,e),ce.lerp(i,n,this.randomDirectionAmount,n)},a1);_a._tempVector30=new ce,cT([cw],_a.prototype,"size",void 0),e.ParticleShapeArcMode=void 0,(a2=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[a2.Random=0]="Random",a2[a2.Loop=1]="Loop";var _o=(cx(a3=function(){var t;return(t=_n.call(this)||this).radius=1,t.arc=360,t.arcMode=e.ParticleShapeArcMode.Random,t.arcSpeed=1,t.shapeType=lj.Circle,t},_n),a3.prototype._generatePositionAndDirection=function(t,r,n,i){var a=a3._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=l9.degreeToRadian(this.arc*o);a.set(Math.cos(s),Math.sin(s)),a.scale(t.random());break;case e.ParticleShapeArcMode.Random:_i.randomPointInsideUnitArcCircle(l9.degreeToRadian(this.arc),a,t)}n.set(a.x,a.y,0),n.scale(this.radius),_i._randomPointUnitSphere(i,t),ce.lerp(n,i,this.randomDirectionAmount,i)},a3);_o._tempPositionPoint=new cu;var _s=(cx(a4=function(){var e;return(e=_n.call(this)||this).angle=25,e.radius=1,e.length=5,e.emitType=0,e.shapeType=lj.Cone,e},_n),a4.prototype._generatePositionAndDirection=function(e,t,r,n){var i=a4._tempVector20,a=l9.degreeToRadian(this.angle),o=Math.sin(a),s=Math.cos(a);switch(this.emitType){case 0:_i.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0);var l=a4._tempVector21;_i.randomPointInsideUnitCircle(l,e),cu.lerp(i,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:_i.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0),n.set(i.x*o,i.y*o,-s),n.normalize();var c=a4._tempVector30;ce.scale(n,this.length*e.random(),c),r.add(c);var u=a4._tempVector31;_i._randomPointUnitSphere(u,e),ce.lerp(n,u,this.randomDirectionAmount,n)}},a4);_s._tempVector20=new cu,_s._tempVector21=new cu,_s._tempVector30=new ce,_s._tempVector31=new ce,e.ConeEmitType=void 0,(a5=e.ConeEmitType||(e.ConeEmitType={}))[a5.Base=0]="Base",a5[a5.Volume=1]="Volume";var _l=(cx(a8=function(){var e;return(e=_n.call(this)||this).radius=1,e.shapeType=lj.Hemisphere,e},_n),a8.prototype._generatePositionAndDirection=function(e,t,r,n){_i._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var i=r.z;i>0&&(r.z=-i),_i._randomPointUnitSphere(n,e),ce.lerp(r,n,this.randomDirectionAmount,n)},a8),_c=(cx(a6=function(){var e;return(e=_n.call(this)||this).radius=1,e.shapeType=lj.Sphere,e},_n),a6.prototype._generatePositionAndDirection=function(e,t,r,n){_i._randomPointInsideUnitSphere(r,e),r.scale(this.radius),_i._randomPointUnitSphere(n,e),ce.lerp(r,n,this.randomDirectionAmount,n)},a6);ux.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 _u=(cx(a7=function(t){var r,n=(r=dD.call(this,t,ux.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},dD),a7),_d=new ce,_h=(cx(a9=function(e,t){(r=uU.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 ce),r._pointStates.push(r._lifetime),r._strapPoints.push(new ce),r._strapPoints.push(new ce);r._curPointNum=0;var i=t.material||new _u(r.engine);return r.setMaterial(i),r.setTexture(t.texture),r._initGeometry(),r},uU),(oe=a9.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 i=!0;if(this._curPointNum===this._maxPointNum)i=!1;else if(this._curPointNum>0){var a=this._points[this._points.length-1];ce.distance(this.entity.transform.worldPosition,a)<this._minSeg&&(i=!1)}i&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},oe.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},oe._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),uU.prototype._render.call(this,e)},oe._initGeometry=function(){var t=new uz(this._entity.engine),r=2*this._maxPointNum,n=20*r,i=new Float32Array(n),a=[new uP("POSITION",0,e.VertexElementFormat.Vector3,0),new uP("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new uF(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(a),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=i,this.mesh=t},oe._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new ce(r[0],r[4],r[8]),i=new ce(r[1],r[5],r[9]),a=new ce(r[2],r[6],r[10]),o=this._stroke;i.scale(o);var s=new ce,l=new ce,c=new cs;ce.transformByQuat(n,c,n),ce.transformByQuat(i,c,i);var u=new ce,d=new ce,h=new ce;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?ce.subtract(p,t[f-1],h):ce.subtract(t[f+1],p,h),this._projectOnPlane(h,a,h),h.normalize();var m=Math.acos(ce.dot(n,h));ce.cross(n,h,d),0>=ce.dot(d,a)&&(m=2*Math.PI-m),cs.rotationAxisAngle(a,m,c),ce.transformByQuat(i,c,u),ce.add(p,u,s),ce.subtract(p,u,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}},oe._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 i=1-n*t,a=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[a]=0,r[a+1]=i,r[o]=1,r[o+1]=i}}},oe._projectOnVector=function(e,t,r){var n=t.clone();ce.normalize(n,n);var i=ce.dot(e,n);r.x=n.x*i,r.y=n.y*i,r.z=n.z*i},oe._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,_d),ce.subtract(e,_d,r)},a9),__=(cx(ot=function(){var t;return t=d4.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},d4),(or=ot.prototype).onTextureChange=function(e){},or.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 ck(this.engine,this.width,this.height,this._isCube?new cW(this.engine,this.width):new cG(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new ck(this.engine,this.width,this.height,this._isCube?new cW(this.engine,this.width):new cG(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},or.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},or._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},cv(ot,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),ot),_f=new ce,_p=new ce,_m=new ce,_g=(cx(on=function(){var e;return e=__.apply(this,arguments)||this,e.position=new ce(0,0,0),e._isCube=!0,e.oriViewMatrix=new cl,e},__),(oi=on.prototype).onBeginRender=function(t){if(this.enabled){__.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),__.prototype._reset.call(this)}},oi._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},oi._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},oi._setCamera=function(e,t){switch(e){case 0:_p.set(0,-1,0),_m.set(1,0,0);break;case 1:_p.set(0,-1,0),_m.set(-1,0,0);break;case 2:_p.set(0,0,1),_m.set(0,1,0);break;case 3:_p.set(0,0,-1),_m.set(0,-1,0);break;case 4:_p.set(0,-1,0),_m.set(0,0,1);break;case 5:_p.set(0,-1,0),_m.set(0,0,-1)}ce.add(this.position,_m,_f),cl.lookAt(this.position,_f,_p,t.viewMatrix),t.fieldOfView=90},on),_v=Object.freeze({__proto__:null,AmbientLight:dZ,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:hF,AnimationClipCurveBinding:hb,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:hL,AnimationEvent:hP,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 AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:hN,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hz,AnimatorControllerLayer:hU,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:hG,AnimatorStateMachine:hH,AnimatorStateTransition:hB,AssetPromise:dt,get AssetType(){return e.AssetType},Background:dq,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:hm,Basic2DBatcher:u3,BasicRenderPipeline:hs,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:uN,BlendShapeFrame:uO,BlendState:up,BlinnPhongMaterial:hg,BoolUpdateFlag:c8,BoxColliderShape:dM,BoxShape:_a,Buffer:uF,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:uz,get BufferUsage(){return e.BufferUsage},BufferUtil:ub,Burst:_r,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},Canvas:dj,CapsuleColliderShape:db,CharacterController:df,CircleShape:_o,CloneManager:cb,get Collider(){return e.Collider},ColliderShape:dE,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:h0,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:cJ,get ConeEmitType(){return e.ConeEmitType},ConeShape:_s,ContentRestorer:cL,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:_g,get CullMode(){return e.CullMode},CurveKey:h8,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:um,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:d$,DynamicCollider:dp,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:h2,Engine:dK,EngineObject:cP,Entity:ue,EventDispatcher:cq,FixedJoint:dx,get FogMode(){return e.FogMode},Font:cY,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:hZ,GradientColorKey:hQ,HemisphereShape:_l,HingeJoint:dS,HitResult:dm,IndexBufferBinding:uL,get IndexFormat(){return e.IndexFormat},InputManager:dL,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:dT,JointMotor:dA,Keyframe:hW,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:dJ,Loader:hp,Logger:cz,MainModule:h3,Material:dD,Mesh:uI,MeshRenderer:uU,get MeshTopology(){return e.MeshTopology},ModelMesh:uG,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:hv,PBRMaterial:hy,PBRSpecularMaterial:hx,ParticleCompositeCurve:h1,ParticleCompositeGradient:hJ,ParticleCurve:h5,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:_e,ParticleGradient:hq,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_t,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:hY,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:dg,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:d_,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:dw,get Platform(){return e.Platform},PointLight:d0,Pointer:dl,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:uB,PrimitiveMesh:u0,Probe:__,RasterState:ug,ReferResource:cF,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:d8,RenderQueue:d7,get RenderQueueType(){return e.RenderQueueType},RenderState:uy,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:ck,RenderTargetBlendState:uf,get Renderer(){return e.Renderer},ResourceManager:dr,RotationOverLifetimeModule:h4,Scene:d3,SceneManager:de,Script:d4,get SetDataOptions(){return e.SetDataOptions},Shader:ux,ShaderData:uS,ShaderFactory:uo,ShaderMacro:ur,ShaderMacroCollection:un,ShaderPass:uh,ShaderProperty:cQ,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:us,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:h6,Skin:u1,SkinnedMeshRenderer:u2,Sky:dY,SkyBoxMaterial:hX,SkyProceduralMaterial:hK,SphereColliderShape:dR,SphereShape:_c,SpotLight:d1,SpringJoint:dC,Sprite:dz,SpriteAtlas:dN,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:uw,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:dG,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:hk,StaticCollider:dv,get StencilOperation(){return e.StencilOperation},StencilState:uv,SubMesh:uD,SubShader:u_,get SunMode(){return e.SunMode},SystemInfo:dd,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:dX,TextUtils:cK,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:cU,Texture2D:cG,Texture2DArray:cH,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:cW,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:h7,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:cZ,TrailMaterial:_u,TrailRenderer:_h,Transform:c7,UnlitMaterial:hS,Utils:c2,VelocityOverLifetimeModule:h9,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:uV,VertexElement:uP,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:cM,deepClone:cw,dependentComponents:c0,ignoreClone:cE,request:hd,resourceLoader:dn,shallowClone:cR});function _y(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 _x(e,t,r){return t&&_y(e.prototype,t),r&&_y(e,r),e}function _S(e,t){return(_S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _C(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&&_S(e,t)}function _T(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oa=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oa.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oa[oa.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oa[oa.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oa[oa.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oa[oa.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oa[oa.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oa[oa.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oa[oa.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oa[oa.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oa[oa.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oa[oa.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oa[oa.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oa[oa.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oa[oa.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oa[oa.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oa[oa.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oa[oa.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oa[oa.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oa[oa.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oa[oa.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oa[oa.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oa[oa.R11_EAC=37488]="R11_EAC",oa[oa.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oa[oa.RG11_EAC=37490]="RG11_EAC",oa[oa.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oa[oa.RGB8_ETC2=37492]="RGB8_ETC2",oa[oa.SRGB8_ETC2=37493]="SRGB8_ETC2",oa[oa.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oa[oa.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oa[oa.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oa[oa.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oa[oa.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oa[oa.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oa[oa.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oa[oa.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oa[oa.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oa[oa.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oa[oa.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oa[oa.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oa[oa.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oa[oa.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oa[oa.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oa[oa.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var _A=(_C(oo=function(e){(t=dj.call(this)||this)._scale=new cu;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},dj),(os=oo.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&_T(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},os.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},os._onWidthChanged=function(e){this._webCanvas.width=e},os._onHeightChange=function(e){this._webCanvas.height=e},_x(oo,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&_T(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&&_T(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),oo),_E=(_C(ol=function(){return dK.apply(this,arguments)},dK),ol.create=function(e){var t=e.canvas,r=new _A("string"==typeof t?document.getElementById(t):t),n=new _O(e.graphicDeviceOptions),i=new ol(r,n,e);return i._initialize(e).then(function(){return i.sceneManager.addScene(new d3(i,"DefaultScene")),i})},_x(ol,[{key:"canvas",get:function(){return this._canvas}}]),ol);function _M(){return(_M=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 _R=((ou=(oc=function(t,r,n,i,a){void 0===i&&(i=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,i),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(),a?o.bufferData(c,a,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},ou.setData=function(t,r,n,i,a,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,u=a?c*a:r.byteLength;if(0!==i||u<r.byteLength){var d=void 0!==r.byteOffset;if(this._isWebGL2&&d)s.bufferSubData(l,n,r,i,u/c);else{var h=new Uint8Array(d?r.buffer:r,i*c,u);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},ou.getData=function(e,t,r,n){if(this._isWebGL2){var i=this._gl;this.bind(),i.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},ou.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},ou._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),_w=((oh=(od=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oh.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,a=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,u=e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,d=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>=i&&t<=a?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=u?this.canIUse(e.GLCapabilityType.pvrtc):t>=d&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oh._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),i=e.GLCapabilityType.shaderVertexID,a=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,u=e.GLCapabilityType.instancedArrays,d=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,S=e.GLCapabilityType.pvrtc_webkit,C=e.GLCapabilityType.s3tc,T=e.GLCapabilityType.s3tc_webkit,A=e.GLCapabilityType.bptc,E=e.GLCapabilityType.textureFloat,M=e.GLCapabilityType.textureHalfFloat,R=e.GLCapabilityType.textureFloatLinear,w=e.GLCapabilityType.textureHalfFloatLinear,b=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic;t.set(i,r),t.set(a,r||!!n(a)),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(u,r||!!n(u)),t.set(d,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(E,r||!!n(E)),t.set(M,r||!!n(M)),t.set(R,!!n(R)),t.set(w,r||!!n(w)),t.set(P,r&&!!n(P)||!!n(b)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),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(S))),t.set(C,!!(n(C)||n(T))),t.set(A,!!n(A))},oh._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,i=null;if(i=r.requireExtension(e))for(var a in t){var o=i[t[a]];(null==o?void 0:o.bind)?n[a]=o.bind(i):n[a]=o}},oh._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,i=e.GLCapabilityType.drawBuffers,a=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(i,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var u={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var d=this.maxDrawBuffers,h=0;h<d;h++)0!=h&&(u["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),u["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(i,_M({drawBuffers:"drawBuffersWEBGL"},u))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},_x(od,[{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}}]),od),_b=((o_=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]},o_),_P=((op=(of=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,i=this._isSupportVAO&&n.enableVAO;if(i){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var a=this._vaoMap.get(e.id);r.bindVertexArray(a)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)r.drawElementsInstanced(u,h,l,d*c,s);else{var _=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,_),r.drawElementsInstanced(u,h,l,d*c,s),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArraysInstanced(u,d,h,s)}else cz.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(i)r.drawElements(u,h,l,d*c);else{var f=o.buffer._platformBuffer._glBuffer;r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,f),r.drawElements(u,h,l,d*c),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,null)}}else r.drawArrays(u,d,h);i?r.bindVertexArray(null):this._disableAttrib()},op.destroy=function(){this._isSupportVAO&&this._clearVAO()},op._bindBufferAndAttrib=function(e){var t,r,n=this._gl,i=this._primitive,a=i.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=i._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=a[u.bindingIndex],h=d.buffer,_=d.stride;r!==(t=h._platformBuffer._glBuffer)&&(r=t,n.bindBuffer(n.ARRAY_BUFFER,t)),n.enableVertexAttribArray(c);var f=u._formatMetaInfo;n.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&n.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else cz.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},op._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},op._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)},op._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},of),_F=((om=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]},om),_L=((ov=(og=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},ov.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},ov.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},ov._bind=function(){this._rhi.bindTexture(this)},ov._init=function(t){var r=this._gl,n=this._isWebGL2,i=this._formatDetail,a=i.internalFormat,o=i.baseFormat,s=i.dataType,l=this._texture,c=l.mipmapCount,u=l.width,d=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,a,u,d);else if(t)for(var f=0;f<c;f++)for(var p=Math.max(1,u>>f),m=0;m<6;m++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+m,f,a,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,a,u,d,0,o,s,null);else for(var g=0;g<c;g++){var v=Math.max(1,u>>g),y=Math.max(1,d>>g);r.texImage2D(this._target,g,a,v,y,0,o,s,null)}},ov._getPixelBuffer=function(e,t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,cz.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,a):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,a),s.readPixels(t,r,n,i,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},ov._setWrapMode=function(t,r){var n=this._gl,i=this._isWebGL2,a=this._target,o=this._texture,s=o.width,l=o.height;switch(i||t===e.TextureWrapMode.Clamp||og._isPowerOf2(s)&&og._isPowerOf2(l)||(cz.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(a,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(a,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(a,r,n.MIRRORED_REPEAT)}},ov._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},og._isPowerOf2=function(e){return(e&e-1)==0},og._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.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)}},og._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.RenderBufferDepthFormat.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.RenderBufferDepthFormat.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.RenderBufferDepthFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.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.RenderBufferDepthFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.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)}},og._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.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},og._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},og._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.RenderBufferDepthFormat.Depth24:case e.RenderBufferDepthFormat.Depth32:case e.RenderBufferDepthFormat.Depth32Stencil8:return!1}return!0},_x(og,[{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,i=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,i?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,i?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,i?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)}}}]),og),_D=((ox=(oy=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,i=r._depth,a=r.width,o=r.height,s=_T(i,cU),l=0,c=n.length;l<c;l++){var u=n[l]._format;if(!_L._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!_L._supportRenderBufferDepthFormat(i,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[i]+" 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!==a||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(i.width!==a||i.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return _T(e,cW)}))throw Error("MRT+Cube+[,MSAA] is not supported");var d=t.capability.maxAntiAliasing;r.antiAliasing>d&&(cz.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+d),r._antiAliasing=d),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),r.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).setRenderTargetInfo=function(e,t){var r=this._gl,n=this._target,i=n.depthTexture,a=n.getColorTexture(0),o=t!==this._curMipLevel;if(r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer),a){var s=_T(a,cW);(o||s)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+e:r.TEXTURE_2D,a._platformTexture._glTexture,t)}if(i){var l=_T(i,cW);if(o||l){var c=i._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,c._formatDetail.attachment,l?r.TEXTURE_CUBE_MAP_POSITIVE_X+e:r.TEXTURE_2D,c._glTexture,t)}}else if(o){var u=_L._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,u,n.width>>t,n.height>>t)}this._curMipLevel=t,this._activeRenderTarget()},ox.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,i=r.width,a=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,i,a,0,0,i,a,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},ox.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},ox._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},ox._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,i=r.colorTextureCount,a=r.width,o=r.height,s=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<i;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,_T(c,cW)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(_T(n,cU)&&!_T(n,cW)){var d=n._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=_L._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},ox._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,i=n._depth,a=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(a),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<a;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var d=_T(i,cU)?i._platformTexture._formatDetail:_L._getRenderBufferDepthFormatDetail(i,e,t),h=d.internalFormat,_=d.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)},ox._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.")},oy),_B=(_C(oS=function(t,r){(n=_L.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,i=r.format,a=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!_L._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||_L._isPowerOf2(o)&&_L._isPowerOf2(s)||(cz.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=_L._getFormatDetail(i,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},_L),(oC=oS.prototype).setPixelBuffer=function(e,t,r,n,i,a){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType,h=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(i=i||_-r,a=a||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,i,a,c,e):(o.compressedTexImage2D(this._target,t,c,i,a,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,i,a,u,d,e)},oC.setImageSource=function(t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,d=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,u,d,t):s.texSubImage2D(this._target,r,a||0,o||0,u,d,t)},oC.getPixelBuffer=function(e,t,r,n,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_L.prototype._getPixelBuffer.call(this,null,e,t,r,n,i,a)},oS),_I=(_C(oT=function(t,r){n=_L.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,i=r.format,a=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(!_L._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return n._bind(),n._formatDetail=_L._getFormatDetail(i,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,a,o,s),n},_L),(oA=oT.prototype).setPixelBuffer=function(e,t,r,n,i,a,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;a=a||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-i,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,i,e,a,o,s,d,t):c.texSubImage3D(l,r,n,i,e,a,o,s,h,_,t)},oA.setImageSource=function(e,t,r,n,i,a,o){var s,l,c=this._gl,u=this._formatDetail,d=u.baseFormat,h=u.dataType;this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,+n),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),c.texSubImage3D(this._target,r,a,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},oA.getPixelBuffer=function(e,t,r,n,i,a,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,a,e),s.readPixels(t,r,n,i,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oT),_V=(_C(oE=function(t,r){(n=_L.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,i=r.format,a=r._mipmap,o=r.width,s=n._isWebGL2;if(!_L._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||_L._isPowerOf2(o)||(cz.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=_L._getFormatDetail(i,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},_L),(oM=oE.prototype).setPixelBuffer=function(e,t,r,n,i,a,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,d=c.baseFormat,h=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>r);if(a=a||f-n,o=o||f-i,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,i,a,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,u,a,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,i,a,o,d,h,t)},oM.setImageSource=function(e,t,r,n,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+n),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,a||0,o||0,c,u,t)},oM.getPixelBuffer=function(e,t,r,n,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");_L.prototype._getPixelBuffer.call(this,e,t,r,n,i,a,o)},oE);e.WebGLMode=void 0,(oR=e.WebGLMode||(e.WebGLMode={}))[oR.Auto=0]="Auto",oR[oR.WebGL2=1]="WebGL2",oR[oR.WebGL1=2]="WebGL1";var _O=((ob=(ow=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new cd(null,null,null,null),this._lastScissor=new cd(null,null,null,null),this._lastClearColor=new ch(null,null,null,null),this._scissorEnable=!1;var r=_M({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(dd.platform===e.Platform.IPhone||dd.platform===e.Platform.IPad){var n=dd.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var i=parseInt(n[1]),a=parseInt(n[2]);15===i&&a>=0&&a<=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,i=this._options,a=e._webCanvas,o=i.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,a.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),a.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),a.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=a,(0==o||1==o)&&((n=a.getContext("webgl2",i))||"undefined"!=typeof OffscreenCanvas&&_T(a,OffscreenCanvas)||(n=a.getContext("experimental-webgl2",i)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=a.getContext("webgl",i))||"undefined"!=typeof OffscreenCanvas&&_T(a,OffscreenCanvas)||(n=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},ob.createPlatformPrimitive=function(e){return new _P(this,e)},ob.createPlatformTexture2D=function(e){return new _B(this,e)},ob.createPlatformTexture2DArray=function(e){return new _I(this,e)},ob.createPlatformTextureCube=function(e){return new _V(this,e)},ob.createPlatformRenderTarget=function(e){return new _D(this,e)},ob.createPlatformBuffer=function(t,r,n,i){return void 0===n&&(n=e.BufferUsage.Static),new _R(this,t,r,n,i)},ob.requireExtension=function(e){return this._extensions.requireExtension(e)},ob.canIUse=function(e){return this.capability.canIUse(e)},ob.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},ob.viewport=function(e,t,r,n){var i=this._gl,a=this._lastViewport;(e!==a.x||t!==a.y||r!==a.z||n!==a.w)&&(i.viewport(e,t,r,n),a.set(e,t,r,n))},ob.scissor=function(e,t,r,n){var i=this._gl,a=this._lastScissor;if(e!==a.x||t!==a.y||r!==a.z||n!==a.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(i.disable(i.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(i.enable(i.SCISSOR_TEST),this._scissorEnable=!0),i.scissor(e,t,r,n)),a.set(e,t,r,n)}},ob.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},ob.clearRenderTarget=function(t,r,n){var i=this._gl,a=t._lastRenderState,o=a.blendState.targetBlendState,s=a.depthState,l=a.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=i.COLOR_BUFFER_BIT;var u=this._lastClearColor,d=n.r,h=n.g,_=n.b,f=n.a;n&&(d!==u.r||h!==u.g||_!==u.b||f!==u.a)&&(i.clearColor(d,h,_,f),u.set(d,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(i.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=i.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(i.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=i.STENCIL_BUFFER_BIT,255!==l.writeMask&&(i.stencilMask(255),l.writeMask=255)),i.clear(c)},ob.drawPrimitive=function(e,t,r){e?e.draw(r,t):cz.error("draw primitive failed.")},ob.activeRenderTarget=function(e,t,r){var n,i,a,o=this._gl;e?(null==(a=e._platformRenderTarget)||a._activeRenderTarget(),n=e.width>>r,i=e.height>>r):(o.bindFramebuffer(o.FRAMEBUFFER,null),n=o.drawingBufferWidth,i=o.drawingBufferHeight);var s=n*t.z,l=i*t.w,c=t.x*n,u=i-t.y*i-l;this.viewport(c,u,s,l),this.scissor(c,u,s,l)},ob.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},ob.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)},ob.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},ob.flush=function(){this._gl.flush()},ob.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},ob.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},ob.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)},ob._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new _F(e),this._extensions=new _b(this),this._capability=new _w(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},ob.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},ob._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},ob._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},ob._onWebGLContextRestored=function(e){this._onDeviceRestored()},_x(ow,[{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}}]),ow);function _N(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)}}var _z=((oF=(oP=function(e,t){var r=this;this._costs={},this._currentLoad=0,this._callbacks={},this._worker=new Worker(e),this._worker.onmessage=function(e){var t=e.data;switch(t.type){case"decode":r._callbacks[t.id].resolve(t.geometry);break;case"error":r._callbacks[t.id].reject(t);break;default:cz.error('DRACOWorker: Unexpected message, "'+t.type+'"')}},t?this._worker.postMessage({type:"init",decoderConfig:{wasmBinary:t}}):this._worker.postMessage({type:"init",decoderConfig:{}})}).prototype).setCosts=function(e,t){this._costs[e]=t},oF.addCurrentLoad=function(e){this._currentLoad+=e},oF.setCallback=function(e,t,r){this._callbacks[e]={resolve:t,reject:r}},oF.decode=function(e,t,r){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:r},[r])},oF.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},_N(oP.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),oL&&_N(oP,oL),oP),_U='let decoderPending;\nlet decoderConfig;\n\nonmessage = function(e) {\n const message = e.data;\n\n switch (message.type) {\n case "init":\n decoderConfig = message.decoderConfig;\n decoderPending = new Promise(function(resolve /*, reject*/) {\n decoderConfig.onModuleLoaded = function(draco) {\n // Module is Promise-like. Wrap before resolving to avoid loop.\n resolve({ draco: draco });\n };\n DracoDecoderModule(decoderConfig);\n });\n break;\n\n case "decode":\n const buffer = message.buffer;\n const taskConfig = message.taskConfig;\n decoderPending.then(module => {\n const draco = module.draco;\n const decoder = new draco.Decoder();\n const decoderBuffer = new draco.DecoderBuffer();\n decoderBuffer.Init(new Int8Array(buffer), buffer.byteLength);\n try {\n const geometry = decodeGeometry(draco, decoder, decoderBuffer, taskConfig);\n const buffers = geometry.attributes.map(attr => attr.array.buffer);\n if (geometry.index) buffers.push(geometry.index.array.buffer);\n self.postMessage({ type: "decode", id: message.id, geometry }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n } finally {\n draco.destroy(decoderBuffer);\n draco.destroy(decoder);\n }\n });\n break;\n }\n};\n\nfunction decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {\n const attributeIDs = taskConfig.attributeIDs;\n const attributeTypes = taskConfig.attributeTypes;\n\n let dracoGeometry;\n let decodingStatus;\n\n const geometryType = decoder.GetEncodedGeometryType(decoderBuffer);\n if (geometryType === draco.TRIANGULAR_MESH) {\n dracoGeometry = new draco.Mesh();\n decodingStatus = decoder.DecodeBufferToMesh(decoderBuffer, dracoGeometry);\n } else {\n throw new Error("DRACODecoder worker: Unexpected geometry type.");\n }\n\n if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {\n throw new Error("DRACODecoder worker: Decoding failed: " + decodingStatus.error_msg());\n }\n\n const geometry = { index: null, attributes: [] };\n\n // Gather all vertex attributes.\n for (let attributeName in attributeIDs) {\n const attributeType = self[attributeTypes[attributeName]];\n\n let attribute;\n let attributeID;\n\n // A Draco file may be created with default vertex attributes, whose attribute IDs\n // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,\n // a Draco file may contain a custom set of attributes, identified by known unique\n // IDs. glTF files always do the latter, and .drc files typically do the former.\n if (taskConfig.useUniqueIDs) {\n attributeID = attributeIDs[attributeName];\n attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);\n } else {\n attributeID = decoder.GetAttributeId(dracoGeometry, draco[attributeIDs[attributeName]]);\n if (attributeID === -1) continue;\n attribute = decoder.GetAttribute(dracoGeometry, attributeID);\n }\n geometry.attributes.push(decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute));\n }\n // Add index.\n if (geometryType === draco.TRIANGULAR_MESH) {\n // Generate mesh faces.\n const numFaces = dracoGeometry.num_faces();\n const numIndices = numFaces * 3;\n let dataSize;\n let ptr;\n let index;\n const indexType = self[taskConfig.indexType];\n\n switch (indexType) {\n case Uint16Array:\n dataSize = numIndices * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt16Array(dracoGeometry, dataSize, ptr);\n index = new Uint16Array(draco.HEAPU16.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n case Uint32Array:\n dataSize = numIndices * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt32Array(dracoGeometry, dataSize, ptr);\n index = new Uint32Array(draco.HEAPU32.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n default:\n throw new Error("DRACODecoder: Unexpected index type.");\n }\n geometry.index = { array: index, itemSize: 1 };\n }\n draco.destroy(dracoGeometry);\n return geometry;\n}\n\nfunction decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute) {\n const numComponents = attribute.num_components();\n const numPoints = dracoGeometry.num_points();\n const numValues = numPoints * numComponents;\n let ptr;\n let array;\n let dataSize;\n switch (attributeType) {\n case Float32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_FLOAT32, dataSize, ptr);\n array = new Float32Array(draco.HEAPF32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT8, numValues, ptr);\n array = new Int8Array(draco.HEAP8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT16, dataSize, ptr);\n array = new Int16Array(draco.HEAP16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT32, dataSize, ptr);\n array = new Int32Array(draco.HEAP32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT8, numValues, ptr);\n array = new Uint8Array(draco.HEAPU8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT16, dataSize, ptr);\n array = new Uint16Array(draco.HEAPU16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT32, dataSize, ptr);\n array = new Uint32Array(draco.HEAPU32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n default:\n throw new Error("DRACODecoder: Unexpected attribute type.");\n }\n\n return {\n name: attributeName,\n array: array,\n itemSize: numComponents\n };\n}\n',_k="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",_G=((oB=(oD=function(e){if(void 0===e&&(e={type:"wasm",workerLimit:4}),this.pool=[],this.workerLimit=Math.min(navigator.hardwareConcurrency||4,4),this.currentTaskId=1,this.taskCache=new WeakMap,e.workerLimit>this.workerLimit)cz.warn("DRACOWorkerPool: Can not initialize worker pool with limit:"+e.workerLimit);else{var t;this.workerLimit=null!=(t=e.workerLimit)?t:4}this.useJS="object"!=typeof WebAssembly||"js"===e.type,this.loadLibPromise=this.preloadLib()}).prototype).preloadLib=function(){var e=this;return this.loadLibPromise?this.loadLibPromise:new Promise(function(t,r){e.useJS?hd(""+_k+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var r=[e,_U].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([r])),decoderWASMBinary:null})}).catch(function(e){r(e)}):Promise.all([hd(""+_k+"draco_wasm_wrapper_gltf.js",{type:"text"}),hd(""+_k+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var r=e[0],n=e[1],i=[r,_U].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:n})}).catch(function(e){r(e)})})},oB.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var r=new _z(t.workerSourceURL,t.decoderWASMBinary);e.pool.push(r)}else e.pool.sort(function(e,t){return e.currentLoad>t.currentLoad?-1:1});return e.pool[e.pool.length-1]})},oB.decode=function(e,t){var r,n=this,i=JSON.stringify(t);if(this.taskCache.has(e)){var a=this.taskCache.get(e);if(a.key===i)return a.promise;if(0===e.byteLength)throw Error("DRACODecoder: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var o=this.currentTaskId++,s=e.byteLength,l=new Promise(function(i,a){n.getWorker().then(function(n){r=n,n.setCosts(o,s),n.addCurrentLoad(s),n.setCallback(o,i,a),n.decode(o,t,e)}).catch(function(e){a(e)})});return l.finally(function(){r&&o&&r.releaseTask(o)}),this.taskCache.set(e,{key:i,promise:l}),l},oD);function _H(){return(_H=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 _W(e,t){return(_W=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _X(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 _K(e,t,r,n){var i,a=arguments.length,o=a<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--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,r,o):i(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o}function _j(e,t){var r,n,i,a,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=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(!(i=(i=l.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=i=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&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a}function _Y(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 _q(e,t,r){return t&&_Y(e.prototype,t),r&&_Y(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var _Q=((oV=(oI=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},oV.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},oV.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},oV.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},oV.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},oV.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},oV.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},oV.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},oV.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,c2.decodeText(t)},oV.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},oV.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 i=[],a=0;a<e;a++){var o=t[a],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,i.push(s)}return i},oV.skip=function(e){return this._position+=e,this},oV.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)},_q(oI,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),oI),_Z={};function _J(e){return function(t){_Z[e]=t}}var _$=((oO=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),i=t.getUint16(5,!0),a=new Uint8Array(e,7,i),o=t.getUint16(7+i,!0),s=new Uint8Array(e,9+i,o),l=c2.decodeText(s),c=c2.decodeText(a),u=new oO;return u.totalLength=r,u.name=l,u.type=c,u.version=n,u.headerLength=s.byteLength+a.byteLength+9,u},_q(oO,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oO);function _0(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cd(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function _1(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new ce(e[3*n],e[3*n+1],e[3*n+2]);return r}function _2(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cu(e[2*n],e[2*n+1]);return r}function _3(e,t,r){return(_3=!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 i=new(Function.bind.apply(e,n));return r&&_W(i,r.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oN=function(){}).decode=function(e,t){return new Promise(function(r){var n=new uG(e),i=JSON.parse(t.nextStr());i.bounds&&n.bounds.copyFrom(i.bounds);var a=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,i.positions.start+a,(i.positions.end-i.positions.start)/4),l=s.length/3,c=_1(s,l);if(n.setPositions(c),i.normals){var u=_1(new Float32Array(o,i.normals.start+a,(i.normals.end-i.normals.start)/4),l);n.setNormals(u)}if(i.uvs){var d=new Float32Array(o,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);n.setUVs(_2(d,l))}if(i.uv1){var h=new Float32Array(o,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);n.setUVs(_2(h,l),1)}if(i.uv2){var _=new Float32Array(o,i.uv2.start+a,(i.uv2.end-i.uv2.start)/4);n.setUVs(_2(_,l),2)}if(i.uv3){var f=new Float32Array(o,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);n.setUVs(_2(f,l),3)}if(i.uv4){var p=new Float32Array(o,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);n.setUVs(_2(p,l),4)}if(i.uv5){var m=new Float32Array(o,i.uv5.start+a,(i.uv5.end-i.uv5.start)/4);n.setUVs(_2(m,l),5)}if(i.uv6){var g=new Float32Array(o,i.uv6.start+a,(i.uv6.end-i.uv6.start)/4);n.setUVs(_2(g,l),6)}if(i.uv7){var v=new Float32Array(o,i.uv7.start+a,(i.uv7.end-i.uv7.start)/4);n.setUVs(_2(v,l),7)}if(i.colors){var y=new Float32Array(o,i.colors.start+a,(i.colors.end-i.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new ch(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(i.boneWeights){var x=new Float32Array(o,i.boneWeights.start+a,(i.boneWeights.end-i.boneWeights.start)/4);n.setBoneWeights(_0(x,l))}if(i.boneIndices){var S=new Float32Array(o,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);n.setBoneIndices(_0(S,l))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var t=new uN(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+a,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,i=_1(r,n);e.deltaNormals&&_1(new Float32Array(o,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&_0(new Float32Array(o,e.deltaTangents.start+a,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,i)}),n.addBlendShape(t)}),i.indices){var C=null;C=0===i.indices.type?new Uint16Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/2):new Uint32Array(o,i.indices.start+a,(i.indices.end-i.indices.start)/4),n.setIndices(C)}i.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},oN),e.MeshDecoder=_K([_J("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oz=function(){}).decode=function(e,t){return new Promise(function(r,n){var i=t.nextStr(),a=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new cG(e,d,h,u,a);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),a){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[i]=m,r(m)}else{var x=new window.Blob([p[0]]),S=new Image;S.onload=function(){m.setImageSource(S);var e=0,t=function(){++e>=f&&r(m)};if(t(),a){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 i=1;i<f;i++)n(i)}},S.src=URL.createObjectURL(x)}})},oz),e.Texture2DDecoder=_K([_J("Texture2D")],e.Texture2DDecoder);var _4=((ok=(oU=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,i=e.position,a=e.rotation,o=e.scale;return i&&t.transform.position.copyFrom(i),a&&t.transform.rotation.copyFrom(a),o&&t.transform.scale.copyFrom(o),t.layer=null!=(n=e.layer)?n:t.layer,t})},ok.parseClassObject=function(e){var t,r=this,n=hp.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return _3(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},ok.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var i=t.methods[n],a=0,o=i.length;a<o;a++)r.push(this.parseMethod(e,n,i[a]));if(t.props){var s=this,l=function(n){var i=t.props[n],a=s.parseBasicType(i,e[n]).then(function(t){return e[n]=t});r.push(a)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=oU.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},ok.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))})},ok.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(oU._isClass(e))return this.parseClassObject(e);if(oU._isAssetRef(e))return this._context.resourceManager.getResourceByRef(e);if(oU._isEntityRef(e))return Promise.resolve(this._context.entityMap.get(e.entityId));if(t){var n=this,i=function(r){if("methods"===r){var i=e[r];for(var o in i)for(var s=i[o],l=0,c=s.length;l<c;l++){var u=s[l];a.push(n.parseMethod(t,o,u))}}else a.push(n.parseBasicType(e[r],t[r]).then(function(e){return t[r]=e}))},a=[];for(var o in e)i(o);return Promise.all(a).then(function(){return t})}}return Promise.resolve(e)},ok._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 ue(r,e.name))},oU.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oU._isClass=function(e){return void 0!=e.class},oU._isAssetRef=function(e){return void 0!=e.refId},oU._isEntityRef=function(e){return void 0!=e.entityId},oU);_4.customParseComponentHandles=new Map;var _5=((oG=function(){}).parseChildren=function(e,t,r){var n=e.get(r).children;if(n&&n.length>0)for(var i=t.get(r),a=0;a<n.length;a++){var o=n[a],s=t.get(o);i.addChild(s),this.parseChildren(e,t,o)}},oG),_8={Transform:c7,Animator:hN,DirectLight:d$,Camera:e.Camera,MeshRenderer:uU,ParticleRenderer:hY,PointLight:d0,SpotLight:d1,Script:d4,SpriteMask:uw,SpriteRenderer:dG,TextRenderer:dX};function _6(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 _7(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 _6(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 _6(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.")}e.InterpolableValueType=void 0,(oH=e.InterpolableValueType||(e.InterpolableValueType={}))[oH.Float=0]="Float",oH[oH.FloatArray=1]="FloatArray",oH[oH.Vector2=2]="Vector2",oH[oH.Vector3=3]="Vector3",oH[oH.Vector4=4]="Vector4",oH[oH.Quaternion=5]="Quaternion",oH[oH.Color=6]="Color",oH[oH.Array=7]="Array",oH[oH.Boolean=8]="Boolean",oH[oH.Rect=9]="Rect",oH[oH.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((oW=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),i=new hF(n),a=r.nextUint16(),o=0;o<a;++o){var s=new hP;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,i.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var u=r.nextStr(),d=_8[r.nextStr()],h=r.nextStr(),_=void 0,f=r.nextUint8(),p=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(_=new e.AnimationFloatCurve).interpolation=f;for(var m=0;m<p;++m){var g=new hW;g.time=r.nextFloat32(),g.value=r.nextFloat32(),g.inTangent=r.nextFloat32(),g.outTangent=r.nextFloat32(),_.addKey(g)}break;case"AnimationArrayCurve":(_=new e.AnimationArrayCurve).interpolation=f;for(var v=0;v<p;++v){var y=new hW;y.time=r.nextFloat32();var x=r.nextUint16();y.value=Array.from(r.nextFloat32Array(x)),y.inTangent=Array.from(r.nextFloat32Array(x)),y.outTangent=Array.from(r.nextFloat32Array(x)),_.addKey(y)}break;case"AnimationFloatArrayCurve":(_=new e.AnimationFloatArrayCurve).interpolation=f;for(var S=0;S<p;++S){var C=new hW;C.time=r.nextFloat32();var T=r.nextUint16();C.value=r.nextFloat32Array(T),C.inTangent=Array.from(r.nextFloat32Array(T)),C.outTangent=Array.from(r.nextFloat32Array(T)),_.addKey(C)}break;case"AnimationVector2Curve":(_=new e.AnimationVector2Curve).interpolation=f;for(var A=0;A<p;++A){var E=new hW;E.time=r.nextFloat32(),E.value=new cu(r.nextFloat32(),r.nextFloat32()),E.inTangent=new cu(r.nextFloat32(),r.nextFloat32()),E.outTangent=new cu(r.nextFloat32(),r.nextFloat32()),_.addKey(E)}break;case"AnimationVector3Curve":(_=new e.AnimationVector3Curve).interpolation=f;for(var M=0;M<p;++M){var R=new hW;R.time=r.nextFloat32(),R.value=new ce(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),R.inTangent=new ce(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),R.outTangent=new ce(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(R)}break;case"AnimationVector4Curve":(_=new e.AnimationVector4Curve).interpolation=f;var w=new hW;w.time=r.nextFloat32(),w.value=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(w);break;case"AnimationColorCurve":(_=new e.AnimationColorCurve).interpolation=f;for(var b=0;b<p;++b){var P=new hW;P.time=r.nextFloat32(),P.value=new ch(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(P)}break;case"AnimationQuaternionCurve":(_=new e.AnimationQuaternionCurve).interpolation=f;for(var F=0;F<p;++F){var L=new hW;L.time=r.nextFloat32(),L.value=new cs(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new cd(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),_.addKey(L)}break;case"AnimationRefCurve":(_=new e.AnimationRefCurve).interpolation=f;for(var D=0;D<p;++D){var B=new hW;B.time=r.nextFloat32(),B.value=JSON.parse(r.nextStr()),_.addKey(B)}}i.addCurveBinding(u,d,h,_)}t(i)})},oW),e.AnimationClipDecoder=_K([_J("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(oX=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",oX.Custom="Custom";var _9=((oK=function(e,t){this.originalData=e,this.scene=t,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[],this.engine=t.engine,this.resourceManager=t.engine.resourceManager}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},oK),fe=((oY=(oj=function(e){var t=this;this.context=e,this._engine=e.scene.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._clearAndResolveScene=this._clearAndResolveScene.bind(this),this.promise=new Promise(function(e,r){t._reject=r,t._resolve=e}),this._reflectionParser=new _4(e)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject)},oY._parseEntities=function(){var e=this,t=this.context.originalData.entities,r=this.context.entityConfigMap,n=this.context.entityMap,i=this.context.rootIds;return this._engine,Promise.all(t.map(function(t){return r.set(t.id,t),t.parent||i.push(t.id),e._reflectionParser.parseEntity(t)})).then(function(e){for(var r=0,i=e.length;r<i;r++)n.set(t[r].id,e[r]);return e})},oY._organizeEntities=function(){for(var e,t=this.context,r=t.entityConfigMap,n=t.entityMap,i=t.scene,a=t.rootIds,o=_7(a);!(e=o()).done;){var s=e.value;_5.parseChildren(r,n,s)}for(var l=a.map(function(e){return n.get(e)}),c=0;c<l.length;c++)i.addRootEntity(l[c])},oY._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,r=[],n=0,i=e.length;n<i;n++)for(var a=e[n],o=t.get(a.id),s=0;s<a.components.length;s++){var l=a.components[s],c=l.refId?l.refId:l.class,u=void 0;"Animator"===c&&(u=o.getComponent(hp.getClass(c))),u=u||o.addComponent(hp.getClass(c));var d=this._reflectionParser.parsePropsAndMethods(u,l);r.push(d)}return Promise.all(r)},oY._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oj.parse=function(e,t){var r=new d3(e),n=new _9(t,r),i=new oj(n);return i.start(),i.promise},oj);function ft(e,t){var r=_$.decode(e),n=new _Q(new Uint8Array(e),r.headerLength,r.dataLength);return _Z[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(_X(oq=function(){return hp.apply(this,arguments)},hp),oq.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,{type:"arraybuffer"}).then(function(e){ft(e,t.engine).then(function(e){n(e)})}).catch(i)})},oq),e.MeshLoader=_K([dn("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(_X(oQ=function(){return hp.apply(this,arguments)},hp),oQ.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,{type:"arraybuffer"}).then(function(e){ft(e,t.engine).then(function(e){n(e)})}).catch(i)})},oQ),e.EditorTextureLoader=_K([dn("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var fr=(_X(oZ=function(){return hp.apply(this,arguments)},hp),oZ.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,_H({},e,{type:"arraybuffer"})).then(function(e){return ft(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){var r=e.value;if("object"==typeof r&&r.refId)return new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e)}).catch(i)})}))})).then(function(){n(e)})})}).catch(i)})},oZ);fr=_K([dn(e.AssetType.AnimationClip,["ani"])],fr);var fn=(_X(oJ=function(){return hp.apply(this,arguments)},hp),oJ.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,_H({},e,{type:"json"})).then(function(e){var r=new hz,i=e.layers,a=[];i.forEach(function(e,n){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hU(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,d=c.stateMachine=new hH;u.forEach(function(e,r){var i=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,u=e.isDefaultState,h=e.clip,_=e.scripts,f=d.addState(i);u&&(d.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(hp.getClass(e))}),h&&a.push(new Promise(function(e){t.getResourceByRef(h).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),u.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var r=e.targetStateName,n=e.duration,i=e.offset,a=e.exitTime,o=d.findStateByName(t),s=d.findStateByName(r),l=new hB;l.destinationState=s,l.duration=n,l.exitTime=a,l.offset=i,o.addTransition(l)})})}r.addLayer(c)}),Promise.all(a).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,i=e.clip;r.layers[t].stateMachine.states[n].clip=i}),n(r)})}).catch(i)})},oJ);fn=_K([dn(e.AssetType.AnimatorController,["json"],!1)],fn);var fi=(_X(o$=function(){return hp.apply(this,arguments)},hp),o$.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new dt(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,_H({},e,{type:"arraybuffer"}))},o$);fi=_K([dn(e.AssetType.Buffer,["bin","r3bin"],!1)],fi);var fa=(_X(o0=function(){return hp.apply(this,arguments)},hp),o0.prototype.load=function(t,r){var n=this;return new dt(function(i,a){n.request(t.url,{type:"arraybuffer"}).then(function(t){var n=new Float32Array(t,0,27),a=new Uint16Array(t,108,1)[0],o=r.engine,s=new cW(o,a);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var d=a>>u,h=0;h<6;h++){var _=d*d*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+h,f,u)}var p=new dZ(o),m=new cf;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,i(p)}).catch(function(e){a(e)})})},o0);function fo(e,t,r,n,i,a,o){try{var s=e[a](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function fs(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var a=e.apply(t,r);function o(e){fo(a,n,i,o,s,"next",e)}function s(e){fo(a,n,i,o,s,"throw",e)}o(void 0)})}}fa=_K([dn(e.AssetType.Env,["env"])],fa);var fl=(_X(o1=function(){return hp.apply(this,arguments)},hp),(o2=o1.prototype).load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,{type:"json"}).then(function(e){var a=e.fontName,o=e.fontUrl;o?r._registerFont(a,o).then(function(){n(new cY(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):n(new cY(t.engine,a))}).catch(function(e){i(e)})})},o2._registerFont=function(e,t){return fs(function(){var r;return _j(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]}})})()},o1);fl=_K([dn(e.AssetType.Font,["font"],!1)],fl);var fc=(_X(o3=function(e,t){var r;return(r=cF.call(this,e)||this).url=t,r},cF),o3);(o4=lY||(lY={}))[o4.BYTE=5120]="BYTE",o4[o4.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",o4[o4.SHORT=5122]="SHORT",o4[o4.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",o4[o4.UNSIGNED_INT=5125]="UNSIGNED_INT",o4[o4.FLOAT=5126]="FLOAT",(o5=lq||(lq={})).SCALAR="SCALAR",o5.VEC2="VEC2",o5.VEC3="VEC3",o5.VEC4="VEC4",o5.MAT2="MAT2",o5.MAT3="MAT3",o5.MAT4="MAT4",(o8=lQ||(lQ={})).TRANSLATION="translation",o8.ROTATION="rotation",o8.SCALE="scale",o8.WEIGHTS="weights",(o6=lZ||(lZ={})).Linear="LINEAR",o6.Step="STEP",o6.CubicSpine="CUBICSPLINE",(o7=lJ||(lJ={})).PERSPECTIVE="perspective",o7.ORTHOGRAPHIC="orthographic",(o9=l$||(l$={})).JPEG="image/jpeg",o9.PNG="image/png",(se=l0||(l0={})).OPAQUE="OPAQUE",se.MASK="MASK",se.BLEND="BLEND",(st=l1||(l1={}))[st.NEAREST=9728]="NEAREST",st[st.LINEAR=9729]="LINEAR",(sr=l2||(l2={}))[sr.NEAREST=9728]="NEAREST",sr[sr.LINEAR=9729]="LINEAR",sr[sr.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sr[sr.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sr[sr.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sr[sr.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sn=l3||(l3={}))[sn.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sn[sn.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sn[sn.REPEAT=10497]="REPEAT";var fu=((sa=(si=function(e,t,r){this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this._resourceCache=new Map,this.contentRestorer=new fE(e)}).prototype).get=function(e,t){var r=this,n=si._parsers[e];if(!n)return Promise.resolve(null);var i=this._resourceCache,a=0===e||1===e,o=a||void 0===t?""+e:e+":"+t,s=i.get(o);if(s)return s;if(a)s=n.parse(this);else{var l=this.glTF[fh[e]];l&&(void 0===t||l[t])?void 0===t?s=8===e?l.map(function(t,n){return r.get(e,n)}):Promise.all(l.map(function(t,n){return r.get(e,n)})):(s=n.parse(this,t),this._handleSubAsset(s,e,t)):s=Promise.resolve(null)}return i.set(o,s),s},sa.parse=function(){var e=this;return this.get(0).then(function(t){return e.glTF=t,Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(2)]).then(function(){var t=e.glTFResource;return(t.skins||t.animations)&&e._createAnimator(e,t.animations),e.resourceManager.addContentRestorer(e.contentRestorer),t})})},sa._createAnimator=function(e,t){var r=e.glTFResource.defaultSceneRoot.addComponent(hN),n=new hz,i=new hU("layer"),a=new hH;if(n.addLayer(i),r.animatorController=n,i.stateMachine=a,t)for(var o=0;o<t.length;o++){var s=t[o],l=s.name,c=a.makeUniqueStateName(l);c!==l&&console.warn("AnimatorState name is existed, name: "+l+" reset to "+c),a.addState(c).clip=s}},sa._handleSubAsset=function(e,t,r){var n,i=this,a=f_[t];if(a){if(8===t)((n=this.glTFResource)[a]||(n[a]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(((n=i.glTFResource)[a]||(n[a]=[]))[r]=e,7===t)for(var n,s,l=0,c=e.length;l<c;l++){var u=e[l];i.resourceManager._onSubAssetSuccess(o+"?q="+a+"["+r+"]["+l+"]",u)}else i.resourceManager._onSubAssetSuccess(o+"?q="+a+"["+r+"]",e),2===t&&(null!=(s=i.glTF.scene)?s:0)===r&&i.resourceManager._onSubAssetSuccess(""+o+"?q=defaultSceneRoot",e)})}}},si.addParser=function(e,t){this._parsers[e]=t},si);fu._parsers={};var fd=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(so=e.GLTFParserType||(e.GLTFParserType={}))[so.Schema=0]="Schema",so[so.Validator=1]="Validator",so[so.Scene=2]="Scene",so[so.Buffer=3]="Buffer",so[so.BufferView=4]="BufferView",so[so.Texture=5]="Texture",so[so.Material=6]="Material",so[so.Mesh=7]="Mesh",so[so.Entity=8]="Entity",so[so.Skin=9]="Skin",so[so.Animation=10]="Animation";var fh=((l4={})[2]="scenes",l4[3]="buffers",l4[5]="textures",l4[6]="materials",l4[7]="meshes",l4[8]="nodes",l4[9]="skins",l4[10]="animations",l4[4]="bufferViews",l4),f_=((l5={})[2]="sceneRoots",l5[5]="textures",l5[6]="materials",l5[7]="meshes",l5[8]="entities",l5[9]="skins",l5[10]="animations",l5);function ff(e){return function(t){var r=new t;fu.addParser(e,r)}}var fp=((ss=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new cu(e[n],e[n+1]);return r},ss.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new ce(e[n],e[n+1],e[n+2]);return r},ss.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new cd(e[n],e[n+1],e[n+2],e[n+3]);return r},ss.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var i=0;i<r;i+=3)n[i/3]=new ch(e[i],e[i+1],e[i+2],1);else for(var a=0;a<r;a+=4)n[a/4]=new ch(e[a],e[a+1],e[a+2],e[a+3]);return n},ss.getAccessorTypeSize=function(e){switch(e){case lq.SCALAR:return 1;case lq.VEC2:return 2;case lq.VEC3:return 3;case lq.VEC4:case lq.MAT2:return 4;case lq.MAT3:return 9;case lq.MAT4:return 16}},ss.getComponentType=function(e){switch(e){case lY.BYTE:return Int8Array;case lY.UNSIGNED_BYTE:return Uint8Array;case lY.SHORT:return Int16Array;case lY.UNSIGNED_SHORT:return Uint16Array;case lY.UNSIGNED_INT:return Uint32Array;case lY.FLOAT:return Float32Array}},ss.getNormalizedComponentScale=function(e){switch(e){case lY.BYTE:return 1/127;case lY.UNSIGNED_BYTE:return 1/255;case lY.SHORT:return 1/32767;case lY.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},ss.getAccessorBuffer=function(t,r,n){var i,a=n.componentType,o=ss.getComponentType(a),s=ss.getAccessorTypeSize(n.type),l=o.BYTES_PER_ELEMENT,c=s*l,u=n.count;if(void 0!==n.bufferView){var d=n.bufferView,h=r[d];i=t.get(e.GLTFParserType.BufferView,n.bufferView).then(function(e){var r,i,_,f=h.buffer,p=null!=(r=e.byteOffset)?r:0,m=null!=(i=n.byteOffset)?i:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+a+":"+v+":"+u,x=t.accessorBufferCache;if(!(_=x[y])){var S=p+v*g,C=u*(g/l),T=new o(e.buffer,S,C);x[y]=_=new fd(T,!0,g),_.restoreInfo=new fP(new fF(f,o,S,C))}}else{var A=p+m,E=u*s,M=new o(e.buffer,A,E);(_=new fd(M,!1,c)).restoreInfo=new fP(new fF(f,o,A,E))}return _})}else{var _=u*s,f=new o(_),p=new fd(f,!1,c);p.restoreInfo=new fP(new fF(void 0,o,void 0,_)),i=Promise.resolve(p)}return n.sparse?i.then(function(e){return ss.processingSparseData(t,n,e).then(function(){return e})}):i},ss.bufferToVector3Array=function(e,t,r,n,i){for(var a=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?ss.getNormalizedComponentScale(i):1,c=0;c<r;c++){var u=a+c*o;s[c]=new ce(e[u]*l,e[u+1]*l,e[u+2]*l)}return s},ss.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},ss.processingSparseData=function(t,r,n){var i=n.restoreInfo,a=t.glTF.bufferViews,o=ss.getAccessorTypeSize(r.type),s=ss.getComponentType(r.componentType),l=n.data.slice(),c=r.sparse,u=c.count,d=c.indices,h=c.values,_=a[d.bufferView],f=a[h.bufferView];return Promise.all([t.get(e.GLTFParserType.BufferView,d.bufferView),t.get(e.GLTFParserType.BufferView,h.bufferView)]).then(function(e){var t,r,a,c,p=e[0],m=e[1],g=(null!=(t=d.byteOffset)?t:0)+(null!=(r=p.byteOffset)?r:0),v=p.byteLength,y=(null!=(a=h.byteOffset)?a:0)+(null!=(c=m.byteOffset)?c:0),x=m.byteLength;i.typeSize=o,i.sparseCount=u;var S=ss.getComponentType(d.componentType),C=v/S.BYTES_PER_ELEMENT,T=new S(p.buffer,g,C);i.sparseIndices=new fF(_.buffer,S,g,C);var A=x/s.BYTES_PER_ELEMENT,E=new s(m.buffer,y,A);i.sparseValues=new fF(f.buffer,s,y,A);for(var M=0;M<u;M++)for(var R=T[M],w=0;w<o;w++)l[R*o+w]=E[M*o+w];n.data=l})},ss.getIndexFormat=function(t){switch(t){case lY.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case lY.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case lY.UNSIGNED_INT:return e.IndexFormat.UInt32}},ss.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==lY.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==lY.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==lY.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==lY.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==lY.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},ss.loadImageBuffer=function(e,t){return new Promise(function(r,n){var i=new window.Blob([e],{type:t}),a=new Image;a.onerror=function(){n(Error("Failed to load image buffer"))},a.onload=function(){requestAnimationFrame(function(){r(a),a.onload=null,a.onerror=null,a.onabort=null})},a.crossOrigin="anonymous",a.src=URL.createObjectURL(i)})},ss.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),i={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==i.magic)return{originBuffer:t};var a=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,a),l=JSON.parse(c2.decodeText(s)),c=[],u=20+a,d=e.contentRestorer.glbBufferSlices;u<i.length;){if(a=n.getUint32(u,!0),(o=n.getUint32(u+4,!0))!==r.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+o.toString(16)),null;var h=u+8,_=t.slice(h,h+a);c.push(_),d.push(new cu(h,a)),u+=a+8}return{glTF:l,buffers:c}},ss.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,i=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==i&&(e.wrapModeV=i)},ss.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,i=t.wrapS,a=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=l2.NEAREST_MIPMAP_NEAREST,n===l1.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=l2.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),i&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[i]),a&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[a]),o},ss);(sl=l8||(l8={}))[sl.linear=1]="linear",sl[sl.sRGB=2]="sRGB",(sc=l6||(l6={}))[sc.ETC1S=163]="ETC1S",sc[sc.UASTC=166]="UASTC",(su=l7||(l7={}))[su.None=0]="None",su[su.BasisLZ=1]="BasisLZ",su[su.Zstd=2]="Zstd",su[su.ZLib=3]="ZLib";var fm=((sd=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 _Q(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 i=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var a=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),u=n.nextUint64(),d=Array(i),h=24*i,_=new _Q(e,n.offset,h);this.levels=d;for(var f=0;f<i;f++)d[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new _Q(e,a,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 _Q(e,s,l,!0);x.position<l;){var S=x.nextUint32(),C=x.scan(S),T=c2.decodeText(C),A=x.nextUint8Array(S-C.byteLength-1);this.keyValue[T]=T.match(/^ktx/i)?c2.decodeText(A).replace(/^(.*)\x00$/,"$1"):A;var E=S%4?4-S%4:0;x.skip(E)}if(u<=0)return this;for(var M=new _Q(e,c,u,!0),R=M.nextUint16(),w=M.nextUint16(),b=M.nextUint32(),P=M.nextUint32(),F=M.nextUint32(),L=M.nextUint32(),D=Array(i),B=0;B<i;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+b,O=V+P,N=O+F,z=new Uint8Array(t,r+I,b),U=new Uint8Array(t,r+V,P),k=new Uint8Array(t,r+O,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:R,selectorCount:w,imageDescs:D,endpointsData:z,selectorsData:U,tablesData:k,extendedData:G}},_q(sd,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sd);e.KTX2TargetFormat=void 0,(sh=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sh.ASTC=0]="ASTC",sh[sh.BC7=1]="BC7",sh[sh.BC1_BC3=2]="BC1_BC3",sh[sh.PVRTC=3]="PVRTC",sh[sh.ETC=4]="ETC",sh[sh.R8=5]="R8",sh[sh.R8G8=6]="R8G8",sh[sh.R8G8B8A8=7]="R8G8B8A8";var fg=((sf=(s_=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)},sf.postMessage=function(e){var t=this;return new Promise(function(r,n){var i=t._getIdleWorkerId();if(-1!==i){t._workerStatus|=1<<i;var a,o=t._workerItems;Promise.resolve(null!=(a=o[i])?a:t._initWorker(i)).then(function(){var t=o[i];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sf.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},sf._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})},sf._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sf._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sf._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},s_),fv=((sm=(sp=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sm.destroy=function(){this._transcodeWorkerPool.destroy()},sm._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new fg(this.workerLimitCount,function(){return new Promise(function(r,n){var i=new Worker(e);i.addEventListener("message",function(e){e.data.error?n(e.data.error):r(i)}),i.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sp);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=fS(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var fx=function(e){return sg||(sg=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})),sg};function fS(e,t,r){var n,i,a,o,s=function(){l.close(),l.delete()};(a=n||(n={}))[a.ETC1=0]="ETC1",a[a.ETC2=1]="ETC2",a[a.BC1=2]="BC1",a[a.BC3=3]="BC3",a[a.BC4=4]="BC4",a[a.BC5=5]="BC5",a[a.BC7=7]="BC7",a[a.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",a[a.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",a[a.ASTC_4x4=10]="ASTC_4x4",a[a.RGBA8=13]="RGBA8",(o=i||(i={}))[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(),u=l.getHeight(),d=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 S=Array(d),C=void 0,T=void 0,A=0;A<d;A++){var E=l.getImageLevelInfo(x,A,v);g&&0===x&&(c!==E.width||u!==E.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=C=E.width)+", height: "+(u=T=E.height)+". You'd better use an image whose size if multiple of 4."):(C=E.origWidth,T=E.origHeight);var M=new Uint8Array(l.getImageTranscodedSizeInBytes(x,A,0,p));if(!l.transcodeImage(M,x,A,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");S[A]=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),i=0,a=0;a<e.length;a++)n.set(e[a],i),i+=e[a].byteLength;return n}(S),width:C,height:T}}m[v]=y}return s(),{faces:m,width:c,height:u,hasAlpha:_,faceCount:f,format:p}}var fC=(_X(sv=function(e){return fv.call(this,e)},fv),(sy=sv.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 i=document.createElement("script");i.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(i),i.onload=function(){fx(n).then(function(){e(null)})},i.onerror=function(){t()}});var i=fy.toString(),a=i.substring(i.indexOf("{"),i.lastIndexOf("}")+1),o="\n "+r+"\n "+fS.toString()+"\n "+a+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},sy.transcode=function(e,t){return 0===this.workerLimitCount?fx().then(function(r){return fS(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},sv);function fT(){var e,t,r,n=function(e,t,r,n){var i=(r+3>>2)*(n+3>>2),a=16*i+65535>>16,o=e.memory,s=a+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*i);return l.set(t),0===e.transcode(i)?l:null},i=function(e,t,r){var i=e.length,a=Array(i),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<i;s++){for(var l=e[s].length,c=Array(l),u=0;u<l;u++){var d=e[s][u],h=d.buffer,_=d.levelHeight,f=d.levelWidth,p=d.uncompressedByteLength;t&&(h=o.decode(h.slice(),p));var m=h.byteLength/i,g=h.byteOffset,v=n(r,new Uint8Array(h.buffer,g+s*m,m),f,_);if(v)c[u]={data:v.slice(),width:f,height:_};else throw"buffer decoded error"}a[s]=c}return a})},a=((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,i=t.byteLength,a=n.malloc(i);e.heap.set(t,a),r=r||Number(n.ZSTD_findDecompressedSize(a,i));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,a,i),l=e.heap.slice(o,o+s);return n.free(a),n.free(o),l},e);a.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){a.heap=new Uint8Array(a.instance.exports.memory.buffer)}}},a.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new a;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){i(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var fA=(_X(sx=function(e,t){var r;return(r=fv.call(this,e)||this).type=t,r},fv),(sS=sx.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(sx.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=fT.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},sS.transcode=function(e){for(var t=e.supercompressionScheme===l7.Zstd,r=e.levels.length,n=e.faceCount,i={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},a={type:"transcode",format:0,needZstd:t,data:Array(n)},o=a.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var u=e.levels[c],d=Math.floor(e.pixelWidth/(1<<c))||1,h=Math.floor(e.pixelHeight/(1<<c))||1,_=u.levelData.buffer,f=u.levelData.byteOffset,p=u.levelData.byteLength;l[c]={buffer:new Uint8Array(_,f,p),levelWidth:d,levelHeight:h,uncompressedByteLength:u.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(a).then(function(e){return i.faces=e,i.hasAlpha=!0,i})},sx);fA.transcoderMap=((sC={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",sC),e.KTX2Loader=(_X(sT=function(){return hp.apply(this,arguments)},hp),(sA=sT.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()}},sA.load=function(t,r){return this.request(t.url,{type:"arraybuffer"}).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,i=t.targetFormat,a=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,i,a)})})},sT.destroy=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},sT._parseBuffer=function(t,r,n){var i,a,o=new fm(t),s=null!=(i=null==n?void 0:n.priorityFormats)?i:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&fA.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();a=c.init().then(function(){return c.transcode(o)})}else{var u=e.KTX2Loader._getBinomialLLCTranscoder();a=u.init().then(function(){return u.transcode(t,l)})}return a.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},sT._createTextureByBuffer=function(t,r,n,i){var a,o=r.width,s=r.height,l=r.faces,c=l.length,u=l[0],d=u.length>1,h=this._getEngineTextureFormat(n,r);if(6!==c){a=new cG(t,o,s,h,d);for(var _=0;_<u.length;_++){var f=u[_].data;a.setPixelBuffer(f,_)}}else{a=new cW(t,s,h,d);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<u.length;g++)a.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return i&&(a.wrapModeU=i[0],a.wrapModeV=i[1],a.filterMode=i[2],a.anisoLevel=i[3]),a},sT._decideTargetFormat=function(t,r,n){var i=t._hardwareRenderer,a=this._detectSupportedFormat(i,n);return a!==e.KTX2TargetFormat.PVRTC||l9.isPowerOf2(r.pixelWidth)&&l9.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===a?(cz.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):a:(cz.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},sT._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var i=r[n],a=this._supportedMap[i];if(a){for(var o=0;o<a.length;o++)if(t.canIUse(a[o]))return i}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return i;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return i}}return null},sT._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new fC(t)},sT._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new fA(t,e.KTX2TargetFormat.ASTC)},sT._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}},sT._isBinomialInit=!1,sT._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]},sT._supportedMap=((sE={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],sE[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],sE[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],sE[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],sE[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],sE),sT),e.KTX2Loader=_K([dn(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(sM=e.KTX2Transcoder||(e.KTX2Transcoder={}))[sM.BinomialLLC=0]="BinomialLLC",sM[sM.Khronos=1]="Khronos";var fE=(_X(sR=function(){var e;return e=cL.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},cL),(sw=sR.prototype).restoreContent=function(){var t=this;return new dt(function(r,n){Promise.all(t.bufferRequests.map(function(e){return hd(e.url,e.config)})).then(function(i){if(t.isGLB){var a=t.glbBufferSlices,o=i[0],s=a.length;i.length=s;for(var l=0;l<s;l++){var c=a[l];i[l]=o.slice(c.x,c.x+c.y)}}dt.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,a=i[n.buffer],o=new Uint8Array(a,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)}):fp.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=_7(t.meshes);!(e=n()).done;){for(var a,o=e.value,s=o.mesh,l=_7(o.vertexBuffers);!(a=l()).done;){var c=a.value,u=t._getBufferData(i,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(i,o.indexBuffer);s.setIndices(d)}for(var h,_=_7(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(i,m.buffer);if(p.deltaPositions=fp.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(i,v.buffer);p.deltaNormals=fp.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,S=t._getBufferData(i,x.buffer);p.deltaTangents=fp.bufferToVector3Array(S,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},sw._getBufferData=function(e,t){var r,n=t.main;if(n){var i=e[n.bufferIndex];r=new n.TypedArray(i,n.byteOffset,n.length)}else r=new n.TypedArray(n.length);var a=t.sparseCount;if(a)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<a;_++)for(var f=l[_],p=0;p<h;p++)r[f*h+p]=d[_*h+p];return r},sR),fM=function(e,t){this.url=e,this.config=t},fR=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},fw=function(){this.vertexBuffers=[],this.blendShapes=[]},fb=function(e,t){this.buffer=e,this.data=t},fP=function(e,t,r,n,i){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=i},fF=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},fL=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},fD=function(e,t,r,n,i){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=i},fB=((sP=(sb=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,i=Array(n>3?n-3:0),a=3;a<n;a++)i[a-3]=arguments[a];throw"Not implemented."},sP.additiveParse=function(e,t,r,n){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];throw"Not implemented."},sb);e.GLTFExtensionMode=void 0,(sF=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[sF.CreateAndParse=0]="CreateAndParse",sF[sF.AdditiveParse=1]="AdditiveParse";var fI=((sL=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,i=Array(n>3?n-3:0),a=3;a<n;a++)i[a-3]=arguments[a];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],u=e[c];if(o=sL._createAndParse.apply(sL,[].concat(c,t,u,r,i)))return o}},sL.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];for(var s in e){var l=e[s];sL._additiveParse.apply(sL,[].concat(s,t,r,l,n,a))}},sL.hasExtensionParser=function(e){var t;return!!(null==(t=sL._extensionParsers[e])?void 0:t.length)},sL.getExtensionParser=function(e,t){var r=sL._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var i=n-1;i>=0;--i){var a=r[i];if(a._mode===t)return a}},sL._addExtensionParser=function(e,t){sL._extensionParsers[e]||(sL._extensionParsers[e]=[]),sL._extensionParsers[e].push(t)},sL._createAndParse=function(t,r,n,i){for(var a=arguments.length,o=Array(a>4?a-4:0),s=4;s<a;s++)o[s-4]=arguments[s];var l=sL.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,i,o))},sL._additiveParse=function(t,r,n,i,a){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=sL.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,i,a,s))},sL);function fV(e,t){return function(r){var n=new r;n._mode=t,fI._addExtensionParser(e,n)}}function fO(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}fI._extensionParsers={},e.GLTFSchemaParser=(_X(sD=function(){return fI.apply(this,arguments)},fI),sD.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,i=r.bufferRequests,a={type:"arraybuffer"};return hd(n,a).then(function(t){return i.push(new fM(n,a)),fp.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(c2.decodeText(new Uint8Array(t.originBuffer))))})},sD),e.GLTFSchemaParser=_K([ff(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(_X(sB=function(){return fI.apply(this,arguments)},fI),sB.prototype.parse=function(t,r){var n=t.glTF.animations[r],i=n.name,a=void 0===i?"AnimationClip"+r:i;return Promise.resolve(fI.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new hF(a),n)).then(function(e){return fI.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},sB._parseStandardProperty=function(t,r,n){for(var i=this,a=t.glTF,o=a.accessors,s=a.bufferViews,l=n.channels,c=n.samplers,u=[],d=t.get(e.GLTFParserType.Entity),h=[],_=0,f=c.length;_<f;_++)!function(r,n){var i=c[r],a=o[i.input],l=o[i.output],d=Promise.all([fp.getAccessorBuffer(t,s,a),fp.getAccessorBuffer(t,s,l)]).then(function(t){var r,n,a=t[0].data,o=t[1].data;if(l.normalized){for(var s=fp.getNormalizedComponentScale(l.componentType),c=new Float32Array(o.length),d=0,h=o.length;d<h;d++)c[d]=o[d]*s;o=c}var _=o.length/a.length;switch(null!=(r=i.interpolation)?r:lZ.Linear){case lZ.CubicSpine:n=e.InterpolationType.CubicSpine;break;case lZ.Step:n=e.InterpolationType.Step;break;case lZ.Linear:n=e.InterpolationType.Linear}a[a.length-1],u.push({type:l.type,interpolation:n,input:a,output:o,outputSize:_})});h.push(d)}(_);return h.push(t.get(e.GLTFParserType.Scene)),Promise.all(h).then(function(){for(var e=0,n=l.length;e<n;e++){for(var a=l[e],o=a.target,s=d[o.node],c="",h=s;h.parent;)c=""===c?""+h.name:h.name+"/"+c,h=h.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(h)){var _=void 0,f=void 0;switch(o.path){case lQ.TRANSLATION:_=c7,f="position";break;case lQ.ROTATION:_=c7,f="rotationQuaternion";break;case lQ.SCALE:_=c7,f="scale";break;case lQ.WEIGHTS:_=u2,f="blendShapeWeights"}var p=i._addCurve(o.path,a,u);r.addCurveBinding(c,_,f,p)}}return r})},sB._addCurve=function(t,r,n){var i=n[r.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case lQ.TRANSLATION:case lQ.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,d=0,h=a.length;d<h;d++){var _=new hW;_.time=a[d],c===e.InterpolationType.CubicSpine?(_.inTangent=new ce(o[u++],o[u++],o[u++]),_.value=new ce(o[u++],o[u++],o[u++]),_.outTangent=new ce(o[u++],o[u++],o[u++])):_.value=new ce(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lQ.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=i.interpolation,m=0,g=0,v=a.length;g<v;g++){var y=new hW;y.time=a[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new cd(o[m++],o[m++],o[m++],o[m++]),y.value=new cs(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new cd(o[m++],o[m++],o[m++],o[m++])):y.value=new cs(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lQ.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var S=0,C=0,T=a.length;C<T;C++){var A=new hW;A.time=a[C],x.interpolation===e.InterpolationType.CubicSpine?(A.inTangent=Array.from(o.subarray(S,S+s)),S+=s,A.value=o.slice(S,S+s),S+=s,A.outTangent=Array.from(o.subarray(S,S+s))):A.value=o.slice(S,S+s),S+=s,x.addKey(A)}return x}},sB),e.GLTFAnimationParser=_K([ff(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(_X(sI=function(){return fI.apply(this,arguments)},fI),(sV=sI.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},sV._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,i=r.url,a=n.bufferRequests,o={type:"arraybuffer"},s=c2.resolveAbsoluteUrl(i,t.uri);return a.push(new fM(s,o)),hd(s,o)},sI),e.GLTFBufferParser=_K([ff(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(_X(sO=function(){return fI.apply(this,arguments)},fI),sO.prototype.parse=function(t,r){var n=t.glTF.nodes[r],i=t.glTFResource.engine,a=n.matrix,o=n.translation,s=n.rotation,l=n.scale,c=n.extensions,u=new ue(i,n.name||"_GLTF_ENTITY_"+r),d=u.transform;if(a){var h=d.localMatrix;h.copyFromArray(a),d.localMatrix=h}else o&&d.setPosition(o[0],o[1],o[2]),s&&d.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&d.setScale(l[0],l[1],l[2]);var _=n.children;if(_)for(var f=0;f<_.length;f++){var p=_[f],m=t.get(e.GLTFParserType.Entity,p);u.addChild(m)}return fI.executeExtensionsAdditiveAndParse(c,t,u,n),u},sO),e.GLTFEntityParser=_K([ff(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(_X(sN=function(){return fI.apply(this,arguments)},fI),sN.prototype.parse=function(t,r){var n=t.glTF.materials[r],i=t.glTFResource.engine,a=fI.executeExtensionsCreateAndParse(n.extensions,t,n);return a||((a=new hy(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n)),Promise.resolve(a).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),fI.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r})},sN._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new hg(t))},sN._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&cz.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},sN._parseStandardProperty=function(t,r,n){var i=n.pbrMetallicRoughness,a=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,u=n.alphaCutoff,d=n.doubleSided;if(i){var h=i.baseColorFactor,_=i.baseColorTexture,f=i.metallicFactor,p=i.roughnessFactor,m=i.metallicRoughnessTexture;h&&(r.baseColor=new ch(ch.linearToGammaSpace(h[0]),ch.linearToGammaSpace(h[1]),ch.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,fI.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===hy&&(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===hy||r.constructor===hx){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new ch(ch.linearToGammaSpace(l[0]),ch.linearToGammaSpace(l[1]),ch.linearToGammaSpace(l[2]))),a){var g=a.index,v=a.scale;e.GLTFMaterialParser._checkOtherTextureTransform(a,"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,S=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),S===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:S>e.TextureCoordinate.UV1&&cz.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case l0.OPAQUE:r.isTransparent=!1;break;case l0.BLEND:r.isTransparent=!0;break;case l0.MASK:r.alphaCutoff=null!=u?u:.5}},sN),e.GLTFMaterialParser=_K([ff(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(_X(sz=function(){return fI.apply(this,arguments)},fI),sz.prototype.parse=function(t,r){for(var n=function(r,n){var l=i.primitives[r];s[r]=new Promise(function(n){var s=fI.executeExtensionsCreateAndParse(l.extensions,t,l,i);if(s)fO(s,uG)?n(s):s.then(function(e){n(e)});else{var c=new uG(o,i.name||r+""),u=new fw;u.mesh=c,t.contentRestorer.meshes.push(u),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,c,u,i,l,a,t.params.keepMeshData).then(n)}})},i=t.glTF.meshes[r],a=t.glTF,o=t.glTFResource.engine,s=[],l=0,c=i.primitives.length;l<c;l++)n(l);return Promise.all(s)},sz._parseMeshFromGLTFPrimitive=function(t,r,n,i,a,o,s){var l,c=function(i){var a=d[h[i]],c=fp.getAccessorBuffer(t,o.bufferViews,a).then(function(t){var o,c,u,d=fp.getAccessorTypeSize(a.type),h=a.count,_=t.data,f=r.instanceId,p=t.vertexBindingInfos,y=a.normalized,x=fp.getElementFormat(a.componentType,d,y);if(y&&(c=fp.getNormalizedComponentScale(a.componentType)),t.interleaved){var S=a.byteOffset||0,C=t.stride;if(u=S%C,void 0===p[f]){o=new uP(i,u,x,v);var T=t.vertexBuffer;T||(T=new uF(m,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=T,n.vertexBuffers.push(new fb(T,t.restoreInfo))),r.setVertexBufferBinding(T,C,v),p[f]=v++}else o=new uP(i,u,x,p[f])}else{u=0,o=new uP(i,u,x,v);var A=t.vertexBuffer;A||(A=new uF(m,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new fb(A,t.restoreInfo))),r.setVertexBufferBinding(A,t.stride,v),p[f]=v++}if(g.push(o),"POSITION"===i){l=h;var E=r.bounds,M=E.min,R=E.max;if(a.min&&a.max)M.copyFromArray(a.min),R.copyFromArray(a.max);else{var w=e.GLTFMeshParser._tempVector3;M.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),R.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var b=u/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=b+F*P;w.copyFromArray(_,L),ce.min(M,w,M),ce.max(R,w,R)}}y&&(M.scale(c),R.scale(c))}});y.push(c)},u=this,d=o.accessors,h=a.attributes,_=a.targets,f=a.indices,p=a.mode,m=r.engine,g=[],v=0,y=[];for(var x in h)c(x);return Promise.all(y).then(function(){if(r.setVertexElements(g),void 0!==f){var c=o.accessors[f],d=fp.getAccessorBuffer(t,o.bufferViews,c).then(function(e){r.setIndices(e.data),r.addSubMesh(0,c.count,p),n.indexBuffer=e.restoreInfo});y.push(d)}else r.addSubMesh(0,l,p);return _&&y.push(e.GLTFMeshParser._createBlendShape(t,r,n,i,a,_,u._getBlendShapeData)),Promise.all(y).then(function(){return r.uploadData(!s),r})})},sz._getBlendShapeData=function(e,t,r){return fp.getAccessorBuffer(e,t.bufferViews,r).then(function(e){var t,n=e.data,i=e.interleaved?(null!=(t=r.byteOffset)?t:0)%e.stride:0,a=r.count,o=r.normalized,s=r.componentType;return{vertices:fp.bufferToVector3Array(n,i,a,o,s),restoreInfo:new fD(e.restoreInfo,i,a,o,s)}})},sz._createBlendShape=function(e,t,r,n,i,a,o){for(var s=e.glTF,l=s.accessors,c=n.extras?n.extras.targetNames:null,u=[],d=a.length,h=Array(d),_=0;_<d;_++)(function(t){var r={};h[t]=r;var n=c?c[t]:"blendShape"+t,a=i.targets[t],d=a.NORMAL,_=a.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o(e,s,l[a.POSITION]),f?o(e,s,l[d]):null,p?o(e,s,l[_]):null]).then(function(e){var t=e[0],i=e[1],a=e[2],o=new uN(n);o.addFrame(1,t.vertices,f?i.vertices:null,p?a.vertices:null),r.blendShape=o,r.restoreInfo=new fL(o,t.restoreInfo,f?i.restoreInfo:null,p?null==a?void 0:a.restoreInfo:null)}))})(_);return Promise.all(u).then(function(){for(var e,n=_7(h);!(e=n()).done;){var i=e.value;t.addBlendShape(i.blendShape),r.blendShapes.push(i.restoreInfo)}})},sz._tempVector3=new ce,sz),e.GLTFMeshParser=_K([ff(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(_X(sU=function(){return fI.apply(this,arguments)},fI),(sk=sU.prototype).parse=function(t,r){var n,i=t.glTF,a=i.scene,o=t.glTFResource,s=i.scenes[r],l=s.extensions,c=o.engine,u=s.nodes;if(1===u.length)n=t.get(e.GLTFParserType.Entity,u[0]);else{n=new ue(c,"GLTF_ROOT");for(var d=0;d<u.length;d++){var h=t.get(e.GLTFParserType.Entity,u[d]);n.addChild(h)}}n._hookResource=o,o._addReferCount(1),(void 0===a?0:a)===r&&(o.defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(t,u[f]));return Promise.all(_).then(function(){return fI.executeExtensionsAdditiveAndParse(l,t,n,s),n})},sk._parseEntityComponent=function(t,r){var n,i=this,a=t.glTF,o=t.glTFResource,s=a.nodes[r],l=s.camera,c=s.mesh,u=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,a.cameras[l],u),void 0!==c&&(n=this._createRenderer(t,s,u)),Promise.resolve(n).then(function(){var e=[],r=s.children;if(r)for(var n=0;n<r.length;n++)e.push(i._parseEntityComponent(t,r[n]));return Promise.all(e)})},sk._createCamera=function(t,r,n){var i=r.orthographic,a=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===lJ.ORTHOGRAPHIC){var l=i.xmag,c=i.ymag,u=i.zfar,d=i.znear;s.isOrthographic=!0,void 0!==d&&(s.nearClipPlane=d),void 0!==u&&(s.farClipPlane=u),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===lJ.PERSPECTIVE){var h=a.aspectRatio,_=a.yfov,f=a.zfar,p=a.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},sk._createRenderer=function(t,r,n){for(var i=function(r){var i=c[r],l=i.material;d.push(Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),void 0!==l&&t.get(e.GLTFParserType.Material,l)]).then(function(o){var s,l=o[1],c=o[2],d=o[0][r];if(c||(c=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),l||u){var h=n.addComponent(u2);h.mesh=d,l&&(h.rootBone=l._rootBone,h.bones=l._bones,a._computeLocalBounds(h,d,l._bones,l._rootBone,l.inverseBindMatrices),h.skin=l),u&&(h.blendShapeWeights=new Float32Array(u)),s=h}else(s=n.addComponent(uU)).mesh=d;s.setMaterial(c),d.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(s.enableVertexColor=!0)}),fI.executeExtensionsAdditiveAndParse(i.extensions,t,s,i)}))},a=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,u=r.weights||l.weights,d=[],h=0;h<c.length;h++)i(h);return Promise.all(d)},sk._computeLocalBounds=function(e,t,r,n,i){var a=r.indexOf(n);if(-1!==a)cr.transform(t.bounds,i[a],e.localBounds);else{var o=new cl(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,i,n,o);0!==s?(cl.multiplyScalar(o,1/s,o),cr.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},sk._computeApproximateBindMatrix=function(e,t,r,n){for(var i=0,a=r.children,o=0,s=a.length;o<s;o++){var l=a[o],c=e.indexOf(l);-1!==c?(cl.add(n,t[c],n),i++):i+=this._computeApproximateBindMatrix(e,t,l,n)}return i},sU),e.GLTFSceneParser=_K([ff(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(_X(sG=function(){return fI.apply(this,arguments)},fI),(sH=sG.prototype).parse=function(t,r){var n=this,i=t.glTF,a=i.skins[r],o=a.inverseBindMatrices,s=a.skeleton,l=a.joints,c=a.name,u=l.length,d=new u1(void 0===c?"SKIN_"+r:c);d.inverseBindMatrices.length=u,d._bones.length=u;var h=i.accessors[o];return Promise.resolve(fp.getAccessorBuffer(t,i.bufferViews,h).then(function(r){for(var i=t.get(e.GLTFParserType.Entity),a=r.data,o=0;o<u;o++){var c=new cl;c.copyFromArray(a,16*o),d.inverseBindMatrices[o]=c;var h=i[l[o]];if(d._bones[o]=h,d.joints[o]=h.name,void 0!==s){var _=i[s];d._rootBone=_,d.skeleton=_.name}else{var f=n._findSkeletonRootBone(l,i);if(f)d._rootBone=f,d.skeleton=f.name;else throw"Failed to find skeleton root bone."}}return d}))},sH._findSkeletonRootBone=function(e,t){for(var r,n={},i=_7(e);!(r=i()).done;){for(var a=r.value,o=[],s=t[a];s;)o.unshift(s),s=s.parent;n[a]=o}for(var l=null,c=0;;c++){var u=n[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=n[e[h]]).length||d!==u[c])return l;l=d}},sG),e.GLTFSkinParser=_K([ff(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(_X(sW=function(){return fI.apply(this,arguments)},fI),sW.prototype.parse=function(t,r){var n=t.glTF.textures[r],i=t.glTFResource,a=t.glTF,o=i.engine,s=i.url,l=n.sampler,c=n.source,u=n.name,d=n.extensions,h=a.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=fI.executeExtensionsCreateAndParse(d,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&fp.getSamplerInfo(a.samplers[l]);if(_){var x=_.lastIndexOf("."),S=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:c2.resolveAbsoluteUrl(s,_),type:S,params:{mipmap:null==y?void 0:y.mipmap}}).then(function(e){return e.name=u||m||e.name||"texture_"+r,v&&fp.parseSampler(e,y),e})}else{var C=a.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[C.buffer],i=new Uint8Array(n,C.byteOffset,C.byteLength);return fp.loadImageBuffer(i,p).then(function(e){var n=new cG(o,e.width,e.height,void 0,null==y?void 0:y.mipmap);n.setImageSource(e),n.generateMipmaps(),n.name=u||m||"texture_"+r,v&&fp.parseSampler(n,y);var i=new fR(n,C,p);return t.contentRestorer.bufferTextures.push(i),n})})}}return Promise.resolve(g).then(function(e){return fI.executeExtensionsAdditiveAndParse(d,t,e,n),e})},sW._wrapMap=((sX={})[l3.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,sX[l3.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,sX[l3.REPEAT]=e.TextureWrapMode.Repeat,sX),sW),e.GLTFTextureParser=_K([ff(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(_X(sK=function(){return fI.apply(this,arguments)},fI),sK.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,i=t.extensionsRequired,a=Number(r);if(!(a>=2&&a<3))throw"Only support glTF 2.x.";if(n){cz.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];fI.hasExtensionParser(s)||cz.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(i){cz.info("extensionsRequired: "+i);for(var l=0;l<i.length;l++){var c=i[l];fI.hasExtensionParser(c)||cz.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},sK),e.GLTFValidator=_K([ff(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(_X(sj=function(){return fI.apply(this,arguments)},fI),sj.prototype.parse=function(t,r){var n=t.glTF.bufferViews[r],i=n.extensions,a=n.byteOffset,o=void 0===a?0:a,s=n.byteLength,l=n.buffer;return i?fI.executeExtensionsCreateAndParse(i,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},sj),e.GLTFBufferViewParser=_K([ff(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser);var fN=(_X(sY=function(){return hp.apply(this,arguments)},hp),sY.prototype.load=function(e,t){var r=e.url,n=e.params,i=new fc(t.engine,r);return new fu(i,t,_H({keepMeshData:!1},n)).parse()},sY);fN=_K([dn(e.AssetType.GLTF,["gltf","glb"])],fN);var fz=Math.PI,fU=(_X(sq=function(){return hp.apply(this,arguments)},hp),sq.prototype.load=function(t,r){var n=this;return new dt(function(i,a){var o=r.engine;n.request(t.url,{type:"arraybuffer"}).then(function(t){for(var r=new Uint8Array(t),n=fU._parseHeader(r),a=n.width,s=n.height,l=n.dataPosition,c=fU._readPixels(r.subarray(l),a,s),u=s>>1,d=fU._convertToCubemap(c,a,s,u),h=new cW(o,u),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,d[_],0);h.generateMipmaps(),i(h)}).catch(a)})},sq._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)]},sq._createCubemapData=function(e,t,r,n,i){for(var a=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,u=0;u<e;u++){for(var d=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(d).scale(c).add(d);f.normalize();var p=this._calcProjectionSpherical(f,r,n,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;a[m]=p.r,a[m+1]=p.g,a[m+2]=p.b,a[m+3]=p.a,d.add(o),h.add(s)}c+=l}return a},sq._calcProjectionSpherical=function(e,t,r,n){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-fz;)i+=2*fz;for(;i>fz;)i-=2*fz;var o=i/fz,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(a/fz*n);l<0?l=0:l>=n&&(l=n-1);var c=(n-l-1)*r*4+4*s,u=t[c],d=t[c+1],h=t[c+2],_=t[c+3];return new ch(u,d,h,_)},sq._readStringLine=function(e,t){for(var r="",n="",i=t;i<e.length-t&&"\n"!=(n=String.fromCharCode(e[i]));i++)r+=n;return r},sq._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var i=!1,a=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?a=!0:0==n.length&&(i=!0);while(!i);if(!a)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}},sq._readPixels=function(e,t,r){for(var n=e.byteLength,i=new Uint8Array(4*t*r),a=0,o=0,s=4*t,l=new Uint8Array(4),c=new Uint8Array(s),u=r;u>0&&o<n;){if(l[0]=e[o++],l[1]=e[o++],l[2]=e[o++],l[3]=e[o++],2!=l[0]||2!=l[1]||(l[2]<<8|l[3])!=t)throw"HDR Bad header format, wrong scan line width";for(var d=0,h=void 0;d<s&&o<n;){var _=(h=e[o++])>128;if(_&&(h-=128),0===h||d+h>s)throw"HDR Bad Format, bad scanline data (run)";if(_)for(var f=e[o++],p=0;p<h;p++)c[d++]=f;else c.set(e.subarray(o,o+h),d),d+=h,o+=h}for(var m=0;m<t;m++){var g=0;i[a]=c[m+g],g+=t,i[a+1]=c[m+g],g+=t,i[a+2]=c[m+g],g+=t,i[a+3]=c[m+g],a+=4}u--}return i},sq._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},sq._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},sq._rightBottomBack=new ce(1,-1,-1),sq._rightBottomFront=new ce(1,-1,1),sq._rightUpBack=new ce(1,1,-1),sq._rightUpFront=new ce(1,1,1),sq._leftBottomBack=new ce(-1,-1,-1),sq._leftBottomFront=new ce(-1,-1,1),sq._leftUpBack=new ce(-1,1,-1),sq._leftUpFront=new ce(-1,1,1),sq._faceRight=[sq._rightBottomBack,sq._rightBottomFront,sq._rightUpBack,sq._rightUpFront],sq._faceLeft=[sq._leftBottomFront,sq._leftBottomBack,sq._leftUpFront,sq._leftUpBack],sq._faceUp=[sq._leftBottomFront,sq._rightBottomFront,sq._leftBottomBack,sq._rightBottomBack],sq._faceBottom=[sq._leftUpBack,sq._rightUpBack,sq._leftUpFront,sq._rightUpFront],sq._faceFront=[sq._leftBottomBack,sq._rightBottomBack,sq._leftUpBack,sq._rightUpBack],sq._faceBack=[sq._rightBottomFront,sq._leftBottomFront,sq._rightUpFront,sq._leftUpFront],sq._tempVector3=new ce,sq._temp2Vector3=new ce,sq._temp3Vector3=new ce,sq._temp4Vector3=new ce,sq._temp5Vector3=new ce,sq);fU=_K([dn(e.AssetType.HDR,["hdr"])],fU);var fk=(_X(sQ=function(){return hp.apply(this,arguments)},hp),sQ.prototype.load=function(e){return this.request(e.url,_H({},e,{type:"json"}))},sQ);fk=_K([dn(e.AssetType.JSON,["json"],!1)],fk);var fG={parse:function(t,r,n,i){if(void 0===i&&(i=!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 a=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*a),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*a,s),glTypeSize:o.getUint32(2*a,s),glFormat:o.getUint32(3*a,s),glInternalFormat:o.getUint32(4*a,s),glBaseInternalFormat:o.getUint32(5*a,s),pixelWidth:o.getUint32(6*a,s),pixelHeight:o.getUint32(7*a,s),pixelDepth:o.getUint32(8*a,s),numberOfArrayElements:o.getUint32(9*a,s),numberOfFaces:o.getUint32(10*a,s),numberOfMipmapLevels:o.getUint32(11*a,s),bytesOfKeyValueData:o.getUint32(12*a,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,i=e.pixelWidth,a=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 u=new Uint8Array(e.buffer,n,l);r.push({data:u,width:i,height:a}),n+=l+(3-(l+3)%4)}i=Math.max(1,.5*i),a=Math.max(1,.5*a)}return r}(l,!0)),i&&(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 fH(e){var t=fG.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var fW=(_X(sZ=function(){return hp.apply(this,arguments)},hp),sZ.prototype.load=function(t,r){var n=this;return new dt(function(i,a){Promise.all(t.urls.map(function(e){return n.request(e,_H({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,i,a=[],o=0;o<e.length;o++){var s=fG.parse(e[o],1,!0,!0);a.push(s.mipmaps),0===o&&(n=s.pixelWidth,i=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:a,engineFormat:r,internalFormat:t,width:n,height:i}}(t),a=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new cW(r.engine,a,s,l),u=0;u<6;u++)for(var d=o[u].length,h=0;h<d;h++){var _=o[u][h],f=_.data,p=_.width,m=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,f,h,0,0,p,m)}i(c)}).catch(function(e){a(e)})})},sZ);fW=_K([dn(e.AssetType.KTXCube,[])],fW);var fX=(_X(sJ=function(){return hp.apply(this,arguments)},hp),sJ.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,_H({},e,{type:"arraybuffer"})).then(function(e){for(var r=fH(e),i=r.width,a=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new cG(t.engine,i,a,s,l),u=0;u<o.length;u++){var d=o[u],h=d.width,_=d.height,f=d.data;c.setPixelBuffer(f,u,0,0,h,_)}n(c)}).catch(function(e){i(e)})})},sJ);fX=_K([dn(e.AssetType.KTX,["ktx"])],fX);var fK=(_X(s$=function(){return hp.apply(this,arguments)},hp),s$.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,_H({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,i=r.value;switch(n){case"Vector2":h.setVector2(e,new cu(i.x,i.y));break;case"Vector3":h.setVector3(e,new ce(i.x,i.y,i.z));break;case"Vector4":h.setVector4(e,new cd(i.x,i.y,i.z,i.w));break;case"Color":h.setColor(e,new ch(i.r,i.g,i.b,i.a));break;case"Float":h.setFloat(e,i);break;case"Texture":d.push(t.getResourceByRef(i).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,i?1:0);break;case"Integer":h.setInt(e,Number(i))}},i=t.engine,a=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new dD(i,ux.find(o));u.name=a;var d=[],h=u.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 i in n)e(t[r],i,n[i]);else t[r]=n}(u,"renderState",c),Promise.all(d).then(function(){n(u)})}).catch(i)})},s$);fK=_K([dn(e.AssetType.Material,["json"])],fK);var fj=(_X(s0=function(){return hp.apply(this,arguments)},hp),s0.prototype.load=function(e,t){var r=this;return new dt(function(n,i){r.request(e.url,_H({},e,{type:"arraybuffer"})).then(function(e){return ft(e,t.engine)}).then(function(e){n(e)}).catch(i)})},s0);fj=_K([dn(e.AssetType.Mesh,["mesh"])],fj);var fY=(_X(s1=function(){return hp.apply(this,arguments)},hp),(s2=s1.prototype).load=function(e,t){var r=this;return new dt(function(n,i){var a=e.url;r._registerFont(a,a).then(function(){n(new cY(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},s2._registerFont=function(e,t){return fs(function(){var r;return _j(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]}})})()},s1);fY=_K([dn(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],fY);var fq=(_X(s3=function(){var e;return e=hp.apply(this,arguments)||this,e._tempRect=new c_,e._tempVec2=new cu,e._tempVec4=new cd,e},hp),(s4=s3.prototype).load=function(t,r){var n=this;return new dt(function(i,a,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=n.request(t.url,_H({},t,{type:"json"}));l.push(c),c.then(function(o){var s=o.atlasItems,c=o.mipmap,u=o.anisoLevel,d=o.filterMode,h=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,m=r.engine,g=new dN(m);if(p<0){i(g);return}l.length=0;for(var v=0;v<s.length;v++)!function(i){var o,p=s[i];if(p.img)l.push(r.load({url:c2.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:c}}).then(function(e){u&&(e.anisoLevel=u),void 0!==d&&(e.filterMode=d),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(a));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);dt.all(l).then(function(){i(g)}).catch(a)}).catch(a)})},s4._makeSprite=function(e,t,r){var n=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new dz(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 d=1/r.width,h=1/r.height;if(u.atlasRegion.set(a.x*d,a.y*h,a.w*d,a.h*h),i){var _=i.x,f=i.y,p=i.z,m=i.w;u.atlasRegionOffset.set(_*d,f*h,p*d,m*h)}t.atlasRotated&&(u.atlasRotated=!0)}return isNaN(l)||(u.width=l),isNaN(c)||(u.height=c),u},s3);fq=_K([dn(e.AssetType.SpriteAtlas,["atlas"],!1)],fq);var fQ=(_X(s5=function(){return hp.apply(this,arguments)},hp),(s8=s5.prototype).load=function(e,t){var r=this;return this.request(e.url,_H({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},s8._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},s8._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new dz(e.engine,r,t.region,t.pivot,t.border),i=t.width,a=t.height;return isNaN(i)||(n.width=i),isNaN(a)||(n.height=a),n}):new dt(function(r){var n=new dz(e.engine,null,t.region,t.pivot,t.border),i=t.width,a=t.height;isNaN(i)||(n.width=i),isNaN(a)||(n.height=a),r(n)})},s5);fQ=_K([dn(e.AssetType.Sprite,["sprite"],!1)],fQ);var fZ=(_X(s6=function(e,t,r){var n;return(n=cL.call(this,e)||this).url=t,n.requestConfig=r,n},cL),s6.prototype.restoreContent=function(){var e=this;return hd(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},s6),fJ=(_X(s7=function(){return hp.apply(this,arguments)},hp),s7.prototype.load=function(e,t){var r=this;return new dt(function(n,i){var a=e.url,o=_H({},e,{type:"image"});r.request(a,o).then(function(r){var i,s=null!=(i=e.params)?i:{},l=s.format,c=s.mipmap,u=s.anisoLevel,d=s.wrapModeU,h=s.wrapModeV,_=s.filterMode,f=new cG(t.engine,r.width,r.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==a.indexOf("data:")){var p=a.lastIndexOf("/");f.name=a.substring(p+1)}t.addContentRestorer(new fZ(f,a,o)),n(f)}).catch(function(e){i(e)})})},s7);fJ=_K([dn(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],fJ);var f$=(_X(s9=function(e,t,r){var n;return(n=cL.call(this,e)||this).urls=t,n.requestConfig=r,n},cL),s9.prototype.restoreContent=function(){var t=this;return new dt(function(r,n){Promise.all(t.urls.map(function(e){return hd(e,t.requestConfig)})).then(function(n){for(var i=t.resource,a=0;a<6;a++)i.setImageSource(e.TextureCubeFace.PositiveX+a,n[a],0);i.generateMipmaps(),r(i)}).catch(function(e){n(e)})})},s9),f0=(_X(le=function(){return hp.apply(this,arguments)},hp),le.prototype.load=function(t,r){var n=this;return new dt(function(i,a){var o=t.urls,s=_H({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],a=n.width;if(a!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new cW(r.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new f$(l,o,s)),i(l)}).catch(function(e){a(e)})})},le);f0=_K([dn(e.AssetType.TextureCube,[""])],f0);var f1=(_X(lt=function(){return hp.apply(this,arguments)},hp),lt.prototype.load=function(t,r){var n=this,i=r.engine;return new dt(function(a,o){n.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){i.sceneManager.activeScene=e,a()})}).catch(o)})},lt);f1=_K([dn(e.AssetType.Project,["proj"],!1)],f1);var f2=(_X(lr=function(){return hp.apply(this,arguments)},hp),lr.prototype.load=function(t,r){var n=this,i=r.engine;return new dt(function(a,o){n.request(t.url,{type:"json"}).then(function(t){return fe.parse(i,t).then(function(n){var i,o=[],s=t.scene.ambient;if(s){var l="Custom"===s.specularMode,c=s.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=s.diffuseIntensity,n.ambientLight.specularIntensity=s.specularIntensity,n.ambientLight.diffuseMode=s.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,l&&s.customAmbientLight&&o.push(r.getResourceByRef(s.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&o.push(r.getResourceByRef(s.ambientLight).then(function(e){l||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(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 d=r.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),h=r.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});o.push(d,h)}else cz.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var _=r.getResourceByRef(u.texture).then(function(e){n.background.texture=e});o.push(_)}}var f=t.scene.shadow;return f&&(void 0!=f.castShadows&&(n.castShadows=f.castShadows),void 0!=f.shadowResolution&&(n.shadowResolution=f.shadowResolution),void 0!=f.shadowDistance&&(n.shadowDistance=f.shadowDistance),void 0!=f.shadowCascades&&(n.shadowCascades=f.shadowCascades),n.shadowTwoCascadeSplits=null!=(i=f.shadowTwoCascadeSplits)?i:n.shadowTwoCascadeSplits,f.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(f.shadowFourCascadeSplits)),Promise.all(o).then(function(){a(n)})})}).catch(o)})},lr);f2=_K([dn(e.AssetType.Scene,["scene"],!0)],f2),_4.registerCustomParseComponent("TextRenderer",fs(function(e,t){var r;return _j(this,function(n){return(r=t.props).font||(e.font=cY.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var f3=(_X(ln=function(){return fB.apply(this,arguments)},fB),(li=ln.prototype).createAndParse=function(t,r,n,i){var a=this;this._initialize();var o=t.glTF,s=t.glTFResource.engine,l=o.bufferViews,c=o.accessors,u=r.bufferView,d=r.attributes,h={},_={};for(var f in d)h[f]=d[f];for(var p in n.attributes)if(void 0!==d[p]){var m=c[n.attributes[p]];_[p]=fp.getComponentType(m.componentType).name}var g=c[n.indices],v={attributeIDs:h,attributeTypes:_,useUniqueIDs:!0,indexType:fp.getComponentType(g.componentType).name};return t.get(e.GLTFParserType.Buffer).then(function(e){var r=fp.getBufferViewData(l[u],e);return f3._decoder.decode(r,v).then(function(e){var r=new uG(s,i.name),l=new fw;return l.mesh=r,t.contentRestorer.meshes.push(l),a._parseMeshFromGLTFPrimitiveDraco(t,r,l,i,n,o,function(t){for(var r=0;r<e.attributes.length;r++)if(e.attributes[r].name===t)return e.attributes[r].array;return null},function(){throw"BlendShape animation is not supported when using draco."},function(){return e.index.array},t.params.keepMeshData)})})},li._initialize=function(){f3._decoder||(f3._decoder=new _G)},li._parseMeshFromGLTFPrimitiveDraco=function(t,r,n,i,a,o,s,l,c,u){var d,h=a.attributes,_=a.targets,f=a.indices,p=a.mode,m=o.accessors,g=m[h.POSITION],v=s("POSITION"),y=fp.floatBufferToVector3Array(v);r.setPositions(y);var x=r.bounds;if(d=g.count,g.min&&g.max)x.min.copyFromArray(g.min),x.max.copyFromArray(g.max);else{var S=f3._tempVector3,C=x.min,T=x.max;C.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),T.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var A=v.length/d,E=0;E<d;E++){var M=E*A;S.copyFromArray(v,M),ce.min(C,S,C),ce.max(T,S,T)}}for(var R in h)if("POSITION"!==R){var w=s(R);switch(R){case"NORMAL":var b=fp.floatBufferToVector3Array(w);r.setNormals(b);break;case"TEXCOORD_0":var P=fp.floatBufferToVector2Array(w);r.setUVs(P,0);break;case"TEXCOORD_1":var F=fp.floatBufferToVector2Array(w);r.setUVs(F,1);break;case"TEXCOORD_2":var L=fp.floatBufferToVector2Array(w);r.setUVs(L,2);break;case"TEXCOORD_3":var D=fp.floatBufferToVector2Array(w);r.setUVs(D,3);break;case"TEXCOORD_4":var B=fp.floatBufferToVector2Array(w);r.setUVs(B,4);break;case"TEXCOORD_5":var I=fp.floatBufferToVector2Array(w);r.setUVs(I,5);break;case"TEXCOORD_6":var V=fp.floatBufferToVector2Array(w);r.setUVs(V,6);break;case"TEXCOORD_7":var O=fp.floatBufferToVector2Array(w);r.setUVs(O,7);break;case"COLOR_0":var N=fp.floatBufferToColorArray(w,m[h.COLOR_0].type===lq.VEC3);r.setColors(N);break;case"TANGENT":var z=fp.floatBufferToVector4Array(w);r.setTangents(z);break;case"JOINTS_0":var U=fp.floatBufferToVector4Array(w);r.setBoneIndices(U);break;case"WEIGHTS_0":var k=fp.floatBufferToVector4Array(w);r.setBoneWeights(k)}}if(void 0!==f){var G=o.accessors[f],H=c();r.setIndices(H),r.addSubMesh(0,G.count,p)}else r.addSubMesh(0,d,p);return _&&e.GLTFMeshParser._createBlendShape(t,r,n,i,a,_,l),r.uploadData(!u),Promise.resolve(r)},ln._tempVector3=new ce,ln);f3=_K([fV("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],f3);var f4=(_X(la=function(){return fB.apply(this,arguments)},fB),la.prototype.additiveParse=function(e,t,r){var n,i=e.glTF.extensions.KHR_lights_punctual.lights[r.light],a=i.color,o=i.intensity,s=i.type,l=i.range,c=i.spot,u=e.glTFResource;if("directional"===s?n=t.addComponent(d$):"point"===s?n=t.addComponent(d0):"spot"===s&&(n=t.addComponent(d1)),a&&n.color.set(a[0],a[1],a[2],1),n.intensity=void 0===o?1:o,l&&!fO(n,d$)&&(n.distance=l),c&&fO(n,d1)){var d=c.innerConeAngle,h=void 0===d?0:d,_=c.outerConeAngle;n.angle=h,n.penumbra=(void 0===_?Math.PI/4:_)-h}u.lights||(u.lights=[]),u.lights.push(n)},la);f4=_K([fV("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],f4);var f5=(_X(lo=function(){return fB.apply(this,arguments)},fB),lo.prototype.additiveParse=function(t,r,n){var i=n.clearcoatFactor,a=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===i?0:i,r.clearCoatRoughness=void 0===o?0:o,a&&(e.GLTFMaterialParser._checkOtherTextureTransform(a,"Clear coat"),t.get(e.GLTFParserType.Texture,a.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}))},lo);f5=_K([fV("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],f5);var f8=(_X(ls=function(){return fB.apply(this,arguments)},fB),ls.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},ls);f8=_K([fV("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],f8);var f6=(_X(ll=function(){return fB.apply(this,arguments)},fB),ll.prototype.createAndParse=function(t,r,n){var i=t.glTFResource.engine,a=new hx(i),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,u=r.specularGlossinessTexture;return o&&(a.baseColor=new ch(ch.linearToGammaSpace(o[0]),ch.linearToGammaSpace(o[1]),ch.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){a.baseTexture=e,fI.executeExtensionsAdditiveAndParse(s.extensions,t,a,s)}),l&&(a.specularColor=new ch(ch.linearToGammaSpace(l[0]),ch.linearToGammaSpace(l[1]),ch.linearToGammaSpace(l[2]))),void 0!==c&&(a.glossiness=c),u&&(e.GLTFMaterialParser._checkOtherTextureTransform(u,"Specular glossiness"),t.get(e.GLTFParserType.Texture,u.index).then(function(e){a.specularGlossinessTexture=e})),a.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n),a},ll);f6=_K([fV("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],f6);var f7=(_X(lc=function(){return fB.apply(this,arguments)},fB),lc.prototype.createAndParse=function(t,r,n){var i=t.glTFResource.engine,a=new hS(i);return a.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,a,n),a},lc);f7=_K([fV("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],f7);var f9=(_X(lu=function(){return fB.apply(this,arguments)},fB),lu.prototype.additiveParse=function(t,r,n){var i=t.glTF.extensions.KHR_materials_variants.variants,a=t.glTFResource,o=n.mappings;a.extensionsData||(a.extensionsData={});var s=[];a.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var a=o[n],l=a.material,c=a.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return i[e].name})})})}(l)},lu);f9=_K([fV("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],f9);var pe=(_X(ld=function(){return fB.apply(this,arguments)},fB),ld);pe=_K([fV("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],pe);var pt=(_X(lh=function(){return fB.apply(this,arguments)},fB),lh.prototype.createAndParse=function(t,r,n){return fs(function(){var i,a,o,s,l,c,u,d,h,_,f,p,m,g,v;return _j(this,function(y){return(i=t.glTF,o=(a=t.glTFResource).engine,s=a.url,l=n.sampler,c=n.name,u=r.source,h=(d=i.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&fp.getSamplerInfo(i.samplers[l]),h)?(g=h.lastIndexOf("."),[2,o.resourceManager.load({url:c2.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&fp.parseSampler(e,m),e})]):(v=i.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,v.buffer).then(function(r){var n=new Uint8Array(r,v.byteOffset,v.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,i=t.targetFormat,a=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,i,a)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&fp.parseSampler(e,m);var r=new fR(e,v,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},lh);pt=_K([fV("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],pt);var pr=(_X(l_=function(){return fB.apply(this,arguments)},fB),l_.prototype.additiveParse=function(e,t,r){var n=r.offset,i=r.rotation,a=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&cz.warn("rotation in KHR_texture_transform is not supported now"),o&&cz.warn("texCoord in KHR_texture_transform is not supported now")},l_);pr=_K([fV("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],pr);var pn=(_X(lf=function(){return fB.apply(this,arguments)},fB),lf.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},lf);pn=_K([fV("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],pn);var pi=(_X(lp=function(){return fB.apply(this,arguments)},fB),lp.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new hP;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},lp);pi=_K([fV("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],pi);var pa="1.1.3";for(var po in console.log("Galacean engine version: "+pa),_v)hp.registerClass(po,_v[po]);e.AmbientLight=dZ,e.AnimationClip=hF,e.AnimationClipCurveBinding=hb,e.AnimationCurve=hL,e.AnimationEvent=hP,e.Animator=hN,e.AnimatorController=hz,e.AnimatorControllerLayer=hU,e.AnimatorState=hG,e.AnimatorStateMachine=hH,e.AnimatorStateTransition=hB,e.AssetPromise=dt,e.Background=dq,e.BaseMaterial=hm,e.Basic2DBatcher=u3,e.BasicRenderPipeline=hs,e.BlendShape=uN,e.BlendShapeFrame=uO,e.BlendState=up,e.BlinnPhongMaterial=hg,e.BoolUpdateFlag=c8,e.BoundingBox=cr,e.BoundingFrustum=ca,e.BoundingSphere=ct,e.BoxColliderShape=dM,e.BoxShape=_a,e.Buffer=uF,e.BufferInfo=fd,e.BufferMesh=uz,e.BufferUtil=ub,e.Burst=_r,e.Canvas=dj,e.CapsuleColliderShape=db,e.CharacterController=df,e.CircleShape=_o,e.CloneManager=cb,e.ColliderShape=dE,e.CollisionUtil=cn,e.Color=ch,e.ColorOverLifetimeModule=h0,e.Component=cJ,e.ComponentMap=_8,e.ConeShape=_s,e.ContentRestorer=cL,e.CubeProbe=_g,e.CurveKey=h8,e.DepthState=um,e.DirectLight=d$,e.DynamicCollider=dp,e.EmissionModule=h2,e.Engine=dK,e.EngineObject=cP,e.Entity=ue,e.EventDispatcher=cq,e.FixedJoint=dx,e.Font=cY,e.GLTFExtensionParser=fB,e.GLTFParser=fI,e.GLTFParserContext=fu,e.GLTFResource=fc,e.GLTFUtils=fp,e.GradientAlphaKey=hZ,e.GradientColorKey=hQ,e.HemisphereShape=_l,e.HingeJoint=dS,e.HitResult=dm,e.IndexBufferBinding=uL,e.InputManager=dL,e.JointLimits=dT,e.JointMotor=dA,e.Keyframe=hW,e.Light=dJ,e.Loader=hp,e.Logger=cz,e.MainModule=h3,e.Material=dD,e.MathUtil=l9,e.Matrix=cl,e.Matrix3x3=co,e.Mesh=uI,e.MeshRenderer=uU,e.ModelMesh=uG,e.PBRBaseMaterial=hv,e.PBRMaterial=hy,e.PBRSpecularMaterial=hx,e.ParticleCompositeCurve=h1,e.ParticleCompositeGradient=hJ,e.ParticleCurve=h5,e.ParticleGenerator=_e,e.ParticleGradient=hq,e.ParticleMaterial=_t,e.ParticleRenderer=hY,e.PhysicsMaterial=dg,e.PhysicsScene=d_,e.Plane=ci,e.PlaneColliderShape=dw,e.PointLight=d0,e.Pointer=dl,e.PrefabParser=_5,e.Primitive=uB,e.PrimitiveMesh=u0,e.Probe=__,e.Quaternion=cs,e.Rand=cp,e.RasterState=ug,e.Ray=cc,e.Rect=c_,e.ReferResource=cF,e.ReflectionParser=_4,e.RenderPass=d8,e.RenderQueue=d7,e.RenderState=uy,e.RenderTarget=ck,e.RenderTargetBlendState=uf,e.ResourceManager=dr,e.RotationOverLifetimeModule=h4,e.Scene=d3,e.SceneManager=de,e.SceneParser=fe,e.Script=d4,e.Shader=ux,e.ShaderData=uS,e.ShaderFactory=uo,e.ShaderMacro=ur,e.ShaderMacroCollection=un,e.ShaderPass=uh,e.ShaderProperty=cQ,e.ShaderTagKey=us,e.SizeOverLifetimeModule=h6,e.Skin=u1,e.SkinnedMeshRenderer=u2,e.Sky=dY,e.SkyBoxMaterial=hX,e.SkyProceduralMaterial=hK,e.SphereColliderShape=dR,e.SphereShape=_c,e.SphericalHarmonics3=cf,e.SpotLight=d1,e.SpringJoint=dC,e.Sprite=dz,e.SpriteAtlas=dN,e.SpriteMask=uw,e.SpriteRenderer=dG,e.StateMachineScript=hk,e.StaticCollider=dv,e.StencilState=uv,e.SubMesh=uD,e.SubShader=u_,e.SystemInfo=dd,e.TextRenderer=dX,e.TextUtils=cK,e.Texture=cU,e.Texture2D=cG,e.Texture2DArray=cH,e.TextureCube=cW,e.TextureSheetAnimationModule=h7,e.Time=cZ,e.TrailMaterial=_u,e.TrailRenderer=_h,e.Transform=c7,e.UnlitMaterial=hS,e.Utils=c2,e.Vector2=cu,e.Vector3=ce,e.Vector4=cd,e.VelocityOverLifetimeModule=h9,e.VertexBufferBinding=uV,e.VertexElement=uP,e.WebCanvas=_A,e.WebGLEngine=_E,e.WebGLGraphicDevice=_O,e.assignmentClone=cM,e.decode=ft,e.deepClone=cw,e.dependentComponents=c0,e.ignoreClone=cE,e.parseSingleKTX=fH,e.registerGLTFExtension=fV,e.registerGLTFParser=ff,e.request=hd,e.resourceLoader=dn,e.shallowClone=cR,e.version=pa,Object.defineProperty(e,"__esModule",{value:!0})});