@galacean/engine 1.3.0-beta.6 → 1.3.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +3916 -3882
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}e.ContainmentType=void 0,(l4=e.ContainmentType||(e.ContainmentType={}))[l4.Disjoint=0]="Disjoint",l4[l4.Contains=1]="Contains",l4[l4.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(l8=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[l8.Back=0]="Back",l8[l8.Front=1]="Front",l8[l8.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(l5=e.FrustumFace||(e.FrustumFace={}))[l5.Near=0]="Near",l5[l5.Far=1]="Far",l5[l5.Left=2]="Left",l5[l5.Right=3]="Right",l5[l5.Bottom=4]="Bottom",l5[l5.Top=5]="Top";var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,T,C,S,A,M,R,E,w,P,F,L,B,D,I,O,V,N,k,z,U,G,H,W,j,K,X,Y,q,Q,Z,J,$,ee,et,er,en,ea,ei,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eT,eC,eS,eA,eM,eR,eE,ew,eP,eF,eL,eB,eD,eI,eO,eV,eN,ek,ez,eU,eG,eH,eW,ej,eK,eX,eY,eq,eQ,eZ,eJ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tr,tn,ta,ti,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv,ty,tx,tb,tT,tC,tS,tA,tM,tR,tE,tw,tP,tF,tL,tB,tD,tI,tO,tV,tN,tk,tz,tU,tG,tH,tW,tj,tK,tX,tY,tq,tQ,tZ,tJ,t$,t0,t1,t2,t3,t4,t8,t5,t9,t6,t7,re,rt,rr,rn,ra,ri,ro,rs,rl,rc,ru,rd,rh,r_,rf,rp,rm,rg,rv,ry,rx,rb,rT,rC,rS,rA,rM,rR,rE,rw,rP,rF,rL,rB,rD,rI,rO,rV,rN,rk,rz,rU,rG,rH,rW,rj,rK,rX,rY,rq,rQ,rZ,rJ,r$,r0,r1,r2,r3,r4,r8,r5,r9,r6,r7,ne,nt,nr,nn,na,ni,no,ns,nl,nc,nu,nd,nh,n_,nf,np,nm,ng,nv,ny,nx,nb,nT,nC,nS,nA,nM,nR,nE,nw,nP,nF,nL,nB,nD,nI,nO,nV,nN,nk,nz,nU,nG,nH,nW,nj,nK,nX,nY,nq,nQ,nZ,nJ,n$,n0,n1,n2,n3,n4,n8,n5,n9,n6,n7,ae,at,ar,an,aa,ai,ao,as,al,ac,au,ad,ah,a_,af,ap,am,ag,av,ay,ax,ab,aT,aC,aS,aA,aM,aR,aE,aw,aP,aF,aL,aB,aD,aI,aO,aV,aN,ak,az,aU,aG,aH,aW,aj,aK,aX,aY,aq,aQ,aZ,aJ,a$,a0,a1,a2,a3,a4,a8,a5,a9,a6,a7,ie,it,ir,ia,ii,io,is,il,ic,iu,id,ih,i_,ip,im,ig,iv,iy,ix,ib,iT,iC,iS,iA,iM,iR,iE,iw,iP,iF,iL,iB,iD,iI,iO,iV,iN,ik,iz,iU,iG,iH,iW,ij,iK,iX,iY,iq,iQ,iZ,iJ,i$,i0,i1,i2,i3,i4,i8,i5,i9,i6,i7,oe,ot,or,on,oa,oi,oo,os,ol,oc,ou,od,oh,o_,of,op,om,og,ov,oy,ox,ob,oT,oC,oS,oA,oM,oR,oE,ow,oP,oF,oL,oB,oD,oI,oO,oV,oN,ok,oz,oU,oG,oH,oW,oj,oK,oX,oY,oq,oQ,oZ,oJ,o$,o0,o1,o2,o3,o4,o8,o5,o9,o6,o7,se,st,sr,sn,sa,si,so,ss,sl,sc,su,sd,sh,s_,sf,sp,sm,sg,sv,sy,sx,sb,sT,sC,sS,sA,sM,sR,sE,sw,sP,sF,sL,sB,sD,sI,sO,sV,sN,sk,sz,sU,sG,sH,sW,sj,sK,sX,sY,sq,sQ,sZ,sJ,s$,s0,s1,s2,s3,s4,s8,s5,s9,s6,s7,le,lt,lr,ln,la,li,lo,ls,ll,lc,lu,ld,lh,l_,lf,lp,lm,lg,lv,ly,lx,lb,lT,lC,lS,lA,lM,lR,lE,lw,lP,lF,lL,lB,lD,lI,lO,lV,lN,lk,lz,lU,lG,lH,lW,lj,lK,lX,lY,lq,lQ,lZ,lJ,l$,l0,l1,l2,l3,l4,l8,l5,l9,l6,l7,ce,ct,cr,cn,ca,ci,co,cs,cl,cc,cu,cd,ch,c_,cf,cp,cm,cg,cv,cy,cx,cb,cT,cC,cS,cA,cM,cR,cE,cw,cP,cF,cL,cB,cD,cI,cO,cV,cN,ck,cz,cU,cG,cH,cW,cj,cK,cX,cY,cq=((l9=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},l9.equals=function(e,t){return Math.abs(e-t)<=l9.zeroTolerance},l9.isPowerOf2=function(e){return(e&e-1)==0},l9.radianToDegree=function(e){return e*l9.radToDegreeFactor},l9.degreeToRadian=function(e){return e*l9.degreeToRadFactor},l9.lerp=function(e,t,r){return e+(t-e)*r},l9);cq.zeroTolerance=1e-6,cq.radToDegreeFactor=180/Math.PI,cq.degreeToRadFactor=Math.PI/180;var cQ=((i=(a=function(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r}).prototype).set=function(e,t,r){return this._x=e,this._y=t,this._z=r,this._onValueChanged&&this._onValueChanged(),this},i.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},i.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},i.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},i.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},i.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},i.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},i.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},i.normalize=function(){return a.normalize(this,this),this},i.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},i.transformNormal=function(e){return a.transformNormal(this,e,this),this},i.transformToVec3=function(e){return a.transformToVec3(this,e,this),this},i.transformCoordinate=function(e){return a.transformCoordinate(this,e,this),this},i.transformByQuat=function(e){return a.transformByQuat(this,e,this),this},i.clone=function(){return new a(this._x,this._y,this._z)},i.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},i.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},i.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},i.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},a.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._onValueChanged&&r._onValueChanged()},a.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._onValueChanged&&r._onValueChanged()},a.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._onValueChanged&&r._onValueChanged()},a.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._onValueChanged&&r._onValueChanged()},a.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},a.cross=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;r.set(a*l-i*s,i*o-n*l,n*s-a*o)},a.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return Math.sqrt(r*r+n*n+a*a)},a.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return r*r+n*n+a*a},a.equals=function(e,t){return cq.equals(e._x,t._x)&&cq.equals(e._y,t._y)&&cq.equals(e._z,t._z)},a.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},a.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},a.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=Math.sqrt(r*r+n*n+a*a);i>cq.zeroTolerance&&(i=1/i,t.set(r*i,n*i,a*i))},a.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},a.transformNormal=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8],r._y=n*o[1]+a*o[5]+i*o[9],r._z=n*o[2]+a*o[6]+i*o[10],r._onValueChanged&&r._onValueChanged()},a.transformToVec3=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},a.transformToVec4=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._w=n*o[3]+a*o[7]+i*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},a.transformCoordinate=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements,s=n*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,r._x=(n*o[0]+a*o[4]+i*o[8]+o[12])*s,r._y=(n*o[1]+a*o[5]+i*o[9]+o[13])*s,r._z=(n*o[2]+a*o[6]+i*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},a.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*n+s*i-l*a,d=c*a+l*n-o*i,h=c*i+o*a-s*n,_=-o*n-s*a-l*i;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(a,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),a);cQ._zero=new cQ(0,0,0),cQ._one=new cQ(1,1,1);var cZ=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new cQ,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}).prototype).clone=function(){return new o(this.center,this.radius)},s.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},o.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=e.length,n=o._tempVec30;n.x=n.y=n.z=0;for(var a=0;a<r;++a)cQ.add(e[a],n,n);cQ.scale(n,1/r,t.center);for(var i=0,s=0;s<r;++s){var l=cQ.distanceSquared(n,e[s]);l>i&&(i=l)}t.radius=Math.sqrt(i)},o.fromBox=function(e,t){var r=t.center,n=e.min,a=e.max;r.x=(n.x+a.x)*.5,r.y=(n.y+a.y)*.5,r.z=(n.z+a.z)*.5,t.radius=cQ.distance(r,a)},o);cZ._tempVec30=new cQ;var cJ=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new cQ,this.max=new cQ,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){var t=this.min,r=this.max,n=r._x+t._x,a=r._y+t._y,i=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,a=r._y-t._y,i=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,a=t.y,i=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new cQ;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(n,a,l),e[4].set(n,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(n,a,i),e},c.transform=function(e){return l.transform(this,e,this),this},c.clone=function(){return new l(this.min,this.max)},c.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,r){cQ.subtract(e,t,r.min),cQ.add(e,t,r.max)},l.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=t.min,n=t.max;r.x=r.y=r.z=Number.MAX_VALUE,n.x=n.y=n.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];cQ.min(r,o,r),cQ.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,a=t.min,i=t.max;a.x=r.x-n,a.y=r.y-n,a.z=r.z-n,i.x=r.x+n,i.y=r.y+n,i.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,a=l._tempVec31;e.getCenter(n),e.getExtent(a),cQ.transformCoordinate(n,t,n);var i=a.x,o=a.y,s=a.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];a.set((0===u?0:Math.abs(i*u))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===d?0:Math.abs(i*d))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(i*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),cQ.subtract(n,a,r.min),cQ.add(n,a,r.max)},l.merge=function(e,t,r){return cQ.min(e.min,t.min,r.min),cQ.max(e.max,t.max,r.max),r},l);cJ._tempVec30=new cQ,cJ._tempVec31=new cQ;var c$=((u=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var a=e.normal,i=t.normal,o=r.normal;cQ.cross(i,o,u._tempVec30),cQ.cross(o,a,u._tempVec31),cQ.cross(a,i,u._tempVec32);var s=-cQ.dot(a,u._tempVec30),l=-cQ.dot(i,u._tempVec31),c=-cQ.dot(o,u._tempVec32);cQ.scale(u._tempVec30,e.distance/s,u._tempVec30),cQ.scale(u._tempVec31,t.distance/l,u._tempVec31),cQ.scale(u._tempVec32,r.distance/c,u._tempVec32),cQ.add(u._tempVec30,u._tempVec31,n),cQ.add(n,u._tempVec32,n)},u.distancePlaneAndPoint=function(e,t){return cQ.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,a=r.max,i=t.normal,o=u._tempVec30,s=u._tempVec31;return(i.x>=0?(o.x=a.x,s.x=n.x):(o.x=n.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=n.y):(o.y=n.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=n.z):(o.z=n.z,s.z=a.z),0>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,a=r.radius,i=u.distancePlaneAndPoint(t,n);return i>a?e.PlaneIntersectionType.Front:i<-a?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var r=t.normal,n=cq.zeroTolerance,a=cQ.dot(r,e.direction);if(Math.abs(a)<n)return -1;var i=cQ.dot(r,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-n)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var r=cq.zeroTolerance,n=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,u=n.x,d=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(u<i.x||u>o.x)return -1}else{var p=1/s,m=(i.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<i.y||d>o.y)return -1}else{var y=1/l,x=(i.y-d)*y,b=(o.y-d)*y;if(x>b){var T=x;x=b,b=T}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<r){if(h<i.z||h>o.z)return -1}else{var C=1/c,S=(i.z-h)*C,A=(o.z-h)*C;if(S>A){var M=S;S=A,A=M}if((_=Math.max(S,_))>(f=Math.min(A,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,a=t.center,i=t.radius,o=u._tempVec30;cQ.subtract(r,a,o);var s=cQ.dot(o,n),l=cQ.dot(o,o)-i*i;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 cQ.distanceSquared(e.center,t.center)<r*r},u.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,a=t.min,i=u._tempVec30;return i.set(Math.max(a.x,Math.min(r.x,n.x)),Math.max(a.y,Math.min(r.y,n.y)),Math.max(a.z,Math.min(r.z,n.z))),cQ.distanceSquared(r,i)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,a=u._tempVec30,i=0;i<6;++i){var o=e.getPlane(i),s=o.normal;if(a.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),cQ.dot(s,a)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,r){var n=u.distancePlaneAndPoint(t.near,r);return Math.abs(n)<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.far,r))<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.left,r))<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.right,r))<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.top,r))<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.bottom,r))<cq.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,r){for(var n=r.min,a=r.max,i=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?(i.x=a.x,o.x=n.x):(i.x=n.x,o.x=a.x),d.y>=0?(i.y=a.y,o.y=n.y):(i.y=n.y,o.y=a.y),d.z>=0?(i.z=a.z,o.z=n.z):(i.z=n.z,o.z=a.z),u.intersectsPlaneAndPoint(c,i)===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,a=0;a<6;++a){var i=t.getPlane(a),o=u.intersectsPlaneAndSphere(i,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},u);c$._tempVec30=new cQ,c$._tempVec31=new cQ,c$._tempVec32=new cQ;var c0=((h=(d=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new cQ,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();cQ.scale(r,n,t.normal),t.distance=e.distance*n},d.fromPoints=function(e,t,r,n){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,u=r.x-a,d=r.y-i,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*a+v*i+y*o)},d),c1=((f=(_=function(e){void 0===e&&(e=null),this.near=new c0,this.far=new c0,this.left=new c0,this.right=new c0,this.top=new c0,this.bottom=new c0,e&&this.calculateFromMatrix(e)}).prototype).getPlane=function(t){switch(t){case e.FrustumFace.Near:return this.near;case e.FrustumFace.Far:return this.far;case e.FrustumFace.Left:return this.left;case e.FrustumFace.Right:return this.right;case e.FrustumFace.Bottom:return this.bottom;case e.FrustumFace.Top:return this.top;default:return null}},f.calculateFromMatrix=function(e){var t=e.elements,r=t[0],n=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],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(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+r,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-r,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+n,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-n,c-s,_-d),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return c$.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return c$.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},_),c2=((m=(p=function(e,t,r,n,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},m.add=function(e){return p.add(this,e,this),this},m.subtract=function(e){return p.subtract(this,e,this),this},m.multiply=function(e){return p.multiply(this,e,this),this},m.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*a+o*s)+n*(l*a-i*s)},m.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},m.invert=function(){return p.invert(this,this),this},m.rotate=function(e){return p.rotate(this,e,this),this},m.scale=function(e){return p.scale(this,e,this),this},m.translate=function(e){return p.translate(this,e,this),this},m.transpose=function(){return p.transpose(this,this),this},m.clone=function(){var e=this.elements;return new p(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},m.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},m.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<12;n++)r[n]=e[n+t];return this},m.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8]},m.copyFromMatrix=function(e){var t=e.elements,r=this.elements;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[4],r[4]=t[5],r[5]=t[6],r[6]=t[8],r[7]=t[9],r[8]=t[10],this},p.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8]},p.subtract=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3],i[4]=n[4]-a[4],i[5]=n[5]-a[5],i[6]=n[6]-a[6],i[7]=n[7]-a[7],i[8]=n[8]-a[8]},p.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=n[5],h=n[6],_=n[7],f=n[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],T=a[7],C=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+u*m+_*g,i[2]=l*p+d*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+u*y+_*x,i[5]=l*v+d*y+f*x,i[6]=o*b+c*T+h*C,i[7]=s*b+u*T+_*C,i[8]=l*b+d*T+f*C},p.equals=function(e,t){var r=e.elements,n=t.elements;return cq.equals(r[0],n[0])&&cq.equals(r[1],n[1])&&cq.equals(r[2],n[2])&&cq.equals(r[3],n[3])&&cq.equals(r[4],n[4])&&cq.equals(r[5],n[5])&&cq.equals(r[6],n[6])&&cq.equals(r[7],n[7])&&cq.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,u=n*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=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,a=r[0],i=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=a*_+i*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*i+o*d)*m,n[2]=(c*i-o*l)*m,n[3]=f*m,n[4]=(h*a-o*u)*m,n[5]=(-c*a+o*s)*m,n[6]=p*m,n[7]=(-d*a+i*u)*m,n[8]=(l*a-i*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],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=a*c-i*l,b=a*u-o*l,T=a*d-s*l,C=i*u-o*c,S=i*d-s*c,A=o*d-s*u,M=h*g-_*m,R=h*v-f*m,E=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+T*w+C*E-S*R+A*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*w)*L,n[1]=(u*E-l*F-d*R)*L,n[2]=(l*P-c*E+d*M)*L,n[3]=(o*P-i*F-s*w)*L,n[4]=(a*F-o*E+s*R)*L,n[5]=(i*E-a*P-s*M)*L,n[6]=(g*A-v*S+y*C)*L,n[7]=(v*T-m*A-y*b)*L,n[8]=(m*S-g*T+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,a=r.elements,i=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],u=n[3],d=n[4],h=n[5],_=n[6],f=n[7],p=n[8];a[0]=o*s+i*u,a[1]=o*l+i*d,a[2]=o*c+i*h,a[3]=o*u-i*s,a[4]=o*d-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},p.scale=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements;o[0]=n*i[0],o[1]=n*i[1],o[2]=n*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},p.translate=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements,s=i[0],l=i[1],c=i[2],u=i[3],d=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=n*s+a*u+_,o[7]=n*l+a*d+f,o[8]=n*c+a*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=a,n[5]=r[7],n[6]=i,n[7]=o}else n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8]},p),c3=((v=(g=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},v.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},v.getAxisAngle=function(e){var t=this._x,r=this._y,n=this._z,a=t*t+r*r+n*n;if(a<cq.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},v.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},v.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},v.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},v.normalize=function(){return g.normalize(this,this),this},v.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},v.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},v.rotateX=function(e){return g.rotateX(this,e,this),this},v.rotateY=function(e){return g.rotateY(this,e,this),this},v.rotateZ=function(e){return g.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return g.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return g.multiply(this,e,this),this},v.invert=function(){return g.invert(this,this),this},v.dot=function(e){return g.dot(this,e)},v.lerp=function(e,t){return g.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return g._tempQuat1.rotationAxisAngle(e,t),this.multiply(g._tempQuat1),this},v.clone=function(){return new g(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,r=this._y,n=this._z,a=this._w,i=t*t,o=r*r,s=n*n,l=a*a,c=i+o+s+l,u=2*(t*a-r*n);u>(1-cq.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-cq.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*a),s+l-o-i),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*r+n*a),o+l-s-i))},g.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},g.multiply=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;r._x=n*u+o*s+a*c-i*l,r._y=a*u+o*l+i*s-n*c,r._z=i*u+o*c+n*l-a*s,r._w=o*u-n*s-a*l-i*c,r._onValueChanged&&r._onValueChanged()},g.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},g.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},g.equals=function(e,t){return cq.equals(e._x,t._x)&&cq.equals(e._y,t._y)&&cq.equals(e._z,t._z)&&cq.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;cQ.normalize(e,n);var a=Math.sin(t*=.5);r._x=n._x*a,r._y=n._y*a,r._z=n._z*a,r._w=Math.cos(t),r._onValueChanged&&r._onValueChanged()},g.rotationEuler=function(e,t,r,n){g.rotationYawPitchRoll(t,e,r,n)},g.rotationYawPitchRoll=function(e,t,r,n){var a=.5*r,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),u=Math.cos(i),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,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],u=a[5],d=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(u-h)*r,t._y=(d-s)*r,t._z=(o-l)*r):i>=c&&i>=_?(n=.5/(r=Math.sqrt(1+i-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+d)*n,t._w=(u-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-i-_)),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+_-i-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,a=e._z,i=e._w,o=r*r+n*n+a*a+i*i;if(o>cq.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var a=1-r;g.dot(e,t)>=0?(n._x=e._x*a+t._x*r,n._y=e._y*a+t._y*r,n._z=e._z*a+t._z*r,n._w=e._w*a+t._w*r):(n._x=e._x*a-t._x*r,n._y=e._y*a-t._y*r,n._z=e._z*a-t._z*r,n._w=e._w*a-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var a,i,o=g.dot(e,t);if(Math.abs(o)>1-cq.zeroTolerance)i=1-r,a=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);i=Math.sin((1-r)*s)*l,a=Math.sin(r*s)*l*Math.sign(o)}n.x=i*e.x+a*t.x,n.y=i*e.y+a*t.y,n.z=i*e.z+a*t.z,n.w=i*e.w+a*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cq.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},g.rotationX=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=r,t._y=0,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationY=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=r,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationZ=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=0,t._z=r,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotateX=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=a*l+i*s,r._z=i*l-a*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-i*s,r._y=a*l+o*s,r._z=i*l+n*s,r._w=o*l-a*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+a*s,r._y=a*l-n*s,r._z=i*l+o*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},n(g,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<cq.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);c3._tempVector3=new cQ,c3._tempQuat1=new c3;var c4=((x=(y=function(e,t,r,n,a,i,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===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===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]=a,m[5]=i,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,a,i,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]=a,m[5]=i,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],a=e[3],i=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*i)*(d*m-h*p)-(t*s-n*i)*(u*m-h*f)+(t*l-a*i)*(u*p-d*f)+(r*s-n*o)*(c*m-h*_)-(r*l-a*o)*(c*p-d*_)+(n*l-a*s)*(c*f-u*_)},x.decompose=function(e,t,r){var n=y._tempMat30,a=this.elements,i=n.elements,o=a[0],s=a[1],l=a[2],c=a[4],u=a[5],d=a[6],h=a[8],_=a[9],f=a[10];e.set(a[12],a[13],a[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+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)<cq.zeroTolerance||Math.abs(m)<cq.zeroTolerance||Math.abs(g)<cq.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,b=1/g;return i[0]=o*v,i[1]=s*v,i[2]=l*v,i[3]=c*x,i[4]=u*x,i[5]=d*x,i[6]=h*b,i[7]=_*b,i[8]=f*b,c3.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>cq.zeroTolerance){var n=2*Math.sqrt(r+1);e._w=.25*n,e._x=(t[6]-t[9])/n,e._y=(t[8]-t[2])/n,e._z=(t[1]-t[4])/n}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},x.getScaling=function(e){var t=this.elements,r=t[0],n=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(r*r+n*n+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+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,a=t.elements,i=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],b=n[15],T=a[0],C=a[1],S=a[2],A=a[3],M=a[4],R=a[5],E=a[6],w=a[7],P=a[8],F=a[9],L=a[10],B=a[11],D=a[12],I=a[13],O=a[14],V=a[15];i[0]=o*T+u*C+f*S+v*A,i[1]=s*T+d*C+p*S+y*A,i[2]=l*T+h*C+m*S+x*A,i[3]=c*T+_*C+g*S+b*A,i[4]=o*M+u*R+f*E+v*w,i[5]=s*M+d*R+p*E+y*w,i[6]=l*M+h*R+m*E+x*w,i[7]=c*M+_*R+g*E+b*w,i[8]=o*P+u*F+f*L+v*B,i[9]=s*P+d*F+p*L+y*B,i[10]=l*P+h*F+m*L+x*B,i[11]=c*P+_*F+g*L+b*B,i[12]=o*D+u*I+f*O+v*V,i[13]=s*D+d*I+p*O+y*V,i[14]=l*D+h*I+m*O+x*V,i[15]=c*D+_*I+g*O+b*V},y.equals=function(e,t){var r=e.elements,n=t.elements;return cq.equals(r[0],n[0])&&cq.equals(r[1],n[1])&&cq.equals(r[2],n[2])&&cq.equals(r[3],n[3])&&cq.equals(r[4],n[4])&&cq.equals(r[5],n[5])&&cq.equals(r[6],n[6])&&cq.equals(r[7],n[7])&&cq.equals(r[8],n[8])&&cq.equals(r[9],n[9])&&cq.equals(r[10],n[10])&&cq.equals(r[11],n[11])&&cq.equals(r[12],n[12])&&cq.equals(r[13],n[13])&&cq.equals(r[14],n[14])&&cq.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r,o[9]=a[9]*s+i[9]*r,o[10]=a[10]*s+i[10]*r,o[11]=a[11]*s+i[11]*r,o[12]=a[12]*s+i[12]*r,o[13]=a[13]*s+i[13]*r,o[14]=a[14]*s+i[14]*r,o[15]=a[15]*s+i[15]*r},y.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8],i[9]=n[9]+a[9],i[10]=n[10]+a[10],i[11]=n[11]+a[11],i[12]=n[12]+a[12],i[13]=n[13]+a[13],i[14]=n[14]+a[14],i[15]=n[15]+a[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,a=r.elements;a[0]=n[0]*t,a[1]=n[1]*t,a[2]=n[2]*t,a[3]=n[3]*t,a[4]=n[4]*t,a[5]=n[5]*t,a[6]=n[6]*t,a[7]=n[7]*t,a[8]=n[8]*t,a[9]=n[9]*t,a[10]=n[10]*t,a[11]=n[11]*t,a[12]=n[12]*t,a[13]=n[13]*t,a[14]=n[14]*t,a[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,u=n*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=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,a,i,o=r.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<cq.zeroTolerance||(s*=u=1/u,l*=u,c*=u,n=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*n,o[2]=c*s*i-l*n,o[3]=0,o[4]=s*l*i-c*n,o[5]=l*l*i+a,o[6]=c*l*i+s*n,o[7]=0,o[8]=s*c*i+l*n,o[9]=l*c*i-s*n,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},y.rotationTranslation=function(e,t,r){y.rotationQuaternion(e,r);var n=r.elements;n[12]=t._x,n[13]=t._y,n[14]=t._z},y.affineTransformation=function(e,t,r,n){var a=n.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,u=o+o,d=s+s,h=i*c,_=i*u,f=i*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,b=e._x,T=e._y,C=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*T,a[5]=(1-(h+g))*T,a[6]=(m+v)*T,a[7]=0,a[8]=(f+y)*C,a[9]=(m-v)*C,a[10]=(1-(h+p))*C,a[11]=0,a[12]=r._x,a[13]=r._y,a[14]=r._z,a[15]=1},y.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e._y,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e._z,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e._x,r[13]=e._y,r[14]=e._z,r[15]=1},y.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],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=a*c-i*l,b=a*u-o*l,T=a*d-s*l,C=i*u-o*c,S=i*d-s*c,A=o*d-s*u,M=h*g-_*m,R=h*v-f*m,E=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+T*w+C*E-S*R+A*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*w)*L,n[1]=(o*P-i*F-s*w)*L,n[2]=(g*A-v*S+y*C)*L,n[3]=(f*S-_*A-p*C)*L,n[4]=(u*E-l*F-d*R)*L,n[5]=(a*F-o*E+s*R)*L,n[6]=(v*T-m*A-y*b)*L,n[7]=(h*A-f*T+p*b)*L,n[8]=(l*P-c*E+d*M)*L,n[9]=(i*E-a*P-s*M)*L,n[10]=(m*S-g*T+y*x)*L,n[11]=(_*T-h*S-p*x)*L,n[12]=(c*R-l*w-u*M)*L,n[13]=(a*w-i*R+o*M)*L,n[14]=(g*b-m*C-v*x)*L,n[15]=(h*C-_*b+f*x)*L},y.lookAt=function(e,t,r,n){var a=n.elements,i=y._tempVec30,o=y._tempVec31,s=y._tempVec32;cQ.subtract(e,t,s),s.normalize(),cQ.cross(r,s,i),i.normalize(),cQ.cross(s,i,o),a[0]=i._x,a[1]=o._x,a[2]=s._x,a[3]=0,a[4]=i._y,a[5]=o._y,a[6]=s._y,a[7]=0,a[8]=i._z,a[9]=o._z,a[10]=s._z,a[11]=0,a[12]=-cQ.dot(i,e),a[13]=-cQ.dot(o,e),a[14]=-cQ.dot(s,e),a[15]=1},y.ortho=function(e,t,r,n,a,i,o){var s=o.elements,l=1/(e-t),c=1/(r-n),u=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(i+a)*u,s[15]=1},y.perspective=function(e,t,r,n,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(r-n);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(n+r)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*n*r*s,i[15]=0},y.rotateAxisAngle=function(e,t,r,n){var a,i,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<cq.zeroTolerance)){var d=e.elements,h=n.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(r),o=1-(i=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],b=d[8],T=d[9],C=d[10],S=d[11],A=s*s*o+i,M=l*s*o+c*a,R=c*s*o-l*a,E=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,B=c*c*o+i;h[0]=_*A+g*M+b*R,h[1]=f*A+v*M+T*R,h[2]=p*A+y*M+C*R,h[3]=m*A+x*M+S*R,h[4]=_*E+g*w+b*P,h[5]=f*E+v*w+T*P,h[6]=p*E+y*w+C*P,h[7]=m*E+x*w+S*P,h[8]=_*F+g*L+b*B,h[9]=f*F+v*L+T*B,h[10]=p*F+y*L+C*B,h[11]=m*F+x*L+S*B,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,a=r.elements,i=t._x,o=t._y,s=t._z;a[0]=n[0]*i,a[1]=n[1]*i,a[2]=n[2]*i,a[3]=n[3]*i,a[4]=n[4]*o,a[5]=n[5]*o,a[6]=n[6]*o,a[7]=n[7]*o,a[8]=n[8]*s,a[9]=n[9]*s,a[10]=n[10]*s,a[11]=n[11]*s,a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;if(e===r)a[12]=n[0]*i+n[4]*o+n[8]*s+n[12],a[13]=n[1]*i+n[5]*o+n[9]*s+n[13],a[14]=n[2]*i+n[6]*o+n[10]*s+n[14],a[15]=n[3]*i+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],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];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]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+n[12],a[13]=c*i+_*o+g*s+n[13],a[14]=u*i+f*o+v*s+n[14],a[15]=d*i+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[3],s=r[6],l=r[7],c=r[11];n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=a,n[6]=r[9],n[7]=r[13],n[8]=i,n[9]=s,n[11]=r[14],n[12]=o,n[13]=l,n[14]=c}else n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15]},y);c4._tempVec30=new cQ,c4._tempVec31=new cQ,c4._tempVec32=new cQ,c4._tempMat30=new c2,c4._identity=new c4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var c8=((T=(b=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new cQ,this.direction=new cQ,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return c$.intersectsRayAndPlane(this,e)},T.intersectSphere=function(e){return c$.intersectsRayAndSphere(this,e)},T.intersectBox=function(e){return c$.intersectsRayAndBox(this,e)},T.getPoint=function(e,t){return cQ.scale(this.direction,e,t),t.add(this.origin)},b),c5=((S=(C=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}).prototype).set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},S.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},S.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},S.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},S.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},S.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},S.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},S.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},S.normalize=function(){return C.normalize(this,this),this},S.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},S.clone=function(){return new C(this._x,this._y)},S.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},S.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},S.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},S.toJSON=function(){return{x:this._x,y:this._y}},C.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._onValueChanged&&r._onValueChanged()},C.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._onValueChanged&&r._onValueChanged()},C.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._onValueChanged&&r._onValueChanged()},C.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._onValueChanged&&r._onValueChanged()},C.dot=function(e,t){return e._x*t._x+e._y*t._y},C.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y;return Math.sqrt(r*r+n*n)},C.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y;return r*r+n*n},C.equals=function(e,t){return cq.equals(e._x,t._x)&&cq.equals(e._y,t._y)},C.lerp=function(e,t,r,n){var a=e._x,i=e._y;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._onValueChanged&&n._onValueChanged()},C.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},C.normalize=function(e,t){var r=e._x,n=e._y,a=Math.sqrt(r*r+n*n);a>cq.zeroTolerance&&(a=1/a,t._x=r*a,t._y=n*a,t._onValueChanged&&t._onValueChanged())},C.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._onValueChanged&&r._onValueChanged()},n(C,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),C);c5._zero=new c5(0,0),c5._one=new c5(1,1);var c9=((M=(A=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},M.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},M.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},M.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},M.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},M.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},M.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},M.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},M.normalize=function(){return A.normalize(this,this),this},M.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},M.clone=function(){return new A(this._x,this._y,this._z,this._w)},M.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},M.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},M.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},M.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},A.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._w=e._w-t._w,r._onValueChanged&&r._onValueChanged()},A.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._w=e._w*t._w,r._onValueChanged&&r._onValueChanged()},A.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._w=e._w/t._w,r._onValueChanged&&r._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(r*r+n*n+a*a+i*i)},A.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return r*r+n*n+a*a+i*i},A.equals=function(e,t){return cq.equals(e._x,t._x)&&cq.equals(e._y,t._y)&&cq.equals(e._z,t._z)&&cq.equals(e._w,t._w)},A.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z,s=e._w;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},A.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._w=Math.max(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._w=Math.min(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cq.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},A.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},A.transform=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;r._x=n*s[0]+a*s[4]+i*s[8]+o*s[12],r._y=n*s[1]+a*s[5]+i*s[9]+o*s[13],r._z=n*s[2]+a*s[6]+i*s[10]+o*s[14],r._w=n*s[3]+a*s[7]+i*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},A.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*n+l*i-c*a,h=u*a+c*n-s*i,_=u*i+s*a-l*n,f=-s*n-l*a-c*i;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(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);c9._zero=new c9(0,0,0,0),c9._one=new c9(1,1,1,1);var c6=((E=(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},E.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},E.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new R(this._r,this._g,this._b,this._a)},E.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},E.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},E.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},E.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},E.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},E.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,a=e;return t>n&&(n=t),r>n&&(n=r),t<a&&(a=t),r<a&&(a=r),(n+a)/2},E.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 cq.equals(e._r,t._r)&&cq.equals(e._g,t._g)&&cq.equals(e._b,t._b)&&cq.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 a=e._r,i=e._g,o=e._b,s=e._a;return n._r=a+(t._r-a)*r,n._g=i+(t._g-i)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(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),c7=((P=(w=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=r,this._height=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._width=r,this._height=n,this._onValueChanged&&this._onValueChanged(),this},P.clone=function(){return new w(this.x,this.y,this.width,this.height)},P.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},n(w,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),w),ue=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*i,d=.488603*o,h=-.488603*a,_=1.092548*(a*i),f=-1.092548*(i*o),p=.315392*(3*o*o-1),m=-1.092548*(a*o),g=.546274*(a*a-i*i);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*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,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*n,c=.858086*a*n,u=-.858086*a*i,d=.247708*(3*i*i-1),h=-.858086*i*n,_=.429042*(n*n-a*a),f=.886227*r[0],p=.886227*r[1],m=.886227*r[2];return f+=r[3]*o+r[6]*s+r[9]*l,p+=r[4]*o+r[7]*s+r[10]*l,m+=r[5]*o+r[8]*s+r[11]*l,f+=r[12]*c+r[15]*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),ut=((D=(B=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},D.random=function(){return this.randomInt32()/4294967295},D.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},B);function ur(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function un(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 ua(e,t,r){return t&&un(e.prototype,t),r&&un(e,r),e}function ui(e,t){return(ui=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function uo(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&&ui(e,t)}function us(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function ul(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function uc(e,t){u_.registerCloneMode(e,t,l6.Ignore)}function uu(e,t){u_.registerCloneMode(e,t,l6.Assignment)}function ud(e,t){u_.registerCloneMode(e,t,l6.Shallow)}function uh(e,t){u_.registerCloneMode(e,t,l6.Deep)}e.Platform=void 0,(I=e.Platform||(e.Platform={}))[I.Android=0]="Android",I[I.IPhone=1]="IPhone",I[I.IPad=2]="IPad",I[I.Mac=3]="Mac",I[I.Unknown=4]="Unknown",e.SpriteMaskInteraction=void 0,(O=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[O.None=0]="None",O[O.VisibleInsideMask=1]="VisibleInsideMask",O[O.VisibleOutsideMask=2]="VisibleOutsideMask",e.SpriteMaskLayer=void 0,(V=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[V.Layer0=1]="Layer0",V[V.Layer1=2]="Layer1",V[V.Layer2=4]="Layer2",V[V.Layer3=8]="Layer3",V[V.Layer4=16]="Layer4",V[V.Layer5=32]="Layer5",V[V.Layer6=64]="Layer6",V[V.Layer7=128]="Layer7",V[V.Layer8=256]="Layer8",V[V.Layer9=512]="Layer9",V[V.Layer10=1024]="Layer10",V[V.Layer11=2048]="Layer11",V[V.Layer12=4096]="Layer12",V[V.Layer13=8192]="Layer13",V[V.Layer14=16384]="Layer14",V[V.Layer15=32768]="Layer15",V[V.Layer16=65536]="Layer16",V[V.Layer17=131072]="Layer17",V[V.Layer18=262144]="Layer18",V[V.Layer19=524288]="Layer19",V[V.Layer20=1048576]="Layer20",V[V.Layer21=2097152]="Layer21",V[V.Layer22=4194304]="Layer22",V[V.Layer23=8388608]="Layer23",V[V.Layer24=16777216]="Layer24",V[V.Layer25=33554432]="Layer25",V[V.Layer26=67108864]="Layer26",V[V.Layer27=134217728]="Layer27",V[V.Layer28=268435456]="Layer28",V[V.Layer29=536870912]="Layer29",V[V.Layer30=1073741824]="Layer30",V[V.Layer31=2147483648]="Layer31",V[V.Everything=4294967295]="Everything",e.TextHorizontalAlignment=void 0,(N=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[N.Left=0]="Left",N[N.Center=1]="Center",N[N.Right=2]="Right",e.TextVerticalAlignment=void 0,(k=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[k.Top=0]="Top",k[k.Center=1]="Center",k[k.Bottom=2]="Bottom",e.OverflowMode=void 0,(z=e.OverflowMode||(e.OverflowMode={}))[z.Overflow=0]="Overflow",z[z.Truncate=1]="Truncate",e.FontStyle=void 0,(U=e.FontStyle||(e.FontStyle={}))[U.None=0]="None",U[U.Bold=1]="Bold",U[U.Italic=2]="Italic","function"==typeof SuppressedError&&SuppressedError,(G=l6||(l6={}))[G.Ignore=0]="Ignore",G[G.Assignment=1]="Assignment",G[G.Shallow=2]="Shallow",G[G.Deep=3]="Deep";var u_=((H=function(){}).registerCloneMode=function(e,t,r){var n=H._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),H._subCloneModeMap.set(e.constructor,n)),n[t]=r},H.getCloneMode=function(e){var t=H._cloneModeMap.get(e);if(!t){t=Object.create(null),H._cloneModeMap.set(e,t);for(var r=H._objectType,n=H._subCloneModeMap;e!==r;){var a=n.get(e);a&&Object.assign(t,a),e=Object.getPrototypeOf(e)}}return t},H.cloneProperty=function(e,t,r,n,a,i,o){if(n!==l6.Ignore){var s=e[r];if(ul(s,Object)){if(void 0===n||n===l6.Assignment){t[r]=s;return}switch(s.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var l=t[r];null==l||l.length!==s.length?t[r]=s.slice():l.set(s);break;case Array:var c=t[r],u=s.length;null==c?t[r]=c=Array(u):c.length=u;for(var d=0;d<u;d++)H.cloneProperty(s,c,d,n,a,i,o);break;default:var h=t[r];if(h||((h=o.get(s))||(h=new s.constructor,o.set(s,h)),t[r]=h),s.copyFrom)h.copyFrom(s);else{var _=H.getCloneMode(s.constructor);for(var f in s)H.cloneProperty(s,h,f,_[f],a,i,o);s._cloneTo&&s._cloneTo(h,a,i)}}}else t[r]=s}},H.deepCloneObject=function(e,t,r){for(var n in e)H.cloneProperty(e,t,n,l6.Deep,null,null,r)},H);u_._subCloneModeMap=new Map,u_._cloneModeMap=new Map,u_._objectType=Object.getPrototypeOf(Object);var uf=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)},ua(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();uf._instanceIdCounter=0,us([uc],uf.prototype,"instanceId",void 0),us([uc],uf.prototype,"_engine",void 0);var up=(uo(W=function(e){var t;return(t=uf.call(this,e)||this).isGCIgnored=!1,t._refCount=0,t._superResources=null,e.resourceManager._addReferResource(ur(t)),t},uf),(j=W.prototype).destroy=function(e,t){if(void 0===e&&(e=!1),!e){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!t)return!1;for(var n=0,a=r.length;n<a;n++)if(r[n].refCount>0)return!1}}return uf.prototype.destroy.call(this),!0},j._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},j._disassociationSuperResource=function(e){var t=this._superResources,r=t.indexOf(e);t.splice(r,1)},j._getReferCount=function(){return this._refCount},j._addReferCount=function(e){this._refCount+=e},j._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},j._onDestroy=function(){uf.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},ua(W,[{key:"refCount",get:function(){return this._refCount}}]),W),um=(uo(K=function(e){var t;return(t=up.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},up),(X=K.prototype).getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},X.getSprites=function(e,t){t.length=0;var r=this._spriteNamesToIndex[e];if(void 0!==r)for(var n=this._sprites;r>=0;r--){var a=n[r];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},X._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},X._onDestroy=function(){up.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},ua(K,[{key:"sprites",get:function(){return this._sprites}}]),K);e.SpriteDrawMode=void 0,(Y=e.SpriteDrawMode||(e.SpriteDrawMode={}))[Y.Simple=0]="Simple",Y[Y.Sliced=1]="Sliced",Y[Y.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(q=e.SpriteTileMode||(e.SpriteTileMode={}))[q.Continuous=0]="Continuous",q[q.Adaptive=1]="Adaptive";var ug=((Q=function(){}).removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var a=e[n];e[r]=a}return e.length--,!0},Q.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",r=0,n=e.length;r<n;r++)t+=String.fromCharCode(e[r]);return decodeURIComponent(encodeURIComponent(t))},Q.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Q.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},Q.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},Q.resolveAbsoluteUrl=function(e,t){return Q.isAbsoluteUrl(t)||Q.isBase64Url(t)?t:t?new URL(t,e).href:e},Q._floatMatrixMultiply=function(e,t,r,n,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],T=t[r],C=t[r+1],S=t[r+2],A=t[r+3],M=t[r+4],R=t[r+5],E=t[r+6],w=t[r+7],P=t[r+8],F=t[r+9],L=t[r+10],B=t[r+11],D=t[r+12],I=t[r+13],O=t[r+14],V=t[r+15];n[a]=o*T+u*C+f*S+v*A,n[a+1]=s*T+d*C+p*S+y*A,n[a+2]=l*T+h*C+m*S+x*A,n[a+3]=c*T+_*C+g*S+b*A,n[a+4]=o*M+u*R+f*E+v*w,n[a+5]=s*M+d*R+p*E+y*w,n[a+6]=l*M+h*R+m*E+x*w,n[a+7]=c*M+_*R+g*E+b*w,n[a+8]=o*P+u*F+f*L+v*B,n[a+9]=s*P+d*F+p*L+y*B,n[a+10]=l*P+h*F+m*L+x*B,n[a+11]=c*P+_*F+g*L+b*B,n[a+12]=o*D+u*I+f*O+v*V,n[a+13]=s*D+d*I+p*O+y*V,n[a+14]=l*D+h*I+m*O+x*V,n[a+15]=c*D+_*I+g*O+b*V},Q._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,a=0,i=r.length;null!=n&&a<i;)n=n[r[a++]];return a&&a==i?n:void 0},Q._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var a=t+r>>1,i=e[t],o=e[r-1],s=e[a];if(n(i,o)>0){var l=i;i=o,o=l}if(n(i,s)>=0){var c=i;i=s,s=o,o=c}else if(n(o,s)>0){var u=o;o=s,s=u}e[t]=i,e[r-1]=s;var d=o,h=t+1,_=r-1;e[a]=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=_)}},Q._stringToPath=function(e){var t=[];return e.charCodeAt(0)===uv&&t.push(""),e.replace(ux,function(e,r,n,a){var i=e;n?i=a.replace(uy,"$1"):r&&(i=r.trim()),t.push(i)}),t},Q._insertionSort=function(e,t,r,n){for(var a=t+1;a<r;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(n(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},Q),uv=46,uy=/\\(\\)?/g,ux=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),ub=((J=(Z=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},J.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},J.removeFlag=function(e){ug.removeFromArray(this._updateFlags,e)&&ug.removeFromArray(e._flagManagers,this)},J.addListener=function(e){this._listeners.push(e)},J.removeListener=function(e){ug.removeFromArray(this._listeners,e)},J.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},Z);($=l7||(l7={}))[$.texture=1]="texture",$[$.size=2]="size",$[$.atlasRotate=4]="atlasRotate",$[$.atlasRegion=8]="atlasRegion",$[$.atlasRegionOffset=16]="atlasRegionOffset",$[$.region=32]="region",$[$.pivot=64]="pivot",$[$.border=128]="border",$[$.destroy=256]="destroy";var uT=(uo(ee=function(e,t,r,n,a,i){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===a&&(a=null),void 0===i&&(i=null),(o=up.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new c5,new c5,new c5,new c5],o._uvs=[new c5,new c5,new c5,new c5],o._bounds=new cJ,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new c7(0,0,1,1),o._atlasRegionOffset=new c9(0,0,0,0),o._region=new c7(0,0,1,1),o._pivot=new c5(.5,.5),o._border=new c9(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new ub,o._texture=t,o._onRegionChange=o._onRegionChange.bind(ur(o)),o._onPivotChange=o._onPivotChange.bind(ur(o)),o._onBorderChange=o._onBorderChange.bind(ur(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,r&&o._region.copyFrom(r),n&&o._pivot.copyFrom(n),a&&o._border.copyFrom(a),o.name=i,o},up),(et=ee.prototype).clone=function(){var e=new ee(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},et._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},et._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},et._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},et._addReferCount=function(e){var t;up.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},et._onDestroy=function(){this._dispatchSpriteChange(l7.destroy),up.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},et._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,a=1/h3._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*a,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},et._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,a=t.width,i=t.height,o=Math.max(e.x-r,0)/a,s=Math.max(e.w-n,0)/i,l=1-Math.max(e.z-(1-r-a),0)/a,c=1-Math.max(e.y-(1-n-i),0)/i,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},et._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,a=r.y,i=r.width,o=r.height,s=1-n-i,l=1-a-o,c=this._atlasRegion,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,b=Math.max(l-p,0)*y+d,T=h+u-Math.max(s-m,0)*v,C=_+d-Math.max(a-g,0)*y,S=this._border,A=S.x,M=S.y,R=S.z,E=S.w;e[0].set(x,C),e[1].set((n-f+A*i)*v+u,_+d-(a-g+M*o)*y),e[2].set(h+u-(s-m+R*i)*v,(l-p+E*o)*y+d),e[3].set(T,b),this._dirtyUpdateFlag&=-3},et._dispatchSpriteChange=function(e){switch(e){case l7.texture:this._dirtyUpdateFlag|=4;break;case l7.atlasRegionOffset:case l7.region:this._dirtyUpdateFlag|=7;break;case l7.atlasRegion:this._dirtyUpdateFlag|=6;break;case l7.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},et._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=cq.clamp(e.x,0,1),r=cq.clamp(e.y,0,1);e.set(t,r,cq.clamp(e.width,0,1-t),cq.clamp(e.height,0,1-r)),this._dispatchSpriteChange(l7.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(l7.size),e._onValueChanged=this._onRegionChange},et._onPivotChange=function(){this._dispatchSpriteChange(l7.pivot)},et._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=cq.clamp(e.x,0,1),r=cq.clamp(e.y,0,1);e.set(t,r,cq.clamp(e.z,0,1-t),cq.clamp(e.w,0,1-r)),this._dispatchSpriteChange(l7.border),e._onValueChanged=this._onBorderChange},ua(ee,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(l7.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(l7.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(l7.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(l7.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=cq.clamp(e.x,0,1),r=cq.clamp(e.y,0,1);this._atlasRegion.set(t,r,cq.clamp(e.width,0,1-t),cq.clamp(e.height,0,1-r)),this._dispatchSpriteChange(l7.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(l7.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=cq.clamp(e.x,0,1),r=cq.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,cq.clamp(e.z,0,1-t),cq.clamp(e.w,0,1-r)),this._dispatchSpriteChange(l7.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(l7.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),ee);(er=ce||(ce={}))[er.positions=1]="positions",er[er.uvs=2]="uvs",er[er.automaticSize=4]="automaticSize",er[er.all=7]="all";var uC=((en=function(){}).canBatchSprite=function(t,r){if(t.subChunk.chunk!==r.subChunk.chunk)return!1;var n=t.component,a=r.component,i=n.maskInteraction;return i===a.maskInteraction&&(i===e.SpriteMaskInteraction.None||n.maskLayer===a.maskLayer)&&t.texture===r.texture&&t.material===r.material},en.canBatchSpriteMask=function(e,t){if(e.subChunk.chunk!==t.subChunk.chunk)return!1;var r=dA._alphaCutoffProperty;return e.texture===t.texture&&e.component.shaderData.getFloat(r)===t.component.shaderData.getFloat(r)},en.batchFor2D=function(e,t){var r=t?t.subChunk:e.subChunk,n=r.chunk,a=r.indices,i=a.length,o=n.updateIndexLength;if(t)e.subChunk.subMesh.count+=i;else{var s=r.subMesh;s.start=o,s.count=i}for(var l=r.vertexArea,c=l.start,u=l.size,d=c/9,h=n.indices,_=0;_<i;++_)h[o++]=d+a[_];n.updateIndexLength+=i,n.updateVertexStart=Math.min(n.updateVertexStart,c),n.updateVertexLength=Math.max(n.updateVertexLength,c+u)},en),uS=((ei=(ea=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},ei.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ei.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ei.dispatch=function(e,t){if(!this._events[e])return!1;var r=this._events[e];if(Array.isArray(r)){var n=r.length,a=ea._dispatchingListenersPool,i=a.length>0?a.pop():[];i.length=n;for(var o=0;o<n;o++)i[o]=r[o];for(var s=0;s<n;s++){var l=i[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}i.length=0,a.push(i)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},ei.on=function(e,t){return this._addEventListener(e,t)},ei.once=function(e,t){return this._addEventListener(e,t,!0)},ei.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var r=this._events[e],n=Array.isArray(r);if(n||r.fn!==t){if(n){for(var a=r.length-1;a>=0;a--)r[a].fn===t&&(r[a].destroyed=!0,r.splice(a,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},ei.removeEventListener=function(e,t){return this.off(e,t)},ei.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ei._addEventListener=function(e,t,r){var n={fn:t,once:r},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(n):a[e]=[i,n]:(a[e]=n,this._eventCount++),this},ei._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},ea);uS._dispatchingListenersPool=[];var uA=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},uM=console.log.bind(console),uR=console.info.bind(console),uE=console.warn.bind(console),uw=console.error.bind(console),uP={debug:uA,info:uA,warn:uA,error:uA,isEnabled:!1,enable:function(){this.debug=uM,this.info=uR,this.warn=uE,this.error=uw,this.isEnabled=!0},disable:function(){this.debug=uA,this.info=uA,this.warn=uA,this.error=uA,this.isEnabled=!1}},uF=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},ua(e,[{key:"type",get:function(){return this._type}}]),e}();uF._propertyIdMap=Object.create(null),uF._propertyNameCounter=0,uF._propertyNameMap=Object.create(null);var uL=((es=(eo=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new c9,this._deltaTimeValue=new c9,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},es._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},es._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(eo._elapsedTimeProperty,t),r.set(this._deltaTime,0,0,0),e.setVector4(eo._deltaTimeProperty,r)},ua(eo,[{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}}]),eo);uL._elapsedTimeProperty=uF.getByName("scene_ElapsedTime"),uL._deltaTimeProperty=uF.getByName("scene_DeltaTime"),e.DataType=void 0,(el=e.DataType||(e.DataType={}))[el.FLOAT=5126]="FLOAT",el[el.FLOAT_VEC2=35664]="FLOAT_VEC2",el[el.FLOAT_VEC3=35665]="FLOAT_VEC3",el[el.FLOAT_VEC4=35666]="FLOAT_VEC4",el[el.INT=5124]="INT",el[el.INT_VEC2=35667]="INT_VEC2",el[el.INT_VEC3=35668]="INT_VEC3",el[el.INT_VEC4=35669]="INT_VEC4",el[el.BOOL=35670]="BOOL",el[el.BOOL_VEC2=35671]="BOOL_VEC2",el[el.BOOL_VEC3=35672]="BOOL_VEC3",el[el.BOOL_VEC4=35673]="BOOL_VEC4",el[el.FLOAT_MAT2=35674]="FLOAT_MAT2",el[el.FLOAT_MAT3=35675]="FLOAT_MAT3",el[el.FLOAT_MAT4=35676]="FLOAT_MAT4",el[el.FLOAT_ARRAY=35677]="FLOAT_ARRAY",el[el.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",el[el.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",el[el.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",el[el.INT_ARRAY=100003]="INT_ARRAY",el[el.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",el[el.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",el[el.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",el[el.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",el[el.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",el[el.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",el[el.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",el[el.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",el[el.SAMPLER_2D=35678]="SAMPLER_2D",el[el.SAMPLER_CUBE=35680]="SAMPLER_CUBE",el[el.BYTE=5120]="BYTE",el[el.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",el[el.SHORT=5122]="SHORT",el[el.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",el[el.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(ec=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",ec.standardDerivatives="OES_standard_derivatives",ec.shaderTextureLod="EXT_shader_texture_lod",ec.elementIndexUint="OES_element_index_uint",ec.depthTexture="WEBGL_depth_texture",ec.drawBuffers="WEBGL_draw_buffers",ec.vertexArrayObject="OES_vertex_array_object",ec.instancedArrays="ANGLE_instanced_arrays",ec.multipleSample="multipleSampleOnlySupportedInWebGL2",ec.textureFloat="OES_texture_float",ec.textureFloatLinear="OES_texture_float_linear",ec.textureHalfFloat="OES_texture_half_float",ec.textureHalfFloatLinear="OES_texture_half_float_linear",ec.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",ec.colorBufferFloat="EXT_color_buffer_float",ec.colorBufferHalfFloat="EXT_color_buffer_half_float",ec.textureFilterAnisotropic="EXT_texture_filter_anisotropic",ec.blendMinMax="EXT_blend_minmax",ec.fragDepth="EXT_frag_depth",ec.astc="WEBGL_compressed_texture_astc",ec.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",ec.etc="WEBGL_compressed_texture_etc",ec.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",ec.etc1="WEBGL_compressed_texture_etc1",ec.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",ec.pvrtc="WEBGL_compressed_texture_pvrtc",ec.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",ec.s3tc="WEBGL_compressed_texture_s3tc",ec.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",ec.bptc="EXT_texture_compression_bptc",ec.WEBGL_lose_context="WEBGL_lose_context",(eu=ct||(ct={}))[eu.None=0]="None",eu[eu.Scene=1]="Scene",eu[eu.Hierarchy=2]="Hierarchy",eu[eu.All=3]="All";var uB=(uo(ed=function(e){var t;return(t=uf.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},uf),(eh=ed.prototype)._onAwake=function(){},eh._onEnable=function(){},eh._onDisable=function(){},eh._onEnableInScene=function(){},eh._onDisableInScene=function(){},eh._setActive=function(e,t){var r=this._entity;t&ct.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&ct.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()))},eh._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},eh._onDestroy=function(){uf.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},ua(ed,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?this._phasedActiveInScene||(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?this._phasedActive||(this._phasedActive=!0,this._onEnable()):this._phasedActive&&(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),ed);us([uc],uB.prototype,"_entity",void 0),us([uc],uB.prototype,"_awoken",void 0),us([uc],uB.prototype,"_phasedActiveInScene",void 0),us([uc],uB.prototype,"_phasedActive",void 0),us([uu],uB.prototype,"_enabled",void 0);var uD=((e_=function(){})._addCheck=function(e,t){for(;t!==uB;){var r=e_._dependenciesMap.get(t);if(r)for(var n=r.components,a=r.mode,i=0,o=n.length;i<o;i++){var s=n[i];if(!e.getComponent(s)){if(1===a)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},e_._removeCheck=function(e,t){for(;t!==uB;){var r=e_._invDependenciesMap.get(t);if(r){for(var n=0,a=r.length;n<a;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},e_._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},e_._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},e_);function uI(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){uD._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return uD._addInvDependency(t,e)})}}uD._invDependenciesMap=new Map,uD._dependenciesMap=new Map,e.DependentMode=void 0,(ef=e.DependentMode||(e.DependentMode={}))[ef.CheckOnly=0]="CheckOnly",ef[ef.AutoAdd=1]="AutoAdd";var uO=((em=(ep=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},em.destroy=function(){this._removeFromManagers(),this._flagManagers=null},em._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)ug.removeFromArray(e[t]._updateFlags,this)},uo(eg=function(){var e;return e=ep.apply(this,arguments)||this,e.flag=!0,e},ep),eg.prototype.dispatch=function(){this.flag=!0},eg),uV=(uo(ev=function(e){var t;return(t=uB.call(this,e)||this)._position=new cQ,t._rotation=new cQ,t._rotationQuaternion=new c3,t._scale=new cQ(1,1,1),t._worldPosition=new cQ,t._worldRotation=new cQ,t._worldRotationQuaternion=new c3,t._lossyWorldScale=new cQ(1,1,1),t._localMatrix=new c4,t._worldMatrix=new c4,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new ub,t._onPositionChanged=t._onPositionChanged.bind(ur(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(ur(t)),t._onRotationChanged=t._onRotationChanged.bind(ur(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(ur(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(ur(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(ur(t)),t._onScaleChanged=t._onScaleChanged.bind(ur(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},uB),(ey=ev.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},ey.setRotation=function(e,t,r){this._rotation.set(e,t,r)},ey.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},ey.setScale=function(e,t,r){this._scale.set(e,t,r)},ey.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},ey.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},ey.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},ey.translate=function(e,t,r,n){if("number"==typeof e){var a=ev._tempVec30;a.set(e,t,r),this._translate(a,n)}else this._translate(e,t)},ey.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},ey.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*cq.degreeToRadFactor;c3.rotationAxisAngle(e,n,ev._tempQuat0),this._rotateByQuat(ev._tempQuat0,r)},ey.lookAt=function(e,t){var r=ev._tempVec30;cQ.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=cq.zeroTolerance)){r.scale(1/n);var a=ev._tempVec31;if(t?cQ.cross(t,r,a):a.set(r.z,0,-r.x),!((n=a.length())<=cq.zeroTolerance)){a.scale(1/n);var i=ev._tempVec32;cQ.cross(r,a,i);var o=ev._tempMat41,s=o.elements;s[0]=a.x,s[1]=a.y,s[2]=a.z,s[4]=i.x,s[5]=i.y,s[6]=i.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},ey.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(uO)},ey._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},ey._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},ey._onDestroy=function(){uB.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},ey._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()}},ey._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()}},ey._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()}},ey._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()}},ey._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()}},ey._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()}},ey._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},ey._getScaleMatrix=function(){var e=ev._tempQuat0,t=ev._tempMat30,r=ev._tempMat31,n=ev._tempMat32;return r.copyFromMatrix(this.worldMatrix),c3.invert(this.worldRotationQuaternion,e),c2.rotationQuaternion(e,t),c2.multiply(t,r,n),n},ey._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},ey._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ey._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ey._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ey._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},ey._rotateByQuat=function(e,t){t?c3.multiply(this.rotationQuaternion,e,this._rotationQuaternion):c3.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},ey._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=ev._tempVec30;cQ.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},ey._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var a=cq.degreeToRadFactor,i=ev._tempQuat0;c3.rotationEuler(e*a,t*a,r*a,i),this._rotateByQuat(i,n)},ey._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},ey._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(c4.invert(t.worldMatrix,ev._tempMat41),cQ.transformCoordinate(e,ev._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},ey._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},ey._onWorldRotationChanged=function(){var e=this._worldRotation;c3.rotationEuler(cq.degreeToRadian(e.x),cq.degreeToRadian(e.y),cq.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},ey._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},ey._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=ev._tempQuat0;c3.invert(t.worldRotationQuaternion,r),c3.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},ey._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},ua(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(cq.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(cq.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,c3.rotationEuler(cq.degreeToRadian(this._rotation.x),cq.degreeToRadian(this._rotation.y),cq.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):c3.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?c3.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):c3.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)&&(c4.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?c4.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?(c4.invert(t.worldMatrix,ev._tempMat42),c4.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 cQ),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 cQ),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 cQ),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),ev);function uN(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 uk(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 uN(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 uN(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.")}uV._tempQuat0=new c3,uV._tempVec30=new cQ,uV._tempVec31=new cQ,uV._tempVec32=new cQ,uV._tempMat30=new c2,uV._tempMat31=new c2,uV._tempMat32=new c2,uV._tempMat41=new c4,uV._tempMat42=new c4,us([uh],uV.prototype,"_position",void 0),us([uh],uV.prototype,"_rotation",void 0),us([uh],uV.prototype,"_rotationQuaternion",void 0),us([uh],uV.prototype,"_scale",void 0),us([uh],uV.prototype,"_worldPosition",void 0),us([uh],uV.prototype,"_worldRotation",void 0),us([uh],uV.prototype,"_worldRotationQuaternion",void 0),us([uh],uV.prototype,"_lossyWorldScale",void 0),us([uh],uV.prototype,"_localMatrix",void 0),us([uh],uV.prototype,"_worldMatrix",void 0),us([uc],uV.prototype,"_worldForward",void 0),us([uc],uV.prototype,"_worldRight",void 0),us([uc],uV.prototype,"_worldUp",void 0),us([uc],uV.prototype,"_isParentDirty",void 0),us([uc],uV.prototype,"_parentTransformCache",void 0),us([uc],uV.prototype,"_updateFlagManager",void 0),us([uc],uV.prototype,"_onPositionChanged",null),us([uc],uV.prototype,"_onWorldPositionChanged",null),us([uc],uV.prototype,"_onRotationChanged",null),us([uc],uV.prototype,"_onWorldRotationChanged",null),us([uc],uV.prototype,"_onRotationQuaternionChanged",null),us([uc],uV.prototype,"_onWorldRotationQuaternionChanged",null),us([uc],uV.prototype,"_onScaleChanged",null),(ex=cr||(cr={}))[ex.LocalEuler=1]="LocalEuler",ex[ex.LocalQuat=2]="LocalQuat",ex[ex.WorldPosition=4]="WorldPosition",ex[ex.WorldEuler=8]="WorldEuler",ex[ex.WorldQuat=16]="WorldQuat",ex[ex.WorldScale=32]="WorldScale",ex[ex.LocalMatrix=64]="LocalMatrix",ex[ex.WorldMatrix=128]="WorldMatrix",ex[ex.WmWp=132]="WmWp",ex[ex.WmWeWq=152]="WmWeWq",ex[ex.WmWpWeWq=156]="WmWpWeWq",ex[ex.WmWs=160]="WmWs",ex[ex.WmWpWs=164]="WmWpWs",ex[ex.WmWpWeWqWs=188]="WmWpWeWqWs",e.BlendFactor=void 0,(eb=e.BlendFactor||(e.BlendFactor={}))[eb.Zero=0]="Zero",eb[eb.One=1]="One",eb[eb.SourceColor=2]="SourceColor",eb[eb.OneMinusSourceColor=3]="OneMinusSourceColor",eb[eb.DestinationColor=4]="DestinationColor",eb[eb.OneMinusDestinationColor=5]="OneMinusDestinationColor",eb[eb.SourceAlpha=6]="SourceAlpha",eb[eb.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eb[eb.DestinationAlpha=8]="DestinationAlpha",eb[eb.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eb[eb.SourceAlphaSaturate=10]="SourceAlphaSaturate",eb[eb.BlendColor=11]="BlendColor",eb[eb.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eT=e.BlendOperation||(e.BlendOperation={}))[eT.Add=0]="Add",eT[eT.Subtract=1]="Subtract",eT[eT.ReverseSubtract=2]="ReverseSubtract",eT[eT.Min=3]="Min",eT[eT.Max=4]="Max",e.ColorWriteMask=void 0,(eC=e.ColorWriteMask||(e.ColorWriteMask={}))[eC.None=0]="None",eC[eC.Red=1]="Red",eC[eC.Green=2]="Green",eC[eC.Blue=4]="Blue",eC[eC.Alpha=8]="Alpha",eC[eC.All=15]="All",e.CompareFunction=void 0,(eS=e.CompareFunction||(e.CompareFunction={}))[eS.Never=0]="Never",eS[eS.Less=1]="Less",eS[eS.Equal=2]="Equal",eS[eS.LessEqual=3]="LessEqual",eS[eS.Greater=4]="Greater",eS[eS.NotEqual=5]="NotEqual",eS[eS.GreaterEqual=6]="GreaterEqual",eS[eS.Always=7]="Always",e.CullMode=void 0,(eA=e.CullMode||(e.CullMode={}))[eA.Off=0]="Off",eA[eA.Front=1]="Front",eA[eA.Back=2]="Back",e.RenderStateDataKey=void 0,(eM=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eM.BlendStateEnabled0=0]="BlendStateEnabled0",eM[eM.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eM[eM.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eM[eM.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eM[eM.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eM[eM.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eM[eM.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eM[eM.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eM[eM.BlendStateBlendColor=8]="BlendStateBlendColor",eM[eM.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eM[eM.DepthStateEnabled=10]="DepthStateEnabled",eM[eM.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eM[eM.DepthStateCompareFunction=12]="DepthStateCompareFunction",eM[eM.StencilStateEnabled=13]="StencilStateEnabled",eM[eM.StencilStateReferenceValue=14]="StencilStateReferenceValue",eM[eM.StencilStateMask=15]="StencilStateMask",eM[eM.StencilStateWriteMask=16]="StencilStateWriteMask",eM[eM.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eM[eM.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eM[eM.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eM[eM.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eM[eM.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eM[eM.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eM[eM.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eM[eM.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eM[eM.RasterStateCullMode=25]="RasterStateCullMode",eM[eM.RasterStateDepthBias=26]="RasterStateDepthBias",eM[eM.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",eM[eM.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(eR=e.RenderQueueType||(e.RenderQueueType={}))[eR.Opaque=0]="Opaque",eR[eR.AlphaTest=1]="AlphaTest",eR[eR.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eE=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eE.Float=0]="Float",eE[eE.Int=1]="Int",eE[eE.Vector2=2]="Vector2",eE[eE.Vector3=3]="Vector3",eE[eE.Vector4=4]="Vector4",eE[eE.Matrix=5]="Matrix",eE[eE.Color=6]="Color",eE[eE.Texture=7]="Texture",eE[eE.FloatArray=8]="FloatArray",eE[eE.IntArray=9]="IntArray",eE[eE.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(ew=e.StencilOperation||(e.StencilOperation={}))[ew.Keep=0]="Keep",ew[ew.Zero=1]="Zero",ew[ew.Replace=2]="Replace",ew[ew.IncrementSaturate=3]="IncrementSaturate",ew[ew.DecrementSaturate=4]="DecrementSaturate",ew[ew.Invert=5]="Invert",ew[ew.IncrementWrap=6]="IncrementWrap",ew[ew.DecrementWrap=7]="DecrementWrap",e.ShaderPlatformTarget=void 0,(eP=e.ShaderPlatformTarget||(e.ShaderPlatformTarget={}))[eP.GLES100=0]="GLES100",eP[eP.GLES300=1]="GLES300";var uz=function(){function e(t,r,n,a){this.name=t,this._maskIndex=n,this._maskValue=a,this.value=r;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,a=e._macroMap[n];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,r,s,1<<l),e._macroMap[n]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=a,e._macroCounter++}return a},e._getMacrosElements=function(t,r){var n=e._macroMaskMap,a=t._mask;r.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=n[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&r.push(s[u])},e}();uz._macroMaskMap=[],uz._macroNameIdMap=Object.create(null),uz._macroNameCounter=0,uz._macroCounter=0,uz._macroMap=Object.create(null);var uU=((eL=(eF=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,a=this._length;if(a<r){for(n.length<r&&(n.length=r);a<t;a++)n[a]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},eL.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var a=r[t]&~e._maskValue;t==n&&0===a?this._length--:r[t]=a}},eL.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,a=this._length;if(a<r){n.length<r&&(n.length=r);for(var i=0;i<a;i++)n[i]|=t[i];for(;i<r;i++)n[i]=t[i];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},eL.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,a=Math.min(e._length-1,n);a>=0;a--){var i=r[a]&~t[a];a==n&&0===i?(n--,this._length--):r[a]=i}},eL.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var a=r[n]&t[n];0==a&&n==this._length-1?this._length--:r[n]=a}},eL.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},eL.clear=function(){this._length=0},eF.unionCollection=function(e,t,r){var n,a,i,o,s=r._mask;e._length<t._length?(n=e._length,a=t._length,i=e._mask,o=t._mask):(n=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<n;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];r._length=a},eF);function uG(){return(uG=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,(eB=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",eB.ShadowCaster="ShadowCaster",eB.Forward="Forward";var uH=uG({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){linearIn=max(linearIn,0.0);return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\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(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge)evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=alphaKeys[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"}),uW=((eD=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},eD.registerInclude=function(e,t){if(uH[e])throw'The "'+e+'" shader include already exist';uH[e]=t},eD.unRegisterInclude=function(e){delete uH[e]},eD.parseIncludes=function(e,t){return void 0===t&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm),e.replace(t,function(e,r){var n=uH[r];return void 0===n?(uP.error('Shader slice "'+e.trim()+'" not founded.'),""):eD.parseIncludes(n,t)})},eD.convertTo300=function(e,t){if(e=(e=(e=e.replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),t){if(e=(e=(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!eD._has300Output(e)){if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,r)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else e=e.replace(/\battribute\b/g,"in");return e},eD._has300Output=function(e){return eD._has300OutInFragReg.test(e)},eD._replaceMRTShader=function(e,t){for(var r="",n=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);n.add(i[1])}return n.forEach(function(e){r+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),r+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},eD);uW._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),uW._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var uj=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}();uj._nameCounter=0,uj._nameMap=Object.create(null);var uK=((eO=(eI=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?uj.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&uP.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},eO.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?uj.getByName(e):e)._uniqueId]},eO.getTagValue=function(e){return this._tagsMap["string"==typeof e?uj.getByName(e)._uniqueId:e._uniqueId]},ua(eI,[{key:"name",get:function(){return this._name}}]),eI);e.ColorSpace=void 0,(eV=e.ColorSpace||(e.ColorSpace={}))[eV.Linear=0]="Linear",eV[eV.Gamma=1]="Gamma";var uX=((ek=(eN=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)},ek.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},ek.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,c6.gammaToLinearSpace(r.r),c6.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)},ek.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},ek.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,c6.gammaToLinearSpace(r.r),c6.gammaToLinearSpace(r.g),c6.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)},ek.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},ek.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,c6.gammaToLinearSpace(r.r),c6.gammaToLinearSpace(r.g),c6.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)},ek.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},ek.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},ek.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},ek.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)},ek.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},ek.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)},ek.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},ek.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)},ek.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},ek.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},ek.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},ek.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},ek.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,a=0;a<t.length;a++){var i=t[a];r.activeTexture(n[a]),r.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},eN),uY=function(){this.constUniforms=[],this.textureUniforms=[]};(ez=cn||(cn={}))[ez.Scene=0]="Scene",ez[ez.Camera=1]="Camera",ez[ez.Renderer=2]="Renderer",ez[ez.Material=3]="Material",ez[ez.RenderElement=4]="RenderElement";var uq=function(){function e(t,r,n){this.sceneUniformBlock=new uY,this.cameraUniformBlock=new uY,this.rendererUniformBlock=new uY,this.materialUniformBlock=new uY,this.renderElementUniformBlock=new uY,this.otherUniformBlock=new uY,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(r,n),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var r=t._propertyValueMap,n=e.constUniforms,a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var r=t._propertyValueMap,n=e.textureUniforms;if(n)for(var a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,r=e.length;t<r;t++){var n=e[t];n.applyFunc(n,n.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,r=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r],a=uF._getShaderPropertyGroup(n.name);void 0!==a&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,a,t))}},t._groupingUniform=function(e,t,r){switch(t){case cn.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case cn.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case cn.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case cn.Material:r?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case cn.RenderElement:r?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:r?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var r=this._gl,n=this._createShader(r.VERTEX_SHADER,e);if(!n)return null;var a=this._createShader(r.FRAGMENT_SHADER,t);if(!a)return null;var i=r.createProgram();return i?(r.attachShader(i,n),r.attachShader(i,a),r.linkProgram(i),r.validateProgram(i),r.deleteShader(n),r.deleteShader(a),!uP.isEnabled||r.getProgramParameter(i,r.LINK_STATUS)||r.isContextLost())?i:(uP.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(i,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(i)),r.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,a=n.createShader(t);return a?(n.shaderSource(a,r),n.compileShader(a),!uP.isEnabled||n.getShaderParameter(a,n.COMPILE_STATUS)||n.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;n.forEach(function(n){var a,o=n.name,s=n.size,l=n.type,c=new uX(e._engine),u=!1,d=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),u=!0);var h=t.getUniformLocation(r,o);switch(c.name=o,c.propertyId=uF.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:u?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:u?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new c5(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new cQ(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new c9(0,0,0,0));break;case t.BOOL:case t.INT:u?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:u?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new c5(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new cQ(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new c9(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=u?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(d=!0,u){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=uF._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),a.forEach(function(n){var a=n.name;e.attributeLocation[a]=t.getAttribLocation(r,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),a=0;a<r;++a){var i=e.getActiveUniform(t,a);n[a]=i}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<n;++a){var i=e.getActiveAttrib(t,a);r[a]=i}return r},e._addLineNum=function(e){var t,r=e.split("\n"),n=(r.length+1).toString().length+6;return r.map(function(e,r){if((t="0:"+(r+1)).length>=n)return t.substring(0,n)+e;for(var a=0;a<n-t.length;a++)t+=" ";return t+e}).join("\n")},ua(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();uq._counter=0,(eU=ca||(ca={}))[eU.Canonical=0]="Canonical",eU[eU.ShaderLab=1]="ShaderLab";var uQ=function(t){function r(n,a,i,o,s){var l;for(var c in(l=t.call(this)||this)._shaderPassId=0,l._renderStateDataMap={},l._shaderProgramPools=[],l._path="",l._platformMacros=[],l._shaderPassId=r._shaderPassCounter++,l._type=ca.Canonical,"string"==typeof o?(l._name=n,l._shaderLabSource=a,l._vertexEntry=i,l._fragmentEntry=o,s=uG({pipelineStage:e.PipelineStage.Forward},s),l._type=ca.ShaderLab):"string"==typeof i?(l._name=n,l._vertexSource=a,l._fragmentSource=i,s=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(l._name="Default",l._vertexSource=n,l._fragmentSource=a,s=null!=i?i:{pipelineStage:e.PipelineStage.Forward}),s)l.setTag(c,s[c]);return l}uo(r,t);var n=r.prototype;return n._getShaderProgram=function(e,t){var r=e._getShaderProgramPool(this),n=r.get(t);return n||(n=this._type===ca.Canonical?this._getCanonicalShaderProgram(e,t):this._compileShaderProgram(e,t,this._vertexEntry,this._fragmentEntry),r.cache(n)),n},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,r=e.length;t<r;t++)e[t]._destroy();e.length=0},n._compileShaderProgram=function(t,n,a,i){var o=this._path,s=this._platformMacros,l=t._hardwareRenderer.isWebGL2,c=[];uz._getMacrosElements(n,c),s.length=0,t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&s.push("HAS_TEX_LOD"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&s.push("HAS_DERIVATIVES"),l?s.push("GRAPHICS_API_WEBGL2"):s.push("GRAPHICS_API_WEBGL1");var u=performance.now(),d=u4._shaderLab._parseShaderPass(this._shaderLabSource,a,i,c,l?e.ShaderPlatformTarget.GLES300:e.ShaderPlatformTarget.GLES100,s,new URL(o,r._shaderRootPath).href),h=d.vertex,_=d.fragment;return uP.info("[ShaderLab compilation] cost time: "+(performance.now()-u)+"ms"),new uq(t,h,_)},n._getCanonicalShaderProgram=function(t,r){var n=t._hardwareRenderer.isWebGL2,a=[];uz._getMacrosElements(r,a);var i=uW.parseCustomMacros(a),o=n?"#version 300 es":"#version 100",s=n?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",l="\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)&&(l+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(l+="#define HAS_DERIVATIVES\n");var c=" "+o+"\n "+s+"\n "+i+"\n "+uW.parseIncludes(this._vertexSource),u=" "+o+"\n "+s+"\n "+(n?"":uW._shaderExtension)+"\n "+l+"\n "+i+"\n "+uW.parseIncludes(this._fragmentSource);return n&&(c=uW.convertTo300(c),u=uW.convertTo300(u,!0)),new uq(t,c,u)},r}(uK);uQ._shaderPassCounter=0,uQ._shaderRootPath="shaders://root/";var uZ=(uo(eG=function(e,t,r){var n;if((n=uK.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var a in n._passes=t.slice(),r)n.setTag(a,r[a]);return n},uK),ua(eG,[{key:"passes",get:function(){return this._passes}}]),eG),uJ=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},u$=((eW=(eH=function(){this.targetBlendState=new uJ,this.blendColor=new c6(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,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!=(a=r.getFloat(f))?a:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(u.sourceColorBlendFactor=null!=(i=r.getFloat(p))?i: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 b=r.getColor(x);void 0!==b&&this.blendColor.copyFrom(b)}var T=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==T){var C=r.getFloat(T);this.alphaToCoverage=void 0!==C&&!!C}},eW._apply=function(e,t){this._platformApply(e,t.blendState)},eW._platformApply=function(t,r){var n=t.gl,a=r.targetBlendState,i=this.targetBlendState,o=i.enabled,s=i.colorBlendOperation,l=i.alphaBlendOperation,c=i.sourceColorBlendFactor,u=i.destinationColorBlendFactor,d=i.sourceAlphaBlendFactor,h=i.destinationAlphaBlendFactor,_=i.colorWriteMask;if(o!==a.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),a.enabled=o),o){(c!==a.sourceColorBlendFactor||u!==a.destinationColorBlendFactor||d!==a.sourceAlphaBlendFactor||h!==a.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(eH._getGLBlendFactor(t,c),eH._getGLBlendFactor(t,u),eH._getGLBlendFactor(t,d),eH._getGLBlendFactor(t,h)),a.sourceColorBlendFactor=c,a.destinationColorBlendFactor=u,a.sourceAlphaBlendFactor=d,a.destinationAlphaBlendFactor=h),(s!==a.colorBlendOperation||l!==a.alphaBlendOperation)&&(n.blendEquationSeparate(eH._getGLBlendOperation(t,s),eH._getGLBlendOperation(t,l)),a.colorBlendOperation=s,a.alphaBlendOperation=l);var f=this.blendColor;c6.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==a.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),a.colorWriteMask=_);var p=this.alphaToCoverage;p!==r.alphaToCoverage&&(p?n.enable(n.SAMPLE_ALPHA_TO_COVERAGE):n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),r.alphaToCoverage=p)},eH._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}},eH._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}},eH);us([uh],u$.prototype,"targetBlendState",void 0),us([uh],u$.prototype,"blendColor",void 0);var u0=((eK=(ej=function(){this.enabled=!0,this.compareFunction=e.CompareFunction.Less,this.writeEnabled=!0}).prototype)._applyShaderDataValue=function(t,r){var n,a=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==a){var i=r.getFloat(a);this.enabled=void 0!==i&&!!i}var o=t[e.RenderStateDataKey.DepthStateWriteEnabled];if(void 0!==o){var s=r.getFloat(o);this.writeEnabled=void 0!==s&&!!s}var l=t[e.RenderStateDataKey.DepthStateCompareFunction];void 0!==l&&(this.compareFunction=null!=(n=r.getFloat(l))?n:e.CompareFunction.Less)},eK._apply=function(e,t){this._platformApply(e,t.depthState)},eK._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.compareFunction,i=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&a!=t.compareFunction&&(r.depthFunc(ej._getGLCompareFunction(e,a)),t.compareFunction=a),i!=t.writeEnabled&&(r.depthMask(i),t.writeEnabled=i)},ej._getGLCompareFunction=function(t,r){var n=t.gl;switch(r){case e.CompareFunction.Never:return n.NEVER;case e.CompareFunction.Less:return n.LESS;case e.CompareFunction.Equal:return n.EQUAL;case e.CompareFunction.LessEqual:return n.LEQUAL;case e.CompareFunction.Greater:return n.GREATER;case e.CompareFunction.NotEqual:return n.NOTEQUAL;case e.CompareFunction.GreaterEqual:return n.GEQUAL;case e.CompareFunction.Always:return n.ALWAYS}},ej),u1=((eY=(eX=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o=t[e.RenderStateDataKey.RasterStateCullMode];void 0!==o&&(this.cullMode=null!=(n=r.getFloat(o))?n:e.CullMode.Back);var s=t[e.RenderStateDataKey.RasterStateDepthBias];void 0!==s&&(this.depthBias=null!=(a=r.getFloat(s))?a:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(i=r.getFloat(l))?i:0)},eY._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},eY._platformApply=function(t,r,n){var a=t.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=i!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),r._cullFaceEnable=l),l&&i!==r.cullMode&&(i==e.CullMode.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),r.cullMode=i),n!==r._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},eX),u2=((eQ=(eq=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,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!=(a=r.getFloat(g))?a:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(i=r.getFloat(v))?i:255);var y=t[e.RenderStateDataKey.StencilStateCompareFunctionFront];void 0!==y&&(this.compareFunctionFront=null!=(o=r.getFloat(y))?o:e.CompareFunction.Always);var x=t[e.RenderStateDataKey.StencilStateCompareFunctionBack];void 0!==x&&(this.compareFunctionBack=null!=(s=r.getFloat(x))?s:e.CompareFunction.Always);var b=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==b&&(this.passOperationFront=null!=(l=r.getFloat(b))?l:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==T&&(this.passOperationBack=null!=(c=r.getFloat(T))?c:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(u=r.getFloat(C))?u:e.StencilOperation.Keep);var S=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(d=r.getFloat(S))?d:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==A&&(this.zFailOperationFront=null!=(h=r.getFloat(A))?h:e.StencilOperation.Keep);var M=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==M&&(this.zFailOperationBack=null!=(_=r.getFloat(M))?_:e.StencilOperation.Keep)},eQ._apply=function(e,t){this._platformApply(e,t.stencilState)},eQ._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.referenceValue,i=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,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=a!==t.referenceValue||i!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,eq._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,eq._getGLCompareFunction(e,s),a,i),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,eq._getGLStencilOperation(e,l),eq._getGLStencilOperation(e,c),eq._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(d!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,eq._getGLStencilOperation(e,d),eq._getGLStencilOperation(e,h),eq._getGLStencilOperation(e,_)),t.failOperationBack=d,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},eq._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}},eq._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}},eq),u3=((eJ=(eZ=function(){this.blendState=new u$,this.depthState=new u0,this.stencilState=new u2,this.rasterState=new u1,this.renderQueueType=e.RenderQueueType.Opaque}).prototype)._applyStates=function(e,t,r,n){r&&this._applyStatesByShaderData(r,n);var a=e._hardwareRenderer,i=e._lastRenderState,o=e._renderContext;this.blendState._apply(a,i),this.depthState._apply(a,i),this.stencilState._apply(a,i),this.rasterState._apply(a,i,o.flipProjection?!t:t)},eJ._applyRenderQueueByShaderData=function(t,r){var n,a=t[e.RenderStateDataKey.RenderQueueType];void 0!==a&&(this.renderQueueType=null!=(n=r.getFloat(a))?n:e.RenderQueueType.Opaque)},eJ._applyStatesByShaderData=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},eZ);us([uh],u3.prototype,"blendState",void 0),us([uh],u3.prototype,"depthState",void 0),us([uh],u3.prototype,"stencilState",void 0),us([uh],u3.prototype,"rasterState",void 0);var u4=((e0=(e$=function(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}).prototype)._registerPath=function(e){for(var t,r=uk(this._subShaders);!(t=r()).done;)for(var n,a=t.value,i=uk(a.passes);!(n=i()).done;)n.value._path=e},e0.compileVariant=function(e,t){var r=e$._compileMacros;r.clear();for(var n=0,a=t.length;n<a;n++)r.enable(uz.getByName(t[n]));for(var i=!1,o=this._subShaders,s=0,l=o.length;s<l;s++)for(var c=o[s].passes,u=0,d=c.length;u<d;u++){var h=c[u]._getShaderProgram(e,r);i=0===u?h.isValid:i&&h.isValid}return i},e0.destroy=function(e){if(void 0===e&&(e=!1),!e&&0!==this._refCount)return!1;for(var t=this._subShaders,r=0,n=t.length;r<n;r++)for(var a=t[r].passes,i=0,o=a.length;i<o;i++)a[i]._destroy();return delete e$._shaderMap[this.name],this._destroyed=!0,!0},e0._getReferCount=function(){return this._refCount},e0._addReferCount=function(e){this._refCount+=e},e$.create=function(e,t,r){var n,a=e$._shaderMap;if(t){if(a[e]){console.error('Shader named "'+e+'" already exists.');return}if("string"==typeof t){var i=new uQ(t,r);n=new e$(e,[new uZ("Default",[i])])}else if(t.length>0)n=t[0].constructor===uQ?new e$(e,[new uZ("Default",t)]):new e$(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!e$._shaderLab)throw"ShaderLab has not been set up yet.";var o=e$._shaderLab._parseShaderContent(e);if(a[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(e){var t=e.passes.map(function(e){if(e.isUsePass){var t,r,n=e.name.split("/");return null==(r=e$.find(n[0]))?void 0:null==(t=r.subShaders.find(function(e){return e.name===n[1]}))?void 0:t.passes.find(function(e){return e.name===n[2]})}var a=new uQ(e.name,e.contents,e.vertexEntry,e.fragmentEntry,e.tags),i=e.renderStates,o=new u3;a._renderState=o;var s=i.constantMap,l=i.variableMap;for(var c in s)e$._applyConstRenderStates(o,parseInt(c),s[c]);var u={};for(var d in l)u[d]=uF.getByName(l[d]);return a._renderStateDataMap=u,a});return new uZ(e.name,t,e.tags)});return n=new e$(o.name,s),a[o.name]=n,n}return a[e]=n,n},e$.find=function(e){return e$._shaderMap[e]},e$._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}},e$.getMacroByName=function(e,t){return uz.getByName(e,t)},e$.getPropertyByName=function(e){return uF.getByName(e)},ua(e$,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e$);u4._compileMacros=new uU,u4._shaderMap=Object.create(null);var u8=(uo(e1=function(e){var t;return(t=up.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(ur(t)),t},up),e1.prototype._onDestroy=function(){up.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},ua(e1,[{key:"isContentLost",get:function(){return this._isContentLost}}]),e1);e.TextureFilterMode=void 0,(e2=e.TextureFilterMode||(e.TextureFilterMode={}))[e2.Point=0]="Point",e2[e2.Bilinear=1]="Bilinear",e2[e2.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(e3=e.TextureFormat||(e.TextureFormat={}))[e3.R8G8B8=0]="R8G8B8",e3[e3.R8G8B8A8=1]="R8G8B8A8",e3[e3.R4G4B4A4=2]="R4G4B4A4",e3[e3.R5G5B5A1=3]="R5G5B5A1",e3[e3.R5G6B5=4]="R5G6B5",e3[e3.Alpha8=5]="Alpha8",e3[e3.LuminanceAlpha=6]="LuminanceAlpha",e3[e3.R16G16B16A16=7]="R16G16B16A16",e3[e3.R32G32B32A32=8]="R32G32B32A32",e3[e3.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",e3[e3.R11G11B10_UFloat=35]="R11G11B10_UFloat",e3[e3.BC1=10]="BC1",e3[e3.BC3=11]="BC3",e3[e3.BC7=12]="BC7",e3[e3.ETC1_RGB=13]="ETC1_RGB",e3[e3.ETC2_RGB=14]="ETC2_RGB",e3[e3.ETC2_RGBA5=15]="ETC2_RGBA5",e3[e3.ETC2_RGBA8=16]="ETC2_RGBA8",e3[e3.PVRTC_RGB2=17]="PVRTC_RGB2",e3[e3.PVRTC_RGBA2=18]="PVRTC_RGBA2",e3[e3.PVRTC_RGB4=19]="PVRTC_RGB4",e3[e3.PVRTC_RGBA4=20]="PVRTC_RGBA4",e3[e3.ASTC_4x4=21]="ASTC_4x4",e3[e3.ASTC_5x5=22]="ASTC_5x5",e3[e3.ASTC_6x6=23]="ASTC_6x6",e3[e3.ASTC_8x8=24]="ASTC_8x8",e3[e3.ASTC_10x10=25]="ASTC_10x10",e3[e3.ASTC_12x12=26]="ASTC_12x12",e3[e3.Depth=27]="Depth",e3[e3.Stencil=28]="Stencil",e3[e3.DepthStencil=29]="DepthStencil",e3[e3.Depth16=30]="Depth16",e3[e3.Depth24=31]="Depth24",e3[e3.Depth32=32]="Depth32",e3[e3.Depth24Stencil8=33]="Depth24Stencil8",e3[e3.Depth32Stencil8=34]="Depth32Stencil8",e3[e3.DXT1=10]="DXT1",e3[e3.DXT5=11]="DXT5";var u5=(uo(e4=function(){var e;return e=u8.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},u8),(e8=e4.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},e8._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},e8._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))},e8._onDestroy=function(){u8.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},e8._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},e8._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},e8._isIntFormat=function(){return e.TextureFormat.R32G32B32A32_UInt===this._format},ua(e4,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(t){if(t!==this._filterMode){if(t!==e.TextureFilterMode.Point&&this._isIntFormat()){t=e.TextureFilterMode.Point,uP.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=t,this._platformTexture.filterMode=t}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(uP.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(uP.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)}}]),e4),u9=((e9=(e5=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new uU,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},e9.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},e9.getInt=function(e){return this.getPropertyValue(e)},e9.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},e9.getFloatArray=function(e){return this.getPropertyValue(e)},e9.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},e9.getIntArray=function(e){return this.getPropertyValue(e)},e9.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},e9.getVector2=function(e){return this.getPropertyValue(e)},e9.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},e9.getVector3=function(e){return this.getPropertyValue(e)},e9.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},e9.getVector4=function(e){return this.getPropertyValue(e)},e9.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},e9.getMatrix=function(e){return this.getPropertyValue(e)},e9.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},e9.getColor=function(e){return this.getPropertyValue(e)},e9.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},e9.getTexture=function(e){return this.getPropertyValue(e)},e9.setTexture=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},e9.getTextureArray=function(e){return this.getPropertyValue(e)},e9.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);if(a)for(var i=0,o=a.length;i<o;i++)a[i]._addReferCount(-n);if(r)for(var s=0,l=r.length;s<l;s++)r[s]._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,r)},e9.getPropertyValue=function(e){return"string"==typeof e&&(e=uF.getByName(e)),this._propertyValueMap[e._uniqueId]},e9.enableMacro=function(e,t){"string"==typeof e&&(e=uz.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var a=this._macroCollection;n&&a.disable(n),a.enable(e),this._macroMap[r]=e}},e9.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=uz._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},e9.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])},e9.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=uF._propertyIdMap;for(var a in r)t.push(n[a]);if(!e)return t},e9.clone=function(){var e=new e5(this._group);return this.cloneTo(e),e},e9.cloneTo=function(e){u_.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,a=Object.keys(r),i=0,o=a.length;i<o;i++){var s=a[i],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(ul(l,u5))n[s]=l,t>0&&l._addReferCount(t);else if(ul(l,Array)||ul(l,Float32Array)||ul(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},e9._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=uF.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 "+cn[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},e9._getReferCount=function(){return this._refCount},e9._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&ul(n,u5)&&n._addReferCount(e)}},e5);function u6(){return function(e){}}us([uc],u9.prototype,"_group",void 0),us([uc],u9.prototype,"_propertyValueMap",void 0),us([uc],u9.prototype,"_macroCollection",void 0),us([uc],u9.prototype,"_macroMap",void 0),us([uc],u9.prototype,"_refCount",void 0),e.Renderer=(uo(e6=function(t){(r=uB.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new uU,r._bounds=new cJ,r._maskInteraction=e.SpriteMaskInteraction.None,r._maskLayer=e.SpriteMaskLayer.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new c9,r._shaderData=new u9(cn.Renderer),r._mvMatrix=new c4,r._mvpMatrix=new c4,r._mvInvMatrix=new c4,r._normalMatrix=new c4,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,n=e.Renderer.prototype,a=r.shaderData;return r._overrideUpdate=r.update!==n.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(ur(r)),r._registerEntityTransformListener(),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},uB),(e7=e6.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},e7.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},e7.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},e7.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},e7.getMaterials=function(){return this._materials},e7.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,a=t,i=r.length;a<i;a++){var o=r[a];o&&this._addResourceReferCount(o,-1)}r.length!==t&&(r.length=t),0!==n.length&&(n.length=0);for(var s=0;s<t;s++){var l=r[s],c=e[s];l!==c&&(r[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},e7.update=function(e){},e7._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},e7._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},e7._prepareRender=function(t){this._renderFrameCount!==this.engine.time.frameCount&&this._update(t);var r=t.virtualCamera,n=r.position,a=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(cQ.subtract(a,n,a),this._distanceForSort=cQ.dot(a,r.forward)):this._distanceForSort=cQ.distanceSquared(a,n),this._render(t),uU.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},e7._cloneTo=function(e,t,r){for(var n=this._materials,a=0,i=n.length;a<i;a++)e._setMaterial(a,n[a])},e7._onDestroy=function(){uB.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this._addResourceReferCount(this.shaderData,-1);for(var e=this._materials,t=0,r=e.length;t<r;t++){var n=e[t];n&&this._addResourceReferCount(n,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},e7._updateTransformShaderData=function(e,t,r){var n=this.entity.transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,n,r):this._updateWorldViewRelatedShaderData(e,n,r)},e7._canBatch=function(e,t){return!1},e7._batch=function(e,t){},e7._update=function(e){var t=this.entity.layer;this._rendererLayer.set(65535&t,t>>>16&65535,0,0)},e7._updateWorldViewRelatedShaderData=function(t,r,n){var a=this.shaderData,i=this._mvInvMatrix;if(n){var o=c4._identity;c4.invert(t.viewMatrix,i),a.setMatrix(e.Renderer._localMatrixProperty,o),a.setMatrix(e.Renderer._worldMatrixProperty,o),a.setMatrix(e.Renderer._mvMatrixProperty,t.viewMatrix),a.setMatrix(e.Renderer._mvInvMatrixProperty,i),a.setMatrix(e.Renderer._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;c4.multiply(t.viewMatrix,r,s),c4.invert(s,i),c4.invert(r,l),l.transpose(),a.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),a.setMatrix(e.Renderer._worldMatrixProperty,r),a.setMatrix(e.Renderer._mvMatrixProperty,s),a.setMatrix(e.Renderer._mvInvMatrixProperty,i),a.setMatrix(e.Renderer._normalMatrixProperty,l)}this._updateProjectionRelatedShaderData(t,r,n)},e7._updateProjectionRelatedShaderData=function(t,r,n){if(n)this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,t.viewProjectionMatrix);else{var a=this._mvpMatrix;c4.multiply(t.viewProjectionMatrix,r,a),this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,a)}},e7._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},e7._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},e7._updateBounds=function(e){},e7._render=function(e){throw"not implement"},e7._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(r,1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},e7._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),n&&this._addResourceReferCount(n,-1),t&&this._addResourceReferCount(t,1),r[e]=t}},e7._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},ua(e6,[{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}}]),e6._tempVector0=new cQ,e6._receiveShadowMacro=uz.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e6._localMatrixProperty=uF.getByName("renderer_LocalMat"),e6._worldMatrixProperty=uF.getByName("renderer_ModelMat"),e6._mvMatrixProperty=uF.getByName("renderer_MVMat"),e6._mvpMatrixProperty=uF.getByName("renderer_MVPMat"),e6._mvInvMatrixProperty=uF.getByName("renderer_MVInvMat"),e6._normalMatrixProperty=uF.getByName("renderer_NormalMat"),e6._rendererLayerProperty=uF.getByName("renderer_Layer"),e6),us([uc],e.Renderer.prototype,"_distanceForSort",void 0),us([uc],e.Renderer.prototype,"_onUpdateIndex",void 0),us([uc],e.Renderer.prototype,"_rendererIndex",void 0),us([uc],e.Renderer.prototype,"_globalShaderMacro",void 0),us([uc],e.Renderer.prototype,"_bounds",void 0),us([uc],e.Renderer.prototype,"_renderFrameCount",void 0),us([uu],e.Renderer.prototype,"_maskInteraction",void 0),us([uu],e.Renderer.prototype,"_maskLayer",void 0),us([uc],e.Renderer.prototype,"_batchedTransformShaderData",void 0),us([uc],e.Renderer.prototype,"_overrideUpdate",void 0),us([uc],e.Renderer.prototype,"_materials",void 0),us([uc],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),us([uc],e.Renderer.prototype,"_rendererLayer",void 0),us([uh],e.Renderer.prototype,"_shaderData",void 0),us([uc],e.Renderer.prototype,"_mvMatrix",void 0),us([uc],e.Renderer.prototype,"_mvpMatrix",void 0),us([uc],e.Renderer.prototype,"_mvInvMatrix",void 0),us([uc],e.Renderer.prototype,"_normalMatrix",void 0),us([uc],e.Renderer.prototype,"_materialsInstanced",void 0),us([uu],e.Renderer.prototype,"_priority",void 0),us([uu],e.Renderer.prototype,"_receiveShadows",void 0),us([uc],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=us([uI(uV,e.DependentMode.CheckOnly)],e.Renderer),(te=ci||(ci={}))[te.WorldVolume=1]="WorldVolume";var u7=((tt=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(4);n.indices=u7._rectangleTriangles,e._subChunk=n},tt.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,a=n.pivot,i=a.x,o=a.y,s=u7._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]-i*l[0]-o*l[4],l[13]=c[13]-i*l[1]-o*l[5],l[14]=c[14]-i*l[2]-o*l[6];for(var h=n._getPositions(),_=e._subChunk,f=_.chunk.vertices,p=0,m=_.vertexArea.start;p<4;++p,m+=9){var g=h[p],v=g.x,y=g.y;f[m]=l[0]*v+l[4]*y+l[12],f[m+1]=l[1]*v+l[5]*y+l[13],f[m+2]=l[2]*v+l[6]*y+l[14]}cJ.transform(n._getBounds(),s,e._bounds)},tt.updateUVs=function(e){var t=e.sprite._getUVs(),r=t[0],n=r.x,a=r.y,i=t[3],o=i.x,s=i.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=n,c[u+1]=a,c[u+9]=o,c[u+10]=a,c[u+18]=n,c[u+19]=s,c[u+27]=o,c[u+28]=s},tt.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<4;++l,c+=9)s[c]=n,s[c+1]=a,s[c+2]=i,s[c+3]=o},tt._rectangleTriangles=[0,1,2,2,1,3],tt._worldMatrix=new c4,tt);u7=us([u6()],u7);var de=((tr=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(16);n.indices=de._rectangleTriangles,e._subChunk=n},tr.updatePositions=function(e){var t,r,n=e.width,a=e.height,i=e.sprite,o=i.border,s=i._getPositions(),l=s[0],c=l.x,u=l.y,d=s[3],h=d.x,_=d.y,f=i.width,p=i.height,m=f*o.x,g=p*o.y,v=f*o.z,y=p*o.w;if(m+v>n){var x=n/(m+v);t=[f*c*x,m*x,m*x,n-f*(1-h)*x]}else t=[f*c,m,n-v,n-f*(1-h)];if(y+g>a){var b=a/(y+g);r=[p*u*b,g*b,g*b,a-p*(1-_)*b]}else r=[p*u,g,a-y,a-p*(1-_)];var T=e.sprite.pivot,C=T.x,S=T.y,A=e.width*C,M=e.height*S,R=de._worldMatrix,E=R.elements,w=e.entity.transform.worldMatrix.elements,P=e.flipX?-1:1,F=e.flipY?-1:1;E[0]=w[0]*P,E[1]=w[1]*P,E[2]=w[2]*P,E[4]=w[4]*F,E[5]=w[5]*F,E[6]=w[6]*F,E[8]=w[8],E[9]=w[9],E[10]=w[10],E[12]=w[12]-A*E[0]-M*E[4],E[13]=w[13]-A*E[1]-M*E[5],E[14]=w[14]-A*E[2]-M*E[6];for(var L=e._subChunk,B=L.chunk.vertices,D=0,I=L.vertexArea.start;D<4;D++)for(var O=t[D],V=0;V<4;V++,I+=9){var N=r[V];B[I]=E[0]*O+E[4]*N+E[12],B[I+1]=E[1]*O+E[5]*N+E[13],B[I+2]=E[2]*O+E[6]*N+E[14]}var k=e._bounds,z=k.min,U=k.max;z.set(t[0],r[0],0),U.set(t[3],r[3],0),e._bounds.transform(R)},tr.updateUVs=function(e){for(var t=e._subChunk,r=t.chunk.vertices,n=e.sprite._getUVs(),a=0,i=t.vertexArea.start+3;a<4;a++)for(var o=n[a].x,s=0;s<4;s++,i+=9)r[i]=o,r[i+1]=n[s].y},tr.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<16;++l,c+=9)s[c]=n,s[c+1]=a,s[c+2]=i,s[c+3]=o},tr._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],tr._worldMatrix=new c4,tr);de=us([u6()],de);var dt=((ta=(tn=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++},ta.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ta.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},ta.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ta.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},ta.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0,a=this.length;n<a;n++){var i=r[n];i&&e(i)}this._endLoop(t)},ta.forEachAndClean=function(e,t){this._startLoop();for(var r=this.length,n=this._elements,a=0;a<r;a++){var i=n[a];i&&e(i)}this._endLoopAndClean(r,n,t)},ta.sort=function(e){ug._quickSort(this._elements,0,this.length,e)},ta.garbageCollection=function(){this._elements.length=this.length},ta._startLoop=function(){this._isLooping=!0},ta._endLoop=function(e){if(this._isLooping=!1,this._blankCount){var t=0,r=this.length-1,n=this._elements;e:do{for(;n[t];)if(++t>=r)break e;for(;!n[r];)if(t>=--r)break e;var a=n[r];e(a,t),n[t++]=a,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},ta._endLoopAndClean=function(e,t,r){for(var n=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[n]=o,r(o,n),n++)}this._isLooping=!1,this.length=n,this._blankCount=0},tn),dr=((ti=function(){}).resetData=function(e,t){if(t){var r=e._getChunkManager(),n=e._subChunk,a=n&&n.vertexArea.size!==9*t;if(a&&r.freeSubChunk(n),!n||a){var i=r.allocateSubChunk(t);i.indices=[],e._subChunk=i}}},ti.updatePositions=function(t){var r,n,a,i,o,s,l=t.width,c=t.height,u=t.sprite,d=t.tileMode,h=t.tiledAdaptiveThreshold,_=dr._posRow,f=dr._posColumn,p=dr._uvRow,m=dr._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===e.SpriteTileMode.Adaptive?dr._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):dr._calculateContinuousDividing(u,l,c,_,f,p,m,g);dr.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,T=t.width*x,C=t.height*b,S=dr._worldMatrix,A=S.elements,M=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,E=t.flipY?-1:1;r=A[0]=M[0]*R,n=A[1]=M[1]*R,a=A[2]=M[2]*R,i=A[4]=M[4]*E,o=A[5]=M[5]*E,s=A[6]=M[6]*E,A[8]=M[8],A[9]=M[9],A[10]=M[10];for(var w=A[12]=M[12]-T*A[0]-C*A[4],P=A[13]=M[13]-T*A[1]-C*A[5],F=A[14]=M[14]-T*A[2]-C*A[6],L=_.length-1,B=f.length-1,D=t._subChunk,I=D.chunk.vertices,O=D.indices,V=0,N=0,k=0,z=D.vertexArea.start;k<B;k++)for(var U=2*k,G=0;G<L;G++){var H=p.get(2*G),W=p.get(2*G+1),j=m.get(U+1);if(!(isNaN(H)||isNaN(W)||isNaN(j))){O[N++]=V,O[N++]=V+1,O[N++]=V+2,O[N++]=V+2,O[N++]=V+1,O[N++]=V+3,V+=4;var K=_.get(G),X=f.get(k),Y=_.get(G+1),q=f.get(k+1);I[z]=r*K+i*X+w,I[z+1]=n*K+o*X+P,I[z+2]=a*K+s*X+F,I[z+9]=r*Y+i*X+w,I[z+10]=n*Y+o*X+P,I[z+11]=a*Y+s*X+F,I[z+18]=r*K+i*q+w,I[z+19]=n*K+o*q+P,I[z+20]=a*K+s*q+F,I[z+27]=r*Y+i*q+w,I[z+28]=n*Y+o*q+P,I[z+29]=a*Y+s*q+F,z+=36}}var Q=t._bounds,Z=Q.min,J=Q.max;Z.set(_.get(0),f.get(0),0),J.set(_.get(L),f.get(B),0),t._bounds.transform(S)},ti.updateUVs=function(e){for(var t=dr._posRow,r=dr._posColumn,n=dr._uvRow,a=dr._uvColumn,i=t.length-1,o=r.length-1,s=e._subChunk,l=s.chunk.vertices,c=0,u=s.vertexArea.start+3;c<o;c++)for(var d=2*c,h=0;h<i;h++){var _=n.get(2*h),f=a.get(d),p=n.get(2*h+1),m=a.get(d+1);isNaN(_)||isNaN(f)||isNaN(p)||isNaN(m)||(l[u]=_,l[u+1]=f,l[u+9]=p,l[u+10]=f,l[u+18]=_,l[u+19]=m,l[u+27]=p,l[u+28]=m,u+=36)}},ti.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=t.vertexArea,c=0,u=l.start+5,d=l.size/9;c<d;++c,u+=9)s[u]=n,s[u+1]=a,s[u+2]=i,s[u+3]=o},ti._calculateAdaptiveDividing=function(e,t,r,n,a,i,o,s,l){var c,u,d,h,_,f,p,m=e.border,g=e._getPositions(),v=g[0],y=v.x,x=v.y,b=g[3],T=b.x,C=b.y,S=e._getUVs(),A=S[0],M=S[1],R=S[2],E=S[3],w=e.width,P=e.height,F=w*m.x,L=w*m.z,B=F+L,D=w-B,I=P*m.w,O=P*m.y,V=I+O,N=P-V;B>=t?(h=3,u=0):D>cq.zeroTolerance?(h=4+(f=(f=(t-B)/D)%1>=n?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),V>=r?(_=3,d=0):N>cq.zeroTolerance?(_=4+(p=(p=(r-V)/N)%1>=n?Math.ceil(p):Math.floor(p))-1,d=2):(_=4,d=1);var k=0,z=0;if((h-1)*(_-1)*4>l)return a.add(t*y),a.add(t*T),i.add(r*x),i.add(r*C),o.add(A.x),o.add(E.x),s.add(A.y),s.add(E.y),k+=2,z+=2,uP.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/B,a.add(w*y*c),a.add(F*c),a.add(t-w*(1-T)*c),o.add(A.x),o.add(M.x),o.add(R.x),o.add(E.x),k+=4;break;case 1:a.add(w*y),a.add(F),a.add(t-L),a.add(t-w*(1-T)),o.add(A.x),o.add(M.x),o.add(NaN),o.add(NaN),o.add(R.x),o.add(E.x),k+=4;break;case 2:c=t/(B+f*D),a.add(w*y*c),a.add(F*c),o.add(A.x),o.add(M.x),o.add(M.x),k+=3;for(var U=0,G=f-1;U<G;U++)a.add(F+(U+1)*D*c),o.add(R.x),o.add(M.x),k+=2;a.add(t-L*c),a.add(t-w*(1-T)*c),o.add(R.x),o.add(R.x),o.add(E.x),k+=3}switch(d){case 0:c=r/V,i.add(P*x*c),i.add(O*c),i.add(r-P*(1-C)*c),s.add(A.y),s.add(M.y),s.add(R.y),s.add(E.y),z+=4;break;case 1:i.add(P*x),i.add(O),i.add(r-I),i.add(r-P*(1-C)),s.add(A.y),s.add(M.y),s.add(NaN),s.add(NaN),s.add(R.y),s.add(E.y),z+=4;break;case 2:c=r/(V+p*N),i.add(P*x*c),i.add(O*c),s.add(A.y),s.add(M.y),s.add(M.y),z+=3;for(var H=0,W=p-1;H<W;H++)i.add(O+(H+1)*N*c),s.add(R.y),s.add(M.y),z+=2;i.add(r-I*c),i.add(r-P*(1-C)*c),s.add(R.y),s.add(R.y),s.add(E.y),z+=3}return k*z},ti._calculateContinuousDividing=function(e,t,r,n,a,i,o,s){var l,c,u,d,h,_,f=e.border,p=e._getPositions(),m=p[0],g=m.x,v=m.y,y=p[3],x=y.x,b=y.y,T=e._getUVs(),C=T[0],S=T[1],A=T[2],M=T[3],R=e.width,E=e.height,w=R*f.x,P=R*f.z,F=w+P,L=R-F,B=E*f.w,D=E*f.y,I=B+D,O=E-I;F>=t?(u=3,l=0):L>cq.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=r?(d=3,c=0):O>cq.zeroTolerance?(d=4+(0|(_=(r-I)/O)),c=2):(d=4,c=1);var V=0,N=0;if((u-1)*(d-1)*4>s)return n.add(t*g),n.add(t*x),a.add(r*v),a.add(r*b),i.add(C.x),i.add(M.x),o.add(C.y),o.add(M.y),V+=2,N+=2,uP.warn("The number of vertices exceeds the upper limit("+s+")."),V*N;switch(l){case 0:var k=t/F;n.add(R*g*k),n.add(w*k),n.add(t-R*(1-x)*k),i.add(C.x),i.add(S.x),i.add(A.x),i.add(M.x),V+=4;break;case 1:n.add(R*g),n.add(w),n.add(t-P),n.add(t-R*(1-x)),i.add(C.x),i.add(S.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(M.x),V+=4;break;case 2:n.add(R*g),n.add(w),i.add(C.x),i.add(S.x),i.add(S.x),V+=3;for(var z=0|h,U=0;U<z;U++)n.add(w+(U+1)*L),i.add(A.x),i.add(S.x),V+=2;n.add(t-P),n.add(t-R*(1-x)),i.add((A.x-S.x)*(h-z)+S.x),i.add(A.x),i.add(M.x),V+=3}switch(c){case 0:var G=r/I;a.add(E*v*G),a.add(D*G),a.add(r-E*(1-b)*G),o.add(C.y),o.add(S.y),o.add(A.y),o.add(M.y),N+=4;break;case 1:a.add(E*v),a.add(D),a.add(r-B),a.add(r-E*(1-b)),o.add(C.y),o.add(S.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(M.y),N+=4;break;case 2:a.add(E*v),a.add(D),o.add(C.y),o.add(S.y),o.add(S.y),N+=3;for(var H=0|_,W=0;W<H;W++)a.add(D+(W+1)*O),o.add(A.y),o.add(S.y),N+=2;a.add(r-B),a.add(r-E*(1-b)),o.add((A.y-S.y)*(_-H)+S.y),o.add(A.y),o.add(M.y),N+=3}return V*N},ti._worldMatrix=new c4,ti._posRow=new dt,ti._posColumn=new dt,ti._uvRow=new dt,ti._uvColumn=new dt,ti);dr=us([u6()],dr),(to=co||(co={}))[to.Compressed=0]="Compressed",to[to.WithoutTiled=1]="WithoutTiled",to[to.WithTiled=2]="WithTiled";var dn=(ts=e.Renderer,uo(tl=function(t){var r;return(r=ts.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new c6(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.drawMode=e.SpriteDrawMode.Simple,r._dirtyUpdateFlag|=4,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(ur(r)),r._color._onValueChanged=r._onColorChanged.bind(ur(r)),r},ts),(tc=tl.prototype)._updateTransformShaderData=function(e,t,r){ts.prototype._updateTransformShaderData.call(this,e,t,!0)},tc._cloneTo=function(e,t,r){ts.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},tc._canBatch=function(e,t){return uC.canBatchSprite(e,t)},tc._batch=function(e,t){uC.batchFor2D(e,t)},tc._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},tc._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},tc._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&ci.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~ci.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this),this._dirtyUpdateFlag&=-5);var n=e.camera,a=n.engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get(),s=this._subChunk;o.set(this,r,s.chunk.primitive,s.subMesh,this.sprite.texture,s),i.addSubRenderElement(o),n._renderPipeline.pushRenderElement(e,i)}}},tc._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),ts.prototype._onDestroy.call(this),this._sprite=null,this._assembler=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null)},tc._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-9},tc._updateStencilState=function(t,r){var n=this.getMaterial(),a=this._engine._spriteDefaultMaterials;if(n===a[t])this.setMaterial(a[r]);else{var i=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(i.enabled=!1,i.writeMask=255,i.referenceValue=0,i.compareFunctionFront=i.compareFunctionBack=e.CompareFunction.Always):(i.enabled=!0,i.writeMask=0,i.referenceValue=1,i.compareFunctionFront=i.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},tc._onSpriteChange=function(t){switch(t){case l7.texture:this.shaderData.setTexture(tl._textureProperty,this.sprite.texture);break;case l7.size:var r=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=ci.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=cs.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ci.WorldVolume);break;case l7.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=cs.WorldVolumeAndUV);break;case l7.region:case l7.atlasRegionOffset:this._dirtyUpdateFlag|=cs.WorldVolumeAndUV;break;case l7.atlasRegion:this._dirtyUpdateFlag|=2;break;case l7.pivot:this._dirtyUpdateFlag|=ci.WorldVolume;break;case l7.destroy:this.sprite=null}},tc._onColorChanged=function(){this._dirtyUpdateFlag|=4},ua(tl,[{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=u7;break;case e.SpriteDrawMode.Sliced:this._assembler=de;break;case e.SpriteDrawMode.Tiled:this._assembler=dr}this._assembler.resetData(this),this._dirtyUpdateFlag|=cs.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cs.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=cq.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cs.VertexData))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=15,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(tl._textureProperty,e.texture)):this.shaderData.setTexture(tl._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:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(t){this._customWidth!==t&&(this._customWidth=t,this._dirtyUpdateFlag|=this._drawMode===e.SpriteDrawMode.Tiled?cs.VertexData:ci.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(t){this._customHeight!==t&&(this._customHeight=t,this._dirtyUpdateFlag|=this._drawMode===e.SpriteDrawMode.Tiled?cs.VertexData:ci.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ci.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ci.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)}}]),tl);dn._textureProperty=uF.getByName("renderer_SpriteTexture"),us([uc],dn.prototype,"_subChunk",void 0),us([uc],dn.prototype,"_drawMode",void 0),us([uu],dn.prototype,"_assembler",void 0),us([uu],dn.prototype,"_tileMode",void 0),us([uu],dn.prototype,"_tiledAdaptiveThreshold",void 0),us([uh],dn.prototype,"_color",void 0),us([uc],dn.prototype,"_sprite",void 0),us([uc],dn.prototype,"_automaticWidth",void 0),us([uc],dn.prototype,"_automaticHeight",void 0),us([uu],dn.prototype,"_customWidth",void 0),us([uu],dn.prototype,"_customHeight",void 0),us([uu],dn.prototype,"_flipX",void 0),us([uu],dn.prototype,"_flipY",void 0),us([uc],dn.prototype,"_onSpriteChange",null),us([uc],dn.prototype,"_onColorChanged",null),(tu=cs||(cs={}))[tu.UV=2]="UV",tu[tu.Color=4]="Color",tu[tu.AutomaticSize=8]="AutomaticSize",tu[tu.WorldVolumeAndUV=2|ci.WorldVolume]="WorldVolumeAndUV",tu[tu.VertexData=4|tu.WorldVolumeAndUV]="VertexData",tu[tu.All=15]="All",e.Layer=void 0,(td=e.Layer||(e.Layer={}))[td.Layer0=1]="Layer0",td[td.Layer1=2]="Layer1",td[td.Layer2=4]="Layer2",td[td.Layer3=8]="Layer3",td[td.Layer4=16]="Layer4",td[td.Layer5=32]="Layer5",td[td.Layer6=64]="Layer6",td[td.Layer7=128]="Layer7",td[td.Layer8=256]="Layer8",td[td.Layer9=512]="Layer9",td[td.Layer10=1024]="Layer10",td[td.Layer11=2048]="Layer11",td[td.Layer12=4096]="Layer12",td[td.Layer13=8192]="Layer13",td[td.Layer14=16384]="Layer14",td[td.Layer15=32768]="Layer15",td[td.Layer16=65536]="Layer16",td[td.Layer17=131072]="Layer17",td[td.Layer18=262144]="Layer18",td[td.Layer19=524288]="Layer19",td[td.Layer20=1048576]="Layer20",td[td.Layer21=2097152]="Layer21",td[td.Layer22=4194304]="Layer22",td[td.Layer23=8388608]="Layer23",td[td.Layer24=16777216]="Layer24",td[td.Layer25=33554432]="Layer25",td[td.Layer26=67108864]="Layer26",td[td.Layer27=134217728]="Layer27",td[td.Layer28=268435456]="Layer28",td[td.Layer29=536870912]="Layer29",td[td.Layer30=1073741824]="Layer30",td[td.Layer31=2147483648]="Layer31",td[td.Everything=4294967295]="Everything",td[td.Nothing=0]="Nothing",e.RenderBufferDepthFormat=void 0,(th=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[th.Depth=27]="Depth",th[th.Stencil=28]="Stencil",th[th.DepthStencil=29]="DepthStencil",th[th.Depth16=30]="Depth16",th[th.Depth24=31]="Depth24",th[th.Depth32=32]="Depth32",th[th.Depth24Stencil8=33]="Depth24Stencil8",th[th.Depth32Stencil8=34]="Depth32Stencil8",e.TextureCubeFace=void 0,(t_=e.TextureCubeFace||(e.TextureCubeFace={}))[t_.PositiveX=0]="PositiveX",t_[t_.NegativeX=1]="NegativeX",t_[t_.PositiveY=2]="PositiveY",t_[t_.NegativeY=3]="NegativeY",t_[t_.PositiveZ=4]="PositiveZ",t_[t_.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(tf=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[tf.Never=0]="Never",tf[tf.Less=1]="Less",tf[tf.Equal=2]="Equal",tf[tf.LessEqual=3]="LessEqual",tf[tf.Greater=4]="Greater",tf[tf.NotEqual=5]="NotEqual",tf[tf.GreaterEqual=6]="GreaterEqual",tf[tf.Always=7]="Always",e.TextureUsage=void 0,(tp=e.TextureUsage||(e.TextureUsage={}))[tp.Static=0]="Static",tp[tp.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(tm=e.TextureWrapMode||(e.TextureWrapMode={}))[tm.Clamp=0]="Clamp",tm[tm.Repeat=1]="Repeat",tm[tm.Mirror=2]="Mirror";var da=(uo(tg=function(t,r,n,a,i,o){if(void 0===i&&(i=e.TextureFormat.Depth),void 0===o&&(o=1),(s=u8.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=r,s._height=n,s._antiAliasing=o,s._depth=i,a){for(var s,l=ul(a,Array)?a.slice():[a],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(ul(i,u5)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(ur(s)),s},u8),(tv=tg.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},tv.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,r=e.length;t<r;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},tv._onDestroy=function(){u8.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,r=0,n=t.length;r<n;r++)t[r]._addReferCount(-1);t.length=0,null==(e=this._depthTexture)||e._addReferCount(-1),this._depthTexture=null,this._depth=null},tv._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},tv._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},ua(tg,[{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}}]),tg),di=(uo(ty=function(t,r,n,a,i,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=e.TextureUsage.Static),(s=u5.call(this,t)||this)._mipmap=i,s._width=r,s._height=n,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==e.TextureFormat.Depth||a==e.TextureFormat.DepthStencil||a==e.TextureFormat.Depth16||a==e.TextureFormat.Depth24||a==e.TextureFormat.Depth32||a==e.TextureFormat.Depth24Stencil8||a==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(ur(s)),s.filterMode=s._isIntFormat()?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u5),(tx=ty.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i),this._isContentLost=!1},tx.setImageSource=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,r,n,a,i),this._isContentLost=!1},tx.getPixelBuffer=function(e,t,r,n,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,r,n,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i)},tx._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),u5.prototype._rebuild.call(this)},ty),ds=(uo(tb=function(t,r,n,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=u5.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(ur(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u5),(tT=tb.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o,s),this._isContentLost=!1},tT.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tT.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):5===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tT._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),u5.prototype._rebuild.call(this)},ua(tb,[{key:"length",get:function(){return this._length}}]),tb),dl=(uo(tC=function(t,r,n,a){var i;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=u5.call(this,t)||this)._mipmap=a,i._width=r,i._height=r,i._format=n,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(ur(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},u5),(tS=tC.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o),this._isContentLost=!1},tS.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tS.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):6===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tS._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),u5.prototype._rebuild.call(this)},tC),dc=((tA=function(){}).recreateTextureIfNeeded=function(e,t,r,n,a,i,o,s){return t?(t.width!==r||t.height!==n||t.format!==a||t.mipmapCount>1!==i)&&(t.destroy(!0),(t=new di(e,r,n,a,i)).isGCIgnored=!0):(t=new di(e,r,n,a,i)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},tA.recreateRenderTargetIfNeeded=function(e,t,r,n,a,i,o,s,l,c,u){var d,h,_=null==(p=t)?void 0:p.getColorTexture(0),f=a?tA.recreateTextureIfNeeded(e,_,r,n,a,s,c,u):null;if(o){var p,m,g,v=null==(m=t)?void 0:m.depthTexture,y=i?tA.recreateTextureIfNeeded(e,v,r,n,i,s,c,u):null;(_!==f||v!==y)&&(null==(g=t)||g.destroy(!0),(t=new da(e,r,n,f,y,l)).isGCIgnored=!0)}else(_!==f||(null==(d=t)?void 0:d._depthFormat)!==i||t.antiAliasing!==l)&&(null==(h=t)||h.destroy(!0),(t=new da(e,r,n,f,i,l)).isGCIgnored=!0);return t},tA.blitTexture=function(e,t,r,n,a,i,o){void 0===n&&(n=0),void 0===a&&(a=tA.defaultViewport),void 0===i&&(i=null),void 0===o&&(o=0);var s=e._basicResources,l=r?s.flipYBlitMesh:s.blitMesh,c=i||s.blitMaterial,u=e._hardwareRenderer,d=e._renderContext;d.flipProjection=!!r,u.activeRenderTarget(r,a,d.flipProjection,0);var h=tA._rendererShaderData;h.setTexture(tA._blitTextureProperty,t),h.setFloat(tA._blitMipLevelProperty,n),tA._texelSize.set(1/t.width,1/t.height,t.width,t.height),h.setVector4(tA._blitTexelSizeProperty,tA._texelSize);var _=c.shader.subShaders[0].passes[o],f=u4._compileMacros;uU.unionCollection(d.camera._globalShaderMacro,c.shaderData._macroCollection,f);var p=_._getShaderProgram(e,f);p.bind(),p.groupingOtherUniformBlock(),p.uploadAll(p.rendererUniformBlock,h),p.uploadAll(p.materialUniformBlock,c.shaderData),p.uploadUnGroupTextures(),(_._renderState||c.renderState)._applyStates(e,!1,_._renderStateDataMap,c.shaderData),u.drawPrimitive(l._primitive,l.subMesh,p)},tA);dc._blitTextureProperty=uF.getByName("renderer_BlitTexture"),dc._blitMipLevelProperty=uF.getByName("renderer_BlitMipLevel"),dc._blitTexelSizeProperty=uF.getByName("renderer_texelSize"),dc._rendererShaderData=new u9(cn.Renderer),dc._texelSize=new c9,dc.defaultViewport=new c9(0,0,1,1);var du=function(){this.position=new cQ,this.isOrthographic=!1,this.viewMatrix=new c4,this.projectionMatrix=new c4,this.viewProjectionMatrix=new c4,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new cQ};e.CameraClearFlags=void 0,(tM=e.CameraClearFlags||(e.CameraClearFlags={}))[tM.None=0]="None",tM[tM.Color=1]="Color",tM[tM.Depth=2]="Depth",tM[tM.Stencil=4]="Stencil",tM[tM.ColorDepth=3]="ColorDepth",tM[tM.ColorStencil=5]="ColorStencil",tM[tM.DepthStencil=6]="DepthStencil",tM[tM.All=7]="All",e.CameraType=void 0,(tR=e.CameraType||(e.CameraType={}))[tR.Normal=0]="Normal",tR[tR.XRCenterCamera=1]="XRCenterCamera",tR[tR.XRLeftCamera=2]="XRLeftCamera",tR[tR.XRRightCamera=4]="XRRightCamera",e.DepthTextureMode=void 0,(tE=e.DepthTextureMode||(e.DepthTextureMode={}))[tE.None=0]="None",tE[tE.PrePass=1]="PrePass",e.Downsampling=void 0,(tw=e.Downsampling||(e.Downsampling={}))[tw.None=1]="None",tw[tw.TwoX=2]="TwoX",tw[tw.FourX=4]="FourX",e.MSAASamples=void 0,(tP=e.MSAASamples||(e.MSAASamples={}))[tP.None=1]="None",tP[tP.TwoX=2]="TwoX",tP[tP.FourX=4]="FourX",tP[tP.EightX=8]="EightX",e.ReplacementFailureStrategy=void 0,(tF=e.ReplacementFailureStrategy||(e.ReplacementFailureStrategy={}))[tF.KeepOriginalShader=0]="KeepOriginalShader",tF[tF.DoNotRender=1]="DoNotRender";var dd=function(){};dd.tempVec4=new c9,dd.tempVec3=new cQ,dd.tempVec2=new c5,e.Camera=(uo(tL=function(t){(r=uB.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r.opaqueTextureDownsampling=e.Downsampling.TwoX,r.msaaSamples=e.MSAASamples.None,r._cameraType=e.CameraType.Normal,r._globalShaderMacro=new uU,r._frustum=new c1,r._virtualCamera=new du,r._replacementShader=null,r._replacementSubShaderTag=null,r._replacementFailureStrategy=null,r._cameraIndex=-1,r._priority=0,r._shaderData=new u9(cn.Camera),r._isCustomViewMatrix=!1,r._isCustomProjectionMatrix=!1,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new c9,r._opaqueTextureEnabled=!1,r._enableHDR=!1,r._enablePostProcess=!1,r._viewport=new c9(0,0,1,1),r._pixelViewport=new c7(0,0,0,0),r._inverseProjectionMatrix=new c4,r._invViewProjMat=new c4;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new dT(ur(r)),r._addResourceReferCount(r.shaderData,1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(ur(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},uB),(tB=tL.prototype).resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},tB.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},tB.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},tB.worldToViewportPoint=function(e,t){var r=dd.tempVec3,n=dd.tempVec4;cQ.transformCoordinate(e,this.viewMatrix,r),cQ.transformToVec4(r,this.projectionMatrix,n);var a=n.w;return t.set((n.x/a+1)*.5,(1-n.y/a)*.5,-r.z),t},tB.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,a=this.farClipPlane,i=1/(n-a);if(this.isOrthographic)r=-(2*e.z)*i+(a+n)*i;else{var o=e.z;r=(-o*(n+a)*i+2*n*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},tB.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-cq.zeroTolerance,r,t.direction);return cQ.subtract(a,n,a),a.normalize(),t},tB.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},tB.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},tB.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},tB.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},tB.screenPointToRay=function(e,t){var r=dd.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},tB.render=function(t,r){void 0===r&&(r=0);var n,a=this.engine._renderContext,i=this._virtualCamera,o=this.entity.transform;c4.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,a.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),uU.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,uP.error("mipLevel only take effect in WebGL2.0")),this._cameraType!==e.CameraType.Normal&&(n=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,t,r,n),this._engine._renderCount++},tB.setReplacementShader=function(t,r,n){void 0===n&&(n=e.ReplacementFailureStrategy.KeepOriginalShader),this._replacementShader=t,this._replacementSubShaderTag="string"==typeof r?uj.getByName(r):r,this._replacementFailureStrategy=n},tB.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},tB._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},tB._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},tB._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2?e.TextureFormat.R11G11B10_UFloat:e.TextureFormat.R16G16B16A16:e.TextureFormat.R8G8B8A8},tB._onDestroy=function(){var e;uB.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},tB._updatePixelViewport=function(){var e,t,r=this._renderTarget;if(r)e=r.width,t=r.height;else{var n=this.engine.canvas;e=n.width,t=n.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},tB._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},tB._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},tB._innerViewportToWorldPoint=function(e,t,r,n,a){var i=dd.tempVec3;return i.set(2*e-1,1-2*t,2*r-1),cQ.transformCoordinate(i,n,a),a},tB._updateShaderData=function(){var t=this.shaderData,r=this._transform;t.setMatrix(e.Camera._inverseViewMatrixProperty,r.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,r.worldPosition),t.setVector3(e.Camera._cameraForwardProperty,r.worldForward),t.setVector3(e.Camera._cameraUpProperty,r.worldUp);var n=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;n.set(1-a,a,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},tB._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,c4.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},tB._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,c4.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},tB._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},tB._checkMainCanvasAntialiasWaste=function(){this._phasedActiveInScene&&this.independentCanvasEnabled&&c9.equals(this._viewport,dc.defaultViewport)&&uP.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},ua(tL,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return!!this.enableHDR||!!this.enablePostProcess&&!!this.scene._postProcessManager.hasActiveEffect||this.opaqueTextureEnabled&&!this._renderTarget}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._transform;return c4.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,a=this._orthographicSize;c4.ortho(-n,n,-a,a,this.nearClipPlane,this.farClipPlane,t)}else c4.perspective(cq.degreeToRadian(this._fieldOfView),r,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return this._enableHDR},set:function(t){if(this.enableHDR!==t){var r=this.engine._hardwareRenderer,n=r.isWebGL2||r.canIUse(e.GLCapabilityType.textureHalfFloat);if(t&&!n){uP.warn("Can't enable HDR in this device.");return}this._enableHDR=t,this._checkMainCanvasAntialiasWaste()}}},{key:"enablePostProcess",get:function(){return this._enablePostProcess},set:function(e){this._enablePostProcess!==e&&(this._enablePostProcess=e,this._checkMainCanvasAntialiasWaste())}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged())}}]),tL._cameraDepthTextureProperty=uF.getByName("camera_DepthTexture"),tL._cameraOpaqueTextureProperty=uF.getByName("camera_OpaqueTexture"),tL._inverseViewMatrixProperty=uF.getByName("camera_ViewInvMat"),tL._cameraPositionProperty=uF.getByName("camera_Position"),tL._cameraForwardProperty=uF.getByName("camera_Forward"),tL._cameraUpProperty=uF.getByName("camera_Up"),tL._cameraDepthBufferParamsProperty=uF.getByName("camera_DepthBufferParams"),tL),us([uh],e.Camera.prototype,"_frustum",void 0),us([uc],e.Camera.prototype,"_renderPipeline",void 0),us([uc],e.Camera.prototype,"_virtualCamera",void 0),us([uc],e.Camera.prototype,"_cameraIndex",void 0),us([uc],e.Camera.prototype,"_frustumChangeFlag",void 0),us([uc],e.Camera.prototype,"_transform",void 0),us([uc],e.Camera.prototype,"_isViewMatrixDirty",void 0),us([uc],e.Camera.prototype,"_isInvViewProjDirty",void 0),us([uh],e.Camera.prototype,"_viewport",void 0),us([uh],e.Camera.prototype,"_pixelViewport",void 0),us([uh],e.Camera.prototype,"_inverseProjectionMatrix",void 0),us([uh],e.Camera.prototype,"_invViewProjMat",void 0),us([uc],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=us([uI(uV,e.DependentMode.CheckOnly)],e.Camera),e.BackgroundMode=void 0,(tD=e.BackgroundMode||(e.BackgroundMode={}))[tD.SolidColor=0]="SolidColor",tD[tD.Sky=1]="Sky",tD[tD.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(tI=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[tI.AspectFitWidth=0]="AspectFitWidth",tI[tI.AspectFitHeight=1]="AspectFitHeight",tI[tI.Fill=2]="Fill";var dh=function(e){this.engine=e},d_=((tV=(tO=function(){this._projectionParams=new c9,this.flipProjection=!1,this.rendererUpdateFlag=0}).prototype).applyVirtualCamera=function(e,t){this.virtualCamera=e,this.flipProjection=t;var r=this.camera.shaderData,n=e.viewMatrix,a=e.projectionMatrix,i=e.viewProjectionMatrix;t&&(c4.multiply(tO._flipYMatrix,a,tO._flipYProjectionMatrix),c4.multiply(tO._flipYProjectionMatrix,n,tO._flipYViewProjectionMatrix),a=tO._flipYProjectionMatrix,i=tO._flipYViewProjectionMatrix),this.viewMatrix=n,this.projectionMatrix=a,this.viewProjectionMatrix=i,r.setMatrix(tO._viewMatrixProperty,n),r.setMatrix(tO._projectionMatrixProperty,a),r.setMatrix(tO.vpMatrixProperty,i);var o=this._projectionParams;o.set(t?-1:1,e.nearClipPlane,e.farClipPlane,0),r.setVector4(tO._cameraProjectionProperty,o)},tV.garbageCollection=function(){this.camera=null},tO);d_.vpMatrixProperty=uF.getByName("camera_VPMat"),d_.pipelineStageKey=uj.getByName("pipelineStage"),d_._flipYMatrix=new c4(1,0,0,0,0,-1),d_._cameraProjectionProperty=uF.getByName("camera_ProjectionParams"),d_._viewMatrixProperty=uF.getByName("camera_ViewMat"),d_._projectionMatrixProperty=uF.getByName("camera_ProjMat"),d_._flipYProjectionMatrix=new c4,d_._flipYViewProjectionMatrix=new c4,(tN=cl||(cl={}))[tN.None=0]="None",tN[tN.WorldMatrix=1]="WorldMatrix",tN[tN.viewMatrix=2]="viewMatrix",tN[tN.ProjectionMatrix=4]="ProjectionMatrix",tN[tN.WorldViewMatrix=3]="WorldViewMatrix",tN[tN.viewProjectionMatrix=6]="viewProjectionMatrix",tN[tN.All=7]="All";var df=((tz=(tk=function(){this.allSpriteMasks=new dt,this.preMaskLayer=0}).prototype).addSpriteMask=function(e){e._maskIndex=this.allSpriteMasks.length,this.allSpriteMasks.add(e)},tz.removeSpriteMask=function(e){var t=this.allSpriteMasks.deleteByIndex(e._maskIndex);t&&(t._maskIndex=e._maskIndex),e._maskIndex=-1},tz.buildMaskRenderElement=function(e,t,r){var n=this.preMaskLayer,a=e.component._maskLayer;if(n!==a){for(var i=this.allSpriteMasks,o=n&a,s=n&~a,l=i._elements,c=0,u=i.length;c<u;c++){var d=l[c],h=d.influenceLayers;!(h&o)&&(h&a?t.pushRenderElement(d._renderElement):h&s&&r.pushRenderElement(d._renderElement))}this.preMaskLayer=a}},tz.destroy=function(){this.allSpriteMasks.length=0},tk.getMaskIncrementRenderQueue=function(){return tk._maskIncrementRenderQueue||(tk._maskIncrementRenderQueue=new dp(e.RenderQueueType.Transparent))},tk.getMaskDecrementRenderQueue=function(){return tk._maskDecrementRenderQueue||(tk._maskDecrementRenderQueue=new dp(e.RenderQueueType.Transparent))},tk),dp=((tG=(tU=function(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[]}).prototype).pushRenderElement=function(e){this.elements.push(e)},tG.sortBatch=function(e,t){this._sort(e),this._batch(t)},tG.render=function(t,r,n){void 0===n&&(n=0);var a=this.batchedSubElements,i=a.length;if(0!==i){var o=t.rendererUpdateFlag,s=t.camera,l=s.engine,c=s.scene,u=s.instanceId,d=s.shaderData,h=c.instanceId,_=c.shaderData,f=l._renderCount,p=l._hardwareRenderer,m=d_.pipelineStageKey,g=this.renderQueueType;c._maskManager.preMaskLayer=0;for(var v=0;v<i;v++){var y=a[v],x=y.component,b=y.batched;o&cl.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(t,!1,b),x._batchedTransformShaderData=b):o&cl.ProjectionMatrix&&x._updateTransformShaderData(t,!0,b),x._maskInteraction!==e.SpriteMaskInteraction.None&&this._drawMask(t,r,y);var T=u4._compileMacros,C=y.primitive,S=y.material,A=y.shaderPasses,M=y.shaderData,R=x.shaderData,E=x.instanceId,w=S.shaderData,P=S.instanceId,F=S.renderStates;if(uU.unionCollection(x._globalShaderMacro,w._macroCollection,T),0!==n){var L=1===n?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate,B=S.renderState.stencilState;B.passOperationFront=L,B.passOperationBack=L}for(var D=0,I=A.length;D<I;D++){var O,V,N=A[D];if(N.getTagValue(m)===r&&(null!=(O=N._renderState)?O:F[D]).renderQueueType===g){var k=N._getShaderProgram(l,T);if(k.isValid){var z=k.bind();f!==k._uploadRenderCount?(k.groupingOtherUniformBlock(),k.uploadAll(k.sceneUniformBlock,_),k.uploadAll(k.cameraUniformBlock,d),k.uploadAll(k.rendererUniformBlock,R),k.uploadAll(k.materialUniformBlock,w),M&&k.uploadAll(k.renderElementUniformBlock,M),k.uploadUnGroupTextures(),k._uploadSceneId=h,k._uploadCameraId=u,k._uploadRendererId=E,k._uploadMaterialId=P,k._uploadRenderCount=f):(k._uploadSceneId!==h?(k.uploadAll(k.sceneUniformBlock,_),k._uploadSceneId=h):z&&k.uploadTextures(k.sceneUniformBlock,_),k._uploadCameraId!==u?(k.uploadAll(k.cameraUniformBlock,d),k._uploadCameraId=u):z&&k.uploadTextures(k.cameraUniformBlock,d),k._uploadRendererId!==E?(k.uploadAll(k.rendererUniformBlock,R),k._uploadRendererId=E):z&&k.uploadTextures(k.rendererUniformBlock,R),k._uploadMaterialId!==P?(k.uploadAll(k.materialUniformBlock,w),k._uploadMaterialId=P):z&&k.uploadTextures(k.materialUniformBlock,w),M&&k.uploadAll(k.renderElementUniformBlock,M),z&&k.uploadUnGroupTextures()),(null!=(V=N._renderState)?V:F[D])._applyStates(l,x.entity.transform._isFrontFaceInvert(),N._renderStateDataMap,S.shaderData),p.drawPrimitive(C,y.subPrimitive,k)}}}}}},tG.clear=function(){this.elements.length=0,this.batchedSubElements.length=0},tG.destroy=function(){},tG._sort=function(e){ug._quickSort(this.elements,0,this.elements.length,e)},tG._batch=function(e){e.batch(this)},tG._drawMask=function(e,t,r){var n=df.getMaskIncrementRenderQueue();n.renderQueueType=this.renderQueueType,n.clear();var a=df.getMaskDecrementRenderQueue();a.renderQueueType=this.renderQueueType,a.clear();var i=e.camera,o=i.engine;i.scene._maskManager.buildMaskRenderElement(r,n,a),n._batch(o._batcherManager),n.render(e,t,1),a._batch(o._batcherManager),a.render(e,t,2)},tU.compareForOpaque=function(e,t){return e.priority-t.priority||e.distanceForSort-t.distanceForSort},tU.compareForTransparent=function(e,t){return e.priority-t.priority||t.distanceForSort-e.distanceForSort},tU);(tH=cc||(cc={}))[tH.No=0]="No",tH[tH.Increment=1]="Increment",tH[tH.Decrement=2]="Decrement";var dm=function(){this.virtualCamera=new du,this.cullPlanes=[new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ),new c0(new cQ)],this.splitBoundSphere=new cZ(new cQ,0)};e.ShadowResolution=void 0,(tW=e.ShadowResolution||(e.ShadowResolution={}))[tW.Low=0]="Low",tW[tW.Medium=1]="Medium",tW[tW.High=2]="High",tW[tW.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tj=e.ShadowType||(e.ShadowType={}))[tj.None=0]="None",tj[tj.Hard=1]="Hard",tj[tj.SoftLow=2]="SoftLow",tj[tj.SoftHigh=3]="SoftHigh",(tK=cu||(cu={}))[tK.FarBottomLeft=0]="FarBottomLeft",tK[tK.FarTopLeft=1]="FarTopLeft",tK[tK.FarTopRight=2]="FarTopRight",tK[tK.FarBottomRight=3]="FarBottomRight",tK[tK.nearBottomLeft=4]="nearBottomLeft",tK[tK.nearTopLeft=5]="nearTopLeft",tK[tK.nearTopRight=6]="nearTopRight",tK[tK.nearBottomRight=7]="nearBottomRight",tK[tK.unknown=8]="unknown";var dg=((tX=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}},tX.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},tX.cullingRenderBounds=function(e,t,r){for(var n=e.min,a=e.max,i=0;i<t;i++){var o=r[i],s=o.normal;if(s.x*(s.x>=0?a.x:n.x)+s.y*(s.y>=0?a.y:n.y)+s.z*(s.z>=0?a.z:n.z)<-o.distance)return!1}return!0},tX.shadowCullFrustum=function(e,t,r,n){var a=r._entity.layer;e.camera.cullingMask&a&&t.cullingMask&a&&r.castShadows&&tX.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._prepareRender(e),r._renderFrameCount=r.engine.time.frameCount)},tX.getBoundSphereByFrustum=function(e,t,r,n,a){var i,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(cq.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(i=t,o=t*c):(i=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,cQ.scale(n,i,_),cQ.add(r.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},tX.getDirectionLightShadowCullPlanes=function(t,r,n,a,i){var o=tX._frustumCorners,s=tX._backPlaneFaces,l=tX._frustumPlaneNeighbors,c=tX._frustumTwoPlaneCorners,u=tX._edgePlanePoint2,d=i.cullPlanes,h=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),m=t.getPlane(e.FrustumFace.Bottom),g=t.getPlane(e.FrustumFace.Top),v=tX._adjustNearPlane,y=tX._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),c$.intersectionPointThreePlanes(v,m,p,o[7]),c$.intersectionPointThreePlanes(v,g,p,o[6]),c$.intersectionPointThreePlanes(v,g,f,o[5]),c$.intersectionPointThreePlanes(v,m,f,o[4]),c$.intersectionPointThreePlanes(y,m,p,o[3]),c$.intersectionPointThreePlanes(y,g,p,o[2]),c$.intersectionPointThreePlanes(y,g,f,o[1]),c$.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var T=void 0;switch(b){case e.FrustumFace.Near:T=v;break;case e.FrustumFace.Far:T=y;break;default:T=t.getPlane(b)}0>cQ.dot(T.normal,a)&&(d[x].copyFrom(T),s[x]=b,x++)}for(var C=x,S=0;S<x;S++)for(var A=s[S],M=l[A],R=0;R<4;R++){for(var E=M[R],w=!0,P=0;P<x;P++)if(E==s[P]){w=!1;break}if(w){var F=c[A][E],L=o[F[0]],B=o[F[1]];cQ.add(L,a,u),c0.fromPoints(L,B,u,d[C++])}}i.cullPlaneCount=C},tX.getDirectionalLightMatrices=function(e,t,r,n,a,i,o,s){var l=o.splitBoundSphere;o.resolution=i;var c=l.center,u=l.radius,d=i/2,h=u*d/(d-tX.atlasBorderSize),_=2*h,f=i/_,p=_/i,m=Math.ceil(cQ.dot(c,e)*f)*p,g=Math.ceil(cQ.dot(c,t)*f)*p,v=cQ.dot(c,r);c.x=e.x*m+t.x*g+r.x*v,c.y=e.y*m+t.y*g+r.y*v,c.z=e.z*m+t.z*g+r.z*v;var y=o.virtualCamera,x=y.position,b=y.viewMatrix,T=y.projectionMatrix;cQ.scale(r,u+a,x),cQ.subtract(c,x,x),c4.lookAt(x,c,e,b),c4.ortho(-h,h,-h,h,0,2*u+a,T);var C=y.viewProjectionMatrix;c4.multiply(T,b,C),ug._floatMatrixMultiply(tX._shadowMapCoordMatrix,C.elements,0,s,16*n)},tX.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),a=Math.floor(e/n)*Math.floor(t/n);a<r;)a=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},tX.getShadowBias=function(t,r,n,a){var i=2/r.elements[0]/n,o=-t.shadowBias*i,s=-t.shadowNormalBias*i;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),a.set(o,s)},tX.applySliceTransform=function(e,t,r,n,a,i){var o=tX._tempMatrix0,s=o.elements,l=1/t,c=1/r,u=a.x*l,d=a.y*c;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=u,s[13]=d,s[14]=0,s[15]=1;var h=16*n;ug._floatMatrixMultiply(o,i,h,i,h)},tX.getScaleAndBiasForLinearDistanceFade=function(e,t,r){if(t<1e-4){r.z=1e3,r.w=-(1e3*e);return}t=1-t;var n=(t*=t)*e,a=e-n;r.z=1/a,r.w=-n/a},tX);dg._tempMatrix0=new c4,dg._shadowMapCoordMatrix=new c4(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),dg._frustumCorners=[new cQ,new cQ,new cQ,new cQ,new cQ,new cQ,new cQ,new cQ],dg._adjustNearPlane=new c0(new cQ),dg._adjustFarPlane=new c0(new cQ),dg._backPlaneFaces=[,,,,,],dg._edgePlanePoint2=new cQ,dg._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]],dg._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]]],dg.atlasBorderSize=4,e.ShadowCascadesMode=void 0,(tY=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tY.NoCascades=1]="NoCascades",tY[tY.TwoCascades=2]="TwoCascades",tY[tY.FourCascades=4]="FourCascades";var dv=function(t){function r(n){var a;return(a=t.call(this,n.engine)||this)._shadowMapSize=new c9,a._shadowBias=new c5,a._shadowSliceData=new dm,a._lightUp=new cQ,a._lightSide=new cQ,a._splitBoundSpheres=new Float32Array(4*r._maxCascades),a._shadowMatrices=new Float32Array((r._maxCascades+1)*16),a._shadowInfos=new c9,a._viewportOffsets=[new c5,new c5,new c5,new c5],a._camera=n,a._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}uo(r,t);var n=r.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(t,n){var a,i,o=this.engine,s=this._camera,l=this._viewportOffsets,c=this._shadowSliceData,u=this._splitBoundSpheres,d=this._shadowMatrices,h=s._renderPipeline._cullingResults,_=h.opaqueQueue,f=h.alphaTestQueue,p=s.scene,m=p._componentsManager,g=o._hardwareRenderer,v=p.shadowCascades,y=r._cascadesSplitDistance,x=c.splitBoundSphere,b=r._tempMatrix0,T=b.elements,C=this._lightUp,S=this._lightSide,A=c.virtualCamera.forward,M=this._shadowMapSize,R=M.z,E=M.w,w=this._shadowMapFormat;i=this._supportDepthTexture?(a=dc.recreateRenderTargetIfNeeded(o,this._renderTarget,R,E,null,w,!0,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear)).depthTexture:(a=dc.recreateRenderTargetIfNeeded(o,this._renderTarget,R,E,w,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear)).getColorTexture(0),o._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=a,this._depthTexture=i,g.activeRenderTarget(a,r._viewport,t.flipProjection,0),this._supportDepthTexture?g.clearRenderTarget(o,e.CameraClearFlags.Depth,null):g.clearRenderTarget(o,e.CameraClearFlags.All,r._clearColor),c4.rotationQuaternion(n.entity.transform.worldRotationQuaternion,b),S.set(T[0],T[1],T[2]),C.set(T[4],T[5],T[6]),A.set(-T[8],-T[9],-T[10]);var P=r._tempVector;P.copyFrom(s.entity.transform.worldForward);for(var F=this._shadowTileResolution,L=0;L<v;L++){dg.getBoundSphereByFrustum(y[L],y[L+1],s,P,c),dg.getDirectionLightShadowCullPlanes(s._frustum,y[L],s.nearClipPlane,A,c),dg.getDirectionalLightMatrices(C,S,A,L,n.shadowNearPlane,F,c,d),v>1&&dg.applySliceTransform(F,R,E,L,this._viewportOffsets[L],d),this._updateSingleShadowCasterShaderData(n,c,t);var B=x.center,D=x.radius,I=4*L;u[I]=B.x,u[I+1]=B.y,u[I+2]=B.z,u[I+3]=D*D,_.clear(),f.clear();for(var O=m._renderers,V=O._elements,N=O.length-1;N>=0;--N)dg.shadowCullFrustum(t,n,V[N],c);if(_.elements.length||f.elements.length){o._renderCount++;var k=o._batcherManager;_.sortBatch(dp.compareForOpaque,k),f.sortBatch(dp.compareForOpaque,k);var z=l[L],U=z.x,G=z.y;g.setGlobalDepthBias(1,1),g.viewport(U,G,F,F),g.scissor(U+1,G+1,F-2,F-2),_.render(t,e.PipelineStage.ShadowCaster),f.render(t,e.PipelineStage.ShadowCaster),g.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var t=this._camera,n=t.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=n.shadowCascades,s=Math.min(n.shadowDistance,t.farClipPlane);if(dg.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),n.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var u=16*o,d=i.length;u<d;u++)i[u]=0;var h=n.shaderData;h.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),h.setVector4(r._shadowInfosProperty,this._shadowInfos),h.setTexture(r._shadowMapsProperty,this._depthTexture),h.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,a=this._camera.scene,i=a.shadowTwoCascadeSplits,o=a.shadowFourCascadeSplits,s=a.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,d=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*cq.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*i,f),n[2]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.FourCascades:n[1]=this._getFarWithRadius(c+h*o.x,f),n[2]=this._getFarWithRadius(c+h*o.y,f),n[3]=this._getFarWithRadius(c+h*o.z,f),n[4]=this._getFarWithRadius(t,f)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var t=this._camera,r=t.scene,n=dg.shadowDepthFormat(r.shadowResolution,this._supportDepthTexture),a=dg.shadowResolution(r.shadowResolution),i=r.shadowCascades,o=Math.min(r.shadowDistance,t.farClipPlane);if(this._getCascadesSplitDistance(o),n!==this._shadowMapFormat||a!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=a,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=a,this._shadowMapSize.set(1/a,1/a,a,a);else{var s=dg.getMaxTileResolutionInAtlas(a,a,i);this._shadowTileResolution=s;var l=2*s,c=i==e.ShadowCascadesMode.TwoCascades?s:2*s;this._shadowMapSize.set(1/l,1/c,l,c)}this._renderTarget=null;var u=this._viewportOffsets,d=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:u[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:u[0].set(0,0),u[1].set(d,0);break;case e.ShadowCascadesMode.FourCascades:u[0].set(0,0),u[1].set(d,0),u[2].set(0,d),u[3].set(d,d)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var a=t.virtualCamera;dg.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(r._lightShadowBiasProperty,this._shadowBias),i.setVector3(r._lightDirectionProperty,e.direction),n.rendererUpdateFlag|=cl.viewProjectionMatrix,n.applyVirtualCamera(a,!0)},r}(dh);dv._lightShadowBiasProperty=uF.getByName("scene_ShadowBias"),dv._lightDirectionProperty=uF.getByName("scene_LightDirection"),dv._shadowMatricesProperty=uF.getByName("scene_ShadowMatrices"),dv._shadowMapSize=uF.getByName("scene_ShadowMapSize"),dv._shadowInfosProperty=uF.getByName("scene_ShadowInfo"),dv._shadowMapsProperty=uF.getByName("scene_ShadowMap"),dv._shadowSplitSpheresProperty=uF.getByName("scene_ShadowSplitSpheres"),dv._maxCascades=4,dv._cascadesSplitDistance=Array(dv._maxCascades+1),dv._viewport=new c9(0,0,1,1),dv._clearColor=new c6(1,1,1,1),dv._tempVector=new cQ,dv._tempMatrix0=new c4;var dy=((tQ=(tq=function(){this.opaqueQueue=new dp(e.RenderQueueType.Opaque),this.transparentQueue=new dp(e.RenderQueueType.Transparent),this.alphaTestQueue=new dp(e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},tQ.sortBatch=function(e){this.opaqueQueue.sortBatch(dp.compareForOpaque,e),this.alphaTestQueue.sortBatch(dp.compareForOpaque,e),this.transparentQueue.sortBatch(dp.compareForTransparent,e)},tQ.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},tq),dx=(uo(tZ=function(t){var r;return(r=dh.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},dh),(tJ=tZ.prototype).onConfig=function(t){var r=this.engine,n=t.pixelViewport,a=n.width,i=n.height,o=dc.recreateRenderTargetIfNeeded(r,this._renderTarget,a,i,null,e.TextureFormat.Depth16,!0,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Point);this._renderTarget=o},tJ.onRender=function(t,r){var n=this.engine,a=this._renderTarget,i=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(a,dc.defaultViewport,t.flipProjection,0),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),n._renderCount++,r.opaqueQueue.render(t,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(t,e.PipelineStage.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},tZ),db=(uo(t$=function(e){return dh.call(this,e)},dh),(t0=t$.prototype).onConfig=function(t,r){this._cameraColorTexture=r;var n=t.opaqueTextureDownsampling,a=n===e.Downsampling.None,i=t.pixelViewport,o=a?1:n===e.Downsampling.TwoX?.5:.25,s=dc.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,i.width*o,i.height*o,t._getInternalColorTextureFormat(),null,!1,!1,1,e.TextureWrapMode.Clamp,a?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear);this._renderTarget=s},t0.onRender=function(t){dc.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},t$),dT=((t2=(t1=function(e){this._lastCanvasSize=new c5,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new dy,this._cascadedShadowCasterPass=new dv(e),this._depthOnlyPass=new dx(t),this._opaqueTexturePass=new db(t)}).prototype).destroy=function(){this._cullingResults.destroy(),this._camera=null},t2.render=function(t,r,n,a){t.rendererUpdateFlag=cl.All;var i=this._camera,o=i.scene,s=i.engine,l=this._cullingResults,c=o._lightManager._sunlight,u=this._depthOnlyPass,d=i.depthTextureMode===e.DepthTextureMode.PrePass&&u._supportDepthTexture;o.castShadows&&c&&c.shadowType!==e.ShadowType.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=cl.None);var h=s._batcherManager;if(l.reset(),t.rendererUpdateFlag|=cl.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,d),this._prepareRender(t),l.sortBatch(h),h.uploadBuffer(),d?(u.onConfig(i),u.onRender(t,l),t.rendererUpdateFlag=cl.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var _=i.pixelViewport,f=dc.recreateRenderTargetIfNeeded(s,this._internalColorTarget,_.width,_.height,i._getInternalColorTextureFormat(),e.TextureFormat.Depth24Stencil8,!1,!1,i.msaaSamples,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear);this._internalColorTarget=f}else{var p,m=this._internalColorTarget;m&&(null==(p=m.getColorTexture(0))||p.destroy(!0),m.destroy(!0),this._internalColorTarget=null)}this._drawRenderPass(t,i,r,n,a)},t2._drawRenderPass=function(t,r,n,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue,u=r.engine,d=r.scene,h=d.background,_=u._hardwareRenderer,f=this._internalColorTarget,p=f||r.renderTarget,m=f?dc.defaultViewport:r.viewport,g=!!f||r.renderTarget&&void 0==n;t.flipProjection!==g&&(t.rendererUpdateFlag|=cl.ProjectionMatrix,t.applyVirtualCamera(r._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,a,n);var v=r.clearFlags&~(null!=i?i:e.CameraClearFlags.None),y=h.solidColor;if(v!==e.CameraClearFlags.None&&_.clearRenderTarget(r.engine,v,y),s.render(t,e.PipelineStage.Forward),l.render(t,e.PipelineStage.Forward),v&e.CameraClearFlags.Color&&(h.mode===e.BackgroundMode.Sky?h.sky._render(t):h.mode===e.BackgroundMode.Texture&&h.texture&&this._drawBackgroundTexture(u,h)),r.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(r,p.getColorTexture(0)),x.onRender(t),_.activeRenderTarget(p,m,t.flipProjection,a,n)}else r.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,e.PipelineStage.Forward);var b=d._postProcessManager,T=r.renderTarget;r.enablePostProcess&&b.hasActiveEffect?b._render(t,f,T):f&&(f._blitRenderTarget(),dc.blitTexture(u,f.getColorTexture(0),T,0,r.viewport)),null==T||T._blitRenderTarget(),null==T||T.generateMipmaps()},t2.pushRenderElement=function(t,r){r.renderQueueFlags=0;for(var n=r.subRenderElements,a=0,i=n.length;a<i;++a){var o=n[a],s=o.material,l=s.renderStates,c=s.shader.subShaders[0],u=t.replacementShader;if(u){var d=u.subShaders,h=t.replacementTag;if(h){for(var _=!1,f=0,p=d.length;f<p;f++){var m=d[f];m.getTagValue(h)===c.getTagValue(h)&&(this.pushRenderElementByType(r,o,m.passes,l),_=!0)}_||t.replacementFailureStrategy!==e.ReplacementFailureStrategy.KeepOriginalShader||this.pushRenderElementByType(r,o,c.passes,l)}else this.pushRenderElementByType(r,o,d[0].passes,l)}else this.pushRenderElementByType(r,o,c.passes,l)}},t2.pushRenderElementByType=function(t,r,n,a){for(var i=this._cullingResults,o=0,s=n.length;o<s;o++){var l=void 0,c=n[o],u=c._renderState;u?(u._applyRenderQueueByShaderData(c._renderStateDataMap,r.material.shaderData),l=u.renderQueueType):l=a[o].renderQueueType;var d=1<<l;if(r.shaderPasses=n,r.renderQueueFlags|=d,!(t.renderQueueFlags&d)){switch(l){case e.RenderQueueType.Opaque:i.opaqueQueue.pushRenderElement(t);break;case e.RenderQueueType.AlphaTest:i.alphaTestQueue.pushRenderElement(t);break;case e.RenderQueueType.Transparent:i.transparentQueue.pushRenderElement(t)}t.renderQueueFlags|=d}}},t2._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,a=t.canvas,i=r._material,o=r._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(a.width,a.height),r._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,u4._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._applyStates(t,!1,s._renderStateDataMap,i.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},t2._prepareRender=function(e){for(var t=e.camera,r=t.engine,n=t.scene._componentsManager._renderers,a=n._elements,i=n.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._prepareRender(e),o._renderFrameCount=r.time.frameCount)}},t1);(t3=cd||(cd={}))[t3.None=0]="None",t3[t3.Opaque=1]="Opaque",t3[t3.AlphaTest=2]="AlphaTest",t3[t3.Transparent=4]="Transparent",t3[t3.All=7]="All";var dC=((t8=(t4=function(){this.subRenderElements=[]}).prototype).set=function(e,t){this.priority=e,this.distanceForSort=t,this.subRenderElements.length=0},t8.addSubRenderElement=function(e){this.subRenderElements.push(e)},t8.dispose=function(){this.subRenderElements.length=0},t4),dS=((t9=(t5=function(){}).prototype).set=function(e,t,r,n,a,i){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n,this.texture=a,this.subChunk=i},t9.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null,this.shaderPasses=null,this.shaderData&&(this.shaderData=null),this.texture&&(this.texture=null),this.subChunk&&(this.subChunk=null)},t5),dA=function(t){function r(n){var a;return(a=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,a._maskIndex=-1,a._sprite=null,a._automaticWidth=0,a._automaticHeight=0,a._customWidth=void 0,a._customHeight=void 0,a._flipX=!1,a._flipY=!1,a._alphaCutoff=.5,u7.resetData(ur(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(r._alphaCutoffProperty,a._alphaCutoff),a._renderElement=new dC,a._renderElement.addSubRenderElement(new dS),a._onSpriteChange=a._onSpriteChange.bind(ur(a)),a}uo(r,t);var n=r.prototype;return n._updateTransformShaderData=function(e,r,n){t.prototype._updateTransformShaderData.call(this,e,r,!0)},n._cloneTo=function(e,r,n){t.prototype._cloneTo.call(this,e,r,n),e.sprite=this._sprite},n._canBatch=function(e,t){return uC.canBatchSpriteMask(e,t)},n._batch=function(e,t){uC.batchFor2D(e,t)},n._onEnableInScene=function(){t.prototype._onEnableInScene.call(this),this.scene._maskManager.addSpriteMask(this)},n._onDisableInScene=function(){t.prototype._onDisableInScene.call(this),this.scene._maskManager.removeSpriteMask(this)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManagerMask},n._updateBounds=function(e){this.sprite?u7.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&ci.WorldVolume&&(u7.updatePositions(this),this._dirtyUpdateFlag&=~ci.WorldVolume),2&this._dirtyUpdateFlag&&(u7.updateUVs(this),this._dirtyUpdateFlag&=-3);var a=this._renderElement,i=a.subRenderElements[0];a.set(this.priority,this._distanceForSort);var o=this._subChunk;i.set(this,r,o.chunk.primitive,o.subMesh,this.sprite.texture,o),i.shaderPasses=r.shader.subShaders[0].passes,i.renderQueueFlags=cd.All,a.addSubRenderElement(i)}}},n._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),t.prototype._onDestroy.call(this),this._sprite=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null),this._renderElement=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 l7.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case l7.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ci.WorldVolume);break;case l7.region:case l7.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case l7.atlasRegion:this._dirtyUpdateFlag|=2;break;case l7.pivot:this._dirtyUpdateFlag|=ci.WorldVolume;break;case l7.destroy:this.sprite=null}},ua(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|=ci.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|=ci.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ci.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ci.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(r._textureProperty,e.texture)):this.shaderData.setTexture(r._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(r._alphaCutoffProperty,e))}}]),r}(e.Renderer);dA._textureProperty=uF.getByName("renderer_MaskTexture"),dA._alphaCutoffProperty=uF.getByName("renderer_MaskAlphaCutoff"),us([uu],dA.prototype,"influenceLayers",void 0),us([uc],dA.prototype,"_subChunk",void 0),us([uc],dA.prototype,"_maskIndex",void 0),us([uc],dA.prototype,"_sprite",void 0),us([uc],dA.prototype,"_automaticWidth",void 0),us([uc],dA.prototype,"_automaticHeight",void 0),us([uu],dA.prototype,"_customWidth",void 0),us([uu],dA.prototype,"_customHeight",void 0),us([uu],dA.prototype,"_flipX",void 0),us([uu],dA.prototype,"_flipY",void 0),us([uu],dA.prototype,"_alphaCutoff",void 0),us([uc],dA.prototype,"_onSpriteChange",null),(t6=ch||(ch={}))[t6.UV=2]="UV",t6[t6.RenderData=3]="RenderData",t6[t6.AutomaticSize=4]="AutomaticSize",t6[t6.All=7]="All";var dM=function(e){this.resource=e},dR=(uo(t7=function(e){var t;return(t=up.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},up),(re=t7.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=r+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new c5(this._curX,this._curY),i.setPixelBuffer(n,0,this._curX,this._curY,t,r),i.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+a,!0},re.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},re.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},re._onDestroy=function(){up.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t7),dE=((rt=function(){}).textContext=function(){var e=rt._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},rt._textContext=e}return e},rt.measureFont=function(e){var t=rt._fontSizeInfoCache,r=t[e];return r||(r=rt._measureFontOrChar(e,rt._measureString,!1),t[e]=r),r},rt.getNativeFontString=function(t,r,n){var a=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rt._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=r+"px "+t},rt.measureChar=function(e,t){return rt._measureFontOrChar(t,e,!0)},rt.measureTextWithWrap=function(t){var r=t._getSubFont(),n=r.nativeFontString,a=rt.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=h3._pixelsPerUnit,u=a.size+t.lineSpacing*c,d=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,T=0,C=0,S=!1,A=0,M=p.length;A<M;++A){var R=p[A],E=rt._getCharInfo(R,n,r),w=R.charCodeAt(0),P=32===w;if(!P||!S||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=E.w,B=E.offsetY,D=.5*E.h,I=D+B,O=D-B;F?(m.length>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),S=!0,x=m,b=g,T=v,C=y):(x+=m,b+=g,T=Math.max(T,v),C=Math.max(C,y)),m="",g=v=y=0),b+L>d&&b>0?(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),S=!0,P?(x="",b=T=C=0):(x=R,b=E.xAdvance,T=I,C=O)):(x+=R,b+=E.xAdvance,T=Math.max(T,I),C=Math.max(C,O))):g+E.w>d?(b>0&&(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),x="",b=T=C=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),S=!0,m=R,g=E.xAdvance,v=I,y=O):(m+=R,g+=E.xAdvance,v=Math.max(v,I),y=Math.max(y,O))}}g>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,T=Math.max(T,v),C=Math.max(C,y))),b>0&&(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b))}var V=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(V=u*o.length),{width:h,height:V,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},rt.measureTextWithoutWrap=function(t){var r=t._getSubFont(),n=r.nativeFontString,a=rt.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=h3._pixelsPerUnit,d=a.size+t.lineSpacing*u,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=rt._getCharInfo(f[v],n,r);p+=x.xAdvance;var b=x.offsetY,T=.5*x.h,C=T+b,S=T-b;m<C&&(m=C),g<S&&(g=S)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},rt.getNativeFontHash=function(t,r,n){var a=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rt._genericFontFamilies.indexOf(t)||(t=""+t),a+=r+"px"+t},rt._measureFontOrChar=function(e,t,r){var n,a=rt.textContext(),i=a.canvas,o=a.context;o.font=e;var s=o.measureText(t),l=Math.max(1,Math.round(s.actualBoundingBoxRight-s.actualBoundingBoxLeft||s.width)),c=Math.ceil(o.measureText(rt._measureBaseline).width),u=c*rt._heightMultiplier;c=rt._baselineMultiplier*c|0;var d=rt._extendHeight;u+=d,c+=.5*d,i.width=l,i.height=u,o.font=e,o.fillStyle="#000",o.clearRect(0,0,l,u),o.textBaseline="middle",o.fillStyle="#fff",o.fillText(t,0,c);for(var h=o.getImageData(0,0,l,u).data,_=h.length,f=-1,p=-1,m=0,g=0,v=0,y=i.width,x=1/y,b=0;b<_;b+=4)0!==h[b+3]?(n=~~(.25*b*x),-1===f&&(f=n),n>p&&(p=n)):h[b]=h[b+1]=h[b+2]=255;if(-1!==f&&-1!==p&&(v=(m=c-f)+(g=p-c+1)),!r)return{ascent:m,descent:g,size:v};var T=null;if(v>0){var C=4*y;T=new Uint8Array(h.buffer,f*C,v*C)}return{char:t,x:0,y:0,w:l,h:v,offsetX:0,offsetY:(m-g)*.5,xAdvance:l,uvs:[new c5,new c5,new c5,new c5],ascent:m,descent:g,index:0,data:T}},rt._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=rt.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},rt._pushLine=function(e,t,r,n,a,i,o){e.push(n),t.push(a),r.push({ascent:i,descent:o,size:i+o})},rt);dE._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],dE._extendHeight=0,dE._measureString="|\xc9q\xc5",dE._measureBaseline="M",dE._heightMultiplier=2,dE._baselineMultiplier=1.4,dE._fontSizeInfoCache={},dE._textContext=null;var dw=((rn=(rr=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},rn._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},rn._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},rn._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var a=t[r].getCharInfo(e);if(a)return a}return null},rn._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},rn._getLastIndex=function(){return this._lastIndex},rn._createFontAtlas=function(){var t,r=this._engine,n=new dR(r),a=new di(r,256,256,e.TextureFormat.R8G8B8A8,!1);a.filterMode=e.TextureFilterMode.Bilinear,n.texture=a,n.isGCIgnored=a.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return r.resourceManager.addContentRestorer(new(uo(t=function(){return dM.call(this,n)},dM),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var a=t[n],o=dE.measureChar(a.char,i).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}r.generateMipmaps()},t)),n},rr),dP=(uo(ra=function(e,t){var r;return void 0===t&&(t=""),(r=up.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},up),(ri=ra.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,a=n[r];return a||(a=new dw(this.engine),n[r]=a),a},ri._onDestroy=function(){up.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]},ra.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new ra(e,t),r[t]=n),n}return null},ua(ra,[{key:"name",get:function(){return this._name}}]),ra),dF=((ro=function(){this.localPositions=new c9}).prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},ro);dF.triangles=[0,2,1,2,0,3];var dL=(rs=e.Renderer,uo(rl=function(t){(r=rs.call(this,t)||this)._textChunks=[],r._subFont=null,r._dirtyFlag=15,r._color=new c6(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new cJ,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;var r,n=ur(r).engine;return r._font=n._textDefaultFont,r._addResourceReferCount(r._font,1),r.setMaterial(n._textDefaultMaterial),r._color._onValueChanged=r._onColorChanged.bind(ur(r)),r},rs),(rc=rl.prototype)._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),rs.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},rc._cloneTo=function(e,t,r){rs.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},rc._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rc._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rc._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rc._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},rc._updateTransformShaderData=function(e,t,r){rs.prototype._updateTransformShaderData.call(this,e,t,!0)},rc._canBatch=function(e,t){return uC.canBatchSprite(e,t)},rc._batch=function(e,t){uC.batchFor2D(e,t)},rc._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},rc._updateBounds=function(e){cJ.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rc._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)),this._isContainDirtyFlag(32)&&(this._updateColor(),this._setDirtyFlagFalse(32));var t=e.camera,r=t.engine,n=r._textSubRenderElementPool,a=this.getMaterial(),i=r._renderElementPool.get();i.set(this.priority,this._distanceForSort);for(var o=this._textChunks,s=0,l=o.length;s<l;++s){var c=o[s],u=c.subChunk,d=c.texture,h=n.get();h.set(this,a,u.chunk.primitive,u.subMesh,d,u),h.shaderData||(h.shaderData=new u9(cn.RenderElement)),h.shaderData.setTexture(rl._textureProperty,d),i.addSubRenderElement(h)}t._renderPipeline.pushRenderElement(e,i)}},rc._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}},rc._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=dE.getNativeFontString(e.name,this.fontSize,this.fontStyle)},rc._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=e[0],r=e[1],n=e[2],a=e[4],i=e[5],o=e[6],s=e[12],l=e[13],c=e[14],u=rl._tempVec31.set(a,i,o),d=rl._tempVec30.set(t,r,n),h=rl._worldPositions,_=h[0],f=h[1],p=h[2],m=h[3],g=this._textChunks,v=0,y=g.length;v<y;++v)for(var x=g[v],b=x.subChunk,T=x.charRenderInfos,C=0,S=T.length;C<S;++C){var A=T[C],M=A.localPositions,R=M.x,E=M.y;_.set(R*t+E*a+s,R*r+E*i+l,R*n+E*o+c),cQ.scale(d,M.z-R,f),cQ.add(_,f,f),cQ.scale(u,M.w-E,p),cQ.add(_,p,m),cQ.add(f,p,p);for(var w=b.chunk.vertices,P=0,F=b.vertexArea.start+36*A.indexInChunk;P<4;++P,F+=9)h[P].copyToArray(w,F)}},rc._updateColor=function(){for(var e=this._color,t=e.r,r=e.g,n=e.b,a=e.a,i=this._textChunks,o=0,s=i.length;o<s;++o)for(var l=i[o].subChunk,c=l.vertexArea,u=c.size/9,d=l.chunk.vertices,h=0,_=c.start+5;h<u;++h,_+=9)d[_]=t,d[_+1]=r,d[_+2]=n,d[_+3]=a},rc._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,a=rl._charRenderInfos,i=this._subFont,o=this.enableWrapping?dE.measureTextWithWrap(this):dE.measureTextWithoutWrap(this),s=o.height,l=o.lines,c=o.lineWidths,u=o.lineHeight,d=o.lineMaxSizes,h=this.engine._charRenderInfoPool,_=l.length,f=0;if(_>0){var p=h3._pixelsPerUnit,m=this.horizontalAlignment,g=1/p,v=.5*(this.width*p),y=this.height*p,x=.5*u,b=0,T=.5*u-d[0].ascent,C=.5*u-d[_-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:b=.5*y-x+T;break;case e.TextVerticalAlignment.Center:b=.5*s-x-(C-T)*.5;break;case e.TextVerticalAlignment.Bottom:b=s-.5*y-x-C}for(var S=-1,A=Number.MAX_SAFE_INTEGER,M=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER,w=0;w<_;++w){var P=c[w];if(P>0){var F=l[w],L=0,B=-1;switch(S<0&&(S=w),m){case e.TextHorizontalAlignment.Left:L=-v;break;case e.TextHorizontalAlignment.Center:L=-(.5*P);break;case e.TextHorizontalAlignment.Right:L=v-P}for(var D=0,I=F.length;D<I;++D){var O=F[D],V=i._getCharInfo(O);if(V.h>0){B<0&&(B=D);var N=a[f++]=h.get(),k=N.localPositions;N.texture=i._getTextureByIndex(V.index),N.uvs=V.uvs;var z=V.w,U=V.ascent,G=V.descent,H=L*g,W=(L+z)*g,j=(b+U)*g,K=(b-G)*g;k.set(H,j,W,K),w===S&&(E=Math.max(E,j)),M=Math.min(M,K),D===B&&(A=Math.min(A,H)),R=Math.max(R,W)}L+=V.xAdvance}}b-=u}S<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(A,M,0),n.set(R,E,0))}else r.set(0,0,0),n.set(0,0,0);if(i._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==f){var X=this._textChunks,Y=new dB;X.push(Y);var q=this._getChunkManager().maxVertexCount,Q=a[0],Z=Q.texture;Y.texture=Z;var J=Y.charRenderInfos;J.push(Q);for(var $=1;$<f;++$){var ee=a[$],et=ee.texture;(Z!==et||4*J.length+4>q)&&(this._buildChunk(Y,J.length),Y=new dB,X.push(Y),Z=et,Y.texture=et,J=Y.charRenderInfos),J.push(ee)}var er=J.length;er>0&&this._buildChunk(Y,er),a.length=0}},rc._onTransformChanged=function(e){rs.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},rc._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},rc._buildChunk=function(e,t){for(var r=this.color,n=r.r,a=r.g,i=r.b,o=r.a,s=dF.triangles,l=s.length,c=e.subChunk=this._getChunkManager().allocateSubChunk(4*t),u=c.chunk.vertices,d=c.indices=[],h=e.charRenderInfos,_=0,f=0,p=0,m=c.vertexArea.start+3;_<t;++_,p+=4){var g=h[_];g.indexInChunk=_;for(var v=0;v<l;++v)d[f++]=s[v]+p;for(var y=0;y<4;++y,m+=9)g.uvs[y].copyToArray(u,m),u[m+2]=n,u[m+3]=a,u[m+4]=i,u[m+5]=o}return c},rc._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,r=this._getChunkManager(),n=0,a=e.length;n<a;++n){for(var i=e[n],o=i.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,r.freeSubChunk(i.subChunk),i.subChunk=null,i.texture=null}e.length=0},rc._onColorChanged=function(){this._setDirtyFlagTrue(32)},ua(rl,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),rl);dL._textureProperty=uF.getByName("renderElement_TextTexture"),dL._tempVec30=new cQ,dL._tempVec31=new cQ,dL._worldPositions=[new cQ,new cQ,new cQ,new cQ],dL._charRenderInfos=[],us([uc],dL.prototype,"_textChunks",void 0),us([uu],dL.prototype,"_subFont",void 0),us([uc],dL.prototype,"_dirtyFlag",void 0),us([uh],dL.prototype,"_color",void 0),us([uu],dL.prototype,"_text",void 0),us([uu],dL.prototype,"_width",void 0),us([uu],dL.prototype,"_height",void 0),us([uc],dL.prototype,"_localBounds",void 0),us([uu],dL.prototype,"_font",void 0),us([uu],dL.prototype,"_fontSize",void 0),us([uu],dL.prototype,"_fontStyle",void 0),us([uu],dL.prototype,"_lineSpacing",void 0),us([uu],dL.prototype,"_horizontalAlignment",void 0),us([uu],dL.prototype,"_verticalAlignment",void 0),us([uu],dL.prototype,"_enableWrapping",void 0),us([uu],dL.prototype,"_overflowMode",void 0),us([uc],dL.prototype,"_onColorChanged",null);var dB=function(){this.charRenderInfos=[]};(ru=c_||(c_={}))[ru.SubFont=1]="SubFont",ru[ru.LocalPositionBounds=2]="LocalPositionBounds",ru[ru.WorldPosition=4]="WorldPosition",ru[ru.WorldBounds=8]="WorldBounds",ru[ru.MaskInteraction=16]="MaskInteraction",ru[ru.Color=32]="Color",ru[ru.Position=14]="Position",ru[ru.Font=15]="Font",e.BufferUsage=void 0,(rd=e.BufferUsage||(e.BufferUsage={}))[rd.Static=0]="Static",rd[rd.Dynamic=1]="Dynamic",rd[rd.Stream=2]="Stream",e.SetDataOptions=void 0,(rh=e.SetDataOptions||(e.SetDataOptions={}))[rh.None=0]="None",rh[rh.Discard=1]="Discard";var dD=(uo(r_=function(t,r,n,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=u8.call(this,t)||this)._dataUpdateManager=new ub,o._engine=t,o._type=r,o._bufferUsage=a,o._readable=i,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,a),i&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,a,n),i){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},u8),(rf=r_.prototype).bind=function(){this._platformBuffer.bind()},rf.setData=function(t,r,n,a,i){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,a,i),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=a?s*a:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,u=new Uint8Array(o,c,l);this._data.set(u,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},rf.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},rf.markAsUnreadable=function(){this._data=null,this._readable=!1},rf._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},rf._onDestroy=function(){u8.prototype._onDestroy.call(this),this._platformBuffer.destroy()},ua(r_,[{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."}}]),r_);e.IndexFormat=void 0,(rp=e.IndexFormat||(e.IndexFormat={}))[rp.UInt8=0]="UInt8",rp[rp.UInt16=1]="UInt16",rp[rp.UInt32=2]="UInt32",e.VertexElementFormat=void 0,(rm=e.VertexElementFormat||(e.VertexElementFormat={}))[rm.Float=0]="Float",rm[rm.Vector2=1]="Vector2",rm[rm.Vector3=2]="Vector3",rm[rm.Vector4=3]="Vector4",rm[rm.Byte4=4]="Byte4",rm[rm.UByte4=5]="UByte4",rm[rm.NormalizedByte4=6]="NormalizedByte4",rm[rm.NormalizedUByte4=7]="NormalizedUByte4",rm[rm.Short2=8]="Short2",rm[rm.UShort2=9]="UShort2",rm[rm.NormalizedShort2=10]="NormalizedShort2",rm[rm.NormalizedUShort2=11]="NormalizedUShort2",rm[rm.Short4=12]="Short4",rm[rm.UShort4=13]="UShort4",rm[rm.NormalizedShort4=14]="NormalizedShort4",rm[rm.NormalizedUShort4=15]="NormalizedUShort4";var dI=((rg=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}},rg._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},rg._getElementInfo=function(t){var r,n,a,i=!1;switch(t){case e.VertexElementFormat.Float:r=1,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:r=2,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:r=3,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:r=4,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:r=4,n=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:r=4,n=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:r=4,n=e.DataType.BYTE,i=!0,a=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,i=!0,a=1/255;break;case e.VertexElementFormat.Short2:r=2,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:r=2,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:r=2,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535;break;case e.VertexElementFormat.Short4:r=4,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:r=4,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:r=4,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535}return{size:r,type:n,normalized:i,normalizedScaleFactor:a}},rg),dO=(ua(rv=function(e,t,r,n,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=dI._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)},[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),rv);e.BufferBindFlag=void 0,(ry=e.BufferBindFlag||(e.BufferBindFlag={}))[ry.VertexBuffer=0]="VertexBuffer",ry[ry.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(rx=e.MeshTopology||(e.MeshTopology={}))[rx.Points=0]="Points",rx[rx.Lines=1]="Lines",rx[rx.LineLoop=2]="LineLoop",rx[rx.LineStrip=3]="LineStrip",rx[rx.Triangles=4]="Triangles",rx[rx.TriangleStrip=5]="TriangleStrip",rx[rx.TriangleFan=6]="TriangleFan",e.BlendMode=void 0,(rb=e.BlendMode||(e.BlendMode={}))[rb.Normal=0]="Normal",rb[rb.Additive=1]="Additive",e.RenderFace=void 0,(rT=e.RenderFace||(e.RenderFace={}))[rT.Front=0]="Front",rT[rT.Back=1]="Back",rT[rT.Double=2]="Double";var dV=(uo(rC=function(e,t){var r;return(r=up.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new u9(cn.Material),r.shader=t,r},up),(rS=rC.prototype).clone=function(){var e=new rC(this._engine,this.shader);return this.cloneTo(e),e},rS.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),u_.deepCloneObject(this.renderStates,e.renderStates,new Map)},rS._addReferCount=function(e){this._destroyed||(up.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},rS._onDestroy=function(){up.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},ua(rC,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,r=this._getReferCount();r>0&&(null==(t=this._shader)||t._addReferCount(-r),e._addReferCount(r)),this._shader=e;for(var n=this._renderStates,a=n.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)n.push(new u3);else n.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rC),dN=function(t){function r(n,a){(i=t.call(this,n,a)||this)._renderFace=e.RenderFace.Front,i._isTransparent=!1,i._blendMode=e.BlendMode.Normal;var i,o=ur(i).shaderData;return o.setFloat(r._alphaCutoffProp,0),o.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque),i}uo(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var a=this.renderStates;if(a.length<t)throw"Pass should less than pass count.";var i=a[t],o=this.shaderData;n?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=e.RenderQueueType.Transparent,o.enableMacro(r._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=o.getFloat(r._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,o.disableMacro(r._transparentMacro))},n.setBlendMode=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";var a=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.One,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add}},n.setRenderFace=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";switch(r){case e.RenderFace.Front:n[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:n[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:n[t].rasterState.cullMode=e.CullMode.Off}},n.clone=function(){var e=new r(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},ua(r,[{key:"shader",get:function(){return this._shader},set:function(t){var r,n=this._getReferCount();n>0&&(null==(r=this._shader)||r._addReferCount(-n),t._addReferCount(n)),this._shader=t;for(var a=this._renderStates,i=a.length,o=0,s=t.subShaders,l=0;l<s.length;l++)o=Math.max(s[l].passes.length,o);if(i<o)for(var c=i;c<o;c++)a.push(new u3),this.setBlendMode(c,e.BlendMode.Normal);else a.length=o}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(t){if(t!==this._isTransparent){this.setIsTransparent(0,t);var n=this.shaderData;t?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.getFloat(r._alphaCutoffProp)?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque),this._isTransparent=t}}},{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.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest)):(n.disableMacro(r._alphaCutoffMacro),this._isTransparent?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque));for(var a=this.renderStates,i=0,o=a.length;i<o;i++){var s=a[i];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}n.setFloat(r._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),r}(dV);dN._shadowCasterRenderQueueProp=uF.getByName("material_ShadowCasterRenderQueue"),dN._baseTextureMacro=uz.getByName("MATERIAL_HAS_BASETEXTURE"),dN._normalTextureMacro=uz.getByName("MATERIAL_HAS_NORMALTEXTURE"),dN._emissiveTextureMacro=uz.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),dN._transparentMacro=uz.getByName("MATERIAL_IS_TRANSPARENT"),dN._baseColorProp=uF.getByName("material_BaseColor"),dN._baseTextureProp=uF.getByName("material_BaseTexture"),dN._tilingOffsetProp=uF.getByName("material_TilingOffset"),dN._normalTextureProp=uF.getByName("material_NormalTexture"),dN._normalIntensityProp=uF.getByName("material_NormalIntensity"),dN._emissiveColorProp=uF.getByName("material_EmissiveColor"),dN._emissiveTextureProp=uF.getByName("material_EmissiveTexture"),dN._alphaCutoffProp=uF.getByName("material_AlphaCutoff"),dN._alphaCutoffMacro=uz.getByName("MATERIAL_IS_ALPHA_CUTOFF");var dk=function(e){function t(r){var n,a=(n=e.call(this,r,u4.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new c6(1,1,1,1)),a.setColor(t._specularColorProp,new c6(1,1,1,1)),a.setColor(t._emissiveColorProp,new c6(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new c9(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),n}return uo(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ua(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}(dN);dk._specularColorProp=uF.getByName("material_SpecularColor"),dk._shininessProp=uF.getByName("material_Shininess"),dk._specularTextureProp=uF.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rA=e.TextureCoordinate||(e.TextureCoordinate={}))[rA.UV0=0]="UV0",rA[rA.UV1=1]="UV1",rA[rA.UV2=2]="UV2",rA[rA.UV3=3]="UV3",rA[rA.UV4=4]="UV4",rA[rA.UV5=5]="UV5",rA[rA.UV6=6]="UV6",rA[rA.UV7=7]="UV7";var dz=function(t){function r(n,a){var i,o=(i=t.call(this,n,a)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new c6(1,1,1,1)),o.setColor(r._emissiveColorProp,new c6(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new c9(1,1,0,0)),o.setFloat(r._normalIntensityProp,1),o.setFloat(r._occlusionTextureIntensityProp,1),o.setFloat(r._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(r._clearCoatProp,0),o.setFloat(r._clearCoatRoughnessProp,0),i}return uo(r,t),ua(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&&uP.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}(dN);dz._occlusionTextureIntensityProp=uF.getByName("material_OcclusionIntensity"),dz._occlusionTextureCoordProp=uF.getByName("material_OcclusionTextureCoord"),dz._occlusionTextureProp=uF.getByName("material_OcclusionTexture"),dz._clearCoatProp=uF.getByName("material_ClearCoat"),dz._clearCoatTextureProp=uF.getByName("material_ClearCoatTexture"),dz._clearCoatRoughnessProp=uF.getByName("material_ClearCoatRoughness"),dz._clearCoatRoughnessTextureProp=uF.getByName("material_ClearCoatRoughnessTexture"),dz._clearCoatNormalTextureProp=uF.getByName("material_ClearCoatNormalTexture");var dU=function(e){function t(r){(n=e.call(this,r,u4.find("pbr"))||this)._anisotropyRotation=0;var n,a=n.shaderData;return a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new cQ(1,0,0)),n}return uo(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ua(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(t._anisotropyInfoProp);!!r.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(t._anisotropyInfoProp),n=cq.degreeToRadFactor*e;r.x=Math.cos(n),r.y=Math.sin(n)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),t}(dz);dU._metallicProp=uF.getByName("material_Metal"),dU._roughnessProp=uF.getByName("material_Roughness"),dU._roughnessMetallicTextureProp=uF.getByName("material_RoughnessMetallicTexture"),dU._iorProp=uF.getByName("material_IOR"),dU._anisotropyInfoProp=uF.getByName("material_AnisotropyInfo"),dU._anisotropyTextureProp=uF.getByName("material_AnisotropyTexture");var dG=function(e){function t(r){var n;return(n=e.call(this,r,u4.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new c6(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return uo(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ua(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}(dz);dG._specularColorProp=uF.getByName("material_PBRSpecularColor"),dG._glossinessProp=uF.getByName("material_Glossiness"),dG._specularGlossinessTextureProp=uF.getByName("material_SpecularGlossinessTexture"),dG._specularGlossinessTextureMacro=uz.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var dH=function(e){function t(r){var n,a=(n=e.call(this,r,u4.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new c6(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new c9(1,1,0,0)),n}return uo(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ua(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}(dN),dW=((rM=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new ub,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},ua(rM,[{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)}}]),rM);(rR=cf||(cf={}))[rR.Position=1]="Position",rR[rR.Normal=2]="Normal",rR[rR.Tangent=4]="Tangent",rR[rR.All=7]="All";var dj=((rw=(rE=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new ub,this._dataChangeManager=new ub,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var a=new dW(e,t,r,n);return this._addFrame(a),a}this._addFrame(e)},rw.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()},rw._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},rw._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(cf.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},rw._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))},rw._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},ua(rE,[{key:"frames",get:function(){return this._frames}}]),rE),dK=(ua(rP=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),rP),dX=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},dY=(uo(rF=function(){return dX.apply(this,arguments)},dX),rF.prototype.dispose=function(){},rF),dq=(uo(rL=function(e){var t;return(t=u8.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(ur(t)),t},u8),(rB=rL.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,a=t[n];a&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(a),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},rB.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},rB.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},rB.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,a=n[e];a&&delete r[a.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},rB.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,a=r.length;n<a;n++){var i=r[n];delete t[i.attribute]}r.length=e},rB.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),a=this.vertexBufferBindings;n>0&&(null==(r=a[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),a[e]=t,this._bufferStructChanged=!0},rB.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this.setVertexBufferBinding(t+i,e[i])},rB.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=dI._getGLIndexType(e.format),this._glIndexByteCount=dI._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},rB.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},rB._addReferCount=function(e){u8.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,a=0,i=n.length;a<i;a++)null==(r=n[a])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},rB._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},rB._onDestroy=function(){u8.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},ua(rL,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),rL),dQ=(uo(rD=function(e,t){(r=up.call(this,e)||this)._updateFlagManager=new ub,r._bounds=new cJ,r._subMeshes=[],r.name=t,r._primitive=new dq(e),r._onBoundsChanged=r._onBoundsChanged.bind(ur(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},up),(rI=rD.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new dY(t,r,n)),this._subMeshes.push(t),t},rI.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},rI.clearSubMesh=function(){this._subMeshes.length=0},rI._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},rI._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},rI._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},rI._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},rI._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},rI._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},rI._addReferCount=function(e){up.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},rI._onDestroy=function(){up.prototype._onDestroy.call(this),this._primitive.destroy()},rI._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},rI._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},rI._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},ua(rD,[{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}}]),rD);(rO=cp||(cp={}))[rO.Bounds=1]="Bounds",rO[rO.VertexElements=2]="VertexElements";var dZ=(ua(rV=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),rV),dJ=(uo(rN=function(){return dQ.apply(this,arguments)},dQ),(rk=rN.prototype).setVertexElements=function(e){this._setVertexElements(e)},rk.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dZ(e,t));var i=this._primitive.vertexBufferBindings;i.length<=r&&(i.length=r+1),this._setVertexBufferBinding(a?t:r,n)},rk.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this._setVertexBufferBinding(t+i,e[i])},rk.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new dK(e,t))),this._setIndexBufferBinding(r)},ua(rN,[{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}}]),rN),d$=(rz=e.Renderer,uo(rU=function(e){var t;return(t=rz.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(ur(t)),t},rz),(rG=rU.prototype)._onDestroy=function(){var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),rz.prototype._onDestroy.call(this)},rG._cloneTo=function(e,t,r){rz.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},rG._prepareRender=function(e){if(!this._mesh){uP.error("mesh is null.");return}if(this._mesh.destroyed){uP.error("mesh is destroyed.");return}rz.prototype._prepareRender.call(this,e)},rG._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;cJ.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},rG._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(rU._uvMacro),r.disableMacro(rU._uv1Macro),r.disableMacro(rU._normalMacro),r.disableMacro(rU._tangentMacro),r.disableMacro(rU._enableVertexColorMacro);for(var a=0,i=n.length;a<i;a++)switch(n[a].attribute){case"TEXCOORD_0":r.enableMacro(rU._uvMacro);break;case"TEXCOORD_1":r.enableMacro(rU._uv1Macro);break;case"NORMAL":r.enableMacro(rU._normalMacro);break;case"TANGENT":r.enableMacro(rU._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(rU._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}var o=this._materials,s=this._engine,l=t.subMeshes,c=s._renderElementPool.get();c.set(this.priority,this._distanceForSort);for(var u=s._subRenderElementPool,d=0,h=l.length;d<h;d++){var _=o[d];if(_){(_.destroyed||_.shader.destroyed)&&(_=this.engine._meshMagentaMaterial);var f=u.get();f.set(this,_,t._primitive,l[d]),c.addSubRenderElement(f)}}e.camera._renderPipeline.pushRenderElement(e,c)},rG._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},rG._onMeshChanged=function(e){e&cp.Bounds&&(this._dirtyUpdateFlag|=ci.WorldVolume),e&cp.VertexElements&&(this._dirtyUpdateFlag|=2)},ua(rU,[{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)}}]),rU);d$._uvMacro=uz.getByName("RENDERER_HAS_UV"),d$._uv1Macro=uz.getByName("RENDERER_HAS_UV1"),d$._normalMacro=uz.getByName("RENDERER_HAS_NORMAL"),d$._tangentMacro=uz.getByName("RENDERER_HAS_TANGENT"),d$._enableVertexColorMacro=uz.getByName("RENDERER_ENABLE_VERTEXCOLOR"),us([uc],d$.prototype,"_mesh",void 0),us([uc],d$.prototype,"_onMeshChanged",null),(rH=cm||(cm={}))[rH.VertexElementMacro=2]="VertexElementMacro",rH[rH.All=3]="All";var d0=((rj=(rW=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 c9,this._canUseTextureStoreData=!0,this._dataTextureInfo=new cQ,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(uO))},rj._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var n=this._subDataDirtyFlags,a=0,i=n.length;a<i;a++)n[a].destroy();n.length=0},rj._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(rW._blendShapeMacro),this._useTextureMode())e.enableMacro(rW._blendShapeTextureMacro),e.setTexture(rW._blendShapeTextureProperty,this._vertexTexture),e.setVector3(rW._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(rW._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var a=t._condensedBlendShapeWeights;a||(a=new Float32Array(n),t._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,a),e.setFloatArray(rW._blendShapeWeightsProperty,a),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(rW._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(rW._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(rW._blendShapeNormalMacro):e.disableMacro(rW._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(rW._blendShapeTangentMacro):e.disableMacro(rW._blendShapeTangentMacro)}else e.disableMacro(rW._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},rj._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},rj._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},rj._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},rj._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},rj._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,a=Math.max(r.length,t+1);n<a&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},rj._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,a=0,i=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<o;i++)t._setVertexElement(r++,new dO("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12,this._useBlendNormal&&(t._setVertexElement(r++,new dO("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12),this._useBlendTangent&&(t._setVertexElement(r++,new dO("TANGENT_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12);return r},rj._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))},rj._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},rj._createVertexBuffers=function(t,r){var n=this._engine,a=this._modelMesh,i=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),u=Math.ceil(i/c),d=s*t*Math.min(c,i);o.length=u,this._vertices=new Float32Array(d),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=i;for(var h=this._bufferBindingOffset,_=0;_<u;_++){var f=u-1,p=(_===f?i-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new dD(n,e.BufferBindFlag.VertexBuffer,m,g);a._setVertexBufferBinding(h+_,new dZ(v,p)),o[_]=v}},rj._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,a=n*t,i=1;a>r&&(i=Math.ceil(a/r),a=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new ds(this._engine,a,i,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*a*i*4),this._vertexTexture=o,this._dataTextureInfo.set(n,a,i)},rj._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,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=i[g],x=y.byteLength/(4*e),b=v*l,T=o[d];T||(o[d]=T=new c5),T.set(u+g,v*c);for(var C=m.deltaPositions,S=0;S<e;S++){var A=b+x*S,M=C[S];M&&(a[A]=M.x,a[A+1]=M.y,a[A+2]=M.z)}if(b+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var E=0;E<e;E++){var w=b+x*E,P=R[E];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var B=b+x*L,D=F[L];D&&(a[B]=D.x,a[B+1]=D.y,a[B+2]=D.z)}b+=3}(v===n-1||d===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},rj._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=i[o],c=n.width*n.height*4;if(t||l.flag){var 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(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,a)},rj._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;r&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&n++,i&&n++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=n},rj._attributeModeUpdateVertexElement=function(e,t,r,n){var a=this._vertexElementOffset+this._vertexElementCount*n,i=t[r],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++a];s+=12,u.bindingIndex=o,u.offset=s}},rj._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},rj._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<n)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<n;u++){var d=t[u];d<o&&(o=d,r=u)}}}},rW);d0._blendShapeMacro=uz.getByName("RENDERER_HAS_BLENDSHAPE"),d0._blendShapeTextureMacro=uz.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),d0._blendShapeNormalMacro=uz.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),d0._blendShapeTangentMacro=uz.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),d0._blendShapeWeightsProperty=uF.getByName("renderer_BlendShapeWeights"),d0._blendShapeTextureProperty=uF.getByName("renderer_BlendShapeTexture"),d0._blendShapeTextureInfoProperty=uF.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(rK=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",rK.Normal="NORMAL",rK.Color="COLOR_0",rK.Tangent="TANGENT",rK.BoneWeight="WEIGHTS_0",rK.BoneIndex="JOINTS_0",rK.UV="TEXCOORD_0",rK.UV1="TEXCOORD_1",rK.UV2="TEXCOORD_2",rK.UV3="TEXCOORD_3",rK.UV4="TEXCOORD_4",rK.UV5="TEXCOORD_5",rK.UV6="TEXCOORD_6",rK.UV7="TEXCOORD_7";var d1=(uo(rX=function(e,t){var r;return(r=dQ.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 cQ(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 d0(e,ur(r)),r},dQ),(rY=rX.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)},rY.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},rY.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},rY.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},rY.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},rY.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},rY.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},rY.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},rY.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},rY.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},rY.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},rY.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},rY.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]."}},rY.getUVs=function(t){switch(t=null!=t?t:0){case 0:var r=this._getVertexElementData(this._uv,e.VertexAttribute.UV,6,this._readVector2VertexData);return this._uv=r,r;case 1:var n=this._getVertexElementData(this._uv1,e.VertexAttribute.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var a=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=a,a;case 3:var i=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var o=this._getVertexElementData(this._uv4,e.VertexAttribute.UV4,10,this._readVector2VertexData);return this._uv4=o,o;case 5:var s=this._getVertexElementData(this._uv5,e.VertexAttribute.UV5,11,this._readVector2VertexData);return this._uv5=s,s;case 6:var l=this._getVertexElementData(this._uv6,e.VertexAttribute.UV6,12,this._readVector2VertexData);return this._uv6=l,l;case 7:var c=this._getVertexElementData(this._uv7,e.VertexAttribute.UV7,13,this._readVector2VertexData);return this._uv7=c,c}throw"The index of channel needs to be in range [0 - 7]."},rY.setIndices=function(t){this._indices!==t&&(this._indices=t,ul(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:ul(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:ul(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},rY.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},rY.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,a=0;a<n;a++)this._addVertexElement(t[a]);var i=this._primitive._vertexElementMap;i[e.VertexAttribute.Position]||this.setPositions(null),i[e.VertexAttribute.Normal]||this.setNormals(null),i[e.VertexAttribute.Color]||this.setColors(null),i[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),i[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),i[e.VertexAttribute.Tangent]||this.setTangents(null),i[e.VertexAttribute.UV]||this.setUVs(null,0),i[e.VertexAttribute.UV1]||this.setUVs(null,1),i[e.VertexAttribute.UV2]||this.setUVs(null,2),i[e.VertexAttribute.UV3]||this.setUVs(null,3),i[e.VertexAttribute.UV4]||this.setUVs(null,4),i[e.VertexAttribute.UV5]||this.setUVs(null,5),i[e.VertexAttribute.UV6]||this.setUVs(null,6),i[e.VertexAttribute.UV7]||this.setUVs(null,7);var o=this._internalVertexBufferCreatedInfo.z;-1!==o&&(null==(r=this._primitive.vertexBufferBindings[o])||r.buffer.destroy(),this._setVertexBufferBinding(o,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},rY.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dZ(e,t));var i=a?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,n),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},rY.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+r;n.length<i&&(n.length=i,a.length=i);for(var o=0;o<r;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},rY.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},rY.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},rY.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},rY.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},rY.uploadData=function(t){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(t),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var r=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,a=0,i=n.length;a<i;a++){var o=r[a];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[a])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,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 dK(u,this._indicesFormat));else{null==u||u.destroy();var d,h=new dD(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new dK(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))},rY.calculateTangents=function(){var e=this.getPositions(),t=this.getNormals(),r=this.getUVs();if(!t||!r)throw"Set normal and uv before calculation.";for(var n=this._indices,a=this.vertexCount,i=rX._tempVec0,o=rX._tempVec1,s=rX._tempVec2,l=rX._tempVec3,c=rX._tempVec4,u=n?n.length/3:e.length/3,d=Array(a),h=Array(a),_=0;_<a;_++)d[_]=new c9,h[_]=new cQ;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],b=r[p],T=r[m],C=r[g];cQ.subtract(y,v,i),cQ.subtract(x,v,o);var S=T.x-b.x,A=C.x-b.x,M=T.y-b.y,R=C.y-b.y,E=1/(S*R-A*M);cQ.scale(i,R*E,s),cQ.scale(o,M*E,c),cQ.subtract(s,c,s),cQ.scale(o,S*E,l),cQ.scale(i,A*E,c),cQ.subtract(l,c,l);var w=d[p];w.set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=d[m]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=d[g]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<a;P++){var F=t[P],L=h[P],B=d[P];s.set(B.x,B.y,B.z),cQ.cross(s,L,c);var D=cQ.dot(c,F)>0?1:-1;cQ.scale(F,cQ.dot(s,F),c),cQ.subtract(s,c,s),s.normalize(),B.set(s.x,s.y,s.z,D)}this.setTangents(d)},rY._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=function(){r._advancedDataSyncToBuffer||(a[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(i),dQ.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(i),(a[e]||(a[e]=new d2)).reset(),i()):e+1==n.length&&n.length--},rY._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)}},rY._onDestroy=function(){dQ.prototype._onDestroy.call(this),this._releaseCache(!0)},rY._getVertexElementData=function(e,t,r,n){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[r])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[r]=l,n.call(this,t))},rY._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)},rY._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},rY._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,a=this._internalVertexBufferCreatedInfo,i=r*n;if(a.x*a.y!==i){var o,s=a.z;-1!==s&&(null==(o=this._primitive.vertexBufferBindings[s])||o.buffer.destroy(),this._setVertexBufferBinding(s,null));var l=this._internalVertexBufferIndex,c=r*this.vertexCount>0;if(c){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var u=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,d=new dD(this._engine,e.BufferBindFlag.VertexBuffer,i,u,!0);this._setVertexBufferBinding(l,new dZ(d,r))}a.set(r,n,c?l:-1)}},rY._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new c5(e[t],e[t+1])})},rY._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new cQ(e[t],e[t+1],e[t+2])})},rY._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new c9(e[t],e[t+1],e[t+2],e[t+3])})},rY._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new c6(e[t],e[t+1],e[t+2],e[t+3])})},rY._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var a=r.vertexBufferBindings[n.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=n._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),u=n.offset,d=a.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},rY._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new dO(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=r,this._blendShapeManager._vertexElementOffset++}}else{var s=n[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~r):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},rY._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)},rY._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,r=e.length,n=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<r&&this._setVertexElementsLength(i)}},rY._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y)})},rY._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},rY._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},rY._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},rY._writeAdvancedVertexData=function(e,t,r){var n,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(n=this._advancedVertexDataVersions[t])?n:-1,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=i.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 b=(y*f+_)/p;if(r(h,b,y),m)for(var T=0;T<g;T++)h[b+T]/=v}u.uploadAdvancedData=!0}}},rY._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,a=this._advancedDataUpdateFlag,i=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,u=this._uv2,d=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&a&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),i&&16&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,i),o&&32&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),u&&256&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,u),d&&512&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,d),h&&1024&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},rY._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},rY._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}},rY._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}},rY._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,r=this._dataVersionCounter++,n=this._vertexBufferInfos,a=0,i=n.length;a<i;a++){var o=n[a];o&&(o.dataVersion=r)}}},ua(rX,[{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}}]),rX);d1._tempVec0=new cQ,d1._tempVec1=new cQ,d1._tempVec2=new cQ,d1._tempVec3=new cQ,d1._tempVec4=new cQ;var d2=((rq=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},rq);(rQ=cg||(cg={}))[rQ.None=0]="None",rQ[rQ.Position=1]="Position",rQ[rQ.Normal=2]="Normal",rQ[rQ.Color=4]="Color",rQ[rQ.Tangent=8]="Tangent",rQ[rQ.BoneWeight=16]="BoneWeight",rQ[rQ.BoneIndex=32]="BoneIndex",rQ[rQ.UV=64]="UV",rQ[rQ.UV1=128]="UV1",rQ[rQ.UV2=256]="UV2",rQ[rQ.UV3=512]="UV3",rQ[rQ.UV4=1024]="UV4",rQ[rQ.UV5=2048]="UV5",rQ[rQ.UV6=4096]="UV6",rQ[rQ.UV7=8192]="UV7",rQ[rQ.All=65535]="All",(rZ=cv||(cv={}))[rZ.Position=0]="Position",rZ[rZ.Normal=1]="Normal",rZ[rZ.Color=2]="Color",rZ[rZ.Tangent=3]="Tangent",rZ[rZ.BoneWeight=4]="BoneWeight",rZ[rZ.BoneIndex=5]="BoneIndex",rZ[rZ.UV=6]="UV",rZ[rZ.UV1=7]="UV1",rZ[rZ.UV2=8]="UV2",rZ[rZ.UV3=9]="UV3",rZ[rZ.UV4=10]="UV4",rZ[rZ.UV5=11]="UV5",rZ[rZ.UV6=12]="UV6",rZ[rZ.UV7=13]="UV7";var d3=(uo(rJ=function(e,t){var r;return(r=dM.call(this,e)||this).primitiveInfo=t,r},dM),rJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:hn._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:hn._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:hn._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:hn._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:hn._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:hn._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:hn._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:hn._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},rJ);(r$=cy||(cy={}))[r$.Sphere=0]="Sphere",r$[r$.Cuboid=1]="Cuboid",r$[r$.Plane=2]="Plane",r$[r$.Cylinder=3]="Cylinder",r$[r$.Torus=4]="Torus",r$[r$.Cone=5]="Cone",r$[r$.Capsule=6]="Capsule",r$[r$.CCSphere=7]="CCSphere";var d4=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},d8=(uo(r0=function(e,t,r,n){var a;return(a=d4.call(this,0,r,n)||this).radius=e,a.segments=t,a},d4),r0),d5=(uo(r1=function(e,t,r,n){var a;return(a=d4.call(this,7,r,n)||this).radius=e,a.step=t,a},d4),r1),d9=(uo(r2=function(e,t,r,n,a){var i;return(i=d4.call(this,1,n,a)||this).width=e,i.height=t,i.depth=r,i},d4),r2),d6=(uo(r3=function(e,t,r,n,a,i){var o;return(o=d4.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},d4),r3),d7=(uo(r4=function(e,t,r,n,a,i,o){var s;return(s=d4.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=a,s},d4),r4),he=(uo(r8=function(e,t,r,n,a,i,o){var s;return(s=d4.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=a,s},d4),r8),ht=(uo(r5=function(e,t,r,n,a,i){var o;return(o=d4.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d4),r5),hr=(uo(r9=function(e,t,r,n,a,i){var o;return(o=d4.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d4),r9),hn=((r6=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var a=new d1(e);r6._setSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(a,new d8(t,r,i,n))),a},r6.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var a=new d1(e);r6._setSubdivisionSurfaceSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(a,new d5(t,r,i,n))),a},r6.createCuboid=function(e,t,r,n,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=!0);var i=new d1(e);r6._setCuboidData(i,t,r,n,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(i,new d9(t,r,n,o,a))),i},r6.createPlane=function(e,t,r,n,a,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d1(e);r6._setPlaneData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new d6(t,r,n,a,s,i))),o},r6.createCylinder=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new d1(e);r6._setCylinderData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(s,new d7(t,r,n,a,i,l,o))),s},r6.createTorus=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===a&&(a=30),void 0===i&&(i=360),void 0===o&&(o=!0);var s=new d1(e);r6._setTorusData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(s,new he(t,r,n,a,i,l,o))),s},r6.createCone=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d1(e);r6._setConeData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new ht(t,r,n,a,s,i))),o},r6.createCapsule=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d1(e);r6._setCapsuleData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d3(o,new hr(t,r,n,a,s,i))),o},r6._setSubdivisionSurfaceSphereData=function(e,t,r,n,a,i){r=cq.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));r6._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),_=r6._generateIndices(e.engine,l,6*c),f=0,p={},m=0;m<l;m++){var g=3*m,v=o[g],y=o[g+1],x=o[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*t,h[g+1]=y*t,h[g+2]=x*t,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var T=8*(l+f++);h.set(h.subarray(g,g+8),T),h[T+6]=1,p[g/8]=T/8}}var C=0;this._spherePoleIdx=0;for(var S=0;S<c;S++){var A=4*S,M=s[A],R=s[A+1],E=s[A+2],w=s[A+3],P=8*M,F=8*R,L=8*E,B=8*w;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]&&(E=p[E]),0===h[B+6]&&(w=p[w])),_[C]=M,_[C+1]=R,_[C+2]=E,this._generateAndReplacePoleUV(_,h,C,u),_[C+3]=M,_[C+4]=E,_[C+5]=w,this._generateAndReplacePoleUV(_,h,C+3,u),C+=6}if(!a){var D=e.bounds;D.min.set(-t,-t,-t),D.max.set(t,t,t)}r6._initialize(e,h,_,n,a,i)},r6._setSphereData=function(e,t,r,n,a,i){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=r6._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),b=-t*Math.cos(v)*x,T=t*Math.cos(y),C=t*Math.sin(v)*x,S=8*p;f[S++]=b,f[S++]=T,f[S++]=C,f[S++]=b,f[S++]=T,f[S++]=C,f[S++]=m,f[S++]=g}for(var A=0,M=0;M<l;++M){var R=M%r,E=(M*_|0)*o+R,w=E+1,P=E+o,F=P+1;c[A++]=w,c[A++]=E,c[A++]=F,c[A++]=E,c[A++]=P,c[A++]=F}if(!a){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}r6._initialize(e,f,c,n,a,i)},r6._subdiveCatmullClark=function(e,t,r){var n=new Map,a=[];t.set(r6._sphereSeedPositions),r.set(r6._sphereSeedCells);for(var i=0;i<e;i++){var o=6*Math.pow(4,i),s=4*o+2;n.clear(),a.length=0;for(var l=0;l<o;l++){for(var c=a[l]={facePoint:new cQ,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 cQ,edgePointIndex:void 0},g=3*_,v=3*f;m.edgePoint.set(.25*(t[g]+t[v]),.25*(t[g+1]+t[v+1]),.25*(t[g+2]+t[v+2])),n.set(p,m)}var y=n.get(p);c.adjacentEdges[h]=y;var x=y.edgePoint,b=c.facePoint;x.x+=.25*b.x,x.y+=.25*b.y,x.z+=.25*b.z}}var T=o+2,C=T+o,S=0;this._sphereEdgeIdx=0;for(var A=r.slice(0,4*o),M=0;M<o;M++){var R=a[M];R.facePoint.copyToArray(t,3*(T+M));for(var E=T+M,w=void 0,P=void 0,F=void 0,L=0;L<4;L++){var B=A[S++];switch(L){case 0:var D=R.adjacentEdges[L%4],I=R.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,D,C),F=w=this._calculateEdgeIndex(t,I,C);break;case 1:case 2:var O=R.adjacentEdges[L%4];w=P,P=this._calculateEdgeIndex(t,O,C);break;case 3:w=P,P=F}var V=4*(4*M+L);r[V]=B,r[V+1]=P,r[V+2]=E,r[V+3]=w}}}},r6._generateAndReplacePoleUV=function(e,t,r,n){var a=t[8*e[r]+7];if(0===a||1===a){var i=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},r6._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+r6._sphereEdgeIdx));var n=r+r6._sphereEdgeIdx++;return t.edgePointIndex=n,n},r6._setCuboidData=function(e,t,r,n,a,i,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 b=0;b<4;b++){var T=8*b+163;u[T++]=0,u[T++]=0,u[T++]=-1}var C=new Uint16Array(36);if(C[0]=0,C[1]=2,C[2]=1,C[3]=2,C[4]=0,C[5]=3,C[6]=4,C[7]=6,C[8]=7,C[9]=6,C[10]=4,C[11]=5,C[12]=8,C[13]=10,C[14]=9,C[15]=10,C[16]=8,C[17]=11,C[18]=12,C[19]=14,C[20]=15,C[21]=14,C[22]=12,C[23]=13,C[24]=16,C[25]=18,C[26]=17,C[27]=18,C[28]=16,C[29]=19,C[30]=20,C[31]=22,C[32]=23,C[33]=22,C[34]=20,C[35]=21,!i){var S=e.bounds;S.min.set(-s,-l,-c),S.max.set(s,l,c)}r6._initialize(e,u,C,a,i,o)},r6._setPlaneData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(a=Math.max(1,Math.floor(a)))+1,u=t/2,d=r/2,h=t/n,_=r/a,f=l*c,p=a*n,m=r6._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/a,x=new Float32Array(8*f),b=0;b<f;++b){var T=b%l,C=b*g|0,S=8*b;x[S++]=T*h-u,x[S++]=0,x[S++]=C*_-d,x[S++]=0,x[S++]=1,x[S++]=0,x[S++]=T*v,x[S++]=C*y}for(var A=0,M=0;M<p;++M){var R=M%n,E=(M*v|0)*l+R,w=E+1,P=E+l,F=P+1;m[A++]=E,m[A++]=P,m[A++]=w,m[A++]=P,m[A++]=F,m[A++]=w}if(!o){var L=e.bounds;L.min.set(-u,0,-d),L.max.set(u,0,d)}r6._initialize(e,x,m,i,o,s)},r6._setCylinderData=function(e,t,r,n,a,i,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1);for(var c=(a=Math.floor(a))+1,u=(i=Math.floor(i))+1,d=.5*n,h=n/i,_=c*u,f=a*i,p=2*a,m=_+2+p,g=r6._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*m),T=0,C=Math.PI,S=2*Math.PI,A=r-t,M=A/n,R=A/i,E=0;E<_;++E){var w=E%c,P=E*v|0,F=w*y,L=P*x,B=C+F*S,D=Math.sin(B),I=Math.cos(B),O=r-P*R,V=O*D,N=P*h-d,k=O*I,z=8*E;b[z++]=V,b[z++]=N,b[z++]=k,b[z++]=D,b[z++]=M,b[z++]=I,b[z++]=F,b[z++]=1-L}for(var U=0;U<f;++U){var G=U%a,H=(U*y|0)*c+G,W=H+1,j=H+c,K=j+1;g[T++]=W,g[T++]=j,g[T++]=H,g[T++]=W,g[T++]=K,g[T++]=j}var X=8*_;b[X++]=0,b[X++]=-d,b[X++]=0,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=.5,b[X++]=.5,b[X++]=0,b[X++]=d,b[X++]=0,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=.5,b[X++]=.5,X=(_+2)*8;for(var Y=1/(2*t),q=1/(2*r),Q=c*i,Z=0;Z<a;++Z){var J=8*Z,$=b[J],ee=b[J+2];b[X++]=$,b[X++]=-d,b[X++]=ee,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=$*q+.5,b[X++]=.5-ee*q;var et=(Z+Q)*8;$=b[et],ee=b[et+2],b[X++]=$,b[X++]=d,b[X++]=ee,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=$*Y+.5,b[X++]=.5-ee*Y}for(var er=_+1,en=_+2,ea=en+1,ei=0;ei<a;++ei){var eo=2*ei,es=ei===a-1?0:eo+2;g[T++]=_,g[T++]=en+es,g[T++]=en+eo,g[T++]=er,g[T++]=ea+eo,g[T++]=ea+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-d,-ec),el.max.set(ec,d,ec)}r6._initialize(e,b,g,o,s,l)},r6._setTorusData=function(e,t,r,n,a,i,o,s,l){var c=((n=Math.floor(n))+1)*((a=Math.floor(a))+1),u=n*a,d=r6._generateIndices(e.engine,c,6*u),h=new Float32Array(8*c);i=i/180*Math.PI;for(var _=0,f=r6._tempVec30,p=0;p<=n;p++)for(var m=0;m<=a;m++){var g=m/a*i,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),b=Math.sin(g),T=(t+r*y)*x,C=(t+r*y)*b,S=r*Math.sin(v);h[_++]=T,h[_++]=C,h[_++]=S;var A=t*x,M=t*b;f.set(T-A,C-M,S).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/a,h[_++]=p/n}_=0;for(var R=1;R<=n;R++)for(var E=1;E<=a;E++){var w=(a+1)*R+E-1,P=(a+1)*(R-1)+E-1,F=(a+1)*(R-1)+E,L=(a+1)*R+E;d[_++]=w,d[_++]=P,d[_++]=L,d[_++]=P,d[_++]=F,d[_++]=L}if(!s){var B=e.bounds,D=t+r;B.min.set(-D,-D,-r),B.max.set(D,D,r)}r6._initialize(e,h,d,o,s,l)},r6._setConeData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.floor(n))+1,c=(a=Math.floor(a))+1,u=.5*r,d=r/a,h=l*c,_=n*a,f=h+1+n,p=r6._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/a,y=new Float32Array(8*f),x=0,b=Math.PI,T=2*Math.PI,C=t/r,S=0;S<h;++S){var A=S%l,M=S*m|0,R=A*g,E=M*v,w=b+R*T,P=Math.sin(w),F=Math.cos(w),L=t-E*t,B=L*P,D=M*d-u,I=L*F,O=8*S;y[O++]=B,y[O++]=D,y[O++]=I,y[O++]=P,y[O++]=C,y[O++]=F,y[O++]=R,y[O++]=1-E}for(var V=0;V<_;++V){var N=V%n,k=(V*g|0)*l+N,z=k+1,U=k+l,G=U+1;p[x++]=z,p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=G,p[x++]=U}var H=8*h;y[H++]=0,y[H++]=-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),j=0;j<n;++j){var K=y[8*j],X=y[8*j+2];y[H++]=K,y[H++]=-u,y[H++]=X,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=K*W+.5,y[H++]=.5-X*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)}r6._initialize(e,y,p,i,o,s)},r6._setCapsuleData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(a=Math.floor(a))+1,u=.5*r,d=r/a,h=l*c,_=n*a,f=l*l,p=n*n,m=h+2*f,g=r6._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/a,b=Math.PI,T=2*Math.PI,C=new Float32Array(8*m),S=0,A=0;A<h;++A){var M=A%l,R=A*v|0,E=M*y,w=R*x,P=b+E*T,F=Math.sin(P),L=Math.cos(P),B=8*A;C[B++]=t*F,C[B++]=R*d-u,C[B++]=t*L,C[B++]=F,C[B++]=0,C[B++]=L,C[B++]=E,C[B++]=1-w}for(var D=0;D<_;++D){var I=D%n,O=(D*y|0)*l+I,V=O+1,N=O+l,k=N+1;g[S++]=V,g[S++]=N,g[S++]=O,g[S++]=V,g[S++]=k,g[S++]=N}if(r6._createCapsuleCap(t,r,n,b,T,h,1,C,g,S),r6._createCapsuleCap(t,r,n,b,-T,h+f,-1,C,g,S+6*p),!o){var z=e.bounds;z.min.set(-t,-t-u,-t),z.max.set(t,t+u,t)}r6._initialize(e,C,g,i,o,s)},r6._initialize=function(t,r,n,a,i,o){if(i)o.setData(r),t.setIndices(n),t.uploadData(a);else{var s=[new dO(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new dO(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new dO(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new dD(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(a),t.addSubMesh(0,n.length)}},r6._generateIndices=function(t,r,n){var a=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))a=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(n);return a},r6._createCapsuleCap=function(e,t,r,n,a,i,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*a,x=v*Math.PI*.5,b=Math.sin(x),T=e*Math.sin(y)*b,C=e*Math.cos(x)*o+d,S=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=T,s[A++]=C,s[A++]=S,s[A++]=T,s[A++]=C-d,s[A++]=S,s[A++]=g,s[A++]=v}for(var M=0;M<_;++M){var R=M%r,E=(M*p|0)*u+R+i,w=E+1,P=E+u,F=P+1;l[c++]=w,l[c++]=E,l[c++]=F,l[c++]=E,l[c++]=P,l[c++]=F}},r6);function ha(e,t,r){return(ha=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&ui(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}hn._tempVec30=new cQ,hn._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]),hn._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]),hn._sphereEdgeIdx=0,hn._spherePoleIdx=0;var hi=((r7=function(){}).cloneComponent=function(e,t,r,n,a){var i=u_.getCloneMode(e.constructor);for(var o in e)u_.cloneProperty(e,t,o,i[o],r,n,a);e._cloneTo&&e._cloneTo(t,r,n)},r7),ho=(uo(ne=function(t,r){var n;return(n=uf.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new dt,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._isTemplate=!1,n._parent=null,n._invModelMatrix=new c4,n.name=r,n.transform=n.addComponent(uV),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},uf),(nt=ne.prototype).addComponent=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];uD._addCheck(this,e);var a=ha(e,[].concat(this,r));return this._components.push(a),a._setActive(!0,ct.All),a},nt.getComponent=function(e){for(var t=this._components,r=0,n=t.length;r<n;r++){var a=t[r];if(ul(a,e))return a}return null},nt.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];ul(i,e)&&t.push(i)}return t},nt.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},nt.addChild=function(e,t){var r;if("number"==typeof e?r=e:(r=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(r,t),t._parent=this;var n=t._scene,a=this._scene,i=ct.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=ct.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==a&&(i|=ct.Scene):i|=ct.Scene),i&&t._processInActive(i),t._scene!==a&&ne._traverseSetOwnerScene(t,a);var o=ct.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=ct.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===a||(o|=ct.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},nt.removeChild=function(e){e._setParent(null)},nt.getChild=function(e){return this._children[e]},nt.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},nt.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,a=t.length;n<a;++n){var i=t[n];if(i&&!(r=ne._findChildByName(r,i)))return null}return r},nt.createChild=function(e){var t=new ne(this.engine,e);return t.layer=this.layer,t.parent=this,t},nt.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=ct.None;r._isActiveInHierarchy&&(n|=ct.Hierarchy),r._isActiveInScene&&(n|=ct.Scene),n&&r._processInActive(n),ne._traverseSetOwnerScene(r,null)}e.length=0},nt.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},nt._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},nt._createCloneEntity=function(){var e=new ne(this._engine,this.name),t=this._templateResource;t&&(e._templateResource=t,t._addReferCount(1)),e.layer=this.layer,e._isActive=this._isActive;var r=e.transform,n=this.transform;r.position=n.position,r.rotation=n.rotation,r.scale=n.scale;for(var a=this._children,i=0,o=a.length;i<o;i++)e.addChild(a[i]._createCloneEntity());return e},nt._parseCloneEntity=function(e,t,r,n,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],r,n,a);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!ul(h,uV)){var _=t.addComponent(h.constructor);hi.cloneComponent(h,_,r,n,a)}}},nt.destroy=function(){if(!this._destroyed){uf.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},nt._removeComponent=function(e){uD._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},nt._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},nt._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},nt._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}},nt._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)},nt._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)},nt._addToChildrenList=function(e,t){var r=this._children,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},nt._setParent=function(e,t){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var n=this._scene,a=e._scene,i=ct.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=ct.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==a&&(i|=ct.Scene):this._isActiveInScene&&(i|=ct.Scene),i&&this._processInActive(i),n!==a&&ne._traverseSetOwnerScene(this,a);var o=ct.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=ct.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===a||(o|=ct.Scene))),o&&this._processActive(o)}else{var s=ct.None;this._isActiveInHierarchy&&(s|=ct.Hierarchy),this._isActiveInScene&&(s|=ct.Scene),s&&this._processInActive(s),r&&ne._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},nt._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];ul(n,e)&&t.push(n)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},nt._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,a=r.length;n<a;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},nt._setActiveInHierarchy=function(e,t){t&ct.Hierarchy&&(this._isActiveInHierarchy=!0),t&ct.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},nt._setInActiveInHierarchy=function(e,t){t&ct.Hierarchy&&(this._isActiveInHierarchy=!1),t&ct.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},nt._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},nt._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var r=this._siblingIndex;if(t<r)for(var n=r;n>=t;n--){var a=n==t?this:e[n-1];e[n]=a,a._siblingIndex=n}else for(var i=r;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},nt.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(c4.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},ne._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var a=r[n];if(a.name===t)return a}return null},ne._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},ne._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},ne._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},ua(ne,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=ct.None;this._isRoot&&this._scene._isActiveInEngine?r|=ct.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=ct.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=ct.Scene)),r&&this._processActive(r)}else{var n=ct.None;this._isActiveInHierarchy&&(n|=ct.Hierarchy),this._isActiveInScene&&(n|=ct.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)}}]),ne),hs=(uo(nr=function(e){var t;return(t=uf.call(this,null)||this).name=e,t.inverseBindMatrices=[],t._updatedManager=new ub,t._bones=[],t._updateMark=-1,t.joints=[],t},uf),(nn=nr.prototype)._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,r=this.bones,n=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=r.length-1;o>=0;o--){var s=r[o],l=16*o;s?ug._floatMatrixMultiply(s.transform.worldMatrix,n[o].elements,0,a,l):a.set(n[o].elements,l),ug._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},nn._cloneTo=function(e,t,r){var n=[],a=this.rootBone;if(a){var i=ho._getEntityHierarchyPath(t,a,n);e.rootBone=i?ho._getEntityByHierarchyPath(r,n):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var u=o[c],d=ho._getEntityHierarchyPath(t,u,n);l[c]=d?ho._getEntityByHierarchyPath(r,n):u}e.bones=l}},ua(nr,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,r=this._bones,n=null!=(t=null==e?void 0:e.length)?t:0,a=r.length;r.length=n;for(var i=0;i<n;i++)r[i]=e[i];a!==n&&(this._skinMatrices=new Float32Array(16*n),this._updatedManager.dispatch(0,n))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),nr);us([uh],hs.prototype,"inverseBindMatrices",void 0),us([uc],hs.prototype,"_skinMatrices",void 0),us([uc],hs.prototype,"_updatedManager",void 0),us([uc],hs.prototype,"_rootBone",void 0),us([uc],hs.prototype,"_bones",void 0),us([uc],hs.prototype,"_updateMark",void 0),(na=cx||(cx={}))[na.BoneCountChanged=0]="BoneCountChanged",na[na.RootBoneChanged=1]="RootBoneChanged";var hl=(uo(ni=function(e){(t=d$.call(this,e)||this)._localBounds=new cJ,t._jointDataCreateCache=new c5(-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(ur(t)),t._onSkinUpdated=t._onSkinUpdated.bind(ur(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},d$),(no=ni.prototype)._updateTransformShaderData=function(e,t,r){var n,a,i=(null!=(a=null==(n=this.skin)?void 0:n.rootBone)?a:this.entity).transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,i,r):this._updateWorldViewRelatedShaderData(e,i,r)},no._onDestroy=function(){var e;d$.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null},no._cloneTo=function(e,t,r){d$.prototype._cloneTo.call(this,e,t,r),this.skin&&e._applySkin(null,e.skin),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},no._update=function(t){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var n=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(n,this);var i=null==r?void 0:r.bones;if(i){var o=a._uniformOccupiesCount,s=i.length,l=this._jointDataCreateCache,c=s!==l.x;if(c||o!==l.y){var u,d=Math.ceil((this._maxVertexUniformVectors-(44+o))/4);if(s>d){var h,_=this.engine;_._hardwareRenderer.canIUseMoreJoints?(c&&(null==(h=this._jointTexture)||h.destroy(),this._jointTexture=new di(_,4,s,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),n.disableMacro("RENDERER_JOINTS_NUM"),n.enableMacro("RENDERER_USE_JOINT_TEXTURE"),n.setTexture(ni._jointSamplerProperty,this._jointTexture)):uP.error("component's joints count("+s+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+d+".",this)}else null==(u=this._jointTexture)||u.destroy(),n.disableMacro("RENDERER_USE_JOINT_TEXTURE"),n.enableMacro("RENDERER_JOINTS_NUM",d.toString()),n.setFloatArray(ni._jointMatrixProperty,r._skinMatrices);l.set(s,o)}this._jointTexture&&this._jointTexture.setPixelBuffer(r._skinMatrices)}d$.prototype._update.call(this,t)},no._updateBounds=function(e){var t,r=null==(t=this.skin)?void 0:t.rootBone;r?cJ.transform(this._localBounds,r.transform.worldMatrix,e):d$.prototype._updateBounds.call(this,e)},no._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var a=new Float32Array(t);if(t>n)a.set(r);else for(var i=0;i<t;i++)a[i]=r[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},no._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=ci.WorldVolume},no._onSkinUpdated=function(e,t){switch(e){case cx.BoneCountChanged:var r=this.shaderData;t>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(ni._jointCountProperty,t)):r.disableMacro("RENDERER_HAS_SKIN");break;case cx.RootBoneChanged:this._dirtyUpdateFlag|=ci.WorldVolume}},no._applySkin=function(e,t){var r,n,a,i,o,s,l=null!=(a=null==e?void 0:null==(r=e.bones)?void 0:r.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var u=null!=(o=null==t?void 0:null==(n=t.bones)?void 0:n.length)?o:0,d=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==u&&this._onSkinUpdated(cx.BoneCountChanged,u),c!==d&&this._onSkinUpdated(cx.RootBoneChanged,d)},ua(ni,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var r=0,n=t.length;r<n;r++)t[r]=e[r]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),ni);hl._jointCountProperty=uF.getByName("renderer_JointCount"),hl._jointSamplerProperty=uF.getByName("renderer_JointSampler"),hl._jointMatrixProperty=uF.getByName("renderer_JointMatrix"),us([uc],hl.prototype,"_condensedBlendShapeWeights",void 0),us([uh],hl.prototype,"_localBounds",void 0),us([uc],hl.prototype,"_jointDataCreateCache",void 0),us([uc],hl.prototype,"_blendShapeWeights",void 0),us([uc],hl.prototype,"_maxVertexUniformVectors",void 0),us([uc],hl.prototype,"_jointTexture",void 0),us([uh],hl.prototype,"_skin",void 0),us([uc],hl.prototype,"_onLocalBoundsChanged",null),us([uc],hl.prototype,"_onSkinUpdated",null);var hc=((nl=(ns=function(t){var r=new Float32Array([-1,-1,0,1,3,-1,2,1,-1,3,0,-1]),n=new Float32Array([3,-1,2,0,-1,-1,0,0,-1,3,0,2]),a=new dV(t,u4.find("blit"));a._addReferCount(1),a.renderState.depthState.enabled=!1,a.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(t,r),this.flipYBlitMesh=this._createBlitMesh(t,n),this.blitMaterial=a;var i=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R8G8B8A8,i),this.whiteTextureCube=this._create1x1Texture(t,1,e.TextureFormat.R8G8B8A8,i),t._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(t,2,e.TextureFormat.R8G8B8A8,i);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R32G32B32A32_UInt,o)}}).prototype)._createBlitMesh=function(t,r){var n=new d1(t);return n._addReferCount(1),n.setVertexElements([new dO("POSITION_UV",0,e.VertexElementFormat.Vector4,0)]),n.setVertexBufferBinding(new dD(t,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static),16),n.addSubMesh(0,3,e.MeshTopology.Triangles),n},nl._create1x1Texture=function(t,r,n,a){switch(r){case 0:var i,o,s=new di(t,1,1,n,!1);s.setPixelBuffer(a),i=s;break;case 2:var l=new ds(t,1,1,1,n,!1);l.setPixelBuffer(0,a),i=l;break;case 1:for(var c=new dl(t,1,n,!1),u=0;u<6;u++)c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,a);i=c;break;default:throw"Invalid texture type"}return i.isGCIgnored=!0,t.resourceManager.addContentRestorer(new(uo(o=function(){return dM.call(this,i)},dM),o.prototype.restoreContent=function(){switch(r){case 0:this.resource.setPixelBuffer(a);break;case 2:this.resource.setPixelBuffer(0,a);break;case 1:for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,a)}},o)),i},ns);(nc=cb||(cb={}))[nc.Texture2D=0]="Texture2D",nc[nc.TextureCube=1]="TextureCube",nc[nc.Texture2DArray=2]="Texture2DArray";var hu=((nu=function(e){this._type=e}).prototype.garbageCollection=function(){for(var e=this._elements,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose();e.length=0},nu),hd=(uo(nd=function(e,t){void 0===t&&(t=1),(r=hu.call(this,e)||this)._lastElementIndex=t-1;for(var r,n=r._elements=Array(t),a=0;a<t;++a)n[a]=new e;return r},hu),(nh=nd.prototype).get=function(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]},nh.return=function(e){this._elements[++this._lastElementIndex]=e},nd),hh=((n_=function(e,t){this.start=e,this.size=t}).prototype.dispose=function(){},n_),h_=((nf=function(){}).prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},nf),hf=((nm=(np=function(t,r){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexLength=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new dq(t);n.addVertexElement(new dO("POSITION",0,e.VertexElementFormat.Vector3,0)),n.addVertexElement(new dO("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)),n.addVertexElement(new dO("COLOR_0",20,e.VertexElementFormat.Vector4,0)),n._addReferCount(1);var a=new dD(t,e.BufferBindFlag.VertexBuffer,36*r,e.BufferUsage.Dynamic,!0);n.setVertexBufferBinding(0,new dZ(a,36));var i=new dD(t,e.BufferBindFlag.IndexBuffer,8*r,e.BufferUsage.Dynamic,!0);n.setIndexBufferBinding(new dK(i,e.IndexFormat.UInt16)),this.primitive=n,this.vertices=new Float32Array(a.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new hh(0,9*r)]}).prototype).allocateSubChunk=function(t){var r=this._allocateArea(9*t);if(r){var n=np.subChunkPool.get();n.chunk=this,n.vertexArea=r;var a=np.subMeshPool.get();return a.topology=e.MeshTopology.Triangles,n.subMesh=a,n}return null},nm.freeSubChunk=function(e){this._freeArea(e.vertexArea),np.subMeshPool.return(e.subMesh),np.subChunkPool.return(e)},nm.uploadBuffer=function(){var t=this.primitive,r=this.updateVertexStart,n=this.updateVertexLength;r!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER&&(t.vertexBufferBindings[0].buffer.setData(this.vertices,4*r,r,n,e.SetDataOptions.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexLength=Number.MIN_SAFE_INTEGER),t.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,e.SetDataOptions.Discard),this.updateIndexLength=0},nm.destroy=function(){this.primitive._addReferCount(-1),this.primitive.destroy(),this.primitive=null,this.vertices=null,this.indices=null},nm._allocateArea=function(e){for(var t=this.vertexFreeAreas,r=np.areaPool,n=0,a=t.length;n<a;++n){var i=t[n],o=i.size;if(o>e){var s=r.get();return s.start=i.start,s.size=e,i.start+=e,i.size-=e,s}if(o===e)return t.splice(n,1),r.return(i),i}return null},nm._freeArea=function(e){var t=this.vertexFreeAreas,r=t.length;if(0===r){t.push(e);return}for(var n=np.areaPool,a=e,i=!0,o=0;o<r;++o){var s=t[o],l=a.start,c=a.size,u=s.start,d=l+c,h=u+s.size;if(d<u){i&&t.splice(o,0,a);return}d===u?(s.start=l,s.size+=c,n.return(a),a=s,i=!1):l===h?(s.size+=c,n.return(a),a=s,i=!1):l>h&&o+1===r&&t.push(a)}},np);hf.areaPool=new hd(hh,10),hf.subChunkPool=new hd(h_,10),hf.subMeshPool=new hd(dY,10);var hp=function(){function e(t,r){void 0===r&&(r=e.MAX_VERTEX_COUNT),this.engine=t,this.maxVertexCount=r,this.primitiveChunks=[]}var t=e.prototype;return t.allocateSubChunk=function(e){for(var t=this.primitiveChunks,r=t.length,n=null,a=0;a<r;++a)if(n=t[a].allocateSubChunk(e))return n;return(t[r]||(t[r]=new hf(this.engine,this.maxVertexCount))).allocateSubChunk(e)},t.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},t.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,r=e.length;t<r;++t)e[t].uploadBuffer()},t.destroy=function(){for(var e=this.primitiveChunks,t=0,r=e.length;t<r;++t)e[t].destroy();e.length=0,this.primitiveChunks=null,this.engine=null},e}();hp.MAX_VERTEX_COUNT=4096;var hm=((nv=(ng=function(e){this.primitiveChunkManager2D=new hp(e),this.primitiveChunkManagerMask=new hp(e,128)}).prototype).destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},nv.batch=function(e){for(var t,r,n,a=e.elements,i=e.batchedSubElements,o=e.renderQueueType,s=0,l=a.length;s<l;++s)for(var c=a[s].subRenderElements,u=0,d=c.length;u<d;++u){var h=c[u];if(h.renderQueueFlags&1<<o){var _=h.component,f=_.constructor;t?n===f&&r._canBatch(t,h)?(r._batch(t,h),t.batched=!0):(i.push(t),t=h,r=_,n=f,_._batch(h),h.batched=!1):(t=h,r=_,n=f,_._batch(h),h.batched=!1)}}t&&i.push(t)},nv.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},ng);e.AssetType=void 0,(ny=e.AssetType||(e.AssetType={})).Text="Text",ny.JSON="JSON",ny.Buffer="Buffer",ny.Texture2D="Texture2D",ny.TextureCube="TextureCube",ny.Material="Material",ny.Mesh="Mesh",ny.AnimationClip="AnimationClip",ny.AnimatorController="AnimatorController",ny.Prefab="Prefab",ny.GLTF="GLTF",ny.KTX="KTX",ny.KTXCube="KTXCube",ny.KTX2="KTX2",ny.Sprite="Sprite",ny.PrimitiveMesh="PrimitiveMesh",ny.SpriteAtlas="SpriteAtlas",ny.Env="Environment",ny.Scene="Scene",ny.HDR="HDR",ny.Font="Font",ny.SourceFont="SourceFont",ny.Project="project";var hg=((nb=(nx=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},nb.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},nb.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},nb.findAndRemove=function(e){for(var t=this._array,r=t.length-1;r>=0;r--)e(t[r])&&this.removeByIndex(r)},nb.indexOf=function(e){return this._array.indexOf(e)},nb.getArray=function(){return this._array},nb.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},ua(nx,[{key:"length",get:function(){return this._array.length}}]),nx),hv=((nC=(nT=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new hg}).prototype).addScene=function(e,t){var r,n=this._scenes;if("number"==typeof e){if(e<0||e>n.length)throw"The index is out of range.";r=e}else r=n.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=n.indexOf(t);a!==r&&(n.removeByIndex(a),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},nC.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)}},nC.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,a=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return a.then(function(e){if(r)for(var t=n._scenes.getArray(),a=0,i=t.length;a<i;a++)t[a].destroy();n.addScene(e)}),a},nC.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},nC._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},ua(nT,[{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)}}]),nT),hy=((nA=(nS=function(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,r){if("pending"===t._state){var n=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:r});n.loaded=e,n.total=r,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,r)})}},function(e,r,n){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:r,total:n});i.loaded=r,i.total=n,t._onTaskDetailCallbacks.forEach(function(t){return t(e,r,n)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e,t){var r=this._taskCompleteProgress,n=this._taskDetailProgress;if(r&&e(r.loaded,r.total),n)for(var a in n){var i=n[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},nA.then=function(e,t){var r=this;return new nS(function(n,a){r._promise.then(e,t).then(n).catch(a)})},nA.catch=function(e){var t=this;return new nS(function(r,n){t._promise.catch(e).then(r).catch(n)})},nA.finally=function(e){return this._promise.finally(e)},nA.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nS.all=function(e){return new nS(function(t,r,n){var a=function(e,r){l++,s[e]=r,n(l,o),l===o&&t(s)},i=function(e,t){ul(e,Promise)||ul(e,nS)?e.then(function(e){a(t,e)},r):Promise.resolve().then(function(){a(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)i(e[c],c)})},ua(nS,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nS);(nM=cT||(cT={})).Pending="pending",nM.Fulfilled="fulfilled",nM.Rejected="rejected",nM.Canceled="canceled";var hx=((nE=(nR=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}).prototype).load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var r=e.map(function(e){return t._loadSingleItem(e)});return hy.all(r)},nE.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},nE.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var a=r[n];ul(a,e)&&t.push(a)}return t},nE.getAssetPath=function(e){return this._assetPool[e]},nE.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()}):ug.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},nE.gc=function(){this._gc(!1),this.engine._pendingGC()},nE.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},nE._onSubAssetSuccess=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.resolve(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={resolve:r}},nE._onSubAssetFail=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.reject(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={reject:r}},nE._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},nE._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},nE._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},nE._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},nE._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},nE._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},nE._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},nE._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},nE._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},nE._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)},nE._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},nE._assignDefaultOptions=function(e){var t,r,n,a,i;if(e.type=null!=(t=e.type)?t:nR._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(r=e.retryCount)?r:this.retryCount,e.timeout=null!=(n=e.timeout)?n:this.timeout,e.retryInterval=null!=(a=e.retryInterval)?a:this.retryInterval,e.url=null!=(i=e.url)?i:e.urls.join(","),e},nE._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),a=n.url,i=this._virtualPathMap[a]?this._virtualPathMap[a]:a;!ug.isAbsoluteUrl(i)&&this.baseUrl&&(i=ug.resolveAbsoluteUrl(this.baseUrl,i));var o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=this._assetUrlPool[s];if(u)return new hy(function(e){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 hy(function(e,t,r,n){_.onProgress(r,n).then(function(t){e(t)}).catch(function(e){t(e)})});var f=nR._loaders[n.type];if(!f)throw"loader not found: "+n.type;return l?((h[s]||this._loadMainAsset(f,n,s)).catch(function(e){r._onSubAssetFail(s,l,e)}),this._createSubAssetPromiseCallback(s,d,l)):this._loadMainAsset(f,n,s)},nE._loadMainAsset=function(e,t,r){var n=this;t.url=r;var a=this._loadingPromises,i=e.load(t,this);return a[r]=i,i.then(function(t){e.useCache&&n._addAsset(r,t),delete a[r],n._releaseSubAssetPromiseCallback(r)},function(){delete a[r],n._releaseSubAssetPromiseCallback(r)}),i},nE._createSubAssetPromiseCallback=function(e,t,r){var n,a=this,i=this._loadingPromises,o=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[r],s=null==o?void 0:o.resolve,l=null==o?void 0:o.reject,c=new hy(function(n,o){if(s)n(s);else if(l)o(l);else{var u;i[t]=c,((u=a._subAssetPromiseCallbacks)[e]||(u[e]={}))[r]={resolve:n,reject:o}}});return s||l||c.then(function(){delete i[t]},function(){return delete i[t]}),c},nE._gc=function(e){for(var t=ug.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++){var a=t[r];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},nE._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,a=t.length;n<a;n++)r=r[t[n]];return r},nE._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],a=void 0,i=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:i,queryPath:a}},nE._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===hT&&t.push(""),e.replace(hS,function(e,r,n,a){var i=e;n?i=a.replace(hC,"$1"):r&&(i=r.trim()),t.push(i)}),t},nE._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},nE.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,a=this._objectPool[t];if(a)i=Promise.resolve(a);else{var i,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return uP.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,i=this.load({url:s,type:this._editorResourceConfig[t].type})}return i.then(function(e){return n?e.clone():e})},nE.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},nR._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,a=r.length;n<a;n++)this._extTypeMapping[r[n].toLowerCase()]=e},nR._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},nR);function hb(e,t,r){return void 0===r&&(r=!0),function(n){var a=new n(r);hx._addLoader(e,a,t)}}hx._loaders={},hx._extTypeMapping={};var hT=46,hC=/\\(\\)?/g,hS=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(nw=e.PointerPhase||(e.PointerPhase={}))[nw.Down=0]="Down",nw[nw.Move=1]="Move",nw[nw.Stationary=2]="Stationary",nw[nw.Up=3]="Up",nw[nw.Leave=4]="Leave";var hA=((nF=(nP=function(t){this.phase=e.PointerPhase.Leave,this.position=new c5,this.deltaPosition=new c5,this._events=[],this._upMap=[],this._downMap=[],this._upList=new dt,this._downList=new dt,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)},nF._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},nF._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},nF._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}},nP);e.PointerButton=void 0,(nL=e.PointerButton||(e.PointerButton={}))[nL.None=0]="None",nL[nL.Primary=1]="Primary",nL[nL.Secondary=2]="Secondary",nL[nL.Auxiliary=4]="Auxiliary",nL[nL.XButton1=8]="XButton1",nL[nL.XButton2=16]="XButton2",nL[nL.XButton3=32]="XButton3",nL[nL.XButton4=64]="XButton4",nL[nL.XButton5=128]="XButton5",nL[nL.XButton6=256]="XButton6",nL[nL.XButton7=512]="XButton7",nL[nL.XButton8=1024]="XButton8";var hM=[1,4,2,8,16,32,64,128,256,512,1024],hR={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},hE=((nB=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?nB.platform=e.Platform.IPhone:/iPad/i.test(r)?nB.platform=e.Platform.IPad:/Android/i.test(r)?nB.platform=e.Platform.Android:/Macintosh/i.test(r)&&(nB.platform=e.Platform.Mac),nB.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"}}},nB._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},ua(nB,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nB);hE.platform=e.Platform.Unknown,hE.operatingSystem="",hE._simdSupported=null,hE._initialize(),e.Keys=void 0,(nD=e.Keys||(e.Keys={}))[nD.Backquote=0]="Backquote",nD[nD.Backslash=1]="Backslash",nD[nD.Backspace=2]="Backspace",nD[nD.BracketLeft=3]="BracketLeft",nD[nD.BracketRight=4]="BracketRight",nD[nD.Comma=5]="Comma",nD[nD.Digit0=6]="Digit0",nD[nD.Digit1=7]="Digit1",nD[nD.Digit2=8]="Digit2",nD[nD.Digit3=9]="Digit3",nD[nD.Digit4=10]="Digit4",nD[nD.Digit5=11]="Digit5",nD[nD.Digit6=12]="Digit6",nD[nD.Digit7=13]="Digit7",nD[nD.Digit8=14]="Digit8",nD[nD.Digit9=15]="Digit9",nD[nD.Equal=16]="Equal",nD[nD.IntlBackslash=17]="IntlBackslash",nD[nD.IntlRo=18]="IntlRo",nD[nD.IntlYen=19]="IntlYen",nD[nD.KeyA=20]="KeyA",nD[nD.KeyB=21]="KeyB",nD[nD.KeyC=22]="KeyC",nD[nD.KeyD=23]="KeyD",nD[nD.KeyE=24]="KeyE",nD[nD.KeyF=25]="KeyF",nD[nD.KeyG=26]="KeyG",nD[nD.KeyH=27]="KeyH",nD[nD.KeyI=28]="KeyI",nD[nD.KeyJ=29]="KeyJ",nD[nD.KeyK=30]="KeyK",nD[nD.KeyL=31]="KeyL",nD[nD.KeyM=32]="KeyM",nD[nD.KeyN=33]="KeyN",nD[nD.KeyO=34]="KeyO",nD[nD.KeyP=35]="KeyP",nD[nD.KeyQ=36]="KeyQ",nD[nD.KeyR=37]="KeyR",nD[nD.KeyS=38]="KeyS",nD[nD.KeyT=39]="KeyT",nD[nD.KeyU=40]="KeyU",nD[nD.KeyV=41]="KeyV",nD[nD.KeyW=42]="KeyW",nD[nD.KeyX=43]="KeyX",nD[nD.KeyY=44]="KeyY",nD[nD.KeyZ=45]="KeyZ",nD[nD.Minus=46]="Minus",nD[nD.Period=47]="Period",nD[nD.Quote=48]="Quote",nD[nD.Semicolon=49]="Semicolon",nD[nD.Slash=50]="Slash",nD[nD.AltLeft=51]="AltLeft",nD[nD.AltRight=52]="AltRight",nD[nD.CapsLock=53]="CapsLock",nD[nD.ContextMenu=54]="ContextMenu",nD[nD.ControlLeft=55]="ControlLeft",nD[nD.ControlRight=56]="ControlRight",nD[nD.Enter=57]="Enter",nD[nD.MetaLeft=58]="MetaLeft",nD[nD.MetaRight=59]="MetaRight",nD[nD.ShiftLeft=60]="ShiftLeft",nD[nD.ShiftRight=61]="ShiftRight",nD[nD.Space=62]="Space",nD[nD.Tab=63]="Tab",nD[nD.Convert=64]="Convert",nD[nD.KanaMode=65]="KanaMode",nD[nD.Lang1=66]="Lang1",nD[nD.Lang2=67]="Lang2",nD[nD.Lang3=68]="Lang3",nD[nD.Lang4=69]="Lang4",nD[nD.Lang5=70]="Lang5",nD[nD.NonConvert=71]="NonConvert",nD[nD.Delete=72]="Delete",nD[nD.End=73]="End",nD[nD.Help=74]="Help",nD[nD.Home=75]="Home",nD[nD.Insert=76]="Insert",nD[nD.PageDown=77]="PageDown",nD[nD.PageUp=78]="PageUp",nD[nD.ArrowDown=79]="ArrowDown",nD[nD.ArrowLeft=80]="ArrowLeft",nD[nD.ArrowRight=81]="ArrowRight",nD[nD.ArrowUp=82]="ArrowUp",nD[nD.NumLock=83]="NumLock",nD[nD.Numpad0=84]="Numpad0",nD[nD.Numpad1=85]="Numpad1",nD[nD.Numpad2=86]="Numpad2",nD[nD.Numpad3=87]="Numpad3",nD[nD.Numpad4=88]="Numpad4",nD[nD.Numpad5=89]="Numpad5",nD[nD.Numpad6=90]="Numpad6",nD[nD.Numpad7=91]="Numpad7",nD[nD.Numpad8=92]="Numpad8",nD[nD.Numpad9=93]="Numpad9",nD[nD.NumpadAdd=94]="NumpadAdd",nD[nD.NumpadBackspace=95]="NumpadBackspace",nD[nD.NumpadClear=96]="NumpadClear",nD[nD.NumpadClearEntry=97]="NumpadClearEntry",nD[nD.NumpadComma=98]="NumpadComma",nD[nD.NumpadDecimal=99]="NumpadDecimal",nD[nD.NumpadDivide=100]="NumpadDivide",nD[nD.NumpadEnter=101]="NumpadEnter",nD[nD.NumpadEqual=102]="NumpadEqual",nD[nD.NumpadHash=103]="NumpadHash",nD[nD.NumpadMemoryAdd=104]="NumpadMemoryAdd",nD[nD.NumpadMemoryClear=105]="NumpadMemoryClear",nD[nD.NumpadMemoryRecall=106]="NumpadMemoryRecall",nD[nD.NumpadMemoryStore=107]="NumpadMemoryStore",nD[nD.NumpadMemorySubtract=108]="NumpadMemorySubtract",nD[nD.NumpadMultiply=109]="NumpadMultiply",nD[nD.NumpadParenLeft=110]="NumpadParenLeft",nD[nD.NumpadParenRight=111]="NumpadParenRight",nD[nD.NumpadStar=112]="NumpadStar",nD[nD.NumpadSubtract=113]="NumpadSubtract",nD[nD.Escape=114]="Escape",nD[nD.F1=115]="F1",nD[nD.F2=116]="F2",nD[nD.F3=117]="F3",nD[nD.F4=118]="F4",nD[nD.F5=119]="F5",nD[nD.F6=120]="F6",nD[nD.F7=121]="F7",nD[nD.F8=122]="F8",nD[nD.F9=123]="F9",nD[nD.F10=124]="F10",nD[nD.F11=125]="F11",nD[nD.F12=126]="F12",nD[nD.F13=127]="F13",nD[nD.F14=128]="F14",nD[nD.F15=129]="F15",nD[nD.Fn=130]="Fn",nD[nD.FnLock=131]="FnLock",nD[nD.PrintScreen=132]="PrintScreen",nD[nD.ScrollLock=133]="ScrollLock",nD[nD.Pause=134]="Pause",nD[nD.BrowserBack=135]="BrowserBack",nD[nD.BrowserFavorites=136]="BrowserFavorites",nD[nD.BrowserForward=137]="BrowserForward",nD[nD.BrowserHome=138]="BrowserHome",nD[nD.BrowserRefresh=139]="BrowserRefresh",nD[nD.BrowserSearch=140]="BrowserSearch",nD[nD.BrowserStop=141]="BrowserStop",nD[nD.Eject=142]="Eject",nD[nD.LaunchApp1=143]="LaunchApp1",nD[nD.LaunchApp2=144]="LaunchApp2",nD[nD.LaunchMail=145]="LaunchMail",nD[nD.MediaPlayPause=146]="MediaPlayPause",nD[nD.MediaSelect=147]="MediaSelect",nD[nD.MediaStop=148]="MediaStop",nD[nD.MediaTrackNext=149]="MediaTrackNext",nD[nD.MediaTrackPrevious=150]="MediaTrackPrevious",nD[nD.Power=151]="Power",nD[nD.Sleep=152]="Sleep",nD[nD.AudioVolumeDown=153]="AudioVolumeDown",nD[nD.AudioVolumeMute=154]="AudioVolumeMute",nD[nD.AudioVolumeUp=155]="AudioVolumeUp",nD[nD.WakeUp=156]="WakeUp",nD[nD.Hyper=157]="Hyper",nD[nD.Super=158]="Super",nD[nD.Turbo=159]="Turbo",nD[nD.Abort=160]="Abort",nD[nD.Resume=161]="Resume",nD[nD.Suspend=162]="Suspend",nD[nD.Again=163]="Again",nD[nD.Copy=164]="Copy",nD[nD.Cut=165]="Cut",nD[nD.Find=166]="Find",nD[nD.Open=167]="Open",nD[nD.Paste=168]="Paste",nD[nD.Props=169]="Props",nD[nD.Select=170]="Select",nD[nD.Undo=171]="Undo",nD[nD.Hiragana=172]="Hiragana",nD[nD.Katakana=173]="Katakana",nD[nD.Unidentified=174]="Unidentified";var hw=((nO=(nI=function(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new dt,this._curFrameDownList=new dt,this._curFrameUpList=new dt,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var t=this._nativeEvents,r=this._curFrameDownList,n=this._curFrameUpList;if(r.length=0,n.length=0,t.length>0){for(var a=this._engine.time.frameCount,i=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,u=t.length;c<u;c++){var d=t[c],h=e.Keys[d.code];switch(d.type){case"keydown":null==i[h]&&(r.add(h),o.add(h),i[h]=o.length-1,s[h]=a);break;case"keyup":var _=i[h];if(null!=_){i[h]=null;var f=o.deleteByIndex(_);f&&(i[f]=_)}if(n.add(h),l[h]=a,hE.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)i[o.get(p)]=null;o.length=0}}}t.length=0}},nO._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},nO._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},nO._onKeyEvent=function(e){this._nativeEvents.push(e)},nO._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},nO._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},nI);e.Collider=(uo(nV=function(e){var t;return(t=uB.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},uB),(nN=nV.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))},nN.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))},nN.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},nN._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}},nN._onLateUpdate=function(){},nN._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])},nN._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])},nN._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},nN._onDestroy=function(){uB.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nN._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},ua(nV,[{key:"shapes",get:function(){return this._shapes}}]),nV),us([uc],e.Collider.prototype,"_index",void 0),us([uc],e.Collider.prototype,"_nativeCollider",void 0),us([uc],e.Collider.prototype,"_updateFlag",void 0),us([uh],e.Collider.prototype,"_shapes",void 0),e.Collider=us([uI(uV,e.DependentMode.CheckOnly)],e.Collider);var hP=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new dt,this._gravity=new cQ(0,-9.81,0),this._onContactEnter=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t})},this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=e.engine;n._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var r=t.prototype;return r.raycast=function(t,r,n,a){var i,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(i=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(i=n),a&&(i=a);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==i?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var a=o._scene.engine._physicalObjectsMap[e];i.entity=a._collider.entity,i.shape=a,i.distance=t,i.normal.copyFrom(n),i.point.copyFrom(r)})||(i.entity=null,i.shape=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)n.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),r.update(t),this._callColliderOnLateUpdate()},r._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},r._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},r._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},r._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},r._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},r._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},r._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},r._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},r._gc=function(){this._colliders.garbageCollection()},r._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},ua(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,cq.zeroTolerance)}}]),t}();hP._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nk=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nk.PreventClimbing=0]="PreventClimbing",nk[nk.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var hF=(nz=e.Collider,uo(nU=function(t){var r;return(r=nz.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new cQ(0,1,0),r._slopeLimit=.707,r._nativeCollider=hP._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(ur(r)),r._upDirection._onValueChanged=r._setUpDirection,r},nz),(nG=nU.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},nG.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nz.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nG.clearShapes=function(){this._shapes.length>0&&nz.prototype.removeShape.call(this,this._shapes[0])},nG._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var r=e.lossyWorldScale,n=0,a=t.length;n<a;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},nG._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},nG._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])},nG._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])},nG._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},ua(nU,[{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))}}]),nU),hL=(nH=e.Collider,uo(nW=function(e){(t=nH.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new cQ,t._angularVelocity=new cQ,t._mass=1,t._centerOfMass=new cQ,t._inertiaTensor=new cQ(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=hP._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(ur(t)),t._setAngularVelocity=t._setAngularVelocity.bind(ur(t)),t._setCenterOfMass=t._setCenterOfMass.bind(ur(t)),t._setInertiaTensor=t._setInertiaTensor.bind(ur(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},nH),(nj=nW.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},nj.applyTorque=function(e){this._nativeCollider.addTorque(e)},nj.move=function(e,t){this._nativeCollider.move(e,t)},nj.sleep=function(){this._nativeCollider.sleep()},nj.wakeUp=function(){this._nativeCollider.wakeUp()},nj._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},nj._cloneTo=function(e){nH.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},nj._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},nj._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},nj._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},nj._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},ua(nW,[{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))}}]),nW);us([uc],hL.prototype,"_linearDamping",void 0),us([uc],hL.prototype,"_angularDamping",void 0),us([uc],hL.prototype,"_linearVelocity",void 0),us([uc],hL.prototype,"_angularVelocity",void 0),us([uc],hL.prototype,"_mass",void 0),us([uc],hL.prototype,"_centerOfMass",void 0),us([uc],hL.prototype,"_inertiaTensor",void 0),us([uc],hL.prototype,"_maxAngularVelocity",void 0),us([uc],hL.prototype,"_maxDepenetrationVelocity",void 0),us([uc],hL.prototype,"_solverIterations",void 0),us([uc],hL.prototype,"_isKinematic",void 0),us([uc],hL.prototype,"_constraints",void 0),us([uc],hL.prototype,"_collisionDetectionMode",void 0),us([uc],hL.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(nK=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nK.Discrete=0]="Discrete",nK[nK.Continuous=1]="Continuous",nK[nK.ContinuousDynamic=2]="ContinuousDynamic",nK[nK.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(nX=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[nX.None=0]="None",nX[nX.FreezePositionX=1]="FreezePositionX",nX[nX.FreezePositionY=2]="FreezePositionY",nX[nX.FreezePositionZ=4]="FreezePositionZ",nX[nX.FreezeRotationX=8]="FreezeRotationX",nX[nX.FreezeRotationY=16]="FreezeRotationY",nX[nX.FreezeRotationZ=32]="FreezeRotationZ";var hB=function(){this.entity=null,this.distance=0,this.point=new cQ,this.normal=new cQ,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(nY=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nY.Average=0]="Average",nY[nY.Minimum=1]="Minimum",nY[nY.Multiply=2]="Multiply",nY[nY.Maximum=3]="Maximum";var hD=((nq=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=hP._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},ua(nq,[{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))}}]),nq),hI=(nQ=e.Collider,uo(nZ=function(e){var t,r=(t=nQ.call(this,e)||this).entity.transform;return t._nativeCollider=hP._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},nQ),nZ);e.ColliderShapeUpAxis=void 0,(nJ=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nJ.X=0]="X",nJ[nJ.Y=1]="Y",nJ[nJ.Z=2]="Z",e.ControllerCollisionFlag=void 0,(n$=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[n$.Sides=1]="Sides",n$[n$.Up=2]="Up",n$[n$.Down=4]="Down",e.Joint=(uo(n0=function(e){var t;return(t=uB.call(this,e)||this)._colliderInfo=new hO,t._connectedColliderInfo=new hO,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new cQ,t},uB),n0.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},ua(n0,[{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))}}]),n0),us([uc],e.Joint.prototype,"_colliderInfo",void 0),us([uc],e.Joint.prototype,"_connectedColliderInfo",void 0),us([uc],e.Joint.prototype,"_nativeJoint",void 0),us([uc],e.Joint.prototype,"_force",void 0),us([uc],e.Joint.prototype,"_torque",void 0),e.Joint=us([uI(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var hO=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},hV=(n1=e.Joint,uo(n2=function(){return n1.apply(this,arguments)},n1),n2.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hP._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n2);(n3=cC||(cC={}))[n3.None=0]="None",n3[n3.LimitEnabled=1]="LimitEnabled",n3[n3.DriveEnabled=2]="DriveEnabled",n3[n3.DriveFreeSpin=4]="DriveFreeSpin";var hN=(n4=e.Joint,uo(n8=function(){var e;return e=n4.apply(this,arguments)||this,e._axis=new cQ(1,0,0),e._hingeFlags=cC.None,e._useSpring=!1,e},n4),(n5=n8.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cQ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hP._nativePhysics.createHingeJoint(t.collider._nativeCollider)},n5._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},ua(n8,[{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&cC.LimitEnabled)==cC.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=cC.LimitEnabled:this._hingeFlags&=~cC.LimitEnabled,this._nativeJoint.setHingeJointFlag(cC.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&cC.DriveEnabled)==cC.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=cC.DriveEnabled:this._hingeFlags&=~cC.DriveEnabled,this._nativeJoint.setHingeJointFlag(cC.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(cC.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))}}]),n8);us([uc],hN.prototype,"_axis",void 0),us([uc],hN.prototype,"_hingeFlags",void 0),us([uc],hN.prototype,"_useSpring",void 0),us([uc],hN.prototype,"_jointMonitor",void 0),us([uc],hN.prototype,"_limits",void 0);var hk=(n9=e.Joint,uo(n6=function(){var e;return e=n9.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},n9),(n7=n6.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cQ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hP._nativePhysics.createSpringJoint(t.collider._nativeCollider)},n7._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},ua(n6,[{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))}}]),n6),hz=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},hU=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},hG=function(){function e(){this._isTrigger=!1,this._rotation=new cQ,this._position=new cQ,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new hD,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)},ua(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}();hG._idGenerator=0,us([uc],hG.prototype,"_collider",void 0),us([uc],hG.prototype,"_nativeShape",void 0),us([uc],hG.prototype,"_id",void 0),us([uc],hG.prototype,"_material",void 0),us([uc],hG.prototype,"_isTrigger",void 0),us([uc],hG.prototype,"_rotation",void 0),us([uc],hG.prototype,"_position",void 0),us([uc],hG.prototype,"_contactOffset",void 0);var hH=(uo(ae=function(){var e;return(e=hG.call(this)||this)._size=new cQ(1,1,1),e._nativeShape=hP._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(ur(e)),e._size._onValueChanged=e._setSize,e},hG),(at=ae.prototype)._cloneTo=function(e){hG.prototype._cloneTo.call(this,e),e.size=this.size},at._setSize=function(){this._nativeShape.setSize(this._size)},ua(ae,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),ae);us([uc],hH.prototype,"_size",void 0);var hW=(uo(ar=function(){var e;return(e=hG.call(this)||this)._radius=1,e._nativeShape=hP._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},hG),ar.prototype._cloneTo=function(e){hG.prototype._cloneTo.call(this,e),e.radius=this.radius},ua(ar,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),ar);us([uc],hW.prototype,"_radius",void 0);var hj=(uo(an=function(){var e;return(e=hG.call(this)||this)._nativeShape=hP._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},hG),an),hK=(uo(aa=function(){var t;return(t=hG.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=hP._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},hG),aa.prototype._cloneTo=function(e){hG.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},ua(aa,[{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))}}]),aa);us([uc],hK.prototype,"_radius",void 0),us([uc],hK.prototype,"_height",void 0),us([uc],hK.prototype,"_upAxis",void 0);var hX=((ao=(ai=function(t,r){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new dt,this._downList=new dt,this._nativeEvents=[],"undefined"!=typeof Window&&ul(r,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=t,this._target=r,this._canvas=t.canvas,this._htmlCanvas=t._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,a=this._canvas,i=a.width,o=a.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),u=c.left,d=c.top,h=i/s,_=o/l,f=t.length-1;f>=0;f--)t[f].phase===e.PointerPhase.Leave&&t.splice(f,1);for(var p=0,m=r.length;p<m;p++){var g=r[p],v=g.pointerId,y=this._getPointerByID(v);if(y)y._events.push(g);else{var x=t.length;if(0===x||this._multiPointerEnabled){for(var b,T=this._pointerPool,C=0;C<x&&!(t[C].id>C);C++);(y=T[b=C]||(T[b]=new hA(C)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-u)*h,(g.clientY-d)*_),t.splice(C,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var S=this._engine.time.frameCount,A=0,M=t.length;A<M;A++){var R=t[A];R._upList.length=R._downList.length=0,this._updatePointerInfo(S,R,u,d,h,_),this._buttons|=R.pressedButtons}},ao._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,a=0,i=r.length;a<i;a++){var o=r[a],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/n.width,l.y/n.height);o._firePointerExitAndEnter(c);var 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}}},ao._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},ao._onPointerEvent=function(e){this._nativeEvents.push(e)},ao._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},ao._updatePointerInfo=function(t,r,n,a,i,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)*i,m=(f.clientY-a)*o;r.deltaPosition.set(p-l.x,m-l.y),l.set(p,m);for(var g=0;g<c;g++){var v=s[g],y=v.button;switch(r.button=hM[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},ao._pointerRayCast=function(t,r,n){for(var a=ai._tempPoint,i=ai._tempRay,o=ai._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,u=c._elements,d=c.length-1;d>=0;d--){var h=u[d];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(r>=f&&n>=p&&r-f<=m&&n-p<=g){if(a.set((r-f)/m,(n-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},ao._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},ao._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},ai);hX._tempRay=new c8,hX._tempPoint=new c5,hX._tempHitResult=new hB;var hY=((al=(as=function(e,t){this._delta=new cQ,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var r=t.length-1;r>=0;r--){var n=t[r];e.x+=n.deltaX,e.y+=n.deltaY,e.z+=n.deltaZ}t.length=0}},al._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},al._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},al._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},al._onWheelEvent=function(e){this._nativeEvents.push(e)},as),hq=((au=(ac=function(e,t){this._initialized=!1,this._engine=e;var r,n,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&ul(i,OffscreenCanvas)||(this._wheelManager=new hY(e,null!=(r=null==t?void 0:t.wheelTarget)?r:i),this._pointerManager=new hX(e,null!=(n=null==t?void 0:t.pointerTarget)?n:i),this._keyboardManager=new hw(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},au.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},au.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},au.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},au.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[hR[e]]===this._engine.time.frameCount)},au.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[hR[e]]===this._engine.time.frameCount)},au._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},au._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},au._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},ua(ac,[{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}}]),ac);(cS||(cS={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(ad=cA||(cA={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",ad.DirectionTime="a_DirectionTime",ad.StartColor="a_StartColor",ad.StartSize="a_StartSize",ad.StartRotation0="a_StartRotation0",ad.StartSpeed="a_StartSpeed",ad.Random0="a_Random0",ad.Random1="a_Random1",ad.SimulationWorldPosition="a_SimulationWorldPosition",ad.SimulationWorldRotation="a_SimulationWorldRotation",ad.SimulationUV="a_SimulationUV";var hQ=function t(r){this.billboardVertexElement=new dO(cS.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new dO(cA.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new dO(cA.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new dO(cA.StartColor,32,e.VertexElementFormat.Vector4,1,1),new dO(cA.StartSize,48,e.VertexElementFormat.Vector3,1,1),new dO(cA.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new dO(cA.StartSpeed,72,e.VertexElementFormat.Float,1,1),new dO(cA.Random0,76,e.VertexElementFormat.Vector4,1,1),new dO(cA.Random1,92,e.VertexElementFormat.Vector4,1,1),new dO(cA.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new dO(cA.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new dO(cA.SimulationUV,136,e.VertexElementFormat.Vector4,1,1)];var n,a,i=new dD(r,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);i.isGCIgnored=!0,this.billboardVertexBufferBinding=new dZ(i,16);var o=new dD(r,e.BufferBindFlag.IndexBuffer,t.billboardIndexCount,e.BufferUsage.Static,!1);o.isGCIgnored=!0,this.billboardIndexBufferBinding=new dK(o,e.IndexFormat.UInt8);var s=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),l=new Uint8Array([0,2,3,0,1,2]);i.setData(s),o.setData(l),r.resourceManager.addContentRestorer(new(uo(n=function(){return dM.call(this,i)},dM),n.prototype.restoreContent=function(){i.setData(s)},n)),r.resourceManager.addContentRestorer(new(uo(a=function(){return dM.call(this,o)},dM),a.prototype.restoreContent=function(){},a))};hQ.instanceVertexStride=152,hQ.instanceVertexFloatStride=hQ.instanceVertexStride/4,hQ.startLifeTimeOffset=3,hQ.timeOffset=7,hQ.simulationUVOffset=34,hQ.billboardIndexCount=6,hQ.boundsFloatStride=8,hQ.boundsTimeOffset=6,hQ.boundsMaxLifetimeOffset=7;var hZ="#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}",hJ="#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}",h$=((ah=function(){}).init=function(){var t=new uQ("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_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>\n#include <uv_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\nuniform vec4 material_BaseColor;uniform sampler2D material_BaseTexture;uniform float material_AlphaCutoff;varying vec2 v_uv;void main(){\n#if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\nfloat alpha=material_BaseColor.a;\n#ifdef MATERIAL_HAS_BASETEXTURE\nalpha*=texture2D(material_BaseTexture,v_uv).a;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(alpha<material_AlphaCutoff){discard;}\n#endif\n#if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\nfloat noise=fract(52.982919*fract(dot(vec2(0.06711,0.00584),gl_FragCoord.xy)));if(alpha<=noise){discard;};\n#endif\n#endif\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});t._renderState=new u3,t._renderStateDataMap[e.RenderStateDataKey.RenderQueueType]=dN._shadowCasterRenderQueueProp;var r=new uQ("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:e.PipelineStage.DepthOnly}),n=[t,r],a={pipelineStage:e.PipelineStage.Forward};u4.create("blinn-phong",[].concat(new uQ("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u4.create("pbr",[].concat(new uQ("Forward",hJ,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u4.create("pbr-specular",[].concat(new uQ("Forward",hJ,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u4.create("unlit",[].concat(new uQ("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u4.create("blit",[new uQ("Forward",hZ,"#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}",a)]),u4.create("skybox",[new uQ("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u4.create("SkyProcedural",[new uQ("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u4.create("particle-shader",[new uQ("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u4.create("SpriteMask",[new uQ("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",a)]),u4.create("Sprite",[new uQ("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),u4.create("Text",[new uQ("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 renderElement_TextTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderElement_TextTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),u4.create("background-texture",[new uQ("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",a)])},ah),h0=((af=(a_=function(){this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,r=e._length,n=this._cacheHierarchyDepth;r>n&&(this._resizeCacheMapHierarchy(t,0,n,r-n),this._cacheHierarchyDepth=r);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=i<o?0:a[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},af.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},af._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},af._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var r in t)t[r].destroy();return}for(var n in++e,t)this._recursiveDestroy(e,t[n])},af._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var a in e){for(var i=e[a],o=e,s=0;s<n;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},a_),h1=(uo(ap=function(e){var t;return(t=hu.call(this,e)||this)._usedElementCount=0,t._elements=[],t},hu),(am=ap.prototype).get=function(){var e=this._usedElementCount,t=this._elements;if(this._usedElementCount++,t.length!==e)return t[e];var r=new this._type;return t.push(r),r},am.clear=function(){this._usedElementCount=0},ap),h2=((av=(ag=function(){}).prototype)._initialize=function(e,t){},av._update=function(){},av._destroy=function(){},av._getRequestAnimationFrame=function(){return null},av._getCancelAnimationFrame=function(){return null},av._getCameraClearFlagsMask=function(t){return e.CameraClearFlags.None},ag);h$.init();var h3=function(t){function r(n,a,i){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new u3,o._renderElementPool=new h1(dC),o._subRenderElementPool=new h1(dS),o._textSubRenderElementPool=new h1(dS),o._charRenderInfoPool=new hd(dF,50),o._spriteDefaultMaterials=[],o._renderContext=new d_,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new uU,o._settings={},o._resourceManager=new hx(ur(o)),o._sceneManager=new hv(ur(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new uL,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){if(o._vSyncCount){var e,t=(null==(e=o.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;o._requestId=t(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)}else o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update()},o._hardwareRenderer=a,o._hardwareRenderer.init(n,o._onDeviceLost.bind(ur(o)),o._onDeviceRestored.bind(ur(o))),o._canvas=n;var o,s=ur(o)._spriteDefaultMaterials;o._spriteDefaultMaterial=s[e.SpriteMaskInteraction.None]=o._createSpriteMaterial(e.SpriteMaskInteraction.None),s[e.SpriteMaskInteraction.VisibleInsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleInsideMask),s[e.SpriteMaskInteraction.VisibleOutsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleOutsideMask),o._textDefaultMaterial=o._createTextMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=dP.createFromOS(ur(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o._batcherManager=new hm(ur(o)),o.inputManager=new hq(ur(o),i.input);var l=i.xrDevice;if(l&&(o.xrManager=new h2,o.xrManager._initialize(ur(o),l)),a.canIUse(e.GLCapabilityType.depthTexture)){var c=new di(ur(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(r._noDepthTextureMacro);var u=new dV(ur(o),u4.find("unlit"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new c6(1,0,1.01,1)),o._meshMagentaMaterial=u;var d=new dV(ur(o),u4.find("particle-shader"));d.isGCIgnored=!0,d.shaderData.setColor("material_BaseColor",new c6(1,0,1.01,1)),o._particleMagentaMaterial=d;var h=o._settings,_=i.colorSpace||e.ColorSpace.Linear;return _===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),h.colorSpace=_,o._basicResources=new hc(ur(o)),o._particleBufferUtils=new hQ(ur(o)),o}uo(r,t);var n=r.prototype;return n.createEntity=function(e){return new ho(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var r=t.deltaTime;this._frameInProcess=!0,this._subRenderElementPool.clear(),this._textSubRenderElementPool.clear(),this._renderElementPool.clear(),null==(e=this.xrManager)||e._update();var n=this.inputManager,a=this._physicsInitialized;n._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var u=0;u<o;u++){var d=i[u];d.isActive&&!d.destroyed&&d.physics._update(r)}a&&n._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(r)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(r)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(r)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this._batcherManager.destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,r=this._shaderProgramPools,n=r[t];if(!n){var a=t+1;a>r.length&&(r.length=a),r[t]=n=new h0,e._shaderProgramPools.push(n)}return n},n._render=function(e){for(var t=this,r=this.time.deltaTime,n=0,a=e.length;n<a;n++){var i=e[n];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(r),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(r,n){var a=e[r];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return uP.debug("No active camera in scene.");i.forEach(function(e){var r=a._componentsManager;r.callCameraOnBeginRender(e),e.render(),r.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&!u4._shaderLab&&(u4._shaderLab=r);var a=[];n&&a.push(n.initialize().then(function(){return hP._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=hx._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new dV(this,u4.find("Sprite")),n=r.renderState,a=n.blendState.targetBlendState;if(a.enabled=!0,a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var i=n.stencilState;i.enabled=!0,i.writeMask=0,i.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;i.compareFunctionFront=o,i.compareFunctionBack=o}return n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,n.renderQueueType=e.RenderQueueType.Transparent,r.isGCIgnored=!0,r},n._createSpriteMaskMaterial=function(){var t=new dV(this,u4.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,r.renderQueueType=e.RenderQueueType.Transparent,t.isGCIgnored=!0,t},n._createTextMaterial=function(){var t=new dV(this,u4.find("Text")),r=t.renderState,n=r.blendState.targetBlendState;return n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.colorBlendOperation=n.alphaBlendOperation=e.BlendOperation.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=e.CullMode.Off,r.renderQueueType=e.RenderQueueType.Transparent,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 u3,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._subRenderElementPool.garbageCollection(),this._textSubRenderElementPool.garbageCollection(),this._renderElementPool.garbageCollection(),this._renderContext.garbageCollection()},ua(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}(uS);h3._gammaMacro=uz.getByName("ENGINE_IS_COLORSPACE_GAMMA"),h3._noDepthTextureMacro=uz.getByName("ENGINE_NO_DEPTH_TEXTURE"),h3._pixelsPerUnit=100;var h4=(ua(ay=function(){this._sizeUpdateFlagManager=new ub},[{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())}}]),ay),h8=((ab=(ax=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},ab._render=function(e){var t=this.material,r=this.mesh;if(!t){uP.warn("The material of sky is not defined.");return}if(t.destroyed){uP.warn("The material of sky is destroyed.");return}if(!r){uP.warn("The mesh of sky is not defined.");return}if(r.destroyed){uP.warn("The mesh of sky is destroyed.");return}var n=e.camera,a=n.engine,i=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,u=i.shaderData,d=ax._viewProjMatrix,h=ax._projectionMatrix,_=a._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(cq.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,c4.multiply(h,d,d);var y=c.getMatrix(d_.vpMatrixProperty);e.flipProjection&&c4.multiply(d_._flipYMatrix,d,d),c.setMatrix(d_.vpMatrixProperty,d);var x=u4._compileMacros;uU.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var b=p.subShaders[0].passes[0],T=b._getShaderProgram(a,x);T.bind(),T.groupingOtherUniformBlock(),T.uploadAll(T.sceneUniformBlock,u),T.uploadAll(T.cameraUniformBlock,c),T.uploadAll(T.materialUniformBlock,f),T.uploadUnGroupTextures(),m._applyStates(a,!1,b._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,T),c.setMatrix(d_.vpMatrixProperty,y)},ua(ax,[{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}}}]),ax);h8._epsilon=1e-6,h8._viewProjMatrix=new c4,h8._projectionMatrix=new c4(1,0,0,0,0,1,0,0,0,0,h8._epsilon-1,-1,0,0,0,0);var h5=((aC=(aT=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new c6(.25,.25,.25,1),this.sky=new h8,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()},aC._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,a=n.width,i=n.height,o=r.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.Fill:o[0].set(-1,-1,1),o[1].set(1,-1,1),o[2].set(-1,1,1),o[3].set(1,1,1);break;case e.BackgroundTextureFillMode.AspectFitWidth:var s=t.height*a/t.width/i;o[0].set(-1,-s,1),o[1].set(1,-s,1),o[2].set(-1,s,1),o[3].set(1,s,1);break;case e.BackgroundTextureFillMode.AspectFitHeight:var l=t.width*i/t.height/a;o[0].set(-l,-1,1),o[1].set(l,-1,1),o[2].set(-l,1,1),o[3].set(l,1,1)}r.setPositions(o),r.uploadData(!1)}},aC._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},aC._initMaterial=function(t){var r=this._material=new dV(t,u4.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},aC._createPlane=function(e){for(var t=new d1(e),r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],a=[,,,,],i=0;i<4;++i)n[i]=new cQ,a[i]=new c5(i%2,1-(.5*i|0));return t.setPositions(n),t.setUVs(a),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},ua(aT,[{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())}}]),aT),h9=((aA=(aS=function(){this._cameraNeedSorting=!1,this._activeCameras=new dt,this._renderers=new dt,this._onStartScripts=new dt,this._onUpdateScripts=new dt,this._onLateUpdateScripts=new dt,this._onPhysicsUpdateScripts=new dt,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new dt,this._onUpdateRenderers=new dt,this._componentsContainerPool=[]}).prototype).addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},aA.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},aA.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,r=e.length;t<r;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},aA.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},aA.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},aA.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},aA.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},aA.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},aA.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},aA.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},aA.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},aA.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},aA.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},aA.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},aA.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},aA.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},aA.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},aA.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},aA.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},aA.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aA.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aA.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}},aA.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},aA.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},aA.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},aA.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},aA._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},aS);e.FogMode=void 0,(aM=e.FogMode||(e.FogMode={}))[aM.None=0]="None",aM[aM.Linear=1]="Linear",aM[aM.Exponential=2]="Exponential",aM[aM.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(aR=e.DiffuseMode||(e.DiffuseMode={}))[aR.SolidColor=0]="SolidColor",aR[aR.SphericalHarmonics=1]="SphericalHarmonics";var h6=(uo(aE=function(t){var r;return(r=up.call(this,t)||this)._diffuseSolidColor=new c6(.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},up),(aw=aE.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(aE._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(aE._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(aE._specularIntensityProperty,this._specularIntensity),t.setFloatArray(aE._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},aw._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(aE._specularTextureProperty,null),n.disableMacro(aE._specularMacro)},aw._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(aE._shMacro):t.disableMacro(aE._shMacro)},aw._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(aE._specularTextureProperty,this._specularTexture),e.setFloat(aE._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(aE._specularMacro)):e.disableMacro(aE._specularMacro)},aw._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(aE._decodeRGBMMacro):e.disableMacro(aE._decodeRGBMMacro)},aw._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]},ua(aE,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTextureDecodeRGBM(t[r].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setDiffuseMode(t[r].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloatArray(aE._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloat(aE._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTexture(t[r].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var t=0,r=this._scenes.length;t<r;t++)this._scenes[t].shaderData.setFloat(aE._specularIntensityProperty,e)}}]),aE);h6._shMacro=uz.getByName("SCENE_USE_SH"),h6._specularMacro=uz.getByName("SCENE_USE_SPECULAR_ENV"),h6._decodeRGBMMacro=uz.getByName("SCENE_IS_DECODE_ENV_RGBM"),h6._diffuseColorProperty=uF.getByName("scene_EnvMapLight.diffuse"),h6._diffuseSHProperty=uF.getByName("scene_EnvSH"),h6._diffuseIntensityProperty=uF.getByName("scene_EnvMapLight.diffuseIntensity"),h6._specularTextureProperty=uF.getByName("scene_EnvSpecularSampler"),h6._specularIntensityProperty=uF.getByName("scene_EnvMapLight.specularIntensity"),h6._mipLevelProperty=uF.getByName("scene_EnvMapLight.mipMapLevel");var h7=(uo(aP=function(){var t;return t=uB.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._lightIndex=-1,t._lightColor=new c6,t._shadowStrength=1,t._color=new c6(1,1,1,1),t},uB),aP.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},ua(aP,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=cq.clamp(e,0,1)}},{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 c4),c4.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new c4),c4.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),aP);us([uc],h7.prototype,"_lightIndex",void 0);var _e=(uo(aF=function(){var e;return e=h7.apply(this,arguments)||this,e._reverseDirection=new cQ,e},h7),(aL=aF.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.direction,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c6.gammaToLinearSpace(o.r),r.color[a+1]=c6.gammaToLinearSpace(o.g),r.color[a+2]=c6.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.direction[i]=s.x,r.direction[i+1]=s.y,r.direction[i+2]=s.z},aL._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},aL._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},aF._updateShaderData=function(e,t){e.setIntArray(aF._cullingMaskProperty,t.cullingMask),e.setFloatArray(aF._colorProperty,t.color),e.setFloatArray(aF._directionProperty,t.direction)},ua(aF,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cQ.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aF);_e._cullingMaskProperty=uF.getByName("scene_DirectLightCullingMask"),_e._colorProperty=uF.getByName("scene_DirectLightColor"),_e._directionProperty=uF.getByName("scene_DirectLightDirection");var _t=(uo(aB=function(){var e;return e=h7.apply(this,arguments)||this,e.distance=100,e},h7),(aD=aB.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c6.gammaToLinearSpace(o.r),r.color[a+1]=c6.gammaToLinearSpace(o.g),r.color[a+2]=c6.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.position[i]=s.x,r.position[i+1]=s.y,r.position[i+2]=s.z,r.distance[t]=this.distance},aD._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},aD._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},aB._updateShaderData=function(e,t){e.setIntArray(aB._cullingMaskProperty,t.cullingMask),e.setFloatArray(aB._colorProperty,t.color),e.setFloatArray(aB._positionProperty,t.position),e.setFloatArray(aB._distanceProperty,t.distance)},ua(aB,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aB);_t._cullingMaskProperty=uF.getByName("scene_PointLightCullingMask"),_t._colorProperty=uF.getByName("scene_PointLightColor"),_t._positionProperty=uF.getByName("scene_PointLightPosition"),_t._distanceProperty=uF.getByName("scene_PointLightDistance");var _r=(uo(aI=function(){var e;return e=h7.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new cQ,e._projectMatrix=new c4,e},h7),(aO=aI.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,u=this.cullingMask;r.cullingMask[n]=65535&u,r.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c6.gammaToLinearSpace(s.r),r.color[a+1]=c6.gammaToLinearSpace(s.g),r.color[a+2]=c6.gammaToLinearSpace(s.b)):(r.color[a]=s.r,r.color[a+1]=s.g,r.color[a+2]=s.b),r.position[i]=l.x,r.position[i+1]=l.y,r.position[i+2]=l.z,r.direction[o]=c.x,r.direction[o+1]=c.y,r.direction[o+2]=c.z,r.distance[t]=this.distance,r.angleCos[t]=Math.cos(this.angle),r.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},aO._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},aO._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},aI._updateShaderData=function(e,t){e.setIntArray(aI._cullingMaskProperty,t.cullingMask),e.setFloatArray(aI._colorProperty,t.color),e.setFloatArray(aI._positionProperty,t.position),e.setFloatArray(aI._directionProperty,t.direction),e.setFloatArray(aI._distanceProperty,t.distance),e.setFloatArray(aI._angleCosProperty,t.angleCos),e.setFloatArray(aI._penumbraCosProperty,t.penumbraCos)},ua(aI,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cQ.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 c4.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),aI);_r._cullingMaskProperty=uF.getByName("scene_SpotLightCullingMask"),_r._colorProperty=uF.getByName("scene_SpotLightColor"),_r._positionProperty=uF.getByName("scene_SpotLightPosition"),_r._directionProperty=uF.getByName("scene_SpotLightDirection"),_r._distanceProperty=uF.getByName("scene_SpotLightDistance"),_r._angleCosProperty=uF.getByName("scene_SpotLightAngleCos"),_r._penumbraCosProperty=uF.getByName("scene_SpotLightPenumbraCos");var _n=function(){function t(){this._spotLights=new dt,this._pointLights=new dt,this._directLights=new dt,this._directData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight)},this._pointData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight)},this._spotData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight),angleCos:new Float32Array(t._maxLight),penumbraCos:new Float32Array(t._maxLight)}}var r=t.prototype;return r._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},r._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},r._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},r._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._updateShaderData=function(e){for(var r=this._spotLights,n=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=t._maxLight,c=Math.min(r.length,l),u=Math.min(n.length,l),d=Math.min(a.length,l),h=0;h<c;h++)r.get(h)._appendData(h,i);for(var _=0;_<u;_++)n.get(_)._appendData(_,o);for(var f=0;f<d;f++)a.get(f)._appendData(f,s);d?(_e._updateShaderData(e,s),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(_t._updateShaderData(e,o),e.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(_r._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._updateSunlightIndex=function(e){var t=this._directLights,r=e._lightIndex;if(r>0){var n=t.get(0),a=t.get(r);t.set(0,a),t.set(r,n),a._lightIndex=0,n._lightIndex=r}},r._getMaxBrightestSunlight=function(){for(var t=this._directLights,r=null,n=Number.NEGATIVE_INFINITY,a=!1,i=0,o=t.length;i<o;i++){var s=t.get(i);s.shadowType===e.ShadowType.None||a||(n=Number.NEGATIVE_INFINITY,a=!0);var l=s.intensity*s.color.getBrightness();a?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=s):n<l&&(n=l,r=s)}return r},t}();_n._sunlightColorProperty=uF.getByName("scene_SunlightColor"),_n._sunlightDirectionProperty=uF.getByName("scene_SunlightDirection"),_n._maxLight=10,e.BloomDownScaleMode=void 0,(aV=e.BloomDownScaleMode||(e.BloomDownScaleMode={}))[aV.Half=0]="Half",aV[aV.Quarter=1]="Quarter";var _a=function(){function t(e){this._uberMaterial=e,this._highQualityFiltering=!1,this._mipDownRT=[],this._mipUpRT=[],this._maxIterations=6,this._enabled=!1,this.downScale=0;var r=e.engine,n=new dV(r,u4.find(t.SHADER_NAME)),a=n.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=n.shaderData,o=e.shaderData;i.setVector4(t._bloomParams,new c9),i.setVector4(t._lowMipTexelSizeProp,new c9),o.setVector4(t._bloomIntensityParams,new c9(1,1,0,0)),o.setVector4(t._dirtTilingOffsetProp,new c9),o.setColor(t._tintProp,new c6(1,1,1,1)),this._bloomMaterial=n,this.threshold=.9,this.scatter=.7,this.intensity=1,this.dirtIntensity=1}var r=t.prototype;return r.onRender=function(e,t){var r=e.camera,n=0===this.downScale?1:2,a=r.pixelViewport,i=a.width>>n,o=a.height>>n,s=this._calculateMipCount(i,o);this._prefilter(r,t,i,o,s),this._downsample(s),this._upsample(s),this._setupUber(r)},r._calculateMipCount=function(e,t){return Math.min(Math.max(Math.floor(Math.log2(Math.max(e,t))-1),1),this._maxIterations)},r._prefilter=function(t,r,n,a,i){for(var o=this._uberMaterial.engine,s=t._getInternalColorTextureFormat(),l=n,c=a,u=0;u<i;u++)this._mipUpRT[u]=dc.recreateRenderTargetIfNeeded(o,this._mipUpRT[u],l,c,s,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear),this._mipDownRT[u]=dc.recreateRenderTargetIfNeeded(o,this._mipDownRT[u],l,c,s,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear),l=Math.max(1,Math.floor(l/2)),c=Math.max(1,Math.floor(c/2));dc.blitTexture(o,r,this._mipDownRT[0],void 0,void 0,this._bloomMaterial,0)},r._downsample=function(e){for(var t=this._bloomMaterial,r=t.engine,n=this._mipDownRT[0],a=1;a<e;a++)dc.blitTexture(r,n.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),dc.blitTexture(r,this._mipUpRT[a].getColorTexture(0),this._mipDownRT[a],void 0,void 0,t,2),n=this._mipDownRT[a]},r._upsample=function(e){for(var r=this._bloomMaterial,n=r.engine,a=r.shaderData,i=e-2;i>=0;i--){var o=i==e-2?this._mipDownRT[i+1]:this._mipUpRT[i+1],s=this._mipDownRT[i],l=this._mipUpRT[i];a.setTexture(t._lowMipTextureProp,o.getColorTexture(0)),this.highQualityFiltering&&a.getVector4(t._lowMipTexelSizeProp).set(1/o.width,1/o.height,o.width,o.height),dc.blitTexture(n,s.getColorTexture(0),l,void 0,void 0,r,3)}},r._setupUber=function(e){var r=this._uberMaterial.shaderData,n=this.dirtTexture;if(n){var a=r.getVector4(t._dirtTilingOffsetProp),i=n.width/n.height,o=e.aspectRatio;i>o?a.set(o/i,1,(1-a.x)*.5,0):i<o?a.set(1,i/o,0,(1-a.y)*.5):a.set(1,1,0,0)}r.setTexture(t._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},r._releaseRenderTargets=function(){for(var e=this._mipDownRT.length,t=0;t<e;t++){var r=this._mipDownRT[t],n=this._mipUpRT[t];r&&(r.getColorTexture(0).destroy(!0),r.destroy(!0)),n&&(n.getColorTexture(0).destroy(!0),n.destroy(!0))}this._mipDownRT.length=0,this._mipUpRT.length=0},ua(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,e?this._uberMaterial.shaderData.enableMacro(t._enableMacro):(this._uberMaterial.shaderData.disableMacro(t._enableMacro),this._releaseRenderTargets()))}},{key:"threshold",get:function(){return this._threshold},set:function(e){if((e=Math.max(0,e))!==this._threshold){this._threshold=e;var r=c6.gammaToLinearSpace(e),n=.5*r,a=this._bloomMaterial.shaderData.getVector4(t._bloomParams);a.x=r,a.y=n}}},{key:"scatter",get:function(){return this._scatter},set:function(e){if((e=cq.clamp(e,0,1))!==this._scatter){this._scatter=e;var r=this._bloomMaterial.shaderData.getVector4(t._bloomParams),n=cq.lerp(.05,.95,e);r.z=n}}},{key:"intensity",get:function(){return this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).x},set:function(e){e=Math.max(0,e),this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).x=e}},{key:"tint",get:function(){return this._uberMaterial.shaderData.getColor(t._tintProp)},set:function(e){var r=this._uberMaterial.shaderData.getColor(t._tintProp);e!==r&&r.copyFrom(e)}},{key:"highQualityFiltering",get:function(){return this._highQualityFiltering},set:function(e){e!==this._highQualityFiltering&&(this._highQualityFiltering=e,e?(this._bloomMaterial.shaderData.enableMacro(t._hqMacro),this._uberMaterial.shaderData.enableMacro(t._hqMacro)):(this._bloomMaterial.shaderData.disableMacro(t._hqMacro),this._uberMaterial.shaderData.disableMacro(t._hqMacro)))}},{key:"dirtTexture",get:function(){return this._uberMaterial.shaderData.getTexture(t._dirtTextureProp)},set:function(e){this._uberMaterial.shaderData.setTexture(t._dirtTextureProp,e),e?this._uberMaterial.shaderData.enableMacro(t._dirtMacro):this._uberMaterial.shaderData.disableMacro(t._dirtMacro)}},{key:"dirtIntensity",get:function(){return this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).y},set:function(e){e=Math.max(0,e),this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).y=e}}]),t}();_a.SHADER_NAME="PostProcessEffect Bloom",_a._hqMacro=uz.getByName("BLOOM_HQ"),_a._dirtMacro=uz.getByName("BLOOM_DIRT"),_a._bloomParams=uF.getByName("material_BloomParams"),_a._lowMipTextureProp=uF.getByName("material_lowMipTexture"),_a._lowMipTexelSizeProp=uF.getByName("material_lowMipTexelSize"),_a._enableMacro=uz.getByName("ENABLE_EFFECT_BLOOM"),_a._bloomTextureProp=uF.getByName("material_BloomTexture"),_a._dirtTextureProp=uF.getByName("material_BloomDirtTexture"),_a._tintProp=uF.getByName("material_BloomTint"),_a._bloomIntensityParams=uF.getByName("material_BloomIntensityParams"),_a._dirtTilingOffsetProp=uF.getByName("material_BloomDirtTilingOffset"),u4.create(_a.SHADER_NAME,[new uQ("Bloom Prefilter",hZ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uQ("Bloom Blur Horizontal",hZ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uQ("Bloom Blur Vertical",hZ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uQ("Bloom Upsample",hZ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}")]),e.TonemappingMode=void 0,(aN=e.TonemappingMode||(e.TonemappingMode={}))[aN.Neutral=0]="Neutral",aN[aN.ACES=1]="ACES";var _i=(ua(ak=function(e){this._uberMaterial=e,this._enabled=!1,this.mode=0},[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,e?this._uberMaterial.shaderData.enableMacro(ak._enableMacro):this._uberMaterial.shaderData.disableMacro(ak._enableMacro))}},{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE",e.toString()))}}]),ak);_i._enableMacro=uz.getByName("ENABLE_EFFECT_TONEMAPPING");var _o=function(){function e(t){this.scene=t,this.isActive=!0;var r=u4.find(e.UBER_SHADER_NAME),n=new dV(t.engine,r),a=n.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new _a(n),o=new _i(n);this._uberMaterial=n,this._bloomEffect=i,this._tonemappingEffect=o}return e.prototype._render=function(e,t,r){var n=e.camera,a=n.engine;t._blitRenderTarget();var i=t.getColorTexture(),o=this._bloomEffect;o.enabled&&o.onRender(e,i),dc.blitTexture(a,i,r,0,n.viewport,this._uberMaterial)},ua(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();_o.UBER_SHADER_NAME="UberPost",Object.assign(uH,{PostCommon:"#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n",Filtering:"#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\nvec2 bSpline3MiddleLeft(vec2 x){return 0.16666667+x*(0.5+x*(0.5-x*0.5));}vec2 bSpline3MiddleRight(vec2 x){return 0.66666667+x*(-1.0+0.5*x)*x;}vec2 bSpline3Rightmost(vec2 x){return 0.16666667+x*(-0.5+x*(0.5-x*0.16666667));}void bicubicFilter(vec2 fracCoord,out vec2 weights[2],out vec2 offsets[2]){vec2 r=bSpline3Rightmost(fracCoord);vec2 mr=bSpline3MiddleRight(fracCoord);vec2 ml=bSpline3MiddleLeft(fracCoord);vec2 l=1.0-mr-ml-r;weights[0]=r+mr;weights[1]=ml+l;offsets[0]=-1.0+mr/weights[0];offsets[1]=1.0+l/weights[1];}vec4 sampleTexture2DBicubic(sampler2D tex,vec2 coord,vec4 texSize){vec2 xy=coord*texSize.zw+0.5;vec2 ic=floor(xy);vec2 fc=fract(xy);vec2 weights[2],offsets[2];bicubicFilter(fc,weights,offsets);return weights[0].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[0].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[0].y)-0.5)*texSize.xy))+weights[1].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[1].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[1].y)-0.5)*texSize.xy));}\n#endif\n",ODT:"#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}",RRT:"#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}",Tonescale:"#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n",ColorTransform:"#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n",NeutralTonemapping:"#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}",ACESTonemapping:"#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"}),u4.create(_o.UBER_SHADER_NAME,hZ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}");var _s=function(t){function r(n,a){(i=t.call(this,n)||this).physics=new hP(ur(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new cQ(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i._lightManager=new _n,i._componentsManager=new h9,i._maskManager=new df,i._isActiveInEngine=!1,i._globalShaderMacro=new uU,i._rootEntities=[],i._postProcessManager=new _o(ur(i)),i._background=new h5(i._engine),i._shaderData=new u9(cn.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new c6(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new c9,i._isActive=!0,i._enableTransparentShadow=!1,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new h6(n),n.sceneManager._allCreatedScenes.push(ur(i)),o.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),o.setColor(r._fogColorProperty,i._fogColor),o.setVector4(r._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}uo(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new ho(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?r=e:(r=void 0,t=e);var r,n=t._isRoot;n||(t._isRoot=!0,t._removeFromParent());var a=t._scene;a!==this?(a&&n&&a._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var i=ct.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=ct.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=ct.Scene),i&&t._processInActive(i),a!==this&&ho._traverseSetOwnerScene(t,this);var o=ct.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=ct.Hierarchy)),t._isActiveInScene&&a===this||(o|=ct.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=ct.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=ct.Hierarchy),e._isActiveInScene&&(t|=ct.Scene),t&&e._processInActive(t),ho._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var a=this.getRootEntity(r);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=ho._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,r=t.length-1;r>=0;r--){var n=t[r];n._isActive&&(e?n._processActive(ct.Hierarchy):n._processInActive(ct.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,r=this._engine,n=this._lightManager;r.time._updateSceneShaderData(t),n._updateShaderData(this.shaderData);var a=this._lightManager._sunlight=this._getSunlight();a?(n._updateSunlightIndex(a),t.setColor(_n._sunlightColorProperty,a._lightColor),t.setVector3(_n._sunlightDirectionProperty,a.direction)):t.setVector3(_n._sunlightDirectionProperty,cQ._zero),this.castShadows&&a&&a.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",a.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),uU.unionCollection(this.engine._macroCollection,t._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,r=e._siblingIndex;t.splice(r,1);for(var n=t.length;r<n;r++)t[r]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._engine.sceneManager;for(e.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts(),this._maskManager.destroy();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},n._addToRootEntityList=function(e,t){var r=this._rootEntities,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var r=t-e,n=this._fogParams;n.x=-1/r,n.y=t/r},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},ua(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){uP.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}},{key:"enableTransparentShadow",get:function(){return this._enableTransparentShadow},set:function(e){e!==this._enableTransparentShadow&&(this._enableTransparentShadow=e,e?this.shaderData.enableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"):this.shaderData.disableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"))}}]),r}(uf);_s._fogColorProperty=uF.getByName("scene_FogColor"),_s._fogParamsProperty=uF.getByName("scene_FogParams");var _l=(uo(az=function(){var e;return e=uB.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},uB),(aU=az.prototype).onAwake=function(){},aU.onEnable=function(){},aU.onStart=function(){},aU.onUpdate=function(e){},aU.onLateUpdate=function(e){},aU.onBeginRender=function(e){},aU.onEndRender=function(e){},aU.onPhysicsUpdate=function(){},aU.onTriggerEnter=function(e){},aU.onTriggerExit=function(e){},aU.onTriggerStay=function(e){},aU.onCollisionEnter=function(e){},aU.onCollisionExit=function(e){},aU.onCollisionStay=function(e){},aU.onPointerDown=function(e){},aU.onPointerUp=function(e){},aU.onPointerClick=function(e){},aU.onPointerEnter=function(e){},aU.onPointerExit=function(e){},aU.onPointerDrag=function(e){},aU.onDisable=function(){},aU.onDestroy=function(){},aU._onAwake=function(){this.onAwake()},aU._onEnable=function(){this.onEnable()},aU._onDisable=function(){this.onDisable()},aU._onEnableInScene=function(){var e=this.scene._componentsManager,t=az.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)},aU._onDisableInScene=function(){var e=this.scene._componentsManager,t=az.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)},aU._onDestroy=function(){uB.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},az);us([uc],_l.prototype,"_started",void 0),us([uc],_l.prototype,"_onStartIndex",void 0),us([uc],_l.prototype,"_onUpdateIndex",void 0),us([uc],_l.prototype,"_onLateUpdateIndex",void 0),us([uc],_l.prototype,"_onPhysicsUpdateIndex",void 0),us([uc],_l.prototype,"_onPreRenderIndex",void 0),us([uc],_l.prototype,"_onPostRenderIndex",void 0),us([uc],_l.prototype,"_entityScriptsIndex",void 0);var _c={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},_u=1/0;function _d(e,t){return void 0===t&&(t={}),new hy(function(r,n,a,i){var o,s,l,c,u=null!=(o=t.retryCount)?o:1,d=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:_u,t.type=null!=(c=t.type)?c:_c[e.substring(e.lastIndexOf(".")+1)],new _h(function(){var r;return(r=t,new hy(function(t,n,a,i){var o,s=new XMLHttpRequest,l="image"===r.type;s.timeout=r.timeout,r.method=null!=(o=r.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){n(Error("request failed from: "+e));return}var r,i=null!=(r=s.response)?r:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){n(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){n(Error("request failed from: "+e))},s.ontimeout=function(){n(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(r.method,e,!0),s.withCredentials="include"===r.credentials,s.responseType=l?"blob":r.type;var c=r.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(r.body)})).onProgress(a,i)},u,d).start().onError(n).onComplete(r)})}var _h=((aH=(aG=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},aH.onComplete=function(e){return this._onComplete=e,this},aH.onError=function(e){return this._onError=e,this},aH.cancel=function(){window.clearTimeout(this._timeoutId)},aH.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)})},aG),__=((aW=function(e){this.useCache=e,this.request=_d}).registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},aW.getClass=function(e){return this._engineObjects[e]},aW.getClassName=function(e){return this._classNameMap.get(e)},aW);__._engineObjects={},__._classNameMap=new Map;var _f=((aK=(aj=function(){}).prototype).initialize=function(e){var t=e.component,r=e.property.split(".");if(e.getProperty){var n=e.getProperty.split(".");this._initializeMounted(t,n,1),this._initializeMounted(t,r,2)}else this._initializeMounted(t,r,3)},aK.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},aK.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},aK._initializeMounted=function(e,t,r){for(var n,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var u=c.indexOf("[");e=(e=e[c.slice(0,u)])[parseInt(c.slice(u+1,-1))]}else if(c.endsWith(")")){var d=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[d].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");n=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),n=1,2&r){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else n=0;2&r&&(this._setMounted=e,this._setType=n,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&r&&(this._getMounted=e,this._getType=n,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},aj);(aX=cM||(cM={}))[aX.Property=0]="Property",aX[aX.Method=1]="Method",aX[aX.Array=2]="Array",(aY=cR||(cR={}))[aY.Get=1]="Get",aY[aY.Set=2]="Set",aY[aY.Both=3]="Both";var _p=function(){function e(t,r,n,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=n,this.cureType=o;var s=e.getAssemblerType(r,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,r){return r?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,r,n,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?n?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):n?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,r)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,r){var n=this.cureType;if(r){var a=this._assembler;if(n._isCopyMode)n._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=n._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)n._isCopyMode?n._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(n._isCopyMode){var s=this.referenceTargetValue;n._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=n._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,r){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,r),this.baseEvaluateData.value)},e.registerAssembler=function(t,r,n){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),a=n?n[r]:void 0;return null!=a?a:_f},e}();_p._components=[],_p._assemblerMap=new Map;var _m=((aQ=(aq=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aQ.getTargetValue=function(){return this._transform.position},aQ.setTargetValue=function(e){this._transform.position=e},aq);_p.registerAssembler(uV,"position",_m);var _g=((aJ=(aZ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aJ.getTargetValue=function(){return this._transform.rotationQuaternion},aJ.setTargetValue=function(e){this._transform.rotationQuaternion=e},aZ);_p.registerAssembler(uV,"rotationQuaternion",_g);var _v=((a0=(a$=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},a0.getTargetValue=function(){return this._transform.scale},a0.setTargetValue=function(e){this._transform.scale=e},a$);_p.registerAssembler(uV,"scale",_v);var _y=((a2=(a1=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.component},a2.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},a2.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},a1);_p.registerAssembler(hl,"blendShapeWeights",_y);var _x=((a4=(a3=function(){this.crossCurveMark=0,this.isActive=!0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},a4.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},a3),_b=((a5=(a8=function(){this.typeIndex=0,this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new _p(e,this.type,t,this.property,this.getProperty,r);return r._initializeOwner(n),n.saveDefaultValue(),n},a5._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new _x;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},a5._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},a8),_T=function(){},_C=(uo(a9=function(e){var t;return(t=uf.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new ub,t._length=0,t._events=[],t},uf),(a6=a9.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,a=new _T;a.functionName=e,a.time=t,a.parameter=r,n=a}else n=e;var i=this._events,o=i.length,s=n.time;if(s>=(o?i[o-1].time:0))i.push(n);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,n)}this._updateFlagManager.dispatch()},a6.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},a6.addCurveBinding=function(e,t,r,n,a,i){var o=new _b;o.relativePath=e,o.type=t,"number"==typeof r?(o.typeIndex=r,o.property=n,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=r,"string"==typeof n?(o.getProperty=n,o.curve=a):o.curve=n),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},a6.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},a6._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var a=r[n],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,_p._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},ua(a9,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),a9);e.InterpolationType=void 0,(a7=e.InterpolationType||(e.InterpolationType={}))[a7.Linear=0]="Linear",a7[a7.CubicSpine=1]="CubicSpine",a7[a7.Step=2]="Step",a7[a7.Hermite=3]="Hermite";var _S=((it=(ie=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)}},it.evaluate=function(e){return this._evaluate(e,this._evaluateData)},it.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var a=t[n];a.time>this._length&&(r=a.time)}this._length=r},it._evaluate=function(t,r){var n,a=this.keys.length;if(!a){console.warn("This curve don't have any keyframes: ",this);return}var i=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=a||t<i[s].time)&&(s=-1);for(var l=s+1;l<a&&!(t<i[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(i[0].value,r.value);else if(l===a)n=this._type._setValue(i[s].value,r.value);else{var c=i[s],u=i[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},it._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},ua(ie,[{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}}]),ie);e.AnimationArrayCurve=(uo(ir=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=[],e},_S),ir._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},ir._initializeLayerOwner=function(e){e.finalValue=[]},ir._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},ir._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},ir._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},ir._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},ir._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},ir._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=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(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},ir._isCopyMode=!0,ir._supportInterpolationMode=!0,ir),e.AnimationArrayCurve=us([u6()],e.AnimationArrayCurve),e.AnimationBoolCurve=(uo(ia=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=!1,e},_S),ia._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},ia._initializeLayerOwner=function(e){e.finalValue=!1},ia._lerpValue=function(e,t){return e},ia._subtractValue=function(e,t,r){return e},ia._getZeroValue=function(){return!1},ia._additiveValue=function(e,t,r){return e},ia._setValue=function(e){return e},ia._hermiteInterpolationValue=function(e){return e.value},ia._isCopyMode=!1,ia._supportInterpolationMode=!1,ia),e.AnimationBoolCurve=us([u6()],e.AnimationBoolCurve),e.AnimationColorCurve=(uo(ii=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new c6,e},_S),ii._initializeOwner=function(e){e.defaultValue=new c6,e.fixedPoseValue=new c6,e.baseEvaluateData.value=new c6,e.crossEvaluateData.value=new c6},ii._initializeLayerOwner=function(e){e.finalValue=new c6},ii._lerpValue=function(e,t,r,n){return c6.lerp(e,t,r,n),n},ii._subtractValue=function(e,t,r){return c6.subtract(e,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0,0),e},ii._additiveValue=function(e,t,r){return c6.scale(e,t,e),c6.add(r,e,r),r},ii._setValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,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)?a.r=d*i.r+h*p*n+_*m*n+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=d*i.g+h*p*n+_*m*n+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=d*i.b+h*p*n+_*m*n+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=d*i.a+h*p*n+_*m*n+f*s.a:a.a=i.a,a},ii._isCopyMode=!0,ii._supportInterpolationMode=!0,ii),e.AnimationColorCurve=us([u6()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(uo(io=function(){return _S.apply(this,arguments)},_S),io.prototype.addKey=function(e){_S.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)}},io._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)},io._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},io._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},io._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},io._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},io._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},io._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},io._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=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(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},io._isCopyMode=!0,io._supportInterpolationMode=!0,io),e.AnimationFloatArrayCurve=us([u6()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(uo(is=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=0,e},_S),is._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},is._initializeLayerOwner=function(e){e.finalValue=0},is._lerpValue=function(e,t,r){return e+(t-e)*r},is._additiveValue=function(e,t,r){return r+e*t},is._subtractValue=function(e,t){return e-t},is._getZeroValue=function(){return 0},is._setValue=function(e){return e},is._hermiteInterpolationValue=function(e,t,r,n){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*a*n+(s-o)*i*n+(-2*s+3*o)*t.value},is._isCopyMode=!1,is._supportInterpolationMode=!0,is),e.AnimationFloatCurve=us([u6()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(uo(il=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new c3,e},_S),il._initializeOwner=function(e){e.defaultValue=new c3,e.fixedPoseValue=new c3,e.baseEvaluateData.value=new c3,e.crossEvaluateData.value=new c3},il._initializeLayerOwner=function(e){e.finalValue=new c3},il._lerpValue=function(e,t,r,n){return c3.slerp(e,t,r,n),n},il._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},il._subtractValue=function(t,r,n){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return c3.conjugate(r,a),c3.multiply(a,t,n),n},il._getZeroValue=function(e){return e.set(0,0,0,1),e},il._setValue=function(e,t){return t.copyFrom(e),t},il._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},il._supportInterpolationMode=!0,il._isCopyMode=!0,il._tempConjugateQuat=new c3,il),e.AnimationQuaternionCurve=us([u6()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(uo(ic=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new c5,e},_S),ic._initializeOwner=function(e){e.defaultValue=new c5,e.fixedPoseValue=new c5,e.baseEvaluateData.value=new c5,e.crossEvaluateData.value=new c5},ic._initializeLayerOwner=function(e){e.finalValue=new c5},ic._lerpValue=function(e,t,r,n){return c5.lerp(e,t,r,n),n},ic._additiveValue=function(e,t,r){return c5.scale(e,t,e),c5.add(r,e,r),r},ic._subtractValue=function(e,t,r){return c5.subtract(e,t,r),r},ic._getZeroValue=function(e){return e.set(0,0),e},ic._setValue=function(e,t){return t.copyFrom(e),t},ic._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,a},ic._isCopyMode=!0,ic._supportInterpolationMode=!0,ic),e.AnimationVector2Curve=us([u6()],e.AnimationVector2Curve),e.AnimationVector3Curve=(uo(iu=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new cQ,e},_S),iu._initializeOwner=function(e){e.defaultValue=new cQ,e.fixedPoseValue=new cQ,e.baseEvaluateData.value=new cQ,e.crossEvaluateData.value=new cQ},iu._initializeLayerOwner=function(e){e.finalValue=new cQ},iu._lerpValue=function(e,t,r,n){return cQ.lerp(e,t,r,n),n},iu._relativeBaseValue=function(e,t){return cQ.subtract(t,e,t),t},iu._additiveValue=function(e,t,r){return cQ.scale(e,t,e),cQ.add(r,e,r),r},iu._subtractValue=function(e,t,r){return cQ.subtract(e,t,r),r},iu._getZeroValue=function(e){return e.set(0,0,0),e},iu._setValue=function(e,t){return t.copyFrom(e),t},iu._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,a},iu._isCopyMode=!0,iu._supportInterpolationMode=!0,iu),e.AnimationVector3Curve=us([u6()],e.AnimationVector3Curve),e.AnimationVector4Curve=(uo(id=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new c9,e},_S),id._initializeOwner=function(e){e.defaultValue=new c9,e.fixedPoseValue=new c9,e.baseEvaluateData.value=new c9,e.crossEvaluateData.value=new c9},id._initializeLayerOwner=function(e){e.finalValue=new c9},id._lerpValue=function(e,t,r,n){return c9.lerp(e,t,r,n),n},id._additiveValue=function(e,t,r){return c9.scale(e,t,e),c9.add(r,e,r),r},id._subtractValue=function(e,t,r){return c9.subtract(e,t,r),r},id._getZeroValue=function(e){return e.set(0,0,0,0),e},id._setValue=function(e,t){return t.copyFrom(e),t},id._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},id._isCopyMode=!0,id._supportInterpolationMode=!0,id),e.AnimationVector4Curve=us([u6()],e.AnimationVector4Curve),e.AnimationRefCurve=(uo(ih=function(){return _S.call(this)},_S),ih._initializeOwner=function(e){},ih._initializeLayerOwner=function(e){},ih._setValue=function(e){return e},ih._isCopyMode=!1,ih._supportInterpolationMode=!1,ih),e.AnimationRefCurve=us([u6()],e.AnimationRefCurve),e.AnimationRectCurve=(uo(i_=function(){var e;return(e=_S.call(this)||this)._evaluateData.value=new c7,e},_S),i_._initializeOwner=function(e){e.defaultValue=new c7,e.fixedPoseValue=new c7,e.baseEvaluateData.value=new c7,e.crossEvaluateData.value=new c7},i_._initializeLayerOwner=function(e){e.finalValue=new c7},i_._setValue=function(e,t){return t.copyFrom(e),t},i_._isCopyMode=!0,i_._supportInterpolationMode=!1,i_),e.AnimationRectCurve=us([u6()],e.AnimationRectCurve),e.AnimationStringCurve=(uo(ip=function(){var e;return(e=_S.call(this)||this)._evaluateData.value="",e},_S),ip._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},ip._initializeLayerOwner=function(e){e.finalValue=""},ip._lerpValue=function(e,t){return e},ip._subtractValue=function(e,t,r){return e},ip._getZeroValue=function(){return""},ip._additiveValue=function(e,t,r){return e},ip._setValue=function(e){return e},ip._hermiteInterpolationValue=function(e){return e.value},ip._isCopyMode=!1,ip._supportInterpolationMode=!1,ip),e.AnimationStringCurve=us([u6()],e.AnimationStringCurve),e.AnimatorConditionMode=void 0,(im=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[im.If=0]="If",im[im.IfNot=1]="IfNot",im[im.Greater=2]="Greater",im[im.Less=3]="Less",im[im.Equals=4]="Equals",im[im.NotEquals=5]="NotEquals",e.AnimatorCullingMode=void 0,(ig=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[ig.None=0]="None",ig[ig.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iv=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iv.Override=0]="Override",iv[iv.Additive=1]="Additive",(iy=cE||(cE={}))[iy.UnStarted=0]="UnStarted",iy[iy.Playing=1]="Playing",iy[iy.Finished=2]="Finished",(ix=cw||(cw={}))[ix.Standby=0]="Standby",ix[ix.Playing=1]="Playing",ix[ix.CrossFading=2]="CrossFading",ix[ix.FixedCrossFading=3]="FixedCrossFading",ix[ix.Finished=4]="Finished";var _A=((ib=function(){this.handlers=[]}).prototype.dispose=function(){},ib),_M=function(){},_R=((iC=(iT=function(){this.duration=0,this.offset=0,this.exitTime=1,this.mute=!1,this._isExit=!1,this._conditions=[],this._solo=!1}).prototype).addCondition=function(e,t,r){if("object"==typeof e)return this._conditions.push(e),e;var n=new _M;return n.mode=e,n.parameterName=t,n.threshold=r,this._conditions.push(n),n},iC.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},ua(iT,[{key:"isExit",get:function(){return this._isExit}},{key:"solo",get:function(){return this._solo},set:function(e){var t;this._solo!==e&&(this._solo=e,null==(t=this._srcState)||t._updateSoloTransition(!!e||void 0))}},{key:"conditions",get:function(){return this._conditions}}]),iT);e.WrapMode=void 0,(iS=e.WrapMode||(e.WrapMode={}))[iS.Once=0]="Once",iS[iS.Loop=1]="Loop";var _E=((iM=(iA=function(){this.isForwards=!0,this._changedOrientation=!1}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=cE.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0,this.isForwards=!0},iM.updateOrientation=function(e){if(0!==e){var t=this.isForwards;this.isForwards=e>0,this.isForwards!==t&&(this._changedOrientation=!0,this.isForwards||this._correctTime())}},iM.update=function(t){this.frameTime+=t;var r=this.state,n=this.frameTime,a=r._getDuration();this.playState=cE.Playing,r.wrapMode===e.WrapMode.Loop?n=a?n%a:0:Math.abs(n)>a&&(n=n<0?-a:a,this.playState=cE.Finished),n<0&&(n+=a),this.clipTime=n+r.clipStartTime*r.clip.length,this._changedOrientation&&(this.isForwards||this._correctTime(),this._changedOrientation=!1)},iM._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},iA),_w=((iR=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new _E,this.destPlayData=new _E,this.layerState=cw.Standby,this.crossCurveMark=0,this.manuallyTransition=new _R,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iR),_P=function(){this.curveLayerOwner=[],this.eventHandlers=[]},_F=(uo(iE=function(t){var r;return(r=uB.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 h1(_A),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},uB),(iw=iE.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();var n,a=this._getAnimatorStateInfo(e,t),i=a.state;i&&this._preparePlay(i,a.layerIndex,r)&&(this._playFrameCount=this.engine.time.frameCount)},iw.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset();var a,i=this._getAnimatorStateInfo(e,r),o=i.state,s=i.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._prepareCrossFadeByTransition(l,s)&&(this._playFrameCount=this.engine.time.frameCount)},iw.update=function(t){if(this._playFrameCount===this.engine.time.frameCount&&(t=0),this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,a=this._controlledRenderers,i=0,o=a.length;i<o;i++)if(!a[i].isCulled){n=!0;break}}else n=!0;var s=this._animatorController;if(s){(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset(),this._updateMark++;for(var l=s.layers,c=0,u=l.length;c<u;c++)this._updateLayer(c,l[c],t,n)}},iw.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},iw.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iw.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},iw.getParameter=function(e){var t,r;return null!=(r=null==(t=this._animatorController)?void 0:t._parametersMap[e])?r:null},iw._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iw._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},iw._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},iw._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.clear(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},iw._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,a=null;if(r){var i=r.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=a,n},iw._getAnimatorStateData=function(e,t,r,n){var a=r.animatorStateDataMap,i=a[e];return i||(i=new _P,a[e]=i,this._saveAnimatorStateData(t,i,r,n),this._saveAnimatorEventHandlers(t,i)),i},iw._saveAnimatorStateData=function(e,t,r,n){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[n].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=r.curveOwnerPool,u=l.length-1;u>=0;u--){var d=l[u],h=d.relativePath,_=""===d.relativePath?a:a.findByPath(d.relativePath);if(_){var f,p,m=d.typeIndex>0?_.getComponents(d.type,_p._components)[d.typeIndex]:_.getComponent(d.type);if(!m)continue;var g=d.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=d._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),T=b[g]||(b[g]=d._createCurveLayerOwner(x));o&&o.pathMasks.length&&(T.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[u]=T}else s[u]=null,uP.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},iw._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){r._entity.getComponents(_l,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.get(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=a[_],p=f[d].bind(f);p&&h.push(p)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},iw._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},iw._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},iw._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},iw._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},iw._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)},iw._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,n,-1))}},iw._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=n;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,n)}}}},iw._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new _w),t},iw._updateLayer=function(t,r,n,a){var i=r.weight,o=this._getAnimatorLayerData(t);this._updateState(t,o,r.stateMachine,n);var s=o.srcPlayData,l=o.destPlayData,c=r.blendingMode===e.AnimatorLayerBlendingMode.Additive;switch(0===t&&(i=1),o.layerState){case cw.Playing:this._evaluatePlayingState(s,i,c,a);break;case cw.FixedCrossFading:this._evaluateCrossFadeFromPoseState(l,o,i,c,a);break;case cw.CrossFading:this._evaluateCrossFadeState(s,l,o,i,c,a);break;case cw.Finished:this._evaluateFinishedState(s,i,c,a)}},iw._updateState=function(e,t,r,n){switch(t.layerState){case cw.Standby:this._checkAnyAndEntryState(e,t,r,n);break;case cw.Playing:this._updatePlayingState(e,t,r,n);break;case cw.Finished:this._updateFinishedState(e,t,r,n);break;case cw.CrossFading:this._updateCrossFadeState(e,t,r,n);break;case cw.FixedCrossFading:this._updateCrossFadeFromPoseState(e,t,r,n)}},iw._updatePlayingState=function(e,t,r,n){var a=t.srcPlayData,i=a.state,o=a.stateData.eventHandlers,s=i.speed*this.speed*n;a.updateOrientation(s);var l=a.clipTime,c=a.playState;a.update(s);var u=a.clipTime,d=a.playState,h=a.isForwards,_=this._applyTransitionsByCondition(e,t,r,i,r.anyStateTransitions)||this._applyStateTransitions(e,t,r,h,a,i.transitions,l,u,s),f=0;if(_){var p=i.clip.length,m=i.clipEndTime*p,g=_.exitTime*i._getDuration();if(h)f=g<l?g+m-l:g-l;else{var v=i.clipStartTime*p;f=-(f=l<g?m-g+l-v:l-g)}a.update(f-s)}if(d===cE.Finished&&(t.layerState=cw.Finished),o.length&&this._fireAnimationEvents(a,o,l,u),c===cE.UnStarted&&this._callAnimatorScriptOnEnter(i,e),d===cE.Finished?this._callAnimatorScriptOnExit(i,e):this._callAnimatorScriptOnUpdate(i,e),_){var y=n-Math.abs(f);this._updateState(e,t,r,y)}},iw._evaluatePlayingState=function(e,t,r,n){var a=e.state.clip._curveBindings,i=e.playState===cE.Finished;if(n||i)for(var o=e.stateData.curveLayerOwner,s=a.length-1;s>=0;s--){var l=o[s],c=null==l?void 0:l.curveOwner;if(c&&l.isActive){var u=a[s].curve;if(u.keys.length){this._checkRevertOwner(c,r);var d=c.evaluateValue(u,e.clipTime,r);n&&c.applyValue(d,t,r),i&&l.saveFinalValue()}}}},iw._updateCrossFadeState=function(e,t,r,n){var a=t.srcPlayData,i=t.destPlayData,o=this.speed,s=a.state,l=a.stateData.eventHandlers,c=i.state,u=i.stateData.eventHandlers,d=c._getDuration(),h=d*t.crossFadeTransition.duration,_=s.speed*o,f=c.speed*o,p=f*n;a&&a.updateOrientation(_*n),i&&i.updateOrientation(p);var m=a.clipTime,g=a.playState,v=i.clipTime,y=i.playState,x=0;if(i.isForwards)x=v+p>h?h-v:p;else{var b=d-v;x=b-p>h?b-h:p}var T=0===f?0:x/f;a.update(T*_),i.update(x);var C=a.clipTime,S=a.playState,A=i.clipTime,M=i.playState,R=Math.abs(i.frameTime)/h;(R>=1-cq.zeroTolerance||0===h)&&(R=1),l.length&&this._fireAnimationEvents(a,l,m,C),u.length&&this._fireAnimationEvents(i,u,v,A),g===cE.UnStarted&&this._callAnimatorScriptOnEnter(s,e),1===R||S===cE.Finished?this._callAnimatorScriptOnExit(s,e):this._callAnimatorScriptOnUpdate(s,e),y===cE.UnStarted&&this._callAnimatorScriptOnEnter(c,e),M===cE.Finished?this._callAnimatorScriptOnExit(c,e):this._callAnimatorScriptOnUpdate(c,e),1===R&&this._updateCrossFadeData(t);var E=n-T;E>cq.zeroTolerance&&this._updateState(e,t,r,E)},iw._evaluateCrossFadeState=function(e,t,r,n,a,i){var o=r.crossLayerOwnerCollection,s=e.state.clip._curveBindings,l=t.state,c=l.clip._curveBindings,u=l._getDuration()*r.crossFadeTransition.duration,d=Math.abs(t.frameTime)/u;(d>=1-cq.zeroTolerance||0===u)&&(d=1);var h=t.playState===cE.Finished;if(i||h)for(var _=o.length-1;_>=0;_--){var f=o[_],p=null==f?void 0:f.curveOwner;if(p){var m=f.crossSrcCurveIndex,g=f.crossDestCurveIndex;this._checkRevertOwner(p,a);var v=p.evaluateCrossFadeValue(m>=0?s[m].curve:null,g>=0?c[g].curve:null,e.clipTime,t.clipTime,d,a);i&&p.applyValue(v,n,a),h&&f.saveFinalValue()}}},iw._updateCrossFadeFromPoseState=function(e,t,r,n){var a=t.destPlayData,i=a.state,o=a.stateData.eventHandlers,s=i._getDuration(),l=s*t.crossFadeTransition.duration,c=i.speed*this.speed,u=c*n;a.updateOrientation(u);var d=a.clipTime,h=a.playState,_=0;if(a.isForwards)_=d+u>l?l-d:u;else{var f=s-d;_=f-u>l?f-l:u}var p=0===c?0:_/c;a.update(_);var m=a.clipTime,g=a.playState,v=Math.abs(a.frameTime)/l;(v>=1-cq.zeroTolerance||0===l)&&(v=1),o.length&&this._fireAnimationEvents(a,o,d,m),h===cE.UnStarted&&this._callAnimatorScriptOnEnter(i,e),g===cE.Finished?this._callAnimatorScriptOnExit(i,e):this._callAnimatorScriptOnUpdate(i,e),1===v&&this._updateCrossFadeData(t);var y=n-p;y>cq.zeroTolerance&&this._updateState(e,t,r,y)},iw._evaluateCrossFadeFromPoseState=function(e,t,r,n,a){var i=t.crossLayerOwnerCollection,o=e.state,s=o.clip._curveBindings,l=o._getDuration()*t.crossFadeTransition.duration,c=Math.abs(e.frameTime)/l;(c>=1||0===l)&&(c=1);var u=e.clipTime,d=e.playState===cE.Finished;if(a||d)for(var h=i.length-1;h>=0;h--){var _=i[h],f=null==_?void 0:_.curveOwner;if(f){var p=_.crossDestCurveIndex;this._checkRevertOwner(f,n);var m=_.curveOwner.crossFadeFromPoseAndApplyValue(p>=0?s[p].curve:null,u,c,n);a&&f.applyValue(m,r,n),d&&_.saveFinalValue()}}},iw._updateFinishedState=function(e,t,r,n){var a=t.srcPlayData,i=a.state,o=i.transitions,s=i.speed*this.speed,l=s*n;a.updateOrientation(l);var c=a.clipTime;(this._applyTransitionsByCondition(e,t,r,i,r.anyStateTransitions)||this._applyStateTransitions(e,t,r,s<0,a,o,c,c,l))&&this._updateState(e,t,r,n)},iw._evaluateFinishedState=function(e,t,r,n){if(n)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},iw._updateCrossFadeData=function(e){e.destPlayData.playState===cE.Finished?e.layerState=cw.Finished:e.layerState=cw.Playing,e.switchPlayData(),e.crossFadeTransition=null},iw._preparePlayOwner=function(e,t){if(e.layerState===cw.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,a=r.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(n=a[i])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},iw._applyStateTransitions=function(e,t,r,n,a,i,o,s,l){var c=a.state,u=c.clip.length,d=null,h=c.clipStartTime*u,_=c.clipEndTime*u;return n?o+l>=_?(d=this._checkSubTransition(e,t,r,a,i,o,_))||(a.currentTransitionIndex=0,d=this._checkSubTransition(e,t,r,a,i,h,s)):d=this._checkSubTransition(e,t,r,a,i,o,s):o+l<=h?(d=this._checkBackwardsSubTransition(e,t,r,a,i,o,h))||(a.currentTransitionIndex=i.length-1,d=this._checkBackwardsSubTransition(e,t,r,a,i,s,_)):d=this._checkBackwardsSubTransition(e,t,r,a,i,o,s),d},iw._checkSubTransition=function(e,t,r,n,a,i,o){for(var s=n.state,l=n.currentTransitionIndex,c=s._getDuration(),u=a.length;l<u;l++){var d=a[l],h=d.exitTime*c;if(h>o)break;if(h>=i&&(n.currentTransitionIndex=Math.min(l+1,u-1),this._checkConditions(s,d))){if(this._applyTransition(e,t,r,d))return d;break}}return null},iw._checkBackwardsSubTransition=function(e,t,r,n,a,i,o){for(var s=n.state,l=n.currentTransitionIndex,c=n.state._getDuration();l>=0;l--){var u=a[l],d=u.exitTime*c;if(d<o)break;if(d<=i&&(n.currentTransitionIndex=Math.max(l-1,0),this._checkConditions(s,u))){if(this._applyTransition(e,t,r,u))return u;break}}return null},iw._applyTransitionsByCondition=function(e,t,r,n,a){for(var i=0,o=a.length;i<o;i++){var s=a[i];if(this._checkConditions(n,s)){if(this._applyTransition(e,t,r,s))return s;return null}}},iw._preparePlay=function(e,t,r){void 0===r&&(r=0);var n=e.name;if(!e.clip)return uP.warn("The state named "+n+" has no AnimationClip data."),!1;var a=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(n,e,a,t);return this._preparePlayOwner(a,e),a.layerState=cw.Playing,a.srcPlayData.reset(e,i,e._getDuration()*r),!0},iw._applyTransition=function(e,t,r,n){var a=this._prepareCrossFadeByTransition(n,e);return n.isExit?(this._checkAnyAndEntryState(e,t,r),!0):a},iw._checkConditions=function(t,r){if(r.mute||(null==t?void 0:t._hasSoloTransition)&&!r.solo)return!1;for(var n=r.conditions,a=!0,i=0,o=n.length;i<o;++i){var s=!1,l=n[i],c=l.mode,u=l.parameterName,d=l.threshold,h=this.getParameter(u);if(!h)return!1;switch(c){case e.AnimatorConditionMode.Equals:h.value===d&&(s=!0);break;case e.AnimatorConditionMode.Greater:h.value>d&&(s=!0);break;case e.AnimatorConditionMode.Less:h.value<d&&(s=!0);break;case e.AnimatorConditionMode.NotEquals:h.value!==d&&(s=!0);break;case e.AnimatorConditionMode.If:!0===h.value&&(s=!0);break;case e.AnimatorConditionMode.IfNot:!1===h.value&&(s=!0)}if(!s){a=!1;break}}return a},iw._prepareCrossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return uP.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(r.name,r,n,t),i=r._getDuration()*e.offset;switch(n.destPlayData.reset(r,a,i),n.layerState){case cw.Standby:case cw.Finished:n.layerState=cw.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case cw.Playing:n.layerState=cw.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case cw.CrossFading:n.layerState=cw.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case cw.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},iw._fireAnimationEvents=function(e,t,r,n){var a=e.state,i=a.clip.length;this.speed*a.speed>=0?n<r?(this._fireSubAnimationEvents(e,t,r,a.clipEndTime*i),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,a.clipStartTime*i,n)):this._fireSubAnimationEvents(e,t,r,n):n>r?(this._fireBackwardSubAnimationEvents(e,t,r,a.clipStartTime*i),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,a.clipEndTime*i,n)):this._fireBackwardSubAnimationEvents(e,t,r,n)},iw._fireSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var u=o.handlers;if(l>=r){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(a+1,i-1)}}},iw._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=i.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(a-1,0)}}},iw._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,a=r.length;n<a;n++)r[n].onStateEnter(this,e,t)},iw._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,a=r.length;n<a;n++)r[n].onStateUpdate(this,e,t)},iw._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,a=r.length;n<a;n++)r[n].onStateExit(this,e,t)},iw._checkAnyAndEntryState=function(e,t,r,n){void 0===n&&(n=0);var a,i=r.anyStateTransitions,o=r.entryTransitions;if((a=i.length&&this._applyTransitionsByCondition(e,t,r,null,i))||(a=o.length&&this._applyTransitionsByCondition(e,t,r,null,o)),a)this._updateState(e,t,r,n);else{var s=r.defaultState;s&&(this._preparePlay(s,e),this._updateState(e,t,r,n))}},iw._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},ua(iE,[{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)}},{key:"layers",get:function(){var e;return null==(e=this._animatorController)?void 0:e._layers}},{key:"parameters",get:function(){var e;return null==(e=this._animatorController)?void 0:e._parameters}}]),iE);us([uu],_F.prototype,"speed",void 0),us([uc],_F.prototype,"_controllerUpdateFlag",void 0),us([uc],_F.prototype,"_updateMark",void 0),us([uc],_F.prototype,"_animatorLayersData",void 0),us([uc],_F.prototype,"_curveOwnerPool",void 0),us([uc],_F.prototype,"_animationEventHandlerPool",void 0),us([uc],_F.prototype,"_tempAnimatorStateInfo",void 0),us([uc],_F.prototype,"_controlledRenderers",void 0);var _L=function(){},_B=((iF=(iP=function(){this._parameters=[],this._parametersMap={},this._layers=[],this._layersMap={},this._updateFlagManager=new ub}).prototype).addParameter=function(e,t){if("string"==typeof e){var r=e;(e=new _L).name=r,e.value=t}return this._parametersMap[e.name]=e,this._parameters.push(e),e},iF.removeParameter=function(e){var t=this._parameters.indexOf(e);-1!==t&&(this._parameters.splice(t,1),delete this._parametersMap[e.name])},iF.getParameter=function(e){return this._parametersMap[e]||null},iF.setParameterValue=function(e,t){var r=this._parametersMap[e];r&&r.value!==t&&(r.value=t)},iF.findLayerByName=function(e){return this._layersMap[e]},iF.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iF.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iF.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iF._registerChangeFlag=function(){return this._updateFlagManager.createFlag(uO)},ua(iP,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),iP),_D=((iB=(iL=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},iB.onStateUpdate=function(e,t,r){},iB.onStateExit=function(e,t,r){},iB.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iL),_I=((iI=(iD=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new ub,this._hasSoloTransition=!1,this._clipStartTime=0,this._clipEndTime=1,this._transitions=[],this._onClipChanged=this._onClipChanged.bind(this)}).prototype).addTransition=function(e){ul(e,iD)?(t=new _R).destinationState=e:t=e,t._srcState=this;var t,r=this._transitions,n=r.length,a=t.exitTime;if(a>=(n?r[n-1].exitTime:0))r.push(t);else{for(var i=n;--i>=0&&a<r[i].exitTime;);r.splice(i+1,0,t)}return t.solo&&!this._hasSoloTransition&&this._updateSoloTransition(!0),t},iI.addExitTransition=function(e){void 0===e&&(e=1);var t=new _R;return t._srcState=this,t._isExit=!0,t.exitTime=e,this.addTransition(t)},iI.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1),e._srcState=null,this._updateSoloTransition()},iI.addStateMachineScript=function(e){var t=new e;t._state=this;var r=_D.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},iI.clearTransitions=function(){this._transitions.length=0},iI._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iI._removeStateMachineScript=function(e){var t=_D.prototype;if(e.onStateEnter!==t.onStateEnter){var r=this._onStateEnterScripts.indexOf(e);-1!==r&&this._onStateEnterScripts.splice(r,1)}if(e.onStateUpdate!==t.onStateUpdate){var n=this._onStateUpdateScripts.indexOf(e);-1!==n&&this._onStateUpdateScripts.splice(n,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},iI._onClipChanged=function(){this._updateFlagManager.dispatch()},iI._updateSoloTransition=function(e){if(void 0!==e)this._hasSoloTransition=e;else{this._hasSoloTransition=!1;for(var t=0,r=this.transitions.length;t<r;++t)if(this.transitions[t].solo){this._hasSoloTransition=!0;return}}},ua(iD,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),iD),_O=((iV=(iO=function(){this.states=[],this._entryTransitions=[],this._anyStateTransitions=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new _I(e),this.states.push(t),this._statesMap[e]=t),t},iV.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},iV.findStateByName=function(e){return this._statesMap[e]},iV.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},iV.addEntryStateTransition=function(e){return this._addTransition(e,this._entryTransitions)},iV.removeEntryStateTransition=function(e){this._removeTransition(e,this._entryTransitions)},iV.addAnyStateTransition=function(e){return this._addTransition(e,this._anyStateTransitions)},iV.removeAnyStateTransition=function(e){this._removeTransition(e,this._anyStateTransitions)},iV._addTransition=function(e,t){var r;return ul(e,_I)?(r=new _R).destinationState=e:r=e,t.push(r),r},iV._removeTransition=function(e,t){var r=t.indexOf(e);-1!==r&&t.splice(r,1)},ua(iO,[{key:"entryTransitions",get:function(){return this._entryTransitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitions}}]),iO),_V=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override,this.stateMachine=new _O},_N=function(){},_k=function(){},_z=((ik=(iN=function(){this._pathMasks=[],this._pathMaskMap={}}).prototype).addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var r=new _k;return r.path=e,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[e]=r,r},ik.removePathMask=function(e){for(var t=this._pathMasks,r=0,n=this._pathMasks.length;r<n;++r)if(t[r].path===e){t.splice(r,1),delete this._pathMaskMap[e];break}},ik.getPathMask=function(e){return this._pathMaskMap[e]},ik.setPathMaskActive=function(e,t,r){void 0===r&&(r=!1);var n=this._pathMaskMap[e];if(n&&(n.active=t),r)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},iN.createByEntity=function(e){var t=new iN;return t.addPathMask(""),iN._addPathMaskWithChildren(t,e,""),t},iN._addPathMaskWithChildren=function(e,t,r){for(var n=t.children,a=0,i=n.length;a<i;++a){var o=n[a],s=r?r+"/"+o.name:o.name;e.addPathMask(s),iN._addPathMaskWithChildren(e,o,s)}},ua(iN,[{key:"pathMasks",get:function(){return this._pathMasks}}]),iN),_U=function(t){function r(n){var a;return(a=t.call(this,n,u4.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new c6(1,1,1,1),a.renderState.rasterState.cullMode=e.CullMode.Off,a.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,a.shaderData.setFloat(r._rotationProp,0),a.shaderData.setFloat(r._exposureProp,1),a.shaderData.setColor(r._tintColorProp,a._tintColor),a}return uo(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},ua(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}(dV);_U._tintColorProp=uF.getByName("material_TintColor"),_U._textureCubeProp=uF.getByName("material_CubeTexture"),_U._rotationProp=uF.getByName("material_Rotation"),_U._exposureProp=uF.getByName("material_Exposure"),_U._decodeSkyRGBMMacro=uz.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iz=e.SunMode||(e.SunMode={}))[iz.None=0]="None",iz[iz.Simple=1]="Simple",iz[iz.HighQuality=2]="HighQuality";var _G=(uo(iU=function(t){var r;return(r=dV.call(this,t,u4.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new c6(.5,.5,.5,1),r.groundTint=new c6(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},dV),iU.prototype.clone=function(){var e=new iU(this._engine);return this.cloneTo(e),e},ua(iU,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iU._sunSimpleMacro),t.enableMacro(iU._sunHighQualityMacro);break;case 1:t.disableMacro(iU._sunHighQualityMacro),t.enableMacro(iU._sunSimpleMacro);break;case 0:t.disableMacro(iU._sunHighQualityMacro),t.disableMacro(iU._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iU._sunSizeProp)},set:function(e){this.shaderData.setFloat(iU._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iU._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iU._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iU._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iU._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iU._skyTintProp)},set:function(e){this.shaderData.setColor(iU._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iU._groundTintProp)},set:function(e){this.shaderData.setColor(iU._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iU._exposureProp)},set:function(e){this.shaderData.setFloat(iU._exposureProp,Math.min(Math.max(0,e),8))}}]),iU);_G._sunSizeProp=uF.getByName("material_SunSize"),_G._sunSizeConvergenceProp=uF.getByName("material_SunSizeConvergence"),_G._atmosphereThicknessProp=uF.getByName("material_AtmosphereThickness"),_G._skyTintProp=uF.getByName("material_SkyTint"),_G._groundTintProp=uF.getByName("material_GroundTint"),_G._exposureProp=uF.getByName("material_Exposure"),_G._sunHighQualityMacro=uz.getByName("MATERIAL_SUN_HIGH_QUALITY"),_G._sunSimpleMacro=uz.getByName("MATERIAL_SUN_SIMPLE"),e.ParticleRenderMode=void 0,(iG=e.ParticleRenderMode||(e.ParticleRenderMode={}))[iG.Billboard=0]="Billboard",iG[iG.StretchBillboard=1]="StretchBillboard",iG[iG.HorizontalBillboard=2]="HorizontalBillboard",iG[iG.VerticalBillboard=3]="VerticalBillboard",iG[iG.Mesh=4]="Mesh",iG[iG.None=5]="None",e.ParticleSimulationSpace=void 0,(iH=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[iH.Local=0]="Local",iH[iH.World=1]="World",e.ParticleStopMode=void 0,(iW=e.ParticleStopMode||(e.ParticleStopMode={}))[iW.StopEmittingAndClear=0]="StopEmittingAndClear",iW[iW.StopEmitting=1]="StopEmitting";var _H=function(t){function r(n){var a;return(a=t.call(this,n)||this).velocityScale=0,a.lengthScale=2,a.pivot=new cQ,a._generatorBounds=new cJ,a._transformedBounds=new cJ,a._onGeneratorParamsChanged=a._onGeneratorParamsChanged.bind(ur(a)),a.generator=new _8(ur(a)),a._currentRenderModeMacro=r._billboardModeMacro,a.shaderData.enableMacro(r._billboardModeMacro),a._supportInstancedArrays=a.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),a._onGeneratorParamsChanged(),a}uo(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){this._supportInstancedArrays&&t.prototype._prepareRender.call(this,e)},n._updateTransformShaderData=function(e,r,n){t.prototype._updateTransformShaderData.call(this,e,r,!0)},n._updateBounds=function(t){var r=this.generator;if(!r.isAlive){var n=this.entity.transform.worldPosition;t.min.copyFrom(n),t.max.copyFrom(n);return}r.main.simulationSpace===e.ParticleSimulationSpace.Local?r._updateBoundsSimulationLocal(t):(this._isContainDirtyFlag(2)&&(r._generateTransformedBounds(),this._setDirtyFlagFalse(2)),r._updateBoundsSimulationWorld(t))},n._update=function(e){var t=this.generator;if(t._update(this.engine.time.deltaTime),t._firstActiveElement!==t._firstFreeElement){var n=this.shaderData;n.setFloat(r._lengthScale,this.lengthScale),n.setFloat(r._speedScale,this.velocityScale),n.setFloat(r._currentTime,this.generator._playTime),n.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(n)}},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var n=this._engine,a=n._renderElementPool.get();a.set(this.priority,this._distanceForSort);var i=n._subRenderElementPool.get();i.set(this,r,t._primitive,t._subPrimitive),a.addSubRenderElement(i),e.camera._renderPipeline.pushRenderElement(e,a)}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1)),this.generator._destroy()},n._isContainDirtyFlag=function(e){return(this._dirtyUpdateFlag&e)!=0},n._setDirtyFlagFalse=function(e){this._dirtyUpdateFlag&=~e},n._onWorldVolumeChanged=function(){this._dirtyUpdateFlag|=ci.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|ci.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|ci.WorldVolume},ua(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var a=null,i=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:a=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:a=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==a&&(this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),a&&i.enableMacro(a),this._currentRenderModeMacro=a),n!==e.ParticleRenderMode.Mesh!=(t===e.ParticleRenderMode.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(t){var r=this._mesh;r!==t&&(this._mesh=t,r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);_H._billboardModeMacro=uz.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),_H._stretchedBillboardModeMacro=uz.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),_H._horizontalBillboardModeMacro=uz.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),_H._verticalBillboardModeMacro=uz.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),_H._renderModeMeshMacro=uz.getByName("RENDERER_MODE_MESH"),_H._pivotOffsetProperty=uF.getByName("renderer_PivotOffset"),_H._lengthScale=uF.getByName("renderer_StretchedBillboardLengthScale"),_H._speedScale=uF.getByName("renderer_StretchedBillboardSpeedScale"),_H._currentTime=uF.getByName("renderer_CurrentTime"),us([uh],_H.prototype,"generator",void 0),us([ud],_H.prototype,"pivot",void 0),us([uc],_H.prototype,"_generatorBounds",void 0),us([uc],_H.prototype,"_transformedBounds",void 0),us([uc],_H.prototype,"_onGeneratorParamsChanged",null),(ij=cP||(cP={}))[ij.TransformVolume=2]="TransformVolume",ij[ij.GeneratorVolume=4]="GeneratorVolume",e.ParticleCurveMode=void 0,(iK=e.ParticleCurveMode||(e.ParticleCurveMode={}))[iK.Constant=0]="Constant",iK[iK.TwoConstants=1]="TwoConstants",iK[iK.Curve=2]="Curve",iK[iK.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(iX=e.ParticleGradientMode||(e.ParticleGradientMode={}))[iX.Constant=0]="Constant",iX[iX.TwoConstants=1]="TwoConstants",iX[iX.Gradient=2]="Gradient",iX[iX.TwoGradients=3]="TwoGradients",(iY=cF||(cF={}))[iY.Burst=592910910]="Burst",iY[iY.StartDelay=322376503]="StartDelay",iY[iY.StartColor=306581307]="StartColor",iY[iY.StartSize=1793934638]="StartSize",iY[iY.StartRotation=3737431713]="StartRotation",iY[iY.randomizeRotationDirection=2527743459]="randomizeRotationDirection",iY[iY.StartLifetime=2368504881]="StartLifetime",iY[iY.StartSpeed=4085612399]="StartSpeed",iY[iY.VelocityOverLifetime=3774601268]="VelocityOverLifetime",iY[iY.ColorOverLifetime=326370691]="ColorOverLifetime",iY[iY.SizeOverLifetime=1494990940]="SizeOverLifetime",iY[iY.RotationOverLifetime=1089181156]="RotationOverLifetime",iY[iY.TextureSheetAnimation=197469413]="TextureSheetAnimation",iY[iY.Shape=2941263940]="Shape",iY[iY.GravityModifier=2759560269]="GravityModifier";var _W=((iQ=(iq=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var r=0,n=e.length;r<n;r++){var a=e[r];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}).prototype).addColorKey=function(e,t){var r=this._colorKeys;if(4===r.length)throw Error("Gradient can only have 4 color keys");var n="number"==typeof e?new _j(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},iQ.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 _K(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},iQ.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},iQ.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},iQ.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,a=0,i=r.length;a<i;a++)r[a]._onValueChanged=null;for(var o=0,s=n.length;o<s;o++)n[o]._onValueChanged=null;r.length=0,n.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(r,e[l]);for(var u=0,d=t.length;u<d;u++)this._addKey(n,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},iQ._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,a=0,i=Math.min(n.length,4);a<i;a++){var o=4*a,s=n[a];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=c6.gammaToLinearSpace(l.r),r[o+2]=c6.gammaToLinearSpace(l.g),r[o+3]=c6.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},iQ._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},iQ._addKey=function(e,t){var r=t.time,n=e.length;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},iQ._removeKey=function(e,t){e.splice(t,1)},iQ._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},iQ._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},ua(iq,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),iq);us([uh],_W.prototype,"_colorKeys",void 0),us([uh],_W.prototype,"_alphaKeys",void 0),us([uc],_W.prototype,"_colorTypeArray",void 0),us([uc],_W.prototype,"_alphaTypeArray",void 0),us([uc],_W.prototype,"_setColorTypeArrayDirty",null),us([uc],_W.prototype,"_setAlphaTypeArrayDirty",null);var _j=(ua(iZ=function(e,t){this._onValueChanged=null,this._color=new c6,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)}}]),iZ),_K=(ua(iJ=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()}}]),iJ),_X=((i$=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new c6,this.constantMax=new c6,this.gradientMin=new _W,this.gradientMax=new _W,t.constructor===c6?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:c6.lerp(this.constantMin,this.constantMax,r,n)}},ua(i$,[{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}}]),i$);us([uh],_X.prototype,"constantMin",void 0),us([uh],_X.prototype,"constantMax",void 0),us([uh],_X.prototype,"gradientMin",void 0),us([uh],_X.prototype,"gradientMax",void 0);var _Y=((i0=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},ua(i0,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),i0);us([uc],_Y.prototype,"_generator",void 0);var _q=(uo(i1=function(){var e;return e=_Y.apply(this,arguments)||this,e.color=new _X(new _W([new _j(0,new c6(1,1,1)),new _j(1,new c6(1,1,1))],[new _K(0,1),new _K(1,1)])),e._colorGradientRand=new ut(0,cF.ColorOverLifetime),e._gradientKeysCount=new c9(0,0,0,0),e},_Y),(i2=i1.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.color.mode;if(n!==e.ParticleGradientMode.Gradient&&n!==e.ParticleGradientMode.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(i1._maxGradientColor,a.gradientMax._getColorTypeArray(i)),t.setFloatArray(i1._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=i1._gradientMacro:(t.setFloatArray(i1._minGradientColor,a.gradientMin._getColorTypeArray(i)),t.setFloatArray(i1._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),r=i1._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),t.setVector4(i1._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},i2._resetRandomSeed=function(e){this._colorGradientRand.reset(e,cF.ColorOverLifetime)},i1);_q._gradientMacro=uz.getByName("RENDERER_COL_GRADIENT"),_q._randomGradientsMacro=uz.getByName("RENDERER_COL_RANDOM_GRADIENTS"),_q._minGradientColor=uF.getByName("renderer_COLMinGradientColor"),_q._minGradientAlpha=uF.getByName("renderer_COLMinGradientAlpha"),_q._maxGradientColor=uF.getByName("renderer_COLMaxGradientColor"),_q._maxGradientAlpha=uF.getByName("renderer_COLMaxGradientAlpha"),_q._gradientKeysCount=uF.getByName("renderer_COLGradientKeysMaxTime"),us([uh],_q.prototype,"color",void 0),us([uc],_q.prototype,"_colorGradientRand",void 0),us([uc],_q.prototype,"_gradientKeysCount",void 0),us([uc],_q.prototype,"_colorMacro",void 0);var _Q=((i4=(i3=function(t,r){this._updateManager=new ub,this._mode=e.ParticleCurveMode.Constant,this._constantMin=0,this._constantMax=0,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager),"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}},i4._getMax=function(){switch(this.mode){case e.ParticleCurveMode.Constant:return this.constantMax;case e.ParticleCurveMode.TwoConstants:return Math.max(this.constantMin,this.constantMax);case e.ParticleCurveMode.Curve:var t;return this._getMaxKeyValue(null==(t=this.curveMax)?void 0:t.keys);case e.ParticleCurveMode.TwoCurves:var r,n,a=this._getMaxKeyValue(null==(r=this.curveMin)?void 0:r.keys),i=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return a>i?a:i}},i4._getMinMax=function(t){switch(this.mode){case e.ParticleCurveMode.Constant:t.x=t.y=this.constantMax;break;case e.ParticleCurveMode.TwoConstants:t.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case e.ParticleCurveMode.Curve:var r,n;t.set(this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys));break;case e.ParticleCurveMode.TwoCurves:var a,i,o,s,l=this._getMinKeyValue(null==(a=this.curveMax)?void 0:a.keys),c=this._getMinKeyValue(null==(i=this.curveMin)?void 0:i.keys),u=this._getMaxKeyValue(null==(o=this.curveMax)?void 0:o.keys),d=this._getMaxKeyValue(null==(s=this.curveMin)?void 0:s.keys),h=l<c?l:c,_=u>d?u:d;t.set(h,_)}},i4._registerOnValueChanged=function(e){this._updateManager.addListener(e)},i4._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},i4._getMaxKeyValue=function(e){var t,r=void 0,n=null!=(t=null==e?void 0:e.length)?t:0;if(n>0){r=e[0].value;for(var a=1;a<n;a++)r=Math.max(r,e[a].value)}return r},i4._getMinKeyValue=function(e){var t,r=void 0,n=null!=(t=null==e?void 0:e.length)?t:0;if(n>0){r=e[0].value;for(var a=1;a<n;a++)r=Math.min(r,e[a].value)}return r},i4._onCurveChange=function(e,t){var r=this._updateDispatch;null==e||e._unRegisterOnValueChanged(r),null==t||t._registerOnValueChanged(r),r()},ua(i3,[{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._updateDispatch())}},{key:"constantMin",get:function(){return this._constantMin},set:function(e){e!==this._constantMin&&(this._constantMin=e,this._updateDispatch())}},{key:"constantMax",get:function(){return this._constantMax},set:function(e){e!==this._constantMax&&(this._constantMax=e,this._updateDispatch())}},{key:"curveMin",get:function(){return this._curveMin},set:function(e){var t=this._curveMin;e!==t&&(this._curveMin=e,this._onCurveChange(t,e))}},{key:"curveMax",get:function(){return this._curveMax},set:function(e){var t=this._curveMax;e!==t&&(this._curveMax=e,this._onCurveChange(t,e))}},{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}}]),i3);us([uc],_Q.prototype,"_updateManager",void 0),us([uh],_Q.prototype,"_curveMin",void 0),us([uh],_Q.prototype,"_curveMax",void 0),us([uc],_Q.prototype,"_updateDispatch",void 0);var _Z=(uo(i8=function(){var e;return e=_Y.apply(this,arguments)||this,e.rateOverTime=new _Q(10),e.rateOverDistance=new _Q(0),e._shapeRand=new ut(0,cF.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new ut(0,cF.Burst),e},_Y),(i5=i8.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)},i5.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},i5.removeBurstByIndex=function(e){this._bursts.splice(e,1)},i5.clearBurst=function(){this._bursts.length=0},i5._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},i5._resetRandomSeed=function(e){this._burstRand.reset(e,cF.Burst),this._shapeRand.reset(e,cF.Shape)},i5._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},i5._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},i5._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,a=e-this._frameRateTime;a>=n;)a-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},i5._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,a=Math.floor((t-e)/n);if(r.isLoop&&(a>0||t%n<e%n)){var i=Math.ceil(e/n)*n;this._emitBySubBurst(e,i,n),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=n,this._emitBySubBurst(s,i,n),this._currentBurstIndex=0}this._emitBySubBurst(i,t,n)}else this._emitBySubBurst(e,t,n)},i5._emitBySubBurst=function(e,t,r){for(var n=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,u=i.length;c<u;c++){var d=i[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,a.random());n._emit(o+h,_)}}this._currentBurstIndex=c},ua(i8,[{key:"shape",get:function(){return this._shape},set:function(e){var t=this._shape;if(e!==t){this._shape=e;var r=this._generator._renderer;null==t||t._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==e||e._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),i8);us([uh],_Z.prototype,"rateOverTime",void 0),us([uh],_Z.prototype,"rateOverDistance",void 0),us([uh],_Z.prototype,"_shape",void 0),us([uc],_Z.prototype,"_shapeRand",void 0),us([uh],_Z.prototype,"_bursts",void 0),us([uc],_Z.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(i9=e.ParticleScaleMode||(e.ParticleScaleMode={}))[i9.Hierarchy=0]="Hierarchy",i9[i9.Local=1]="Local",i9[i9.World=2]="World";var _J=((i7=(i6=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new _Q(0),this.startRotation3D=!1,this.startRotationX=new _Q(0),this.startRotationY=new _Q(0),this.startRotationZ=new _Q(0),this.flipRotation=0,this.startColor=new _X(new c6(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new ut(0,cF.StartSpeed),this._startLifeTimeRand=new ut(0,cF.StartLifetime),this._startColorRand=new ut(0,cF.StartColor),this._startSizeRand=new ut(0,cF.StartSize),this._startRotationRand=new ut(0,cF.StartRotation),this._gravityModifierRand=new ut(0,cF.GravityModifier),this._startSize3D=!1,this._simulationSpace=e.ParticleSimulationSpace.Local,this._gravity=new cQ,this._generator=t,this.startLifetime=new _Q(5),this.startSpeed=new _Q(5),this.startSizeX=new _Q(1),this.startSizeY=new _Q(1),this.startSizeZ=new _Q(1),this.gravityModifier=new _Q(0)}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,cF.StartSpeed),this._startLifeTimeRand.reset(e,cF.StartLifetime),this._startColorRand.reset(e,cF.StartColor),this._startSizeRand.reset(e,cF.StartSize),this._startRotationRand.reset(e,cF.StartRotation)},i7._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}},i7._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(i6._worldPosition,n.worldPosition);var a=n.worldRotationQuaternion,i=i6._tempVector40;i.copyFrom(a),t.setVector4(i6._worldRotation,i);break;case e.ParticleSimulationSpace.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:var o=n.lossyWorldScale;t.setVector3(i6._positionScale,o),t.setVector3(i6._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(i6._positionScale,o),t.setVector3(i6._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(i6._positionScale,n.lossyWorldScale),t.setVector3(i6._sizeScale,i6._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());cQ.scale(r.scene.physics.gravity,l,s),t.setVector3(i6._gravity,s),t.setInt(i6._simulationSpace,this.simulationSpace),t.setFloat(i6._startRotation3D,+this.startRotation3D),t.setInt(i6._scaleMode,this.scalingMode)},i7._cloneTo=function(t){t.maxParticles=this.maxParticles,t._simulationSpace===e.ParticleSimulationSpace.World&&t._generator._generateTransformedBounds()},i7._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ua(i6,[{key:"startLifetime",get:function(){return this._startLifetime},set:function(e){var t=this._startLifetime;e!==t&&(this._startLifetime=e,this._onCompositeCurveChange(t,e))}},{key:"startSpeed",get:function(){return this._startSpeed},set:function(e){var t=this._startSpeed;e!==t&&(this._startSpeed=e,this._onCompositeCurveChange(t,e))}},{key:"startSize3D",get:function(){return this._startSize3D},set:function(e){e!==this._startSize3D&&(this._startSize3D=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"startSizeX",get:function(){return this._startSizeX},set:function(e){var t=this._startSizeX;e!==t&&(this._startSizeX=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeY",get:function(){return this._startSizeY},set:function(e){var t=this._startSizeY;e!==t&&(this._startSizeY=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeZ",get:function(){return this._startSizeZ},set:function(e){var t=this._startSizeZ;e!==t&&(this._startSizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"gravityModifier",get:function(){return this._gravityModifier},set:function(e){var t=this._gravityModifier;e!==t&&(this._gravityModifier=e,this._onCompositeCurveChange(t,e))}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(t){if(t!==this._simulationSpace){this._simulationSpace=t;var r=this._generator;r._renderer._onTransformChanged(cr.WorldMatrix),t===e.ParticleSimulationSpace.Local&&r._freeBoundsArray()}}},{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}}]),i6);_J._tempVector40=new c9,_J._vector3One=new cQ(1,1,1),_J._positionScale=uF.getByName("renderer_PositionScale"),_J._sizeScale=uF.getByName("renderer_SizeScale"),_J._worldPosition=uF.getByName("renderer_WorldPosition"),_J._worldRotation=uF.getByName("renderer_WorldRotation"),_J._gravity=uF.getByName("renderer_Gravity"),_J._simulationSpace=uF.getByName("renderer_SimulationSpace"),_J._startRotation3D=uF.getByName("renderer_ThreeDStartRotation"),_J._scaleMode=uF.getByName("renderer_ScalingMode"),us([uh],_J.prototype,"startDelay",void 0),us([uh],_J.prototype,"startRotationX",void 0),us([uh],_J.prototype,"startRotationY",void 0),us([uh],_J.prototype,"startRotationZ",void 0),us([uh],_J.prototype,"startColor",void 0),us([uc],_J.prototype,"_maxParticleBuffer",void 0),us([uc],_J.prototype,"_startSpeedRand",void 0),us([uc],_J.prototype,"_startLifeTimeRand",void 0),us([uc],_J.prototype,"_startColorRand",void 0),us([uc],_J.prototype,"_startSizeRand",void 0),us([uc],_J.prototype,"_startRotationRand",void 0),us([uc],_J.prototype,"_gravityModifierRand",void 0),us([uh],_J.prototype,"_startLifetime",void 0),us([uh],_J.prototype,"_startSpeed",void 0),us([uh],_J.prototype,"_startSizeX",void 0),us([uh],_J.prototype,"_startSizeY",void 0),us([uh],_J.prototype,"_startSizeZ",void 0),us([uh],_J.prototype,"_gravityModifier",void 0),us([uc],_J.prototype,"_generator",void 0),us([uc],_J.prototype,"_gravity",void 0);var _$=(uo(oe=function(){var e;return e=_Y.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new _Q(0),e.rotationY=new _Q(0),e.rotationZ=new _Q(45),e._rotationRand=new ut(0,cF.RotationOverLifetime),e._rotationMinConstant=new cQ,e._rotationMaxConstant=new cQ,e},_Y),(ot=oe.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(oe._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(oe._maxCurveXProperty,i.curveMax._getTypeArray()),t.setFloatArray(oe._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(oe._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(oe._minCurveXProperty,i.curveMin._getTypeArray()),t.setFloatArray(oe._minCurveYProperty,o.curveMin._getTypeArray())),a=oe._isRandomTwoMacro),n=oe._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(cq.degreeToRadian(i.constantMax),cq.degreeToRadian(o.constantMax),cq.degreeToRadian(s.constantMax)),t.setVector3(oe._maxConstantProperty,u),l?i.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(cq.degreeToRadian(i.constantMin),cq.degreeToRadian(o.constantMin),cq.degreeToRadian(s.constantMin)),t.setVector3(oe._minConstantProperty,d),a=oe._isRandomTwoMacro}n=oe._constantModeMacro}l&&(r=oe._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},ot._resetRandomSeed=function(e){this._rotationRand.reset(e,cF.RotationOverLifetime)},oe);_$._constantModeMacro=uz.getByName("RENDERER_ROL_CONSTANT_MODE"),_$._curveModeMacro=uz.getByName("RENDERER_ROL_CURVE_MODE"),_$._isSeparateMacro=uz.getByName("RENDERER_ROL_IS_SEPARATE"),_$._isRandomTwoMacro=uz.getByName("RENDERER_ROL_IS_RANDOM_TWO"),_$._minConstantProperty=uF.getByName("renderer_ROLMinConst"),_$._minCurveXProperty=uF.getByName("renderer_ROLMinCurveX"),_$._minCurveYProperty=uF.getByName("renderer_ROLMinCurveY"),_$._minCurveZProperty=uF.getByName("renderer_ROLMinCurveZ"),_$._maxConstantProperty=uF.getByName("renderer_ROLMaxConst"),_$._maxCurveXProperty=uF.getByName("renderer_ROLMaxCurveX"),_$._maxCurveYProperty=uF.getByName("renderer_ROLMaxCurveY"),_$._maxCurveZProperty=uF.getByName("renderer_ROLMaxCurveZ"),us([uh],_$.prototype,"rotationX",void 0),us([uh],_$.prototype,"rotationY",void 0),us([uh],_$.prototype,"rotationZ",void 0),us([uc],_$.prototype,"_rotationRand",void 0),us([uc],_$.prototype,"_rotationMinConstant",void 0),us([uc],_$.prototype,"_rotationMaxConstant",void 0),us([uc],_$.prototype,"_enableSeparateMacro",void 0),us([uc],_$.prototype,"_isCurveMacro",void 0),us([uc],_$.prototype,"_isRandomTwoMacro",void 0);var _0=((on=(or=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this._updateManager=new ub,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var n=0,a=t.length;n<a;n++){var i=t[n];this.addKey(i)}}).prototype).addKey=function(e,t){var r=this._keys;if(4===r.length)throw Error("Curve can only have 4 keys");var n="number"==typeof e?new _1(e,t):e;this._addKey(r,n),n._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},on.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},on.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},on._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},on._registerOnValueChanged=function(e){this._updateManager.addListener(e)},on._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},on._addKey=function(e,t){var r=e.length,n=t.time;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},ua(or,[{key:"keys",get:function(){return this._keys}}]),or);us([uc],_0.prototype,"_updateManager",void 0),us([uh],_0.prototype,"_keys",void 0),us([uc],_0.prototype,"_typeArray",void 0),us([uc],_0.prototype,"_updateDispatch",void 0);var _1=((oi=(oa=function(e,t){this._updateManager=new ub,this._time=e,this._value=t}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},oi._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},ua(oa,[{key:"time",get:function(){return this._time},set:function(e){e!==this._time&&(this._time=e,this._updateManager.dispatch())}},{key:"value",get:function(){return this._value},set:function(e){e!==this._value&&(this._value=e,this._updateManager.dispatch())}}]),oa);us([uc],_1.prototype,"_updateManager",void 0);var _2=(uo(oo=function(e){var t;return(t=_Y.call(this,e)||this)._separateAxes=!1,t.sizeX=new _Q(new _0(new _1(0,0),new _1(1,1))),t.sizeY=new _Q(new _0(new _1(0,0),new _1(1,1))),t.sizeZ=new _Q(new _0(new _1(0,0),new _1(1,1))),t},_Y),(os=oo.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:i.mode===e.ParticleCurveMode.TwoCurves;(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:i.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(oo._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(t.setFloatArray(oo._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(oo._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(oo._minCurveXProperty,i.curveMin._getTypeArray()),l&&(t.setFloatArray(oo._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(oo._minCurveZProperty,s.curveMin._getTypeArray())),a=oo._isRandomTwoMacro),n=oo._curveModeMacro),l&&(r=oo._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},os._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ua(oo,[{key:"separateAxes",get:function(){return this._separateAxes},set:function(e){e!==this._separateAxes&&(this._separateAxes=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"sizeX",get:function(){return this._sizeX},set:function(e){var t=this._sizeX;e!==t&&(this._sizeX=e,this._onCompositeCurveChange(t,e))}},{key:"sizeY",get:function(){return this._sizeY},set:function(e){var t=this._sizeY;e!==t&&(this._sizeY=e,this._onCompositeCurveChange(t,e))}},{key:"sizeZ",get:function(){return this._sizeZ},set:function(e){var t=this._sizeZ;e!==t&&(this._sizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),oo);_2._curveModeMacro=uz.getByName("RENDERER_SOL_CURVE_MODE"),_2._isSeparateMacro=uz.getByName("RENDERER_SOL_IS_SEPARATE"),_2._isRandomTwoMacro=uz.getByName("RENDERER_SOL_IS_RANDOM_TWO"),_2._minCurveXProperty=uF.getByName("renderer_SOLMinCurveX"),_2._minCurveYProperty=uF.getByName("renderer_SOLMinCurveY"),_2._minCurveZProperty=uF.getByName("renderer_SOLMinCurveZ"),_2._maxCurveXProperty=uF.getByName("renderer_SOLMaxCurveX"),_2._maxCurveYProperty=uF.getByName("renderer_SOLMaxCurveY"),_2._maxCurveZProperty=uF.getByName("renderer_SOLMaxCurveZ"),us([uh],_2.prototype,"_sizeX",void 0),us([uh],_2.prototype,"_sizeY",void 0),us([uh],_2.prototype,"_sizeZ",void 0),us([uc],_2.prototype,"_enableSeparateMacro",void 0),us([uc],_2.prototype,"_isCurveMacro",void 0),us([uc],_2.prototype,"_isRandomTwoMacro",void 0);var _3=(uo(ol=function(){var e;return e=_Y.apply(this,arguments)||this,e.startFrame=new _Q(0),e.frameOverTime=new _Q(new _0(new _1(0,0),new _1(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new cQ(1,1,1),e._frameOverTimeRand=new ut(0,cF.TextureSheetAnimation),e._tiling=new c5(1,1),e},_Y),(oc=ol.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.frameOverTime.mode;if(n===e.ParticleCurveMode.Curve||n===e.ParticleCurveMode.TwoCurves){var a=this.frameOverTime;t.setFloatArray(ol._frameMaxCurveProperty,a.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=ol._frameCurveMacro:(t.setFloatArray(ol._frameMinCurveProperty,a.curveMin._getTypeArray()),r=ol._frameRandomCurvesMacro),t.setFloat(ol._cycleCountProperty,this.cycleCount),t.setVector3(ol._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},oc._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,cF.TextureSheetAnimation)},ua(ol,[{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)}}]),ol);_3._frameCurveMacro=uz.getByName("RENDERER_TSA_FRAME_CURVE"),_3._frameRandomCurvesMacro=uz.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),_3._cycleCountProperty=uF.getByName("renderer_TSACycles"),_3._tillingParamsProperty=uF.getByName("renderer_TSATillingParams"),_3._frameMinCurveProperty=uF.getByName("renderer_TSAFrameMinCurve"),_3._frameMaxCurveProperty=uF.getByName("renderer_TSAFrameMaxCurve"),us([uh],_3.prototype,"startFrame",void 0),us([uh],_3.prototype,"frameOverTime",void 0),us([ud],_3.prototype,"_tillingInfo",void 0),us([uc],_3.prototype,"_frameOverTimeRand",void 0),us([uh],_3.prototype,"_tiling",void 0),us([uc],_3.prototype,"_textureSheetMacro",void 0),(ou=cL||(cL={}))[ou.WholeSheet=0]="WholeSheet",ou[ou.SingleRow=1]="SingleRow";var _4=(uo(od=function(t){var r;return(r=_Y.call(this,t)||this)._velocityRand=new ut(0,cF.VelocityOverLifetime),r._velocityMinConstant=new cQ,r._velocityMaxConstant=new cQ,r._space=e.ParticleSimulationSpace.Local,r.velocityX=new _Q(0),r.velocityY=new _Q(0),r.velocityZ=new _Q(0),r},_Y),(oh=od.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,a=this.velocityY,i=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve)t.setFloatArray(od._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(od._maxGradientYProperty,a.curveMax._getTypeArray()),t.setFloatArray(od._maxGradientZProperty,i.curveMax._getTypeArray()),o?(t.setFloatArray(od._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(od._minGradientYProperty,a.curveMin._getTypeArray()),t.setFloatArray(od._minGradientZProperty,i.curveMin._getTypeArray()),r=od._randomCurveMacro):r=od._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,a.constantMax,i.constantMax),t.setVector3(od._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,a.constantMin,i.constantMin),t.setVector3(od._minConstantProperty,l),r=od._randomConstantMacro}else r=od._constantMacro}t.setInt(od._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},oh._resetRandomSeed=function(e){this._velocityRand.reset(e,cF.VelocityOverLifetime)},oh._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ua(od,[{key:"velocityX",get:function(){return this._velocityX},set:function(e){var t=this._velocityX;e!==t&&(this._velocityX=e,this._onCompositeCurveChange(t,e))}},{key:"velocityY",get:function(){return this._velocityY},set:function(e){var t=this._velocityY;e!==t&&(this._velocityY=e,this._onCompositeCurveChange(t,e))}},{key:"velocityZ",get:function(){return this._velocityZ},set:function(e){var t=this._velocityZ;e!==t&&(this._velocityZ=e,this._onCompositeCurveChange(t,e))}},{key:"space",get:function(){return this._space},set:function(e){e!==this._space&&(this._space=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._generator._renderer._onGeneratorParamsChanged())}}]),od);_4._constantMacro=uz.getByName("RENDERER_VOL_CONSTANT"),_4._curveMacro=uz.getByName("RENDERER_VOL_CURVE"),_4._randomConstantMacro=uz.getByName("RENDERER_VOL_RANDOM_CONSTANT"),_4._randomCurveMacro=uz.getByName("RENDERER_VOL_RANDOM_CURVE"),_4._minConstantProperty=uF.getByName("renderer_VOLMinConst"),_4._maxConstantProperty=uF.getByName("renderer_VOLMaxConst"),_4._minGradientXProperty=uF.getByName("renderer_VOLMinGradientX"),_4._minGradientYProperty=uF.getByName("renderer_VOLMinGradientY"),_4._minGradientZProperty=uF.getByName("renderer_VOLMinGradientZ"),_4._maxGradientXProperty=uF.getByName("renderer_VOLMaxGradientX"),_4._maxGradientYProperty=uF.getByName("renderer_VOLMaxGradientY"),_4._maxGradientZProperty=uF.getByName("renderer_VOLMaxGradientZ"),_4._spaceProperty=uF.getByName("renderer_VOLSpace"),us([uc],_4.prototype,"_velocityRand",void 0),us([uc],_4.prototype,"_velocityMinConstant",void 0),us([uc],_4.prototype,"_velocityMaxConstant",void 0),us([uc],_4.prototype,"_velocityMacro",void 0),us([uh],_4.prototype,"_velocityX",void 0),us([uh],_4.prototype,"_velocityY",void 0),us([uh],_4.prototype,"_velocityZ",void 0);var _8=function(){function t(r){this.useAutoRandomSeed=!0,this.emission=new _Z(this),this.rotationOverLifetime=new _$(this),this.colorOverLifetime=new _q(this),this.textureSheetAnimation=new _3(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new dY(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._renderer=r,new dX().start=0,this._primitive=new dq(r.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,t._particleIncreaseCount),this.main=new _J(this),this.velocityOverLifetime=new _4(this),this.sizeOverLifetime=new _2(this),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(_H,t._tempParticleRenderers),n=0,a=r.length;n<a;n++)r[n].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(4294967295*Math.random()))},r.stop=function(r,n){if(void 0===r&&(r=!0),void 0===n&&(n=e.ParticleStopMode.StopEmitting),r)for(var a=this._renderer.entity.getComponentsIncludeChildren(_H,t._tempParticleRenderers),i=0,o=a.length;i<o;i++)a[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===e.ParticleStopMode.StopEmittingAndClear){var s=this._firstFreeElement;this._firstRetiredElement=s,this._firstActiveElement=s,this._firstNewElement=s,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},r.emit=function(e){this._emit(this._playTime,e)},r._emit=function(e,r){if(this.emission.enabled&&!(this.main._maxParticleBuffer<this._currentParticleCount))for(var n=t._tempVector30,a=t._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,e,n,a);var l=this.main._getPositionScale();n.multiply(l),a.normalize().multiply(l)}else n.set(0,0,0),a.set(0,0,-1);this._addNewParticle(n,a,i,e)}},r._update=function(t){var r=this.isAlive,n=this.main,a=this.emission,i=n.duration,o=this._playTime;if(this._playTime+=t*n.simulationSpeed,this._retireActiveParticles(),this._freeRetiredParticles(),n.simulationSpace===e.ParticleSimulationSpace.World&&this._retireTransformedBounds(),a.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),a._emit(o,this._playTime),!n.isLoop&&this._playTime>i&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===e.ParticleSimulationSpace.World&&this._generateTransformedBounds();else{var s=Math.min(a._frameRateTime,Math.floor(this._playTime/i)*i);this._playTime-=s,a._frameRateTime-=s}this.isAlive!==r&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},r._reorganizeGeometryBuffers=function(){var t=this._renderer,r=t.engine._particleBufferUtils,n=this._primitive,a=this._vertexBufferBindings;if(n.clearVertexElements(),a.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var i=t.mesh;if(!i)return;var o=i.getVertexElement(e.VertexAttribute.Position),s=i.getVertexElement(e.VertexAttribute.Color),l=i.getVertexElement(e.VertexAttribute.UV),c=o?i.vertexBufferBindings[o.bindingIndex]:null,u=s?i.vertexBufferBindings[s.bindingIndex]:null,d=l?i.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,a);n.addVertexElement(new dO(e.VertexAttribute.Position,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,a);n.addVertexElement(new dO(e.VertexAttribute.Color,s.offset,s.format,_))}if(d){var f=this._addVertexBufferBindingsFilterDuplicate(d,a);n.addVertexElement(new dO(e.VertexAttribute.UV,l.offset,l.format,f))}var p=i._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),a.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=hQ.billboardIndexCount;n.setVertexBufferBindings(a);for(var m=r.instanceVertexElements,g=a.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new dO(x.attribute,x.offset,x.format,g,x.instanceStepRate))}},r._resizeInstanceBuffer=function(t,r){null==(h=this._instanceVertexBufferBinding)||h.buffer.destroy();var n=hQ.instanceVertexStride,a=t?this._currentParticleCount+r:this.main._maxParticleBuffer,i=n*a,o=this._renderer.engine,s=new dD(o,e.BufferBindFlag.VertexBuffer,i,e.BufferUsage.Dynamic,!1);s.isGCIgnored=!0;var l=this._primitive.vertexBufferBindings,c=new dZ(s,n),u=new Float32Array(i/4),d=this._instanceVertices;if(d){var h,_,f,p=hQ.instanceVertexFloatStride,m=this._firstFreeElement,g=this._firstRetiredElement;if(t){u.set(new Float32Array(d.buffer,0,m*p));var v=m+1,y=(v+r)*p;u.set(new Float32Array(d.buffer,v*p*4),y),this._firstNewElement>m&&(this._firstNewElement+=r),this._firstActiveElement>m&&(this._firstActiveElement+=r),g>m&&(this._firstRetiredElement+=r)}else g<=m?(_=m-g,f=0,this._firstFreeElement-=g,this._firstNewElement-=g,this._firstActiveElement-=g,this._firstRetiredElement=0):(_=this._currentParticleCount-g,f=m,this._firstNewElement>m&&(this._firstNewElement-=m),this._firstActiveElement>m&&(this._firstActiveElement-=m),g>m&&(this._firstRetiredElement-=m)),u.set(new Float32Array(d.buffer,g*p*4,_*p),f*p);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(d?l.length-1:l.length,c),this._instanceVertices=u,this._instanceVertexBufferBinding=c,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(),this.emission._destroy()},r._updateBoundsSimulationLocal=function(e){var t=this._renderer,r=this.main.startLifetime._getMax(),n=t._generatorBounds,a=t._transformedBounds;t._isContainDirtyFlag(cP.GeneratorVolume)&&(this._calculateGeneratorBounds(r,n),t._setDirtyFlagFalse(cP.GeneratorVolume)),t._isContainDirtyFlag(cP.TransformVolume)&&(this._calculateTransformedBounds(r,n,a),t._setDirtyFlagFalse(cP.TransformVolume)),this._addGravityToBounds(r,a,e)},r._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,r=this._firstActiveTransformedBoundingBox,n=this._firstFreeTransformedBoundingBox,a=r*hQ.boundsFloatStride;if(e.min.copyFromArray(t,a),e.max.copyFromArray(t,a+3),r<n)for(var i=r+1;i<n;i++)this._mergeTransformedBounds(i,e);else{for(var o=r+1,s=this._transformedBoundsCount;o<s;o++)this._mergeTransformedBounds(o,e);if(n>0)for(var l=0;l<n;l++)this._mergeTransformedBounds(l,e)}var c=this.main.startLifetime._getMax();this._addGravityToBounds(c,e,e)},r._freeBoundsArray=function(){this._transformedBoundsArray=null,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0},r._generateTransformedBounds=function(){var e=this._renderer,t=this.main.startLifetime._getMax(),r=e._generatorBounds;e._isContainDirtyFlag(cP.GeneratorVolume)&&(this._calculateGeneratorBounds(t,r),e._setDirtyFlagFalse(cP.GeneratorVolume));var n=hQ.boundsFloatStride,a=hQ.boundsTimeOffset,i=hQ.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(cP.TransformVolume)){var s=o+1;s>=this._transformedBoundsCount&&(s=0),s===this._firstActiveTransformedBoundingBox&&(this._resizeTransformedBoundsArray(),s=o+1);var l=e._transformedBounds;this._calculateTransformedBounds(t,r,l);var c=o*n,u=this._transformedBoundsArray;l.min.copyToArray(u,c),l.max.copyToArray(u,c+3),u[c+a]=this._playTime,u[c+i]=t,this._firstFreeTransformedBoundingBox=s,e._setDirtyFlagFalse(cP.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*hQ.boundsFloatStride+a]=this._playTime}},r._addNewParticle=function(r,n,a,i){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=a.worldPosition,s=a.worldRotationQuaternion);var h=u.startSpeed.evaluate(void 0,u._startSpeedRand.random()),_=this._instanceVertices,f=l*hQ.instanceVertexFloatStride;_[f]=r.x,_[f+1]=r.y,_[f+2]=r.z,_[f+hQ.startLifeTimeOffset]=u.startLifetime.evaluate(void 0,u._startLifeTimeRand.random()),_[f+4]=n.x,_[f+5]=n.y,_[f+6]=n.z,_[f+hQ.timeOffset]=i;var p=t._tempColor0;u.startColor.evaluate(void 0,u._startColorRand.random(),p),this._renderer.engine.settings.colorSpace===e.ColorSpace.Linear&&p.toLinear(p),_[f+8]=p.r,_[f+9]=p.g,_[f+10]=p.b,_[f+11]=p.a;var m=u._startSizeRand;if(u.startSize3D)_[f+12]=u.startSizeX.evaluate(void 0,m.random()),_[f+13]=u.startSizeY.evaluate(void 0,m.random()),_[f+14]=u.startSizeZ.evaluate(void 0,m.random());else{var g=u.startSize.evaluate(void 0,m.random());_[f+12]=g,_[f+13]=g,_[f+14]=g}var v=u._startRotationRand;u.startRotation3D?(_[f+15]=cq.degreeToRadian(u.startRotationX.evaluate(void 0,v.random())),_[f+16]=cq.degreeToRadian(u.startRotationY.evaluate(void 0,v.random())),_[f+17]=cq.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random()))):_[f+15]=cq.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random())),_[f+18]=h;var y=this.colorOverLifetime;y.enabled&&y.color.mode===e.ParticleGradientMode.TwoGradients&&(_[f+20]=y._colorGradientRand.random());var x=this.rotationOverLifetime;x.enabled&&x.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(_[f+22]=x._rotationRand.random());var b=this.textureSheetAnimation;b.enabled&&b.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(_[f+23]=b._frameOverTimeRand.random());var T=this.velocityOverLifetime;if(T.enabled&&T.velocityX.mode===e.ParticleCurveMode.TwoConstants&&T.velocityY.mode===e.ParticleCurveMode.TwoConstants&&T.velocityZ.mode===e.ParticleCurveMode.TwoConstants){var C=T._velocityRand;_[f+24]=C.random(),_[f+25]=C.random(),_[f+26]=C.random()}if(this.main.simulationSpace===e.ParticleSimulationSpace.World&&(_[f+27]=o.x,_[f+28]=o.y,_[f+29]=o.z,_[f+30]=s.x,_[f+31]=s.y,_[f+32]=s.z,_[f+33]=s.w),this.textureSheetAnimation.enabled){var S=this.textureSheetAnimation._tillingInfo;_[f+hQ.simulationUVOffset]=S.x,_[f+35]=S.y,_[f+36]=0,_[f+37]=0}else _[f+hQ.simulationUVOffset]=1,_[f+35]=1,_[f+36]=0,_[f+37]=0;this._firstFreeElement=c},r._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var r=this._firstActiveElement*hQ.instanceVertexFloatStride,n=r+hQ.timeOffset;if(Math.fround(this._playTime-t[n])<t[r+hQ.startLifeTimeOffset])break;t[n]=e,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},r._freeRetiredParticles=function(){for(var e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var t=this._firstRetiredElement*hQ.instanceVertexFloatStride+hQ.startLifeTimeOffset;if(e-this._instanceVertices[t]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},r._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,r=this._firstFreeElement;if(t!==r){var n=hQ.instanceVertexStride,a=t*n,i=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)i.setData(o,0,a,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;i.setData(o,0,a,s,e.SetDataOptions.Discard),r>0&&i.setData(o,s,0,r*n)}this._firstNewElement=r,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},r._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return t.push(e),r},r._resizeTransformedBoundsArray=function(){var e=hQ.boundsFloatStride,r=t._transformedBoundsIncreaseCount;this._transformedBoundsCount+=r;var n=this._transformedBoundsArray,a=new Float32Array(this._transformedBoundsCount*e);if(n){var i=this._firstFreeTransformedBoundingBox;a.set(new Float32Array(n.buffer,0,i*e));var o=i+1,s=(o+r)*e;a.set(new Float32Array(n.buffer,o*e*4),s),this._firstActiveTransformedBoundingBox>i&&(this._firstActiveTransformedBoundingBox+=r)}this._transformedBoundsArray=a},r._retireTransformedBounds=function(){for(var e=hQ.boundsFloatStride,t=hQ.boundsTimeOffset,r=hQ.boundsMaxLifetimeOffset,n=this._transformedBoundsArray,a=this._firstFreeTransformedBoundingBox,i=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==a;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-n[o+t]<=n[o+r])break;++this._firstActiveTransformedBoundingBox>=i&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},r._calculateGeneratorBounds=function(r,n){var a=t._tempVector30,i=t._tempVector31,o=t._tempVector20,s=n.min,l=n.max,c=this.main,u=this.emission.shape;(null==u?void 0:u.enabled)?(u._getPositionRange(s,l),u._getDirectionRange(i,a)):(s.set(0,0,0),l.set(0,0,0),i.set(0,0,-1),a.set(0,0,0)),this._getExtremeValueFromZero(c.startSpeed,o);var d=o.x,h=o.y,_=i.x,f=i.y,p=i.z,m=a.x,g=a.y,v=a.z;s.set(s.x+Math.min(_*h,m*d)*r,s.y+Math.min(f*h,g*d)*r,s.z+Math.min(p*h,v*d)*r),l.set(l.x+Math.max(_*d,m*h)*r,l.y+Math.max(f*d,g*h)*r,l.z+Math.max(p*d,v*h)*r);var y=c.startSize._getMax();if(c.startSize3D){var x=c.startSizeY._getMax();y=this._renderer.renderMode===e.ParticleRenderMode.Billboard||e.ParticleRenderMode.StretchBillboard||e.ParticleRenderMode.HorizontalBillboard?Math.max(y,x):Math.max(y,x,c.startSizeZ._getMax())}y*=1.414;var b=this.sizeOverLifetime;if(b.enabled){var T=b.size._getMax();b.separateAxes&&(T=Math.max(T,b.sizeY._getMax(),b.sizeZ._getMax())),y*=T}s.set(s.x-y,s.y-y,s.z-y),l.set(l.x+y,l.y+y,l.z+y)},r._mergeTransformedBounds=function(e,t){var r=t.min,n=t.max,a=this._transformedBoundsArray,i=e*hQ.boundsFloatStride;r.set(Math.min(r.x,a[i]),Math.min(r.y,a[i+1]),Math.min(r.z,a[i+2])),n.set(Math.max(n.x,a[i+3]),Math.max(n.y,a[i+4]),Math.max(n.z,a[i+5]))},r._calculateTransformedBounds=function(r,n,a){var i=t._tempVector20,o=t._tempVector21,s=t._tempVector22,l=t._tempMat,c=this._renderer.entity.transform,u=c.worldPosition;c4.rotationQuaternion(c.worldRotationQuaternion,l);var d=n.min,h=n.max,_=a.min,f=a.max,p=this.velocityOverLifetime;p.enabled?(this._getExtremeValueFromZero(p.velocityX,i),this._getExtremeValueFromZero(p.velocityY,o),this._getExtremeValueFromZero(p.velocityZ,s),p.space===e.ParticleSimulationSpace.Local?(_.set(d.x+i.x*r,d.y+o.x*r,d.z+s.x*r),f.set(h.x+i.y*r,h.y+o.y*r,h.z+s.y*r),a.transform(l)):(a.transform(l),_.set(d.x+i.x*r,d.y+o.x*r,d.z+s.x*r),f.set(h.x+i.y*r,h.y+o.y*r,h.z+s.y*r))):cJ.transform(n,l,a),_.add(u),f.add(u)},r._addGravityToBounds=function(e,r,n){var a=r.min,i=r.max,o=t._tempVector20;this._getExtremeValueFromZero(this.main.gravityModifier,o);var s=this._renderer.scene.physics.gravity,l=s.x,c=s.y,u=s.z,d=.5*e*e,h=o.x*d,_=o.y*d,f=l*h,p=l*_,m=c*h,g=c*_,v=u*h,y=u*_;n.min.set(Math.min(f,p)+a.x,Math.min(m,g)+a.y,Math.min(v,y)+a.z),n.max.set(Math.max(f,p)+i.x,Math.max(m,g)+i.y,Math.max(v,y)+i.z)},r._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},ua(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}();_8._tempVector20=new c5,_8._tempVector21=new c5,_8._tempVector22=new c5,_8._tempVector30=new cQ,_8._tempVector31=new cQ,_8._tempMat=new c4,_8._tempColor0=new c6,_8._tempParticleRenderers=[],_8._particleIncreaseCount=128,_8._transformedBoundsIncreaseCount=16,us([uh],_8.prototype,"main",void 0),us([uh],_8.prototype,"emission",void 0),us([uh],_8.prototype,"velocityOverLifetime",void 0),us([uh],_8.prototype,"sizeOverLifetime",void 0),us([uh],_8.prototype,"rotationOverLifetime",void 0),us([uh],_8.prototype,"colorOverLifetime",void 0),us([uh],_8.prototype,"textureSheetAnimation",void 0),us([uc],_8.prototype,"_playTime",void 0),us([uc],_8.prototype,"_firstNewElement",void 0),us([uc],_8.prototype,"_firstActiveElement",void 0),us([uc],_8.prototype,"_firstFreeElement",void 0),us([uc],_8.prototype,"_firstRetiredElement",void 0),us([uc],_8.prototype,"_primitive",void 0),us([uc],_8.prototype,"_vertexBufferBindings",void 0),us([uc],_8.prototype,"_subPrimitive",void 0),us([uc],_8.prototype,"_renderer",void 0),us([uc],_8.prototype,"_isPlaying",void 0),us([uc],_8.prototype,"_instanceBufferResized",void 0),us([uc],_8.prototype,"_waitProcessRetiredElementCount",void 0),us([uc],_8.prototype,"_instanceVertexBufferBinding",void 0),us([uc],_8.prototype,"_instanceVertices",void 0),us([uc],_8.prototype,"_transformedBoundsArray",void 0),us([uc],_8.prototype,"_transformedBoundsCount",void 0),us([uc],_8.prototype,"_firstActiveTransformedBoundingBox",void 0),us([uc],_8.prototype,"_firstFreeTransformedBoundingBox",void 0);var _5=(uo(o_=function(e){var t;return(t=dN.call(this,e,u4.find("particle-shader"))||this).shaderData.setColor(dN._baseColorProp,new c6(1,1,1,1)),t.isTransparent=!0,t},dN),o_.prototype.clone=function(){var e=new o_(this._engine);return this.cloneTo(e),e},ua(o_,[{key:"baseColor",get:function(){return this.shaderData.getColor(dN._baseColorProp)},set:function(e){var t=this.shaderData.getColor(dN._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(dN._baseTextureProp)},set:function(e){this.shaderData.setTexture(dN._baseTextureProp,e),e?this.shaderData.enableMacro(dN._baseTextureMacro):this.shaderData.disableMacro(dN._baseTextureMacro)}}]),o_),_9=function(e,t){this.time=e,this.count=t};us([uh],_9.prototype,"count",void 0);var _6=((op=(of=function(){this._updateManager=new ub,this._enabled=!0,this._randomDirectionAmount=0}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},op._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},ua(of,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._updateManager.dispatch())}},{key:"randomDirectionAmount",get:function(){return this._randomDirectionAmount},set:function(e){e!==this._randomDirectionAmount&&(this._randomDirectionAmount=e,this._updateManager.dispatch())}}]),of);us([uc],_6.prototype,"_updateManager",void 0);var _7=((om=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},om.randomPointInsideUnitArcCircle=function(e,t,r){om.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},om.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},om.randomPointInsideUnitCircle=function(e,t){om.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},om._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,a=Math.sqrt(1-r*r);e.x=a*Math.cos(n),e.y=a*Math.sin(n),e.z=r},om._randomPointInsideUnitSphere=function(e,t){om._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},om._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},om);e.ParticleShapeType=void 0,(og=e.ParticleShapeType||(e.ParticleShapeType={}))[og.Box=0]="Box",og[og.Circle=1]="Circle",og[og.Cone=2]="Cone",og[og.Hemisphere=3]="Hemisphere",og[og.Sphere=4]="Sphere";var fe=(uo(ov=function(){var t;return(t=_6.call(this)||this).shapeType=e.ParticleShapeType.Box,t._size=new cQ(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t},_6),(oy=ov.prototype)._generatePositionAndDirection=function(e,t,r,n){_7._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=ov._tempVector30;a.set(0,0,-1),_7._randomPointUnitSphere(n,e),cQ.lerp(a,n,this.randomDirectionAmount,n)},oy._getDirectionRange=function(e,t){var r=Math.PI*this.randomDirectionAmount;if(this.randomDirectionAmount<.5){var n=Math.sin(r);e.set(-n,-n,-1),t.set(n,n,0)}else{var a=Math.cos(r);e.set(-1,-1,-1),t.set(1,1,-a)}},oy._getPositionRange=function(e,t){var r=this._size,n=r.x,a=r.y,i=r.z;e.set(-(.5*n),-(.5*a),-(.5*i)),t.set(.5*n,.5*a,.5*i)},ua(ov,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),ov);fe._tempVector30=new cQ,us([uh],fe.prototype,"_size",void 0),e.ParticleShapeArcMode=void 0,(ox=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[ox.Random=0]="Random",ox[ox.Loop=1]="Loop";var ft=(uo(ob=function(){var t;return t=_6.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Circle,t._radius=1,t._arc=360,t._arcMode=e.ParticleShapeArcMode.Random,t._arcSpeed=1,t},_6),(oT=ob.prototype)._generatePositionAndDirection=function(t,r,n,a){var i=ob._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=cq.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(t.random());break;case e.ParticleShapeArcMode.Random:_7.randomPointInsideUnitArcCircle(cq.degreeToRadian(this.arc),i,t)}n.set(i.x,i.y,0),n.scale(this.radius),_7._randomPointUnitSphere(a,t),cQ.lerp(n,a,this.randomDirectionAmount,a)},oT._getDirectionRange=function(e,t){var r=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),n=.5*(360-this._arc)*this.randomDirectionAmount,a=n>90?-1:-Math.sin(n);this._getUnitArcRange(this._arc+n,e,t,a,r)},oT._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},oT._getUnitArcRange=function(e,t,r,n,a){var i=cq.degreeToRadian(e),o=Math.sin(i);e<90?(t.set(0,n,-a),r.set(1,o,a)):(e<180?t.set(Math.cos(i),n,-a):e<270?t.set(-1,Math.min(o,n),-a):t.set(-1,-1,-a),r.set(1,1,a))},ua(ob,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"arc",get:function(){return this._arc},set:function(e){e!==this._arc&&(this._arc=e,this._updateManager.dispatch())}},{key:"arcMode",get:function(){return this._arcMode},set:function(e){e!==this._arcMode&&(this._arcMode=e,this._updateManager.dispatch())}},{key:"arcSpeed",get:function(){return this._arcSpeed},set:function(e){e!==this._arcSpeed&&(this._arcSpeed=e,this._updateManager.dispatch())}}]),ob);ft._tempPositionPoint=new c5;var fr=(uo(oC=function(){var t;return t=_6.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t},_6),(oS=oC.prototype)._generatePositionAndDirection=function(e,t,r,n){var a=oC._tempVector20,i=cq.degreeToRadian(this.angle),o=Math.sin(i),s=Math.cos(i);switch(this.emitType){case 0:_7.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var l=oC._tempVector21;_7.randomPointInsideUnitCircle(l,e),c5.lerp(a,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:_7.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0),n.set(a.x*o,a.y*o,-s),n.normalize();var c=oC._tempVector30;cQ.scale(n,this.length*e.random(),c),r.add(c);var u=oC._tempVector31;_7._randomPointUnitSphere(u,e),cQ.lerp(n,u,this.randomDirectionAmount,n)}},oS._getDirectionRange=function(e,t){var r=0;switch(this.emitType){case 0:r=cq.degreeToRadian(this._angle);break;case 1:r=Math.sin(cq.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var n=Math.sin(r);e.set(-n,-n,-1),t.set(n,n,0)},oS._getPositionRange=function(e,t){var r=this.radius;switch(this.emitType){case 0:e.set(-r,-r,0),t.set(r,r,0);break;case 1:var n=this.length,a=Math.sin(cq.degreeToRadian(this._angle));e.set(-r-a*n,-r-a*n,-n),t.set(r+a*n,r+a*n,0)}},ua(oC,[{key:"angle",get:function(){return this._angle},set:function(e){e!==this._angle&&(this._angle=e,this._updateManager.dispatch())}},{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"length",get:function(){return this._length},set:function(e){e!==this._length&&(this._length=e,this._updateManager.dispatch())}},{key:"emitType",get:function(){return this._emitType},set:function(e){e!==this._emitType&&(this._emitType=e,this._updateManager.dispatch())}}]),oC);fr._tempVector20=new c5,fr._tempVector21=new c5,fr._tempVector30=new cQ,fr._tempVector31=new cQ,e.ConeEmitType=void 0,(oA=e.ConeEmitType||(e.ConeEmitType={}))[oA.Base=0]="Base",oA[oA.Volume=1]="Volume";var fn=(uo(oM=function(){var t;return t=_6.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Hemisphere,t._radius=1,t},_6),(oR=oM.prototype)._generatePositionAndDirection=function(e,t,r,n){_7._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var a=r.z;a>0&&(r.z=-a),_7._randomPointUnitSphere(n,e),cQ.lerp(r,n,this.randomDirectionAmount,n)},oR._getDirectionRange=function(e,t){var r=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,r)},oR._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,0)},ua(oM,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),oM),fa=(uo(oE=function(){var t;return t=_6.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Sphere,t._radius=1,t},_6),(ow=oE.prototype)._generatePositionAndDirection=function(e,t,r,n){_7._randomPointInsideUnitSphere(r,e),r.scale(this.radius),_7._randomPointUnitSphere(n,e),cQ.lerp(r,n,this.randomDirectionAmount,n)},ow._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},ow._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,r)},ua(oE,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),oE);u4.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 fi=(uo(oP=function(t){var r,n=(r=dV.call(this,t,u4.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},dV),oP),fo=new cQ,fs=(uo(oF=function(e,t){(r=d$.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 cQ),r._pointStates.push(r._lifetime),r._strapPoints.push(new cQ),r._strapPoints.push(new cQ);r._curPointNum=0;var a=t.material||new fi(r.engine);return r.setMaterial(a),r.setTexture(t.texture),r._initGeometry(),r},d$),(oL=oF.prototype).update=function(e){for(var t=0,r=0,n=0;n<this._curPointNum;n++)this._pointStates[n]-=e,this._pointStates[n]<0?t++:t>0&&(r=n-t,this._pointStates[r]=this._pointStates[n],this._points[r].copyFrom(this._points[n]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];cQ.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},oL.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},oL._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),d$.prototype._render.call(this,e)},oL._initGeometry=function(){var t=new dJ(this._entity.engine),r=2*this._maxPointNum,n=20*r,a=new Float32Array(n),i=[new dO("POSITION",0,e.VertexElementFormat.Vector3,0),new dO("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new dD(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(i),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=a,this.mesh=t},oL._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new cQ(r[0],r[4],r[8]),a=new cQ(r[1],r[5],r[9]),i=new cQ(r[2],r[6],r[10]),o=this._stroke;a.scale(o);var s=new cQ,l=new cQ,c=new c3;cQ.transformByQuat(n,c,n),cQ.transformByQuat(a,c,a);var u=new cQ,d=new cQ,h=new cQ;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?cQ.subtract(p,t[f-1],h):cQ.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(cQ.dot(n,h));cQ.cross(n,h,d),0>=cQ.dot(d,i)&&(m=2*Math.PI-m),c3.rotationAxisAngle(i,m,c),cQ.transformByQuat(a,c,u),cQ.add(p,u,s),cQ.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}},oL._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,r=this._vertices,n=0;n<e;n++){var a=1-n*t,i=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[i]=0,r[i+1]=a,r[o]=1,r[o+1]=a}}},oL._projectOnVector=function(e,t,r){var n=t.clone();cQ.normalize(n,n);var a=cQ.dot(e,n);r.x=n.x*a,r.y=n.y*a,r.z=n.z*a},oL._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,fo),cQ.subtract(e,fo,r)},oF),fl=(uo(oB=function(){var t;return t=_l.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},_l),(oD=oB.prototype).onTextureChange=function(e){},oD.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 da(this.engine,this.width,this.height,this._isCube?new dl(this.engine,this.width):new di(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new da(this.engine,this.width,this.height,this._isCube?new dl(this.engine,this.width):new di(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},oD.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},oD._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},ua(oB,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),oB),fc=new cQ,fu=new cQ,fd=new cQ,fh=(uo(oI=function(){var e;return e=fl.apply(this,arguments)||this,e.position=new cQ(0,0,0),e._isCube=!0,e.oriViewMatrix=new c4,e},fl),(oO=oI.prototype).onBeginRender=function(t){if(this.enabled){fl.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),fl.prototype._reset.call(this)}},oO._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},oO._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},oO._setCamera=function(e,t){switch(e){case 0:fu.set(0,-1,0),fd.set(1,0,0);break;case 1:fu.set(0,-1,0),fd.set(-1,0,0);break;case 2:fu.set(0,0,1),fd.set(0,1,0);break;case 3:fu.set(0,0,-1),fd.set(0,-1,0);break;case 4:fu.set(0,-1,0),fd.set(0,0,1);break;case 5:fu.set(0,-1,0),fd.set(0,0,-1)}cQ.add(this.position,fd,fc),c4.lookAt(this.position,fc,fu,t.viewMatrix),t.fieldOfView=90},oI),f_=Object.freeze({__proto__:null,AmbientLight:h6,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:_C,AnimationClipCurveBinding:_b,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:_S,AnimationEvent:_T,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:_F,AnimatorCondition:_M,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:_B,AnimatorControllerLayer:_V,AnimatorControllerParameter:_L,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorLayerMask:_z,AnimatorState:_I,AnimatorStateMachine:_O,AnimatorStateTransition:_R,AssetPromise:hy,get AssetType(){return e.AssetType},Background:h5,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:dN,BasicRenderPipeline:dT,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:dj,BlendShapeFrame:dW,BlendState:u$,BlinnPhongMaterial:dk,get BloomDownScaleMode(){return e.BloomDownScaleMode},BloomEffect:_a,BoolUpdateFlag:uO,BoxColliderShape:hH,BoxShape:fe,Buffer:dD,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:dJ,get BufferUsage(){return e.BufferUsage},BufferUtil:dI,Burst:_9,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},get CameraType(){return e.CameraType},Canvas:h4,CapsuleColliderShape:hK,CharacterController:hF,CircleShape:ft,ClearableObjectPool:h1,CloneManager:u_,get Collider(){return e.Collider},ColliderShape:hG,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:_q,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:uB,get ConeEmitType(){return e.ConeEmitType},ConeShape:fr,ContentRestorer:dM,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:fh,get CullMode(){return e.CullMode},CurveKey:_1,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:u0,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:_e,get Downsampling(){return e.Downsampling},DynamicCollider:hL,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:_Z,Engine:h3,EngineObject:uf,Entity:ho,EventDispatcher:uS,FixedJoint:hV,get FogMode(){return e.FogMode},Font:dP,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:_K,GradientColorKey:_j,HemisphereShape:fn,HingeJoint:hN,HitResult:hB,IndexBufferBinding:dK,get IndexFormat(){return e.IndexFormat},InputManager:hq,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:hz,JointMotor:hU,Keyframe:_N,get Keys(){return e.Keys},get Layer(){return e.Layer},LayerPathMask:_k,Light:h7,Loader:__,Logger:uP,get MSAASamples(){return e.MSAASamples},MainModule:_J,Material:dV,Mesh:dQ,MeshRenderer:d$,get MeshTopology(){return e.MeshTopology},ModelMesh:d1,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:dz,PBRMaterial:dU,PBRSpecularMaterial:dG,ParticleCompositeCurve:_Q,ParticleCompositeGradient:_X,ParticleCurve:_0,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:_8,ParticleGradient:_W,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_5,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:_H,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleShapeType(){return e.ParticleShapeType},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:hD,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:hP,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:hj,get Platform(){return e.Platform},PointLight:_t,Pointer:hA,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:dq,PrimitiveMesh:hn,Probe:fl,RasterState:u1,ReferResource:up,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderQueue:dp,get RenderQueueType(){return e.RenderQueueType},RenderState:u3,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:da,RenderTargetBlendState:uJ,get Renderer(){return e.Renderer},get ReplacementFailureStrategy(){return e.ReplacementFailureStrategy},ResourceManager:hx,ReturnableObjectPool:hd,RotationOverLifetimeModule:_$,SafeLoopArray:hg,Scene:_s,SceneManager:hv,Script:_l,get SetDataOptions(){return e.SetDataOptions},Shader:u4,ShaderData:u9,ShaderFactory:uW,ShaderLib:uH,ShaderMacro:uz,ShaderMacroCollection:uU,ShaderPass:uQ,get ShaderPlatformTarget(){return e.ShaderPlatformTarget},ShaderProperty:uF,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:uj,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:_2,Skin:hs,SkinnedMeshRenderer:hl,Sky:h8,SkyBoxMaterial:_U,SkyProceduralMaterial:_G,SphereColliderShape:hW,SphereShape:fa,SpotLight:_r,SpringJoint:hk,Sprite:uT,SpriteAtlas:um,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:dA,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:dn,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:_D,StaticCollider:hI,get StencilOperation(){return e.StencilOperation},StencilState:u2,SubMesh:dY,SubPrimitive:dX,SubShader:uZ,get SunMode(){return e.SunMode},SystemInfo:hE,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:dL,TextUtils:dE,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:u5,Texture2D:di,Texture2DArray:ds,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:dl,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:_3,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:uL,TonemappingEffect:_i,get TonemappingMode(){return e.TonemappingMode},TrailMaterial:fi,TrailRenderer:fs,Transform:uV,UnlitMaterial:dH,Utils:ug,VelocityOverLifetimeModule:_4,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:dZ,VertexElement:dO,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},XRManager:h2,_PostProcessManager:_o,assignmentClone:uu,deepClone:uh,dependentComponents:uI,ignoreClone:uc,request:_d,resourceLoader:hb,shallowClone:ud});function ff(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 fp(e,t,r){return t&&ff(e.prototype,t),r&&ff(e,r),e}function fm(e,t){return(fm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fg(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&&fm(e,t)}function fv(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oV=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oV.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oV[oV.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oV[oV.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oV[oV.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oV[oV.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oV[oV.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oV[oV.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oV[oV.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oV[oV.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oV[oV.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oV[oV.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oV[oV.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oV[oV.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oV[oV.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oV[oV.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oV[oV.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oV[oV.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oV[oV.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oV[oV.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oV[oV.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oV[oV.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oV[oV.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oV[oV.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oV[oV.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oV[oV.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oV[oV.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oV[oV.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oV[oV.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oV[oV.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oV[oV.R11_EAC=37488]="R11_EAC",oV[oV.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oV[oV.RG11_EAC=37490]="RG11_EAC",oV[oV.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oV[oV.RGB8_ETC2=37492]="RGB8_ETC2",oV[oV.SRGB8_ETC2=37493]="SRGB8_ETC2",oV[oV.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oV[oV.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oV[oV.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oV[oV.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oV[oV.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oV[oV.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oV[oV.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oV[oV.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oV[oV.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oV[oV.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oV[oV.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oV[oV.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oV[oV.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oV[oV.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oV[oV.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oV[oV.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var fy=(fg(oN=function(e){(t=h4.call(this)||this)._scale=new c5;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},h4),(ok=oN.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!fv(t,OffscreenCanvas)){var r=t.clientWidth*e,n=t.clientHeight*e;this.width=r,this.height=n}},ok.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},ok._onWidthChanged=function(e){this._webCanvas.width=e},ok._onHeightChange=function(e){this._webCanvas.height=e},fp(oN,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&fv(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&&fv(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),oN),fx=(fg(oz=function(){return h3.apply(this,arguments)},h3),oz.create=function(e){var t=e.canvas,r=new fy("string"==typeof t?document.getElementById(t):t),n=new fL(e.graphicDeviceOptions),a=new oz(r,n,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new _s(a,"DefaultScene")),a})},fp(oz,[{key:"canvas",get:function(){return this._canvas}}]),oz);function fb(){return(fb=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 fT=((oG=(oU=function(t,r,n,a,i){void 0===a&&(a=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,a),c=r===e.BufferBindFlag.VertexBuffer?o.ARRAY_BUFFER:o.ELEMENT_ARRAY_BUFFER;this._gl=o,this._glBuffer=s,this._glBufferUsage=l,this._glBindTarget=c,this._isWebGL2=t.isWebGL2,this.bind(),i?o.bufferData(c,i,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},oG.setData=function(t,r,n,a,i,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=r.BYTES_PER_ELEMENT||1,u=i?c*i:r.byteLength;if(0!==a||u<r.byteLength){var d=void 0!==r.byteOffset;if(this._isWebGL2&&d)s.bufferSubData(l,n,r,a,u/c);else{var h=new Uint8Array(d?r.buffer:r,a*c,u);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},oG.getData=function(e,t,r,n){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},oG.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},oG._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}},oU),fC=((oW=(oH=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oW.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,a=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR,o=e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,s=e.GLCompressedTextureInternalFormat.R11_EAC,l=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC,c=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,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>=a&&t<=i?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=u?this.canIUse(e.GLCapabilityType.pvrtc):t>=d&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oW._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),a=e.GLCapabilityType.shaderVertexID,i=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,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,b=e.GLCapabilityType.pvrtc_webkit,T=e.GLCapabilityType.s3tc,C=e.GLCapabilityType.s3tc_webkit,S=e.GLCapabilityType.bptc,A=e.GLCapabilityType.textureFloat,M=e.GLCapabilityType.textureHalfFloat,R=e.GLCapabilityType.textureFloatLinear,E=e.GLCapabilityType.textureHalfFloatLinear,w=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic,B=e.GLCapabilityType.fragDepth;t.set(a,r),t.set(i,r||!!n(i)),t.set(o,r||!!n(o)),t.set(s,r||!!n(s)),t.set(l,r||!!n(l)),t.set(c,r||!!n(c)),t.set(u,r||!!n(u)),t.set(d,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(A,r||!!n(A)),t.set(M,r||!!n(M)),t.set(R,!!n(R)),t.set(E,r||!!n(E)),t.set(P,r&&!!n(P)||!!n(w)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),t.set(B,r||!!n(B)),t.set(f,!!(n(f)||n(p))),t.set(m,!!(n(m)||n(g))),t.set(v,!!(n(v)||n(y))),t.set(x,!!(n(x)||n(b))),t.set(T,!!(n(T)||n(C))),t.set(S,!!n(S))},oW._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,a=null;if(a=r.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?n[i]=o.bind(a):n[i]=o}},oW._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,a=e.GLCapabilityType.drawBuffers,i=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat,c=e.GLCapabilityType.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(c,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(r,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var 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(a,fb({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(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},fp(oH,[{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}}]),oH),fS=((oj=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]},oj),fA=((oX=(oK=function(t,r){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=r,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._isSupportVAO=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var r=this._gl,n=this._primitive,a=this._isSupportVAO&&n.enableVAO;if(a){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);r.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)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 uP.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)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);a?r.bindVertexArray(null):this._disableAttrib()},oX.destroy=function(){this._isSupportVAO&&this._clearVAO()},oX._bindBufferAndAttrib=function(e){var t,r,n=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=i[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 uP.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},oX._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},oX._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)},oX._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},oK),fM=((oY=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]},oY),fR=((oQ=(oq=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},oQ.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},oQ.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},oQ._bind=function(){this._rhi.bindTexture(this)},oQ._init=function(t){var r=this._gl,n=this._isWebGL2,a=this._formatDetail,i=a.internalFormat,o=a.baseFormat,s=a.dataType,l=this._texture,c=l.mipmapCount,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,i,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,i,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,i,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,i,v,y,0,o,s,null)}},oQ._getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,uP.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,r,n,a,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oQ._setWrapMode=function(t,r){var n=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===e.TextureWrapMode.Clamp||oq._isPowerOf2(s)&&oq._isPowerOf2(l)||(uP.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=e.TextureWrapMode.Clamp),t){case e.TextureWrapMode.Clamp:n.texParameteri(i,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(i,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(i,r,n.MIRRORED_REPEAT)}},oQ._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},oq._isPowerOf2=function(e){return(e&e-1)==0},oq._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.R11G11B10_UFloat:return{internalFormat:n?r.R11F_G11F_B10F:r.NONE,baseFormat:r.RGB,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:n?r.RGBA16F:r.RGBA,baseFormat:r.RGBA,dataType:r.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:n?r.RGBA32F:r.RGBA,baseFormat:r.RGBA,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32_UInt:return{internalFormat:n?r.RGBA32UI:r.NONE,baseFormat:r.RGBA_INTEGER,dataType:r.UNSIGNED_INT,isCompressed:!1};case e.TextureFormat.BC1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.BC3:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case e.TextureFormat.BC7:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case e.TextureFormat.ETC1_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,isCompressed:!0};case e.TextureFormat.ETC2_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC,isCompressed:!0};case e.TextureFormat.PVRTC_RGB2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGB4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.ASTC_4x4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,isCompressed:!0};case e.TextureFormat.ASTC_5x5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,isCompressed:!0};case e.TextureFormat.ASTC_6x6:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,isCompressed:!0};case e.TextureFormat.ASTC_8x8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,isCompressed:!0};case e.TextureFormat.ASTC_10x10:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,isCompressed:!0};case e.TextureFormat.ASTC_12x12:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,isCompressed:!0};case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:n?r.DEPTH_COMPONENT16:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oq._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oq._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.R11G11B10_UFloat:case e.TextureFormat.R32G32B32A32_UInt:case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},oq._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);break;case e.TextureFormat.R11G11B10_UFloat:n=r.isWebGL2}return n},oq._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return!1}return!0},fp(oq,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var r=this._gl,n=this._target,a=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.NEAREST_MIPMAP_NEAREST:r.NEAREST);break;case e.TextureFilterMode.Bilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_NEAREST:r.LINEAR);break;case e.TextureFilterMode.Trilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_LINEAR:r.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(t){this._bind();var r=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NEVER);break;case e.TextureDepthCompareFunction.Less:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LESS);break;case e.TextureDepthCompareFunction.Equal:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GEQUAL);break;case e.TextureDepthCompareFunction.Always:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.ALWAYS)}}}]),oq),fE=((oJ=(oZ=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,a=r._depth,i=r.width,o=r.height,s=fv(a,u5),l=0,c=n.length;l<c;l++){var u=n[l]._format;if(!fR._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!fR._supportRenderBufferDepthFormat(a,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[a]+" in RenderTarget");if(n.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==i||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(a.width!==i||a.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return fv(e,dl)}))throw Error("MRT+Cube+[,MSAA] is not supported");var d=t.capability.maxAntiAliasing;r.antiAliasing>d&&(uP.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).activeRenderTarget=function(e,t){var r=this._gl,n=this._target;r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=n.getColorTexture(0);if(o){var s=fv(o,dl);(a||s&&i)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=n.depthTexture;if(l){var c=fv(l,dl);if(a||c){var u=l._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,u._formatDetail.attachment,c?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,u._glTexture,e)}}else if(a){var d=fR._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,d,n.width>>e,n.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&r.bindFramebuffer(r.FRAMEBUFFER,this._MSAAFrameBuffer)},oJ.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),r=this._target,n=r.colorTextureCount,a=r.width,i=r.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<n;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},oJ.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},oJ._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,a=r.colorTextureCount,i=r.width,o=r.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,fv(c,dl)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(fv(n,u5)&&!fv(n,dl)){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=fR._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},oJ._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,a=n._depth,i=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var 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!==a){var d=fv(a,u5)?a._platformTexture._formatDetail:fR._getRenderBufferDepthFormatDetail(a,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)},oJ._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.")},oZ),fw=(fg(o$=function(t,r){(n=fR.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,a=r.format,i=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!fR._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||fR._isPowerOf2(o)&&fR._isPowerOf2(s)||(uP.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=fR._getFormatDetail(a,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},fR),(o0=o$.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,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(a=a||_-r,i=i||f-n,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,r,n,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,a,i,u,d,e)},o0.setImageSource=function(t,r,n,a,i,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,+a),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,u,d,t):s.texSubImage2D(this._target,r,i||0,o||0,u,d,t)},o0.getPixelBuffer=function(e,t,r,n,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fR.prototype._getPixelBuffer.call(this,null,e,t,r,n,a,i)},o$),fP=(fg(o1=function(t,r){n=fR.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,a=r.format,i=r.width,o=r.height,s=r.length,l=r.mipmapCount;if(!n._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!fR._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return n._bind(),n._formatDetail=fR._getFormatDetail(a,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,i,o,s),n},fR),(o2=o1.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;i=i||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,r,n,a,e,i,o,s,d,t):c.texSubImage3D(l,r,n,a,e,i,o,s,h,_,t)},o2.setImageSource=function(e,t,r,n,a,i,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,+a),c.texSubImage3D(this._target,r,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},o2.getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,r,n,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},o1),fF=(fg(o3=function(t,r){(n=fR.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,a=r.format,i=r._mipmap,o=r.width,s=n._isWebGL2;if(!fR._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||fR._isPowerOf2(o)||(uP.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=fR._getFormatDetail(a,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},fR),(o4=o3.prototype).setPixelBuffer=function(e,t,r,n,a,i,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(i=i||f-n,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<r;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,u,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,d,h,t)},o4.setImageSource=function(e,t,r,n,a,i,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,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,i||0,o||0,c,u,t)},o4.getPixelBuffer=function(e,t,r,n,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fR.prototype._getPixelBuffer.call(this,e,t,r,n,a,i,o)},o3);e.WebGLMode=void 0,(o8=e.WebGLMode||(e.WebGLMode={}))[o8.Auto=0]="Auto",o8[o8.WebGL2=1]="WebGL2",o8[o8.WebGL1=2]="WebGL1";var fL=((o9=(o5=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new c9(null,null,null,null),this._lastScissor=new c9(null,null,null,null),this._lastClearColor=new c6(null,null,null,null),this._scissorEnable=!1;var r=fb({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(hE.platform===e.Platform.IPhone||hE.platform===e.Platform.IPad){var n=hE.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var a=parseInt(n[1]),i=parseInt(n[2]);15===a&&i>=0&&i<=4&&(r._forceFlush=!0)}}this._options=r,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).init=function(e,t,r){var n,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((n=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&fv(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&fv(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},o9.createPlatformPrimitive=function(e){return new fA(this,e)},o9.createPlatformTexture2D=function(e){return new fw(this,e)},o9.createPlatformTexture2DArray=function(e){return new fP(this,e)},o9.createPlatformTextureCube=function(e){return new fF(this,e)},o9.createPlatformRenderTarget=function(e){return new fE(this,e)},o9.createPlatformBuffer=function(t,r,n,a){return void 0===n&&(n=e.BufferUsage.Static),new fT(this,t,r,n,a)},o9.requireExtension=function(e){return this._extensions.requireExtension(e)},o9.canIUse=function(e){return this.capability.canIUse(e)},o9.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},o9.viewport=function(e,t,r,n){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||r!==i.z||n!==i.w)&&(a.viewport(e,t,r,n),i.set(e,t,r,n))},o9.scissor=function(e,t,r,n){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||r!==i.z||n!==i.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,r,n)),i.set(e,t,r,n)}},o9.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},o9.clearRenderTarget=function(t,r,n){var a=this._gl,i=t._lastRenderState,o=i.blendState.targetBlendState,s=i.depthState,l=i.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=a.COLOR_BUFFER_BIT;var 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)&&(a.clearColor(d,h,_,f),u.set(d,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(a.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=a.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(a.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=a.STENCIL_BUFFER_BIT,255!==l.writeMask&&(a.stencilMask(255),l.writeMask=255)),a.clear(c)},o9.drawPrimitive=function(e,t,r){e?e.draw(r,t):uP.error("draw primitive failed.")},o9.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},o9.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},o9.activeRenderTarget=function(e,t,r,n,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(n,a),i=e.width>>n,o=e.height>>n}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,u=t.x*i,d=r?t.y*o:o-t.y*o-c;this.viewport(u,d,l,c),this.scissor(u,d,l,c)},o9.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},o9.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)},o9.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},o9.flush=function(){this._gl.flush()},o9.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},o9.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},o9.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)},o9._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new fM(e),this._extensions=new fS(this),this._capability=new fC(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},o9.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},o9._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},o9._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},o9._onWebGLContextRestored=function(e){this._onDeviceRestored()},fp(o5,[{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}}]),o5);function fB(){return(fB=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 fD(e,t){return(fD=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fI(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&&fD(e,t)}function fO(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function fV(e,t){var r,n,a,i,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}},l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i}function fN(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 fk(e,t,r){return t&&fN(e.prototype,t),r&&fN(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var fz=((o7=(o6=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},o7.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},o7.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},o7.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},o7.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},o7.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},o7.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},o7.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},o7.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},o7.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},o7.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,ug.decodeText(t)},o7.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},o7.nextImagesData=function(e){for(var t=Array(e),r=0;r<e;r++){var n=this._dataView.getUint32(this._position,this._littleEndian);t[r]=n,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},o7.skip=function(e){return this._position+=e,this},o7.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)},fk(o6,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),o6),fU={};function fG(e){return function(t){fU[e]=t}}var fH=((se=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint8(4),a=t.getUint16(5,!0),i=new Uint8Array(e,7,a),o=t.getUint16(7+a,!0),s=new Uint8Array(e,9+a,o),l=ug.decodeText(s),c=ug.decodeText(i),u=new se;return u.totalLength=r,u.name=l,u.type=c,u.version=n,u.headerLength=s.byteLength+i.byteLength+9,u},fk(se,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),se);function fW(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c9(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function fj(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cQ(e[3*n],e[3*n+1],e[3*n+2]);return r}function fK(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c5(e[2*n],e[2*n+1]);return r}function fX(e,t,r){return(fX=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&fD(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((st=function(){}).decode=function(e,t){return new Promise(function(r){var n=new d1(e),a=JSON.parse(t.nextStr());a.bounds&&n.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=fj(s,l);if(n.setPositions(c),a.normals){var u=fj(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);n.setNormals(u)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);n.setUVs(fK(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);n.setUVs(fK(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);n.setUVs(fK(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);n.setUVs(fK(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);n.setUVs(fK(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);n.setUVs(fK(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);n.setUVs(fK(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);n.setUVs(fK(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c6(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);n.setBoneWeights(fW(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);n.setBoneIndices(fW(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new dj(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,a=fj(r,n);e.deltaNormals&&fj(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&fW(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,a)}),n.addBlendShape(t)}),a.indices){var T=null;T=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),n.setIndices(T)}a.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},st),e.MeshDecoder=fO([fG("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((sr=function(){}).decode=function(e,t){return new Promise(function(r,n){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new di(e,d,h,u,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,r(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&r(m)};if(t(),i){var n=function(e){var r=new window.Blob([p[e]]),n=new Image;n.onload=function(){m.setImageSource(n,e),t()},n.src=URL.createObjectURL(r)};m.generateMipmaps();for(var a=1;a<f;a++)n(a)}},b.src=URL.createObjectURL(x)}})},sr),e.Texture2DDecoder=fO([fG("Texture2D")],e.Texture2DDecoder),e.ParserType=void 0,(sn=e.ParserType||(e.ParserType={}))[sn.Prefab=0]="Prefab",sn[sn.Scene=1]="Scene";var fY=((sa=function(e,t,r){void 0===t&&(t=1),this.engine=e,this.type=t,this.resource=r,this.entityMap=new Map,this.entityConfigMap=new Map,this.components=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=e.resourceManager}).prototype.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},sa),fq=((so=(si=function(e){this._context=e}).prototype).parseEntity=function(t){var r=this;return this._getEntityByConfig(t).then(function(n){n.isActive=null==(a=t.isActive)||a;var a,i,o=t.position,s=t.rotation,l=t.scale;return o&&n.transform.position.copyFrom(o),s&&n.transform.rotation.copyFrom(s),l&&n.transform.scale.copyFrom(l),n.layer=null!=(i=t.layer)?i:n.layer,r._context.type===e.ParserType.Prefab&&n._markAsTemplate(r._context.resource),n})},so.parseClassObject=function(e){var t,r=this,n=__.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return fX(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},so.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var a=t.methods[n],i=0,o=a.length;i<o;i++)r.push(this.parseMethod(e,n,a[i]));if(t.props){var s=this,l=function(n){var a=t.props[n],i=s.parseBasicType(a,e[n]).then(function(t){return e[n]=t});r.push(i)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=si.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},so.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))})},so.parseBasicType=function(t,r){var n=this;if(Array.isArray(t))return Promise.all(t.map(function(e){return n.parseBasicType(e)}));if("object"==typeof t&&null!=t){if(si._isClass(t))return this.parseClassObject(t);if(si._isAssetRef(t)){var a=this._context;return a.resourceManager.getResourceByRef(t).then(function(t){return a.type===e.ParserType.Prefab&&a.resource._addDependenceAsset(t),t})}if(si._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));if(r){var i=this,o=function(e){if("methods"===e){var n=t[e];for(var a in n)for(var o=n[a],l=0,c=o.length;l<c;l++){var u=o[l];s.push(i.parseMethod(r,a,u))}}else s.push(i.parseBasicType(t[e],r[e]).then(function(t){return r[e]=t}))},s=[];for(var l in t)o(l);return Promise.all(s).then(function(){return r})}}return Promise.resolve(t)},so._getEntityByConfig=function(t){var r=this,n=t.assetRefId,a=this._context.engine;return n?a.resourceManager.getResourceByRef({refId:n,key:t.key,isClone:t.isClone}).then(function(i){var o=a.resourceManager._objectPool[n];return r._context.type===e.ParserType.Prefab&&r._context.resource._addDependenceAsset(o),i.name=t.name,i}):Promise.resolve(new ho(a,t.name))},si.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},si._isClass=function(e){return void 0!=e.class},si._isAssetRef=function(e){return void 0!=e.refId},si._isEntityRef=function(e){return void 0!=e.entityId},si);function fQ(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function fZ(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 fJ(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 fZ(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 fZ(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.")}fq.customParseComponentHandles=new Map,e.InterpolableValueType=void 0,(ss=e.InterpolableValueType||(e.InterpolableValueType={}))[ss.Float=0]="Float",ss[ss.FloatArray=1]="FloatArray",ss[ss.Vector2=2]="Vector2",ss[ss.Vector3=3]="Vector3",ss[ss.Vector4=4]="Vector4",ss[ss.Quaternion=5]="Quaternion",ss[ss.Color=6]="Color",ss[ss.Array=7]="Array",ss[ss.Boolean=8]="Boolean",ss[ss.Rect=9]="Rect",ss[ss.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((sl=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),a=new _C(n),i=r.nextUint16(),o=0;o<i;++o){var s=new _T;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,a.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var u=r.nextStr(),d=r.nextStr(),h=__.getClass(d),_=r.nextStr(),f=r.nextStr(),p=void 0,m=r.nextUint8(),g=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(p=new e.AnimationFloatCurve).interpolation=m;for(var v=0;v<g;++v){var y=new _N;y.time=r.nextFloat32(),y.value=r.nextFloat32(),y.inTangent=r.nextFloat32(),y.outTangent=r.nextFloat32(),p.addKey(y)}break;case"AnimationArrayCurve":(p=new e.AnimationArrayCurve).interpolation=m;for(var x=0;x<g;++x){var b=new _N;b.time=r.nextFloat32();var T=r.nextUint16();b.value=Array.from(r.nextFloat32Array(T)),b.inTangent=Array.from(r.nextFloat32Array(T)),b.outTangent=Array.from(r.nextFloat32Array(T)),p.addKey(b)}break;case"AnimationFloatArrayCurve":(p=new e.AnimationFloatArrayCurve).interpolation=m;for(var C=0;C<g;++C){var S=new _N;S.time=r.nextFloat32();var A=r.nextUint16();S.value=r.nextFloat32Array(A),S.inTangent=Array.from(r.nextFloat32Array(A)),S.outTangent=Array.from(r.nextFloat32Array(A)),p.addKey(S)}break;case"AnimationVector2Curve":(p=new e.AnimationVector2Curve).interpolation=m;for(var M=0;M<g;++M){var R=new _N;R.time=r.nextFloat32(),R.value=new c5(r.nextFloat32(),r.nextFloat32()),R.inTangent=new c5(r.nextFloat32(),r.nextFloat32()),R.outTangent=new c5(r.nextFloat32(),r.nextFloat32()),p.addKey(R)}break;case"AnimationVector3Curve":(p=new e.AnimationVector3Curve).interpolation=m;for(var E=0;E<g;++E){var w=new _N;w.time=r.nextFloat32(),w.value=new cQ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cQ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cQ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(w)}break;case"AnimationVector4Curve":(p=new e.AnimationVector4Curve).interpolation=m;var P=new _N;P.time=r.nextFloat32(),P.value=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(P);break;case"AnimationColorCurve":(p=new e.AnimationColorCurve).interpolation=m;for(var F=0;F<g;++F){var L=new _N;L.time=r.nextFloat32(),L.value=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(L)}break;case"AnimationQuaternionCurve":(p=new e.AnimationQuaternionCurve).interpolation=m;for(var B=0;B<g;++B){var D=new _N;D.time=r.nextFloat32(),D.value=new c3(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.inTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.outTangent=new c9(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(D)}break;case"AnimationRefCurve":(p=new e.AnimationRefCurve).interpolation=m;for(var I=0;I<g;++I){var O=new _N;O.time=r.nextFloat32();var V=r.nextStr();V?O.value=JSON.parse(V):O.value=null,p.addKey(O)}break;case"AnimationBoolCurve":(p=new e.AnimationBoolCurve).interpolation=m;for(var N=0;N<g;++N){var k=new _N;k.time=r.nextFloat32(),k.value=1===r.nextUint8(),p.addKey(k)}break;case"AnimationStringCurve":(p=new e.AnimationStringCurve).interpolation=m;for(var z=0;z<g;++z){var U=new _N;U.time=r.nextFloat32(),U.value=r.nextStr(),p.addKey(U)}}a.addCurveBinding(u,h,_,f,p)}t(a)})},sl),e.AnimationClipDecoder=fO([fG("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(sc=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",sc.Custom="Custom";var f$=(fI(su=function(e,t){var r;return(r=up.call(this,e)||this).url=t,r._dependenceAssets=new Set,r},up),(sd=su.prototype).instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},sd._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},sd._onDestroy=function(){var e=this;up.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(t){t._disassociationSuperResource(e)})},su),f0=((s_=(sh=function(e,t){var r=this;this.data=e,this.context=t,this._prefabContextMap=new WeakMap,this._prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,t){r._reject=t,r._resolve=e}),this._reflectionParser=new fq(t)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},s_._parseEntities=function(){var e=this,t=this.data.entities,r=this.context.entityConfigMap,n=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var n,i=null!=(n=t.strippedId)?n:t.id;return t.id=i,r.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var r=0,a=e.length;r<a;r++)n.set(t[r].id,e[r]);return e})},s_._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,r=this.context.components,n=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],u=c.refId?c.refId:c.class,d=s.addComponent(__.getClass(u));r.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);n.push(h)}return Promise.all(n)},s_._parsePrefabModification=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.target,n=t.props,a=t.methods,i=r.entityId,o=r.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(i),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:n,methods:a}):l?Promise.resolve(e._applyEntityData(l,n)):void 0})))}}(a);return Promise.all(n)},s_._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.entityId,n=e._prefabContextMap.get(c).entityMap.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},s_._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=r.get(s);n.concat.apply(n,[].concat(l.map(function(t){var r=t.componentId,n=e._prefabContextMap.get(c).components.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},s_._organizeEntities=function(){for(var e,t=this.context,r=t.rootIds,n=t.strippedIds,a=r.concat(n),i=fJ(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<r.length;s++)this._handleRootEntity(r[s])},s_._getEntityByConfig=function(e,t){var r=this;return(e.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return r._applyEntityData(t,e)})},s_._parseEntity=function(e,t){var r=new ho(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(r)},s_._parsePrefab=function(t,r){var n=this,a=t.assetRefId;return r.resourceManager.getResourceByRef({refId:a}).then(function(a){var i=fQ(a,f$)?a.instantiate():a.instantiateSceneRoot(),o=new fY(r,e.ParserType.Prefab,null);t.parent||n.context.rootIds.push(t.id),n._generateInstanceContext(i,o,""),n._prefabContextMap.set(i,o);var s=n._prefabPromiseMap.get(t.id);if(s)for(var l=0,c=s.length;l<c;l++)s[l].resolve(o);return i})},s_._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(r,n){var a,i=null!=(a=t._prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:r,reject:n}),t._prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var r=e.prefabSource.entityId;return t.entityMap.get(r)})},s_._parseChildren=function(e){var t=this.context,r=t.entityConfigMap,n=t.entityMap,a=r.get(e).children;if(a&&a.length>0)for(var i=n.get(e),o=0;o<a.length;o++){var s=a[o],l=n.get(s);i.addChild(l),this._parseChildren(s)}},s_._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(r=t.isActive)?r:e.isActive,e.name=null!=(n=t.name)?n:e.name;var r,n,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},s_._generateInstanceContext=function(e,t,r){var n=t.entityMap,a=t.components,i={},o={};n.set(r,e),e._components.forEach(function(t){var n=__.getClassName(t.constructor);i[n]||(i[n]=e.getComponents(t.constructor,[]),o[n]=0),a.set(r+":"+n+"/"+o[n]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],u=r?r+"/"+s:""+s;this._generateInstanceContext(c,t,u)}},sh),f1=(fI(sf=function(e,t,r){var n;return(n=f0.call(this,e,t)||this).scene=r,n},f0),(sp=sf.prototype)._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},sp._clearAndResolve=function(){return this.context.clear(),this.scene},sf.parse=function(t,r){var n=new _s(t),a=new fY(t,e.ParserType.Scene,n),i=new sf(r,a,n);return i.start(),i.promise.then(function(){return n})},sf);function f2(e,t){var r=fH.decode(e),n=new fz(new Uint8Array(e),r.headerLength,r.dataLength);return fU[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(fI(sm=function(){return __.apply(this,arguments)},__),sm.prototype.load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"arraybuffer"})).then(function(e){f2(e,t.engine).then(function(e){n(e)})}).catch(a)})},sm),e.MeshLoader=fO([hb("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(fI(sg=function(){return __.apply(this,arguments)},__),sg.prototype.load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"arraybuffer"})).then(function(e){f2(e,t.engine).then(function(e){n(e)})}).catch(a)})},sg),e.EditorTextureLoader=fO([hb("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var f3=(fI(sv=function(){return __.apply(this,arguments)},__),(sy=sv.prototype).load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"arraybuffer"})).then(function(e){return f2(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return r._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){n(e)})}).catch(a)}).catch(a)})},sy._parseKeyframeValue=function(e,t){var r=e.value;return"object"==typeof r&&(null==r?void 0:r.refId)?new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e.value)})}):Promise.resolve(e.value)},sv);f3=fO([hb(e.AssetType.AnimationClip,["ani"])],f3);var f4=(fI(sx=function(){return __.apply(this,arguments)},__),(sb=sx.prototype).load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"json"})).then(function(e){var a=new _B,i=e.layers,o=e.parameters,s=[];i.forEach(function(e,n){var i=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new _V(i);if(u.blendingMode=o,u.weight=l,c){var d=c.states,h=c.transitions,_=c.entryTransitions,f=c.anyTransitions,p=u.stateMachine,m={},g={};d.forEach(function(e,r){var a=e.id,i=e.name,o=e.speed,l=e.wrapMode,c=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,d=e.clip,h=e.scripts,_=p.addState(i);_.speed=o,_.wrapMode=l,_.clipStartTime=c,_.clipEndTime=u,h.forEach(function(e){_.addStateMachineScript(__.getClass(e))}),m[a]=_,d&&s.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),h.forEach(function(e){var t=r._createTransition(e,m[e.destinationStateId]);g[e.id]=t}),d.forEach(function(e){var t=e.id;e.transitions.forEach(function(e){var r=g[e];r&&m[t].addTransition(r)})}),_.forEach(function(e){p.addEntryStateTransition(r._createTransition(e,m[e.destinationStateId]))}),f.forEach(function(e){p.addAnyStateTransition(r._createTransition(e,m[e.destinationStateId]))})}a.addLayer(u)}),o.forEach(function(e){var t=new _L;t.name=e.name,t.value=e.value,a.addParameter(t)}),Promise.all(s).then(function(e){e.forEach(function(e){var t=e.layerIndex,r=e.stateIndex,n=e.clip;a.layers[t].stateMachine.states[r].clip=n}),n(a)})}).catch(a)})},sb._createTransition=function(e,t){var r=new _R;return r.duration=e.duration,r.offset=e.offset,r.exitTime=e.exitTime,r.solo=e.solo,r.mute=e.mute,r._isExit=e.isExit,r.destinationState=t,e.conditions.forEach(function(e){r.addCondition(e.mode,e.parameterName,e.threshold)}),r},sx);f4=fO([hb(e.AssetType.AnimatorController,["json"],!1)],f4);var f8=(fI(sT=function(){return __.apply(this,arguments)},__),sT.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new hy(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,fB({},e,{type:"arraybuffer"}))},sT);f8=fO([hb(e.AssetType.Buffer,["bin","r3bin"],!1)],f8);var f5=(fI(sC=function(){return __.apply(this,arguments)},__),sC.prototype.load=function(t,r){var n=this;return new hy(function(a,i){n.request(t.url,fB({},t,{type:"arraybuffer"})).then(function(t){var n=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=r.engine,s=new dl(o,i);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var d=i>>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 h6(o),m=new ue;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,a(p)}).catch(function(e){i(e)})})},sC);function f9(e,t,r,n,a,i,o){try{var s=e[i](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,a)}function f6(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var i=e.apply(t,r);function o(e){f9(i,n,a,o,s,"next",e)}function s(e){f9(i,n,a,o,s,"throw",e)}o(void 0)})}}f5=fO([hb(e.AssetType.Env,["env"])],f5);var f7=(fI(sS=function(){return __.apply(this,arguments)},__),(sA=sS.prototype).load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?r._registerFont(i,o).then(function(){n(new dP(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):n(new dP(t.engine,i))}).catch(function(e){a(e)})})},sA._registerFont=function(e,t){return f6(function(){var r;return fV(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]}})})()},sS);f7=fO([hb(e.AssetType.Font,["font"],!1)],f7);var pe=(fI(sM=function(e,t){var r;return(r=up.call(this,e)||this).url=t,r},up),(sR=sM.prototype).instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},sR._onDestroy=function(){up.prototype._onDestroy.call(this);var e=this.textures,t=this.materials,r=this.meshes;if(e&&this._disassociationSuperResource(e),t&&this._disassociationSuperResource(t),r)for(var n=0,a=r.length;n<a;n++)this._disassociationSuperResource(r[n])},sR._disassociationSuperResource=function(e){for(var t=0,r=e.length;t<r;t++)e[t]._disassociationSuperResource(this)},fk(sM,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),sM);(sE=cB||(cB={}))[sE.BYTE=5120]="BYTE",sE[sE.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",sE[sE.SHORT=5122]="SHORT",sE[sE.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",sE[sE.UNSIGNED_INT=5125]="UNSIGNED_INT",sE[sE.FLOAT=5126]="FLOAT",e.AccessorType=void 0,(sw=e.AccessorType||(e.AccessorType={})).SCALAR="SCALAR",sw.VEC2="VEC2",sw.VEC3="VEC3",sw.VEC4="VEC4",sw.MAT2="MAT2",sw.MAT3="MAT3",sw.MAT4="MAT4",(sP=cD||(cD={})).TRANSLATION="translation",sP.ROTATION="rotation",sP.SCALE="scale",sP.WEIGHTS="weights",(sF=cI||(cI={})).Linear="LINEAR",sF.Step="STEP",sF.CubicSpine="CUBICSPLINE",(sL=cO||(cO={})).PERSPECTIVE="perspective",sL.ORTHOGRAPHIC="orthographic",(sB=cV||(cV={})).JPEG="image/jpeg",sB.PNG="image/png",(sD=cN||(cN={})).OPAQUE="OPAQUE",sD.MASK="MASK",sD.BLEND="BLEND",(sI=ck||(ck={}))[sI.NEAREST=9728]="NEAREST",sI[sI.LINEAR=9729]="LINEAR",(sO=cz||(cz={}))[sO.NEAREST=9728]="NEAREST",sO[sO.LINEAR=9729]="LINEAR",sO[sO.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sO[sO.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sO[sO.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sO[sO.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sV=cU||(cU={}))[sV.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sV[sV.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sV[sV.REPEAT=10497]="REPEAT";var pt=((sk=(sN=function(e,t,r){var n=this;this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,r){var a,i=(a=n._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=r,n._setTaskDetailProgress(e,t,r)},this.contentRestorer=new pm(e)}).prototype).get=function(e,t){var r=this,n=sN._parsers[e];if(!n)return Promise.resolve(null);var a=this._resourceCache,i=void 0===t?""+e:e+":"+t,o=a.get(i);if(o)return o;var s=pn[e],l=!!pa[e];if(s){var c=this.glTF[s];c&&(void 0===t||c[t])?void 0===t?o=8===e?c.map(function(t,n){return r.get(e,n)}):Promise.all(c.map(function(t,n){return r.get(e,n)})):(o=n.parse(this,t),l&&this._handleSubAsset(o,e,t)):o=Promise.resolve(null)}else o=n.parse(this,t),l&&this._handleSubAsset(o,e,t);return a.set(i,o),o},sk.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,r=t.animatorController;return r&&(t._defaultSceneRoot.addComponent(_F).animatorController=r),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},sk._addTaskCompletePromise=function(e){var t=this,r=this._progress.taskComplete;r.total+=1,e.then(function(){t._setTaskCompleteProgress(++r.loaded,r.total)})},sk._handleSubAsset=function(e,t,r){var n,a=this,i=pa[t];if(8===t)((n=this.glTFResource)[i]||(n[i]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==r?a.glTFResource[i]=e:((n=a.glTFResource)[i]||(n[i]=[]))[r]=e,7===t)for(var n,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+r+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===r?"":"["+r+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===r&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},sN.addParser=function(e,t){this._parsers[e]=t},sN);pt._parsers={};var pr=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(sz=e.GLTFParserType||(e.GLTFParserType={}))[sz.Schema=0]="Schema",sz[sz.Validator=1]="Validator",sz[sz.Scene=2]="Scene",sz[sz.Buffer=3]="Buffer",sz[sz.BufferView=4]="BufferView",sz[sz.Texture=5]="Texture",sz[sz.Material=6]="Material",sz[sz.Mesh=7]="Mesh",sz[sz.Entity=8]="Entity",sz[sz.Skin=9]="Skin",sz[sz.Animation=10]="Animation",sz[sz.AnimatorController=11]="AnimatorController";var pn=((cG={})[2]="scenes",cG[3]="buffers",cG[5]="textures",cG[6]="materials",cG[7]="meshes",cG[8]="nodes",cG[9]="skins",cG[10]="animations",cG[4]="bufferViews",cG),pa=((cH={})[2]="_sceneRoots",cH[5]="textures",cH[6]="materials",cH[7]="meshes",cH[8]="entities",cH[9]="skins",cH[10]="animations",cH[11]="animatorController",cH);function pi(e){return function(t){var r=new t;pt.addParser(e,r)}}var po=((sU=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new c5(e[n],e[n+1]);return r},sU.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new cQ(e[n],e[n+1],e[n+2]);return r},sU.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new c9(e[n],e[n+1],e[n+2],e[n+3]);return r},sU.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var a=0;a<r;a+=3)n[a/3]=new c6(e[a],e[a+1],e[a+2],1);else for(var i=0;i<r;i+=4)n[i/4]=new c6(e[i],e[i+1],e[i+2],e[i+3]);return n},sU.getAccessorTypeSize=function(t){switch(t){case e.AccessorType.SCALAR:return 1;case e.AccessorType.VEC2:return 2;case e.AccessorType.VEC3:return 3;case e.AccessorType.VEC4:case e.AccessorType.MAT2:return 4;case e.AccessorType.MAT3:return 9;case e.AccessorType.MAT4:return 16}},sU.getComponentType=function(e){switch(e){case cB.BYTE:return Int8Array;case cB.UNSIGNED_BYTE:return Uint8Array;case cB.SHORT:return Int16Array;case cB.UNSIGNED_SHORT:return Uint16Array;case cB.UNSIGNED_INT:return Uint32Array;case cB.FLOAT:return Float32Array}},sU.getNormalizedComponentScale=function(e){switch(e){case cB.BYTE:return 1/127;case cB.UNSIGNED_BYTE:return 1/255;case cB.SHORT:return 1/32767;case cB.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},sU.getAccessorBuffer=function(t,r,n){var a,i=n.componentType,o=sU.getComponentType(i),s=sU.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];a=t.get(e.GLTFParserType.BufferView,n.bufferView).then(function(e){var r,a,_,f=h.buffer,p=null!=(r=e.byteOffset)?r:0,m=null!=(a=n.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+i+":"+v+":"+u,x=t.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,T=u*(g/l),C=new o(e.buffer,b,T);x[y]=_=new pr(C,!0,g),_.restoreInfo=new pb(new pT(f,o,b,T))}}else{var S=p+m,A=u*s,M=new o(e.buffer,S,A);(_=new pr(M,!1,c)).restoreInfo=new pb(new pT(f,o,S,A))}return _})}else{var _=u*s,f=new o(_),p=new pr(f,!1,c);p.restoreInfo=new pb(new pT(void 0,o,void 0,_)),a=Promise.resolve(p)}return n.sparse?a.then(function(e){return sU.processingSparseData(t,n,e).then(function(){return e})}):a},sU.bufferToVector3Array=function(e,t,r,n,a){for(var i=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?sU.getNormalizedComponentScale(a):1,c=0;c<r;c++){var u=i+c*o;s[c]=new cQ(e[u]*l,e[u+1]*l,e[u+2]*l)}return s},sU.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},sU.processingSparseData=function(t,r,n){var a=n.restoreInfo,i=t.glTF.bufferViews,o=sU.getAccessorTypeSize(r.type),s=sU.getComponentType(r.componentType),l=n.data.slice(),c=r.sparse,u=c.count,d=c.indices,h=c.values,_=i[d.bufferView],f=i[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,i,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!=(i=h.byteOffset)?i:0)+(null!=(c=m.byteOffset)?c:0),x=m.byteLength;a.typeSize=o,a.sparseCount=u;var b=sU.getComponentType(d.componentType),T=v/b.BYTES_PER_ELEMENT,C=new b(p.buffer,g,T);a.sparseIndices=new pT(_.buffer,b,g,T);var S=x/s.BYTES_PER_ELEMENT,A=new s(m.buffer,y,S);a.sparseValues=new pT(f.buffer,s,y,S);for(var M=0;M<u;M++)for(var R=C[M],E=0;E<o;E++)l[R*o+E]=A[M*o+E];n.data=l})},sU.getIndexFormat=function(t){switch(t){case cB.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case cB.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case cB.UNSIGNED_INT:return e.IndexFormat.UInt32}},sU.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==cB.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==cB.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==cB.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==cB.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==cB.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},sU.loadImageBuffer=function(e,t){return new Promise(function(r,n){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){n(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){r(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},sU.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),a={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==a.magic)return{originBuffer:t};var i=n.getUint32(12,!0),o=n.getUint32(16,!0);if(o!==r.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(ug.decodeText(s)),c=[],u=20+i,d=e.contentRestorer.glbBufferSlices;u<a.length;){if(i=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+i);c.push(_),d.push(new c5(h,i)),u+=i+8}return{glTF:l,buffers:c}},sU.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,a=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==a&&(e.wrapModeV=a)},sU.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=cz.NEAREST_MIPMAP_NEAREST,n===ck.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=cz.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},sU);(sG=cW||(cW={}))[sG.linear=1]="linear",sG[sG.sRGB=2]="sRGB",(sH=cj||(cj={}))[sH.ETC1S=163]="ETC1S",sH[sH.UASTC=166]="UASTC",(sW=cK||(cK={}))[sW.None=0]="None",sW[sW.BasisLZ=1]="BasisLZ",sW[sW.Zstd=2]="Zstd",sW[sW.ZLib=3]="ZLib";var ps=((sj=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 fz(e,12);this.vkFormat=n.nextUint32(),this.typeSize=n.nextUint32(),this.pixelWidth=n.nextUint32(),this.pixelHeight=n.nextUint32(),this.pixelDepth=n.nextUint32(),this.layerCount=n.nextUint32(),this.faceCount=n.nextUint32();var a=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var i=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),u=n.nextUint64(),d=Array(a),h=24*a,_=new fz(e,n.offset,h);this.levels=d;for(var f=0;f<a;f++)d[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new fz(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new fz(e,s,l,!0);x.position<l;){var b=x.nextUint32(),T=x.scan(b),C=ug.decodeText(T),S=x.nextUint8Array(b-T.byteLength-1);this.keyValue[C]=C.match(/^ktx/i)?ug.decodeText(S).replace(/^(.*)\x00$/,"$1"):S;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var M=new fz(e,c,u,!0),R=M.nextUint16(),E=M.nextUint16(),w=M.nextUint32(),P=M.nextUint32(),F=M.nextUint32(),L=M.nextUint32(),B=Array(a),D=0;D<a;D++)B[D]={imageFlags:M.nextUint32(),rgbSliceByteOffset:M.nextUint32(),rgbSliceByteLength:M.nextUint32(),alphaSliceByteOffset:M.nextUint32(),alphaSliceByteLength:M.nextUint32()};var I=c+M.position,O=I+w,V=O+P,N=V+F,k=new Uint8Array(t,r+I,w),z=new Uint8Array(t,r+O,P),U=new Uint8Array(t,r+V,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:R,selectorCount:E,imageDescs:B,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},fk(sj,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sj);e.KTX2TargetFormat=void 0,(sK=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sK.ASTC=0]="ASTC",sK[sK.BC7=1]="BC7",sK[sK.BC1_BC3=2]="BC1_BC3",sK[sK.PVRTC=3]="PVRTC",sK[sK.ETC=4]="ETC",sK[sK.R8=5]="R8",sK[sK.R8G8=6]="R8G8",sK[sK.R8G8B8A8=7]="R8G8B8A8";var pl=((sY=(sX=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)},sY.postMessage=function(e){var t=this;return new Promise(function(r,n){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sY.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},sY._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})},sY._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sY._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sY._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},sX),pc=((sQ=(sq=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sQ.destroy=function(){this._transcodeWorkerPool.destroy()},sQ._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new pl(this.workerLimitCount,function(){return new Promise(function(r,n){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?n(e.data.error):r(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sq);function pu(){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=ph(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var pd=function(e){return sZ||(sZ=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})),sZ};function ph(e,t,r){var n,a,i,o,s=function(){l.close(),l.delete()};(i=n||(n={}))[i.ETC1=0]="ETC1",i[i.ETC2=1]="ETC2",i[i.BC1=2]="BC1",i[i.BC3=3]="BC3",i[i.BC4=4]="BC4",i[i.BC5=5]="BC5",i[i.BC7=7]="BC7",i[i.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",i[i.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",i[i.ASTC_4x4=10]="ASTC_4x4",i[i.RGBA8=13]="RGBA8",(o=a||(a={}))[o.ASTC=0]="ASTC",o[o.BC7=1]="BC7",o[o.BC1_BC3=2]="BC1_BC3",o[o.PVRTC=3]="PVRTC",o[o.ETC=4]="ETC",o[o.R8=5]="R8",o[o.RG8=6]="RG8",o[o.RGBA8=7]="RGBA8";var l=new r(new Uint8Array(e));if(!l.isValid())throw s(),Error("Invalid or unsupported .ktx2 file");if(!l.startTranscoding())throw s(),Error("KTX2 startTranscoding failed");for(var c=l.getWidth(),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 b=Array(d),T=void 0,C=void 0,S=0;S<d;S++){var A=l.getImageLevelInfo(x,S,v);g&&0===x&&(c!==A.width||u!==A.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=T=A.width)+", height: "+(u=C=A.height)+". You'd better use an image whose size if multiple of 4."):(T=A.origWidth,C=A.origHeight);var M=new Uint8Array(l.getImageTranscodedSizeInBytes(x,S,0,p));if(!l.transcodeImage(M,x,S,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");b[S]=M}y[x]={data:function(e){if(1===e.length)return e[0];for(var t=0,r=0;r<e.length;r++)t+=e[r].byteLength;for(var n=new Uint8Array(t),a=0,i=0;i<e.length;i++)n.set(e[i],a),a+=e[i].byteLength;return n}(b),width:T,height:C}}m[v]=y}return s(),{faces:m,width:c,height:u,hasAlpha:_,faceCount:f,format:p}}var p_=(fI(sJ=function(e){return pc.call(this,e)},pc),(s$=sJ.prototype)._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var r=t[0],n=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){pd(n).then(function(){e(null)})},a.onerror=function(){t()}});var a=pu.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+r+"\n "+ph.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},s$.transcode=function(e,t){return 0===this.workerLimitCount?pd().then(function(r){return ph(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},sJ);function pf(){var e,t,r,n=function(e,t,r,n){var a=(r+3>>2)*(n+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null},a=function(e,t,r){var a=e.length,i=Array(a),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<a;s++){for(var l=e[s].length,c=Array(l),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/a,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"}i[s]=c}return i})},i=((t=(e=function(){}).prototype).init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,r){if(void 0===r&&(r=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var n=e.instance.exports,a=t.byteLength,i=n.malloc(a);e.heap.set(t,i),r=r||Number(n.ZSTD_findDecompressedSize(i,a));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,i,a),l=e.heap.slice(o,o+s);return n.free(i),n.free(o),l},e);i.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){i.heap=new Uint8Array(i.instance.exports.memory.buffer)}}},i.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new i;self.onmessage=function(e){var t,n=e.data;switch(n.type){case"init":(t=n.transcoderWasm,r=WebAssembly.instantiate(t,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":r.then(function(e){a(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var pp=(fI(s0=function(e,t){var r;return(r=pc.call(this,e)||this).type=t,r},pc),(s1=s0.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(s0.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=pf.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},s1.transcode=function(e){for(var t=e.supercompressionScheme===cK.Zstd,r=e.levels.length,n=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(n)},o=i.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var 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(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},s0);pp.transcoderMap=((s2={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",s2),e.KTX2Loader=(fI(s3=function(){return __.apply(this,arguments)},__),(s4=s3.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()}},s4.load=function(t,r){var n=this;return new hy(function(a,i,o,s){n.request(t.url,{type:"arraybuffer"}).onProgress(o,s).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)})}).then(a).catch(i)})},s3.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},s3._parseBuffer=function(t,r,n){var a,i,o=new ps(t),s=null!=(a=null==n?void 0:n.priorityFormats)?a:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&pp.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var u=e.KTX2Loader._getBinomialLLCTranscoder();i=u.init().then(function(){return u.transcode(t,l)})}return i.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},s3._createTextureByBuffer=function(t,r,n,a){var i,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){i=new di(t,o,s,h,d);for(var _=0;_<u.length;_++){var f=u[_].data;i.setPixelBuffer(f,_)}}else{i=new dl(t,s,h,d);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<u.length;g++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return a&&(i.wrapModeU=a[0],i.wrapModeV=a[1],i.filterMode=a[2],i.anisoLevel=a[3]),i},s3._decideTargetFormat=function(t,r,n){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,n);return i!==e.KTX2TargetFormat.PVRTC||cq.isPowerOf2(r.pixelWidth)&&cq.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===i?(uP.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(uP.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},s3._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var a=r[n],i=this._supportedMap[a];if(i){for(var o=0;o<i.length;o++)if(t.canIUse(i[o]))return a}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return a;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return a}}return null},s3._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new p_(t)},s3._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new pp(t,e.KTX2TargetFormat.ASTC)},s3._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}},s3._isBinomialInit=!1,s3._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]},s3._supportedMap=((s8={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],s8[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],s8[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],s8[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],s8[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],s8),s3),e.KTX2Loader=fO([hb(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(s5=e.KTX2Transcoder||(e.KTX2Transcoder={}))[s5.BinomialLLC=0]="BinomialLLC",s5[s5.Khronos=1]="Khronos";var pm=(fI(s9=function(){var e;return e=dM.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},dM),(s6=s9.prototype).restoreContent=function(){var t=this;return new hy(function(r,n){Promise.all(t.bufferRequests.map(function(e){return _d(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}hy.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,i=a[n.buffer],o=new Uint8Array(i,null!=(r=n.byteOffset)?r:0,n.byteLength),s=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(o,s.engine).then(function(e){for(var t=e.result.faces[0],r=0;r<t.length;r++)s.setPixelBuffer(t[r].data,r)}):po.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=fJ(t.meshes);!(e=n()).done;){for(var i,o=e.value,s=o.mesh,l=fJ(o.vertexBuffers);!(i=l()).done;){var c=i.value,u=t._getBufferData(a,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(a,o.indexBuffer);s.setIndices(d)}for(var h,_=fJ(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=po.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=po.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=po.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},s6._getBufferData=function(e,t){var r,n=t.main;if(n){var a=e[n.bufferIndex];r=new n.TypedArray(a,n.byteOffset,n.length)}else r=new n.TypedArray(n.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)r[f*h+p]=d[_*h+p];return r},s9),pg=function(e,t){this.url=e,this.config=t},pv=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},py=function(){this.vertexBuffers=[],this.blendShapes=[]},px=function(e,t){this.buffer=e,this.data=t},pb=function(e,t,r,n,a){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=a},pT=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},pC=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},pS=function(e,t,r,n,a){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=a},pA=((le=(s7=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];throw"Not implemented."},le.additiveParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},s7);e.GLTFExtensionMode=void 0,(lt=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[lt.CreateAndParse=0]="CreateAndParse",lt[lt.AdditiveParse=1]="AdditiveParse";var pM=((lr=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],u=e[c];if(o=lr._createAndParse.apply(lr,[].concat(c,t,u,r,a)))return o}},lr.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];for(var s in e){var l=e[s];lr._additiveParse.apply(lr,[].concat(s,t,r,l,n,i))}},lr.hasExtensionParser=function(e){var t;return!!(null==(t=lr._extensionParsers[e])?void 0:t.length)},lr.getExtensionParser=function(e,t){var r=lr._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var a=n-1;a>=0;--a){var i=r[a];if(i._mode===t)return i}},lr._addExtensionParser=function(e,t){lr._extensionParsers[e]||(lr._extensionParsers[e]=[]),lr._extensionParsers[e].push(t)},lr._createAndParse=function(t,r,n,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=lr.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,a,o))},lr._additiveParse=function(t,r,n,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=lr.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,a,i,s))},lr);function pR(e,t){return function(r){var n=new r;n._mode=t,pM._addExtensionParser(e,n)}}function pE(){var e,t=function(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;++r){var n=e.charCodeAt(r);t[r]=n>96?n-97:n>64?n-39:n+4}for(var a=0,i=0;i<e.length;++i)t[a++]=t[i]<60?o[t[i]]:(t[i]-60)*64+t[++i];return t.buffer.slice(0,a)},r=function(t,r,n,a,i,o){var s=e.exports.sbrk,l=n+3&-4,c=s(l*a),u=s(i.length),d=new Uint8Array(e.exports.memory.buffer);d.set(i,u);var h=t(c,n,a,u,i.length);if(0==h&&o&&o(c,l,a),r.set(d.subarray(c,c+n*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)},n=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var r=e.data;t.pending-=r.count,t.requests[r.id][r.action](r.value),delete t.requests[r.id]},t},a=function(e){for(var r="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(t(s))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }',a=new Blob([r],{type:"text/javascript"}),i=URL.createObjectURL(a),o=0;o<e;++o)u[o]=n(i);URL.revokeObjectURL(i)},i=function(e,t,r,n,a){for(var i=u[0],o=1;o<u.length;++o)u[o].pending<i.pending&&(i=u[o]);return new Promise(function(o,s){var l=new Uint8Array(r),c=d++;i.pending+=e,i.requests[c]={resolve:o,reject:s},i.object.postMessage({id:c,count:e,size:t,source:l,mode:n,filter:a},[l.buffer])})};if(cX)return cX;var o=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),s=hE._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";cX=WebAssembly.instantiate(t(s)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:cX,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,a(this.workerCount)},decodeGltfBuffer:function(t,n,a,o,s){return(this.workerCount>0&&0===u.length&&this.useWorkers(),u.length>0)?i(t,n,a,c[o],l[s]):cX.then(function(){var i=new Uint8Array(t*n);return r(e.exports[c[o]],i,t,n,a,e.exports[l[s]]),i})},release:function(){for(var e=0;e<u.length;e++)u[e].object.terminate()}}});var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},c={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;return cX}pM._extensionParsers={},e.GLTFSchemaParser=(fI(ln=function(){return pM.apply(this,arguments)},pM),ln.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,a=r.bufferRequests,i={type:"arraybuffer"};return _d(n,i).onProgress(void 0,e._onTaskDetail).then(function(t){return a.push(new pg(n,i)),po.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(ug.decodeText(new Uint8Array(t.originBuffer))))})},ln),e.GLTFSchemaParser=fO([pi(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(fI(la=function(){return pM.apply(this,arguments)},pM),la.prototype.parse=function(t,r){var n=t.glTF.animations[r],a=n.name,i=void 0===a?"AnimationClip"+r:a;return Promise.resolve(pM.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new _C(i),n)).then(function(e){return pM.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},la._parseStandardProperty=function(t,r,n){for(var a=function(r,n){var a=u[r],i=s[a.input],o=s[a.output],c=Promise.all([po.getAccessorBuffer(t,l,i),po.getAccessorBuffer(t,l,o)]).then(function(t){var n,i,s=t[0].data,l=t[1].data;if(o.normalized){for(var c=po.getNormalizedComponentScale(o.componentType),u=new Float32Array(l.length),d=0,_=l.length;d<_;d++)u[d]=l[d]*c;l=u}var f=l.length/s.length;switch(null!=(n=a.interpolation)?n:cI.Linear){case cI.CubicSpine:i=e.InterpolationType.CubicSpine;break;case cI.Step:i=e.InterpolationType.Step;break;case cI.Linear:i=e.InterpolationType.Linear}s[s.length-1],h[r]={type:o.type,interpolation:i,input:s,output:l,outputSize:f}});f.push(c)},i=this,o=t.glTF,s=o.accessors,l=o.bufferViews,c=n.channels,u=n.samplers,d=u.length,h=Array(d),_=t.get(e.GLTFParserType.Entity),f=[],p=0;p<d;p++)a(p);return f.push(t.get(e.GLTFParserType.Scene)),Promise.all(f).then(function(){for(var e=0,n=c.length;e<n;e++){for(var a=c[e],s=a.target,l=_[s.node],u="",d=l;d.parent;)u=""===u?""+d.name:d.name+"/"+u,d=d.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(d)){var f=void 0,p=void 0;switch(s.path){case cD.TRANSLATION:f=uV,p="position";break;case cD.ROTATION:f=uV,p="rotationQuaternion";break;case cD.SCALE:f=uV,p="scale";break;case cD.WEIGHTS:f=hl,p="blendShapeWeights"}var m=i._addCurve(s.path,a,h);if(s.path===cD.WEIGHTS)for(var g=o.nodes[s.node].mesh,v=0,y=o.meshes[g].primitives.length;v<y;v++)r.addCurveBinding(u,f,v,p,m);else r.addCurveBinding(u,f,p,m)}}return r})},la._addCurve=function(t,r,n){var a=n[r.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case cD.TRANSLATION:case cD.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new _N;_.time=i[d],c===e.InterpolationType.CubicSpine?(_.inTangent=new cQ(o[u++],o[u++],o[u++]),_.value=new cQ(o[u++],o[u++],o[u++]),_.outTangent=new cQ(o[u++],o[u++],o[u++])):_.value=new cQ(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case cD.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new _N;y.time=i[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new c9(o[m++],o[m++],o[m++],o[m++]),y.value=new c3(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new c9(o[m++],o[m++],o[m++],o[m++])):y.value=new c3(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case cD.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,T=0,C=i.length;T<C;T++){var S=new _N;S.time=i[T],x.interpolation===e.InterpolationType.CubicSpine?(S.inTangent=Array.from(o.subarray(b,b+s)),b+=s,S.value=o.slice(b,b+s),b+=s,S.outTangent=Array.from(o.subarray(b,b+s))):S.value=o.slice(b,b+s),b+=s,x.addKey(S)}return x}},la),e.GLTFAnimationParser=fO([pi(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(fI(li=function(){return pM.apply(this,arguments)},pM),(lo=li.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},lo._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,a=r.url,i=n.bufferRequests,o={type:"arraybuffer"},s=ug.resolveAbsoluteUrl(a,t.uri);i.push(new pg(s,o));var l=_d(s,o).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(l),l},li),e.GLTFBufferParser=fO([pi(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(fI(ls=function(){return pM.apply(this,arguments)},pM),ls.prototype.parse=function(t,r){var n=t.glTFResource,a=t.glTF.nodes[r],i=n.engine,o=a.matrix,s=a.translation,l=a.rotation,c=a.scale,u=a.extensions,d=new ho(i,a.name||"_GLTF_ENTITY_"+r);d._markAsTemplate(n);var h=d.transform;if(o){var _=h.localMatrix;_.copyFromArray(o),h.localMatrix=_}else s&&h.setPosition(s[0],s[1],s[2]),l&&h.setRotationQuaternion(l[0],l[1],l[2],l[3]),c&&h.setScale(c[0],c[1],c[2]);var f=a.children;if(f)for(var p=0;p<f.length;p++){var m=f[p],g=t.get(e.GLTFParserType.Entity,m);d.addChild(g)}return pM.executeExtensionsAdditiveAndParse(u,t,d,a),d},ls),e.GLTFEntityParser=fO([pi(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(fI(ll=function(){return pM.apply(this,arguments)},pM),ll.prototype.parse=function(t,r){var n=t.glTF.materials[r],a=t.glTFResource,i=a.engine,o=pM.executeExtensionsCreateAndParse(n.extensions,t,n);return o||((o=new dU(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,o,n)),Promise.resolve(o).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(i)),pM.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r._associationSuperResource(a),r})},ll._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new dk(t))},ll._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&uP.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},ll._parseStandardProperty=function(t,r,n){var a=n.pbrMetallicRoughness,i=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,u=n.alphaCutoff,d=n.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(r.baseColor=new c6(c6.linearToGammaSpace(h[0]),c6.linearToGammaSpace(h[1]),c6.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,pM.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===dU&&(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===dU||r.constructor===dG){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new c6(c6.linearToGammaSpace(l[0]),c6.linearToGammaSpace(l[1]),c6.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;e.GLTFMaterialParser._checkOtherTextureTransform(i,"Normal"),t.get(e.GLTFParserType.Texture,g).then(function(e){r.normalTexture=e}),void 0!==v&&(r.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;e.GLTFMaterialParser._checkOtherTextureTransform(o,"Occlusion"),t.get(e.GLTFParserType.Texture,y).then(function(e){r.occlusionTexture=e}),void 0!==x&&(r.occlusionTextureIntensity=x),b===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:b>e.TextureCoordinate.UV1&&uP.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case cN.OPAQUE:r.isTransparent=!1;break;case cN.BLEND:r.isTransparent=!0;break;case cN.MASK:r.alphaCutoff=null!=u?u:.5}},ll),e.GLTFMaterialParser=fO([pi(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(fI(lc=function(){return pM.apply(this,arguments)},pM),lc.prototype.parse=function(t,r){for(var n=function(r,n){var c=a.primitives[r];l[r]=new Promise(function(n){var l=pM.executeExtensionsCreateAndParse(c.extensions,t,c,a);if(l)fQ(l,d1)?(l._associationSuperResource(o),n(l)):l.then(function(e){e._associationSuperResource(o),n(e)});else{var u=new d1(s,a.name||r+"");u._associationSuperResource(o);var d=new py;d.mesh=u,t.contentRestorer.meshes.push(d),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,u,d,a,c,i,t.params.keepMeshData).then(n)}})},a=t.glTF.meshes[r],i=t.glTF,o=t.glTFResource,s=o.engine,l=[],c=0,u=a.primitives.length;c<u;c++)n(c);return Promise.all(l)},lc._parseMeshFromGLTFPrimitive=function(t,r,n,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=po.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,c,u,d=po.getAccessorTypeSize(i.type),h=i.count,_=t.data,f=r.instanceId,v=t.vertexBindingInfos,y=i.normalized,x=po.getElementFormat(i.componentType,d,y);if(y&&(c=po.getNormalizedComponentScale(i.componentType)),t.interleaved){var b=i.byteOffset||0,T=t.stride;if(u=b%T,void 0===v[f]){o=new dO(a,u,x,g);var C=t.vertexBuffer;C||(C=new dD(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=C,n.vertexBuffers.push(new px(C,t.restoreInfo))),r.setVertexBufferBinding(C,T,g),v[f]=g++}else o=new dO(a,u,x,v[f])}else{u=0,o=new dO(a,u,x,g);var S=t.vertexBuffer;S||(S=new dD(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new px(S,t.restoreInfo))),r.setVertexBufferBinding(S,t.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=r.bounds,M=A.min,R=A.max;if(i.min&&i.max)M.copyFromArray(i.min),R.copyFromArray(i.max);else{var E=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 w=u/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;E.copyFromArray(_,L),cQ.min(M,E,M),cQ.max(R,E,R)}}y&&(M.scale(c),R.scale(c))}});v.push(c)},u=o.accessors,d=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=r.engine,m=[],g=0,v=[];for(var y in d)c(y);return Promise.all(v).then(function(){if(r.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=po.getAccessorBuffer(t,o.bufferViews,c).then(function(e){r.setIndices(e.data),r.addSubMesh(0,c.count,f),n.indexBuffer=e.restoreInfo});v.push(u)}else r.addSubMesh(0,l,f);return h&&v.push(e.GLTFMeshParser._createBlendShape(t,r,n,a,i,h)),Promise.all(v).then(function(){return r.uploadData(!s),r})})},lc._getBlendShapeData=function(e,t,r){return po.getAccessorBuffer(e,t.bufferViews,r).then(function(e){var t,n=e.data,a=e.interleaved?(null!=(t=r.byteOffset)?t:0)%e.stride:0,i=r.count,o=r.normalized,s=r.componentType;return{vertices:po.bufferToVector3Array(n,a,i,o,s),restoreInfo:new pS(e.restoreInfo,a,i,o,s)}})},lc._createBlendShape=function(e,t,r,n,a,i){for(var o=this,s=e.glTF,l=s.accessors,c=n.extras?n.extras.targetNames:null,u=[],d=i.length,h=Array(d),_=0;_<d;_++)(function(t){var r={};h[t]=r;var n=c?c[t]:"blendShape"+t,i=a.targets[t],d=i.NORMAL,_=i.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[d]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new dj(n);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),r.blendShape=o,r.restoreInfo=new pC(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))})(_);return Promise.all(u).then(function(){for(var e,n=fJ(h);!(e=n()).done;){var a=e.value;t.addBlendShape(a.blendShape),r.blendShapes.push(a.restoreInfo)}})},lc._tempVector3=new cQ,lc),e.GLTFMeshParser=fO([pi(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(fI(lu=function(){return pM.apply(this,arguments)},pM),(ld=lu.prototype).parse=function(t,r){var n,a=t.glTF,i=a.scene,o=t.glTFResource,s=a.scenes[r],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=t.get(e.GLTFParserType.Entity,u[0]);else{(n=new ho(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=t.get(e.GLTFParserType.Entity,u[d]);n.addChild(h)}}(void 0===i?0:i)===r&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(t,u[f]));return Promise.all(_).then(function(){return pM.executeExtensionsAdditiveAndParse(l,t,n,s),n})},ld._parseEntityComponent=function(t,r){var n,a=this,i=t.glTF,o=t.glTFResource,s=i.nodes[r],l=s.camera,c=s.mesh,u=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,i.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(a._parseEntityComponent(t,r[n]));return Promise.all(e)})},ld._createCamera=function(t,r,n){var a=r.orthographic,i=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===cO.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,u=a.zfar,d=a.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===cO.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},ld._createRenderer=function(t,r,n){for(var a,i=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,u=c.length,d=r.weights||l.weights,h=Array(u),_=0;_<u;_++)h[_]=t.get(e.GLTFParserType.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),Promise.all(h)]).then(function(r){for(var a=r[0],o=r[1],s=r[2],l=0;l<u;l++)!function(r){var l=s[r]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),u=c[r],h=a[r],_=void 0;if(o||d){var f=n.addComponent(hl);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),d&&(f.blendShapeWeights=new Float32Array(d)),_=f}else(_=n.addComponent(d$)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),pM.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},ld._computeLocalBounds=function(e,t,r,n,a){var i=r.indexOf(n);if(-1!==i)cJ.transform(t.bounds,a[i],e.localBounds);else{var o=new c4(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,a,n,o);0!==s?(c4.multiplyScalar(o,1/s,o),cJ.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},ld._computeApproximateBindMatrix=function(e,t,r,n){for(var a=0,i=r.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(c4.add(n,t[c],n),a++):a+=this._computeApproximateBindMatrix(e,t,l,n)}return a},lu),e.GLTFSceneParser=fO([pi(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(fI(lh=function(){return pM.apply(this,arguments)},pM),(l_=lh.prototype).parse=function(t,r){var n=this,a=t.glTF,i=a.skins[r],o=i.inverseBindMatrices,s=i.skeleton,l=i.joints,c=i.name,u=l.length,d=new hs(void 0===c?"SKIN_"+r:c);d.inverseBindMatrices.length=u;var h=Array(u),_=a.accessors[o];return Promise.resolve(po.getAccessorBuffer(t,a.bufferViews,_).then(function(r){for(var a=t.get(e.GLTFParserType.Entity),i=r.data,o=0;o<u;o++){var c=new c4;c.copyFromArray(i,16*o),d.inverseBindMatrices[o]=c;var _=a[l[o]];h[o]=_,d.joints[o]=_.name}if(d.bones=h,void 0!==s){var f=a[s];d.rootBone=f}else{var p=n._findSkeletonRootBone(l,a);if(p)d.rootBone=p;else throw"Failed to find skeleton root bone."}return d}))},l_._findSkeletonRootBone=function(e,t){for(var r,n={},a=fJ(e);!(r=a()).done;){for(var i=r.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;n[i]=o}for(var l=null,c=0;;c++){var 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}},lh),e.GLTFSkinParser=fO([pi(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(fI(lf=function(){return pM.apply(this,arguments)},pM),lf.prototype.parse=function(t,r){var n=t.glTF.textures[r],a=t.glTFResource,i=t.glTF,o=a.engine,s=a.url,l=n.sampler,c=n.source,u=n.name,d=n.extensions,h=i.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=pM.executeExtensionsCreateAndParse(d,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&po.getSamplerInfo(i.samplers[l]);if(_){var x=_.lastIndexOf("."),b=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:ug.resolveAbsoluteUrl(s,_),type:b,params:{mipmap:null==y?void 0:y.mipmap}}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name=u||m||e.name||"texture_"+r,v&&po.parseSampler(e,y),e}),t._addTaskCompletePromise(g)}else{var T=i.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[T.buffer],a=new Uint8Array(n,T.byteOffset,T.byteLength);return po.loadImageBuffer(a,p).then(function(e){var n=new di(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&&po.parseSampler(n,y);var a=new pv(n,T,p);return t.contentRestorer.bufferTextures.push(a),n})})}}return Promise.resolve(g).then(function(e){return pM.executeExtensionsAdditiveAndParse(d,t,e,n),e._associationSuperResource(a),e})},lf._wrapMap=((lp={})[cU.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,lp[cU.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,lp[cU.REPEAT]=e.TextureWrapMode.Repeat,lp),lf),e.GLTFTextureParser=fO([pi(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(fI(lm=function(){return pM.apply(this,arguments)},pM),lm.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,a=t.extensionsRequired,i=Number(r);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(n){uP.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];pM.hasExtensionParser(s)||uP.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){uP.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];pM.hasExtensionParser(c)||uP.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},lm),e.GLTFValidator=fO([pi(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(fI(lg=function(){return pM.apply(this,arguments)},pM),lg.prototype.parse=function(t,r){var n=t.glTF.bufferViews[r],a=n.extensions,i=n.byteOffset,o=void 0===i?0:i,s=n.byteLength,l=n.buffer;return a?pM.executeExtensionsCreateAndParse(a,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},lg),e.GLTFBufferViewParser=fO([pi(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=(fI(lv=function(){return pM.apply(this,arguments)},pM),(ly=lv.prototype).parse=function(t){var r=this;return t.needAnimatorController?t.get(e.GLTFParserType.Animation).then(function(e){return Promise.resolve(r._createAnimatorController(e))}):Promise.resolve(null)},ly._createAnimatorController=function(e){var t=new _B,r=new _V("layer"),n=new _O;if(t.addLayer(r),r.stateMachine=n,e)for(var a=0;a<e.length;a++){var i=e[a],o=i.name,s=n.makeUniqueStateName(o);s!==o&&console.warn("AnimatorState name is existed, name: "+o+" reset to "+s),n.addState(s).clip=i}return t},lv),e.GLTFAnimatorControllerParser=fO([pi(e.GLTFParserType.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=(fI(lx=function(){return __.apply(this,arguments)},__),(lb=lx.prototype).initialize=function(e,t){var r,n,a,i=null!=(a=null==(r=t.glTFLoader)?void 0:r.meshOpt)?a:null==(n=t.glTF)?void 0:n.meshOpt;return i?pE().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},lb.load=function(e,t){var r=e.url,n=e.params,a=new pe(t.engine,r),i=new pt(a,t,fB({keepMeshData:!1},n));return new hy(function(e,t,r,n){i._setTaskCompleteProgress=r,i._setTaskDetailProgress=n,i.parse().then(e).catch(t)})},lx.release=function(){cX&&pE().then(function(e){e.release()})},lx),e.GLTFLoader=fO([hb(e.AssetType.GLTF,["gltf","glb"])],e.GLTFLoader);var pw=(fI(lT=function(e,t,r){var n;return(n=f0.call(this,e,t)||this).prefabResource=r,n},f0),(lC=lT.prototype)._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},lC._clearAndResolve=function(){return this.context.clear(),this.prefabResource},lT.parse=function(t,r,n){var a=new f$(t,r),i=new fY(t,e.ParserType.Prefab,a),o=new lT(n,i,a);return o.start(),o.promise.then(function(){return a})},lT),pP=(fI(lS=function(){return __.apply(this,arguments)},__),lS.prototype.load=function(e,t){var r=this,n=t.engine;return new hy(function(t,a){r.request(e.url,fB({},e,{type:"json"})).then(function(r){pw.parse(n,e.url,r).then(t).catch(a)})})},lS);pP=fO([hb(e.AssetType.Prefab,["prefab"])],pP);var pF=Math.PI,pL=(fI(lA=function(){return __.apply(this,arguments)},__),lA.prototype.load=function(t,r){var n=this;return new hy(function(a,i){var o=r.engine;n.request(t.url,fB({},t,{type:"arraybuffer"})).then(function(t){for(var r=new Uint8Array(t),n=pL._parseHeader(r),i=n.width,s=n.height,l=n.dataPosition,c=pL._readPixels(r.subarray(l),i,s),u=s>>1,d=pL._convertToCubemap(c,i,s,u),h=new dl(o,u),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,d[_],0);h.generateMipmaps(),a(h)}).catch(i)})},lA._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)]},lA._createCubemapData=function(e,t,r,n,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,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,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,d.add(o),h.add(s)}c+=l}return i},lA._calcProjectionSpherical=function(e,t,r,n){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-pF;)a+=2*pF;for(;a>pF;)a-=2*pF;var o=a/pF,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(i/pF*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 c6(u,d,h,_)},lA._readStringLine=function(e,t){for(var r="",n="",a=t;a<e.length-t&&"\n"!=(n=String.fromCharCode(e[a]));a++)r+=n;return r},lA._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?i=!0:0==n.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=n.length+1,n=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(n);if(!s||s.length<3)throw"HDR Bad header format, no size";if(r=parseInt(s[2]),t=parseInt(s[1]),r<8||r>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:r,dataPosition:o+=n.length+1}},lA._readPixels=function(e,t,r){for(var n=e.byteLength,a=new Uint8Array(4*t*r),i=0,o=0,s=4*t,l=new Uint8Array(s),c=r;c>0&&o<n;){var u=e[o++],d=e[o++],h=e[o++],_=e[o++];if(2!=u||2!=d||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<n;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},lA._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},lA._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},lA._rightBottomBack=new cQ(1,-1,-1),lA._rightBottomFront=new cQ(1,-1,1),lA._rightUpBack=new cQ(1,1,-1),lA._rightUpFront=new cQ(1,1,1),lA._leftBottomBack=new cQ(-1,-1,-1),lA._leftBottomFront=new cQ(-1,-1,1),lA._leftUpBack=new cQ(-1,1,-1),lA._leftUpFront=new cQ(-1,1,1),lA._faceRight=[lA._rightBottomBack,lA._rightBottomFront,lA._rightUpBack,lA._rightUpFront],lA._faceLeft=[lA._leftBottomFront,lA._leftBottomBack,lA._leftUpFront,lA._leftUpBack],lA._faceUp=[lA._leftBottomFront,lA._rightBottomFront,lA._leftBottomBack,lA._rightBottomBack],lA._faceBottom=[lA._leftUpBack,lA._rightUpBack,lA._leftUpFront,lA._rightUpFront],lA._faceFront=[lA._leftBottomBack,lA._rightBottomBack,lA._leftUpBack,lA._rightUpBack],lA._faceBack=[lA._rightBottomFront,lA._leftBottomFront,lA._rightUpFront,lA._leftUpFront],lA._tempVector3=new cQ,lA._temp2Vector3=new cQ,lA._temp3Vector3=new cQ,lA._temp4Vector3=new cQ,lA._temp5Vector3=new cQ,lA);pL=fO([hb(e.AssetType.HDR,["hdr"])],pL);var pB=(fI(lM=function(){return __.apply(this,arguments)},__),lM.prototype.load=function(e){return this.request(e.url,fB({},e,{type:"json"}))},lM);pB=fO([hb(e.AssetType.JSON,["json"],!1)],pB);var pD={parse:function(t,r,n,a){if(void 0===a&&(a=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(t))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var i=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*i),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*i,s),glTypeSize:o.getUint32(2*i,s),glFormat:o.getUint32(3*i,s),glInternalFormat:o.getUint32(4*i,s),glBaseInternalFormat:o.getUint32(5*i,s),pixelWidth:o.getUint32(6*i,s),pixelHeight:o.getUint32(7*i,s),pixelDepth:o.getUint32(8*i,s),numberOfArrayElements:o.getUint32(9*i,s),numberOfFaces:o.getUint32(10*i,s),numberOfMipmapLevels:o.getUint32(11*i,s),bytesOfKeyValueData:o.getUint32(12*i,s),loadType:0};if(0!==l.glType)throw Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),0===l.pixelHeight||0!==l.pixelDepth)throw Error("only 2D textures currently supported");if(0!==l.numberOfArrayElements)throw Error("texture arrays not currently supported");if(l.numberOfFaces!==r)throw Error("number of faces expected"+r+", but found "+l.numberOfFaces);return n&&(l.mipmaps=function(e,t){for(var r=[],n=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,n,1)[0];n+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,n,l);r.push({data:u,width:a,height:i}),n+=l+(3-(l+3)%4)}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return r}(l,!0)),a&&(l.engineFormat=function(t){switch(t){case e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:return e.TextureFormat.BC1;case e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:return e.TextureFormat.BC3;case e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT:return e.TextureFormat.BC7;case e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL:return e.TextureFormat.ETC1_RGB;case e.GLCompressedTextureInternalFormat.RGB8_ETC2:return e.TextureFormat.ETC2_RGB;case e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return e.TextureFormat.ETC2_RGBA5;case e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC:return e.TextureFormat.ETC2_RGBA8;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGB2;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA2;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGB4;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR:return e.TextureFormat.ASTC_4x4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR:return e.TextureFormat.ASTC_5x5;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR:return e.TextureFormat.ASTC_6x6;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR:return e.TextureFormat.ASTC_8x8;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR:return e.TextureFormat.ASTC_10x10;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR:return e.TextureFormat.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+e.GLCompressedTextureInternalFormat[t])}}(l.glInternalFormat)),l}};function pI(e){var t=pD.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var pO=(fI(lR=function(){return __.apply(this,arguments)},__),lR.prototype.load=function(t,r){var n=this;return new hy(function(a,i){Promise.all(t.urls.map(function(e){return n.request(e,fB({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,a,i=[],o=0;o<e.length;o++){var s=pD.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(n=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:i,engineFormat:r,internalFormat:t,width:n,height:a}}(t),i=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new dl(r.engine,i,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)}a(c)}).catch(function(e){i(e)})})},lR);pO=fO([hb(e.AssetType.KTXCube,[])],pO);var pV=(fI(lE=function(){return __.apply(this,arguments)},__),lE.prototype.load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"arraybuffer"})).then(function(e){for(var r=pI(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new di(t.engine,a,i,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){a(e)})})},lE);pV=fO([hb(e.AssetType.KTX,["ktx"])],pV);var pN=(fI(lw=function(){return __.apply(this,arguments)},__),lw.prototype.load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,a=r.value;switch(n){case"Vector2":h.setVector2(e,new c5(a.x,a.y));break;case"Vector3":h.setVector3(e,new cQ(a.x,a.y,a.z));break;case"Vector4":h.setVector4(e,new c9(a.x,a.y,a.z,a.w));break;case"Color":h.setColor(e,new c6(a.r,a.g,a.b,a.a));break;case"Float":h.setFloat(e,a);break;case"Texture":d.push(t.getResourceByRef(a).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,a?1:0);break;case"Integer":h.setInt(e,Number(a))}},a=t.engine,i=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new dV(a,u4.find(o));u.name=i;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 a in n)e(t[r],a,n[a]);else t[r]=n}(u,"renderState",c),Promise.all(d).then(function(){n(u)})}).catch(a)})},lw);pN=fO([hb(e.AssetType.Material,["json"])],pN);var pk=(fI(lP=function(){return __.apply(this,arguments)},__),lP.prototype.load=function(e,t){var r=this;return new hy(function(n,a){r.request(e.url,fB({},e,{type:"arraybuffer"})).then(function(e){return f2(e,t.engine)}).then(function(e){n(e)}).catch(a)})},lP);pk=fO([hb(e.AssetType.Mesh,["mesh"])],pk);var pz=(fI(lF=function(){return __.apply(this,arguments)},__),lF.prototype.load=function(e,t){var r=t.engine;return this.request(e.url,fB({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return hn.createSubdivisionSurfaceSphere(r,e.sphereRadius,e.sphereStep);case"capsule":return hn.createCapsule(r,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return hn.createCone(r,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return hn.createCuboid(r,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return hn.createCylinder(r,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return hn.createPlane(r,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return hn.createTorus(r,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},lF);pz=fO([hb(e.AssetType.PrimitiveMesh,["mesh"],!1)],pz),(lL=cY||(cY={})).Sphere="sphere",lL.Cuboid="cuboid",lL.Plane="plane",lL.Cylinder="cylinder",lL.Torus="torus",lL.Cone="cone",lL.Capsule="capsule";var pU=(fI(lB=function(){return __.apply(this,arguments)},__),lB.prototype.load=function(t,r){var n=this,a=r.engine;return new hy(function(i,o){n.request(t.url,fB({},t,{type:"json"})).then(function(t){return a.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){a.sceneManager.activeScene=e,i()})}).catch(o)})},lB);pU=fO([hb(e.AssetType.Project,["proj"],!1)],pU);var pG=(fI(lD=function(){return __.apply(this,arguments)},__),(lI=lD.prototype).load=function(e,t){var r=this;return new hy(function(n,a){var i=e.url;r._registerFont(i,i).then(function(){n(new dP(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},lI._registerFont=function(e,t){return f6(function(){var r;return fV(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]}})})()},lD);pG=fO([hb(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],pG);var pH=(fI(lO=function(){var e;return e=__.apply(this,arguments)||this,e._tempRect=new c7,e._tempVec2=new c5,e._tempVec4=new c9,e},__),(lV=lO.prototype).load=function(t,r){var n=this;return new hy(function(a,i,o,s,l){var c=[];l(function(){for(var e=0;e<c.length;e++)c[e].cancel()});var u=n.request(t.url,fB({},t,{type:"json"}));c.push(u),u.then(function(o){var s=o.atlasItems,l=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 um(m);if(p<=0){a(g);return}c.length=0;for(var v=0;v<p;v++)!function(a){var o,p=s[a];if(p.img)c.push(r.load({url:ug.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:l}}).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(i));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);hy.all(c).then(function(){a(g)}).catch(i)}).catch(i)})},lV._makeSprite=function(e,t,r){var n=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new uT(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(i.x*d,i.y*h,i.w*d,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.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},lO);pH=fO([hb(e.AssetType.SpriteAtlas,["atlas"],!1)],pH);var pW=(fI(lN=function(){return __.apply(this,arguments)},__),(lk=lN.prototype).load=function(e,t){var r=this;return this.request(e.url,fB({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},lk._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},lk._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new uT(e.engine,r,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),n}):new hy(function(r){var n=new uT(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),r(n)})},lN);pW=fO([hb(e.AssetType.Sprite,["sprite"],!1)],pW);var pj=(fI(lz=function(e,t,r){var n;return(n=dM.call(this,e)||this).url=t,n.requestConfig=r,n},dM),lz.prototype.restoreContent=function(){var e=this;return _d(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},lz),pK=(fI(lU=function(){return __.apply(this,arguments)},__),lU.prototype.load=function(e,t){var r=this;return new hy(function(n,a,i,o){var s=e.url,l=fB({},e,{type:"image"});r.request(s,l).onProgress(i,o).then(function(r){var a,i=null!=(a=e.params)?a:{},o=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new di(t.engine,r.width,r.height,o,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!==s.indexOf("data:")){var p=s.lastIndexOf("/");f.name=s.substring(p+1)}t.addContentRestorer(new pj(f,s,l)),n(f)}).catch(function(e){a(e)})})},lU);pK=fO([hb(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],pK);var pX=(fI(lG=function(e,t,r){var n;return(n=dM.call(this,e)||this).urls=t,n.requestConfig=r,n},dM),lG.prototype.restoreContent=function(){var t=this;return new hy(function(r,n){Promise.all(t.urls.map(function(e){return _d(e,t.requestConfig)})).then(function(n){for(var a=t.resource,i=0;i<6;i++)a.setImageSource(e.TextureCubeFace.PositiveX+i,n[i],0);a.generateMipmaps(),r(a)}).catch(function(e){n(e)})})},lG),pY=(fI(lH=function(){return __.apply(this,arguments)},__),lH.prototype.load=function(t,r){var n=this;return new hy(function(a,i){var o=t.urls,s=fB({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],i=n.width;if(i!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new dl(r.engine,i),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new pX(l,o,s)),a(l)}).catch(function(e){i(e)})})},lH);pY=fO([hb(e.AssetType.TextureCube,[""])],pY);var pq=(fI(lW=function(){return __.apply(this,arguments)},__),lW.prototype.load=function(t,r){var n=this,a=r.engine;return new hy(function(i,o){n.request(t.url,fB({},t,{type:"json"})).then(function(t){return f1.parse(a,t).then(function(n){var a,o,s=[],l=t.scene.ambient;if(l){var c=l.specularMode===e.SpecularMode.Custom,u=l.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=l.diffuseIntensity,n.ambientLight.specularIntensity=l.specularIntensity,n.ambientLight.diffuseMode=l.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(l.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,c&&l.customAmbientLight&&s.push(r.getResourceByRef(l.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),l.ambientLight&&(!c||u)&&s.push(r.getResourceByRef(l.ambientLight).then(function(e){c||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),u&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var d=t.scene.background;switch(n.background.mode=d.mode,n.background.mode){case e.BackgroundMode.SolidColor:n.background.solidColor.copyFrom(d.color);break;case e.BackgroundMode.Sky:if(d.skyMesh&&d.skyMaterial){var h=r.getResourceByRef(d.skyMesh).then(function(e){n.background.sky.mesh=e}),_=r.getResourceByRef(d.skyMaterial).then(function(e){n.background.sky.material=e});s.push(h,_)}else uP.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(d.texture){var f,p=r.getResourceByRef(d.texture).then(function(e){n.background.texture=e});s.push(p),n.background.textureFillMode=null!=(f=d.textureFillMode)?f:n.background.textureFillMode}}var m=t.scene.shadow;m&&(void 0!=m.castShadows&&(n.castShadows=m.castShadows),void 0!=m.shadowResolution&&(n.shadowResolution=m.shadowResolution),void 0!=m.shadowDistance&&(n.shadowDistance=m.shadowDistance),void 0!=m.shadowCascades&&(n.shadowCascades=m.shadowCascades),n.shadowTwoCascadeSplits=null!=(a=m.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,m.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(m.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(o=m.shadowFadeBorder)?o:n.shadowFadeBorder);var g=t.scene.fog;g&&(void 0!=g.fogMode&&(n.fogMode=g.fogMode),void 0!=g.fogStart&&(n.fogStart=g.fogStart),void 0!=g.fogEnd&&(n.fogEnd=g.fogEnd),void 0!=g.fogDensity&&(n.fogDensity=g.fogDensity),void 0!=g.fogColor&&n.fogColor.copyFrom(g.fogColor));var v=t.scene.postProcess;if(v){var y=n._postProcessManager,x=y._bloomEffect,b=y._tonemappingEffect;if(y.isActive=v.isActive,x.enabled=v.bloom.enabled,x.downScale=v.bloom.downScale,x.threshold=v.bloom.threshold,x.scatter=v.bloom.scatter,x.intensity=v.bloom.intensity,x.tint.copyFrom(v.bloom.tint),x.dirtIntensity=v.bloom.dirtIntensity,b.enabled=v.tonemapping.enabled,b.mode=v.tonemapping.mode,v.bloom.dirtTexture){var T=r.getResourceByRef(v.bloom.dirtTexture).then(function(e){x.dirtTexture=e});s.push(T)}}return Promise.all(s).then(function(){i(n)})})}).catch(o)})},lW);pq=fO([hb(e.AssetType.Scene,["scene"],!0)],pq),fq.registerCustomParseComponent("TextRenderer",f6(function(e,t){var r;return fV(this,function(n){return(r=t.props).font||(e.font=dP.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var pQ=(fI(lj=function(){return pA.apply(this,arguments)},pA),lj.prototype.additiveParse=function(e,t,r){var n,a=e.glTF.extensions.KHR_lights_punctual.lights[r.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,u=e.glTFResource;if("directional"===s?n=t.addComponent(_e):"point"===s?n=t.addComponent(_t):"spot"===s&&(n=t.addComponent(_r)),i&&n.color.set(i[0],i[1],i[2],1),n.intensity=void 0===o?1:o,l&&!fQ(n,_e)&&(n.distance=l),c&&fQ(n,_r)){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)},lj);pQ=fO([pR("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],pQ);var pZ=(fI(lK=function(){return pA.apply(this,arguments)},pA),lK.prototype.additiveParse=function(t,r,n){var a=n.clearcoatFactor,i=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===a?0:a,r.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(e.GLTFParserType.Texture,i.index).then(function(e){r.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(e.GLTFParserType.Texture,l.index).then(function(e){r.clearCoatNormalTexture=e}))},lK);pZ=fO([pR("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],pZ);var pJ=(fI(lX=function(){return pA.apply(this,arguments)},pA),lX.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},lX);pJ=fO([pR("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],pJ);var p$=(fI(lY=function(){return pA.apply(this,arguments)},pA),lY.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dG(a),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,u=r.specularGlossinessTexture;return o&&(i.baseColor=new c6(c6.linearToGammaSpace(o[0]),c6.linearToGammaSpace(o[1]),c6.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,pM.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new c6(c6.linearToGammaSpace(l[0]),c6.linearToGammaSpace(l[1]),c6.linearToGammaSpace(l[2]))),void 0!==c&&(i.glossiness=c),u&&(e.GLTFMaterialParser._checkOtherTextureTransform(u,"Specular glossiness"),t.get(e.GLTFParserType.Texture,u.index).then(function(e){i.specularGlossinessTexture=e})),i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lY);p$=fO([pR("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],p$);var p0=(fI(lq=function(){return pA.apply(this,arguments)},pA),lq.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dH(a);return i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lq);p0=fO([pR("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],p0);var p1=(fI(lQ=function(){return pA.apply(this,arguments)},pA),lQ.prototype.additiveParse=function(t,r,n){var a=t.glTF.extensions.KHR_materials_variants.variants,i=t.glTFResource,o=n.mappings;i._extensionsData||(i._extensionsData={});var s=[];i.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var i=o[n],l=i.material,c=i.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return a[e].name})})})}(l)},lQ);p1=fO([pR("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],p1);var p2=(fI(lZ=function(){return pA.apply(this,arguments)},pA),lZ);p2=fO([pR("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],p2);var p3=(fI(lJ=function(){return pA.apply(this,arguments)},pA),lJ.prototype.createAndParse=function(t,r,n){return f6(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return fV(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=n.sampler,c=n.name,u=r.source,h=(d=a.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&po.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:ug.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&po.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,y.buffer).then(function(r){var n=new Uint8Array(r,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&po.parseSampler(e,m);var r=new pv(e,y,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},lJ);p3=fO([pR("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],p3);var p4=(fI(l$=function(){return pA.apply(this,arguments)},pA),l$.prototype.additiveParse=function(e,t,r){var n=r.offset,a=r.rotation,i=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&uP.warn("rotation in KHR_texture_transform is not supported now"),o&&uP.warn("texCoord in KHR_texture_transform is not supported now")},l$);p4=fO([pR("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],p4);var p8=(fI(l0=function(){return pA.apply(this,arguments)},pA),l0.prototype.createAndParse=function(e,t){var r=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(r),r},l0);p8=fO([pR("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],p8);var p5=(fI(l1=function(){return pA.apply(this,arguments)},pA),l1.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new _T;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},l1);p5=fO([pR("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],p5);var p9=(fI(l2=function(){return pA.apply(this,arguments)},pA),l2.prototype.createAndParse=function(t,r){return t.get(e.GLTFParserType.Buffer,r.buffer).then(function(e){return pE().then(function(t){return t.decodeGltfBuffer(r.count,r.byteStride,new Uint8Array(e,r.byteOffset,r.byteLength),r.mode,r.filter)})})},l2);p9=fO([pR("EXT_meshopt_compression",e.GLTFExtensionMode.CreateAndParse)],p9);var p6=(fI(l3=function(){return pA.apply(this,arguments)},pA),l3.prototype.additiveParse=function(t,r,n){var a=n.anisotropyStrength,i=n.anisotropyRotation,o=n.anisotropyTexture;r.anisotropy=void 0===a?0:a,r.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(e.GLTFParserType.Texture,o.index).then(function(e){r.anisotropyTexture=e}))},l3);p6=fO([pR("KHR_materials_anisotropy",e.GLTFExtensionMode.AdditiveParse)],p6);var p7="1.3.0-beta.6";for(var me in console.log("Galacean engine version: "+p7),f_)__.registerClass(me,f_[me]);e.AmbientLight=h6,e.AnimationClip=_C,e.AnimationClipCurveBinding=_b,e.AnimationCurve=_S,e.AnimationEvent=_T,e.Animator=_F,e.AnimatorCondition=_M,e.AnimatorController=_B,e.AnimatorControllerLayer=_V,e.AnimatorControllerParameter=_L,e.AnimatorLayerMask=_z,e.AnimatorState=_I,e.AnimatorStateMachine=_O,e.AnimatorStateTransition=_R,e.AssetPromise=hy,e.Background=h5,e.BaseMaterial=dN,e.BasicRenderPipeline=dT,e.BlendShape=dj,e.BlendShapeFrame=dW,e.BlendState=u$,e.BlinnPhongMaterial=dk,e.BloomEffect=_a,e.BoolUpdateFlag=uO,e.BoundingBox=cJ,e.BoundingFrustum=c1,e.BoundingSphere=cZ,e.BoxColliderShape=hH,e.BoxShape=fe,e.Buffer=dD,e.BufferInfo=pr,e.BufferMesh=dJ,e.BufferReader=fz,e.BufferUtil=dI,e.Burst=_9,e.Canvas=h4,e.CapsuleColliderShape=hK,e.CharacterController=hF,e.CircleShape=ft,e.ClearableObjectPool=h1,e.CloneManager=u_,e.ColliderShape=hG,e.CollisionUtil=c$,e.Color=c6,e.ColorOverLifetimeModule=_q,e.Component=uB,e.ConeShape=fr,e.ContentRestorer=dM,e.CubeProbe=fh,e.CurveKey=_1,e.DepthState=u0,e.DirectLight=_e,e.DynamicCollider=hL,e.EmissionModule=_Z,e.Engine=h3,e.EngineObject=uf,e.Entity=ho,e.EventDispatcher=uS,e.FileHeader=fH,e.FixedJoint=hV,e.Font=dP,e.GLTFExtensionParser=pA,e.GLTFParser=pM,e.GLTFParserContext=pt,e.GLTFResource=pe,e.GLTFUtils=po,e.GradientAlphaKey=_K,e.GradientColorKey=_j,e.HemisphereShape=fn,e.HingeJoint=hN,e.HitResult=hB,e.IndexBufferBinding=dK,e.InputManager=hq,e.JointLimits=hz,e.JointMotor=hU,e.Keyframe=_N,e.LayerPathMask=_k,e.Light=h7,e.Loader=__,e.Logger=uP,e.MainModule=_J,e.Material=dV,e.MathUtil=cq,e.Matrix=c4,e.Matrix3x3=c2,e.Mesh=dQ,e.MeshRenderer=d$,e.ModelMesh=d1,e.PBRBaseMaterial=dz,e.PBRMaterial=dU,e.PBRSpecularMaterial=dG,e.ParserContext=fY,e.ParticleCompositeCurve=_Q,e.ParticleCompositeGradient=_X,e.ParticleCurve=_0,e.ParticleGenerator=_8,e.ParticleGradient=_W,e.ParticleMaterial=_5,e.ParticleRenderer=_H,e.PhysicsMaterial=hD,e.PhysicsScene=hP,e.Plane=c0,e.PlaneColliderShape=hj,e.PointLight=_t,e.Pointer=hA,e.PrefabResource=f$,e.Primitive=dq,e.PrimitiveMesh=hn,e.Probe=fl,e.Quaternion=c3,e.Rand=ut,e.RasterState=u1,e.Ray=c8,e.Rect=c7,e.ReferResource=up,e.ReflectionParser=fq,e.RenderQueue=dp,e.RenderState=u3,e.RenderTarget=da,e.RenderTargetBlendState=uJ,e.ResourceManager=hx,e.ReturnableObjectPool=hd,e.RotationOverLifetimeModule=_$,e.SafeLoopArray=hg,e.Scene=_s,e.SceneManager=hv,e.SceneParser=f1,e.Script=_l,e.Shader=u4,e.ShaderData=u9,e.ShaderFactory=uW,e.ShaderLib=uH,e.ShaderMacro=uz,e.ShaderMacroCollection=uU,e.ShaderPass=uQ,e.ShaderProperty=uF,e.ShaderTagKey=uj,e.SizeOverLifetimeModule=_2,e.Skin=hs,e.SkinnedMeshRenderer=hl,e.Sky=h8,e.SkyBoxMaterial=_U,e.SkyProceduralMaterial=_G,e.SphereColliderShape=hW,e.SphereShape=fa,e.SphericalHarmonics3=ue,e.SpotLight=_r,e.SpringJoint=hk,e.Sprite=uT,e.SpriteAtlas=um,e.SpriteMask=dA,e.SpriteRenderer=dn,e.StateMachineScript=_D,e.StaticCollider=hI,e.StencilState=u2,e.SubMesh=dY,e.SubPrimitive=dX,e.SubShader=uZ,e.SystemInfo=hE,e.TextRenderer=dL,e.TextUtils=dE,e.Texture=u5,e.Texture2D=di,e.Texture2DArray=ds,e.TextureCube=dl,e.TextureSheetAnimationModule=_3,e.Time=uL,e.TonemappingEffect=_i,e.TrailMaterial=fi,e.TrailRenderer=fs,e.Transform=uV,e.UnlitMaterial=dH,e.Utils=ug,e.Vector2=c5,e.Vector3=cQ,e.Vector4=c9,e.VelocityOverLifetimeModule=_4,e.VertexBufferBinding=dZ,e.VertexElement=dO,e.WebCanvas=fy,e.WebGLEngine=fx,e.WebGLGraphicDevice=fL,e.XRManager=h2,e._PostProcessManager=_o,e.assignmentClone=uu,e.decode=f2,e.decoder=fG,e.decoderMap=fU,e.deepClone=uh,e.dependentComponents=uI,e.ignoreClone=uc,e.parseSingleKTX=pI,e.registerGLTFExtension=pR,e.registerGLTFParser=pi,e.request=_d,e.resourceLoader=hb,e.shallowClone=ud,e.version=p7,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,(l8=e.ContainmentType||(e.ContainmentType={}))[l8.Disjoint=0]="Disjoint",l8[l8.Contains=1]="Contains",l8[l8.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(l5=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[l5.Back=0]="Back",l5[l5.Front=1]="Front",l5[l5.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(l9=e.FrustumFace||(e.FrustumFace={}))[l9.Near=0]="Near",l9[l9.Far=1]="Far",l9[l9.Left=2]="Left",l9[l9.Right=3]="Right",l9[l9.Bottom=4]="Bottom",l9[l9.Top=5]="Top";var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,T,C,S,A,M,R,E,w,P,F,L,B,D,I,O,V,N,k,z,U,G,H,W,j,K,X,Y,q,Q,Z,J,$,ee,et,er,en,ea,ei,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eT,eC,eS,eA,eM,eR,eE,ew,eP,eF,eL,eB,eD,eI,eO,eV,eN,ek,ez,eU,eG,eH,eW,ej,eK,eX,eY,eq,eQ,eZ,eJ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tr,tn,ta,ti,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv,ty,tx,tb,tT,tC,tS,tA,tM,tR,tE,tw,tP,tF,tL,tB,tD,tI,tO,tV,tN,tk,tz,tU,tG,tH,tW,tj,tK,tX,tY,tq,tQ,tZ,tJ,t$,t0,t1,t2,t3,t4,t8,t5,t9,t6,t7,re,rt,rr,rn,ra,ri,ro,rs,rl,rc,ru,rd,rh,r_,rf,rp,rm,rg,rv,ry,rx,rb,rT,rC,rS,rA,rM,rR,rE,rw,rP,rF,rL,rB,rD,rI,rO,rV,rN,rk,rz,rU,rG,rH,rW,rj,rK,rX,rY,rq,rQ,rZ,rJ,r$,r0,r1,r2,r3,r4,r8,r5,r9,r6,r7,ne,nt,nr,nn,na,ni,no,ns,nl,nc,nu,nd,nh,n_,nf,np,nm,ng,nv,ny,nx,nb,nT,nC,nS,nA,nM,nR,nE,nw,nP,nF,nL,nB,nD,nI,nO,nV,nN,nk,nz,nU,nG,nH,nW,nj,nK,nX,nY,nq,nQ,nZ,nJ,n$,n0,n1,n2,n3,n4,n8,n5,n9,n6,n7,ae,at,ar,an,aa,ai,ao,as,al,ac,au,ad,ah,a_,af,ap,am,ag,av,ay,ax,ab,aT,aC,aS,aA,aM,aR,aE,aw,aP,aF,aL,aB,aD,aI,aO,aV,aN,ak,az,aU,aG,aH,aW,aj,aK,aX,aY,aq,aQ,aZ,aJ,a$,a0,a1,a2,a3,a4,a8,a5,a9,a6,a7,ie,it,ir,ia,ii,io,is,il,ic,iu,id,ih,i_,ip,im,ig,iv,iy,ix,ib,iT,iC,iS,iA,iM,iR,iE,iw,iP,iF,iL,iB,iD,iI,iO,iV,iN,ik,iz,iU,iG,iH,iW,ij,iK,iX,iY,iq,iQ,iZ,iJ,i$,i0,i1,i2,i3,i4,i8,i5,i9,i6,i7,oe,ot,or,on,oa,oi,oo,os,ol,oc,ou,od,oh,o_,of,op,om,og,ov,oy,ox,ob,oT,oC,oS,oA,oM,oR,oE,ow,oP,oF,oL,oB,oD,oI,oO,oV,oN,ok,oz,oU,oG,oH,oW,oj,oK,oX,oY,oq,oQ,oZ,oJ,o$,o0,o1,o2,o3,o4,o8,o5,o9,o6,o7,se,st,sr,sn,sa,si,so,ss,sl,sc,su,sd,sh,s_,sf,sp,sm,sg,sv,sy,sx,sb,sT,sC,sS,sA,sM,sR,sE,sw,sP,sF,sL,sB,sD,sI,sO,sV,sN,sk,sz,sU,sG,sH,sW,sj,sK,sX,sY,sq,sQ,sZ,sJ,s$,s0,s1,s2,s3,s4,s8,s5,s9,s6,s7,le,lt,lr,ln,la,li,lo,ls,ll,lc,lu,ld,lh,l_,lf,lp,lm,lg,lv,ly,lx,lb,lT,lC,lS,lA,lM,lR,lE,lw,lP,lF,lL,lB,lD,lI,lO,lV,lN,lk,lz,lU,lG,lH,lW,lj,lK,lX,lY,lq,lQ,lZ,lJ,l$,l0,l1,l2,l3,l4,l8,l5,l9,l6,l7,ce,ct,cr,cn,ca,ci,co,cs,cl,cc,cu,cd,ch,c_,cf,cp,cm,cg,cv,cy,cx,cb,cT,cC,cS,cA,cM,cR,cE,cw,cP,cF,cL,cB,cD,cI,cO,cV,cN,ck,cz,cU,cG,cH,cW,cj,cK,cX,cY,cq,cQ=((l6=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},l6.equals=function(e,t){return Math.abs(e-t)<=l6.zeroTolerance},l6.isPowerOf2=function(e){return(e&e-1)==0},l6.radianToDegree=function(e){return e*l6.radToDegreeFactor},l6.degreeToRadian=function(e){return e*l6.degreeToRadFactor},l6.lerp=function(e,t,r){return e+(t-e)*r},l6);cQ.zeroTolerance=1e-6,cQ.radToDegreeFactor=180/Math.PI,cQ.degreeToRadFactor=Math.PI/180;var cZ=((i=(a=function(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r}).prototype).set=function(e,t,r){return this._x=e,this._y=t,this._z=r,this._onValueChanged&&this._onValueChanged(),this},i.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},i.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},i.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},i.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},i.length=function(){var e=this._x,t=this._y,r=this._z;return Math.sqrt(e*e+t*t+r*r)},i.lengthSquared=function(){var e=this._x,t=this._y,r=this._z;return e*e+t*t+r*r},i.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},i.normalize=function(){return a.normalize(this,this),this},i.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},i.transformNormal=function(e){return a.transformNormal(this,e,this),this},i.transformToVec3=function(e){return a.transformToVec3(this,e,this),this},i.transformCoordinate=function(e){return a.transformCoordinate(this,e,this),this},i.transformByQuat=function(e){return a.transformByQuat(this,e,this),this},i.clone=function(){return new a(this._x,this._y,this._z)},i.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},i.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},i.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},i.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},a.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._onValueChanged&&r._onValueChanged()},a.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._onValueChanged&&r._onValueChanged()},a.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._onValueChanged&&r._onValueChanged()},a.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._onValueChanged&&r._onValueChanged()},a.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},a.cross=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;r.set(a*l-i*s,i*o-n*l,n*s-a*o)},a.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return Math.sqrt(r*r+n*n+a*a)},a.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z;return r*r+n*n+a*a},a.equals=function(e,t){return cQ.equals(e._x,t._x)&&cQ.equals(e._y,t._y)&&cQ.equals(e._z,t._z)},a.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._onValueChanged&&n._onValueChanged()},a.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._onValueChanged&&r._onValueChanged()},a.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},a.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=Math.sqrt(r*r+n*n+a*a);i>cQ.zeroTolerance&&(i=1/i,t.set(r*i,n*i,a*i))},a.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._onValueChanged&&r._onValueChanged()},a.transformNormal=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8],r._y=n*o[1]+a*o[5]+i*o[9],r._z=n*o[2]+a*o[6]+i*o[10],r._onValueChanged&&r._onValueChanged()},a.transformToVec3=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._onValueChanged&&r._onValueChanged()},a.transformToVec4=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements;r._x=n*o[0]+a*o[4]+i*o[8]+o[12],r._y=n*o[1]+a*o[5]+i*o[9]+o[13],r._z=n*o[2]+a*o[6]+i*o[10]+o[14],r._w=n*o[3]+a*o[7]+i*o[11]+o[15],r._onValueChanged&&r._onValueChanged()},a.transformCoordinate=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t.elements,s=n*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,r._x=(n*o[0]+a*o[4]+i*o[8]+o[12])*s,r._y=(n*o[1]+a*o[5]+i*o[9]+o[13])*s,r._z=(n*o[2]+a*o[6]+i*o[10]+o[14])*s,r._onValueChanged&&r._onValueChanged()},a.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*n+s*i-l*a,d=c*a+l*n-o*i,h=c*i+o*a-s*n,_=-o*n-s*a-l*i;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(a,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),a);cZ._zero=new cZ(0,0,0),cZ._one=new cZ(1,1,1);var cJ=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new cZ,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}).prototype).clone=function(){return new o(this.center,this.radius)},s.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},o.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=e.length,n=o._tempVec30;n.x=n.y=n.z=0;for(var a=0;a<r;++a)cZ.add(e[a],n,n);cZ.scale(n,1/r,t.center);for(var i=0,s=0;s<r;++s){var l=cZ.distanceSquared(n,e[s]);l>i&&(i=l)}t.radius=Math.sqrt(i)},o.fromBox=function(e,t){var r=t.center,n=e.min,a=e.max;r.x=(n.x+a.x)*.5,r.y=(n.y+a.y)*.5,r.z=(n.z+a.z)*.5,t.radius=cZ.distance(r,a)},o);cJ._tempVec30=new cZ;var c$=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new cZ,this.max=new cZ,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){var t=this.min,r=this.max,n=r._x+t._x,a=r._y+t._y,i=r._z+t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getExtent=function(e){var t=this.min,r=this.max,n=r._x-t._x,a=r._y-t._y,i=r._z-t._z;return e.set(isNaN(n)?0:.5*n,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,r=this.max,n=t.x,a=t.y,i=t.z,o=r.x,s=r.y,l=r.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new cZ;return e[0].set(n,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(n,a,l),e[4].set(n,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(n,a,i),e},c.transform=function(e){return l.transform(this,e,this),this},c.clone=function(){return new l(this.min,this.max)},c.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,r){cZ.subtract(e,t,r.min),cZ.add(e,t,r.max)},l.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var r=t.min,n=t.max;r.x=r.y=r.z=Number.MAX_VALUE,n.x=n.y=n.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];cZ.min(r,o,r),cZ.max(n,o,n)}},l.fromSphere=function(e,t){var r=e.center,n=e.radius,a=t.min,i=t.max;a.x=r.x-n,a.y=r.y-n,a.z=r.z-n,i.x=r.x+n,i.y=r.y+n,i.z=r.z+n},l.transform=function(e,t,r){var n=l._tempVec30,a=l._tempVec31;e.getCenter(n),e.getExtent(a),cZ.transformCoordinate(n,t,n);var i=a.x,o=a.y,s=a.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];a.set((0===u?0:Math.abs(i*u))+(0===_?0:Math.abs(o*_))+(0===m?0:Math.abs(s*m)),(0===d?0:Math.abs(i*d))+(0===f?0:Math.abs(o*f))+(0===g?0:Math.abs(s*g)),(0===h?0:Math.abs(i*h))+(0===p?0:Math.abs(o*p))+(0===v?0:Math.abs(s*v))),cZ.subtract(n,a,r.min),cZ.add(n,a,r.max)},l.merge=function(e,t,r){return cZ.min(e.min,t.min,r.min),cZ.max(e.max,t.max,r.max),r},l);c$._tempVec30=new cZ,c$._tempVec31=new cZ;var c0=((u=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var a=e.normal,i=t.normal,o=r.normal;cZ.cross(i,o,u._tempVec30),cZ.cross(o,a,u._tempVec31),cZ.cross(a,i,u._tempVec32);var s=-cZ.dot(a,u._tempVec30),l=-cZ.dot(i,u._tempVec31),c=-cZ.dot(o,u._tempVec32);cZ.scale(u._tempVec30,e.distance/s,u._tempVec30),cZ.scale(u._tempVec31,t.distance/l,u._tempVec31),cZ.scale(u._tempVec32,r.distance/c,u._tempVec32),cZ.add(u._tempVec30,u._tempVec31,n),cZ.add(n,u._tempVec32,n)},u.distancePlaneAndPoint=function(e,t){return cZ.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,a=r.max,i=t.normal,o=u._tempVec30,s=u._tempVec31;return(i.x>=0?(o.x=a.x,s.x=n.x):(o.x=n.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=n.y):(o.y=n.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=n.z):(o.z=n.z,s.z=a.z),0>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,a=r.radius,i=u.distancePlaneAndPoint(t,n);return i>a?e.PlaneIntersectionType.Front:i<-a?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var r=t.normal,n=cQ.zeroTolerance,a=cZ.dot(r,e.direction);if(Math.abs(a)<n)return -1;var i=cZ.dot(r,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-n)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var r=cQ.zeroTolerance,n=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,u=n.x,d=n.y,h=n.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<r){if(u<i.x||u>o.x)return -1}else{var p=1/s,m=(i.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<i.y||d>o.y)return -1}else{var y=1/l,x=(i.y-d)*y,b=(o.y-d)*y;if(x>b){var T=x;x=b,b=T}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<r){if(h<i.z||h>o.z)return -1}else{var C=1/c,S=(i.z-h)*C,A=(o.z-h)*C;if(S>A){var M=S;S=A,A=M}if((_=Math.max(S,_))>(f=Math.min(A,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var r=e.origin,n=e.direction,a=t.center,i=t.radius,o=u._tempVec30;cZ.subtract(r,a,o);var s=cZ.dot(o,n),l=cZ.dot(o,o)-i*i;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 cZ.distanceSquared(e.center,t.center)<r*r},u.intersectsSphereAndBox=function(e,t){var r=e.center,n=t.max,a=t.min,i=u._tempVec30;return i.set(Math.max(a.x,Math.min(r.x,n.x)),Math.max(a.y,Math.min(r.y,n.y)),Math.max(a.z,Math.min(r.z,n.z))),cZ.distanceSquared(r,i)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var r=t.min,n=t.max,a=u._tempVec30,i=0;i<6;++i){var o=e.getPlane(i),s=o.normal;if(a.set(s.x>=0?n.x:r.x,s.y>=0?n.y:r.y,s.z>=0?n.z:r.z),cZ.dot(s,a)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,r){var n=u.distancePlaneAndPoint(t.near,r);return Math.abs(n)<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.far,r))<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.left,r))<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.right,r))<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.top,r))<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.bottom,r))<cQ.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,r){for(var n=r.min,a=r.max,i=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?(i.x=a.x,o.x=n.x):(i.x=n.x,o.x=a.x),d.y>=0?(i.y=a.y,o.y=n.y):(i.y=n.y,o.y=a.y),d.z>=0?(i.z=a.z,o.z=n.z):(i.z=n.z,o.z=a.z),u.intersectsPlaneAndPoint(c,i)===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,a=0;a<6;++a){var i=t.getPlane(a),o=u.intersectsPlaneAndSphere(i,r);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){n=e.ContainmentType.Intersects;break}}return n},u);c0._tempVec30=new cZ,c0._tempVec31=new cZ,c0._tempVec32=new cZ;var c1=((h=(d=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new cZ,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();cZ.scale(r,n,t.normal),t.distance=e.distance*n},d.fromPoints=function(e,t,r,n){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,u=r.x-a,d=r.y-i,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*a+v*i+y*o)},d),c2=((f=(_=function(e){void 0===e&&(e=null),this.near=new c1,this.far=new c1,this.left=new c1,this.right=new c1,this.top=new c1,this.bottom=new c1,e&&this.calculateFromMatrix(e)}).prototype).getPlane=function(t){switch(t){case e.FrustumFace.Near:return this.near;case e.FrustumFace.Far:return this.far;case e.FrustumFace.Left:return this.left;case e.FrustumFace.Right:return this.right;case e.FrustumFace.Bottom:return this.bottom;case e.FrustumFace.Top:return this.top;default:return null}},f.calculateFromMatrix=function(e){var t=e.elements,r=t[0],n=t[1],a=t[2],i=t[3],o=t[4],s=t[5],l=t[6],c=t[7],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(i+a,c+l,_+h),this.near.distance=g+m,this.near.normalize(),this.far.normal.set(i-a,c-l,_-h),this.far.distance=g-m,this.far.normalize(),this.left.normal.set(i+r,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-r,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+n,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-n,c-s,_-d),this.top.distance=g-p,this.top.normalize()},f.intersectsBox=function(e){return c0.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return c0.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},_),c3=((m=(p=function(e,t,r,n,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,r,n,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=r,c[3]=n,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},m.add=function(e){return p.add(this,e,this),this},m.subtract=function(e){return p.subtract(this,e,this),this},m.multiply=function(e){return p.multiply(this,e,this),this},m.determinant=function(){var e=this.elements,t=e[0],r=e[1],n=e[2],a=e[3],i=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*i-o*l)+r*(-c*a+o*s)+n*(l*a-i*s)},m.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,this},m.invert=function(){return p.invert(this,this),this},m.rotate=function(e){return p.rotate(this,e,this),this},m.scale=function(e){return p.scale(this,e,this),this},m.translate=function(e){return p.translate(this,e,this),this},m.transpose=function(){return p.transpose(this,this),this},m.clone=function(){var e=this.elements;return new p(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},m.copyFrom=function(e){var t=this.elements,r=e.elements;return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],this},m.copyFromArray=function(e,t){void 0===t&&(t=0);for(var r=this.elements,n=0;n<12;n++)r[n]=e[n+t];return this},m.copyToArray=function(e,t){void 0===t&&(t=0);var r=this.elements;e[t]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8]},m.copyFromMatrix=function(e){var t=e.elements,r=this.elements;return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[4],r[4]=t[5],r[5]=t[6],r[6]=t[8],r[7]=t[9],r[8]=t[10],this},p.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8]},p.subtract=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]-a[0],i[1]=n[1]-a[1],i[2]=n[2]-a[2],i[3]=n[3]-a[3],i[4]=n[4]-a[4],i[5]=n[5]-a[5],i[6]=n[6]-a[6],i[7]=n[7]-a[7],i[8]=n[8]-a[8]},p.multiply=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements,o=n[0],s=n[1],l=n[2],c=n[3],u=n[4],d=n[5],h=n[6],_=n[7],f=n[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],T=a[7],C=a[8];i[0]=o*p+c*m+h*g,i[1]=s*p+u*m+_*g,i[2]=l*p+d*m+f*g,i[3]=o*v+c*y+h*x,i[4]=s*v+u*y+_*x,i[5]=l*v+d*y+f*x,i[6]=o*b+c*T+h*C,i[7]=s*b+u*T+_*C,i[8]=l*b+d*T+f*C},p.equals=function(e,t){var r=e.elements,n=t.elements;return cQ.equals(r[0],n[0])&&cQ.equals(r[1],n[1])&&cQ.equals(r[2],n[2])&&cQ.equals(r[3],n[3])&&cQ.equals(r[4],n[4])&&cQ.equals(r[5],n[5])&&cQ.equals(r[6],n[6])&&cQ.equals(r[7],n[7])&&cQ.equals(r[8],n[8])},p.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r},p.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,u=n*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[3]=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,a=r[0],i=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=a*_+i*f+o*p;m&&(m=1/m,n[0]=_*m,n[1]=(-h*i+o*d)*m,n[2]=(c*i-o*l)*m,n[3]=f*m,n[4]=(h*a-o*u)*m,n[5]=(-c*a+o*s)*m,n[6]=p*m,n[7]=(-d*a+i*u)*m,n[8]=(l*a-i*s)*m)},p.normalMatrix=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],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=a*c-i*l,b=a*u-o*l,T=a*d-s*l,C=i*u-o*c,S=i*d-s*c,A=o*d-s*u,M=h*g-_*m,R=h*v-f*m,E=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+T*w+C*E-S*R+A*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*w)*L,n[1]=(u*E-l*F-d*R)*L,n[2]=(l*P-c*E+d*M)*L,n[3]=(o*P-i*F-s*w)*L,n[4]=(a*F-o*E+s*R)*L,n[5]=(i*E-a*P-s*M)*L,n[6]=(g*A-v*S+y*C)*L,n[7]=(v*T-m*A-y*b)*L,n[8]=(m*S-g*T+y*x)*L},p.rotate=function(e,t,r){var n=e.elements,a=r.elements,i=Math.sin(t),o=Math.cos(t),s=n[0],l=n[1],c=n[2],u=n[3],d=n[4],h=n[5],_=n[6],f=n[7],p=n[8];a[0]=o*s+i*u,a[1]=o*l+i*d,a[2]=o*c+i*h,a[3]=o*u-i*s,a[4]=o*d-i*l,a[5]=o*h-i*c,a[6]=_,a[7]=f,a[8]=p},p.scale=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements;o[0]=n*i[0],o[1]=n*i[1],o[2]=n*i[2],o[3]=a*i[3],o[4]=a*i[4],o[5]=a*i[5],o[6]=i[6],o[7]=i[7],o[8]=i[8]},p.translate=function(e,t,r){var n=t._x,a=t._y,i=e.elements,o=r.elements,s=i[0],l=i[1],c=i[2],u=i[3],d=i[4],h=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=d,o[5]=h,o[6]=n*s+a*u+_,o[7]=n*l+a*d+f,o[8]=n*c+a*h+p},p.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[5];n[1]=r[3],n[2]=r[6],n[3]=a,n[5]=r[7],n[6]=i,n[7]=o}else n[0]=r[0],n[1]=r[3],n[2]=r[6],n[3]=r[1],n[4]=r[4],n[5]=r[7],n[6]=r[2],n[7]=r[5],n[8]=r[8]},p),c4=((v=(g=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},v.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},v.getAxisAngle=function(e){var t=this._x,r=this._y,n=this._z,a=t*t+r*r+n*n;if(a<cQ.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var i=1/a;return e._x=this._x*i,e._y=this._y*i,e._z=this._z*i,2*Math.acos(this._w)},v.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},v.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},v.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},v.normalize=function(){return g.normalize(this,this),this},v.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},v.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},v.rotateX=function(e){return g.rotateX(this,e,this),this},v.rotateY=function(e){return g.rotateY(this,e,this),this},v.rotateZ=function(e){return g.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return g.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return g.multiply(this,e,this),this},v.invert=function(){return g.invert(this,this),this},v.dot=function(e){return g.dot(this,e)},v.lerp=function(e,t){return g.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return g._tempQuat1.rotationAxisAngle(e,t),this.multiply(g._tempQuat1),this},v.clone=function(){return new g(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,r=this._y,n=this._z,a=this._w,i=t*t,o=r*r,s=n*n,l=a*a,c=i+o+s+l,u=2*(t*a-r*n);u>(1-cQ.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-cQ.zeroTolerance)*c?(e._x=Math.atan2(2*(a*r-t*n),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(n*t+r*a),s+l-o-i),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*r+n*a),o+l-s-i))},g.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},g.multiply=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;r._x=n*u+o*s+a*c-i*l,r._y=a*u+o*l+i*s-n*c,r._z=i*u+o*c+n*l-a*s,r._w=o*u-n*s-a*l-i*c,r._onValueChanged&&r._onValueChanged()},g.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},g.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},g.equals=function(e,t){return cQ.equals(e._x,t._x)&&cQ.equals(e._y,t._y)&&cQ.equals(e._z,t._z)&&cQ.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;cZ.normalize(e,n);var a=Math.sin(t*=.5);r._x=n._x*a,r._y=n._y*a,r._z=n._z*a,r._w=Math.cos(t),r._onValueChanged&&r._onValueChanged()},g.rotationEuler=function(e,t,r,n){g.rotationYawPitchRoll(t,e,r,n)},g.rotationYawPitchRoll=function(e,t,r,n){var a=.5*r,i=.5*t,o=.5*e,s=Math.sin(a),l=Math.cos(a),c=Math.sin(i),u=Math.cos(i),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,a=e.elements,i=a[0],o=a[1],s=a[2],l=a[3],c=a[4],u=a[5],d=a[6],h=a[7],_=a[8],f=i+c+_;f>0?(r=Math.sqrt(f+1),t._w=.5*r,r=.5/r,t._x=(u-h)*r,t._y=(d-s)*r,t._z=(o-l)*r):i>=c&&i>=_?(n=.5/(r=Math.sqrt(1+i-c-_)),t._x=.5*r,t._y=(o+l)*n,t._z=(s+d)*n,t._w=(u-h)*n):c>_?(n=.5/(r=Math.sqrt(1+c-i-_)),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+_-i-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,a=e._z,i=e._w,o=r*r+n*n+a*a+i*i;if(o>cQ.zeroTolerance){var s=1/o;t._x=-r*s,t._y=-n*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},g.lerp=function(e,t,r,n){var a=1-r;g.dot(e,t)>=0?(n._x=e._x*a+t._x*r,n._y=e._y*a+t._y*r,n._z=e._z*a+t._z*r,n._w=e._w*a+t._w*r):(n._x=e._x*a-t._x*r,n._y=e._y*a-t._y*r,n._z=e._z*a-t._z*r,n._w=e._w*a-t._w*r),n.normalize()},g.slerp=function(e,t,r,n){var a,i,o=g.dot(e,t);if(Math.abs(o)>1-cQ.zeroTolerance)i=1-r,a=r*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);i=Math.sin((1-r)*s)*l,a=Math.sin(r*s)*l*Math.sign(o)}n.x=i*e.x+a*t.x,n.y=i*e.y+a*t.y,n.z=i*e.z+a*t.z,n.w=i*e.w+a*t.w,n._onValueChanged&&n._onValueChanged()},g.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cQ.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},g.rotationX=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=r,t._y=0,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationY=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=r,t._z=0,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotationZ=function(e,t){var r=Math.sin(e*=.5),n=Math.cos(e);t._x=0,t._y=0,t._z=r,t._w=n,t._onValueChanged&&t._onValueChanged()},g.rotateX=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+o*s,r._y=a*l+i*s,r._z=i*l-a*s,r._w=o*l-n*s,r._onValueChanged&&r._onValueChanged()},g.rotateY=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l-i*s,r._y=a*l+o*s,r._z=i*l+n*s,r._w=o*l-a*s,r._onValueChanged&&r._onValueChanged()},g.rotateZ=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);r._x=n*l+a*s,r._y=a*l-n*s,r._z=i*l+o*s,r._w=o*l-i*s,r._onValueChanged&&r._onValueChanged()},g.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},n(g,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<cQ.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);c4._tempVector3=new cZ,c4._tempQuat1=new c4;var c8=((x=(y=function(e,t,r,n,a,i,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===a&&(a=0),void 0===i&&(i=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===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]=a,m[5]=i,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,a,i,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]=a,m[5]=i,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],a=e[3],i=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*i)*(d*m-h*p)-(t*s-n*i)*(u*m-h*f)+(t*l-a*i)*(u*p-d*f)+(r*s-n*o)*(c*m-h*_)-(r*l-a*o)*(c*p-d*_)+(n*l-a*s)*(c*f-u*_)},x.decompose=function(e,t,r){var n=y._tempMat30,a=this.elements,i=n.elements,o=a[0],s=a[1],l=a[2],c=a[4],u=a[5],d=a[6],h=a[8],_=a[9],f=a[10];e.set(a[12],a[13],a[14]);var p=Math.sqrt(o*o+s*s+l*l),m=Math.sqrt(c*c+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)<cQ.zeroTolerance||Math.abs(m)<cQ.zeroTolerance||Math.abs(g)<cQ.zeroTolerance)return t.identity(),!1;var v=1/p,x=1/m,b=1/g;return i[0]=o*v,i[1]=s*v,i[2]=l*v,i[3]=c*x,i[4]=u*x,i[5]=d*x,i[6]=h*b,i[7]=_*b,i[8]=f*b,c4.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>cQ.zeroTolerance){var n=2*Math.sqrt(r+1);e._w=.25*n,e._x=(t[6]-t[9])/n,e._y=(t[8]-t[2])/n,e._z=(t[1]-t[4])/n}else if(t[0]>t[5]&&t[0]>t[10]){var a=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/a,e._x=.25*a,e._y=(t[1]+t[4])/a,e._z=(t[8]+t[2])/a}else if(t[5]>t[10]){var i=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/i,e._x=(t[1]+t[4])/i,e._y=.25*i,e._z=(t[6]+t[9])/i}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},x.getScaling=function(e){var t=this.elements,r=t[0],n=t[1],a=t[2],i=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(r*r+n*n+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+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,a=t.elements,i=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],b=n[15],T=a[0],C=a[1],S=a[2],A=a[3],M=a[4],R=a[5],E=a[6],w=a[7],P=a[8],F=a[9],L=a[10],B=a[11],D=a[12],I=a[13],O=a[14],V=a[15];i[0]=o*T+u*C+f*S+v*A,i[1]=s*T+d*C+p*S+y*A,i[2]=l*T+h*C+m*S+x*A,i[3]=c*T+_*C+g*S+b*A,i[4]=o*M+u*R+f*E+v*w,i[5]=s*M+d*R+p*E+y*w,i[6]=l*M+h*R+m*E+x*w,i[7]=c*M+_*R+g*E+b*w,i[8]=o*P+u*F+f*L+v*B,i[9]=s*P+d*F+p*L+y*B,i[10]=l*P+h*F+m*L+x*B,i[11]=c*P+_*F+g*L+b*B,i[12]=o*D+u*I+f*O+v*V,i[13]=s*D+d*I+p*O+y*V,i[14]=l*D+h*I+m*O+x*V,i[15]=c*D+_*I+g*O+b*V},y.equals=function(e,t){var r=e.elements,n=t.elements;return cQ.equals(r[0],n[0])&&cQ.equals(r[1],n[1])&&cQ.equals(r[2],n[2])&&cQ.equals(r[3],n[3])&&cQ.equals(r[4],n[4])&&cQ.equals(r[5],n[5])&&cQ.equals(r[6],n[6])&&cQ.equals(r[7],n[7])&&cQ.equals(r[8],n[8])&&cQ.equals(r[9],n[9])&&cQ.equals(r[10],n[10])&&cQ.equals(r[11],n[11])&&cQ.equals(r[12],n[12])&&cQ.equals(r[13],n[13])&&cQ.equals(r[14],n[14])&&cQ.equals(r[15],n[15])},y.lerp=function(e,t,r,n){var a=e.elements,i=t.elements,o=n.elements,s=1-r;o[0]=a[0]*s+i[0]*r,o[1]=a[1]*s+i[1]*r,o[2]=a[2]*s+i[2]*r,o[3]=a[3]*s+i[3]*r,o[4]=a[4]*s+i[4]*r,o[5]=a[5]*s+i[5]*r,o[6]=a[6]*s+i[6]*r,o[7]=a[7]*s+i[7]*r,o[8]=a[8]*s+i[8]*r,o[9]=a[9]*s+i[9]*r,o[10]=a[10]*s+i[10]*r,o[11]=a[11]*s+i[11]*r,o[12]=a[12]*s+i[12]*r,o[13]=a[13]*s+i[13]*r,o[14]=a[14]*s+i[14]*r,o[15]=a[15]*s+i[15]*r},y.add=function(e,t,r){var n=e.elements,a=t.elements,i=r.elements;i[0]=n[0]+a[0],i[1]=n[1]+a[1],i[2]=n[2]+a[2],i[3]=n[3]+a[3],i[4]=n[4]+a[4],i[5]=n[5]+a[5],i[6]=n[6]+a[6],i[7]=n[7]+a[7],i[8]=n[8]+a[8],i[9]=n[9]+a[9],i[10]=n[10]+a[10],i[11]=n[11]+a[11],i[12]=n[12]+a[12],i[13]=n[13]+a[13],i[14]=n[14]+a[14],i[15]=n[15]+a[15]},y.multiplyScalar=function(e,t,r){var n=e.elements,a=r.elements;a[0]=n[0]*t,a[1]=n[1]*t,a[2]=n[2]*t,a[3]=n[3]*t,a[4]=n[4]*t,a[5]=n[5]*t,a[6]=n[6]*t,a[7]=n[7]*t,a[8]=n[8]*t,a[9]=n[9]*t,a[10]=n[10]*t,a[11]=n[11]*t,a[12]=n[12]*t,a[13]=n[13]*t,a[14]=n[14]*t,a[15]=n[15]*t},y.rotationQuaternion=function(e,t){var r=t.elements,n=e._x,a=e._y,i=e._z,o=e._w,s=n+n,l=a+a,c=i+i,u=n*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;r[0]=1-h-p,r[1]=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,a,i,o=r.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<cQ.zeroTolerance||(s*=u=1/u,l*=u,c*=u,n=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*n,o[2]=c*s*i-l*n,o[3]=0,o[4]=s*l*i-c*n,o[5]=l*l*i+a,o[6]=c*l*i+s*n,o[7]=0,o[8]=s*c*i+l*n,o[9]=l*c*i-s*n,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},y.rotationTranslation=function(e,t,r){y.rotationQuaternion(e,r);var n=r.elements;n[12]=t._x,n[13]=t._y,n[14]=t._z},y.affineTransformation=function(e,t,r,n){var a=n.elements,i=t._x,o=t._y,s=t._z,l=t._w,c=i+i,u=o+o,d=s+s,h=i*c,_=i*u,f=i*d,p=o*u,m=o*d,g=s*d,v=l*c,y=l*u,x=l*d,b=e._x,T=e._y,C=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*T,a[5]=(1-(h+g))*T,a[6]=(m+v)*T,a[7]=0,a[8]=(f+y)*C,a[9]=(m-v)*C,a[10]=(1-(h+p))*C,a[11]=0,a[12]=r._x,a[13]=r._y,a[14]=r._z,a[15]=1},y.scaling=function(e,t){var r=t.elements;r[0]=e._x,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e._y,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e._z,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1},y.translation=function(e,t){var r=t.elements;r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e._x,r[13]=e._y,r[14]=e._z,r[15]=1},y.invert=function(e,t){var r=e.elements,n=t.elements,a=r[0],i=r[1],o=r[2],s=r[3],l=r[4],c=r[5],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=a*c-i*l,b=a*u-o*l,T=a*d-s*l,C=i*u-o*c,S=i*d-s*c,A=o*d-s*u,M=h*g-_*m,R=h*v-f*m,E=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+T*w+C*E-S*R+A*M;if(!L)return null;L=1/L,n[0]=(c*F-u*P+d*w)*L,n[1]=(o*P-i*F-s*w)*L,n[2]=(g*A-v*S+y*C)*L,n[3]=(f*S-_*A-p*C)*L,n[4]=(u*E-l*F-d*R)*L,n[5]=(a*F-o*E+s*R)*L,n[6]=(v*T-m*A-y*b)*L,n[7]=(h*A-f*T+p*b)*L,n[8]=(l*P-c*E+d*M)*L,n[9]=(i*E-a*P-s*M)*L,n[10]=(m*S-g*T+y*x)*L,n[11]=(_*T-h*S-p*x)*L,n[12]=(c*R-l*w-u*M)*L,n[13]=(a*w-i*R+o*M)*L,n[14]=(g*b-m*C-v*x)*L,n[15]=(h*C-_*b+f*x)*L},y.lookAt=function(e,t,r,n){var a=n.elements,i=y._tempVec30,o=y._tempVec31,s=y._tempVec32;cZ.subtract(e,t,s),s.normalize(),cZ.cross(r,s,i),i.normalize(),cZ.cross(s,i,o),a[0]=i._x,a[1]=o._x,a[2]=s._x,a[3]=0,a[4]=i._y,a[5]=o._y,a[6]=s._y,a[7]=0,a[8]=i._z,a[9]=o._z,a[10]=s._z,a[11]=0,a[12]=-cZ.dot(i,e),a[13]=-cZ.dot(o,e),a[14]=-cZ.dot(s,e),a[15]=1},y.ortho=function(e,t,r,n,a,i,o){var s=o.elements,l=1/(e-t),c=1/(r-n),u=1/(a-i);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(n+r)*c,s[14]=(i+a)*u,s[15]=1},y.perspective=function(e,t,r,n,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(r-n);i[0]=o/t,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(n+r)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*n*r*s,i[15]=0},y.rotateAxisAngle=function(e,t,r,n){var a,i,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<cQ.zeroTolerance)){var d=e.elements,h=n.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(r),o=1-(i=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],b=d[8],T=d[9],C=d[10],S=d[11],A=s*s*o+i,M=l*s*o+c*a,R=c*s*o-l*a,E=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,B=c*c*o+i;h[0]=_*A+g*M+b*R,h[1]=f*A+v*M+T*R,h[2]=p*A+y*M+C*R,h[3]=m*A+x*M+S*R,h[4]=_*E+g*w+b*P,h[5]=f*E+v*w+T*P,h[6]=p*E+y*w+C*P,h[7]=m*E+x*w+S*P,h[8]=_*F+g*L+b*B,h[9]=f*F+v*L+T*B,h[10]=p*F+y*L+C*B,h[11]=m*F+x*L+S*B,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,a=r.elements,i=t._x,o=t._y,s=t._z;a[0]=n[0]*i,a[1]=n[1]*i,a[2]=n[2]*i,a[3]=n[3]*i,a[4]=n[4]*o,a[5]=n[5]*o,a[6]=n[6]*o,a[7]=n[7]*o,a[8]=n[8]*s,a[9]=n[9]*s,a[10]=n[10]*s,a[11]=n[11]*s,a[12]=n[12],a[13]=n[13],a[14]=n[14],a[15]=n[15]},y.translate=function(e,t,r){var n=e.elements,a=r.elements,i=t._x,o=t._y,s=t._z;if(e===r)a[12]=n[0]*i+n[4]*o+n[8]*s+n[12],a[13]=n[1]*i+n[5]*o+n[9]*s+n[13],a[14]=n[2]*i+n[6]*o+n[10]*s+n[14],a[15]=n[3]*i+n[7]*o+n[11]*s+n[15];else{var l=n[0],c=n[1],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];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]=m,a[9]=g,a[10]=v,a[11]=y,a[12]=l*i+h*o+m*s+n[12],a[13]=c*i+_*o+g*s+n[13],a[14]=u*i+f*o+v*s+n[14],a[15]=d*i+p*o+y*s+n[15]}},y.transpose=function(e,t){var r=e.elements,n=t.elements;if(t===e){var a=r[1],i=r[2],o=r[3],s=r[6],l=r[7],c=r[11];n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=a,n[6]=r[9],n[7]=r[13],n[8]=i,n[9]=s,n[11]=r[14],n[12]=o,n[13]=l,n[14]=c}else n[0]=r[0],n[1]=r[4],n[2]=r[8],n[3]=r[12],n[4]=r[1],n[5]=r[5],n[6]=r[9],n[7]=r[13],n[8]=r[2],n[9]=r[6],n[10]=r[10],n[11]=r[14],n[12]=r[3],n[13]=r[7],n[14]=r[11],n[15]=r[15]},y);c8._tempVec30=new cZ,c8._tempVec31=new cZ,c8._tempVec32=new cZ,c8._tempMat30=new c3,c8._identity=new c8(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var c5=((T=(b=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new cZ,this.direction=new cZ,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return c0.intersectsRayAndPlane(this,e)},T.intersectSphere=function(e){return c0.intersectsRayAndSphere(this,e)},T.intersectBox=function(e){return c0.intersectsRayAndBox(this,e)},T.getPoint=function(e,t){return cZ.scale(this.direction,e,t),t.add(this.origin)},b),c9=((S=(C=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}).prototype).set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},S.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},S.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},S.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},S.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},S.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},S.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},S.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},S.normalize=function(){return C.normalize(this,this),this},S.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},S.clone=function(){return new C(this._x,this._y)},S.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},S.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},S.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},S.toJSON=function(){return{x:this._x,y:this._y}},C.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._onValueChanged&&r._onValueChanged()},C.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._onValueChanged&&r._onValueChanged()},C.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._onValueChanged&&r._onValueChanged()},C.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._onValueChanged&&r._onValueChanged()},C.dot=function(e,t){return e._x*t._x+e._y*t._y},C.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y;return Math.sqrt(r*r+n*n)},C.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y;return r*r+n*n},C.equals=function(e,t){return cQ.equals(e._x,t._x)&&cQ.equals(e._y,t._y)},C.lerp=function(e,t,r,n){var a=e._x,i=e._y;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._onValueChanged&&n._onValueChanged()},C.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._onValueChanged&&r._onValueChanged()},C.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},C.normalize=function(e,t){var r=e._x,n=e._y,a=Math.sqrt(r*r+n*n);a>cQ.zeroTolerance&&(a=1/a,t._x=r*a,t._y=n*a,t._onValueChanged&&t._onValueChanged())},C.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._onValueChanged&&r._onValueChanged()},n(C,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),C);c9._zero=new c9(0,0),c9._one=new c9(1,1);var c6=((M=(A=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=r,this._w=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._w=n,this._onValueChanged&&this._onValueChanged(),this},M.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},M.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},M.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},M.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},M.length=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return Math.sqrt(e*e+t*t+r*r+n*n)},M.lengthSquared=function(){var e=this._x,t=this._y,r=this._z,n=this._w;return e*e+t*t+r*r+n*n},M.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},M.normalize=function(){return A.normalize(this,this),this},M.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},M.clone=function(){return new A(this._x,this._y,this._z,this._w)},M.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},M.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},M.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},M.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,r){r._x=e._x+t._x,r._y=e._y+t._y,r._z=e._z+t._z,r._w=e._w+t._w,r._onValueChanged&&r._onValueChanged()},A.subtract=function(e,t,r){r._x=e._x-t._x,r._y=e._y-t._y,r._z=e._z-t._z,r._w=e._w-t._w,r._onValueChanged&&r._onValueChanged()},A.multiply=function(e,t,r){r._x=e._x*t._x,r._y=e._y*t._y,r._z=e._z*t._z,r._w=e._w*t._w,r._onValueChanged&&r._onValueChanged()},A.divide=function(e,t,r){r._x=e._x/t._x,r._y=e._y/t._y,r._z=e._z/t._z,r._w=e._w/t._w,r._onValueChanged&&r._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(r*r+n*n+a*a+i*i)},A.distanceSquared=function(e,t){var r=t._x-e._x,n=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return r*r+n*n+a*a+i*i},A.equals=function(e,t){return cQ.equals(e._x,t._x)&&cQ.equals(e._y,t._y)&&cQ.equals(e._z,t._z)&&cQ.equals(e._w,t._w)},A.lerp=function(e,t,r,n){var a=e._x,i=e._y,o=e._z,s=e._w;n._x=a+(t._x-a)*r,n._y=i+(t._y-i)*r,n._z=o+(t._z-o)*r,n._w=s+(t._w-s)*r,n._onValueChanged&&n._onValueChanged()},A.max=function(e,t,r){r._x=Math.max(e._x,t._x),r._y=Math.max(e._y,t._y),r._z=Math.max(e._z,t._z),r._w=Math.max(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.min=function(e,t,r){r._x=Math.min(e._x,t._x),r._y=Math.min(e._y,t._y),r._z=Math.min(e._z,t._z),r._w=Math.min(e._w,t._w),r._onValueChanged&&r._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var r=e._x,n=e._y,a=e._z,i=e._w,o=Math.sqrt(r*r+n*n+a*a+i*i);o>cQ.zeroTolerance&&(o=1/o,t._x=r*o,t._y=n*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},A.scale=function(e,t,r){r._x=e._x*t,r._y=e._y*t,r._z=e._z*t,r._w=e._w*t,r._onValueChanged&&r._onValueChanged()},A.transform=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;r._x=n*s[0]+a*s[4]+i*s[8]+o*s[12],r._y=n*s[1]+a*s[5]+i*s[9]+o*s[13],r._z=n*s[2]+a*s[6]+i*s[10]+o*s[14],r._w=n*s[3]+a*s[7]+i*s[11]+o*s[15],r._onValueChanged&&r._onValueChanged()},A.transformByQuat=function(e,t,r){var n=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,d=u*n+l*i-c*a,h=u*a+c*n-s*i,_=u*i+s*a-l*n,f=-s*n-l*a-c*i;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(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);c6._zero=new c6(0,0,0,0),c6._one=new c6(1,1,1,1);var c7=((E=(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},E.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},E.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new R(this._r,this._g,this._b,this._a)},E.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},E.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},E.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},E.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},E.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},E.getBrightness=function(){var e=this.r,t=this.g,r=this.b,n=e,a=e;return t>n&&(n=t),r>n&&(n=r),t<a&&(a=t),r<a&&(a=r),(n+a)/2},E.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 cQ.equals(e._r,t._r)&&cQ.equals(e._g,t._g)&&cQ.equals(e._b,t._b)&&cQ.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 a=e._r,i=e._g,o=e._b,s=e._a;return n._r=a+(t._r-a)*r,n._g=i+(t._g-i)*r,n._b=o+(t._b-o)*r,n._a=s+(t._a-s)*r,n._onValueChanged&&n._onValueChanged(),n},n(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),ue=((P=(w=function(e,t,r,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=r,this._height=n}).prototype).set=function(e,t,r,n){return this._x=e,this._y=t,this._width=r,this._height=n,this._onValueChanged&&this._onValueChanged(),this},P.clone=function(){return new w(this.x,this.y,this.width,this.height)},P.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._width=e.width,this._height=e.height,this._onValueChanged&&this._onValueChanged(),this},n(w,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),w),ut=((L=(F=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,r){t.scale(r);var n=this.coefficients,a=e._x,i=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*i,d=.488603*o,h=-.488603*a,_=1.092548*(a*i),f=-1.092548*(i*o),p=.315392*(3*o*o-1),m=-1.092548*(a*o),g=.546274*(a*a-i*i);n[0]+=.282095*s,n[1]+=.282095*l,n[2]+=.282095*c,n[3]+=s*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,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*n,c=.858086*a*n,u=-.858086*a*i,d=.247708*(3*i*i-1),h=-.858086*i*n,_=.429042*(n*n-a*a),f=.886227*r[0],p=.886227*r[1],m=.886227*r[2];return f+=r[3]*o+r[6]*s+r[9]*l,p+=r[4]*o+r[7]*s+r[10]*l,m+=r[5]*o+r[8]*s+r[11]*l,f+=r[12]*c+r[15]*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),ur=((D=(B=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},D.random=function(){return this.randomInt32()/4294967295},D.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},B);function un(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ua(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 ui(e,t,r){return t&&ua(e.prototype,t),r&&ua(e,r),e}function uo(e,t){return(uo=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function us(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&&uo(e,t)}function ul(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function uc(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function uu(e,t){uf.registerCloneMode(e,t,l7.Ignore)}function ud(e,t){uf.registerCloneMode(e,t,l7.Assignment)}function uh(e,t){uf.registerCloneMode(e,t,l7.Shallow)}function u_(e,t){uf.registerCloneMode(e,t,l7.Deep)}e.Platform=void 0,(I=e.Platform||(e.Platform={}))[I.Android=0]="Android",I[I.IPhone=1]="IPhone",I[I.IPad=2]="IPad",I[I.Mac=3]="Mac",I[I.Unknown=4]="Unknown",e.SpriteMaskInteraction=void 0,(O=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[O.None=0]="None",O[O.VisibleInsideMask=1]="VisibleInsideMask",O[O.VisibleOutsideMask=2]="VisibleOutsideMask",e.SpriteMaskLayer=void 0,(V=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[V.Layer0=1]="Layer0",V[V.Layer1=2]="Layer1",V[V.Layer2=4]="Layer2",V[V.Layer3=8]="Layer3",V[V.Layer4=16]="Layer4",V[V.Layer5=32]="Layer5",V[V.Layer6=64]="Layer6",V[V.Layer7=128]="Layer7",V[V.Layer8=256]="Layer8",V[V.Layer9=512]="Layer9",V[V.Layer10=1024]="Layer10",V[V.Layer11=2048]="Layer11",V[V.Layer12=4096]="Layer12",V[V.Layer13=8192]="Layer13",V[V.Layer14=16384]="Layer14",V[V.Layer15=32768]="Layer15",V[V.Layer16=65536]="Layer16",V[V.Layer17=131072]="Layer17",V[V.Layer18=262144]="Layer18",V[V.Layer19=524288]="Layer19",V[V.Layer20=1048576]="Layer20",V[V.Layer21=2097152]="Layer21",V[V.Layer22=4194304]="Layer22",V[V.Layer23=8388608]="Layer23",V[V.Layer24=16777216]="Layer24",V[V.Layer25=33554432]="Layer25",V[V.Layer26=67108864]="Layer26",V[V.Layer27=134217728]="Layer27",V[V.Layer28=268435456]="Layer28",V[V.Layer29=536870912]="Layer29",V[V.Layer30=1073741824]="Layer30",V[V.Layer31=2147483648]="Layer31",V[V.Everything=4294967295]="Everything",e.TextHorizontalAlignment=void 0,(N=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[N.Left=0]="Left",N[N.Center=1]="Center",N[N.Right=2]="Right",e.TextVerticalAlignment=void 0,(k=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[k.Top=0]="Top",k[k.Center=1]="Center",k[k.Bottom=2]="Bottom",e.OverflowMode=void 0,(z=e.OverflowMode||(e.OverflowMode={}))[z.Overflow=0]="Overflow",z[z.Truncate=1]="Truncate",e.FontStyle=void 0,(U=e.FontStyle||(e.FontStyle={}))[U.None=0]="None",U[U.Bold=1]="Bold",U[U.Italic=2]="Italic","function"==typeof SuppressedError&&SuppressedError,(G=l7||(l7={}))[G.Ignore=0]="Ignore",G[G.Assignment=1]="Assignment",G[G.Shallow=2]="Shallow",G[G.Deep=3]="Deep";var uf=((H=function(){}).registerCloneMode=function(e,t,r){var n=H._subCloneModeMap.get(e.constructor);n||(n=Object.create(null),H._subCloneModeMap.set(e.constructor,n)),n[t]=r},H.getCloneMode=function(e){var t=H._cloneModeMap.get(e);if(!t){t=Object.create(null),H._cloneModeMap.set(e,t);for(var r=H._objectType,n=H._subCloneModeMap;e!==r;){var a=n.get(e);a&&Object.assign(t,a),e=Object.getPrototypeOf(e)}}return t},H.cloneProperty=function(e,t,r,n,a,i,o){if(n!==l7.Ignore){var s=e[r];if(uc(s,Object)){if(void 0===n||n===l7.Assignment){t[r]=s;return}switch(s.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var l=t[r];null==l||l.length!==s.length?t[r]=s.slice():l.set(s);break;case Array:var c=t[r],u=s.length;null==c?t[r]=c=Array(u):c.length=u;for(var d=0;d<u;d++)H.cloneProperty(s,c,d,n,a,i,o);break;default:var h=t[r];if(h||((h=o.get(s))||(h=new s.constructor,o.set(s,h)),t[r]=h),s.copyFrom)h.copyFrom(s);else{var _=H.getCloneMode(s.constructor);for(var f in s)H.cloneProperty(s,h,f,_[f],a,i,o);s._cloneTo&&s._cloneTo(h,a,i)}}}else t[r]=s}},H.deepCloneObject=function(e,t,r){for(var n in e)H.cloneProperty(e,t,n,l7.Deep,null,null,r)},H);uf._subCloneModeMap=new Map,uf._cloneModeMap=new Map,uf._objectType=Object.getPrototypeOf(Object);var up=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)},ui(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();up._instanceIdCounter=0,ul([uu],up.prototype,"instanceId",void 0),ul([uu],up.prototype,"_engine",void 0);var um=(us(W=function(e){var t;return(t=up.call(this,e)||this).isGCIgnored=!1,t._refCount=0,t._superResources=null,e.resourceManager._addReferResource(un(t)),t},up),(j=W.prototype).destroy=function(e,t){if(void 0===e&&(e=!1),!e){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!t)return!1;for(var n=0,a=r.length;n<a;n++)if(r[n].refCount>0)return!1}}return up.prototype.destroy.call(this),!0},j._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},j._disassociationSuperResource=function(e){var t=this._superResources,r=t.indexOf(e);t.splice(r,1)},j._getReferCount=function(){return this._refCount},j._addReferCount=function(e){this._refCount+=e},j._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},j._onDestroy=function(){up.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},ui(W,[{key:"refCount",get:function(){return this._refCount}}]),W),ug=(us(K=function(e){var t;return(t=um.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},um),(X=K.prototype).getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},X.getSprites=function(e,t){t.length=0;var r=this._spriteNamesToIndex[e];if(void 0!==r)for(var n=this._sprites;r>=0;r--){var a=n[r];a.name===e&&t.push(a)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},X._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},X._onDestroy=function(){um.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},ui(K,[{key:"sprites",get:function(){return this._sprites}}]),K);e.SpriteDrawMode=void 0,(Y=e.SpriteDrawMode||(e.SpriteDrawMode={}))[Y.Simple=0]="Simple",Y[Y.Sliced=1]="Sliced",Y[Y.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(q=e.SpriteTileMode||(e.SpriteTileMode={}))[q.Continuous=0]="Continuous",q[q.Adaptive=1]="Adaptive";var uv=((Q=function(){}).removeFromArray=function(e,t){var r=e.indexOf(t);if(r<0)return!1;var n=e.length-1;if(r!==n){var a=e[n];e[r]=a}return e.length--,!0},Q.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",r=0,n=e.length;r<n;r++)t+=String.fromCharCode(e[r]);return decodeURIComponent(encodeURIComponent(t))},Q.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},Q.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},Q.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},Q.resolveAbsoluteUrl=function(e,t){return Q.isAbsoluteUrl(t)||Q.isBase64Url(t)?t:t?new URL(t,e).href:e},Q._floatMatrixMultiply=function(e,t,r,n,a){var i=e.elements,o=i[0],s=i[1],l=i[2],c=i[3],u=i[4],d=i[5],h=i[6],_=i[7],f=i[8],p=i[9],m=i[10],g=i[11],v=i[12],y=i[13],x=i[14],b=i[15],T=t[r],C=t[r+1],S=t[r+2],A=t[r+3],M=t[r+4],R=t[r+5],E=t[r+6],w=t[r+7],P=t[r+8],F=t[r+9],L=t[r+10],B=t[r+11],D=t[r+12],I=t[r+13],O=t[r+14],V=t[r+15];n[a]=o*T+u*C+f*S+v*A,n[a+1]=s*T+d*C+p*S+y*A,n[a+2]=l*T+h*C+m*S+x*A,n[a+3]=c*T+_*C+g*S+b*A,n[a+4]=o*M+u*R+f*E+v*w,n[a+5]=s*M+d*R+p*E+y*w,n[a+6]=l*M+h*R+m*E+x*w,n[a+7]=c*M+_*R+g*E+b*w,n[a+8]=o*P+u*F+f*L+v*B,n[a+9]=s*P+d*F+p*L+y*B,n[a+10]=l*P+h*F+m*L+x*B,n[a+11]=c*P+_*F+g*L+b*B,n[a+12]=o*D+u*I+f*O+v*V,n[a+13]=s*D+d*I+p*O+y*V,n[a+14]=l*D+h*I+m*O+x*V,n[a+15]=c*D+_*I+g*O+b*V},Q._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,a=0,i=r.length;null!=n&&a<i;)n=n[r[a++]];return a&&a==i?n:void 0},Q._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var a=t+r>>1,i=e[t],o=e[r-1],s=e[a];if(n(i,o)>0){var l=i;i=o,o=l}if(n(i,s)>=0){var c=i;i=s,s=o,o=c}else if(n(o,s)>0){var u=o;o=s,s=u}e[t]=i,e[r-1]=s;var d=o,h=t+1,_=r-1;e[a]=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=_)}},Q._stringToPath=function(e){var t=[];return e.charCodeAt(0)===uy&&t.push(""),e.replace(ub,function(e,r,n,a){var i=e;n?i=a.replace(ux,"$1"):r&&(i=r.trim()),t.push(i)}),t},Q._insertionSort=function(e,t,r,n){for(var a=t+1;a<r;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(n(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},Q),uy=46,ux=/\\(\\)?/g,ub=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),uT=((J=(Z=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},J.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},J.removeFlag=function(e){uv.removeFromArray(this._updateFlags,e)&&uv.removeFromArray(e._flagManagers,this)},J.addListener=function(e){this._listeners.push(e)},J.removeListener=function(e){uv.removeFromArray(this._listeners,e)},J.dispatch=function(e,t){for(var r=this._updateFlags,n=r.length-1;n>=0;n--)r[n].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},Z);($=ce||(ce={}))[$.texture=1]="texture",$[$.size=2]="size",$[$.atlasRotate=4]="atlasRotate",$[$.atlasRegion=8]="atlasRegion",$[$.atlasRegionOffset=16]="atlasRegionOffset",$[$.region=32]="region",$[$.pivot=64]="pivot",$[$.border=128]="border",$[$.destroy=256]="destroy";var uC=(us(ee=function(e,t,r,n,a,i){var o;return void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===a&&(a=null),void 0===i&&(i=null),(o=um.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new c9,new c9,new c9,new c9],o._uvs=[new c9,new c9,new c9,new c9],o._bounds=new c$,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new ue(0,0,1,1),o._atlasRegionOffset=new c6(0,0,0,0),o._region=new ue(0,0,1,1),o._pivot=new c9(.5,.5),o._border=new c6(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new uT,o._texture=t,o._onRegionChange=o._onRegionChange.bind(un(o)),o._onPivotChange=o._onPivotChange.bind(un(o)),o._onBorderChange=o._onBorderChange.bind(un(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,r&&o._region.copyFrom(r),n&&o._pivot.copyFrom(n),a&&o._border.copyFrom(a),o.name=i,o},um),(et=ee.prototype).clone=function(){var e=new ee(this._engine,this._texture,this._region,this._pivot,this._border,this.name);return e._atlasRotated=this._atlasRotated,e._atlasRegion.copyFrom(this._atlasRegion),e._atlasRegionOffset.copyFrom(this._atlasRegionOffset),e},et._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},et._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},et._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},et._addReferCount=function(e){var t;um.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},et._onDestroy=function(){this._dispatchSpriteChange(ce.destroy),um.prototype._onDestroy.call(this),this._positions.length=0,this._positions=null,this._uvs.length=0,this._uvs=null,this._atlasRegion=null,this._atlasRegionOffset=null,this._region=null,this._pivot=null,this._border=null,this._bounds=null,this._atlas=null,this._texture=null,this._updateFlagManager=null},et._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,r=this._atlasRegionOffset,n=this._region,a=1/h4._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-r.x-r.z)*n.width*a,this._automaticHeight=e.height*t.height/(1-r.y-r.w)*n.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},et._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,r=t.x,n=t.y,a=t.width,i=t.height,o=Math.max(e.x-r,0)/a,s=Math.max(e.w-n,0)/i,l=1-Math.max(e.z-(1-r-a),0)/a,c=1-Math.max(e.y-(1-n-i),0)/i,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},et._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,r=this._region,n=r.x,a=r.y,i=r.width,o=r.height,s=1-n-i,l=1-a-o,c=this._atlasRegion,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,b=Math.max(l-p,0)*y+d,T=h+u-Math.max(s-m,0)*v,C=_+d-Math.max(a-g,0)*y,S=this._border,A=S.x,M=S.y,R=S.z,E=S.w;e[0].set(x,C),e[1].set((n-f+A*i)*v+u,_+d-(a-g+M*o)*y),e[2].set(h+u-(s-m+R*i)*v,(l-p+E*o)*y+d),e[3].set(T,b),this._dirtyUpdateFlag&=-3},et._dispatchSpriteChange=function(e){switch(e){case ce.texture:this._dirtyUpdateFlag|=4;break;case ce.atlasRegionOffset:case ce.region:this._dirtyUpdateFlag|=7;break;case ce.atlasRegion:this._dirtyUpdateFlag|=6;break;case ce.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},et._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=cQ.clamp(e.x,0,1),r=cQ.clamp(e.y,0,1);e.set(t,r,cQ.clamp(e.width,0,1-t),cQ.clamp(e.height,0,1-r)),this._dispatchSpriteChange(ce.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(ce.size),e._onValueChanged=this._onRegionChange},et._onPivotChange=function(){this._dispatchSpriteChange(ce.pivot)},et._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=cQ.clamp(e.x,0,1),r=cQ.clamp(e.y,0,1);e.set(t,r,cQ.clamp(e.z,0,1-t),cQ.clamp(e.w,0,1-r)),this._dispatchSpriteChange(ce.border),e._onValueChanged=this._onBorderChange},ui(ee,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(ce.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(ce.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(ce.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(ce.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=cQ.clamp(e.x,0,1),r=cQ.clamp(e.y,0,1);this._atlasRegion.set(t,r,cQ.clamp(e.width,0,1-t),cQ.clamp(e.height,0,1-r)),this._dispatchSpriteChange(ce.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(ce.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=cQ.clamp(e.x,0,1),r=cQ.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,cQ.clamp(e.z,0,1-t),cQ.clamp(e.w,0,1-r)),this._dispatchSpriteChange(ce.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(ce.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),ee);function uS(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 uA(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 uS(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 uS(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.")}(er=ct||(ct={}))[er.positions=1]="positions",er[er.uvs=2]="uvs",er[er.automaticSize=4]="automaticSize",er[er.all=7]="all",e.BlendFactor=void 0,(en=e.BlendFactor||(e.BlendFactor={}))[en.Zero=0]="Zero",en[en.One=1]="One",en[en.SourceColor=2]="SourceColor",en[en.OneMinusSourceColor=3]="OneMinusSourceColor",en[en.DestinationColor=4]="DestinationColor",en[en.OneMinusDestinationColor=5]="OneMinusDestinationColor",en[en.SourceAlpha=6]="SourceAlpha",en[en.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",en[en.DestinationAlpha=8]="DestinationAlpha",en[en.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",en[en.SourceAlphaSaturate=10]="SourceAlphaSaturate",en[en.BlendColor=11]="BlendColor",en[en.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(ea=e.BlendOperation||(e.BlendOperation={}))[ea.Add=0]="Add",ea[ea.Subtract=1]="Subtract",ea[ea.ReverseSubtract=2]="ReverseSubtract",ea[ea.Min=3]="Min",ea[ea.Max=4]="Max",e.ColorWriteMask=void 0,(ei=e.ColorWriteMask||(e.ColorWriteMask={}))[ei.None=0]="None",ei[ei.Red=1]="Red",ei[ei.Green=2]="Green",ei[ei.Blue=4]="Blue",ei[ei.Alpha=8]="Alpha",ei[ei.All=15]="All",e.CompareFunction=void 0,(eo=e.CompareFunction||(e.CompareFunction={}))[eo.Never=0]="Never",eo[eo.Less=1]="Less",eo[eo.Equal=2]="Equal",eo[eo.LessEqual=3]="LessEqual",eo[eo.Greater=4]="Greater",eo[eo.NotEqual=5]="NotEqual",eo[eo.GreaterEqual=6]="GreaterEqual",eo[eo.Always=7]="Always",e.CullMode=void 0,(es=e.CullMode||(e.CullMode={}))[es.Off=0]="Off",es[es.Front=1]="Front",es[es.Back=2]="Back",e.RenderStateDataKey=void 0,(el=e.RenderStateDataKey||(e.RenderStateDataKey={}))[el.BlendStateEnabled0=0]="BlendStateEnabled0",el[el.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",el[el.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",el[el.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",el[el.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",el[el.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",el[el.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",el[el.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",el[el.BlendStateBlendColor=8]="BlendStateBlendColor",el[el.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",el[el.DepthStateEnabled=10]="DepthStateEnabled",el[el.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",el[el.DepthStateCompareFunction=12]="DepthStateCompareFunction",el[el.StencilStateEnabled=13]="StencilStateEnabled",el[el.StencilStateReferenceValue=14]="StencilStateReferenceValue",el[el.StencilStateMask=15]="StencilStateMask",el[el.StencilStateWriteMask=16]="StencilStateWriteMask",el[el.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",el[el.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",el[el.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",el[el.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",el[el.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",el[el.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",el[el.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",el[el.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",el[el.RasterStateCullMode=25]="RasterStateCullMode",el[el.RasterStateDepthBias=26]="RasterStateDepthBias",el[el.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",el[el.RenderQueueType=28]="RenderQueueType",e.RenderQueueType=void 0,(ec=e.RenderQueueType||(e.RenderQueueType={}))[ec.Opaque=0]="Opaque",ec[ec.AlphaTest=1]="AlphaTest",ec[ec.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eu=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eu.Float=0]="Float",eu[eu.Int=1]="Int",eu[eu.Vector2=2]="Vector2",eu[eu.Vector3=3]="Vector3",eu[eu.Vector4=4]="Vector4",eu[eu.Matrix=5]="Matrix",eu[eu.Color=6]="Color",eu[eu.Texture=7]="Texture",eu[eu.FloatArray=8]="FloatArray",eu[eu.IntArray=9]="IntArray",eu[eu.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(ed=e.StencilOperation||(e.StencilOperation={}))[ed.Keep=0]="Keep",ed[ed.Zero=1]="Zero",ed[ed.Replace=2]="Replace",ed[ed.IncrementSaturate=3]="IncrementSaturate",ed[ed.DecrementSaturate=4]="DecrementSaturate",ed[ed.Invert=5]="Invert",ed[ed.IncrementWrap=6]="IncrementWrap",ed[ed.DecrementWrap=7]="DecrementWrap",e.ShaderPlatformTarget=void 0,(eh=e.ShaderPlatformTarget||(e.ShaderPlatformTarget={}))[eh.GLES100=0]="GLES100",eh[eh.GLES300=1]="GLES300";var uM=function(){function e(t,r,n,a){this.name=t,this._maskIndex=n,this._maskValue=a,this.value=r;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,r){var n=r?t+" "+r:t,a=e._macroMap[n];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,r,s,1<<l),e._macroMap[n]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=a,e._macroCounter++}return a},e._getMacrosElements=function(t,r){var n=e._macroMaskMap,a=t._mask;r.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=n[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&r.push(s[u])},e}();uM._macroMaskMap=[],uM._macroNameIdMap=Object.create(null),uM._macroNameCounter=0,uM._macroCounter=0,uM._macroMap=Object.create(null);var uR=((ef=(e_=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,r=t+1,n=this._mask,a=this._length;if(a<r){for(n.length<r&&(n.length=r);a<t;a++)n[a]=0;n[t]=e._maskValue,this._length=r}else n[t]|=e._maskValue},ef.disable=function(e){var t=e._maskIndex,r=this._mask,n=this._length-1;if(!(t>n)){var a=r[t]&~e._maskValue;t==n&&0===a?this._length--:r[t]=a}},ef.unionCollection=function(e){var t=e._mask,r=e._length,n=this._mask,a=this._length;if(a<r){n.length<r&&(n.length=r);for(var i=0;i<a;i++)n[i]|=t[i];for(;i<r;i++)n[i]=t[i];this._length=r}else for(var o=0;o<r;o++)n[o]|=t[o]},ef.complementaryCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1,a=Math.min(e._length-1,n);a>=0;a--){var i=r[a]&~t[a];a==n&&0===i?(n--,this._length--):r[a]=i}},ef.intersectionCollection=function(e){for(var t=e._mask,r=this._mask,n=this._length-1;n>=0;n--){var a=r[n]&t[n];0==a&&n==this._length-1?this._length--:r[n]=a}},ef.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},ef.clear=function(){this._length=0},e_.unionCollection=function(e,t,r){var n,a,i,o,s=r._mask;e._length<t._length?(n=e._length,a=t._length,i=e._mask,o=t._mask):(n=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<n;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];r._length=a},e_);function uE(){return(uE=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,(ep=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",ep.ShadowCaster="ShadowCaster",ep.Forward="Forward";var uw=((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,a=em._dispatchingListenersPool,i=a.length>0?a.pop():[];i.length=n;for(var o=0;o<n;o++)i[o]=r[o];for(var s=0;s<n;s++){var l=i[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}i.length=0,a.push(i)}else r.once&&this.off(e,r.fn),r.fn(t);return!0},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 a=r.length-1;a>=0;a--)r[a].fn===t&&(r[a].destroyed=!0,r.splice(a,1));0===r.length?this._clearEvent(e):1===r.length&&(this._events[e]=r[0])}}else this._clearEvent(e);return this},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},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(n):a[e]=[i,n]:(a[e]=n,this._eventCount++),this},eg._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},em);uw._dispatchingListenersPool=[];var uP=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},uF=console.log.bind(console),uL=console.info.bind(console),uB=console.warn.bind(console),uD=console.error.bind(console),uI={debug:uP,info:uP,warn:uP,error:uP,isEnabled:!1,enable:function(){this.debug=uF,this.info=uL,this.warn=uB,this.error=uD,this.isEnabled=!0},disable:function(){this.debug=uP,this.info=uP,this.warn=uP,this.error=uP,this.isEnabled=!1}},uO=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},ui(e,[{key:"type",get:function(){return this._type}}]),e}();uO._propertyIdMap=Object.create(null),uO._propertyNameCounter=0,uO._propertyNameMap=Object.create(null);var uV=((ey=(ev=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new c6,this._deltaTimeValue=new c6,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)},ui(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);uV._elapsedTimeProperty=uO.getByName("scene_ElapsedTime"),uV._deltaTimeProperty=uO.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,(eb=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",eb.standardDerivatives="OES_standard_derivatives",eb.shaderTextureLod="EXT_shader_texture_lod",eb.elementIndexUint="OES_element_index_uint",eb.depthTexture="WEBGL_depth_texture",eb.drawBuffers="WEBGL_draw_buffers",eb.vertexArrayObject="OES_vertex_array_object",eb.instancedArrays="ANGLE_instanced_arrays",eb.multipleSample="multipleSampleOnlySupportedInWebGL2",eb.textureFloat="OES_texture_float",eb.textureFloatLinear="OES_texture_float_linear",eb.textureHalfFloat="OES_texture_half_float",eb.textureHalfFloatLinear="OES_texture_half_float_linear",eb.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",eb.colorBufferFloat="EXT_color_buffer_float",eb.colorBufferHalfFloat="EXT_color_buffer_half_float",eb.textureFilterAnisotropic="EXT_texture_filter_anisotropic",eb.blendMinMax="EXT_blend_minmax",eb.fragDepth="EXT_frag_depth",eb.astc="WEBGL_compressed_texture_astc",eb.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",eb.etc="WEBGL_compressed_texture_etc",eb.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",eb.etc1="WEBGL_compressed_texture_etc1",eb.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",eb.pvrtc="WEBGL_compressed_texture_pvrtc",eb.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",eb.s3tc="WEBGL_compressed_texture_s3tc",eb.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",eb.bptc="EXT_texture_compression_bptc",eb.WEBGL_lose_context="WEBGL_lose_context";var uN=uE({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){linearIn=max(linearIn,0.0);return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;uniform vec3 camera_Forward;uniform vec4 camera_ProjectionParams;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nvec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(v_normal,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,v_normal);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];if(weight!=0.0){position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef CAMERA_ORTHOGRAPHIC\nvec3 V=-camera_Forward;\n#else\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec4 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat getShadowFade(vec3 positionWS){vec3 camToPixel=positionWS-camera_Position;float distanceCamToPixel2=dot(camToPixel,camToPixel);return saturate(distanceCamToPixel2*scene_ShadowInfo.z+scene_ShadowInfo.w);}float sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nfloat shadowFade=getShadowFade(v_pos);attenuation=mix(1.0,mix(attenuation,1.0,shadowFade),scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\n#define MIN_PERCEPTUAL_ROUGHNESS 0.045\n#define MIN_ROUGHNESS 0.002025\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;uniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nuniform vec3 material_AnisotropyInfo;\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nuniform sampler2D material_AnisotropyTexture;\n#endif\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicT;vec3 anisotropicB;vec3 anisotropicN;float anisotropy;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;float f0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.0;\n#endif\n}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 getAnisotropicBentNormal(Geometry geometry,vec3 n,float roughness){vec3 anisotropyDirection=geometry.anisotropy>=0.0 ? geometry.anisotropicB : geometry.anisotropicT;vec3 anisotropicTangent=cross(anisotropyDirection,geometry.viewDir);vec3 anisotropicNormal=cross(anisotropicTangent,anisotropyDirection);vec3 bentNormal=normalize(mix(n,anisotropicNormal,abs(geometry.anisotropy)*saturate(5.0*roughness)));return bentNormal;}\n#endif\nvoid initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;\n#ifdef CAMERA_ORTHOGRAPHIC\ngeometry.viewDir=-camera_Forward;\n#else\ngeometry.viewDir=normalize(camera_Position-v_pos);\n#endif\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat anisotropy=material_AnisotropyInfo.z;vec3 anisotropicDirection=vec3(material_AnisotropyInfo.xy,0.0);\n#ifdef MATERIAL_HAS_ANISOTROPY_TEXTURE\nvec3 anisotropyTextureInfo=texture2D(material_AnisotropyTexture,v_uv).rgb;anisotropy*=anisotropyTextureInfo.b;anisotropicDirection.xy*=anisotropyTextureInfo.rg*2.0-1.0;\n#endif\ngeometry.anisotropy=anisotropy;geometry.anisotropicT=normalize(tbn*anisotropicDirection);geometry.anisotropicB=normalize(cross(geometry.normal,geometry.anisotropicT));\n#endif\n}void initMaterial(out Material material,inout Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float f0=pow2((material_IOR-1.0)/(material_IOR+1.0));material.f0=f0;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(f0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(MIN_PERCEPTUAL_ROUGHNESS,min(material.roughness+getAARoughnessFactor(geometry.normal),1.0));\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(MIN_PERCEPTUAL_ROUGHNESS,min(material.clearCoatRoughness+getAARoughnessFactor(geometry.clearCoatNormal),1.0));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n#ifdef MATERIAL_ENABLE_ANISOTROPY\ngeometry.anisotropicN=getAnisotropicBentNormal(geometry,geometry.normal,material.roughness);\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float f0,float dotLH){return f0+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat G_GGX_SmithCorrelated_Anisotropic(float at,float ab,float ToV,float BoV,float ToL,float BoL,float NoV,float NoL){float lambdaV=NoL*length(vec3(at*ToV,ab*BoV,NoV));float lambdaL=NoV*length(vec3(at*ToL,ab*BoL,NoL));return 0.5/max(lambdaV+lambdaL,EPSILON);}\n#endif\nfloat D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nfloat D_GGX_Anisotropic(float at,float ab,float ToH,float BoH,float NoH){float a2=at*ab;vec3 d=vec3(ab*ToH,at*BoH,a2*NoH);float d2=dot(d,d);float b2=a2/d2;return a2*b2*b2*RECIPROCAL_PI;}\n#endif\nvec3 isotropicLobe(vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX(alpha,dotNH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);return F*(G*D);}\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 anisotropicLobe(vec3 h,vec3 l,Geometry geometry,vec3 specularColor,float alpha,float dotNV,float dotNL,float dotNH,float dotLH){vec3 t=geometry.anisotropicT;vec3 b=geometry.anisotropicB;vec3 v=geometry.viewDir;float dotTV=dot(t,v);float dotBV=dot(b,v);float dotTL=dot(t,l);float dotBL=dot(b,l);float dotTH=dot(t,h);float dotBH=dot(b,h);float at=max(alpha*(1.0+geometry.anisotropy),MIN_ROUGHNESS);float ab=max(alpha*(1.0-geometry.anisotropy),MIN_ROUGHNESS);vec3 F=F_Schlick(specularColor,dotLH);float D=D_GGX_Anisotropic(at,ab,dotTH,dotBH,dotNH);float G=G_GGX_SmithCorrelated_Anisotropic(at,ab,dotTV,dotBV,dotTL,dotBL,dotNV,dotNL);return F*(G*D);}\n#endif\nvec3 BRDF_Specular_GGX(vec3 incidentDirection,Geometry geometry,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+geometry.viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,geometry.viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nreturn anisotropicLobe(halfDir,incidentDirection,geometry,specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#else\nreturn isotropicLobe(specularColor,alpha,dotNV,dotNL,dotNH,dotLH);\n#endif\n}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getReflectedVector(Geometry geometry,vec3 n){\n#ifdef MATERIAL_ENABLE_ANISOTROPY\nvec3 r=reflect(-geometry.viewDir,geometry.anisotropicN);\n#else\nvec3 r=reflect(-geometry.viewDir,n);\n#endif\nreturn r;}vec3 getLightProbeRadiance(Geometry geometry,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=getReflectedVector(geometry,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(material.f0,geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));normal*=camera_ProjectionParams.x;\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) || defined(MATERIAL_ENABLE_ANISOTROPY) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;float denom=max(dot(tangent,tangent),dot(bitangent,bitangent));float invmax=(denom==0.0)? 0.0 : camera_ProjectionParams.x/sqrt(denom);mat3 tbn=mat3(tangent*invmax,bitangent*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"},{particle_common:"#define GLSLIFY 1\nvec3 rotationByEuler(in vec3 vector,in vec3 rot){float halfRoll=rot.z*0.5;float halfPitch=rot.x*0.5;float halfYaw=rot.y*0.5;float sinRoll=sin(halfRoll);float cosRoll=cos(halfRoll);float sinPitch=sin(halfPitch);float cosPitch=cos(halfPitch);float sinYaw=sin(halfYaw);float cosYaw=cos(halfYaw);float quaX=(cosYaw*sinPitch*cosRoll)+(sinYaw*cosPitch*sinRoll);float quaY=(sinYaw*cosPitch*cosRoll)-(cosYaw*sinPitch*sinRoll);float quaZ=(cosYaw*cosPitch*sinRoll)-(sinYaw*sinPitch*cosRoll);float quaW=(cosYaw*cosPitch*cosRoll)+(sinYaw*sinPitch*sinRoll);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByAxis(in vec3 vector,in vec3 axis,in float angle){float halfAngle=angle*0.5;float sin=sin(halfAngle);float quaX=axis.x*sin;float quaY=axis.y*sin;float quaZ=axis.z*sin;float quaW=cos(halfAngle);float x=quaX+quaX;float y=quaY+quaY;float z=quaZ+quaZ;float wx=quaW*x;float wy=quaW*y;float wz=quaW*z;float xx=quaX*x;float xy=quaX*y;float xz=quaX*z;float yy=quaY*y;float yz=quaY*z;float zz=quaZ*z;return vec3(((vector.x*((1.0-yy)-zz))+(vector.y*(xy-wz)))+(vector.z*(xz+wy)),((vector.x*(xy+wz))+(vector.y*((1.0-xx)-zz)))+(vector.z*(yz-wx)),((vector.x*(xz-wy))+(vector.y*(yz+wx)))+(vector.z*((1.0-xx)-yy)));}vec3 rotationByQuaternions(in vec3 v,in vec4 q){return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}float evaluateParticleCurve(in vec2 keys[4],in float normalizedAge){float value;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;if(time>=normalizedAge){vec2 lastKey=keys[i-1];float lastTime=lastKey.x;float age=(normalizedAge-lastTime)/(time-lastTime);value=mix(lastKey.y,key.y,age);break;}}return value;}float evaluateParticleCurveCumulative(in vec2 keys[4],in float normalizedAge){float cumulativeValue=0.0;for(int i=1;i<4;i++){vec2 key=keys[i];float time=key.x;vec2 lastKey=keys[i-1];float lastValue=lastKey.y;if(time>=normalizedAge){float lastTime=lastKey.x;float offsetTime=normalizedAge-lastTime;float age=offsetTime/(time-lastTime);cumulativeValue+=(lastValue+mix(lastValue,key.y,age))*0.5*offsetTime;break;}else{cumulativeValue+=(lastValue+key.y)*0.5*(time-lastKey.x);}}return cumulativeValue;}",velocity_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform int renderer_VOLSpace;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nuniform vec3 renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nuniform vec3 renderer_VOLMinConst;\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nuniform vec2 renderer_VOLMaxGradientX[4];uniform vec2 renderer_VOLMaxGradientY[4];uniform vec2 renderer_VOLMaxGradientZ[4];\n#ifdef RENDERER_VOL_RANDOM_CURVE\nuniform vec2 renderer_VOLMinGradientX[4];uniform vec2 renderer_VOLMinGradientY[4];uniform vec2 renderer_VOLMinGradientZ[4];\n#endif\n#endif\n#endif\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nvec3 computeParticleLifeVelocity(in float normalizedAge){vec3 velocity;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_RANDOM_CONSTANT)\nvelocity=renderer_VOLMaxConst;\n#ifdef RENDERER_VOL_RANDOM_CONSTANT\nvelocity=mix(renderer_VOLMinConst,velocity,vec3(a_Random1.y,a_Random1.z,a_Random1.w));\n#endif\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nvelocity=vec3(evaluateParticleCurve(renderer_VOLMaxGradientX,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurve(renderer_VOLMaxGradientZ,normalizedAge));\n#endif\n#ifdef RENDERER_VOL_RANDOM_CURVE\nvelocity=vec3(mix(velocity.x,evaluateParticleCurve(renderer_VOLMinGradientX,normalizedAge),a_Random1.y),mix(velocity.y,evaluateParticleCurve(renderer_VOLMinGradientY,normalizedAge),a_Random1.z),mix(velocity.z,evaluateParticleCurve(renderer_VOLMinGradientZ,normalizedAge),a_Random1.w));\n#endif\nreturn velocity;}\n#endif\nvec3 getStartPosition(vec3 startVelocity,float age,vec3 dragData){vec3 startPosition;float lastTime=min(startVelocity.x/dragData.x,age);startPosition=lastTime*(startVelocity-0.5*dragData*lastTime);return startPosition;}vec3 computeParticlePosition(in vec3 startVelocity,in vec3 lifeVelocity,in float age,in float normalizedAge,vec3 gravityVelocity,vec4 worldRotation,vec3 dragData){vec3 startPosition=getStartPosition(startVelocity,age,dragData);vec3 lifePosition;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\n#if defined(RENDERER_VOL_CONSTANT)|| defined(RENDERER_VOL_RANDOM_CONSTANT)\nlifePosition=lifeVelocity*age;\n#endif\n#if defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifePosition=vec3(evaluateParticleCurveCumulative(renderer_VOLMaxGradientX,normalizedAge)evaluateParticleCurveCumulative(renderer_VOLMaxGradientY,normalizedAge),evaluateParticleCurveCumulative(renderer_VOLMaxGradientZ,normalizedAge));\n#ifdef RENDERER_VOL_RANDOM_CURVE\nlifePosition=vec3(mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientX,normalizedAge),lifePosition.x,a_Random1.y),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientY,normalizedAge),lifePosition.y,a_Random1.z),mix(evaluateParticleCurveCumulative(renderer_VOLMinGradientZ,normalizedAge),lifePosition.z,a_Random1.w));\n#endif\nlifePosition*=vec3(a_ShapePositionStartLifeTime.w);\n#endif\nvec3 finalPosition;if(renderer_VOLSpace==0){finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition+lifePosition,worldRotation);}else{finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation)+lifePosition;}\n#else\nvec3 finalPosition=rotationByQuaternions(a_ShapePositionStartLifeTime.xyz+startPosition,worldRotation);\n#endif\nif(renderer_SimulationSpace==0){finalPosition=finalPosition+renderer_WorldPosition;}else if(renderer_SimulationSpace==1){finalPosition=finalPosition+a_SimulationWorldPosition;}finalPosition+=0.5*gravityVelocity*age;return finalPosition;}",rotation_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nuniform vec2 renderer_ROLMaxCurveZ[4];\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec2 renderer_ROLMinCurveZ[4];\n#endif\n#else\nuniform vec3 renderer_ROLMaxConst;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nuniform vec3 renderer_ROLMinConst;\n#endif\n#endif\n#endif\nfloat computeParticleRotationFloat(in float rotation,in float age,in float normalizedAge){\n#if defined(RENDERER_ROL_CONSTANT_MODE) || defined(RENDERER_ROL_CURVE_MODE)\n#ifdef RENDERER_ROL_CURVE_MODE\nfloat lifeRotation=evaluateParticleCurveCumulative(renderer_ROLMaxCurveZ,normalizedAge);\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(evaluateParticleCurveCumulative(renderer_ROLMinCurveZ,normalizedAge),lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*a_ShapePositionStartLifeTime.w;\n#else\nfloat lifeRotation=renderer_ROLMaxConst.z;\n#ifdef RENDERER_ROL_IS_RANDOM_TWO\nlifeRotation=mix(renderer_ROLMinConst.z,lifeRotation,a_Random0.w);\n#endif\nrotation+=lifeRotation*age;\n#endif\n#endif\nreturn rotation;}\n#if defined(RENDERER_MODE_MESH) && (defined(ROTATION_OVER_LIFETIME) || defined(ROTATION_OVER_LIFETIME_SEPARATE))\nvec3 computeParticleRotationVec3(in vec3 rotation,in float age,in float normalizedAge){\n#ifdef ROTATION_OVER_LIFETIME\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nfloat ageRot=u_ROLAngularVelocityConst*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge);\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nfloat ageRot=mix(u_ROLAngularVelocityConst,u_ROLAngularVelocityConstMax,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradient,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientMax,normalizedAge),a_Random0.w);\n#endif\n#endif\n#ifdef ROTATION_OVER_LIFETIME_SEPARATE\n#ifdef ROTATION_OVER_LIFETIME_CONSTANT\nvec3 ageRot=u_ROLAngularVelocityConstSeparate*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_CURVE\nrotation+=vec3(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge));\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CONSTANTS\nvec3 ageRot=mix(u_ROLAngularVelocityConstSeparate,renderer_ROLMaxConst,a_Random0.w)*age;rotation+=ageRot;\n#endif\n#ifdef ROTATION_OVER_LIFETIME_RANDOM_CURVES\nrotation+=vec3(mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientX,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveX,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientY,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveY,normalizedAge),a_Random0.w),mix(getTotalValueFromGradientFloat(u_ROLAngularVelocityGradientZ,normalizedAge),getTotalValueFromGradientFloat(renderer_ROLMaxCurveZ,normalizedAge),a_Random0.w));\n#endif\n#endif\nreturn rotation;}\n#endif\n",size_over_lifetime_module:"#define GLSLIFY 1\n#ifdef RENDERER_SOL_CURVE_MODE\nuniform vec2 renderer_SOLMaxCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMaxCurveY[4];uniform vec2 renderer_SOLMaxCurveZ[4];\n#endif\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nuniform vec2 renderer_SOLMinCurveX[4];\n#ifdef RENDERER_SOL_IS_SEPARATE\nuniform vec2 renderer_SOLMinCurveY[4];uniform vec2 renderer_SOLMinCurveZ[4];\n#endif\n#endif\n#endif\nvec2 computeParticleSizeBillboard(in vec2 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE_MODE\nfloat lifeSizeX=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeX=mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),lifeSizeX,a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_IS_SEPARATE\nfloat lifeSizeY=evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge);\n#ifdef RENDERER_SOL_IS_RANDOM_TWO\nlifeSizeY=mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),lifeSizeY,a_Random0.z);\n#endif\nsize*=vec2(lifeSizeX,lifeSizeY);\n#else\nsize*=lifeSizeX;\n#endif\n#endif\nreturn size;}\n#ifdef RENDERER_MODE_MESH\nvec3 computeParticleSizeMesh(in vec3 size,in float normalizedAge){\n#ifdef RENDERER_SOL_CURVE\nsize*=evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge);\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES\nsize*=mix(evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),evaluateParticleCurve(u_SOLSizeGradientMax,normalizedAge),a_Random0.z);\n#endif\n#ifdef RENDERER_SOL_CURVE_SEPARATE\nsize*=vec3(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge));\n#endif\n#ifdef RENDERER_SOL_RANDOM_CURVES_SEPARATE\nsize*=vec3(mix(evaluateParticleCurve(renderer_SOLMinCurveX,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveX,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveY,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveY,normalizedAge),a_Random0.z),mix(evaluateParticleCurve(renderer_SOLMinCurveZ,normalizedAge),evaluateParticleCurve(renderer_SOLMaxCurveZ,normalizedAge),a_Random0.z));\n#endif\nreturn size;}\n#endif\n",color_over_lifetime_module:"#define GLSLIFY 1\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nuniform vec4 renderer_COLMaxGradientColor[4];uniform vec2 renderer_COLMaxGradientAlpha[4];\n#ifdef RENDERER_COL_RANDOM_GRADIENTS\nuniform vec4 renderer_COLMinGradientColor[4];uniform vec2 renderer_COLMinGradientAlpha[4];\n#endif\nuniform vec4 renderer_COLGradientKeysMaxTime;\n#endif\n#if defined(RENDERER_COL_GRADIENT) || defined(RENDERER_COL_RANDOM_GRADIENTS)\nvec4 evaluateParticleGradient(in vec4 colorKeys[4],in float colorKeysMaxTime,in vec2 alphaKeys[4],in float alphaKeysMaxTime,in float normalizedAge){vec4 value;float alphaAge=min(normalizedAge,alphaKeysMaxTime);for(int i=0;i<4;i++){vec2 key=alphaKeys[i];float time=key.x;if(alphaAge<=time){if(i==0){value.a=alphaKeys[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"}),uk=((eT=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},eT.registerInclude=function(e,t){if(uN[e])throw'The "'+e+'" shader include already exist';uN[e]=t},eT.unRegisterInclude=function(e){delete uN[e]},eT.parseIncludes=function(e,t){return void 0===t&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm),e.replace(t,function(e,r){var n=uN[r];return void 0===n?(uI.error('Shader slice "'+e.trim()+'" not founded.'),""):eT.parseIncludes(n,t)})},eT.convertTo300=function(e,t){if(e=(e=(e=e.replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),t){if(e=(e=(e=(e=(e=e.replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod")).replace(/\btexture(2D|Cube)GradEXT\b/g,"textureGrad")).replace(/\btexture2DProjLodEXT\b/g,"textureProjLod")).replace(/\btexture2DProjGradEXT\b/g,"textureProjGrad")).replace(/\bgl_FragDepthEXT\b/g,"gl_FragDepth"),!eT._has300Output(e)){if(/\bgl_FragData\[.+?\]/g.test(e)){var r=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,r)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else e=e.replace(/\battribute\b/g,"in");return e},eT._has300Output=function(e){return eT._has300OutInFragReg.test(e)},eT._replaceMRTShader=function(e,t){for(var r="",n=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);n.add(i[1])}return n.forEach(function(e){r+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),r+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,r)},eT);uk._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers","GL_EXT_frag_depth"].map(function(e){return"#extension "+e+" : enable\n"}).join(""),uk._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var uz=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}();uz._nameCounter=0,uz._nameMap=Object.create(null);var uU=((eS=(eC=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?uz.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&uI.warn('The value of tag named "'+r.name+'" is being replaced.'),n[r._uniqueId]=t},eS.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?uz.getByName(e):e)._uniqueId]},eS.getTagValue=function(e){return this._tagsMap["string"==typeof e?uz.getByName(e)._uniqueId:e._uniqueId]},ui(eC,[{key:"name",get:function(){return this._name}}]),eC);e.ColorSpace=void 0,(eA=e.ColorSpace||(e.ColorSpace={}))[eA.Linear=0]="Linear",eA[eA.Gamma=1]="Gamma";var uG=((eR=(eM=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)},eR.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},eR.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,c7.gammaToLinearSpace(r.r),c7.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)},eR.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},eR.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,c7.gammaToLinearSpace(r.r),c7.gammaToLinearSpace(r.g),c7.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)},eR.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},eR.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,c7.gammaToLinearSpace(r.r),c7.gammaToLinearSpace(r.g),c7.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)},eR.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},eR.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},eR.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},eR.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)},eR.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},eR.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)},eR.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},eR.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)},eR.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},eR.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},eR.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},eR.uploadTexture=function(e,t){var r=this._rhi;r.activeTexture(e.textureIndex),r.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},eR.uploadTextureArray=function(e,t){for(var r=this._rhi,n=e.textureIndex,a=0;a<t.length;a++){var i=t[a];r.activeTexture(n[a]),r.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},eM),uH=function(){this.constUniforms=[],this.textureUniforms=[]};(eE=cr||(cr={}))[eE.Scene=0]="Scene",eE[eE.Camera=1]="Camera",eE[eE.Renderer=2]="Renderer",eE[eE.Material=3]="Material",eE[eE.RenderElement=4]="RenderElement";var uW=function(){function e(t,r,n){this.sceneUniformBlock=new uH,this.cameraUniformBlock=new uH,this.rendererUniformBlock=new uH,this.materialUniformBlock=new uH,this.renderElementUniformBlock=new uH,this.otherUniformBlock=new uH,this._uploadRenderCount=-1,this._uploadSceneId=-1,this._uploadCameraId=-1,this._uploadRendererId=-1,this._uploadMaterialId=-1,this.attributeLocation=Object.create(null),this._activeTextureUint=0,this._engine=t,this._gl=t._hardwareRenderer.gl,this._glProgram=this._createProgram(r,n),this._glProgram?(this._isValid=!0,this._recordLocation()):this._isValid=!1,this.id=e._counter++}var t=e.prototype;return t.uploadAll=function(e,t){this.uploadUniforms(e,t),this.uploadTextures(e,t)},t.uploadUniforms=function(e,t){for(var r=t._propertyValueMap,n=e.constUniforms,a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var r=t._propertyValueMap,n=e.textureUniforms;if(n)for(var a=0,i=n.length;a<i;a++){var o=n[a],s=r[o.propertyId];s&&!s.destroyed?o.applyFunc(o,s):o.applyFunc(o,o.textureDefault)}},t.uploadUnGroupTextures=function(){var e=this.otherUniformBlock.textureUniforms;if(e)for(var t=0,r=e.length;t<r;t++){var n=e[t];n.applyFunc(n,n.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,r=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),r.length>0&&this._groupingSubOtherUniforms(r,!0)},t.bind=function(){var e=this._engine._hardwareRenderer;return e._currentBindShaderProgram!==this&&(this._gl.useProgram(this._glProgram),e._currentBindShaderProgram=this,!0)},t.destroy=function(){var e=this._gl;this._glProgram&&e.deleteProgram(this._glProgram)},t._groupingSubOtherUniforms=function(e,t){for(var r=e.length-1;r>=0;r--){var n=e[r],a=uO._getShaderPropertyGroup(n.name);void 0!==a&&(e.splice(e.indexOf(n),1),this._groupingUniform(n,a,t))}},t._groupingUniform=function(e,t,r){switch(t){case cr.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case cr.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case cr.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case cr.Material:r?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case cr.RenderElement:r?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:r?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var r=this._gl,n=this._createShader(r.VERTEX_SHADER,e);if(!n)return null;var a=this._createShader(r.FRAGMENT_SHADER,t);if(!a)return null;var i=r.createProgram();return i?(r.attachShader(i,n),r.attachShader(i,a),r.linkProgram(i),r.validateProgram(i),r.deleteShader(n),r.deleteShader(a),!uI.isEnabled||r.getProgramParameter(i,r.LINK_STATUS)||r.isContextLost())?i:(uI.error("Could not link WebGL program\n\nShader error: "+r.getError()+"\n\nValidate status: "+r.getProgramParameter(i,r.VALIDATE_STATUS)+"\n\nProgram information log: "+r.getProgramInfoLog(i)),r.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,r){var n=this._gl,a=n.createShader(t);return a?(n.shaderSource(a,r),n.compileShader(a),!uI.isEnabled||n.getShaderParameter(a,n.COMPILE_STATUS)||n.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==n.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+n.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(r)),n.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,r=this._glProgram,n=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;n.forEach(function(n){var a,o=n.name,s=n.size,l=n.type,c=new uG(e._engine),u=!1,d=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),u=!0);var h=t.getUniformLocation(r,o);switch(c.name=o,c.propertyId=uO.getByName(o)._uniqueId,c.location=h,l){case t.FLOAT:u?c.applyFunc=c.upload1fv:(c.applyFunc=c.upload1f,c.cacheValue=0);break;case t.FLOAT_VEC2:u?c.applyFunc=c.upload2fv:(c.applyFunc=c.upload2f,c.cacheValue=new c9(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new cZ(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new c6(0,0,0,0));break;case t.BOOL:case t.INT:u?c.applyFunc=c.upload1iv:(c.applyFunc=c.upload1i,c.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:u?c.applyFunc=c.upload2iv:(c.applyFunc=c.upload2i,c.cacheValue=new c9(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new cZ(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new c6(0,0,0));break;case t.FLOAT_MAT4:c.applyFunc=u?c.uploadMat4v:c.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.UNSIGNED_INT_SAMPLER_2D:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(l){case t.SAMPLER_2D:a=i.whiteTexture2D;break;case t.SAMPLER_CUBE:a=i.whiteTextureCube;break;case t.UNSIGNED_INT_SAMPLER_2D:a=i.uintWhiteTexture2D;break;case t.SAMPLER_2D_ARRAY:a=i.whiteTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,c.textureUseCompareMode=!0}if(d=!0,u){for(var _=Array(s),f=new Int32Array(s),p=Array(s),m=0;m<s;m++)_[m]=a,f[m]=e._activeTextureUint,p[m]=t.TEXTURE0+e._activeTextureUint++;c.textureDefault=_,c.textureIndex=p,c.applyFunc=c.uploadTextureArray,e.bind(),t.uniform1iv(h,f)}else{var g=t.TEXTURE0+e._activeTextureUint;c.textureDefault=a,c.textureIndex=g,c.applyFunc=c.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var v=uO._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),a.forEach(function(n){var a=n.name;e.attributeLocation[a]=t.getAttribLocation(r,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),n=Array(r),a=0;a<r;++a){var i=e.getActiveUniform(t,a);n[a]=i}return n},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,r=[],n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<n;++a){var i=e.getActiveAttrib(t,a);r[a]=i}return r},e._addLineNum=function(e){var t,r=e.split("\n"),n=(r.length+1).toString().length+6;return r.map(function(e,r){if((t="0:"+(r+1)).length>=n)return t.substring(0,n)+e;for(var a=0;a<n-t.length;a++)t+=" ";return t+e}).join("\n")},ui(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();uW._counter=0,(ew=cn||(cn={}))[ew.Canonical=0]="Canonical",ew[ew.ShaderLab=1]="ShaderLab";var uj=function(t){function r(n,a,i,o,s){var l;for(var c in(l=t.call(this)||this)._shaderPassId=0,l._renderStateDataMap={},l._shaderProgramPools=[],l._path="",l._platformMacros=[],l._shaderPassId=r._shaderPassCounter++,l._type=cn.Canonical,"string"==typeof o?(l._name=n,l._shaderLabSource=a,l._vertexEntry=i,l._fragmentEntry=o,s=uE({pipelineStage:e.PipelineStage.Forward},s),l._type=cn.ShaderLab):"string"==typeof i?(l._name=n,l._vertexSource=a,l._fragmentSource=i,s=null!=o?o:{pipelineStage:e.PipelineStage.Forward}):(l._name="Default",l._vertexSource=n,l._fragmentSource=a,s=null!=i?i:{pipelineStage:e.PipelineStage.Forward}),s)l.setTag(c,s[c]);return l}us(r,t);var n=r.prototype;return n._getShaderProgram=function(e,t){var r=e._getShaderProgramPool(this),n=r.get(t);return n||(n=this._type===cn.Canonical?this._getCanonicalShaderProgram(e,t):this._compileShaderProgram(e,t,this._vertexEntry,this._fragmentEntry),r.cache(n)),n},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,r=e.length;t<r;t++)e[t]._destroy();e.length=0},n._compileShaderProgram=function(t,n,a,i){var o=this._path,s=this._platformMacros,l=t._hardwareRenderer.isWebGL2,c=[];uM._getMacrosElements(n,c),s.length=0,t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&s.push("HAS_TEX_LOD"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&s.push("HAS_DERIVATIVES"),l?s.push("GRAPHICS_API_WEBGL2"):s.push("GRAPHICS_API_WEBGL1");var u=performance.now(),d=u$._shaderLab._parseShaderPass(this._shaderLabSource,a,i,c,l?e.ShaderPlatformTarget.GLES300:e.ShaderPlatformTarget.GLES100,s,new URL(o,r._shaderRootPath).href),h=d.vertex,_=d.fragment;return uI.info("[ShaderLab compilation] cost time: "+(performance.now()-u)+"ms"),new uW(t,h,_)},n._getCanonicalShaderProgram=function(t,r){var n=t._hardwareRenderer.isWebGL2,a=[];uM._getMacrosElements(r,a);var i=uk.parseCustomMacros(a),o=n?"#version 300 es":"#version 100",s=n?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",l="\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)&&(l+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(l+="#define HAS_DERIVATIVES\n");var c=" "+o+"\n "+s+"\n "+i+"\n "+uk.parseIncludes(this._vertexSource),u=" "+o+"\n "+s+"\n "+(n?"":uk._shaderExtension)+"\n "+l+"\n "+i+"\n "+uk.parseIncludes(this._fragmentSource);return n&&(c=uk.convertTo300(c),u=uk.convertTo300(u,!0)),new uW(t,c,u)},r}(uU);uj._shaderPassCounter=0,uj._shaderRootPath="shaders://root/";var uK=(us(eP=function(e,t,r){var n;if((n=uU.call(this)||this)._name=e,t.length<1)throw" count must large than 0.";for(var a in n._passes=t.slice(),r)n.setTag(a,r[a]);return n},uU),ui(eP,[{key:"passes",get:function(){return this._passes}}]),eP),uX=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},uY=((eL=(eF=function(){this.targetBlendState=new uX,this.blendColor=new c7(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,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!=(a=r.getFloat(f))?a:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(u.sourceColorBlendFactor=null!=(i=r.getFloat(p))?i: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 b=r.getColor(x);void 0!==b&&this.blendColor.copyFrom(b)}var T=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==T){var C=r.getFloat(T);this.alphaToCoverage=void 0!==C&&!!C}},eL._apply=function(e,t){this._platformApply(e,t.blendState)},eL._platformApply=function(t,r){var n=t.gl,a=r.targetBlendState,i=this.targetBlendState,o=i.enabled,s=i.colorBlendOperation,l=i.alphaBlendOperation,c=i.sourceColorBlendFactor,u=i.destinationColorBlendFactor,d=i.sourceAlphaBlendFactor,h=i.destinationAlphaBlendFactor,_=i.colorWriteMask;if(o!==a.enabled&&(o?n.enable(n.BLEND):n.disable(n.BLEND),a.enabled=o),o){(c!==a.sourceColorBlendFactor||u!==a.destinationColorBlendFactor||d!==a.sourceAlphaBlendFactor||h!==a.destinationAlphaBlendFactor)&&(n.blendFuncSeparate(eF._getGLBlendFactor(t,c),eF._getGLBlendFactor(t,u),eF._getGLBlendFactor(t,d),eF._getGLBlendFactor(t,h)),a.sourceColorBlendFactor=c,a.destinationColorBlendFactor=u,a.sourceAlphaBlendFactor=d,a.destinationAlphaBlendFactor=h),(s!==a.colorBlendOperation||l!==a.alphaBlendOperation)&&(n.blendEquationSeparate(eF._getGLBlendOperation(t,s),eF._getGLBlendOperation(t,l)),a.colorBlendOperation=s,a.alphaBlendOperation=l);var f=this.blendColor;c7.equals(r.blendColor,f)||(n.blendColor(f.r,f.g,f.b,f.a),r.blendColor.copyFrom(f))}_!==a.colorWriteMask&&(n.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),a.colorWriteMask=_);var p=this.alphaToCoverage;p!==r.alphaToCoverage&&(p?n.enable(n.SAMPLE_ALPHA_TO_COVERAGE):n.disable(n.SAMPLE_ALPHA_TO_COVERAGE),r.alphaToCoverage=p)},eF._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}},eF._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}},eF);ul([u_],uY.prototype,"targetBlendState",void 0),ul([u_],uY.prototype,"blendColor",void 0);var uq=((eD=(eB=function(){this.enabled=!0,this.compareFunction=e.CompareFunction.Less,this.writeEnabled=!0}).prototype)._applyShaderDataValue=function(t,r){var n,a=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==a){var i=r.getFloat(a);this.enabled=void 0!==i&&!!i}var o=t[e.RenderStateDataKey.DepthStateWriteEnabled];if(void 0!==o){var s=r.getFloat(o);this.writeEnabled=void 0!==s&&!!s}var l=t[e.RenderStateDataKey.DepthStateCompareFunction];void 0!==l&&(this.compareFunction=null!=(n=r.getFloat(l))?n:e.CompareFunction.Less)},eD._apply=function(e,t){this._platformApply(e,t.depthState)},eD._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.compareFunction,i=this.writeEnabled;n!=t.enabled&&(n?r.enable(r.DEPTH_TEST):r.disable(r.DEPTH_TEST),t.enabled=n),n&&a!=t.compareFunction&&(r.depthFunc(eB._getGLCompareFunction(e,a)),t.compareFunction=a),i!=t.writeEnabled&&(r.depthMask(i),t.writeEnabled=i)},eB._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}},eB),uQ=((eO=(eI=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o=t[e.RenderStateDataKey.RasterStateCullMode];void 0!==o&&(this.cullMode=null!=(n=r.getFloat(o))?n:e.CullMode.Back);var s=t[e.RenderStateDataKey.RasterStateDepthBias];void 0!==s&&(this.depthBias=null!=(a=r.getFloat(s))?a:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(i=r.getFloat(l))?i:0)},eO._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},eO._platformApply=function(t,r,n){var a=t.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=i!==e.CullMode.Off;l!==r._cullFaceEnable&&(l?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),r._cullFaceEnable=l),l&&i!==r.cullMode&&(i==e.CullMode.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),r.cullMode=i),n!==r._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),r._frontFaceInvert=n),t._enableGlobalDepthBias||o===r.depthBias&&s===r.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),r.depthBias=o,r.slopeScaledDepthBias=s)},eI),uZ=((eN=(eV=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._applyShaderDataValue=function(t,r){var n,a,i,o,s,l,c,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!=(a=r.getFloat(g))?a:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(i=r.getFloat(v))?i:255);var y=t[e.RenderStateDataKey.StencilStateCompareFunctionFront];void 0!==y&&(this.compareFunctionFront=null!=(o=r.getFloat(y))?o:e.CompareFunction.Always);var x=t[e.RenderStateDataKey.StencilStateCompareFunctionBack];void 0!==x&&(this.compareFunctionBack=null!=(s=r.getFloat(x))?s:e.CompareFunction.Always);var b=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==b&&(this.passOperationFront=null!=(l=r.getFloat(b))?l:e.StencilOperation.Keep);var T=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==T&&(this.passOperationBack=null!=(c=r.getFloat(T))?c:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(u=r.getFloat(C))?u:e.StencilOperation.Keep);var S=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(d=r.getFloat(S))?d:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==A&&(this.zFailOperationFront=null!=(h=r.getFloat(A))?h:e.StencilOperation.Keep);var M=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==M&&(this.zFailOperationBack=null!=(_=r.getFloat(M))?_:e.StencilOperation.Keep)},eN._apply=function(e,t){this._platformApply(e,t.stencilState)},eN._platformApply=function(e,t){var r=e.gl,n=this.enabled,a=this.referenceValue,i=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,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=a!==t.referenceValue||i!==t.mask;(p||o!==t.compareFunctionFront)&&(r.stencilFuncSeparate(r.FRONT,eV._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,eV._getGLCompareFunction(e,s),a,i),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,eV._getGLStencilOperation(e,l),eV._getGLStencilOperation(e,c),eV._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(d!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,eV._getGLStencilOperation(e,d),eV._getGLStencilOperation(e,h),eV._getGLStencilOperation(e,_)),t.failOperationBack=d,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},eV._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}},eV._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}},eV),uJ=((ez=(ek=function(){this.blendState=new uY,this.depthState=new uq,this.stencilState=new uZ,this.rasterState=new uQ,this.renderQueueType=e.RenderQueueType.Opaque}).prototype)._applyStates=function(e,t,r,n){r&&this._applyStatesByShaderData(r,n);var a=e._hardwareRenderer,i=e._lastRenderState,o=e._renderContext;this.blendState._apply(a,i),this.depthState._apply(a,i),this.stencilState._apply(a,i),this.rasterState._apply(a,i,o.flipProjection?!t:t)},ez._applyRenderQueueByShaderData=function(t,r){var n,a=t[e.RenderStateDataKey.RenderQueueType];void 0!==a&&(this.renderQueueType=null!=(n=r.getFloat(a))?n:e.RenderQueueType.Opaque)},ez._applyStatesByShaderData=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},ek);ul([u_],uJ.prototype,"blendState",void 0),ul([u_],uJ.prototype,"depthState",void 0),ul([u_],uJ.prototype,"stencilState",void 0),ul([u_],uJ.prototype,"rasterState",void 0);var u$=((eG=(eU=function(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}).prototype)._registerPath=function(e){for(var t,r=uA(this._subShaders);!(t=r()).done;)for(var n,a=t.value,i=uA(a.passes);!(n=i()).done;)n.value._path=e},eG.compileVariant=function(e,t){var r=eU._compileMacros;r.clear();for(var n=0,a=t.length;n<a;n++)r.enable(uM.getByName(t[n]));for(var i=!1,o=this._subShaders,s=0,l=o.length;s<l;s++)for(var c=o[s].passes,u=0,d=c.length;u<d;u++){var h=c[u]._getShaderProgram(e,r);i=0===u?h.isValid:i&&h.isValid}return i},eG.destroy=function(e){if(void 0===e&&(e=!1),!e&&0!==this._refCount)return!1;for(var t=this._subShaders,r=0,n=t.length;r<n;r++)for(var a=t[r].passes,i=0,o=a.length;i<o;i++)a[i]._destroy();return delete eU._shaderMap[this.name],this._destroyed=!0,!0},eG._getReferCount=function(){return this._refCount},eG._addReferCount=function(e){this._refCount+=e},eU.create=function(e,t,r){var n,a=eU._shaderMap;if(t){if(a[e]){console.error('Shader named "'+e+'" already exists.');return}if("string"==typeof t){var i=new uj(t,r);n=new eU(e,[new uK("Default",[i])])}else if(t.length>0)n=t[0].constructor===uj?new eU(e,[new uK("Default",t)]):new eU(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!eU._shaderLab)throw"ShaderLab has not been set up yet.";var o=eU._shaderLab._parseShaderContent(e);if(a[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(e){var t=e.passes.map(function(e){if(e.isUsePass){var t,r,n=e.name.split("/");return null==(r=eU.find(n[0]))?void 0:null==(t=r.subShaders.find(function(e){return e.name===n[1]}))?void 0:t.passes.find(function(e){return e.name===n[2]})}var a=new uj(e.name,e.contents,e.vertexEntry,e.fragmentEntry,e.tags),i=e.renderStates,o=new uJ;a._renderState=o;var s=i.constantMap,l=i.variableMap;for(var c in s)eU._applyConstRenderStates(o,parseInt(c),s[c]);var u={};for(var d in l)u[d]=uO.getByName(l[d]);return a._renderStateDataMap=u,a});return new uK(e.name,t,e.tags)});return n=new eU(o.name,s),a[o.name]=n,n}return a[e]=n,n},eU.find=function(e){return eU._shaderMap[e]},eU._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}},eU.getMacroByName=function(e,t){return uM.getByName(e,t)},eU.getPropertyByName=function(e){return uO.getByName(e)},ui(eU,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),eU);u$._compileMacros=new uR,u$._shaderMap=Object.create(null);var u0=(us(eH=function(e){var t;return(t=um.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(un(t)),t},um),eH.prototype._onDestroy=function(){um.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},ui(eH,[{key:"isContentLost",get:function(){return this._isContentLost}}]),eH);e.TextureFilterMode=void 0,(eW=e.TextureFilterMode||(e.TextureFilterMode={}))[eW.Point=0]="Point",eW[eW.Bilinear=1]="Bilinear",eW[eW.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(ej=e.TextureFormat||(e.TextureFormat={}))[ej.R8G8B8=0]="R8G8B8",ej[ej.R8G8B8A8=1]="R8G8B8A8",ej[ej.R4G4B4A4=2]="R4G4B4A4",ej[ej.R5G5B5A1=3]="R5G5B5A1",ej[ej.R5G6B5=4]="R5G6B5",ej[ej.Alpha8=5]="Alpha8",ej[ej.LuminanceAlpha=6]="LuminanceAlpha",ej[ej.R16G16B16A16=7]="R16G16B16A16",ej[ej.R32G32B32A32=8]="R32G32B32A32",ej[ej.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",ej[ej.R11G11B10_UFloat=35]="R11G11B10_UFloat",ej[ej.BC1=10]="BC1",ej[ej.BC3=11]="BC3",ej[ej.BC7=12]="BC7",ej[ej.ETC1_RGB=13]="ETC1_RGB",ej[ej.ETC2_RGB=14]="ETC2_RGB",ej[ej.ETC2_RGBA5=15]="ETC2_RGBA5",ej[ej.ETC2_RGBA8=16]="ETC2_RGBA8",ej[ej.PVRTC_RGB2=17]="PVRTC_RGB2",ej[ej.PVRTC_RGBA2=18]="PVRTC_RGBA2",ej[ej.PVRTC_RGB4=19]="PVRTC_RGB4",ej[ej.PVRTC_RGBA4=20]="PVRTC_RGBA4",ej[ej.ASTC_4x4=21]="ASTC_4x4",ej[ej.ASTC_5x5=22]="ASTC_5x5",ej[ej.ASTC_6x6=23]="ASTC_6x6",ej[ej.ASTC_8x8=24]="ASTC_8x8",ej[ej.ASTC_10x10=25]="ASTC_10x10",ej[ej.ASTC_12x12=26]="ASTC_12x12",ej[ej.Depth=27]="Depth",ej[ej.Stencil=28]="Stencil",ej[ej.DepthStencil=29]="DepthStencil",ej[ej.Depth16=30]="Depth16",ej[ej.Depth24=31]="Depth24",ej[ej.Depth32=32]="Depth32",ej[ej.Depth24Stencil8=33]="Depth24Stencil8",ej[ej.Depth32Stencil8=34]="Depth32Stencil8",ej[ej.DXT1=10]="DXT1",ej[ej.DXT5=11]="DXT5";var u1=(us(eK=function(){var e;return e=u0.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},u0),(eX=eK.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},eX._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},eX._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))},eX._onDestroy=function(){u0.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},eX._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},eX._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},eX._isIntFormat=function(){return e.TextureFormat.R32G32B32A32_UInt===this._format},ui(eK,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(t){if(t!==this._filterMode){if(t!==e.TextureFilterMode.Point&&this._isIntFormat()){t=e.TextureFilterMode.Point,uI.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=t,this._platformTexture.filterMode=t}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(uI.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(uI.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)}}]),eK),u2=((eq=(eY=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)},eq.setFloat=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Float,r)},eq.getInt=function(e){return this.getPropertyValue(e)},eq.setInt=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Int,r)},eq.getFloatArray=function(e){return this.getPropertyValue(e)},eq.setFloatArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,r)},eq.getIntArray=function(e){return this.getPropertyValue(e)},eq.setIntArray=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,r)},eq.getVector2=function(e){return this.getPropertyValue(e)},eq.setVector2=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,r)},eq.getVector3=function(e){return this.getPropertyValue(e)},eq.setVector3=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,r)},eq.getVector4=function(e){return this.getPropertyValue(e)},eq.setVector4=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,r)},eq.getMatrix=function(e){return this.getPropertyValue(e)},eq.setMatrix=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,r)},eq.getColor=function(e){return this.getPropertyValue(e)},eq.setColor=function(t,r){this._setPropertyValue(t,e.ShaderPropertyType.Color,r)},eq.getTexture=function(e){return this.getPropertyValue(e)},eq.setTexture=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);a&&a._addReferCount(-n),r&&r._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,r)},eq.getTextureArray=function(e){return this.getPropertyValue(e)},eq.setTextureArray=function(t,r){var n=this._refCount;if(n>0){var a=this.getPropertyValue(t);if(a)for(var i=0,o=a.length;i<o;i++)a[i]._addReferCount(-n);if(r)for(var s=0,l=r.length;s<l;s++)r[s]._addReferCount(n)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,r)},eq.getPropertyValue=function(e){return"string"==typeof e&&(e=uO.getByName(e)),this._propertyValueMap[e._uniqueId]},eq.enableMacro=function(e,t){"string"==typeof e&&(e=uM.getByName(e,t));var r=e._nameId,n=this._macroMap[r];if(n!==e){var a=this._macroCollection;n&&a.disable(n),a.enable(e),this._macroMap[r]=e}},eq.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=uM._macroNameIdMap[e]))return}else t=e._nameId;var t,r=this._macroMap[t];r&&(this._macroCollection.disable(r),delete this._macroMap[t])},eq.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])},eq.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,r=this._propertyValueMap,n=uO._propertyIdMap;for(var a in r)t.push(n[a]);if(!e)return t},eq.clone=function(){var e=new eY(this._group);return this.cloneTo(e),e},eq.cloneTo=function(e){uf.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),r=this._propertyValueMap,n=e._propertyValueMap,a=Object.keys(r),i=0,o=a.length;i<o;i++){var s=a[i],l=r[s];if(null!=l){if("number"==typeof l)n[s]=l;else if(uc(l,u1))n[s]=l,t>0&&l._addReferCount(t);else if(uc(l,Array)||uc(l,Float32Array)||uc(l,Int32Array))n[s]=l.slice();else{var c=n[s];c?c.copyFrom(l):n[s]=l.clone()}}else n[s]=l}},eq._setPropertyValue=function(t,r,n){if("string"==typeof t&&(t=uO.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 "+cr[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},eq._getReferCount=function(){return this._refCount},eq._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var r in t){var n=t[r];n&&uc(n,u1)&&n._addReferCount(e)}},eY);ul([uu],u2.prototype,"_group",void 0),ul([uu],u2.prototype,"_propertyValueMap",void 0),ul([uu],u2.prototype,"_macroCollection",void 0),ul([uu],u2.prototype,"_macroMap",void 0),ul([uu],u2.prototype,"_refCount",void 0);var u3=((eQ=function(){}).canBatchSprite=function(t,r){if(!0===r.shaderPasses[0].getTagValue(eQ._disableBatchTag)||t.subChunk.chunk!==r.subChunk.chunk)return!1;var n=t.component,a=r.component,i=n.maskInteraction;return i===a.maskInteraction&&(i===e.SpriteMaskInteraction.None||n.maskLayer===a.maskLayer)&&t.texture===r.texture&&t.material===r.material},eQ.canBatchSpriteMask=function(e,t){if(e.subChunk.chunk!==t.subChunk.chunk)return!1;var r=dM._alphaCutoffProperty;return e.texture===t.texture&&e.component.shaderData.getFloat(r)===t.component.shaderData.getFloat(r)},eQ.batchFor2D=function(e,t){var r=t?t.subChunk:e.subChunk,n=r.chunk,a=r.indices,i=a.length,o=n.updateIndexLength;if(t)e.subChunk.subMesh.count+=i;else{var s=r.subMesh;s.start=o,s.count=i}for(var l=r.vertexArea,c=l.start,u=l.size,d=c/9,h=n.indices,_=0;_<i;++_)h[o++]=d+a[_];n.updateIndexLength+=i,n.updateVertexStart=Math.min(n.updateVertexStart,c),n.updateVertexEnd=Math.max(n.updateVertexEnd,c+u)},eQ);u3._disableBatchTag=uz.getByName("spriteDisableBatching"),(eZ=ca||(ca={}))[eZ.None=0]="None",eZ[eZ.Scene=1]="Scene",eZ[eZ.Hierarchy=2]="Hierarchy",eZ[eZ.All=3]="All";var u4=(us(eJ=function(e){var t;return(t=up.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},up),(e$=eJ.prototype)._onAwake=function(){},e$._onEnable=function(){},e$._onDisable=function(){},e$._onEnableInScene=function(){},e$._onDisableInScene=function(){},e$._setActive=function(e,t){var r=this._entity;t&ca.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&ca.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()))},e$._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},e$._onDestroy=function(){up.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},ui(eJ,[{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}}]),eJ);ul([uu],u4.prototype,"_entity",void 0),ul([uu],u4.prototype,"_awoken",void 0),ul([uu],u4.prototype,"_phasedActiveInScene",void 0),ul([uu],u4.prototype,"_phasedActive",void 0),ul([ud],u4.prototype,"_enabled",void 0);var u8=((e0=function(){})._addCheck=function(e,t){for(;t!==u4;){var r=e0._dependenciesMap.get(t);if(r)for(var n=r.components,a=r.mode,i=0,o=n.length;i<o;i++){var s=n[i];if(!e.getComponent(s)){if(1===a)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},e0._removeCheck=function(e,t){for(;t!==u4;){var r=e0._invDependenciesMap.get(t);if(r){for(var n=0,a=r.length;n<a;n++)if(e.getComponent(r[n]))throw"Should remove "+r[n].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},e0._addDependency=function(e,t,r){var n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},e0._addInvDependency=function(e,t){var r=this._invDependenciesMap,n=r.get(e);n?n.includes(t)||n.push(t):r.set(e,[t])},e0);function u5(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){u8._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return u8._addInvDependency(t,e)})}}u8._invDependenciesMap=new Map,u8._dependenciesMap=new Map,e.DependentMode=void 0,(e1=e.DependentMode||(e.DependentMode={}))[e1.CheckOnly=0]="CheckOnly",e1[e1.AutoAdd=1]="AutoAdd";var u9=((e3=(e2=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},e3.destroy=function(){this._removeFromManagers(),this._flagManagers=null},e3._removeFromManagers=function(){for(var e=this._flagManagers,t=0,r=e.length;t<r;t++)uv.removeFromArray(e[t]._updateFlags,this)},us(e4=function(){var e;return e=e2.apply(this,arguments)||this,e.flag=!0,e},e2),e4.prototype.dispatch=function(){this.flag=!0},e4),u6=(us(e8=function(e){var t;return(t=u4.call(this,e)||this)._position=new cZ,t._rotation=new cZ,t._rotationQuaternion=new c4,t._scale=new cZ(1,1,1),t._worldPosition=new cZ,t._worldRotation=new cZ,t._worldRotationQuaternion=new c4,t._lossyWorldScale=new cZ(1,1,1),t._localMatrix=new c8,t._worldMatrix=new c8,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new uT,t._onPositionChanged=t._onPositionChanged.bind(un(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(un(t)),t._onRotationChanged=t._onRotationChanged.bind(un(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(un(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(un(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(un(t)),t._onScaleChanged=t._onScaleChanged.bind(un(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},u4),(e5=e8.prototype).setPosition=function(e,t,r){this._position.set(e,t,r)},e5.setRotation=function(e,t,r){this._rotation.set(e,t,r)},e5.setRotationQuaternion=function(e,t,r,n){this._rotationQuaternion.set(e,t,r,n)},e5.setScale=function(e,t,r){this._scale.set(e,t,r)},e5.setWorldPosition=function(e,t,r){this._worldPosition.set(e,t,r)},e5.setWorldRotation=function(e,t,r){this._worldRotation.set(e,t,r)},e5.setWorldRotationQuaternion=function(e,t,r,n){this._worldRotationQuaternion.set(e,t,r,n)},e5.translate=function(e,t,r,n){if("number"==typeof e){var a=e8._tempVec30;a.set(e,t,r),this._translate(a,n)}else this._translate(e,t)},e5.rotate=function(e,t,r,n){"number"==typeof e?this._rotateXYZ(e,t,r,n):this._rotateXYZ(e.x,e.y,e.z,t)},e5.rotateByAxis=function(e,t,r){void 0===r&&(r=!0);var n=t*cQ.degreeToRadFactor;c4.rotationAxisAngle(e,n,e8._tempQuat0),this._rotateByQuat(e8._tempQuat0,r)},e5.lookAt=function(e,t){var r=e8._tempVec30;cZ.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=cQ.zeroTolerance)){r.scale(1/n);var a=e8._tempVec31;if(t?cZ.cross(t,r,a):a.set(r.z,0,-r.x),!((n=a.length())<=cQ.zeroTolerance)){a.scale(1/n);var i=e8._tempVec32;cZ.cross(r,a,i);var o=e8._tempMat41,s=o.elements;s[0]=a.x,s[1]=a.y,s[2]=a.z,s[4]=i.x,s[5]=i.y,s[6]=i.z,s[8]=r.x,s[9]=r.y,s[10]=r.z,o.getRotation(this._worldRotationQuaternion)}}},e5.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(u9)},e5._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},e5._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},e5._onDestroy=function(){u4.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},e5._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()}},e5._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()}},e5._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()}},e5._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()}},e5._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()}},e5._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()}},e5._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},e5._getScaleMatrix=function(){var e=e8._tempQuat0,t=e8._tempMat30,r=e8._tempMat31,n=e8._tempMat32;return r.copyFromMatrix(this.worldMatrix),c4.invert(this.worldRotationQuaternion,e),c3.rotationQuaternion(e,t),c3.multiply(t,r,n),n},e5._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},e5._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},e5._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},e5._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},e5._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},e5._rotateByQuat=function(e,t){t?c4.multiply(this.rotationQuaternion,e,this._rotationQuaternion):c4.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},e5._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=e8._tempVec30;cZ.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},e5._rotateXYZ=function(e,t,r,n){void 0===n&&(n=!0);var a=cQ.degreeToRadFactor,i=e8._tempQuat0;c4.rotationEuler(e*a,t*a,r*a,i),this._rotateByQuat(i,n)},e5._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},e5._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(c8.invert(t.worldMatrix,e8._tempMat41),cZ.transformCoordinate(e,e8._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},e5._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},e5._onWorldRotationChanged=function(){var e=this._worldRotation;c4.rotationEuler(cQ.degreeToRadian(e.x),cQ.degreeToRadian(e.y),cQ.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},e5._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},e5._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var r=e8._tempQuat0;c4.invert(t.worldRotationQuaternion,r),c4.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},e5._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},ui(e8,[{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(cQ.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(cQ.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,c4.rotationEuler(cQ.degreeToRadian(this._rotation.x),cQ.degreeToRadian(this._rotation.y),cQ.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):c4.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?c4.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):c4.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)&&(c8.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?c8.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?(c8.invert(t.worldMatrix,e8._tempMat42),c8.multiply(e8._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 cZ),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 cZ),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 cZ),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),e8);function u7(){return function(e){}}u6._tempQuat0=new c4,u6._tempVec30=new cZ,u6._tempVec31=new cZ,u6._tempVec32=new cZ,u6._tempMat30=new c3,u6._tempMat31=new c3,u6._tempMat32=new c3,u6._tempMat41=new c8,u6._tempMat42=new c8,ul([u_],u6.prototype,"_position",void 0),ul([u_],u6.prototype,"_rotation",void 0),ul([u_],u6.prototype,"_rotationQuaternion",void 0),ul([u_],u6.prototype,"_scale",void 0),ul([u_],u6.prototype,"_worldPosition",void 0),ul([u_],u6.prototype,"_worldRotation",void 0),ul([u_],u6.prototype,"_worldRotationQuaternion",void 0),ul([u_],u6.prototype,"_lossyWorldScale",void 0),ul([u_],u6.prototype,"_localMatrix",void 0),ul([u_],u6.prototype,"_worldMatrix",void 0),ul([uu],u6.prototype,"_worldForward",void 0),ul([uu],u6.prototype,"_worldRight",void 0),ul([uu],u6.prototype,"_worldUp",void 0),ul([uu],u6.prototype,"_isParentDirty",void 0),ul([uu],u6.prototype,"_parentTransformCache",void 0),ul([uu],u6.prototype,"_updateFlagManager",void 0),ul([uu],u6.prototype,"_onPositionChanged",null),ul([uu],u6.prototype,"_onWorldPositionChanged",null),ul([uu],u6.prototype,"_onRotationChanged",null),ul([uu],u6.prototype,"_onWorldRotationChanged",null),ul([uu],u6.prototype,"_onRotationQuaternionChanged",null),ul([uu],u6.prototype,"_onWorldRotationQuaternionChanged",null),ul([uu],u6.prototype,"_onScaleChanged",null),(e9=ci||(ci={}))[e9.LocalEuler=1]="LocalEuler",e9[e9.LocalQuat=2]="LocalQuat",e9[e9.WorldPosition=4]="WorldPosition",e9[e9.WorldEuler=8]="WorldEuler",e9[e9.WorldQuat=16]="WorldQuat",e9[e9.WorldScale=32]="WorldScale",e9[e9.LocalMatrix=64]="LocalMatrix",e9[e9.WorldMatrix=128]="WorldMatrix",e9[e9.WmWp=132]="WmWp",e9[e9.WmWeWq=152]="WmWeWq",e9[e9.WmWpWeWq=156]="WmWpWeWq",e9[e9.WmWs=160]="WmWs",e9[e9.WmWpWs=164]="WmWpWs",e9[e9.WmWpWeWqWs=188]="WmWpWeWqWs",e.Renderer=(us(e6=function(t){(r=u4.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new uR,r._bounds=new c$,r._maskInteraction=e.SpriteMaskInteraction.None,r._maskLayer=e.SpriteMaskLayer.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new c6,r._shaderData=new u2(cr.Renderer),r._mvMatrix=new c8,r._mvpMatrix=new c8,r._mvInvMatrix=new c8,r._normalMatrix=new c8,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,n=e.Renderer.prototype,a=r.shaderData;return r._overrideUpdate=r.update!==n.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(un(r)),r._registerEntityTransformListener(),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},u4),(e7=e6.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},e7.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},e7.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},e7.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},e7.getMaterials=function(){return this._materials},e7.setMaterials=function(e){for(var t=e.length,r=this._materials,n=this._materialsInstanced,a=t,i=r.length;a<i;a++){var o=r[a];o&&this._addResourceReferCount(o,-1)}r.length!==t&&(r.length=t),0!==n.length&&(n.length=0);for(var s=0;s<t;s++){var l=r[s],c=e[s];l!==c&&(r[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},e7.update=function(e){},e7._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},e7._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},e7._prepareRender=function(t){this._renderFrameCount!==this.engine.time.frameCount&&this._update(t);var r=t.virtualCamera,n=r.position,a=this.bounds.getCenter(e.Renderer._tempVector0);r.isOrthographic?(cZ.subtract(a,n,a),this._distanceForSort=cZ.dot(a,r.forward)):this._distanceForSort=cZ.distanceSquared(a,n),this._render(t),uR.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},e7._cloneTo=function(e,t,r){for(var n=this._materials,a=0,i=n.length;a<i;a++)e._setMaterial(a,n[a])},e7._onDestroy=function(){u4.prototype._onDestroy.call(this),this._unRegisterEntityTransformListener(),this._addResourceReferCount(this.shaderData,-1);for(var e=this._materials,t=0,r=e.length;t<r;t++){var n=e[t];n&&this._addResourceReferCount(n,-1)}this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},e7._updateTransformShaderData=function(e,t,r){var n=this.entity.transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,n,r):this._updateWorldViewRelatedShaderData(e,n,r)},e7._canBatch=function(e,t){return!1},e7._batch=function(e,t){},e7._update=function(e){var t=this.entity.layer;this._rendererLayer.set(65535&t,t>>>16&65535,0,0)},e7._updateWorldViewRelatedShaderData=function(t,r,n){var a=this.shaderData,i=this._mvInvMatrix;if(n){var o=c8._identity;c8.invert(t.viewMatrix,i),a.setMatrix(e.Renderer._localMatrixProperty,o),a.setMatrix(e.Renderer._worldMatrixProperty,o),a.setMatrix(e.Renderer._mvMatrixProperty,t.viewMatrix),a.setMatrix(e.Renderer._mvInvMatrixProperty,i),a.setMatrix(e.Renderer._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;c8.multiply(t.viewMatrix,r,s),c8.invert(s,i),c8.invert(r,l),l.transpose(),a.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),a.setMatrix(e.Renderer._worldMatrixProperty,r),a.setMatrix(e.Renderer._mvMatrixProperty,s),a.setMatrix(e.Renderer._mvInvMatrixProperty,i),a.setMatrix(e.Renderer._normalMatrixProperty,l)}this._updateProjectionRelatedShaderData(t,r,n)},e7._updateProjectionRelatedShaderData=function(t,r,n){if(n)this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,t.viewProjectionMatrix);else{var a=this._mvpMatrix;c8.multiply(t.viewProjectionMatrix,r,a),this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,a)}},e7._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},e7._unRegisterEntityTransformListener=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged)},e7._updateBounds=function(e){},e7._render=function(e){throw"not implement"},e7._createInstanceMaterial=function(e,t){var r=e.clone();return r.name=r.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(r,1),this._materialsInstanced[t]=!0,this._materials[t]=r,r},e7._setMaterial=function(e,t){var r=this._materials;e>=r.length&&(r.length=e+1);var n=r[e];if(n!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),n&&this._addResourceReferCount(n,-1),t&&this._addResourceReferCount(t,1),r[e]=t}},e7._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},ui(e6,[{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}}]),e6._tempVector0=new cZ,e6._receiveShadowMacro=uM.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e6._localMatrixProperty=uO.getByName("renderer_LocalMat"),e6._worldMatrixProperty=uO.getByName("renderer_ModelMat"),e6._mvMatrixProperty=uO.getByName("renderer_MVMat"),e6._mvpMatrixProperty=uO.getByName("renderer_MVPMat"),e6._mvInvMatrixProperty=uO.getByName("renderer_MVInvMat"),e6._normalMatrixProperty=uO.getByName("renderer_NormalMat"),e6._rendererLayerProperty=uO.getByName("renderer_Layer"),e6),ul([uu],e.Renderer.prototype,"_distanceForSort",void 0),ul([uu],e.Renderer.prototype,"_onUpdateIndex",void 0),ul([uu],e.Renderer.prototype,"_rendererIndex",void 0),ul([uu],e.Renderer.prototype,"_globalShaderMacro",void 0),ul([uu],e.Renderer.prototype,"_bounds",void 0),ul([uu],e.Renderer.prototype,"_renderFrameCount",void 0),ul([ud],e.Renderer.prototype,"_maskInteraction",void 0),ul([ud],e.Renderer.prototype,"_maskLayer",void 0),ul([uu],e.Renderer.prototype,"_batchedTransformShaderData",void 0),ul([uu],e.Renderer.prototype,"_overrideUpdate",void 0),ul([uu],e.Renderer.prototype,"_materials",void 0),ul([uu],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),ul([uu],e.Renderer.prototype,"_rendererLayer",void 0),ul([u_],e.Renderer.prototype,"_shaderData",void 0),ul([uu],e.Renderer.prototype,"_mvMatrix",void 0),ul([uu],e.Renderer.prototype,"_mvpMatrix",void 0),ul([uu],e.Renderer.prototype,"_mvInvMatrix",void 0),ul([uu],e.Renderer.prototype,"_normalMatrix",void 0),ul([uu],e.Renderer.prototype,"_materialsInstanced",void 0),ul([ud],e.Renderer.prototype,"_priority",void 0),ul([ud],e.Renderer.prototype,"_receiveShadows",void 0),ul([uu],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=ul([u5(u6,e.DependentMode.CheckOnly)],e.Renderer),(te=co||(co={}))[te.WorldVolume=1]="WorldVolume";var de=((tt=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(4);n.indices=de._rectangleTriangles,e._subChunk=n},tt.updatePositions=function(e){var t=e.width,r=e.height,n=e.sprite,a=n.pivot,i=a.x,o=a.y,s=de._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]-i*l[0]-o*l[4],l[13]=c[13]-i*l[1]-o*l[5],l[14]=c[14]-i*l[2]-o*l[6];for(var h=n._getPositions(),_=e._subChunk,f=_.chunk.vertices,p=0,m=_.vertexArea.start;p<4;++p,m+=9){var g=h[p],v=g.x,y=g.y;f[m]=l[0]*v+l[4]*y+l[12],f[m+1]=l[1]*v+l[5]*y+l[13],f[m+2]=l[2]*v+l[6]*y+l[14]}c$.transform(n._getBounds(),s,e._bounds)},tt.updateUVs=function(e){var t=e.sprite._getUVs(),r=t[0],n=r.x,a=r.y,i=t[3],o=i.x,s=i.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=n,c[u+1]=a,c[u+9]=o,c[u+10]=a,c[u+18]=n,c[u+19]=s,c[u+27]=o,c[u+28]=s},tt.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<4;++l,c+=9)s[c]=n,s[c+1]=a,s[c+2]=i,s[c+3]=o},tt._rectangleTriangles=[0,1,2,2,1,3],tt._worldMatrix=new c8,tt);de=ul([u7()],de);var dt=((tr=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(16);n.indices=dt._rectangleTriangles,e._subChunk=n},tr.updatePositions=function(e){var t,r,n=e.width,a=e.height,i=e.sprite,o=i.border,s=i._getPositions(),l=s[0],c=l.x,u=l.y,d=s[3],h=d.x,_=d.y,f=i.width,p=i.height,m=f*o.x,g=p*o.y,v=f*o.z,y=p*o.w;if(m+v>n){var x=n/(m+v);t=[f*c*x,m*x,m*x,n-f*(1-h)*x]}else t=[f*c,m,n-v,n-f*(1-h)];if(y+g>a){var b=a/(y+g);r=[p*u*b,g*b,g*b,a-p*(1-_)*b]}else r=[p*u,g,a-y,a-p*(1-_)];var T=e.sprite.pivot,C=T.x,S=T.y,A=e.width*C,M=e.height*S,R=dt._worldMatrix,E=R.elements,w=e.entity.transform.worldMatrix.elements,P=e.flipX?-1:1,F=e.flipY?-1:1;E[0]=w[0]*P,E[1]=w[1]*P,E[2]=w[2]*P,E[4]=w[4]*F,E[5]=w[5]*F,E[6]=w[6]*F,E[8]=w[8],E[9]=w[9],E[10]=w[10],E[12]=w[12]-A*E[0]-M*E[4],E[13]=w[13]-A*E[1]-M*E[5],E[14]=w[14]-A*E[2]-M*E[6];for(var L=e._subChunk,B=L.chunk.vertices,D=0,I=L.vertexArea.start;D<4;D++)for(var O=t[D],V=0;V<4;V++,I+=9){var N=r[V];B[I]=E[0]*O+E[4]*N+E[12],B[I+1]=E[1]*O+E[5]*N+E[13],B[I+2]=E[2]*O+E[6]*N+E[14]}var k=e._bounds,z=k.min,U=k.max;z.set(t[0],r[0],0),U.set(t[3],r[3],0),e._bounds.transform(R)},tr.updateUVs=function(e){for(var t=e._subChunk,r=t.chunk.vertices,n=e.sprite._getUVs(),a=0,i=t.vertexArea.start+3;a<4;a++)for(var o=n[a].x,s=0;s<4;s++,i+=9)r[i]=o,r[i+1]=n[s].y},tr.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<16;++l,c+=9)s[c]=n,s[c+1]=a,s[c+2]=i,s[c+3]=o},tr._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],tr._worldMatrix=new c8,tr);dt=ul([u7()],dt);var dr=((ta=(tn=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++},ta.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ta.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},ta.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ta.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},ta.forEach=function(e,t){this._startLoop();for(var r=this._elements,n=0,a=this.length;n<a;n++){var i=r[n];i&&e(i)}this._endLoop(t)},ta.forEachAndClean=function(e,t){this._startLoop();for(var r=this.length,n=this._elements,a=0;a<r;a++){var i=n[a];i&&e(i)}this._endLoopAndClean(r,n,t)},ta.sort=function(e){uv._quickSort(this._elements,0,this.length,e)},ta.garbageCollection=function(){this._elements.length=this.length},ta._startLoop=function(){this._isLooping=!0},ta._endLoop=function(e){if(this._isLooping=!1,this._blankCount){var t=0,r=this.length-1,n=this._elements;e:do{for(;n[t];)if(++t>=r)break e;for(;!n[r];)if(t>=--r)break e;var a=n[r];e(a,t),n[t++]=a,n[r--]=null}while(t<r);this.length-=this._blankCount,this._blankCount=0}},ta._endLoopAndClean=function(e,t,r){for(var n=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[n]=o,r(o,n),n++)}this._isLooping=!1,this.length=n,this._blankCount=0},tn),dn=((ti=function(){}).resetData=function(e,t){if(t){var r=e._getChunkManager(),n=e._subChunk,a=n&&n.vertexArea.size!==9*t;if(a&&r.freeSubChunk(n),!n||a){var i=r.allocateSubChunk(t);i.indices=[],e._subChunk=i}}},ti.updatePositions=function(t){var r,n,a,i,o,s,l=t.width,c=t.height,u=t.sprite,d=t.tileMode,h=t.tiledAdaptiveThreshold,_=dn._posRow,f=dn._posColumn,p=dn._uvRow,m=dn._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===e.SpriteTileMode.Adaptive?dn._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):dn._calculateContinuousDividing(u,l,c,_,f,p,m,g);dn.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,T=t.width*x,C=t.height*b,S=dn._worldMatrix,A=S.elements,M=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,E=t.flipY?-1:1;r=A[0]=M[0]*R,n=A[1]=M[1]*R,a=A[2]=M[2]*R,i=A[4]=M[4]*E,o=A[5]=M[5]*E,s=A[6]=M[6]*E,A[8]=M[8],A[9]=M[9],A[10]=M[10];for(var w=A[12]=M[12]-T*A[0]-C*A[4],P=A[13]=M[13]-T*A[1]-C*A[5],F=A[14]=M[14]-T*A[2]-C*A[6],L=_.length-1,B=f.length-1,D=t._subChunk,I=D.chunk.vertices,O=D.indices,V=0,N=0,k=0,z=D.vertexArea.start;k<B;k++)for(var U=2*k,G=0;G<L;G++){var H=p.get(2*G),W=p.get(2*G+1),j=m.get(U+1);if(!(isNaN(H)||isNaN(W)||isNaN(j))){O[N++]=V,O[N++]=V+1,O[N++]=V+2,O[N++]=V+2,O[N++]=V+1,O[N++]=V+3,V+=4;var K=_.get(G),X=f.get(k),Y=_.get(G+1),q=f.get(k+1);I[z]=r*K+i*X+w,I[z+1]=n*K+o*X+P,I[z+2]=a*K+s*X+F,I[z+9]=r*Y+i*X+w,I[z+10]=n*Y+o*X+P,I[z+11]=a*Y+s*X+F,I[z+18]=r*K+i*q+w,I[z+19]=n*K+o*q+P,I[z+20]=a*K+s*q+F,I[z+27]=r*Y+i*q+w,I[z+28]=n*Y+o*q+P,I[z+29]=a*Y+s*q+F,z+=36}}var Q=t._bounds,Z=Q.min,J=Q.max;Z.set(_.get(0),f.get(0),0),J.set(_.get(L),f.get(B),0),t._bounds.transform(S)},ti.updateUVs=function(e){for(var t=dn._posRow,r=dn._posColumn,n=dn._uvRow,a=dn._uvColumn,i=t.length-1,o=r.length-1,s=e._subChunk,l=s.chunk.vertices,c=0,u=s.vertexArea.start+3;c<o;c++)for(var d=2*c,h=0;h<i;h++){var _=n.get(2*h),f=a.get(d),p=n.get(2*h+1),m=a.get(d+1);isNaN(_)||isNaN(f)||isNaN(p)||isNaN(m)||(l[u]=_,l[u+1]=f,l[u+9]=p,l[u+10]=f,l[u+18]=_,l[u+19]=m,l[u+27]=p,l[u+28]=m,u+=36)}},ti.updateColor=function(e){for(var t=e._subChunk,r=e.color,n=r.r,a=r.g,i=r.b,o=r.a,s=t.chunk.vertices,l=t.vertexArea,c=0,u=l.start+5,d=l.size/9;c<d;++c,u+=9)s[u]=n,s[u+1]=a,s[u+2]=i,s[u+3]=o},ti._calculateAdaptiveDividing=function(e,t,r,n,a,i,o,s,l){var c,u,d,h,_,f,p,m=e.border,g=e._getPositions(),v=g[0],y=v.x,x=v.y,b=g[3],T=b.x,C=b.y,S=e._getUVs(),A=S[0],M=S[1],R=S[2],E=S[3],w=e.width,P=e.height,F=w*m.x,L=w*m.z,B=F+L,D=w-B,I=P*m.w,O=P*m.y,V=I+O,N=P-V;B>=t?(h=3,u=0):D>cQ.zeroTolerance?(h=4+(f=(f=(t-B)/D)%1>=n?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),V>=r?(_=3,d=0):N>cQ.zeroTolerance?(_=4+(p=(p=(r-V)/N)%1>=n?Math.ceil(p):Math.floor(p))-1,d=2):(_=4,d=1);var k=0,z=0;if((h-1)*(_-1)*4>l)return a.add(t*y),a.add(t*T),i.add(r*x),i.add(r*C),o.add(A.x),o.add(E.x),s.add(A.y),s.add(E.y),k+=2,z+=2,uI.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/B,a.add(w*y*c),a.add(F*c),a.add(t-w*(1-T)*c),o.add(A.x),o.add(M.x),o.add(R.x),o.add(E.x),k+=4;break;case 1:a.add(w*y),a.add(F),a.add(t-L),a.add(t-w*(1-T)),o.add(A.x),o.add(M.x),o.add(NaN),o.add(NaN),o.add(R.x),o.add(E.x),k+=4;break;case 2:c=t/(B+f*D),a.add(w*y*c),a.add(F*c),o.add(A.x),o.add(M.x),o.add(M.x),k+=3;for(var U=0,G=f-1;U<G;U++)a.add(F+(U+1)*D*c),o.add(R.x),o.add(M.x),k+=2;a.add(t-L*c),a.add(t-w*(1-T)*c),o.add(R.x),o.add(R.x),o.add(E.x),k+=3}switch(d){case 0:c=r/V,i.add(P*x*c),i.add(O*c),i.add(r-P*(1-C)*c),s.add(A.y),s.add(M.y),s.add(R.y),s.add(E.y),z+=4;break;case 1:i.add(P*x),i.add(O),i.add(r-I),i.add(r-P*(1-C)),s.add(A.y),s.add(M.y),s.add(NaN),s.add(NaN),s.add(R.y),s.add(E.y),z+=4;break;case 2:c=r/(V+p*N),i.add(P*x*c),i.add(O*c),s.add(A.y),s.add(M.y),s.add(M.y),z+=3;for(var H=0,W=p-1;H<W;H++)i.add(O+(H+1)*N*c),s.add(R.y),s.add(M.y),z+=2;i.add(r-I*c),i.add(r-P*(1-C)*c),s.add(R.y),s.add(R.y),s.add(E.y),z+=3}return k*z},ti._calculateContinuousDividing=function(e,t,r,n,a,i,o,s){var l,c,u,d,h,_,f=e.border,p=e._getPositions(),m=p[0],g=m.x,v=m.y,y=p[3],x=y.x,b=y.y,T=e._getUVs(),C=T[0],S=T[1],A=T[2],M=T[3],R=e.width,E=e.height,w=R*f.x,P=R*f.z,F=w+P,L=R-F,B=E*f.w,D=E*f.y,I=B+D,O=E-I;F>=t?(u=3,l=0):L>cQ.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=r?(d=3,c=0):O>cQ.zeroTolerance?(d=4+(0|(_=(r-I)/O)),c=2):(d=4,c=1);var V=0,N=0;if((u-1)*(d-1)*4>s)return n.add(t*g),n.add(t*x),a.add(r*v),a.add(r*b),i.add(C.x),i.add(M.x),o.add(C.y),o.add(M.y),V+=2,N+=2,uI.warn("The number of vertices exceeds the upper limit("+s+")."),V*N;switch(l){case 0:var k=t/F;n.add(R*g*k),n.add(w*k),n.add(t-R*(1-x)*k),i.add(C.x),i.add(S.x),i.add(A.x),i.add(M.x),V+=4;break;case 1:n.add(R*g),n.add(w),n.add(t-P),n.add(t-R*(1-x)),i.add(C.x),i.add(S.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(M.x),V+=4;break;case 2:n.add(R*g),n.add(w),i.add(C.x),i.add(S.x),i.add(S.x),V+=3;for(var z=0|h,U=0;U<z;U++)n.add(w+(U+1)*L),i.add(A.x),i.add(S.x),V+=2;n.add(t-P),n.add(t-R*(1-x)),i.add((A.x-S.x)*(h-z)+S.x),i.add(A.x),i.add(M.x),V+=3}switch(c){case 0:var G=r/I;a.add(E*v*G),a.add(D*G),a.add(r-E*(1-b)*G),o.add(C.y),o.add(S.y),o.add(A.y),o.add(M.y),N+=4;break;case 1:a.add(E*v),a.add(D),a.add(r-B),a.add(r-E*(1-b)),o.add(C.y),o.add(S.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(M.y),N+=4;break;case 2:a.add(E*v),a.add(D),o.add(C.y),o.add(S.y),o.add(S.y),N+=3;for(var H=0|_,W=0;W<H;W++)a.add(D+(W+1)*O),o.add(A.y),o.add(S.y),N+=2;a.add(r-B),a.add(r-E*(1-b)),o.add((A.y-S.y)*(_-H)+S.y),o.add(A.y),o.add(M.y),N+=3}return V*N},ti._worldMatrix=new c8,ti._posRow=new dr,ti._posColumn=new dr,ti._uvRow=new dr,ti._uvColumn=new dr,ti);dn=ul([u7()],dn),(to=cs||(cs={}))[to.Compressed=0]="Compressed",to[to.WithoutTiled=1]="WithoutTiled",to[to.WithTiled=2]="WithTiled";var da=(ts=e.Renderer,us(tl=function(t){var r;return(r=ts.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new c7(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.drawMode=e.SpriteDrawMode.Simple,r._dirtyUpdateFlag|=4,r.setMaterial(r._engine._spriteDefaultMaterial),r._onSpriteChange=r._onSpriteChange.bind(un(r)),r._color._onValueChanged=r._onColorChanged.bind(un(r)),r},ts),(tc=tl.prototype)._updateTransformShaderData=function(e,t,r){ts.prototype._updateTransformShaderData.call(this,e,t,!0)},tc._cloneTo=function(e,t,r){ts.prototype._cloneTo.call(this,e,t,r),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},tc._canBatch=function(e,t){return u3.canBatchSprite(e,t)},tc._batch=function(e,t){u3.batchFor2D(e,t)},tc._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},tc._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},tc._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&co.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~co.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this),this._dirtyUpdateFlag&=-5);var n=e.camera,a=n.engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get(),s=this._subChunk;o.set(this,r,s.chunk.primitive,s.subMesh,this.sprite.texture,s),i.addSubRenderElement(o),n._renderPipeline.pushRenderElement(e,i)}}},tc._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),ts.prototype._onDestroy.call(this),this._sprite=null,this._assembler=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null)},tc._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-9},tc._updateStencilState=function(t,r){var n=this.getMaterial(),a=this._engine._spriteDefaultMaterials;if(n===a[t])this.setMaterial(a[r]);else{var i=n.renderState.stencilState;r===e.SpriteMaskInteraction.None?(i.enabled=!1,i.writeMask=255,i.referenceValue=0,i.compareFunctionFront=i.compareFunctionBack=e.CompareFunction.Always):(i.enabled=!0,i.writeMask=0,i.referenceValue=1,i.compareFunctionFront=i.compareFunctionBack=r===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater)}},tc._onSpriteChange=function(t){switch(t){case ce.texture:this.shaderData.setTexture(tl._textureProperty,this.sprite.texture);break;case ce.size:var r=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=co.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=cl.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=co.WorldVolume);break;case ce.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=cl.WorldVolumeAndUV);break;case ce.region:case ce.atlasRegionOffset:this._dirtyUpdateFlag|=cl.WorldVolumeAndUV;break;case ce.atlasRegion:this._dirtyUpdateFlag|=2;break;case ce.pivot:this._dirtyUpdateFlag|=co.WorldVolume;break;case ce.destroy:this.sprite=null}},tc._onColorChanged=function(){this._dirtyUpdateFlag|=4},ui(tl,[{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=de;break;case e.SpriteDrawMode.Sliced:this._assembler=dt;break;case e.SpriteDrawMode.Tiled:this._assembler=dn}this._assembler.resetData(this),this._dirtyUpdateFlag|=cl.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cl.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=cQ.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cl.VertexData))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=15,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(tl._textureProperty,e.texture)):this.shaderData.setTexture(tl._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:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(t){this._customWidth!==t&&(this._customWidth=t,this._dirtyUpdateFlag|=this._drawMode===e.SpriteDrawMode.Tiled?cl.VertexData:co.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(t){this._customHeight!==t&&(this._customHeight=t,this._dirtyUpdateFlag|=this._drawMode===e.SpriteDrawMode.Tiled?cl.VertexData:co.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=co.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=co.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)}}]),tl);da._textureProperty=uO.getByName("renderer_SpriteTexture"),ul([uu],da.prototype,"_subChunk",void 0),ul([uu],da.prototype,"_drawMode",void 0),ul([ud],da.prototype,"_assembler",void 0),ul([ud],da.prototype,"_tileMode",void 0),ul([ud],da.prototype,"_tiledAdaptiveThreshold",void 0),ul([u_],da.prototype,"_color",void 0),ul([uu],da.prototype,"_sprite",void 0),ul([uu],da.prototype,"_automaticWidth",void 0),ul([uu],da.prototype,"_automaticHeight",void 0),ul([ud],da.prototype,"_customWidth",void 0),ul([ud],da.prototype,"_customHeight",void 0),ul([ud],da.prototype,"_flipX",void 0),ul([ud],da.prototype,"_flipY",void 0),ul([uu],da.prototype,"_onSpriteChange",null),ul([uu],da.prototype,"_onColorChanged",null),(tu=cl||(cl={}))[tu.UV=2]="UV",tu[tu.Color=4]="Color",tu[tu.AutomaticSize=8]="AutomaticSize",tu[tu.WorldVolumeAndUV=2|co.WorldVolume]="WorldVolumeAndUV",tu[tu.VertexData=4|tu.WorldVolumeAndUV]="VertexData",tu[tu.All=15]="All",e.Layer=void 0,(td=e.Layer||(e.Layer={}))[td.Layer0=1]="Layer0",td[td.Layer1=2]="Layer1",td[td.Layer2=4]="Layer2",td[td.Layer3=8]="Layer3",td[td.Layer4=16]="Layer4",td[td.Layer5=32]="Layer5",td[td.Layer6=64]="Layer6",td[td.Layer7=128]="Layer7",td[td.Layer8=256]="Layer8",td[td.Layer9=512]="Layer9",td[td.Layer10=1024]="Layer10",td[td.Layer11=2048]="Layer11",td[td.Layer12=4096]="Layer12",td[td.Layer13=8192]="Layer13",td[td.Layer14=16384]="Layer14",td[td.Layer15=32768]="Layer15",td[td.Layer16=65536]="Layer16",td[td.Layer17=131072]="Layer17",td[td.Layer18=262144]="Layer18",td[td.Layer19=524288]="Layer19",td[td.Layer20=1048576]="Layer20",td[td.Layer21=2097152]="Layer21",td[td.Layer22=4194304]="Layer22",td[td.Layer23=8388608]="Layer23",td[td.Layer24=16777216]="Layer24",td[td.Layer25=33554432]="Layer25",td[td.Layer26=67108864]="Layer26",td[td.Layer27=134217728]="Layer27",td[td.Layer28=268435456]="Layer28",td[td.Layer29=536870912]="Layer29",td[td.Layer30=1073741824]="Layer30",td[td.Layer31=2147483648]="Layer31",td[td.Everything=4294967295]="Everything",td[td.Nothing=0]="Nothing",e.RenderBufferDepthFormat=void 0,(th=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[th.Depth=27]="Depth",th[th.Stencil=28]="Stencil",th[th.DepthStencil=29]="DepthStencil",th[th.Depth16=30]="Depth16",th[th.Depth24=31]="Depth24",th[th.Depth32=32]="Depth32",th[th.Depth24Stencil8=33]="Depth24Stencil8",th[th.Depth32Stencil8=34]="Depth32Stencil8",e.TextureCubeFace=void 0,(t_=e.TextureCubeFace||(e.TextureCubeFace={}))[t_.PositiveX=0]="PositiveX",t_[t_.NegativeX=1]="NegativeX",t_[t_.PositiveY=2]="PositiveY",t_[t_.NegativeY=3]="NegativeY",t_[t_.PositiveZ=4]="PositiveZ",t_[t_.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(tf=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[tf.Never=0]="Never",tf[tf.Less=1]="Less",tf[tf.Equal=2]="Equal",tf[tf.LessEqual=3]="LessEqual",tf[tf.Greater=4]="Greater",tf[tf.NotEqual=5]="NotEqual",tf[tf.GreaterEqual=6]="GreaterEqual",tf[tf.Always=7]="Always",e.TextureUsage=void 0,(tp=e.TextureUsage||(e.TextureUsage={}))[tp.Static=0]="Static",tp[tp.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(tm=e.TextureWrapMode||(e.TextureWrapMode={}))[tm.Clamp=0]="Clamp",tm[tm.Repeat=1]="Repeat",tm[tm.Mirror=2]="Mirror";var di=(us(tg=function(t,r,n,a,i,o){if(void 0===i&&(i=e.TextureFormat.Depth),void 0===o&&(o=1),(s=u0.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=r,s._height=n,s._antiAliasing=o,s._depth=i,a){for(var s,l=uc(a,Array)?a.slice():[a],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(uc(i,u1)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1),s._depthFormat=i.format}else"number"==typeof i&&(s._depthFormat=i);return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(un(s)),s},u0),(tv=tg.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},tv.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,r=e.length;t<r;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},tv._onDestroy=function(){u0.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,r=0,n=t.length;r<n;r++)t[r]._addReferCount(-1);t.length=0,null==(e=this._depthTexture)||e._addReferCount(-1),this._depthTexture=null,this._depth=null},tv._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},tv._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},ui(tg,[{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}}]),tg),ds=(us(ty=function(t,r,n,a,i,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=e.TextureUsage.Static),(s=u1.call(this,t)||this)._mipmap=i,s._width=r,s._height=n,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==e.TextureFormat.Depth||a==e.TextureFormat.DepthStencil||a==e.TextureFormat.Depth16||a==e.TextureFormat.Depth24||a==e.TextureFormat.Depth32||a==e.TextureFormat.Depth24Stencil8||a==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(un(s)),s.filterMode=s._isIntFormat()?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u1),(tx=ty.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=0),void 0===n&&(n=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i),this._isContentLost=!1},tx.setImageSource=function(e,t,r,n,a,i){void 0===t&&(t=0),void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,r,n,a,i),this._isContentLost=!1},tx.getPixelBuffer=function(e,t,r,n,a,i){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,r,n,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i)},tx._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),u1.prototype._rebuild.call(this)},ty),dl=(us(tb=function(t,r,n,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=u1.call(this,t)||this)._mipmap=o,s._width=r,s._height=n,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(un(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u1),(tT=tb.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o,s),this._isContentLost=!1},tT.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tT.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):5===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tT._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),u1.prototype._rebuild.call(this)},ui(tb,[{key:"length",get:function(){return this._length}}]),tb),dc=(us(tC=function(t,r,n,a){var i;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=u1.call(this,t)||this)._mipmap=a,i._width=r,i._height=r,i._format=n,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(un(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},u1),(tS=tC.prototype).setPixelBuffer=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,r,n,a,i,o),this._isContentLost=!1},tS.setImageSource=function(e,t,r,n,a,i,o){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,r,n,a,i,o),this._isContentLost=!1},tS.getPixelBuffer=function(e,t,r,n,a,i,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,r):6===s?this._platformTexture.getPixelBuffer(e,t,r,n,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,r,n,a,i,o)},tS._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),u1.prototype._rebuild.call(this)},tC),du=((tA=function(){}).recreateTextureIfNeeded=function(e,t,r,n,a,i,o,s){return t?(t.width!==r||t.height!==n||t.format!==a||t.mipmapCount>1!==i)&&(t.destroy(!0),(t=new ds(e,r,n,a,i)).isGCIgnored=!0):(t=new ds(e,r,n,a,i)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},tA.recreateRenderTargetIfNeeded=function(e,t,r,n,a,i,o,s,l,c,u){var d,h,_=null==(p=t)?void 0:p.getColorTexture(0),f=a?tA.recreateTextureIfNeeded(e,_,r,n,a,s,c,u):null;if(o){var p,m,g,v=null==(m=t)?void 0:m.depthTexture,y=i?tA.recreateTextureIfNeeded(e,v,r,n,i,s,c,u):null;(_!==f||v!==y)&&(null==(g=t)||g.destroy(!0),(t=new di(e,r,n,f,y,l)).isGCIgnored=!0)}else(_!==f||(null==(d=t)?void 0:d._depthFormat)!==i||t.antiAliasing!==l)&&(null==(h=t)||h.destroy(!0),(t=new di(e,r,n,f,i,l)).isGCIgnored=!0);return t},tA.blitTexture=function(e,t,r,n,a,i,o){void 0===n&&(n=0),void 0===a&&(a=tA.defaultViewport),void 0===i&&(i=null),void 0===o&&(o=0);var s=e._basicResources,l=r?s.flipYBlitMesh:s.blitMesh,c=i||s.blitMaterial,u=e._hardwareRenderer,d=e._renderContext;d.flipProjection=!!r,u.activeRenderTarget(r,a,d.flipProjection,0);var h=tA._rendererShaderData;h.setTexture(tA._blitTextureProperty,t),h.setFloat(tA._blitMipLevelProperty,n),tA._texelSize.set(1/t.width,1/t.height,t.width,t.height),h.setVector4(tA._blitTexelSizeProperty,tA._texelSize);var _=c.shader.subShaders[0].passes[o],f=u$._compileMacros;uR.unionCollection(d.camera._globalShaderMacro,c.shaderData._macroCollection,f);var p=_._getShaderProgram(e,f);p.bind(),p.groupingOtherUniformBlock(),p.uploadAll(p.rendererUniformBlock,h),p.uploadAll(p.materialUniformBlock,c.shaderData),p.uploadUnGroupTextures(),(_._renderState||c.renderState)._applyStates(e,!1,_._renderStateDataMap,c.shaderData),u.drawPrimitive(l._primitive,l.subMesh,p)},tA);du._blitTextureProperty=uO.getByName("renderer_BlitTexture"),du._blitMipLevelProperty=uO.getByName("renderer_BlitMipLevel"),du._blitTexelSizeProperty=uO.getByName("renderer_texelSize"),du._rendererShaderData=new u2(cr.Renderer),du._texelSize=new c6,du.defaultViewport=new c6(0,0,1,1);var dd=function(){this.position=new cZ,this.isOrthographic=!1,this.viewMatrix=new c8,this.projectionMatrix=new c8,this.viewProjectionMatrix=new c8,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new cZ};e.CameraClearFlags=void 0,(tM=e.CameraClearFlags||(e.CameraClearFlags={}))[tM.None=0]="None",tM[tM.Color=1]="Color",tM[tM.Depth=2]="Depth",tM[tM.Stencil=4]="Stencil",tM[tM.ColorDepth=3]="ColorDepth",tM[tM.ColorStencil=5]="ColorStencil",tM[tM.DepthStencil=6]="DepthStencil",tM[tM.All=7]="All",e.CameraType=void 0,(tR=e.CameraType||(e.CameraType={}))[tR.Normal=0]="Normal",tR[tR.XRCenterCamera=1]="XRCenterCamera",tR[tR.XRLeftCamera=2]="XRLeftCamera",tR[tR.XRRightCamera=4]="XRRightCamera",e.DepthTextureMode=void 0,(tE=e.DepthTextureMode||(e.DepthTextureMode={}))[tE.None=0]="None",tE[tE.PrePass=1]="PrePass",e.Downsampling=void 0,(tw=e.Downsampling||(e.Downsampling={}))[tw.None=1]="None",tw[tw.TwoX=2]="TwoX",tw[tw.FourX=4]="FourX",e.MSAASamples=void 0,(tP=e.MSAASamples||(e.MSAASamples={}))[tP.None=1]="None",tP[tP.TwoX=2]="TwoX",tP[tP.FourX=4]="FourX",tP[tP.EightX=8]="EightX",e.ReplacementFailureStrategy=void 0,(tF=e.ReplacementFailureStrategy||(e.ReplacementFailureStrategy={}))[tF.KeepOriginalShader=0]="KeepOriginalShader",tF[tF.DoNotRender=1]="DoNotRender";var dh=function(){};dh.tempVec4=new c6,dh.tempVec3=new cZ,dh.tempVec2=new c9,e.Camera=(us(tL=function(t){(r=u4.call(this,t)||this).enableFrustumCulling=!0,r.clearFlags=e.CameraClearFlags.All,r.cullingMask=e.Layer.Everything,r.depthTextureMode=e.DepthTextureMode.None,r.opaqueTextureDownsampling=e.Downsampling.TwoX,r.msaaSamples=e.MSAASamples.None,r._cameraType=e.CameraType.Normal,r._globalShaderMacro=new uR,r._frustum=new c2,r._virtualCamera=new dd,r._replacementShader=null,r._replacementSubShaderTag=null,r._replacementFailureStrategy=null,r._cameraIndex=-1,r._priority=0,r._shaderData=new u2(cr.Camera),r._isCustomViewMatrix=!1,r._isCustomProjectionMatrix=!1,r._fieldOfView=45,r._orthographicSize=10,r._isProjectionDirty=!0,r._isInvProjMatDirty=!0,r._customAspectRatio=void 0,r._renderTarget=null,r._depthBufferParams=new c6,r._opaqueTextureEnabled=!1,r._enableHDR=!1,r._enablePostProcess=!1,r._viewport=new c6(0,0,1,1),r._pixelViewport=new ue(0,0,0,0),r._inverseProjectionMatrix=new c8,r._invViewProjMat=new c8;var r,n=r.entity.transform;return r._transform=n,r._isViewMatrixDirty=n.registerWorldChangeFlag(),r._isInvViewProjDirty=n.registerWorldChangeFlag(),r._frustumChangeFlag=n.registerWorldChangeFlag(),r._renderPipeline=new dC(un(r)),r._addResourceReferCount(r.shaderData,1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(un(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},u4),(tB=tL.prototype).resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},tB.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},tB.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},tB.worldToViewportPoint=function(e,t){var r=dh.tempVec3,n=dh.tempVec4;cZ.transformCoordinate(e,this.viewMatrix,r),cZ.transformToVec4(r,this.projectionMatrix,n);var a=n.w;return t.set((n.x/a+1)*.5,(1-n.y/a)*.5,-r.z),t},tB.viewportToWorldPoint=function(e,t){var r,n=this.nearClipPlane,a=this.farClipPlane,i=1/(n-a);if(this.isOrthographic)r=-(2*e.z)*i+(a+n)*i;else{var o=e.z;r=(-o*(n+a)*i+2*n*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(r+1)/2,this._getInvViewProjMat(),t),t},tB.viewportPointToRay=function(e,t){var r=this._getInvViewProjMat(),n=this._innerViewportToWorldPoint(e.x,e.y,0,r,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-cQ.zeroTolerance,r,t.direction);return cZ.subtract(a,n,a),a.normalize(),t},tB.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},tB.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},tB.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},tB.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},tB.screenPointToRay=function(e,t){var r=dh.tempVec2;return this.screenToViewportPoint(e,r),this.viewportPointToRay(r,t)},tB.render=function(t,r){void 0===r&&(r=0);var n,a=this.engine._renderContext,i=this._virtualCamera,o=this.entity.transform;c8.multiply(this.projectionMatrix,this.viewMatrix,i.viewProjectionMatrix),i.position.copyFrom(o.worldPosition),i.isOrthographic&&i.forward.copyFrom(o.worldForward),a.camera=this,a.virtualCamera=i,a.replacementShader=this._replacementShader,a.replacementTag=this._replacementSubShaderTag,a.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(i.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),uR.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!this.engine._hardwareRenderer.isWebGL2&&(r=0,uI.error("mipLevel only take effect in WebGL2.0")),this._cameraType!==e.CameraType.Normal&&(n=this.engine.xrManager._getCameraClearFlagsMask(this._cameraType)),this._renderPipeline.render(a,t,r,n),this._engine._renderCount++},tB.setReplacementShader=function(t,r,n){void 0===n&&(n=e.ReplacementFailureStrategy.KeepOriginalShader),this._replacementShader=t,this._replacementSubShaderTag="string"==typeof r?uz.getByName(r):r,this._replacementFailureStrategy=n},tB.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},tB._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},tB._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},tB._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2?e.TextureFormat.R11G11B10_UFloat:e.TextureFormat.R16G16B16A16:e.TextureFormat.R8G8B8A8},tB._onDestroy=function(){var e;u4.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this._addResourceReferCount(this.shaderData,-1),this._viewport._onValueChanged=null,this.engine.canvas._sizeUpdateFlagManager.removeListener(this._onPixelViewportChanged),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},tB._updatePixelViewport=function(){var e,t,r=this._renderTarget;if(r)e=r.width,t=r.height;else{var n=this.engine.canvas;e=n.width,t=n.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},tB._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},tB._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},tB._innerViewportToWorldPoint=function(e,t,r,n,a){var i=dh.tempVec3;return i.set(2*e-1,1-2*t,2*r-1),cZ.transformCoordinate(i,n,a),a},tB._updateShaderData=function(){var t=this.shaderData,r=this._transform;t.setMatrix(e.Camera._inverseViewMatrixProperty,r.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,r.worldPosition),t.setVector3(e.Camera._cameraForwardProperty,r.worldForward),t.setVector3(e.Camera._cameraUpProperty,r.worldUp);var n=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;n.set(1-a,a,0,0),t.setVector4(e.Camera._cameraDepthBufferParamsProperty,n)},tB._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,c8.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},tB._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,c8.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},tB._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},tB._checkMainCanvasAntialiasWaste=function(){this._phasedActiveInScene&&this.independentCanvasEnabled&&c6.equals(this._viewport,du.defaultViewport)&&uI.warn("Camera use independent canvas and viewport cover the whole screen, it is recommended to disable antialias, depth and stencil to save memory when create engine.")},ui(tL,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){return!!this.enableHDR||!!this.enablePostProcess&&!!this.scene._postProcessManager.hasActiveEffect||this.opaqueTextureEnabled&&!this._renderTarget}},{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._virtualCamera.nearClipPlane},set:function(e){this._virtualCamera.nearClipPlane=e,this._projectionMatrixChange()}},{key:"farClipPlane",get:function(){return this._virtualCamera.farClipPlane},set:function(e){this._virtualCamera.farClipPlane=e,this._projectionMatrixChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projectionMatrixChange()}},{key:"aspectRatio",get:function(){var e,t=this.pixelViewport;return null!=(e=this._customAspectRatio)?e:t.width/t.height},set:function(e){this._customAspectRatio=e,this._projectionMatrixChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e)}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._phasedActiveInScene&&(this.scene._componentsManager._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projectionMatrixChange(),e?this.shaderData.enableMacro("CAMERA_ORTHOGRAPHIC"):this.shaderData.disableMacro("CAMERA_ORTHOGRAPHIC")}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projectionMatrixChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(!this._isViewMatrixDirty.flag||this._isCustomViewMatrix)return e;this._isViewMatrixDirty.flag=!1;var t=this._transform;return c8.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert(),e},set:function(e){this._virtualCamera.viewMatrix.copyFrom(e),this._isCustomViewMatrix=!0,this._viewMatrixChange()}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix;if(!this._isProjectionDirty||this._isCustomProjectionMatrix)return t;this._isProjectionDirty=!1;var r=this.aspectRatio;if(e.isOrthographic){var n=this._orthographicSize*r,a=this._orthographicSize;c8.ortho(-n,n,-a,a,this.nearClipPlane,this.farClipPlane,t)}else c8.perspective(cQ.degreeToRadian(this._fieldOfView),r,this.nearClipPlane,this.farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isCustomProjectionMatrix=!0,this._projectionMatrixChange()}},{key:"enableHDR",get:function(){return this._enableHDR},set:function(t){if(this.enableHDR!==t){var r=this.engine._hardwareRenderer,n=r.isWebGL2||r.canIUse(e.GLCapabilityType.textureHalfFloat);if(t&&!n){uI.warn("Can't enable HDR in this device.");return}this._enableHDR=t,this._checkMainCanvasAntialiasWaste()}}},{key:"enablePostProcess",get:function(){return this._enablePostProcess},set:function(e){this._enablePostProcess!==e&&(this._enablePostProcess=e,this._checkMainCanvasAntialiasWaste())}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget!==e&&(this._renderTarget&&this._addResourceReferCount(this._renderTarget,-1),e&&this._addResourceReferCount(e,1),this._renderTarget=e,this._onPixelViewportChanged())}}]),tL._cameraDepthTextureProperty=uO.getByName("camera_DepthTexture"),tL._cameraOpaqueTextureProperty=uO.getByName("camera_OpaqueTexture"),tL._inverseViewMatrixProperty=uO.getByName("camera_ViewInvMat"),tL._cameraPositionProperty=uO.getByName("camera_Position"),tL._cameraForwardProperty=uO.getByName("camera_Forward"),tL._cameraUpProperty=uO.getByName("camera_Up"),tL._cameraDepthBufferParamsProperty=uO.getByName("camera_DepthBufferParams"),tL),ul([u_],e.Camera.prototype,"_frustum",void 0),ul([uu],e.Camera.prototype,"_renderPipeline",void 0),ul([uu],e.Camera.prototype,"_virtualCamera",void 0),ul([uu],e.Camera.prototype,"_cameraIndex",void 0),ul([uu],e.Camera.prototype,"_frustumChangeFlag",void 0),ul([uu],e.Camera.prototype,"_transform",void 0),ul([uu],e.Camera.prototype,"_isViewMatrixDirty",void 0),ul([uu],e.Camera.prototype,"_isInvViewProjDirty",void 0),ul([u_],e.Camera.prototype,"_viewport",void 0),ul([u_],e.Camera.prototype,"_pixelViewport",void 0),ul([u_],e.Camera.prototype,"_inverseProjectionMatrix",void 0),ul([u_],e.Camera.prototype,"_invViewProjMat",void 0),ul([uu],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=ul([u5(u6,e.DependentMode.CheckOnly)],e.Camera),e.BackgroundMode=void 0,(tD=e.BackgroundMode||(e.BackgroundMode={}))[tD.SolidColor=0]="SolidColor",tD[tD.Sky=1]="Sky",tD[tD.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(tI=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[tI.AspectFitWidth=0]="AspectFitWidth",tI[tI.AspectFitHeight=1]="AspectFitHeight",tI[tI.Fill=2]="Fill";var d_=function(e){this.engine=e},df=((tV=(tO=function(){this._projectionParams=new c6,this.flipProjection=!1,this.rendererUpdateFlag=0}).prototype).applyVirtualCamera=function(e,t){this.virtualCamera=e,this.flipProjection=t;var r=this.camera.shaderData,n=e.viewMatrix,a=e.projectionMatrix,i=e.viewProjectionMatrix;t&&(c8.multiply(tO._flipYMatrix,a,tO._flipYProjectionMatrix),c8.multiply(tO._flipYProjectionMatrix,n,tO._flipYViewProjectionMatrix),a=tO._flipYProjectionMatrix,i=tO._flipYViewProjectionMatrix),this.viewMatrix=n,this.projectionMatrix=a,this.viewProjectionMatrix=i,r.setMatrix(tO._viewMatrixProperty,n),r.setMatrix(tO._projectionMatrixProperty,a),r.setMatrix(tO.vpMatrixProperty,i);var o=this._projectionParams;o.set(t?-1:1,e.nearClipPlane,e.farClipPlane,0),r.setVector4(tO._cameraProjectionProperty,o)},tV.garbageCollection=function(){this.camera=null},tO);df.vpMatrixProperty=uO.getByName("camera_VPMat"),df.pipelineStageKey=uz.getByName("pipelineStage"),df._flipYMatrix=new c8(1,0,0,0,0,-1),df._cameraProjectionProperty=uO.getByName("camera_ProjectionParams"),df._viewMatrixProperty=uO.getByName("camera_ViewMat"),df._projectionMatrixProperty=uO.getByName("camera_ProjMat"),df._flipYProjectionMatrix=new c8,df._flipYViewProjectionMatrix=new c8,(tN=cc||(cc={}))[tN.None=0]="None",tN[tN.WorldMatrix=1]="WorldMatrix",tN[tN.viewMatrix=2]="viewMatrix",tN[tN.ProjectionMatrix=4]="ProjectionMatrix",tN[tN.WorldViewMatrix=3]="WorldViewMatrix",tN[tN.viewProjectionMatrix=6]="viewProjectionMatrix",tN[tN.All=7]="All";var dp=((tz=(tk=function(){this.allSpriteMasks=new dr,this.preMaskLayer=0}).prototype).addSpriteMask=function(e){e._maskIndex=this.allSpriteMasks.length,this.allSpriteMasks.add(e)},tz.removeSpriteMask=function(e){var t=this.allSpriteMasks.deleteByIndex(e._maskIndex);t&&(t._maskIndex=e._maskIndex),e._maskIndex=-1},tz.buildMaskRenderElement=function(e,t,r){var n=this.preMaskLayer,a=e.component._maskLayer;if(n!==a){for(var i=this.allSpriteMasks,o=n&a,s=n&~a,l=i._elements,c=0,u=i.length;c<u;c++){var d=l[c],h=d.influenceLayers;!(h&o)&&(h&a?t.pushRenderElement(d._renderElement):h&s&&r.pushRenderElement(d._renderElement))}this.preMaskLayer=a}},tz.destroy=function(){this.allSpriteMasks.length=0},tk.getMaskIncrementRenderQueue=function(){return tk._maskIncrementRenderQueue||(tk._maskIncrementRenderQueue=new dm(e.RenderQueueType.Transparent))},tk.getMaskDecrementRenderQueue=function(){return tk._maskDecrementRenderQueue||(tk._maskDecrementRenderQueue=new dm(e.RenderQueueType.Transparent))},tk),dm=((tG=(tU=function(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[]}).prototype).pushRenderElement=function(e){this.elements.push(e)},tG.sortBatch=function(e,t){this._sort(e),this._batch(t)},tG.render=function(t,r,n){void 0===n&&(n=0);var a=this.batchedSubElements,i=a.length;if(0!==i){var o=t.rendererUpdateFlag,s=t.camera,l=s.engine,c=s.scene,u=s.instanceId,d=s.shaderData,h=c.instanceId,_=c.shaderData,f=l._renderCount,p=l._hardwareRenderer,m=df.pipelineStageKey,g=this.renderQueueType;c._maskManager.preMaskLayer=0;for(var v=0;v<i;v++){var y=a[v],x=y.component,b=y.batched;o&cc.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(t,!1,b),x._batchedTransformShaderData=b):o&cc.ProjectionMatrix&&x._updateTransformShaderData(t,!0,b),x._maskInteraction!==e.SpriteMaskInteraction.None&&this._drawMask(t,r,y);var T=u$._compileMacros,C=y.primitive,S=y.material,A=y.shaderPasses,M=y.shaderData,R=x.shaderData,E=x.instanceId,w=S.shaderData,P=S.instanceId,F=S.renderStates;if(uR.unionCollection(x._globalShaderMacro,w._macroCollection,T),0!==n){var L=1===n?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate,B=S.renderState.stencilState;B.passOperationFront=L,B.passOperationBack=L}for(var D=0,I=A.length;D<I;D++){var O,V,N=A[D];if(N.getTagValue(m)===r&&(null!=(O=N._renderState)?O:F[D]).renderQueueType===g){var k=N._getShaderProgram(l,T);if(k.isValid){var z=k.bind();f!==k._uploadRenderCount?(k.groupingOtherUniformBlock(),k.uploadAll(k.sceneUniformBlock,_),k.uploadAll(k.cameraUniformBlock,d),k.uploadAll(k.rendererUniformBlock,R),k.uploadAll(k.materialUniformBlock,w),M&&k.uploadAll(k.renderElementUniformBlock,M),k.uploadUnGroupTextures(),k._uploadSceneId=h,k._uploadCameraId=u,k._uploadRendererId=E,k._uploadMaterialId=P,k._uploadRenderCount=f):(k._uploadSceneId!==h?(k.uploadAll(k.sceneUniformBlock,_),k._uploadSceneId=h):z&&k.uploadTextures(k.sceneUniformBlock,_),k._uploadCameraId!==u?(k.uploadAll(k.cameraUniformBlock,d),k._uploadCameraId=u):z&&k.uploadTextures(k.cameraUniformBlock,d),k._uploadRendererId!==E?(k.uploadAll(k.rendererUniformBlock,R),k._uploadRendererId=E):z&&k.uploadTextures(k.rendererUniformBlock,R),k._uploadMaterialId!==P?(k.uploadAll(k.materialUniformBlock,w),k._uploadMaterialId=P):z&&k.uploadTextures(k.materialUniformBlock,w),M&&k.uploadAll(k.renderElementUniformBlock,M),z&&k.uploadUnGroupTextures()),(null!=(V=N._renderState)?V:F[D])._applyStates(l,x.entity.transform._isFrontFaceInvert(),N._renderStateDataMap,S.shaderData),p.drawPrimitive(C,y.subPrimitive,k)}}}}}},tG.clear=function(){this.elements.length=0,this.batchedSubElements.length=0},tG.destroy=function(){},tG._sort=function(e){uv._quickSort(this.elements,0,this.elements.length,e)},tG._batch=function(e){e.batch(this)},tG._drawMask=function(e,t,r){var n=dp.getMaskIncrementRenderQueue();n.renderQueueType=this.renderQueueType,n.clear();var a=dp.getMaskDecrementRenderQueue();a.renderQueueType=this.renderQueueType,a.clear();var i=e.camera,o=i.engine;i.scene._maskManager.buildMaskRenderElement(r,n,a),n._batch(o._batcherManager),n.render(e,t,1),a._batch(o._batcherManager),a.render(e,t,2)},tU.compareForOpaque=function(e,t){return e.priority-t.priority||e.distanceForSort-t.distanceForSort},tU.compareForTransparent=function(e,t){return e.priority-t.priority||t.distanceForSort-e.distanceForSort},tU);(tH=cu||(cu={}))[tH.No=0]="No",tH[tH.Increment=1]="Increment",tH[tH.Decrement=2]="Decrement";var dg=function(){this.virtualCamera=new dd,this.cullPlanes=[new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ),new c1(new cZ)],this.splitBoundSphere=new cJ(new cZ,0)};e.ShadowResolution=void 0,(tW=e.ShadowResolution||(e.ShadowResolution={}))[tW.Low=0]="Low",tW[tW.Medium=1]="Medium",tW[tW.High=2]="High",tW[tW.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tj=e.ShadowType||(e.ShadowType={}))[tj.None=0]="None",tj[tj.Hard=1]="Hard",tj[tj.SoftLow=2]="SoftLow",tj[tj.SoftHigh=3]="SoftHigh",(tK=cd||(cd={}))[tK.FarBottomLeft=0]="FarBottomLeft",tK[tK.FarTopLeft=1]="FarTopLeft",tK[tK.FarTopRight=2]="FarTopRight",tK[tK.FarBottomRight=3]="FarBottomRight",tK[tK.nearBottomLeft=4]="nearBottomLeft",tK[tK.nearTopLeft=5]="nearTopLeft",tK[tK.nearTopRight=6]="nearTopRight",tK[tK.nearBottomRight=7]="nearBottomRight",tK[tK.unknown=8]="unknown";var dv=((tX=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}},tX.shadowDepthFormat=function(t,r){return r?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},tX.cullingRenderBounds=function(e,t,r){for(var n=e.min,a=e.max,i=0;i<t;i++){var o=r[i],s=o.normal;if(s.x*(s.x>=0?a.x:n.x)+s.y*(s.y>=0?a.y:n.y)+s.z*(s.z>=0?a.z:n.z)<-o.distance)return!1}return!0},tX.shadowCullFrustum=function(e,t,r,n){var a=r._entity.layer;e.camera.cullingMask&a&&t.cullingMask&a&&r.castShadows&&tX.cullingRenderBounds(r.bounds,n.cullPlaneCount,n.cullPlanes)&&(r._prepareRender(e),r._renderFrameCount=r.engine.time.frameCount)},tX.getBoundSphereByFrustum=function(e,t,r,n,a){var i,o,s=r.aspectRatio,l=r.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(cQ.degreeToRadian(l)/2),u=c*c,d=t-e,h=t+e;u>d/h?(i=t,o=t*c):(i=.5*h*(1+u),o=.5*Math.sqrt(d*d+2*(t*t+e*e)*u+h*h*u*u));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,cZ.scale(n,i,_),cZ.add(r.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},tX.getDirectionLightShadowCullPlanes=function(t,r,n,a,i){var o=tX._frustumCorners,s=tX._backPlaneFaces,l=tX._frustumPlaneNeighbors,c=tX._frustumTwoPlaneCorners,u=tX._edgePlanePoint2,d=i.cullPlanes,h=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),m=t.getPlane(e.FrustumFace.Bottom),g=t.getPlane(e.FrustumFace.Top),v=tX._adjustNearPlane,y=tX._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(r-n),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),c0.intersectionPointThreePlanes(v,m,p,o[7]),c0.intersectionPointThreePlanes(v,g,p,o[6]),c0.intersectionPointThreePlanes(v,g,f,o[5]),c0.intersectionPointThreePlanes(v,m,f,o[4]),c0.intersectionPointThreePlanes(y,m,p,o[3]),c0.intersectionPointThreePlanes(y,g,p,o[2]),c0.intersectionPointThreePlanes(y,g,f,o[1]),c0.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var T=void 0;switch(b){case e.FrustumFace.Near:T=v;break;case e.FrustumFace.Far:T=y;break;default:T=t.getPlane(b)}0>cZ.dot(T.normal,a)&&(d[x].copyFrom(T),s[x]=b,x++)}for(var C=x,S=0;S<x;S++)for(var A=s[S],M=l[A],R=0;R<4;R++){for(var E=M[R],w=!0,P=0;P<x;P++)if(E==s[P]){w=!1;break}if(w){var F=c[A][E],L=o[F[0]],B=o[F[1]];cZ.add(L,a,u),c1.fromPoints(L,B,u,d[C++])}}i.cullPlaneCount=C},tX.getDirectionalLightMatrices=function(e,t,r,n,a,i,o,s){var l=o.splitBoundSphere;o.resolution=i;var c=l.center,u=l.radius,d=i/2,h=u*d/(d-tX.atlasBorderSize),_=2*h,f=i/_,p=_/i,m=Math.ceil(cZ.dot(c,e)*f)*p,g=Math.ceil(cZ.dot(c,t)*f)*p,v=cZ.dot(c,r);c.x=e.x*m+t.x*g+r.x*v,c.y=e.y*m+t.y*g+r.y*v,c.z=e.z*m+t.z*g+r.z*v;var y=o.virtualCamera,x=y.position,b=y.viewMatrix,T=y.projectionMatrix;cZ.scale(r,u+a,x),cZ.subtract(c,x,x),c8.lookAt(x,c,e,b),c8.ortho(-h,h,-h,h,0,2*u+a,T);var C=y.viewProjectionMatrix;c8.multiply(T,b,C),uv._floatMatrixMultiply(tX._shadowMapCoordMatrix,C.elements,0,s,16*n)},tX.getMaxTileResolutionInAtlas=function(e,t,r){for(var n=Math.min(e,t),a=Math.floor(e/n)*Math.floor(t/n);a<r;)a=Math.floor(e/(n=Math.floor(n>>1)))*Math.floor(t/n);return n},tX.getShadowBias=function(t,r,n,a){var i=2/r.elements[0]/n,o=-t.shadowBias*i,s=-t.shadowNormalBias*i;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),a.set(o,s)},tX.applySliceTransform=function(e,t,r,n,a,i){var o=tX._tempMatrix0,s=o.elements,l=1/t,c=1/r,u=a.x*l,d=a.y*c;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=u,s[13]=d,s[14]=0,s[15]=1;var h=16*n;uv._floatMatrixMultiply(o,i,h,i,h)},tX.getScaleAndBiasForLinearDistanceFade=function(e,t,r){if(t<1e-4){r.z=1e3,r.w=-(1e3*e);return}t=1-t;var n=(t*=t)*e,a=e-n;r.z=1/a,r.w=-n/a},tX);dv._tempMatrix0=new c8,dv._shadowMapCoordMatrix=new c8(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),dv._frustumCorners=[new cZ,new cZ,new cZ,new cZ,new cZ,new cZ,new cZ,new cZ],dv._adjustNearPlane=new c1(new cZ),dv._adjustFarPlane=new c1(new cZ),dv._backPlaneFaces=[,,,,,],dv._edgePlanePoint2=new cZ,dv._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]],dv._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]]],dv.atlasBorderSize=4,e.ShadowCascadesMode=void 0,(tY=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tY.NoCascades=1]="NoCascades",tY[tY.TwoCascades=2]="TwoCascades",tY[tY.FourCascades=4]="FourCascades";var dy=function(t){function r(n){var a;return(a=t.call(this,n.engine)||this)._shadowMapSize=new c6,a._shadowBias=new c9,a._shadowSliceData=new dg,a._lightUp=new cZ,a._lightSide=new cZ,a._splitBoundSpheres=new Float32Array(4*r._maxCascades),a._shadowMatrices=new Float32Array((r._maxCascades+1)*16),a._shadowInfos=new c6,a._viewportOffsets=[new c9,new c9,new c9,new c9],a._camera=n,a._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}us(r,t);var n=r.prototype;return n.onRender=function(e){var t=this._camera.scene._lightManager._sunlight;this._updateShadowSettings(),this._renderDirectShadowMap(e,t),this._updateReceiversShaderData(t)},n._renderDirectShadowMap=function(t,n){var a,i,o=this.engine,s=this._camera,l=this._viewportOffsets,c=this._shadowSliceData,u=this._splitBoundSpheres,d=this._shadowMatrices,h=s._renderPipeline._cullingResults,_=h.opaqueQueue,f=h.alphaTestQueue,p=s.scene,m=p._componentsManager,g=o._hardwareRenderer,v=p.shadowCascades,y=r._cascadesSplitDistance,x=c.splitBoundSphere,b=r._tempMatrix0,T=b.elements,C=this._lightUp,S=this._lightSide,A=c.virtualCamera.forward,M=this._shadowMapSize,R=M.z,E=M.w,w=this._shadowMapFormat;i=this._supportDepthTexture?(a=du.recreateRenderTargetIfNeeded(o,this._renderTarget,R,E,null,w,!0,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear)).depthTexture:(a=du.recreateRenderTargetIfNeeded(o,this._renderTarget,R,E,w,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear)).getColorTexture(0),o._hardwareRenderer._isWebGL2&&(i.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=a,this._depthTexture=i,g.activeRenderTarget(a,r._viewport,t.flipProjection,0),this._supportDepthTexture?g.clearRenderTarget(o,e.CameraClearFlags.Depth,null):g.clearRenderTarget(o,e.CameraClearFlags.All,r._clearColor),c8.rotationQuaternion(n.entity.transform.worldRotationQuaternion,b),S.set(T[0],T[1],T[2]),C.set(T[4],T[5],T[6]),A.set(-T[8],-T[9],-T[10]);var P=r._tempVector;P.copyFrom(s.entity.transform.worldForward);for(var F=this._shadowTileResolution,L=0;L<v;L++){dv.getBoundSphereByFrustum(y[L],y[L+1],s,P,c),dv.getDirectionLightShadowCullPlanes(s._frustum,y[L],s.nearClipPlane,A,c),dv.getDirectionalLightMatrices(C,S,A,L,n.shadowNearPlane,F,c,d),v>1&&dv.applySliceTransform(F,R,E,L,this._viewportOffsets[L],d),this._updateSingleShadowCasterShaderData(n,c,t);var B=x.center,D=x.radius,I=4*L;u[I]=B.x,u[I+1]=B.y,u[I+2]=B.z,u[I+3]=D*D,_.clear(),f.clear();for(var O=m._renderers,V=O._elements,N=O.length-1;N>=0;--N)dv.shadowCullFrustum(t,n,V[N],c);if(_.elements.length||f.elements.length){o._renderCount++;var k=o._batcherManager;_.sortBatch(dm.compareForOpaque,k),f.sortBatch(dm.compareForOpaque,k);var z=l[L],U=z.x,G=z.y;g.setGlobalDepthBias(1,1),g.viewport(U,G,F,F),g.scissor(U+1,G+1,F-2,F-2),_.render(t,e.PipelineStage.ShadowCaster),f.render(t,e.PipelineStage.ShadowCaster),g.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var t=this._camera,n=t.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=n.shadowCascades,s=Math.min(n.shadowDistance,t.farClipPlane);if(dv.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),n.shadowFadeBorder,this._shadowInfos),this._shadowInfos.x=e.shadowStrength,o>1)for(var l=4*o,c=a.length;l<c;l++)a[l]=0;for(var u=16*o,d=i.length;u<d;u++)i[u]=0;var h=n.shaderData;h.setFloatArray(r._shadowMatricesProperty,this._shadowMatrices),h.setVector4(r._shadowInfosProperty,this._shadowInfos),h.setTexture(r._shadowMapsProperty,this._depthTexture),h.setFloatArray(r._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(r._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(t){var n=r._cascadesSplitDistance,a=this._camera.scene,i=a.shadowTwoCascadeSplits,o=a.shadowFourCascadeSplits,s=a.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,d=l.fieldOfView;n[0]=c;var h=t-c,_=Math.tan(.5*cQ.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*i,f),n[2]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.FourCascades:n[1]=this._getFarWithRadius(c+h*o.x,f),n[2]=this._getFarWithRadius(c+h*o.y,f),n[3]=this._getFarWithRadius(c+h*o.z,f),n[4]=this._getFarWithRadius(t,f)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var t=this._camera,r=t.scene,n=dv.shadowDepthFormat(r.shadowResolution,this._supportDepthTexture),a=dv.shadowResolution(r.shadowResolution),i=r.shadowCascades,o=Math.min(r.shadowDistance,t.farClipPlane);if(this._getCascadesSplitDistance(o),n!==this._shadowMapFormat||a!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=a,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=a,this._shadowMapSize.set(1/a,1/a,a,a);else{var s=dv.getMaxTileResolutionInAtlas(a,a,i);this._shadowTileResolution=s;var l=2*s,c=i==e.ShadowCascadesMode.TwoCascades?s:2*s;this._shadowMapSize.set(1/l,1/c,l,c)}this._renderTarget=null;var u=this._viewportOffsets,d=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:u[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:u[0].set(0,0),u[1].set(d,0);break;case e.ShadowCascadesMode.FourCascades:u[0].set(0,0),u[1].set(d,0),u[2].set(0,d),u[3].set(d,d)}}},n._updateSingleShadowCasterShaderData=function(e,t,n){var a=t.virtualCamera;dv.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(r._lightShadowBiasProperty,this._shadowBias),i.setVector3(r._lightDirectionProperty,e.direction),n.rendererUpdateFlag|=cc.viewProjectionMatrix,n.applyVirtualCamera(a,!0)},r}(d_);dy._lightShadowBiasProperty=uO.getByName("scene_ShadowBias"),dy._lightDirectionProperty=uO.getByName("scene_LightDirection"),dy._shadowMatricesProperty=uO.getByName("scene_ShadowMatrices"),dy._shadowMapSize=uO.getByName("scene_ShadowMapSize"),dy._shadowInfosProperty=uO.getByName("scene_ShadowInfo"),dy._shadowMapsProperty=uO.getByName("scene_ShadowMap"),dy._shadowSplitSpheresProperty=uO.getByName("scene_ShadowSplitSpheres"),dy._maxCascades=4,dy._cascadesSplitDistance=Array(dy._maxCascades+1),dy._viewport=new c6(0,0,1,1),dy._clearColor=new c7(1,1,1,1),dy._tempVector=new cZ,dy._tempMatrix0=new c8;var dx=((tQ=(tq=function(){this.opaqueQueue=new dm(e.RenderQueueType.Opaque),this.transparentQueue=new dm(e.RenderQueueType.Transparent),this.alphaTestQueue=new dm(e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},tQ.sortBatch=function(e){this.opaqueQueue.sortBatch(dm.compareForOpaque,e),this.alphaTestQueue.sortBatch(dm.compareForOpaque,e),this.transparentQueue.sortBatch(dm.compareForTransparent,e)},tQ.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},tq),db=(us(tZ=function(t){var r;return(r=d_.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},d_),(tJ=tZ.prototype).onConfig=function(t){var r=this.engine,n=t.pixelViewport,a=n.width,i=n.height,o=du.recreateRenderTargetIfNeeded(r,this._renderTarget,a,i,null,e.TextureFormat.Depth16,!0,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Point);this._renderTarget=o},tJ.onRender=function(t,r){var n=this.engine,a=this._renderTarget,i=t.camera,o=n._hardwareRenderer;o.activeRenderTarget(a,du.defaultViewport,t.flipProjection,0),o.clearRenderTarget(n,e.CameraClearFlags.Depth,null),n._renderCount++,r.opaqueQueue.render(t,e.PipelineStage.DepthOnly),r.alphaTestQueue.render(t,e.PipelineStage.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},tZ),dT=(us(t$=function(e){return d_.call(this,e)},d_),(t0=t$.prototype).onConfig=function(t,r){this._cameraColorTexture=r;var n=t.opaqueTextureDownsampling,a=n===e.Downsampling.None,i=t.pixelViewport,o=a?1:n===e.Downsampling.TwoX?.5:.25,s=du.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,i.width*o,i.height*o,t._getInternalColorTextureFormat(),null,!1,!1,1,e.TextureWrapMode.Clamp,a?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear);this._renderTarget=s},t0.onRender=function(t){du.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},t$),dC=((t2=(t1=function(e){this._lastCanvasSize=new c9,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new dx,this._cascadedShadowCasterPass=new dy(e),this._depthOnlyPass=new db(t),this._opaqueTexturePass=new dT(t)}).prototype).destroy=function(){this._cullingResults.destroy(),this._camera=null},t2.render=function(t,r,n,a){t.rendererUpdateFlag=cc.All;var i=this._camera,o=i.scene,s=i.engine,l=this._cullingResults,c=o._lightManager._sunlight,u=this._depthOnlyPass,d=i.depthTextureMode===e.DepthTextureMode.PrePass&&u._supportDepthTexture;o.castShadows&&c&&c.shadowType!==e.ShadowType.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=cc.None);var h=s._batcherManager;if(l.reset(),t.rendererUpdateFlag|=cc.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,d),this._prepareRender(t),l.sortBatch(h),h.uploadBuffer(),d?(u.onConfig(i),u.onRender(t,l),t.rendererUpdateFlag=cc.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var _=i.pixelViewport,f=du.recreateRenderTargetIfNeeded(s,this._internalColorTarget,_.width,_.height,i._getInternalColorTextureFormat(),e.TextureFormat.Depth24Stencil8,!1,!1,i.msaaSamples,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear);this._internalColorTarget=f}else{var p,m=this._internalColorTarget;m&&(null==(p=m.getColorTexture(0))||p.destroy(!0),m.destroy(!0),this._internalColorTarget=null)}this._drawRenderPass(t,i,r,n,a)},t2._drawRenderPass=function(t,r,n,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue,u=r.engine,d=r.scene,h=d.background,_=u._hardwareRenderer,f=this._internalColorTarget,p=f||r.renderTarget,m=f?du.defaultViewport:r.viewport,g=!!f||r.renderTarget&&void 0==n;t.flipProjection!==g&&(t.rendererUpdateFlag|=cc.ProjectionMatrix,t.applyVirtualCamera(r._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,a,n);var v=r.clearFlags&~(null!=i?i:e.CameraClearFlags.None),y=h.solidColor;if(v!==e.CameraClearFlags.None&&_.clearRenderTarget(r.engine,v,y),s.render(t,e.PipelineStage.Forward),l.render(t,e.PipelineStage.Forward),v&e.CameraClearFlags.Color&&(h.mode===e.BackgroundMode.Sky?h.sky._render(t):h.mode===e.BackgroundMode.Texture&&h.texture&&this._drawBackgroundTexture(u,h)),r.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(r,p.getColorTexture(0)),x.onRender(t),_.activeRenderTarget(p,m,t.flipProjection,a,n)}else r.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,e.PipelineStage.Forward);var b=d._postProcessManager,T=r.renderTarget;r.enablePostProcess&&b.hasActiveEffect?b._render(t,f,T):f&&(f._blitRenderTarget(),du.blitTexture(u,f.getColorTexture(0),T,0,r.viewport)),null==T||T._blitRenderTarget(),null==T||T.generateMipmaps()},t2.pushRenderElement=function(t,r){r.renderQueueFlags=0;for(var n=r.subRenderElements,a=0,i=n.length;a<i;++a){var o=n[a],s=o.material,l=s.renderStates,c=s.shader.subShaders[0],u=t.replacementShader;if(u){var d=u.subShaders,h=t.replacementTag;if(h){for(var _=!1,f=0,p=d.length;f<p;f++){var m=d[f];m.getTagValue(h)===c.getTagValue(h)&&(this.pushRenderElementByType(r,o,m.passes,l),_=!0)}_||t.replacementFailureStrategy!==e.ReplacementFailureStrategy.KeepOriginalShader||this.pushRenderElementByType(r,o,c.passes,l)}else this.pushRenderElementByType(r,o,d[0].passes,l)}else this.pushRenderElementByType(r,o,c.passes,l)}},t2.pushRenderElementByType=function(t,r,n,a){for(var i=this._cullingResults,o=0,s=n.length;o<s;o++){var l=void 0,c=n[o],u=c._renderState;u?(u._applyRenderQueueByShaderData(c._renderStateDataMap,r.material.shaderData),l=u.renderQueueType):l=a[o].renderQueueType;var d=1<<l;if(r.shaderPasses=n,r.renderQueueFlags|=d,!(t.renderQueueFlags&d)){switch(l){case e.RenderQueueType.Opaque:i.opaqueQueue.pushRenderElement(t);break;case e.RenderQueueType.AlphaTest:i.alphaTestQueue.pushRenderElement(t);break;case e.RenderQueueType.Transparent:i.transparentQueue.pushRenderElement(t)}t.renderQueueFlags|=d}}},t2._drawBackgroundTexture=function(t,r){var n=t._hardwareRenderer,a=t.canvas,i=r._material,o=r._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(a.width,a.height),r._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,u$._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._applyStates(t,!1,s._renderStateDataMap,i.shaderData),n.drawPrimitive(o._primitive,o.subMesh,l)},t2._prepareRender=function(e){for(var t=e.camera,r=t.engine,n=t.scene._componentsManager._renderers,a=n._elements,i=n.length-1;i>=0;--i){var o=a[i];t.cullingMask&o._entity.layer&&(!t.enableFrustumCulling||t._frustum.intersectsBox(o.bounds))&&(o._prepareRender(e),o._renderFrameCount=r.time.frameCount)}},t1);(t3=ch||(ch={}))[t3.None=0]="None",t3[t3.Opaque=1]="Opaque",t3[t3.AlphaTest=2]="AlphaTest",t3[t3.Transparent=4]="Transparent",t3[t3.All=7]="All";var dS=((t8=(t4=function(){this.subRenderElements=[]}).prototype).set=function(e,t){this.priority=e,this.distanceForSort=t,this.subRenderElements.length=0},t8.addSubRenderElement=function(e){this.subRenderElements.push(e)},t8.dispose=function(){this.subRenderElements.length=0},t4),dA=((t9=(t5=function(){}).prototype).set=function(e,t,r,n,a,i){this.component=e,this.material=t,this.primitive=r,this.subPrimitive=n,this.texture=a,this.subChunk=i},t9.dispose=function(){this.component=null,this.material=null,this.primitive=null,this.subPrimitive=null,this.shaderPasses=null,this.shaderData&&(this.shaderData=null),this.texture&&(this.texture=null),this.subChunk&&(this.subChunk=null)},t5),dM=function(t){function r(n){var a;return(a=t.call(this,n)||this).influenceLayers=e.SpriteMaskLayer.Everything,a._maskIndex=-1,a._sprite=null,a._automaticWidth=0,a._automaticHeight=0,a._customWidth=void 0,a._customHeight=void 0,a._flipX=!1,a._flipY=!1,a._alphaCutoff=.5,de.resetData(un(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(r._alphaCutoffProperty,a._alphaCutoff),a._renderElement=new dS,a._renderElement.addSubRenderElement(new dA),a._onSpriteChange=a._onSpriteChange.bind(un(a)),a}us(r,t);var n=r.prototype;return n._updateTransformShaderData=function(e,r,n){t.prototype._updateTransformShaderData.call(this,e,r,!0)},n._cloneTo=function(e,r,n){t.prototype._cloneTo.call(this,e,r,n),e.sprite=this._sprite},n._canBatch=function(e,t){return u3.canBatchSpriteMask(e,t)},n._batch=function(e,t){u3.batchFor2D(e,t)},n._onEnableInScene=function(){t.prototype._onEnableInScene.call(this),this.scene._maskManager.addSpriteMask(this)},n._onDisableInScene=function(){t.prototype._onDisableInScene.call(this),this.scene._maskManager.removeSpriteMask(this)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManagerMask},n._updateBounds=function(e){this.sprite?de.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&co.WorldVolume&&(de.updatePositions(this),this._dirtyUpdateFlag&=~co.WorldVolume),2&this._dirtyUpdateFlag&&(de.updateUVs(this),this._dirtyUpdateFlag&=-3);var a=this._renderElement,i=a.subRenderElements[0];a.set(this.priority,this._distanceForSort);var o=this._subChunk;i.set(this,r,o.chunk.primitive,o.subMesh,this.sprite.texture,o),i.shaderPasses=r.shader.subShaders[0].passes,i.renderQueueFlags=ch.All,a.addSubRenderElement(i)}}},n._onDestroy=function(){var e=this._sprite;e&&(this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onSpriteChange)),t.prototype._onDestroy.call(this),this._sprite=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null),this._renderElement=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 ce.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case ce.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=co.WorldVolume);break;case ce.region:case ce.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case ce.atlasRegion:this._dirtyUpdateFlag|=2;break;case ce.pivot:this._dirtyUpdateFlag|=co.WorldVolume;break;case ce.destroy:this.sprite=null}},ui(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|=co.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|=co.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=co.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=co.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(r._textureProperty,e.texture)):this.shaderData.setTexture(r._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(r._alphaCutoffProperty,e))}}]),r}(e.Renderer);dM._textureProperty=uO.getByName("renderer_MaskTexture"),dM._alphaCutoffProperty=uO.getByName("renderer_MaskAlphaCutoff"),ul([ud],dM.prototype,"influenceLayers",void 0),ul([uu],dM.prototype,"_subChunk",void 0),ul([uu],dM.prototype,"_maskIndex",void 0),ul([uu],dM.prototype,"_sprite",void 0),ul([uu],dM.prototype,"_automaticWidth",void 0),ul([uu],dM.prototype,"_automaticHeight",void 0),ul([ud],dM.prototype,"_customWidth",void 0),ul([ud],dM.prototype,"_customHeight",void 0),ul([ud],dM.prototype,"_flipX",void 0),ul([ud],dM.prototype,"_flipY",void 0),ul([ud],dM.prototype,"_alphaCutoff",void 0),ul([uu],dM.prototype,"_onSpriteChange",null),(t6=c_||(c_={}))[t6.UV=2]="UV",t6[t6.RenderData=3]="RenderData",t6[t6.AutomaticSize=4]="AutomaticSize",t6[t6.All=7]="All";var dR=function(e){this.resource=e},dE=(us(t7=function(e){var t;return(t=um.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},um),(re=t7.prototype).uploadCharTexture=function(e){var t=e.w,r=e.h,n=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=r+a;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=a,this._curY=this._nextY+a);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&r>0&&n&&(e.bufferOffset=new c9(this._curX,this._curY),i.setPixelBuffer(n,0,this._curX,this._curY,t,r),i.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+a,!0},re.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},re.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},re._onDestroy=function(){um.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t7),dw=((rt=function(){}).textContext=function(){var e=rt._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},rt._textContext=e}return e},rt.measureFont=function(e){var t=rt._fontSizeInfoCache,r=t[e];return r||(r=rt._measureFontOrChar(e,rt._measureString,!1),t[e]=r),r},rt.getNativeFontString=function(t,r,n){var a=n&e.FontStyle.Bold?"bold ":"";return n&e.FontStyle.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rt._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=r+"px "+t},rt.measureChar=function(e,t){return rt._measureFontOrChar(t,e,!0)},rt.measureTextWithWrap=function(t){var r=t._getSubFont(),n=r.nativeFontString,a=rt.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=h4._pixelsPerUnit,u=a.size+t.lineSpacing*c,d=t.width*c,h=0;r.nativeFontString=n;for(var _=0,f=i.length;_<f;_++){var p=i[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var m="",g=0,v=0,y=0,x="",b=0,T=0,C=0,S=!1,A=0,M=p.length;A<M;++A){var R=p[A],E=rt._getCharInfo(R,n,r),w=R.charCodeAt(0),P=32===w;if(!P||!S||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=E.w,B=E.offsetY,D=.5*E.h,I=D+B,O=D-B;F?(m.length>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),S=!0,x=m,b=g,T=v,C=y):(x+=m,b+=g,T=Math.max(T,v),C=Math.max(C,y)),m="",g=v=y=0),b+L>d&&b>0?(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),S=!0,P?(x="",b=T=C=0):(x=R,b=E.xAdvance,T=I,C=O)):(x+=R,b+=E.xAdvance,T=Math.max(T,I),C=Math.max(C,O))):g+E.w>d?(b>0&&(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),x="",b=T=C=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),S=!0,m=R,g=E.xAdvance,v=I,y=O):(m+=R,g+=E.xAdvance,v=Math.max(v,I),y=Math.max(y,O))}}g>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b),b=0,g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g)):(x+=m,b+=g,T=Math.max(T,v),C=Math.max(C,y))),b>0&&(this._pushLine(o,s,l,x,b,T,C),h=Math.max(h,b))}var V=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(V=u*o.length),{width:h,height:V,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},rt.measureTextWithoutWrap=function(t){var r=t._getSubFont(),n=r.nativeFontString,a=rt.measureFont(n),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=h4._pixelsPerUnit,d=a.size+t.lineSpacing*u,h=0;r.nativeFontString=n;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=rt._getCharInfo(f[v],n,r);p+=x.xAdvance;var b=x.offsetY,T=.5*x.h,C=T+b,S=T-b;m<C&&(m=C),g<S&&(g=S)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},rt.getNativeFontHash=function(t,r,n){var a=n&e.FontStyle.Bold?"bold":"";return n&e.FontStyle.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rt._genericFontFamilies.indexOf(t)||(t=""+t),a+=r+"px"+t},rt._measureFontOrChar=function(e,t,r){var n,a=rt.textContext(),i=a.canvas,o=a.context;o.font=e;var s=o.measureText(t),l=Math.max(1,Math.round(s.actualBoundingBoxRight-s.actualBoundingBoxLeft||s.width)),c=Math.ceil(o.measureText(rt._measureBaseline).width),u=c*rt._heightMultiplier;c=rt._baselineMultiplier*c|0;var d=rt._extendHeight;u+=d,c+=.5*d,i.width=l,i.height=u,o.font=e,o.fillStyle="#000",o.clearRect(0,0,l,u),o.textBaseline="middle",o.fillStyle="#fff",o.fillText(t,0,c);for(var h=o.getImageData(0,0,l,u).data,_=h.length,f=-1,p=-1,m=0,g=0,v=0,y=i.width,x=1/y,b=0;b<_;b+=4)0!==h[b+3]?(n=~~(.25*b*x),-1===f&&(f=n),n>p&&(p=n)):h[b]=h[b+1]=h[b+2]=255;if(-1!==f&&-1!==p&&(v=(m=c-f)+(g=p-c+1)),!r)return{ascent:m,descent:g,size:v};var T=null;if(v>0){var C=4*y;T=new Uint8Array(h.buffer,f*C,v*C)}return{char:t,x:0,y:0,w:l,h:v,offsetX:0,offsetY:(m-g)*.5,xAdvance:l,uvs:[new c9,new c9,new c9,new c9],ascent:m,descent:g,index:0,data:T}},rt._getCharInfo=function(e,t,r){var n=r._getCharInfo(e);return n||(n=rt.measureChar(e,t),r._uploadCharTexture(n),r._addCharInfo(e,n)),n},rt._pushLine=function(e,t,r,n,a,i,o){e.push(n),t.push(a),r.push({ascent:i,descent:o,size:i+o})},rt);dw._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],dw._extendHeight=0,dw._measureString="|\xc9q\xc5",dw._measureBaseline="M",dw._heightMultiplier=2,dw._baselineMultiplier=1.4,dw._fontSizeInfoCache={},dw._textContext=null;var dP=((rn=(rr=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},rn._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},rn._addCharInfo=function(e,t){var r=this._lastIndex;t.index=r,this._fontAtlases[r].addCharInfo(e,t)},rn._getCharInfo=function(e){for(var t=this._fontAtlases,r=0,n=t.length;r<n;++r){var a=t[r].getCharInfo(e);if(a)return a}return null},rn._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},rn._getLastIndex=function(){return this._lastIndex},rn._createFontAtlas=function(){var t,r=this._engine,n=new dE(r),a=new ds(r,256,256,e.TextureFormat.R8G8B8A8,!1);a.filterMode=e.TextureFilterMode.Bilinear,n.texture=a,n.isGCIgnored=a.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return r.resourceManager.addContentRestorer(new(us(t=function(){return dR.call(this,n)},dR),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var a=t[n],o=dw.measureChar(a.char,i).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;r.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}r.generateMipmaps()},t)),n},rr),dF=(us(ra=function(e,t){var r;return void 0===t&&(t=""),(r=um.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},um),(ri=ra.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,a=n[r];return a||(a=new dP(this.engine),n[r]=a),a},ri._onDestroy=function(){um.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]},ra.createFromOS=function(e,t){if(t){var r=e._fontMap,n=r[t];return n||(n=new ra(e,t),r[t]=n),n}return null},ui(ra,[{key:"name",get:function(){return this._name}}]),ra),dL=((ro=function(){this.localPositions=new c6}).prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},ro);dL.triangles=[0,2,1,2,0,3];var dB=(rs=e.Renderer,us(rl=function(t){(r=rs.call(this,t)||this)._textChunks=[],r._subFont=null,r._dirtyFlag=15,r._color=new c7(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new c$,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;var r,n=un(r).engine;return r._font=n._textDefaultFont,r._addResourceReferCount(r._font,1),r.setMaterial(n._textDefaultMaterial),r._color._onValueChanged=r._onColorChanged.bind(un(r)),r},rs),(rc=rl.prototype)._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),rs.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},rc._cloneTo=function(e,t,r){rs.prototype._cloneTo.call(this,e,t,r),e.font=this._font,e._subFont=this._subFont},rc._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rc._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rc._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rc._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},rc._updateTransformShaderData=function(e,t,r){rs.prototype._updateTransformShaderData.call(this,e,t,!0)},rc._canBatch=function(e,t){return u3.canBatchSprite(e,t)},rc._batch=function(e,t){u3.batchFor2D(e,t)},rc._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},rc._updateBounds=function(e){c$.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rc._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)),this._isContainDirtyFlag(32)&&(this._updateColor(),this._setDirtyFlagFalse(32));var t=e.camera,r=t.engine,n=r._textSubRenderElementPool,a=this.getMaterial(),i=r._renderElementPool.get();i.set(this.priority,this._distanceForSort);for(var o=this._textChunks,s=0,l=o.length;s<l;++s){var c=o[s],u=c.subChunk,d=c.texture,h=n.get();h.set(this,a,u.chunk.primitive,u.subMesh,d,u),h.shaderData||(h.shaderData=new u2(cr.RenderElement)),h.shaderData.setTexture(rl._textureProperty,d),i.addSubRenderElement(h)}t._renderPipeline.pushRenderElement(e,i)}},rc._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}},rc._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=dw.getNativeFontString(e.name,this.fontSize,this.fontStyle)},rc._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=e[0],r=e[1],n=e[2],a=e[4],i=e[5],o=e[6],s=e[12],l=e[13],c=e[14],u=rl._tempVec31.set(a,i,o),d=rl._tempVec30.set(t,r,n),h=rl._worldPositions,_=h[0],f=h[1],p=h[2],m=h[3],g=this._textChunks,v=0,y=g.length;v<y;++v)for(var x=g[v],b=x.subChunk,T=x.charRenderInfos,C=0,S=T.length;C<S;++C){var A=T[C],M=A.localPositions,R=M.x,E=M.y;_.set(R*t+E*a+s,R*r+E*i+l,R*n+E*o+c),cZ.scale(d,M.z-R,f),cZ.add(_,f,f),cZ.scale(u,M.w-E,p),cZ.add(_,p,m),cZ.add(f,p,p);for(var w=b.chunk.vertices,P=0,F=b.vertexArea.start+36*A.indexInChunk;P<4;++P,F+=9)h[P].copyToArray(w,F)}},rc._updateColor=function(){for(var e=this._color,t=e.r,r=e.g,n=e.b,a=e.a,i=this._textChunks,o=0,s=i.length;o<s;++o)for(var l=i[o].subChunk,c=l.vertexArea,u=c.size/9,d=l.chunk.vertices,h=0,_=c.start+5;h<u;++h,_+=9)d[_]=t,d[_+1]=r,d[_+2]=n,d[_+3]=a},rc._updateLocalData=function(){var t=this._localBounds,r=t.min,n=t.max,a=rl._charRenderInfos,i=this._subFont,o=this.enableWrapping?dw.measureTextWithWrap(this):dw.measureTextWithoutWrap(this),s=o.height,l=o.lines,c=o.lineWidths,u=o.lineHeight,d=o.lineMaxSizes,h=this.engine._charRenderInfoPool,_=l.length,f=0;if(_>0){var p=h4._pixelsPerUnit,m=this.horizontalAlignment,g=1/p,v=.5*(this.width*p),y=this.height*p,x=.5*u,b=0,T=.5*u-d[0].ascent,C=.5*u-d[_-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:b=.5*y-x+T;break;case e.TextVerticalAlignment.Center:b=.5*s-x-(C-T)*.5;break;case e.TextVerticalAlignment.Bottom:b=s-.5*y-x-C}for(var S=-1,A=Number.MAX_SAFE_INTEGER,M=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,E=Number.MIN_SAFE_INTEGER,w=0;w<_;++w){var P=c[w];if(P>0){var F=l[w],L=0,B=-1;switch(S<0&&(S=w),m){case e.TextHorizontalAlignment.Left:L=-v;break;case e.TextHorizontalAlignment.Center:L=-(.5*P);break;case e.TextHorizontalAlignment.Right:L=v-P}for(var D=0,I=F.length;D<I;++D){var O=F[D],V=i._getCharInfo(O);if(V.h>0){B<0&&(B=D);var N=a[f++]=h.get(),k=N.localPositions;N.texture=i._getTextureByIndex(V.index),N.uvs=V.uvs;var z=V.w,U=V.ascent,G=V.descent,H=L*g,W=(L+z)*g,j=(b+U)*g,K=(b-G)*g;k.set(H,j,W,K),w===S&&(E=Math.max(E,j)),M=Math.min(M,K),D===B&&(A=Math.min(A,H)),R=Math.max(R,W)}L+=V.xAdvance}}b-=u}S<0?(r.set(0,0,0),n.set(0,0,0)):(r.set(A,M,0),n.set(R,E,0))}else r.set(0,0,0),n.set(0,0,0);if(i._getLastIndex()>0&&a.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId}),this._freeTextChunks(),0!==f){var X=this._textChunks,Y=new dD;X.push(Y);var q=this._getChunkManager().maxVertexCount,Q=a[0],Z=Q.texture;Y.texture=Z;var J=Y.charRenderInfos;J.push(Q);for(var $=1;$<f;++$){var ee=a[$],et=ee.texture;(Z!==et||4*J.length+4>q)&&(this._buildChunk(Y,J.length),Y=new dD,X.push(Y),Z=et,Y.texture=et,J=Y.charRenderInfos),J.push(ee)}var er=J.length;er>0&&this._buildChunk(Y,er),a.length=0}},rc._onTransformChanged=function(e){rs.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},rc._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===e.OverflowMode.Truncate&&this.height<=0},rc._buildChunk=function(e,t){for(var r=this.color,n=r.r,a=r.g,i=r.b,o=r.a,s=dL.triangles,l=s.length,c=e.subChunk=this._getChunkManager().allocateSubChunk(4*t),u=c.chunk.vertices,d=c.indices=[],h=e.charRenderInfos,_=0,f=0,p=0,m=c.vertexArea.start+3;_<t;++_,p+=4){var g=h[_];g.indexInChunk=_;for(var v=0;v<l;++v)d[f++]=s[v]+p;for(var y=0;y<4;++y,m+=9)g.uvs[y].copyToArray(u,m),u[m+2]=n,u[m+3]=a,u[m+4]=i,u[m+5]=o}return c},rc._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,r=this._getChunkManager(),n=0,a=e.length;n<a;++n){for(var i=e[n],o=i.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,r.freeSubChunk(i.subChunk),i.subChunk=null,i.texture=null}e.length=0},rc._onColorChanged=function(){this._setDirtyFlagTrue(32)},ui(rl,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){if(this._isTextNoVisible()){if(this._isContainDirtyFlag(8)){var e=this._localBounds;e.min.set(0,0,0),e.max.set(0,0,0),this._updateBounds(this._bounds),this._setDirtyFlagFalse(8)}return this._bounds}return this._isContainDirtyFlag(1)&&this._resetSubFont(),this._isContainDirtyFlag(2)&&this._updateLocalData(),this._isContainDirtyFlag(4)&&this._updatePosition(),this._isContainDirtyFlag(8)&&this._updateBounds(this._bounds),this._setDirtyFlagFalse(15),this._bounds}}]),rl);dB._textureProperty=uO.getByName("renderElement_TextTexture"),dB._tempVec30=new cZ,dB._tempVec31=new cZ,dB._worldPositions=[new cZ,new cZ,new cZ,new cZ],dB._charRenderInfos=[],ul([uu],dB.prototype,"_textChunks",void 0),ul([ud],dB.prototype,"_subFont",void 0),ul([uu],dB.prototype,"_dirtyFlag",void 0),ul([u_],dB.prototype,"_color",void 0),ul([ud],dB.prototype,"_text",void 0),ul([ud],dB.prototype,"_width",void 0),ul([ud],dB.prototype,"_height",void 0),ul([uu],dB.prototype,"_localBounds",void 0),ul([ud],dB.prototype,"_font",void 0),ul([ud],dB.prototype,"_fontSize",void 0),ul([ud],dB.prototype,"_fontStyle",void 0),ul([ud],dB.prototype,"_lineSpacing",void 0),ul([ud],dB.prototype,"_horizontalAlignment",void 0),ul([ud],dB.prototype,"_verticalAlignment",void 0),ul([ud],dB.prototype,"_enableWrapping",void 0),ul([ud],dB.prototype,"_overflowMode",void 0),ul([uu],dB.prototype,"_onColorChanged",null);var dD=function(){this.charRenderInfos=[]};(ru=cf||(cf={}))[ru.SubFont=1]="SubFont",ru[ru.LocalPositionBounds=2]="LocalPositionBounds",ru[ru.WorldPosition=4]="WorldPosition",ru[ru.WorldBounds=8]="WorldBounds",ru[ru.MaskInteraction=16]="MaskInteraction",ru[ru.Color=32]="Color",ru[ru.Position=14]="Position",ru[ru.Font=15]="Font",e.BufferUsage=void 0,(rd=e.BufferUsage||(e.BufferUsage={}))[rd.Static=0]="Static",rd[rd.Dynamic=1]="Dynamic",rd[rd.Stream=2]="Stream",e.SetDataOptions=void 0,(rh=e.SetDataOptions||(e.SetDataOptions={}))[rh.None=0]="None",rh[rh.Discard=1]="Discard";var dI=(us(r_=function(t,r,n,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=u0.call(this,t)||this)._dataUpdateManager=new uT,o._engine=t,o._type=r,o._bufferUsage=a,o._readable=i,"number"==typeof n)o._byteLength=n,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,n,a),i&&(o._data=new Uint8Array(n));else{var o,s=n.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(r,s,a,n),i){var l=n.constructor===ArrayBuffer?n.slice(0):n.buffer.slice(n.byteOffset,n.byteOffset+s);o._data=new Uint8Array(l)}}return o},u0),(rf=r_.prototype).bind=function(){this._platformBuffer.bind()},rf.setData=function(t,r,n,a,i){if(void 0===r&&(r=0),void 0===n&&(n=0),void 0===i&&(i=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,r,n,a,i),this._readable){var o=t.constructor===ArrayBuffer?t:t.buffer;if(this._data.buffer!==o){var s=t.BYTES_PER_ELEMENT||1,l=a?s*a:t.byteLength,c=void 0!==t.byteOffset?t.byteOffset+n*s:n,u=new Uint8Array(o,c,l);this._data.set(u,r)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},rf.getData=function(e,t,r,n){void 0===t&&(t=0),void 0===r&&(r=0),this._platformBuffer.getData(e,t,r,n)},rf.markAsUnreadable=function(){this._data=null,this._readable=!1},rf._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},rf._onDestroy=function(){u0.prototype._onDestroy.call(this),this._platformBuffer.destroy()},ui(r_,[{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."}}]),r_);e.IndexFormat=void 0,(rp=e.IndexFormat||(e.IndexFormat={}))[rp.UInt8=0]="UInt8",rp[rp.UInt16=1]="UInt16",rp[rp.UInt32=2]="UInt32",e.VertexElementFormat=void 0,(rm=e.VertexElementFormat||(e.VertexElementFormat={}))[rm.Float=0]="Float",rm[rm.Vector2=1]="Vector2",rm[rm.Vector3=2]="Vector3",rm[rm.Vector4=3]="Vector4",rm[rm.Byte4=4]="Byte4",rm[rm.UByte4=5]="UByte4",rm[rm.NormalizedByte4=6]="NormalizedByte4",rm[rm.NormalizedUByte4=7]="NormalizedUByte4",rm[rm.Short2=8]="Short2",rm[rm.UShort2=9]="UShort2",rm[rm.NormalizedShort2=10]="NormalizedShort2",rm[rm.NormalizedUShort2=11]="NormalizedUShort2",rm[rm.Short4=12]="Short4",rm[rm.UShort4=13]="UShort4",rm[rm.NormalizedShort4=14]="NormalizedShort4",rm[rm.NormalizedUShort4=15]="NormalizedUShort4";var dO=((rg=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}},rg._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},rg._getElementInfo=function(t){var r,n,a,i=!1;switch(t){case e.VertexElementFormat.Float:r=1,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:r=2,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:r=3,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:r=4,n=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:r=4,n=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:r=4,n=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:r=4,n=e.DataType.BYTE,i=!0,a=1/127;break;case e.VertexElementFormat.NormalizedUByte4:r=4,n=e.DataType.UNSIGNED_BYTE,i=!0,a=1/255;break;case e.VertexElementFormat.Short2:r=2,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:r=2,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:r=2,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:r=2,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535;break;case e.VertexElementFormat.Short4:r=4,n=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:r=4,n=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:r=4,n=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:r=4,n=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535}return{size:r,type:n,normalized:i,normalizedScaleFactor:a}},rg),dV=(ui(rv=function(e,t,r,n,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=r,this._bindingIndex=n,this._formatMetaInfo=dO._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)},[{key:"attribute",get:function(){return this._attributeName}},{key:"offset",get:function(){return this._offset},set:function(e){this._offset=e}},{key:"format",get:function(){return this._format}},{key:"bindingIndex",get:function(){return this._bindingIndex},set:function(e){this._bindingIndex=e}},{key:"instanceStepRate",get:function(){return this._instanceStepRate}},{key:"semantic",get:function(){return this.attribute}}]),rv);e.BufferBindFlag=void 0,(ry=e.BufferBindFlag||(e.BufferBindFlag={}))[ry.VertexBuffer=0]="VertexBuffer",ry[ry.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(rx=e.MeshTopology||(e.MeshTopology={}))[rx.Points=0]="Points",rx[rx.Lines=1]="Lines",rx[rx.LineLoop=2]="LineLoop",rx[rx.LineStrip=3]="LineStrip",rx[rx.Triangles=4]="Triangles",rx[rx.TriangleStrip=5]="TriangleStrip",rx[rx.TriangleFan=6]="TriangleFan",e.BlendMode=void 0,(rb=e.BlendMode||(e.BlendMode={}))[rb.Normal=0]="Normal",rb[rb.Additive=1]="Additive",e.RenderFace=void 0,(rT=e.RenderFace||(e.RenderFace={}))[rT.Front=0]="Front",rT[rT.Back=1]="Back",rT[rT.Double=2]="Double";var dN=(us(rC=function(e,t){var r;return(r=um.call(this,e)||this)._renderStates=[],r._priority=0,r._shaderData=new u2(cr.Material),r.shader=t,r},um),(rS=rC.prototype).clone=function(){var e=new rC(this._engine,this.shader);return this.cloneTo(e),e},rS.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),uf.deepCloneObject(this.renderStates,e.renderStates,new Map)},rS._addReferCount=function(e){this._destroyed||(um.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},rS._onDestroy=function(){um.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},ui(rC,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,r=this._getReferCount();r>0&&(null==(t=this._shader)||t._addReferCount(-r),e._addReferCount(r)),this._shader=e;for(var n=this._renderStates,a=n.length,i=0,o=e.subShaders,s=0;s<o.length;s++)i=Math.max(o[s].passes.length,i);if(a<i)for(var l=a;l<i;l++)n.push(new uJ);else n.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rC),dk=function(t){function r(n,a){(i=t.call(this,n,a)||this)._renderFace=e.RenderFace.Front,i._isTransparent=!1,i._blendMode=e.BlendMode.Normal;var i,o=un(i).shaderData;return o.setFloat(r._alphaCutoffProp,0),o.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque),i}us(r,t);var n=r.prototype;return n.setIsTransparent=function(t,n){var a=this.renderStates;if(a.length<t)throw"Pass should less than pass count.";var i=a[t],o=this.shaderData;n?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=e.RenderQueueType.Transparent,o.enableMacro(r._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=o.getFloat(r._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,o.disableMacro(r._transparentMacro))},n.setBlendMode=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";var a=n[t].blendState.targetBlendState;switch(r){case e.BlendMode.Normal:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.One,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add}},n.setRenderFace=function(t,r){var n=this.renderStates;if(n.length<t)throw"Pass should less than pass count.";switch(r){case e.RenderFace.Front:n[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:n[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:n[t].rasterState.cullMode=e.CullMode.Off}},n.clone=function(){var e=new r(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},ui(r,[{key:"shader",get:function(){return this._shader},set:function(t){var r,n=this._getReferCount();n>0&&(null==(r=this._shader)||r._addReferCount(-n),t._addReferCount(n)),this._shader=t;for(var a=this._renderStates,i=a.length,o=0,s=t.subShaders,l=0;l<s.length;l++)o=Math.max(s[l].passes.length,o);if(i<o)for(var c=i;c<o;c++)a.push(new uJ),this.setBlendMode(c,e.BlendMode.Normal);else a.length=o}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(t){if(t!==this._isTransparent){this.setIsTransparent(0,t);var n=this.shaderData;t?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.getFloat(r._alphaCutoffProp)?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque),this._isTransparent=t}}},{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.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest)):(n.disableMacro(r._alphaCutoffMacro),this._isTransparent?n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.AlphaTest):n.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque));for(var a=this.renderStates,i=0,o=a.length;i<o;i++){var s=a[i];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}n.setFloat(r._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),r}(dN);dk._shadowCasterRenderQueueProp=uO.getByName("material_ShadowCasterRenderQueue"),dk._baseTextureMacro=uM.getByName("MATERIAL_HAS_BASETEXTURE"),dk._normalTextureMacro=uM.getByName("MATERIAL_HAS_NORMALTEXTURE"),dk._emissiveTextureMacro=uM.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),dk._transparentMacro=uM.getByName("MATERIAL_IS_TRANSPARENT"),dk._baseColorProp=uO.getByName("material_BaseColor"),dk._baseTextureProp=uO.getByName("material_BaseTexture"),dk._tilingOffsetProp=uO.getByName("material_TilingOffset"),dk._normalTextureProp=uO.getByName("material_NormalTexture"),dk._normalIntensityProp=uO.getByName("material_NormalIntensity"),dk._emissiveColorProp=uO.getByName("material_EmissiveColor"),dk._emissiveTextureProp=uO.getByName("material_EmissiveTexture"),dk._alphaCutoffProp=uO.getByName("material_AlphaCutoff"),dk._alphaCutoffMacro=uM.getByName("MATERIAL_IS_ALPHA_CUTOFF");var dz=function(e){function t(r){var n,a=(n=e.call(this,r,u$.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new c7(1,1,1,1)),a.setColor(t._specularColorProp,new c7(1,1,1,1)),a.setColor(t._emissiveColorProp,new c7(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new c6(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),n}return us(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ui(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}(dk);dz._specularColorProp=uO.getByName("material_SpecularColor"),dz._shininessProp=uO.getByName("material_Shininess"),dz._specularTextureProp=uO.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rA=e.TextureCoordinate||(e.TextureCoordinate={}))[rA.UV0=0]="UV0",rA[rA.UV1=1]="UV1",rA[rA.UV2=2]="UV2",rA[rA.UV3=3]="UV3",rA[rA.UV4=4]="UV4",rA[rA.UV5=5]="UV5",rA[rA.UV6=6]="UV6",rA[rA.UV7=7]="UV7";var dU=function(t){function r(n,a){var i,o=(i=t.call(this,n,a)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(r._baseColorProp,new c7(1,1,1,1)),o.setColor(r._emissiveColorProp,new c7(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new c6(1,1,0,0)),o.setFloat(r._normalIntensityProp,1),o.setFloat(r._occlusionTextureIntensityProp,1),o.setFloat(r._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(r._clearCoatProp,0),o.setFloat(r._clearCoatRoughnessProp,0),i}return us(r,t),ui(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&&uI.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}(dk);dU._occlusionTextureIntensityProp=uO.getByName("material_OcclusionIntensity"),dU._occlusionTextureCoordProp=uO.getByName("material_OcclusionTextureCoord"),dU._occlusionTextureProp=uO.getByName("material_OcclusionTexture"),dU._clearCoatProp=uO.getByName("material_ClearCoat"),dU._clearCoatTextureProp=uO.getByName("material_ClearCoatTexture"),dU._clearCoatRoughnessProp=uO.getByName("material_ClearCoatRoughness"),dU._clearCoatRoughnessTextureProp=uO.getByName("material_ClearCoatRoughnessTexture"),dU._clearCoatNormalTextureProp=uO.getByName("material_ClearCoatNormalTexture");var dG=function(e){function t(r){(n=e.call(this,r,u$.find("pbr"))||this)._anisotropyRotation=0;var n,a=n.shaderData;return a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new cZ(1,0,0)),n}return us(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ui(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}},{key:"anisotropy",get:function(){return this.shaderData.getVector3(t._anisotropyInfoProp).z},set:function(e){var r=this.shaderData.getVector3(t._anisotropyInfoProp);!!r.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),r.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var r=this.shaderData.getVector3(t._anisotropyInfoProp),n=cQ.degreeToRadFactor*e;r.x=Math.cos(n),r.y=Math.sin(n)}}},{key:"anisotropyTexture",get:function(){return this.shaderData.getTexture(t._anisotropyTextureProp)},set:function(e){this.shaderData.setTexture(t._anisotropyTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ANISOTROPY_TEXTURE")}}]),t}(dU);dG._metallicProp=uO.getByName("material_Metal"),dG._roughnessProp=uO.getByName("material_Roughness"),dG._roughnessMetallicTextureProp=uO.getByName("material_RoughnessMetallicTexture"),dG._iorProp=uO.getByName("material_IOR"),dG._anisotropyInfoProp=uO.getByName("material_AnisotropyInfo"),dG._anisotropyTextureProp=uO.getByName("material_AnisotropyTexture");var dH=function(e){function t(r){var n;return(n=e.call(this,r,u$.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new c7(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return us(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ui(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}(dU);dH._specularColorProp=uO.getByName("material_PBRSpecularColor"),dH._glossinessProp=uO.getByName("material_Glossiness"),dH._specularGlossinessTextureProp=uO.getByName("material_SpecularGlossinessTexture"),dH._specularGlossinessTextureMacro=uM.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var dW=function(e){function t(r){var n,a=(n=e.call(this,r,u$.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new c7(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new c6(1,1,0,0)),n}return us(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},ui(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}(dk),dj=((rM=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new uT,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},ui(rM,[{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)}}]),rM);(rR=cp||(cp={}))[rR.Position=1]="Position",rR[rR.Normal=2]="Normal",rR[rR.Tangent=4]="Tangent",rR[rR.All=7]="All";var dK=((rw=(rE=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new uT,this._dataChangeManager=new uT,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,r,n){if("number"==typeof e){var a=new dj(e,t,r,n);return this._addFrame(a),a}this._addFrame(e)},rw.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()},rw._releaseData=function(){for(var e=this._frames,t=0,r=e.length;t<r;t++)e[t]._releaseData()},rw._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(cp.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},rw._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))},rw._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},ui(rE,[{key:"frames",get:function(){return this._frames}}]),rE),dX=(ui(rP=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),rP),dY=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},dq=(us(rF=function(){return dY.apply(this,arguments)},dY),rF.prototype.dispose=function(){},rF),dQ=(us(rL=function(e){var t;return(t=u0.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(un(t)),t},u0),(rB=rL.prototype).addVertexElement=function(e){var t=this._vertexElementMap,r=this._vertexElements,n=e.attribute,a=t[n];a&&(console.warn("VertexElement "+n+" already exists."),r.splice(r.indexOf(a),1)),t[n]=e,r.push(e),this._bufferStructChanged=!0},rB.removeVertexElement=function(e){var t=this._vertexElements,r=t[e];t.splice(e,1),delete this._vertexElementMap[r.attribute],this._bufferStructChanged=!0},rB.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},rB.setVertexElement=function(e,t){var r=this._vertexElementMap,n=this._vertexElements,a=n[e];a&&delete r[a.attribute],r[t.attribute]=t,n[e]=t,this._bufferStructChanged=!0},rB.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,r=this._vertexElements,n=e,a=r.length;n<a;n++){var i=r[n];delete t[i.attribute]}r.length=e},rB.setVertexBufferBinding=function(e,t){var r,n=this._getReferCount(),a=this.vertexBufferBindings;n>0&&(null==(r=a[e])||r.buffer._addReferCount(-n),null==t||t.buffer._addReferCount(n)),a[e]=t,this._bufferStructChanged=!0},rB.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this.setVertexBufferBinding(t+i,e[i])},rB.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=dO._getGLIndexType(e.format),this._glIndexByteCount=dO._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},rB.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},rB._addReferCount=function(e){u0.prototype._addReferCount.call(this,e);for(var t,r,n=this.vertexBufferBindings,a=0,i=n.length;a<i;a++)null==(r=n[a])||r.buffer._addReferCount(e);null==(t=this.indexBufferBinding)||t._buffer._addReferCount(e)},rB._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},rB._onDestroy=function(){u0.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},ui(rL,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),rL),dZ=(us(rD=function(e,t){(r=um.call(this,e)||this)._updateFlagManager=new uT,r._bounds=new c$,r._subMeshes=[],r.name=t,r._primitive=new dQ(e),r._onBoundsChanged=r._onBoundsChanged.bind(un(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},um),(rI=rD.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new dq(t,r,n)),this._subMeshes.push(t),t},rI.removeSubMesh=function(e){var t=this._subMeshes,r=t.indexOf(e);-1!==r&&t.splice(r,1)},rI.clearSubMesh=function(){this._subMeshes.length=0},rI._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},rI._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},rI._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},rI._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},rI._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},rI._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},rI._addReferCount=function(e){um.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},rI._onDestroy=function(){um.prototype._onDestroy.call(this),this._primitive.destroy()},rI._setVertexElements=function(e){this._clearVertexElements();for(var t=0,r=e.length;t<r;t++)this._addVertexElement(e[t])},rI._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},rI._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},ui(rD,[{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}}]),rD);(rO=cm||(cm={}))[rO.Bounds=1]="Bounds",rO[rO.VertexElements=2]="VertexElements";var dJ=(ui(rV=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),rV),d$=(us(rN=function(){return dZ.apply(this,arguments)},dZ),(rk=rN.prototype).setVertexElements=function(e){this._setVertexElements(e)},rk.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dJ(e,t));var i=this._primitive.vertexBufferBindings;i.length<=r&&(i.length=r+1),this._setVertexBufferBinding(a?t:r,n)},rk.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=this._primitive.vertexBufferBindings,n=e.length,a=t+n;r.length<a&&(r.length=a);for(var i=0;i<n;i++)this._setVertexBufferBinding(t+i,e[i])},rk.setIndexBufferBinding=function(e,t){var r=e;r&&(void 0!==r.buffer||(r=new dX(e,t))),this._setIndexBufferBinding(r)},ui(rN,[{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}}]),rN),d0=(rz=e.Renderer,us(rU=function(e){var t;return(t=rz.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(un(t)),t},rz),(rG=rU.prototype)._onDestroy=function(){var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),rz.prototype._onDestroy.call(this)},rG._cloneTo=function(e,t,r){rz.prototype._cloneTo.call(this,e,t,r),e.mesh=this._mesh},rG._prepareRender=function(e){if(!this._mesh){uI.error("mesh is null.");return}if(this._mesh.destroyed){uI.error("mesh is destroyed.");return}rz.prototype._prepareRender.call(this,e)},rG._updateBounds=function(e){var t=this._mesh;if(t){var r=t.bounds,n=this._entity.transform.worldMatrix;c$.transform(r,n,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},rG._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,n=t._primitive.vertexElements;r.disableMacro(rU._uvMacro),r.disableMacro(rU._uv1Macro),r.disableMacro(rU._normalMacro),r.disableMacro(rU._tangentMacro),r.disableMacro(rU._enableVertexColorMacro);for(var a=0,i=n.length;a<i;a++)switch(n[a].attribute){case"TEXCOORD_0":r.enableMacro(rU._uvMacro);break;case"TEXCOORD_1":r.enableMacro(rU._uv1Macro);break;case"NORMAL":r.enableMacro(rU._normalMacro);break;case"TANGENT":r.enableMacro(rU._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(rU._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}var o=this._materials,s=this._engine,l=t.subMeshes,c=s._renderElementPool.get();c.set(this.priority,this._distanceForSort);for(var u=s._subRenderElementPool,d=0,h=l.length;d<h;d++){var _=o[d];if(_){(_.destroyed||_.shader.destroyed)&&(_=this.engine._meshMagentaMaterial);var f=u.get();f.set(this,_,t._primitive,l[d]),c.addSubRenderElement(f)}}e.camera._renderPipeline.pushRenderElement(e,c)},rG._setMesh=function(e){var t=this._mesh;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},rG._onMeshChanged=function(e){e&cm.Bounds&&(this._dirtyUpdateFlag|=co.WorldVolume),e&cm.VertexElements&&(this._dirtyUpdateFlag|=2)},ui(rU,[{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)}}]),rU);d0._uvMacro=uM.getByName("RENDERER_HAS_UV"),d0._uv1Macro=uM.getByName("RENDERER_HAS_UV1"),d0._normalMacro=uM.getByName("RENDERER_HAS_NORMAL"),d0._tangentMacro=uM.getByName("RENDERER_HAS_TANGENT"),d0._enableVertexColorMacro=uM.getByName("RENDERER_ENABLE_VERTEXCOLOR"),ul([uu],d0.prototype,"_mesh",void 0),ul([uu],d0.prototype,"_onMeshChanged",null),(rH=cg||(cg={}))[rH.VertexElementMacro=2]="VertexElementMacro",rH[rH.All=3]="All";var d1=((rj=(rW=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 c6,this._canUseTextureStoreData=!0,this._dataTextureInfo=new cZ,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(u9))},rj._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._layoutChangeManager.removeListener(this._updateLayoutChange);this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._blendShapes.length=0,this._blendShapeCount=0;for(var n=this._subDataDirtyFlags,a=0,i=n.length;a<i;a++)n[a].destroy();n.length=0},rj._updateShaderData=function(e,t){var r=this._blendShapeCount;if(r>0){if(e.enableMacro(rW._blendShapeMacro),this._useTextureMode())e.enableMacro(rW._blendShapeTextureMacro),e.setTexture(rW._blendShapeTextureProperty,this._vertexTexture),e.setVector3(rW._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(rW._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var n=this._getVertexBufferModeSupportCount();if(r>n){var a=t._condensedBlendShapeWeights;a||(a=new Float32Array(n),t._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,a),e.setFloatArray(rW._blendShapeWeightsProperty,a),this._modelMesh._primitive.enableVAO=!1,r=n}else e.setFloatArray(rW._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;e.disableMacro(rW._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?e.enableMacro(rW._blendShapeNormalMacro):e.disableMacro(rW._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(rW._blendShapeTangentMacro):e.disableMacro(rW._blendShapeTangentMacro)}else e.disableMacro(rW._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},rj._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},rj._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},rj._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},rj._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,r=e.length;t<r;t++)if(e[t].flag)return!0;return!1},rj._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,r=e._primitive.vertexBufferBindings,n=0,a=Math.max(r.length,t+1);n<a&&(r[n]||n===t);n++);this._bufferBindingOffset=n}},rj._addVertexElements=function(t){this._updateVertexBufferIndex();for(var r=this._vertexElementOffset,n=this._bufferBindingOffset,a=0,i=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<o;i++)t._setVertexElement(r++,new dV("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12,this._useBlendNormal&&(t._setVertexElement(r++,new dV("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12),this._useBlendTangent&&(t._setVertexElement(r++,new dV("TANGENT_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12);return r},rj._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))},rj._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,r=e.length;t<r;t++)e[t]._releaseData();this._vertices=null},rj._createVertexBuffers=function(t,r){var n=this._engine,a=this._modelMesh,i=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),u=Math.ceil(i/c),d=s*t*Math.min(c,i);o.length=u,this._vertices=new Float32Array(d),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=i;for(var h=this._bufferBindingOffset,_=0;_<u;_++){var f=u-1,p=(_===f?i-f*c:c)*l,m=p*t,g=r?e.BufferUsage.Static:e.BufferUsage.Dynamic,v=new dI(n,e.BufferBindFlag.VertexBuffer,m,g);a._setVertexBufferBinding(h+_,new dJ(v,p)),o[_]=v}},rj._createTextureArray=function(t){var r=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,a=n*t,i=1;a>r&&(i=Math.ceil(a/r),a=r);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new dl(this._engine,a,i,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*a*i*4),this._vertexTexture=o,this._dataTextureInfo.set(n,a,i)},rj._updateVertexBuffers=function(e,t){for(var r=this._blendShapes,n=this._maxCountSingleVertexBuffer,a=this._vertices,i=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,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=i[g],x=y.byteLength/(4*e),b=v*l,T=o[d];T||(o[d]=T=new c9),T.set(u+g,v*c);for(var C=m.deltaPositions,S=0;S<e;S++){var A=b+x*S,M=C[S];M&&(a[A]=M.x,a[A+1]=M.y,a[A+2]=M.z)}if(b+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var E=0;E<e;E++){var w=b+x*E,P=R[E];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var B=b+x*L,D=F[L];D&&(a[B]=D.x,a[B+1]=D.y,a[B+2]=D.z)}b+=3}(v===n-1||d===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},rj._updateTextureArray=function(e,t){for(var r=this._blendShapes,n=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=r.length;o<s;o++){var l=i[o],c=n.width*n.height*4;if(t||l.flag){var 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(a[m]=v.x,a[m+1]=v.y,a[m+2]=v.z,m+=4,f){var y=f[g];a[m]=y.x,a[m+1]=y.y,a[m+2]=y.z,m+=4}if(p){var x=p[g];a[m]=x.x,a[m+1]=x.y,a[m+2]=x.z,m+=4}}l.flag=!1}}n.setPixelBuffer(0,a)},rj._updateLayoutChange=function(e,t){var r=this._blendShapeCount>1,n=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;r&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&n++,i&&n++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=n},rj._attributeModeUpdateVertexElement=function(e,t,r,n){var a=this._vertexElementOffset+this._vertexElementCount*n,i=t[r],o=i.x,s=i.y,l=e[a];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++a];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++a];s+=12,u.bindingIndex=o,u.offset=s}},rj._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},rj._filterCondensedBlendShapeWeights=function(e,t){for(var r,n=t.length,a=this._modelMesh._primitive.vertexElements,i=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<n)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,r=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,r),t[r]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<n;u++){var d=t[u];d<o&&(o=d,r=u)}}}},rW);d1._blendShapeMacro=uM.getByName("RENDERER_HAS_BLENDSHAPE"),d1._blendShapeTextureMacro=uM.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),d1._blendShapeNormalMacro=uM.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),d1._blendShapeTangentMacro=uM.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),d1._blendShapeWeightsProperty=uO.getByName("renderer_BlendShapeWeights"),d1._blendShapeTextureProperty=uO.getByName("renderer_BlendShapeTexture"),d1._blendShapeTextureInfoProperty=uO.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(rK=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",rK.Normal="NORMAL",rK.Color="COLOR_0",rK.Tangent="TANGENT",rK.BoneWeight="WEIGHTS_0",rK.BoneIndex="JOINTS_0",rK.UV="TEXCOORD_0",rK.UV1="TEXCOORD_1",rK.UV2="TEXCOORD_2",rK.UV3="TEXCOORD_3",rK.UV4="TEXCOORD_4",rK.UV5="TEXCOORD_5",rK.UV6="TEXCOORD_6",rK.UV7="TEXCOORD_7";var d2=(us(rX=function(e,t){var r;return(r=dZ.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 cZ(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 d1(e,un(r)),r},dZ),(rY=rX.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)},rY.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},rY.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},rY.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},rY.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},rY.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},rY.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},rY.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},rY.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},rY.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},rY.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},rY.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},rY.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]."}},rY.getUVs=function(t){switch(t=null!=t?t:0){case 0:var r=this._getVertexElementData(this._uv,e.VertexAttribute.UV,6,this._readVector2VertexData);return this._uv=r,r;case 1:var n=this._getVertexElementData(this._uv1,e.VertexAttribute.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var a=this._getVertexElementData(this._uv2,e.VertexAttribute.UV2,8,this._readVector2VertexData);return this._uv2=a,a;case 3:var i=this._getVertexElementData(this._uv3,e.VertexAttribute.UV3,9,this._readVector2VertexData);return this._uv3=i,i;case 4:var o=this._getVertexElementData(this._uv4,e.VertexAttribute.UV4,10,this._readVector2VertexData);return this._uv4=o,o;case 5:var s=this._getVertexElementData(this._uv5,e.VertexAttribute.UV5,11,this._readVector2VertexData);return this._uv5=s,s;case 6:var l=this._getVertexElementData(this._uv6,e.VertexAttribute.UV6,12,this._readVector2VertexData);return this._uv6=l,l;case 7:var c=this._getVertexElementData(this._uv7,e.VertexAttribute.UV7,13,this._readVector2VertexData);return this._uv7=c,c}throw"The index of channel needs to be in range [0 - 7]."},rY.setIndices=function(t){this._indices!==t&&(this._indices=t,uc(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:uc(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:uc(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},rY.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},rY.setVertexElements=function(t){this._clearVertexElements();for(var r,n=t.length,a=0;a<n;a++)this._addVertexElement(t[a]);var i=this._primitive._vertexElementMap;i[e.VertexAttribute.Position]||this.setPositions(null),i[e.VertexAttribute.Normal]||this.setNormals(null),i[e.VertexAttribute.Color]||this.setColors(null),i[e.VertexAttribute.BoneWeight]||this.setBoneWeights(null),i[e.VertexAttribute.BoneIndex]||this.setBoneIndices(null),i[e.VertexAttribute.Tangent]||this.setTangents(null),i[e.VertexAttribute.UV]||this.setUVs(null,0),i[e.VertexAttribute.UV1]||this.setUVs(null,1),i[e.VertexAttribute.UV2]||this.setUVs(null,2),i[e.VertexAttribute.UV3]||this.setUVs(null,3),i[e.VertexAttribute.UV4]||this.setUVs(null,4),i[e.VertexAttribute.UV5]||this.setUVs(null,5),i[e.VertexAttribute.UV6]||this.setUVs(null,6),i[e.VertexAttribute.UV7]||this.setUVs(null,7);var o=this._internalVertexBufferCreatedInfo.z;-1!==o&&(null==(r=this._primitive.vertexBufferBindings[o])||r.buffer.destroy(),this._setVertexBufferBinding(o,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=n,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=n},rY.setVertexBufferBinding=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=0);var n=e,a=void 0!==n.buffer;a||(n=new dJ(e,t));var i=a?t:r,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,n),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},rY.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var r=e.length,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+r;n.length<i&&(n.length=i,a.length=i);for(var o=0;o<r;o++){var s=t+o;this._setVertexBufferBinding(s,e[o]),s===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),s===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1)}this._vertexCountDirty=!0},rY.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},rY.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},rY.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},rY.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},rY.uploadData=function(t){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(t),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var r=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,a=0,i=n.length;a<i;a++){var o=r[a];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=n[a])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c=this._indices,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 dX(u,this._indicesFormat));else{null==u||u.destroy();var d,h=new dI(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new dX(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))},rY.calculateTangents=function(){var e=this.getPositions(),t=this.getNormals(),r=this.getUVs();if(!t||!r)throw"Set normal and uv before calculation.";for(var n=this._indices,a=this.vertexCount,i=rX._tempVec0,o=rX._tempVec1,s=rX._tempVec2,l=rX._tempVec3,c=rX._tempVec4,u=n?n.length/3:e.length/3,d=Array(a),h=Array(a),_=0;_<a;_++)d[_]=new c6,h[_]=new cZ;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],b=r[p],T=r[m],C=r[g];cZ.subtract(y,v,i),cZ.subtract(x,v,o);var S=T.x-b.x,A=C.x-b.x,M=T.y-b.y,R=C.y-b.y,E=1/(S*R-A*M);cZ.scale(i,R*E,s),cZ.scale(o,M*E,c),cZ.subtract(s,c,s),cZ.scale(o,S*E,l),cZ.scale(i,A*E,c),cZ.subtract(l,c,l);var w=d[p];w.set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=d[m]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),(w=d[g]).set(w.x+s.x,w.y+s.y,w.z+s.z,1),h[p].add(l),h[m].add(l),h[g].add(l)}for(var P=0;P<a;P++){var F=t[P],L=h[P],B=d[P];s.set(B.x,B.y,B.z),cZ.cross(s,L,c);var D=cZ.dot(c,F)>0?1:-1;cZ.scale(F,cZ.dot(s,F),c),cZ.subtract(s,c,s),s.normalize(),B.set(s.x,s.y,s.z,D)}this.setTangents(d)},rY._setVertexBufferBinding=function(e,t){var r=this,n=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=function(){r._advancedDataSyncToBuffer||(a[e].dataVersion=r._dataVersionCounter++)},o=n[e];o&&o.buffer._dataUpdateManager.removeListener(i),dZ.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(i),(a[e]||(a[e]=new d3)).reset(),i()):e+1==n.length&&n.length--},rY._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)}},rY._onDestroy=function(){dZ.prototype._onDestroy.call(this),this._releaseCache(!0)},rY._getVertexElementData=function(e,t,r,n){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[r])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[r]=l,n.call(this,t))},rY._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)},rY._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},rY._updateInternalVertexBuffer=function(t){var r=this._internalVertexBufferStride,n=this.vertexCount,a=this._internalVertexBufferCreatedInfo,i=r*n;if(a.x*a.y!==i){var o,s=a.z;-1!==s&&(null==(o=this._primitive.vertexBufferBindings[s])||o.buffer.destroy(),this._setVertexBufferBinding(s,null));var l=this._internalVertexBufferIndex,c=r*this.vertexCount>0;if(c){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var u=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,d=new dI(this._engine,e.BufferBindFlag.VertexBuffer,i,u,!0);this._setVertexBufferBinding(l,new dJ(d,r))}a.set(r,n,c?l:-1)}},rY._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new c9(e[t],e[t+1])})},rY._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new cZ(e[t],e[t+1],e[t+2])})},rY._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new c6(e[t],e[t+1],e[t+2],e[t+3])})},rY._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new c7(e[t],e[t+1],e[t+2],e[t+3])})},rY._readVertexData=function(e,t){var r=this._primitive,n=r._vertexElementMap[e];if(!n)return null;var a=r.vertexBufferBindings[n.bindingIndex],i=null==a?void 0:a.buffer;if(!i)return null;if(!i.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var o=this.vertexCount,s=n._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),u=n.offset,d=a.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},rY._updateAdvancedVertexElement=function(e,t,r){var n=this._primitive._vertexElementMap;if(e){if(!n[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new dV(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=r,this._blendShapeManager._vertexElementOffset++}}else{var s=n[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~r):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},rY._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)},rY._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,r=e.length,n=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(n!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<r&&this._setVertexElementsLength(i)}},rY._writeVector2AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y)})},rY._writeVector3AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},rY._writeVector4AdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},rY._writeColorAdvancedVertexData=function(e,t,r){this._writeAdvancedVertexData(e,t,function(e,t,n){var a=r[n];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},rY._writeAdvancedVertexData=function(e,t,r){var n,a=this._primitive,i=a._vertexElementMap[e],o=i.bindingIndex,s=a.vertexBufferBindings[o],l=null==s?void 0:s.buffer;if(l){if(!l.readable)throw"Vertex buffer is not readable, can't write vertex data.";var c=null!=(n=this._advancedVertexDataVersions[t])?n:-1,u=this._vertexBufferInfos[o];if(c>u.dataVersion){for(var d=i._formatMetaInfo,h=this._getVertexTypedArray(l.data.buffer,d.type),_=i.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 b=(y*f+_)/p;if(r(h,b,y),m)for(var T=0;T<g;T++)h[b+T]/=v}u.uploadAdvancedData=!0}}},rY._updateAdvancedVertices=function(){var t=this._positions,r=this._normals,n=this._colors,a=this._advancedDataUpdateFlag,i=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,u=this._uv2,d=this._uv3,h=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),r&&2&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,r),n&&4&a&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,n),i&&16&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneWeight,4,i),o&&32&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.BoneIndex,5,o),s&&8&a&&this._writeVector4AdvancedVertexData(e.VertexAttribute.Tangent,3,s),l&&64&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV,6,l),c&&128&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV1,7,c),u&&256&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV2,8,u),d&&512&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,d),h&&1024&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,h),_&&2048&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV5,11,_),f&&4096&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV6,12,f),p&&8192&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV7,13,p),this._advancedDataUpdateFlag=0},rY._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},rY._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}},rY._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}},rY._releaseCache=function(e){if(this._positions=null,this._tangents=null,this._normals=null,this._colors=null,this._boneIndices=null,this._boneWeights=null,this._uv=null,this._uv1=null,this._uv2=null,this._uv3=null,this._uv4=null,this._uv5=null,this._uv6=null,this._uv7=null,this._indices=null,this._blendShapeManager._releaseMemoryCache(),!e){null==(t=this._primitive.vertexBufferBindings[this._internalVertexBufferIndex])||t.buffer.markAsUnreadable();for(var t,r=this._dataVersionCounter++,n=this._vertexBufferInfos,a=0,i=n.length;a<i;a++){var o=n[a];o&&(o.dataVersion=r)}}},ui(rX,[{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}}]),rX);d2._tempVec0=new cZ,d2._tempVec1=new cZ,d2._tempVec2=new cZ,d2._tempVec3=new cZ,d2._tempVec4=new cZ;var d3=((rq=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},rq);(rQ=cv||(cv={}))[rQ.None=0]="None",rQ[rQ.Position=1]="Position",rQ[rQ.Normal=2]="Normal",rQ[rQ.Color=4]="Color",rQ[rQ.Tangent=8]="Tangent",rQ[rQ.BoneWeight=16]="BoneWeight",rQ[rQ.BoneIndex=32]="BoneIndex",rQ[rQ.UV=64]="UV",rQ[rQ.UV1=128]="UV1",rQ[rQ.UV2=256]="UV2",rQ[rQ.UV3=512]="UV3",rQ[rQ.UV4=1024]="UV4",rQ[rQ.UV5=2048]="UV5",rQ[rQ.UV6=4096]="UV6",rQ[rQ.UV7=8192]="UV7",rQ[rQ.All=65535]="All",(rZ=cy||(cy={}))[rZ.Position=0]="Position",rZ[rZ.Normal=1]="Normal",rZ[rZ.Color=2]="Color",rZ[rZ.Tangent=3]="Tangent",rZ[rZ.BoneWeight=4]="BoneWeight",rZ[rZ.BoneIndex=5]="BoneIndex",rZ[rZ.UV=6]="UV",rZ[rZ.UV1=7]="UV1",rZ[rZ.UV2=8]="UV2",rZ[rZ.UV3=9]="UV3",rZ[rZ.UV4=10]="UV4",rZ[rZ.UV5=11]="UV5",rZ[rZ.UV6=12]="UV6",rZ[rZ.UV7=13]="UV7";var d4=(us(rJ=function(e,t){var r;return(r=dR.call(this,e)||this).primitiveInfo=t,r},dR),rJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:ha._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:ha._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:ha._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:ha._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:ha._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:ha._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:ha._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:ha._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},rJ);(r$=cx||(cx={}))[r$.Sphere=0]="Sphere",r$[r$.Cuboid=1]="Cuboid",r$[r$.Plane=2]="Plane",r$[r$.Cylinder=3]="Cylinder",r$[r$.Torus=4]="Torus",r$[r$.Cone=5]="Cone",r$[r$.Capsule=6]="Capsule",r$[r$.CCSphere=7]="CCSphere";var d8=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},d5=(us(r0=function(e,t,r,n){var a;return(a=d8.call(this,0,r,n)||this).radius=e,a.segments=t,a},d8),r0),d9=(us(r1=function(e,t,r,n){var a;return(a=d8.call(this,7,r,n)||this).radius=e,a.step=t,a},d8),r1),d6=(us(r2=function(e,t,r,n,a){var i;return(i=d8.call(this,1,n,a)||this).width=e,i.height=t,i.depth=r,i},d8),r2),d7=(us(r3=function(e,t,r,n,a,i){var o;return(o=d8.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},d8),r3),he=(us(r4=function(e,t,r,n,a,i,o){var s;return(s=d8.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=a,s},d8),r4),ht=(us(r8=function(e,t,r,n,a,i,o){var s;return(s=d8.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=a,s},d8),r8),hr=(us(r5=function(e,t,r,n,a,i){var o;return(o=d8.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d8),r5),hn=(us(r9=function(e,t,r,n,a,i){var o;return(o=d8.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},d8),r9),ha=((r6=function(){}).createSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=18),void 0===n&&(n=!0);var a=new d2(e);r6._setSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(a,new d5(t,r,i,n))),a},r6.createSubdivisionSurfaceSphere=function(e,t,r,n){void 0===t&&(t=.5),void 0===r&&(r=3),void 0===n&&(n=!0);var a=new d2(e);r6._setSubdivisionSurfaceSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(a,new d9(t,r,i,n))),a},r6.createCuboid=function(e,t,r,n,a){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=!0);var i=new d2(e);r6._setCuboidData(i,t,r,n,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(i,new d6(t,r,n,o,a))),i},r6.createPlane=function(e,t,r,n,a,i){void 0===t&&(t=1),void 0===r&&(r=1),void 0===n&&(n=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d2(e);r6._setPlaneData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(o,new d7(t,r,n,a,s,i))),o},r6.createCylinder=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new d2(e);r6._setCylinderData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(s,new he(t,r,n,a,i,l,o))),s},r6.createTorus=function(e,t,r,n,a,i,o){void 0===t&&(t=.5),void 0===r&&(r=.1),void 0===n&&(n=30),void 0===a&&(a=30),void 0===i&&(i=360),void 0===o&&(o=!0);var s=new d2(e);r6._setTorusData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(s,new ht(t,r,n,a,i,l,o))),s},r6.createCone=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=20),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d2(e);r6._setConeData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(o,new hr(t,r,n,a,s,i))),o},r6.createCapsule=function(e,t,r,n,a,i){void 0===t&&(t=.5),void 0===r&&(r=2),void 0===n&&(n=6),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new d2(e);r6._setCapsuleData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new d4(o,new hn(t,r,n,a,s,i))),o},r6._setSubdivisionSurfaceSphereData=function(e,t,r,n,a,i){r=cQ.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));r6._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),_=r6._generateIndices(e.engine,l,6*c),f=0,p={},m=0;m<l;m++){var g=3*m,v=o[g],y=o[g+1],x=o[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*t,h[g+1]=y*t,h[g+2]=x*t,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var T=8*(l+f++);h.set(h.subarray(g,g+8),T),h[T+6]=1,p[g/8]=T/8}}var C=0;this._spherePoleIdx=0;for(var S=0;S<c;S++){var A=4*S,M=s[A],R=s[A+1],E=s[A+2],w=s[A+3],P=8*M,F=8*R,L=8*E,B=8*w;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]&&(E=p[E]),0===h[B+6]&&(w=p[w])),_[C]=M,_[C+1]=R,_[C+2]=E,this._generateAndReplacePoleUV(_,h,C,u),_[C+3]=M,_[C+4]=E,_[C+5]=w,this._generateAndReplacePoleUV(_,h,C+3,u),C+=6}if(!a){var D=e.bounds;D.min.set(-t,-t,-t),D.max.set(t,t,t)}r6._initialize(e,h,_,n,a,i)},r6._setSphereData=function(e,t,r,n,a,i){for(var o=(r=Math.max(2,Math.floor(r)))+1,s=o*o,l=r*r,c=r6._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),b=-t*Math.cos(v)*x,T=t*Math.cos(y),C=t*Math.sin(v)*x,S=8*p;f[S++]=b,f[S++]=T,f[S++]=C,f[S++]=b,f[S++]=T,f[S++]=C,f[S++]=m,f[S++]=g}for(var A=0,M=0;M<l;++M){var R=M%r,E=(M*_|0)*o+R,w=E+1,P=E+o,F=P+1;c[A++]=w,c[A++]=E,c[A++]=F,c[A++]=E,c[A++]=P,c[A++]=F}if(!a){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}r6._initialize(e,f,c,n,a,i)},r6._subdiveCatmullClark=function(e,t,r){var n=new Map,a=[];t.set(r6._sphereSeedPositions),r.set(r6._sphereSeedCells);for(var i=0;i<e;i++){var o=6*Math.pow(4,i),s=4*o+2;n.clear(),a.length=0;for(var l=0;l<o;l++){for(var c=a[l]={facePoint:new cZ,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 cZ,edgePointIndex:void 0},g=3*_,v=3*f;m.edgePoint.set(.25*(t[g]+t[v]),.25*(t[g+1]+t[v+1]),.25*(t[g+2]+t[v+2])),n.set(p,m)}var y=n.get(p);c.adjacentEdges[h]=y;var x=y.edgePoint,b=c.facePoint;x.x+=.25*b.x,x.y+=.25*b.y,x.z+=.25*b.z}}var T=o+2,C=T+o,S=0;this._sphereEdgeIdx=0;for(var A=r.slice(0,4*o),M=0;M<o;M++){var R=a[M];R.facePoint.copyToArray(t,3*(T+M));for(var E=T+M,w=void 0,P=void 0,F=void 0,L=0;L<4;L++){var B=A[S++];switch(L){case 0:var D=R.adjacentEdges[L%4],I=R.adjacentEdges[(L+3)%4];P=this._calculateEdgeIndex(t,D,C),F=w=this._calculateEdgeIndex(t,I,C);break;case 1:case 2:var O=R.adjacentEdges[L%4];w=P,P=this._calculateEdgeIndex(t,O,C);break;case 3:w=P,P=F}var V=4*(4*M+L);r[V]=B,r[V+1]=P,r[V+2]=E,r[V+3]=w}}}},r6._generateAndReplacePoleUV=function(e,t,r,n){var a=t[8*e[r]+7];if(0===a||1===a){var i=8*e[r],o=8*(n+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[r+1]+6]+t[8*e[r+2]+6]-.5),e[r]=n+this._spherePoleIdx++}},r6._calculateEdgeIndex=function(e,t,r){if(void 0!==t.edgePointIndex)return t.edgePointIndex;t.edgePoint.copyToArray(e,3*(r+r6._sphereEdgeIdx));var n=r+r6._sphereEdgeIdx++;return t.edgePointIndex=n,n},r6._setCuboidData=function(e,t,r,n,a,i,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 b=0;b<4;b++){var T=8*b+163;u[T++]=0,u[T++]=0,u[T++]=-1}var C=new Uint16Array(36);if(C[0]=0,C[1]=2,C[2]=1,C[3]=2,C[4]=0,C[5]=3,C[6]=4,C[7]=6,C[8]=7,C[9]=6,C[10]=4,C[11]=5,C[12]=8,C[13]=10,C[14]=9,C[15]=10,C[16]=8,C[17]=11,C[18]=12,C[19]=14,C[20]=15,C[21]=14,C[22]=12,C[23]=13,C[24]=16,C[25]=18,C[26]=17,C[27]=18,C[28]=16,C[29]=19,C[30]=20,C[31]=22,C[32]=23,C[33]=22,C[34]=20,C[35]=21,!i){var S=e.bounds;S.min.set(-s,-l,-c),S.max.set(s,l,c)}r6._initialize(e,u,C,a,i,o)},r6._setPlaneData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(1,Math.floor(n)))+1,c=(a=Math.max(1,Math.floor(a)))+1,u=t/2,d=r/2,h=t/n,_=r/a,f=l*c,p=a*n,m=r6._generateIndices(e.engine,f,6*p),g=1/l,v=1/n,y=1/a,x=new Float32Array(8*f),b=0;b<f;++b){var T=b%l,C=b*g|0,S=8*b;x[S++]=T*h-u,x[S++]=0,x[S++]=C*_-d,x[S++]=0,x[S++]=1,x[S++]=0,x[S++]=T*v,x[S++]=C*y}for(var A=0,M=0;M<p;++M){var R=M%n,E=(M*v|0)*l+R,w=E+1,P=E+l,F=P+1;m[A++]=E,m[A++]=P,m[A++]=w,m[A++]=P,m[A++]=F,m[A++]=w}if(!o){var L=e.bounds;L.min.set(-u,0,-d),L.max.set(u,0,d)}r6._initialize(e,x,m,i,o,s)},r6._setCylinderData=function(e,t,r,n,a,i,o,s,l){void 0===t&&(t=.5),void 0===r&&(r=.5),void 0===n&&(n=2),void 0===a&&(a=20),void 0===i&&(i=1);for(var c=(a=Math.floor(a))+1,u=(i=Math.floor(i))+1,d=.5*n,h=n/i,_=c*u,f=a*i,p=2*a,m=_+2+p,g=r6._generateIndices(e.engine,m,6*f+3*p),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*m),T=0,C=Math.PI,S=2*Math.PI,A=r-t,M=A/n,R=A/i,E=0;E<_;++E){var w=E%c,P=E*v|0,F=w*y,L=P*x,B=C+F*S,D=Math.sin(B),I=Math.cos(B),O=r-P*R,V=O*D,N=P*h-d,k=O*I,z=8*E;b[z++]=V,b[z++]=N,b[z++]=k,b[z++]=D,b[z++]=M,b[z++]=I,b[z++]=F,b[z++]=1-L}for(var U=0;U<f;++U){var G=U%a,H=(U*y|0)*c+G,W=H+1,j=H+c,K=j+1;g[T++]=W,g[T++]=j,g[T++]=H,g[T++]=W,g[T++]=K,g[T++]=j}var X=8*_;b[X++]=0,b[X++]=-d,b[X++]=0,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=.5,b[X++]=.5,b[X++]=0,b[X++]=d,b[X++]=0,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=.5,b[X++]=.5,X=(_+2)*8;for(var Y=1/(2*t),q=1/(2*r),Q=c*i,Z=0;Z<a;++Z){var J=8*Z,$=b[J],ee=b[J+2];b[X++]=$,b[X++]=-d,b[X++]=ee,b[X++]=0,b[X++]=-1,b[X++]=0,b[X++]=$*q+.5,b[X++]=.5-ee*q;var et=(Z+Q)*8;$=b[et],ee=b[et+2],b[X++]=$,b[X++]=d,b[X++]=ee,b[X++]=0,b[X++]=1,b[X++]=0,b[X++]=$*Y+.5,b[X++]=.5-ee*Y}for(var er=_+1,en=_+2,ea=en+1,ei=0;ei<a;++ei){var eo=2*ei,es=ei===a-1?0:eo+2;g[T++]=_,g[T++]=en+es,g[T++]=en+eo,g[T++]=er,g[T++]=ea+eo,g[T++]=ea+es}if(!s){var el=e.bounds,ec=Math.max(t,r);el.min.set(-ec,-d,-ec),el.max.set(ec,d,ec)}r6._initialize(e,b,g,o,s,l)},r6._setTorusData=function(e,t,r,n,a,i,o,s,l){var c=((n=Math.floor(n))+1)*((a=Math.floor(a))+1),u=n*a,d=r6._generateIndices(e.engine,c,6*u),h=new Float32Array(8*c);i=i/180*Math.PI;for(var _=0,f=r6._tempVec30,p=0;p<=n;p++)for(var m=0;m<=a;m++){var g=m/a*i,v=p/n*Math.PI*2,y=Math.cos(v),x=Math.cos(g),b=Math.sin(g),T=(t+r*y)*x,C=(t+r*y)*b,S=r*Math.sin(v);h[_++]=T,h[_++]=C,h[_++]=S;var A=t*x,M=t*b;f.set(T-A,C-M,S).normalize(),h[_++]=f.x,h[_++]=f.y,h[_++]=f.z,h[_++]=m/a,h[_++]=p/n}_=0;for(var R=1;R<=n;R++)for(var E=1;E<=a;E++){var w=(a+1)*R+E-1,P=(a+1)*(R-1)+E-1,F=(a+1)*(R-1)+E,L=(a+1)*R+E;d[_++]=w,d[_++]=P,d[_++]=L,d[_++]=P,d[_++]=F,d[_++]=L}if(!s){var B=e.bounds,D=t+r;B.min.set(-D,-D,-r),B.max.set(D,D,r)}r6._initialize(e,h,d,o,s,l)},r6._setConeData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.floor(n))+1,c=(a=Math.floor(a))+1,u=.5*r,d=r/a,h=l*c,_=n*a,f=h+1+n,p=r6._generateIndices(e.engine,f,6*_+3*n),m=1/l,g=1/n,v=1/a,y=new Float32Array(8*f),x=0,b=Math.PI,T=2*Math.PI,C=t/r,S=0;S<h;++S){var A=S%l,M=S*m|0,R=A*g,E=M*v,w=b+R*T,P=Math.sin(w),F=Math.cos(w),L=t-E*t,B=L*P,D=M*d-u,I=L*F,O=8*S;y[O++]=B,y[O++]=D,y[O++]=I,y[O++]=P,y[O++]=C,y[O++]=F,y[O++]=R,y[O++]=1-E}for(var V=0;V<_;++V){var N=V%n,k=(V*g|0)*l+N,z=k+1,U=k+l,G=U+1;p[x++]=z,p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=G,p[x++]=U}var H=8*h;y[H++]=0,y[H++]=-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),j=0;j<n;++j){var K=y[8*j],X=y[8*j+2];y[H++]=K,y[H++]=-u,y[H++]=X,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=K*W+.5,y[H++]=.5-X*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)}r6._initialize(e,y,p,i,o,s)},r6._setCapsuleData=function(e,t,r,n,a,i,o,s){for(var l=(n=Math.max(2,Math.floor(n)))+1,c=(a=Math.floor(a))+1,u=.5*r,d=r/a,h=l*c,_=n*a,f=l*l,p=n*n,m=h+2*f,g=r6._generateIndices(e.engine,m,(_+2*p)*6),v=1/l,y=1/n,x=1/a,b=Math.PI,T=2*Math.PI,C=new Float32Array(8*m),S=0,A=0;A<h;++A){var M=A%l,R=A*v|0,E=M*y,w=R*x,P=b+E*T,F=Math.sin(P),L=Math.cos(P),B=8*A;C[B++]=t*F,C[B++]=R*d-u,C[B++]=t*L,C[B++]=F,C[B++]=0,C[B++]=L,C[B++]=E,C[B++]=1-w}for(var D=0;D<_;++D){var I=D%n,O=(D*y|0)*l+I,V=O+1,N=O+l,k=N+1;g[S++]=V,g[S++]=N,g[S++]=O,g[S++]=V,g[S++]=k,g[S++]=N}if(r6._createCapsuleCap(t,r,n,b,T,h,1,C,g,S),r6._createCapsuleCap(t,r,n,b,-T,h+f,-1,C,g,S+6*p),!o){var z=e.bounds;z.min.set(-t,-t-u,-t),z.max.set(t,t+u,t)}r6._initialize(e,C,g,i,o,s)},r6._initialize=function(t,r,n,a,i,o){if(i)o.setData(r),t.setIndices(n),t.uploadData(a);else{var s=[new dV(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new dV(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new dV(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new dI(t.engine,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(n),t.calculateTangents(),t.uploadData(a),t.addSubMesh(0,n.length)}},r6._generateIndices=function(t,r,n){var a=null;if(r>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))a=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(n);return a},r6._createCapsuleCap=function(e,t,r,n,a,i,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*a,x=v*Math.PI*.5,b=Math.sin(x),T=e*Math.sin(y)*b,C=e*Math.cos(x)*o+d,S=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=T,s[A++]=C,s[A++]=S,s[A++]=T,s[A++]=C-d,s[A++]=S,s[A++]=g,s[A++]=v}for(var M=0;M<_;++M){var R=M%r,E=(M*p|0)*u+R+i,w=E+1,P=E+u,F=P+1;l[c++]=w,l[c++]=E,l[c++]=F,l[c++]=E,l[c++]=P,l[c++]=F}},r6);function hi(e,t,r){return(hi=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&uo(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}ha._tempVec30=new cZ,ha._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]),ha._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]),ha._sphereEdgeIdx=0,ha._spherePoleIdx=0;var ho=((r7=function(){}).cloneComponent=function(e,t,r,n,a){var i=uf.getCloneMode(e.constructor);for(var o in e)uf.cloneProperty(e,t,o,i[o],r,n,a);e._cloneTo&&e._cloneTo(t,r,n)},r7),hs=(us(ne=function(t,r){var n;return(n=up.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new dr,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._isTemplate=!1,n._parent=null,n._invModelMatrix=new c8,n.name=r,n.transform=n.addComponent(u6),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},up),(nt=ne.prototype).addComponent=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];u8._addCheck(this,e);var a=hi(e,[].concat(this,r));return this._components.push(a),a._setActive(!0,ca.All),a},nt.getComponent=function(e){for(var t=this._components,r=0,n=t.length;r<n;r++){var a=t[r];if(uc(a,e))return a}return null},nt.getComponents=function(e,t){t.length=0;for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];uc(i,e)&&t.push(i)}return t},nt.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},nt.addChild=function(e,t){var r;if("number"==typeof e?r=e:(r=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(r,t),t._parent=this;var n=t._scene,a=this._scene,i=ca.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=ca.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==a&&(i|=ca.Scene):i|=ca.Scene),i&&t._processInActive(i),t._scene!==a&&ne._traverseSetOwnerScene(t,a);var o=ca.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=ca.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===a||(o|=ca.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,r)},nt.removeChild=function(e){e._setParent(null)},nt.getChild=function(e){return this._children[e]},nt.findByName=function(e){if(e===this.name)return this;for(var t=this._children,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},nt.findByPath=function(e){for(var t=e.split("/"),r=this,n=0,a=t.length;n<a;++n){var i=t[n];if(i&&!(r=ne._findChildByName(r,i)))return null}return r},nt.createChild=function(e){var t=new ne(this.engine,e);return t.layer=this.layer,t.parent=this,t},nt.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var r=e[t];r._parent=null;var n=ca.None;r._isActiveInHierarchy&&(n|=ca.Hierarchy),r._isActiveInScene&&(n|=ca.Scene),n&&r._processInActive(n),ne._traverseSetOwnerScene(r,null)}e.length=0},nt.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},nt._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},nt._createCloneEntity=function(){var e=new ne(this._engine,this.name),t=this._templateResource;t&&(e._templateResource=t,t._addReferCount(1)),e.layer=this.layer,e._isActive=this._isActive;var r=e.transform,n=this.transform;r.position=n.position,r.rotation=n.rotation,r.scale=n.scale;for(var a=this._children,i=0,o=a.length;i<o;i++)e.addChild(a[i]._createCloneEntity());return e},nt._parseCloneEntity=function(e,t,r,n,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],r,n,a);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!uc(h,u6)){var _=t.addComponent(h.constructor);ho.cloneComponent(h,_,r,n,a)}}},nt.destroy=function(){if(!this._destroyed){up.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var r=this._children;r.length>0;)r[0].destroy();this._isRoot?this._scene.removeRootEntity(this):this._setParent(null),this.isActive=!1}},nt._removeComponent=function(e){u8._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},nt._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},nt._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},nt._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}},nt._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)},nt._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)},nt._addToChildrenList=function(e,t){var r=this._children,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},nt._setParent=function(e,t){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var n=this._scene,a=e._scene,i=ca.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=ca.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==a&&(i|=ca.Scene):this._isActiveInScene&&(i|=ca.Scene),i&&this._processInActive(i),n!==a&&ne._traverseSetOwnerScene(this,a);var o=ca.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=ca.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===a||(o|=ca.Scene))),o&&this._processActive(o)}else{var s=ca.None;this._isActiveInHierarchy&&(s|=ca.Hierarchy),this._isActiveInScene&&(s|=ca.Scene),s&&this._processInActive(s),r&&ne._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},nt._getComponentsInChildren=function(e,t){for(var r=this._components.length-1;r>=0;r--){var n=this._components[r];uc(n,e)&&t.push(n)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},nt._setActiveComponents=function(e,t){for(var r=this._activeChangedComponents,n=0,a=r.length;n<a;++n)r[n]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(r),this._activeChangedComponents=null},nt._setActiveInHierarchy=function(e,t){t&ca.Hierarchy&&(this._isActiveInHierarchy=!0),t&ca.Scene&&(this._isActiveInScene=!0);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];(i.enabled||!i._awoken)&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setActiveInHierarchy(e,t)}},nt._setInActiveInHierarchy=function(e,t){t&ca.Hierarchy&&(this._isActiveInHierarchy=!1),t&ca.Scene&&(this._isActiveInScene=!1);for(var r=this._components,n=0,a=r.length;n<a;n++){var i=r[n];i.enabled&&e.push(i)}for(var o=this._children,s=0,l=o.length;s<l;s++){var c=o[s];c.isActive&&c._setInActiveInHierarchy(e,t)}},nt._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},nt._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var r=this._siblingIndex;if(t<r)for(var n=r;n>=t;n--){var a=n==t?this:e[n-1];e[n]=a,a._siblingIndex=n}else for(var i=r;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},nt.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(c8.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},ne._findChildByName=function(e,t){for(var r=e._children,n=r.length-1;n>=0;n--){var a=r[n];if(a.name===t)return a}return null},ne._traverseSetOwnerScene=function(e,t){e._scene=t;for(var r=e._children,n=r.length-1;n>=0;n--)this._traverseSetOwnerScene(r[n],t)},ne._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},ne._getEntityByHierarchyPath=function(e,t){for(var r=e,n=t.length-1;n>=0;n--)r=r.children[t[n]];return r},ui(ne,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,r=ca.None;this._isRoot&&this._scene._isActiveInEngine?r|=ca.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=ca.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=ca.Scene)),r&&this._processActive(r)}else{var n=ca.None;this._isActiveInHierarchy&&(n|=ca.Hierarchy),this._isActiveInScene&&(n|=ca.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)}}]),ne),hl=(us(nr=function(e){var t;return(t=up.call(this,null)||this).name=e,t.inverseBindMatrices=[],t._updatedManager=new uT,t._bones=[],t._updateMark=-1,t.joints=[],t},up),(nn=nr.prototype)._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,r=this.bones,n=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=r.length-1;o>=0;o--){var s=r[o],l=16*o;s?uv._floatMatrixMultiply(s.transform.worldMatrix,n[o].elements,0,a,l):a.set(n[o].elements,l),uv._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},nn._cloneTo=function(e,t,r){var n=[],a=this.rootBone;if(a){var i=hs._getEntityHierarchyPath(t,a,n);e.rootBone=i?hs._getEntityByHierarchyPath(r,n):a}var o=this.bones;if(o.length>0){for(var s=o.length,l=Array(s),c=0;c<s;c++){var u=o[c],d=hs._getEntityHierarchyPath(t,u,n);l[c]=d?hs._getEntityByHierarchyPath(r,n):u}e.bones=l}},ui(nr,[{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._rootBone!==e&&(this._updatedManager.dispatch(1,e),this._rootBone=e)}},{key:"bones",get:function(){return this._bones},set:function(e){var t,r=this._bones,n=null!=(t=null==e?void 0:e.length)?t:0,a=r.length;r.length=n;for(var i=0;i<n;i++)r[i]=e[i];a!==n&&(this._skinMatrices=new Float32Array(16*n),this._updatedManager.dispatch(0,n))}},{key:"skeleton",get:function(){var e;return null==(e=this.rootBone)?void 0:e.name},set:function(e){var t=this._rootBone;t&&(t.name=e)}}]),nr);ul([u_],hl.prototype,"inverseBindMatrices",void 0),ul([uu],hl.prototype,"_skinMatrices",void 0),ul([uu],hl.prototype,"_updatedManager",void 0),ul([uu],hl.prototype,"_rootBone",void 0),ul([uu],hl.prototype,"_bones",void 0),ul([uu],hl.prototype,"_updateMark",void 0),(na=cb||(cb={}))[na.BoneCountChanged=0]="BoneCountChanged",na[na.RootBoneChanged=1]="RootBoneChanged";var hc=(us(ni=function(e){(t=d0.call(this,e)||this)._localBounds=new c$,t._jointDataCreateCache=new c9(-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(un(t)),t._onSkinUpdated=t._onSkinUpdated.bind(un(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},d0),(no=ni.prototype)._updateTransformShaderData=function(e,t,r){var n,a,i=(null!=(a=null==(n=this.skin)?void 0:n.rootBone)?a:this.entity).transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,i,r):this._updateWorldViewRelatedShaderData(e,i,r)},no._onDestroy=function(){var e;d0.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(e=this._jointTexture)||e.destroy(),this._jointTexture=null},no._cloneTo=function(e,t,r){d0.prototype._cloneTo.call(this,e,t,r),this.skin&&e._applySkin(null,e.skin),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},no._update=function(t){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var n=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(n,this);var i=null==r?void 0:r.bones;if(i){var o=a._uniformOccupiesCount,s=i.length,l=this._jointDataCreateCache,c=s!==l.x;if(c||o!==l.y){var u,d=Math.ceil((this._maxVertexUniformVectors-(44+o))/4);if(s>d){var h,_=this.engine;_._hardwareRenderer.canIUseMoreJoints?(c&&(null==(h=this._jointTexture)||h.destroy(),this._jointTexture=new ds(_,4,s,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),n.disableMacro("RENDERER_JOINTS_NUM"),n.enableMacro("RENDERER_USE_JOINT_TEXTURE"),n.setTexture(ni._jointSamplerProperty,this._jointTexture)):uI.error("component's joints count("+s+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+d+".",this)}else null==(u=this._jointTexture)||u.destroy(),n.disableMacro("RENDERER_USE_JOINT_TEXTURE"),n.enableMacro("RENDERER_JOINTS_NUM",d.toString()),n.setFloatArray(ni._jointMatrixProperty,r._skinMatrices);l.set(s,o)}this._jointTexture&&this._jointTexture.setPixelBuffer(r._skinMatrices)}d0.prototype._update.call(this,t)},no._updateBounds=function(e){var t,r=null==(t=this.skin)?void 0:t.rootBone;r?c$.transform(this._localBounds,r.transform.worldMatrix,e):d0.prototype._updateBounds.call(this,e)},no._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,r=this._blendShapeWeights;if(r){var n=r.length;if(n!==t){var a=new Float32Array(t);if(t>n)a.set(r);else for(var i=0;i<t;i++)a[i]=r[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},no._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=co.WorldVolume},no._onSkinUpdated=function(e,t){switch(e){case cb.BoneCountChanged:var r=this.shaderData;t>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(ni._jointCountProperty,t)):r.disableMacro("RENDERER_HAS_SKIN");break;case cb.RootBoneChanged:this._dirtyUpdateFlag|=co.WorldVolume}},no._applySkin=function(e,t){var r,n,a,i,o,s,l=null!=(a=null==e?void 0:null==(r=e.bones)?void 0:r.length)?a:0,c=null!=(i=null==e?void 0:e.rootBone)?i:this.entity;null==e||e._updatedManager.removeListener(this._onSkinUpdated);var u=null!=(o=null==t?void 0:null==(n=t.bones)?void 0:n.length)?o:0,d=null!=(s=null==t?void 0:t.rootBone)?s:this.entity;null==t||t._updatedManager.addListener(this._onSkinUpdated),l!==u&&this._onSkinUpdated(cb.BoneCountChanged,u),c!==d&&this._onSkinUpdated(cb.RootBoneChanged,d)},ui(ni,[{key:"skin",get:function(){return this._skin},set:function(e){var t=this._skin;t!==e&&(this._applySkin(t,e),this._skin=e)}},{key:"blendShapeWeights",get:function(){return this._checkBlendShapeWeightLength(),this._blendShapeWeights},set:function(e){this._checkBlendShapeWeightLength();var t=this._blendShapeWeights;if(e.length<=t.length)t.set(e);else for(var r=0,n=t.length;r<n;r++)t[r]=e[r]}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this.skin.rootBone},set:function(e){this.skin.rootBone=e}},{key:"bones",get:function(){return this.skin.bones},set:function(e){this.skin.bones=e}}]),ni);hc._jointCountProperty=uO.getByName("renderer_JointCount"),hc._jointSamplerProperty=uO.getByName("renderer_JointSampler"),hc._jointMatrixProperty=uO.getByName("renderer_JointMatrix"),ul([uu],hc.prototype,"_condensedBlendShapeWeights",void 0),ul([u_],hc.prototype,"_localBounds",void 0),ul([uu],hc.prototype,"_jointDataCreateCache",void 0),ul([uu],hc.prototype,"_blendShapeWeights",void 0),ul([uu],hc.prototype,"_maxVertexUniformVectors",void 0),ul([uu],hc.prototype,"_jointTexture",void 0),ul([u_],hc.prototype,"_skin",void 0),ul([uu],hc.prototype,"_onLocalBoundsChanged",null),ul([uu],hc.prototype,"_onSkinUpdated",null);var hu=((nl=(ns=function(t){var r=new Float32Array([-1,-1,0,1,3,-1,2,1,-1,3,0,-1]),n=new Float32Array([3,-1,2,0,-1,-1,0,0,-1,3,0,2]),a=new dN(t,u$.find("blit"));a._addReferCount(1),a.renderState.depthState.enabled=!1,a.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(t,r),this.flipYBlitMesh=this._createBlitMesh(t,n),this.blitMaterial=a;var i=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R8G8B8A8,i),this.whiteTextureCube=this._create1x1Texture(t,1,e.TextureFormat.R8G8B8A8,i),t._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(t,2,e.TextureFormat.R8G8B8A8,i);var o=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(t,0,e.TextureFormat.R32G32B32A32_UInt,o)}}).prototype)._createBlitMesh=function(t,r){var n=new d2(t);return n._addReferCount(1),n.setVertexElements([new dV("POSITION_UV",0,e.VertexElementFormat.Vector4,0)]),n.setVertexBufferBinding(new dI(t,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static),16),n.addSubMesh(0,3,e.MeshTopology.Triangles),n},nl._create1x1Texture=function(t,r,n,a){switch(r){case 0:var i,o,s=new ds(t,1,1,n,!1);s.setPixelBuffer(a),i=s;break;case 2:var l=new dl(t,1,1,1,n,!1);l.setPixelBuffer(0,a),i=l;break;case 1:for(var c=new dc(t,1,n,!1),u=0;u<6;u++)c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,a);i=c;break;default:throw"Invalid texture type"}return i.isGCIgnored=!0,t.resourceManager.addContentRestorer(new(us(o=function(){return dR.call(this,i)},dR),o.prototype.restoreContent=function(){switch(r){case 0:this.resource.setPixelBuffer(a);break;case 2:this.resource.setPixelBuffer(0,a);break;case 1:for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,a)}},o)),i},ns);(nc=cT||(cT={}))[nc.Texture2D=0]="Texture2D",nc[nc.TextureCube=1]="TextureCube",nc[nc.Texture2DArray=2]="Texture2DArray";var hd=((nu=function(e){this._type=e}).prototype.garbageCollection=function(){for(var e=this._elements,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose();e.length=0},nu),hh=(us(nd=function(e,t){void 0===t&&(t=1),(r=hd.call(this,e)||this)._lastElementIndex=t-1;for(var r,n=r._elements=Array(t),a=0;a<t;++a)n[a]=new e;return r},hd),(nh=nd.prototype).get=function(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]},nh.return=function(e){this._elements[++this._lastElementIndex]=e},nd),h_=((n_=function(){}).prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},n_),hf=((nf=function(e,t){this.start=e,this.size=t}).prototype.dispose=function(){},nf),hp=((nm=(np=function(t,r){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new dQ(t);n.addVertexElement(new dV("POSITION",0,e.VertexElementFormat.Vector3,0)),n.addVertexElement(new dV("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)),n.addVertexElement(new dV("COLOR_0",20,e.VertexElementFormat.Vector4,0)),n._addReferCount(1);var a=new dI(t,e.BufferBindFlag.VertexBuffer,36*r,e.BufferUsage.Dynamic,!0);n.setVertexBufferBinding(0,new dJ(a,36));var i=new dI(t,e.BufferBindFlag.IndexBuffer,8*r,e.BufferUsage.Dynamic,!0);n.setIndexBufferBinding(new dX(i,e.IndexFormat.UInt16)),this.primitive=n,this.vertices=new Float32Array(a.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new hf(0,9*r)]}).prototype).allocateSubChunk=function(t){var r=this._allocateArea(9*t);if(r){var n=np.subChunkPool.get();n.chunk=this,n.vertexArea=r;var a=np.subMeshPool.get();return a.topology=e.MeshTopology.Triangles,n.subMesh=a,n}return null},nm.freeSubChunk=function(e){this._freeArea(e.vertexArea),np.subMeshPool.return(e.subMesh),np.subChunkPool.return(e)},nm.uploadBuffer=function(){var t=this.primitive,r=this.updateVertexStart,n=this.updateVertexEnd;r!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER&&(t.vertexBufferBindings[0].buffer.setData(this.vertices,4*r,r,n-r,e.SetDataOptions.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),t.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,e.SetDataOptions.Discard),this.updateIndexLength=0},nm.destroy=function(){this.primitive._addReferCount(-1),this.primitive.destroy(),this.primitive=null,this.vertices=null,this.indices=null},nm._allocateArea=function(e){for(var t=this.vertexFreeAreas,r=np.areaPool,n=0,a=t.length;n<a;++n){var i=t[n],o=i.size;if(o>e){var s=r.get();return s.start=i.start,s.size=e,i.start+=e,i.size-=e,s}if(o===e)return t.splice(n,1),i}return null},nm._freeArea=function(e){var t=this.vertexFreeAreas,r=t.length;if(0===r){t.push(e);return}for(var n=np.areaPool,a=e,i=!0,o=0;o<r;++o){var s=t[o],l=a.start,c=a.size,u=s.start,d=l+c,h=u+s.size;if(d<u){i&&t.splice(o,0,a);return}d===u?(s.start=l,s.size+=c,n.return(a),a=s,i=!1):l===h?(s.size+=c,n.return(a),a=s,i=!1):l>h&&o+1===r&&t.push(a)}},np);hp.areaPool=new hh(hf,10),hp.subChunkPool=new hh(h_,10),hp.subMeshPool=new hh(dq,10);var hm=function(){function e(t,r){void 0===r&&(r=e.MAX_VERTEX_COUNT),this.engine=t,this.maxVertexCount=r,this.primitiveChunks=[]}var t=e.prototype;return t.allocateSubChunk=function(e){for(var t=this.primitiveChunks,r=t.length,n=null,a=0;a<r;++a)if(n=t[a].allocateSubChunk(e))return n;return(t[r]||(t[r]=new hp(this.engine,this.maxVertexCount))).allocateSubChunk(e)},t.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},t.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,r=e.length;t<r;++t)e[t].uploadBuffer()},t.destroy=function(){for(var e=this.primitiveChunks,t=0,r=e.length;t<r;++t)e[t].destroy();e.length=0,this.primitiveChunks=null,this.engine=null},e}();hm.MAX_VERTEX_COUNT=4096;var hg=((nv=(ng=function(e){this.primitiveChunkManager2D=new hm(e),this.primitiveChunkManagerMask=new hm(e,128)}).prototype).destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},nv.batch=function(e){for(var t,r,n,a=e.elements,i=e.batchedSubElements,o=e.renderQueueType,s=0,l=a.length;s<l;++s)for(var c=a[s].subRenderElements,u=0,d=c.length;u<d;++u){var h=c[u];if(h.renderQueueFlags&1<<o){var _=h.component,f=_.constructor;t?n===f&&r._canBatch(t,h)?(r._batch(t,h),t.batched=!0):(i.push(t),t=h,r=_,n=f,_._batch(h),h.batched=!1):(t=h,r=_,n=f,_._batch(h),h.batched=!1)}}t&&i.push(t)},nv.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},ng);e.AssetType=void 0,(ny=e.AssetType||(e.AssetType={})).Text="Text",ny.JSON="JSON",ny.Buffer="Buffer",ny.Texture2D="Texture2D",ny.TextureCube="TextureCube",ny.Material="Material",ny.Mesh="Mesh",ny.AnimationClip="AnimationClip",ny.AnimatorController="AnimatorController",ny.Prefab="Prefab",ny.GLTF="GLTF",ny.KTX="KTX",ny.KTXCube="KTXCube",ny.KTX2="KTX2",ny.Sprite="Sprite",ny.PrimitiveMesh="PrimitiveMesh",ny.SpriteAtlas="SpriteAtlas",ny.Env="Environment",ny.Scene="Scene",ny.HDR="HDR",ny.Font="Font",ny.SourceFont="SourceFont",ny.Project="project";var hv=((nb=(nx=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},nb.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},nb.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},nb.findAndRemove=function(e){for(var t=this._array,r=t.length-1;r>=0;r--)e(t[r])&&this.removeByIndex(r)},nb.indexOf=function(e){return this._array.indexOf(e)},nb.getArray=function(){return this._array},nb.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},ui(nx,[{key:"length",get:function(){return this._array.length}}]),nx),hy=((nC=(nT=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new hv}).prototype).addScene=function(e,t){var r,n=this._scenes;if("number"==typeof e){if(e<0||e>n.length)throw"The index is out of range.";r=e}else r=n.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=n.indexOf(t);a!==r&&(n.removeByIndex(a),n.add(r,t))}else t._sceneManager=this,n.add(r,t),t.isActive&&t._processActive(!0)},nC.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)}},nC.loadScene=function(t,r){void 0===r&&(r=!0);var n=this,a=this.engine.resourceManager.load({url:t,type:e.AssetType.Scene});return a.then(function(e){if(r)for(var t=n._scenes.getArray(),a=0,i=t.length;a<i;a++)t[a].destroy();n.addScene(e)}),a},nC.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},nC._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},ui(nT,[{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)}}]),nT),hx=((nA=(nS=function(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(r,n){t._reject=n,e(function(e){"pending"===t._state&&(r(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(n(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,r){if("pending"===t._state){var n=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:r});n.loaded=e,n.total=r,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,r)})}},function(e,r,n){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:r,total:n});i.loaded=r,i.total=n,t._onTaskDetailCallbacks.forEach(function(t){return t(e,r,n)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e,t){var r=this._taskCompleteProgress,n=this._taskDetailProgress;if(r&&e(r.loaded,r.total),n)for(var a in n){var i=n[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},nA.then=function(e,t){var r=this;return new nS(function(n,a){r._promise.then(e,t).then(n).catch(a)})},nA.catch=function(e){var t=this;return new nS(function(r,n){t._promise.catch(e).then(r).catch(n)})},nA.finally=function(e){return this._promise.finally(e)},nA.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nS.all=function(e){return new nS(function(t,r,n){var a=function(e,r){l++,s[e]=r,n(l,o),l===o&&t(s)},i=function(e,t){uc(e,Promise)||uc(e,nS)?e.then(function(e){a(t,e)},r):Promise.resolve().then(function(){a(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)i(e[c],c)})},ui(nS,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nS);(nM=cC||(cC={})).Pending="pending",nM.Fulfilled="fulfilled",nM.Rejected="rejected",nM.Canceled="canceled";var hb=((nE=(nR=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this.baseUrl=null,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}).prototype).load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var r=e.map(function(e){return t._loadSingleItem(e)});return hx.all(r)},nE.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},nE.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var a=r[n];uc(a,e)&&t.push(a)}return t},nE.getAssetPath=function(e){return this._assetPool[e]},nE.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()}):uv.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},nE.gc=function(){this._gc(!1),this.engine._pendingGC()},nE.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},nE._onSubAssetSuccess=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.resolve(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={resolvedValue:r}},nE._onSubAssetFail=function(e,t,r){var n,a,i=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[t];i?i.reject(r):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={rejectedValue:r}},nE._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},nE._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},nE._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},nE._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},nE._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},nE._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},nE._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},nE._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},nE._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},nE._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)},nE._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},nE._assignDefaultOptions=function(e){var t,r,n,a,i;if(e.type=null!=(t=e.type)?t:nR._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(r=e.retryCount)?r:this.retryCount,e.timeout=null!=(n=e.timeout)?n:this.timeout,e.retryInterval=null!=(a=e.retryInterval)?a:this.retryInterval,e.url=null!=(i=e.url)?i:e.urls.join(","),e},nE._loadSingleItem=function(e){var t,r=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),a=n.url,i=this._virtualPathMap[a]?this._virtualPathMap[a]:a;!uv.isAbsoluteUrl(i)&&this.baseUrl&&(i=uv.resolveAbsoluteUrl(this.baseUrl,i));var o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=this._assetUrlPool[s];if(u)return new hx(function(e){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 hx(function(e,t,r,n){_.onProgress(r,n).then(function(t){e(t)}).catch(function(e){t(e)})});var f=nR._loaders[n.type];if(!f)throw"loader not found: "+n.type;return l?((h[s]||this._loadMainAsset(f,n,s)).catch(function(e){r._onSubAssetFail(s,l,e)}),this._createSubAssetPromiseCallback(s,d,l)):this._loadMainAsset(f,n,s)},nE._loadMainAsset=function(e,t,r){var n=this;t.url=r;var a=this._loadingPromises,i=e.load(t,this);return a[r]=i,i.then(function(t){e.useCache&&n._addAsset(r,t),delete a[r],n._releaseSubAssetPromiseCallback(r)},function(){delete a[r],n._releaseSubAssetPromiseCallback(r)}),i},nE._createSubAssetPromiseCallback=function(e,t,r){var n,a=this,i=this._loadingPromises,o=null==(n=this._subAssetPromiseCallbacks[e])?void 0:n[r],s=null==o?void 0:o.resolvedValue,l=null==o?void 0:o.rejectedValue;if(s||l)return new hx(function(e,t){s?e(s):l&&t(l)});var c=new hx(function(t,n){var i;((i=a._subAssetPromiseCallbacks)[e]||(i[e]={}))[r]={resolve:t,reject:n}});return i[t]=c,c.then(function(){delete i[t]},function(){return delete i[t]}),c},nE._gc=function(e){for(var t=uv.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++){var a=t[r];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},nE._getResolveResource=function(e,t){var r=e;if(t)for(var n=0,a=t.length;n<a;n++)r=r[t[n]];return r},nE._parseURL=function(e){var t=e.split("?"),r=t[0],n=t[1],a=void 0,i=r;if(n){for(var o=n.split("&"),s=0;s<o.length;s++){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?r+"?"+o.join("&"):r}return{assetBaseURL:i,queryPath:a}},nE._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===hC&&t.push(""),e.replace(hA,function(e,r,n,a){var i=e;n?i=a.replace(hS,"$1"):r&&(i=r.trim()),t.push(i)}),t},nE._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},nE.getResourceByRef=function(e){var t=e.refId,r=e.key,n=e.isClone,a=this._objectPool[t];if(a)i=Promise.resolve(a);else{var i,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return uI.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=r?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+r:s,i=this.load({url:s,type:this._editorResourceConfig[t].type})}return i.then(function(e){return n?e.clone():e})},nE.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},nR._addLoader=function(e,t,r){this._loaders[e]=t;for(var n=0,a=r.length;n<a;n++)this._extTypeMapping[r[n].toLowerCase()]=e},nR._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},nR);function hT(e,t,r){return void 0===r&&(r=!0),function(n){var a=new n(r);hb._addLoader(e,a,t)}}hb._loaders={},hb._extTypeMapping={};var hC=46,hS=/\\(\\)?/g,hA=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(nw=e.PointerPhase||(e.PointerPhase={}))[nw.Down=0]="Down",nw[nw.Move=1]="Move",nw[nw.Stationary=2]="Stationary",nw[nw.Up=3]="Up",nw[nw.Leave=4]="Leave";var hM=((nF=(nP=function(t){this.phase=e.PointerPhase.Leave,this.position=new c9,this.deltaPosition=new c9,this._events=[],this._upMap=[],this._downMap=[],this._upList=new dr,this._downList=new dr,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)},nF._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},nF._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},nF._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}},nP);e.PointerButton=void 0,(nL=e.PointerButton||(e.PointerButton={}))[nL.None=0]="None",nL[nL.Primary=1]="Primary",nL[nL.Secondary=2]="Secondary",nL[nL.Auxiliary=4]="Auxiliary",nL[nL.XButton1=8]="XButton1",nL[nL.XButton2=16]="XButton2",nL[nL.XButton3=32]="XButton3",nL[nL.XButton4=64]="XButton4",nL[nL.XButton5=128]="XButton5",nL[nL.XButton6=256]="XButton6",nL[nL.XButton7=512]="XButton7",nL[nL.XButton8=1024]="XButton8";var hR=[1,4,2,8,16,32,64,128,256,512,1024],hE={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},hw=((nB=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?nB.platform=e.Platform.IPhone:/iPad/i.test(r)?nB.platform=e.Platform.IPad:/Android/i.test(r)?nB.platform=e.Platform.Android:/Macintosh/i.test(r)&&(nB.platform=e.Platform.Mac),nB.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"}}},nB._detectSIMDSupported=function(){return null===this._simdSupported&&(this._simdSupported=WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]))),this._simdSupported},ui(nB,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nB);hw.platform=e.Platform.Unknown,hw.operatingSystem="",hw._simdSupported=null,hw._initialize(),e.Keys=void 0,(nD=e.Keys||(e.Keys={}))[nD.Backquote=0]="Backquote",nD[nD.Backslash=1]="Backslash",nD[nD.Backspace=2]="Backspace",nD[nD.BracketLeft=3]="BracketLeft",nD[nD.BracketRight=4]="BracketRight",nD[nD.Comma=5]="Comma",nD[nD.Digit0=6]="Digit0",nD[nD.Digit1=7]="Digit1",nD[nD.Digit2=8]="Digit2",nD[nD.Digit3=9]="Digit3",nD[nD.Digit4=10]="Digit4",nD[nD.Digit5=11]="Digit5",nD[nD.Digit6=12]="Digit6",nD[nD.Digit7=13]="Digit7",nD[nD.Digit8=14]="Digit8",nD[nD.Digit9=15]="Digit9",nD[nD.Equal=16]="Equal",nD[nD.IntlBackslash=17]="IntlBackslash",nD[nD.IntlRo=18]="IntlRo",nD[nD.IntlYen=19]="IntlYen",nD[nD.KeyA=20]="KeyA",nD[nD.KeyB=21]="KeyB",nD[nD.KeyC=22]="KeyC",nD[nD.KeyD=23]="KeyD",nD[nD.KeyE=24]="KeyE",nD[nD.KeyF=25]="KeyF",nD[nD.KeyG=26]="KeyG",nD[nD.KeyH=27]="KeyH",nD[nD.KeyI=28]="KeyI",nD[nD.KeyJ=29]="KeyJ",nD[nD.KeyK=30]="KeyK",nD[nD.KeyL=31]="KeyL",nD[nD.KeyM=32]="KeyM",nD[nD.KeyN=33]="KeyN",nD[nD.KeyO=34]="KeyO",nD[nD.KeyP=35]="KeyP",nD[nD.KeyQ=36]="KeyQ",nD[nD.KeyR=37]="KeyR",nD[nD.KeyS=38]="KeyS",nD[nD.KeyT=39]="KeyT",nD[nD.KeyU=40]="KeyU",nD[nD.KeyV=41]="KeyV",nD[nD.KeyW=42]="KeyW",nD[nD.KeyX=43]="KeyX",nD[nD.KeyY=44]="KeyY",nD[nD.KeyZ=45]="KeyZ",nD[nD.Minus=46]="Minus",nD[nD.Period=47]="Period",nD[nD.Quote=48]="Quote",nD[nD.Semicolon=49]="Semicolon",nD[nD.Slash=50]="Slash",nD[nD.AltLeft=51]="AltLeft",nD[nD.AltRight=52]="AltRight",nD[nD.CapsLock=53]="CapsLock",nD[nD.ContextMenu=54]="ContextMenu",nD[nD.ControlLeft=55]="ControlLeft",nD[nD.ControlRight=56]="ControlRight",nD[nD.Enter=57]="Enter",nD[nD.MetaLeft=58]="MetaLeft",nD[nD.MetaRight=59]="MetaRight",nD[nD.ShiftLeft=60]="ShiftLeft",nD[nD.ShiftRight=61]="ShiftRight",nD[nD.Space=62]="Space",nD[nD.Tab=63]="Tab",nD[nD.Convert=64]="Convert",nD[nD.KanaMode=65]="KanaMode",nD[nD.Lang1=66]="Lang1",nD[nD.Lang2=67]="Lang2",nD[nD.Lang3=68]="Lang3",nD[nD.Lang4=69]="Lang4",nD[nD.Lang5=70]="Lang5",nD[nD.NonConvert=71]="NonConvert",nD[nD.Delete=72]="Delete",nD[nD.End=73]="End",nD[nD.Help=74]="Help",nD[nD.Home=75]="Home",nD[nD.Insert=76]="Insert",nD[nD.PageDown=77]="PageDown",nD[nD.PageUp=78]="PageUp",nD[nD.ArrowDown=79]="ArrowDown",nD[nD.ArrowLeft=80]="ArrowLeft",nD[nD.ArrowRight=81]="ArrowRight",nD[nD.ArrowUp=82]="ArrowUp",nD[nD.NumLock=83]="NumLock",nD[nD.Numpad0=84]="Numpad0",nD[nD.Numpad1=85]="Numpad1",nD[nD.Numpad2=86]="Numpad2",nD[nD.Numpad3=87]="Numpad3",nD[nD.Numpad4=88]="Numpad4",nD[nD.Numpad5=89]="Numpad5",nD[nD.Numpad6=90]="Numpad6",nD[nD.Numpad7=91]="Numpad7",nD[nD.Numpad8=92]="Numpad8",nD[nD.Numpad9=93]="Numpad9",nD[nD.NumpadAdd=94]="NumpadAdd",nD[nD.NumpadBackspace=95]="NumpadBackspace",nD[nD.NumpadClear=96]="NumpadClear",nD[nD.NumpadClearEntry=97]="NumpadClearEntry",nD[nD.NumpadComma=98]="NumpadComma",nD[nD.NumpadDecimal=99]="NumpadDecimal",nD[nD.NumpadDivide=100]="NumpadDivide",nD[nD.NumpadEnter=101]="NumpadEnter",nD[nD.NumpadEqual=102]="NumpadEqual",nD[nD.NumpadHash=103]="NumpadHash",nD[nD.NumpadMemoryAdd=104]="NumpadMemoryAdd",nD[nD.NumpadMemoryClear=105]="NumpadMemoryClear",nD[nD.NumpadMemoryRecall=106]="NumpadMemoryRecall",nD[nD.NumpadMemoryStore=107]="NumpadMemoryStore",nD[nD.NumpadMemorySubtract=108]="NumpadMemorySubtract",nD[nD.NumpadMultiply=109]="NumpadMultiply",nD[nD.NumpadParenLeft=110]="NumpadParenLeft",nD[nD.NumpadParenRight=111]="NumpadParenRight",nD[nD.NumpadStar=112]="NumpadStar",nD[nD.NumpadSubtract=113]="NumpadSubtract",nD[nD.Escape=114]="Escape",nD[nD.F1=115]="F1",nD[nD.F2=116]="F2",nD[nD.F3=117]="F3",nD[nD.F4=118]="F4",nD[nD.F5=119]="F5",nD[nD.F6=120]="F6",nD[nD.F7=121]="F7",nD[nD.F8=122]="F8",nD[nD.F9=123]="F9",nD[nD.F10=124]="F10",nD[nD.F11=125]="F11",nD[nD.F12=126]="F12",nD[nD.F13=127]="F13",nD[nD.F14=128]="F14",nD[nD.F15=129]="F15",nD[nD.Fn=130]="Fn",nD[nD.FnLock=131]="FnLock",nD[nD.PrintScreen=132]="PrintScreen",nD[nD.ScrollLock=133]="ScrollLock",nD[nD.Pause=134]="Pause",nD[nD.BrowserBack=135]="BrowserBack",nD[nD.BrowserFavorites=136]="BrowserFavorites",nD[nD.BrowserForward=137]="BrowserForward",nD[nD.BrowserHome=138]="BrowserHome",nD[nD.BrowserRefresh=139]="BrowserRefresh",nD[nD.BrowserSearch=140]="BrowserSearch",nD[nD.BrowserStop=141]="BrowserStop",nD[nD.Eject=142]="Eject",nD[nD.LaunchApp1=143]="LaunchApp1",nD[nD.LaunchApp2=144]="LaunchApp2",nD[nD.LaunchMail=145]="LaunchMail",nD[nD.MediaPlayPause=146]="MediaPlayPause",nD[nD.MediaSelect=147]="MediaSelect",nD[nD.MediaStop=148]="MediaStop",nD[nD.MediaTrackNext=149]="MediaTrackNext",nD[nD.MediaTrackPrevious=150]="MediaTrackPrevious",nD[nD.Power=151]="Power",nD[nD.Sleep=152]="Sleep",nD[nD.AudioVolumeDown=153]="AudioVolumeDown",nD[nD.AudioVolumeMute=154]="AudioVolumeMute",nD[nD.AudioVolumeUp=155]="AudioVolumeUp",nD[nD.WakeUp=156]="WakeUp",nD[nD.Hyper=157]="Hyper",nD[nD.Super=158]="Super",nD[nD.Turbo=159]="Turbo",nD[nD.Abort=160]="Abort",nD[nD.Resume=161]="Resume",nD[nD.Suspend=162]="Suspend",nD[nD.Again=163]="Again",nD[nD.Copy=164]="Copy",nD[nD.Cut=165]="Cut",nD[nD.Find=166]="Find",nD[nD.Open=167]="Open",nD[nD.Paste=168]="Paste",nD[nD.Props=169]="Props",nD[nD.Select=170]="Select",nD[nD.Undo=171]="Undo",nD[nD.Hiragana=172]="Hiragana",nD[nD.Katakana=173]="Katakana",nD[nD.Unidentified=174]="Unidentified";var hP=((nO=(nI=function(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new dr,this._curFrameDownList=new dr,this._curFrameUpList=new dr,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var t=this._nativeEvents,r=this._curFrameDownList,n=this._curFrameUpList;if(r.length=0,n.length=0,t.length>0){for(var a=this._engine.time.frameCount,i=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,u=t.length;c<u;c++){var d=t[c],h=e.Keys[d.code];switch(d.type){case"keydown":null==i[h]&&(r.add(h),o.add(h),i[h]=o.length-1,s[h]=a);break;case"keyup":var _=i[h];if(null!=_){i[h]=null;var f=o.deleteByIndex(_);f&&(i[f]=_)}if(n.add(h),l[h]=a,hw.platform===e.Platform.Mac&&(h===e.Keys.MetaLeft||h===e.Keys.MetaRight)){for(var p=0,m=o.length;p<m;p++)i[o.get(p)]=null;o.length=0}}}t.length=0}},nO._destroy=function(){this._removeEventListener(),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._engine=null},nO._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},nO._onKeyEvent=function(e){this._nativeEvents.push(e)},nO._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},nO._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},nI);e.Collider=(us(nV=function(e){var t;return(t=u4.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},u4),(nN=nV.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))},nN.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))},nN.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},nN._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}},nN._onLateUpdate=function(){},nN._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])},nN._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])},nN._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},nN._onDestroy=function(){u4.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nN._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},ui(nV,[{key:"shapes",get:function(){return this._shapes}}]),nV),ul([uu],e.Collider.prototype,"_index",void 0),ul([uu],e.Collider.prototype,"_nativeCollider",void 0),ul([uu],e.Collider.prototype,"_updateFlag",void 0),ul([u_],e.Collider.prototype,"_shapes",void 0),e.Collider=ul([u5(u6,e.DependentMode.CheckOnly)],e.Collider);var hF=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new dr,this._gravity=new cZ(0,-9.81,0),this._onContactEnter=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(e,n){var a=r._scene.engine._physicalObjectsMap,i=a[e],o=a[n];i.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=o,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t}),o.collider.entity._scripts.forEach(function(e){var r=t._collision;r.shape=i,e.onCollisionStay(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=r._scene.engine._physicalObjectsMap,a=n[e],i=n[t];a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(i)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t})},this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=e.engine;n._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var r=t.prototype;return r.raycast=function(t,r,n,a){var i,o=this,s=Number.MAX_VALUE;"number"==typeof r?s=r:void 0!=r&&(i=r);var l=e.Layer.Everything;"number"==typeof n?l=n:void 0!=n&&(i=n),a&&(i=a);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&l&&t.isSceneQuery};return void 0==i?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,r,n){var a=o._scene.engine._physicalObjectsMap[e];i.entity=a._collider.entity,i.shape=a,i.distance=t,i.normal.copyFrom(n),i.point.copyFrom(r)})||(i.entity=null,i.shape=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},r._update=function(e){var t=this._fixedTimeStep,r=this._nativePhysicsScene,n=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)n.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),r.update(t),this._callColliderOnLateUpdate()},r._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},r._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},r._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},r._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},r._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},r._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},r._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},r._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},r._gc=function(){this._colliders.garbageCollection()},r._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},ui(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,cQ.zeroTolerance)}}]),t}();hF._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nk=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nk.PreventClimbing=0]="PreventClimbing",nk[nk.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var hL=(nz=e.Collider,us(nU=function(t){var r;return(r=nz.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new cZ(0,1,0),r._slopeLimit=.707,r._nativeCollider=hF._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(un(r)),r._upDirection._onValueChanged=r._setUpDirection,r},nz),(nG=nU.prototype).move=function(e,t,r){return this._nativeCollider.move(e,t,r)},nG.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nz.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nG.clearShapes=function(){this._shapes.length>0&&nz.prototype.removeShape.call(this,this._shapes[0])},nG._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var r=e.lossyWorldScale,n=0,a=t.length;n<a;n++)t[n]._nativeShape.setWorldScale(r);this._updateFlag.flag=!1}},nG._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this._updateFlag.flag=!1},nG._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])},nG._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])},nG._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},ui(nU,[{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))}}]),nU),hB=(nH=e.Collider,us(nW=function(e){(t=nH.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new cZ,t._angularVelocity=new cZ,t._mass=1,t._centerOfMass=new cZ,t._inertiaTensor=new cZ(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=hF._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(un(t)),t._setAngularVelocity=t._setAngularVelocity.bind(un(t)),t._setCenterOfMass=t._setCenterOfMass.bind(un(t)),t._setInertiaTensor=t._setInertiaTensor.bind(un(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},nH),(nj=nW.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},nj.applyTorque=function(e){this._nativeCollider.addTorque(e)},nj.move=function(e,t){this._nativeCollider.move(e,t)},nj.sleep=function(){this._nativeCollider.sleep()},nj.wakeUp=function(){this._nativeCollider.wakeUp()},nj._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},nj._cloneTo=function(e){nH.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},nj._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},nj._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},nj._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},nj._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},ui(nW,[{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))}}]),nW);ul([uu],hB.prototype,"_linearDamping",void 0),ul([uu],hB.prototype,"_angularDamping",void 0),ul([uu],hB.prototype,"_linearVelocity",void 0),ul([uu],hB.prototype,"_angularVelocity",void 0),ul([uu],hB.prototype,"_mass",void 0),ul([uu],hB.prototype,"_centerOfMass",void 0),ul([uu],hB.prototype,"_inertiaTensor",void 0),ul([uu],hB.prototype,"_maxAngularVelocity",void 0),ul([uu],hB.prototype,"_maxDepenetrationVelocity",void 0),ul([uu],hB.prototype,"_solverIterations",void 0),ul([uu],hB.prototype,"_isKinematic",void 0),ul([uu],hB.prototype,"_constraints",void 0),ul([uu],hB.prototype,"_collisionDetectionMode",void 0),ul([uu],hB.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(nK=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nK.Discrete=0]="Discrete",nK[nK.Continuous=1]="Continuous",nK[nK.ContinuousDynamic=2]="ContinuousDynamic",nK[nK.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(nX=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[nX.None=0]="None",nX[nX.FreezePositionX=1]="FreezePositionX",nX[nX.FreezePositionY=2]="FreezePositionY",nX[nX.FreezePositionZ=4]="FreezePositionZ",nX[nX.FreezeRotationX=8]="FreezeRotationX",nX[nX.FreezeRotationY=16]="FreezeRotationY",nX[nX.FreezeRotationZ=32]="FreezeRotationZ";var hD=function(){this.entity=null,this.distance=0,this.point=new cZ,this.normal=new cZ,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(nY=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nY.Average=0]="Average",nY[nY.Minimum=1]="Minimum",nY[nY.Multiply=2]="Multiply",nY[nY.Maximum=3]="Maximum";var hI=((nq=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=hF._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},ui(nq,[{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))}}]),nq),hO=(nQ=e.Collider,us(nZ=function(e){var t,r=(t=nQ.call(this,e)||this).entity.transform;return t._nativeCollider=hF._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},nQ),nZ);e.ColliderShapeUpAxis=void 0,(nJ=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nJ.X=0]="X",nJ[nJ.Y=1]="Y",nJ[nJ.Z=2]="Z",e.ControllerCollisionFlag=void 0,(n$=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[n$.Sides=1]="Sides",n$[n$.Up=2]="Up",n$[n$.Down=4]="Down",e.Joint=(us(n0=function(e){var t;return(t=u4.call(this,e)||this)._colliderInfo=new hV,t._connectedColliderInfo=new hV,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new cZ,t},u4),n0.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},ui(n0,[{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))}}]),n0),ul([uu],e.Joint.prototype,"_colliderInfo",void 0),ul([uu],e.Joint.prototype,"_connectedColliderInfo",void 0),ul([uu],e.Joint.prototype,"_nativeJoint",void 0),ul([uu],e.Joint.prototype,"_force",void 0),ul([uu],e.Joint.prototype,"_torque",void 0),e.Joint=ul([u5(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var hV=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},hN=(n1=e.Joint,us(n2=function(){return n1.apply(this,arguments)},n1),n2.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hF._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n2);(n3=cS||(cS={}))[n3.None=0]="None",n3[n3.LimitEnabled=1]="LimitEnabled",n3[n3.DriveEnabled=2]="DriveEnabled",n3[n3.DriveFreeSpin=4]="DriveFreeSpin";var hk=(n4=e.Joint,us(n8=function(){var e;return e=n4.apply(this,arguments)||this,e._axis=new cZ(1,0,0),e._hingeFlags=cS.None,e._useSpring=!1,e},n4),(n5=n8.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cZ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hF._nativePhysics.createHingeJoint(t.collider._nativeCollider)},n5._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},ui(n8,[{key:"axis",get:function(){return this._axis},set:function(e){var t=this._axis;e!==t&&t.copyFrom(e),this._nativeJoint.setAxis(t)}},{key:"swingOffset",get:function(){return this._colliderInfo.localPosition},set:function(e){var t=this._colliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setSwingOffset(t)}},{key:"angle",get:function(){return this._nativeJoint.getAngle()}},{key:"velocity",get:function(){return this._nativeJoint.getVelocity()}},{key:"useLimits",get:function(){return(this._hingeFlags&cS.LimitEnabled)==cS.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=cS.LimitEnabled:this._hingeFlags&=~cS.LimitEnabled,this._nativeJoint.setHingeJointFlag(cS.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&cS.DriveEnabled)==cS.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=cS.DriveEnabled:this._hingeFlags&=~cS.DriveEnabled,this._nativeJoint.setHingeJointFlag(cS.DriveEnabled,e))}},{key:"useSpring",get:function(){return this._useSpring},set:function(e){this._useSpring!==e&&(this._useSpring=e,this.limits=this._limits)}},{key:"motor",get:function(){return this._jointMonitor},set:function(e){this._jointMonitor!==e&&(this._jointMonitor=e,this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRation),this._nativeJoint.setHingeJointFlag(cS.DriveFreeSpin,e.freeSpin))}},{key:"limits",get:function(){return this._limits},set:function(e){this._limits!==e&&(this._limits=e,this.useSpring?this._nativeJoint.setSoftLimit(e.min,e.max,e.stiffness,e.damping):this._nativeJoint.setHardLimit(e.min,e.max,e.contactDistance))}}]),n8);ul([uu],hk.prototype,"_axis",void 0),ul([uu],hk.prototype,"_hingeFlags",void 0),ul([uu],hk.prototype,"_useSpring",void 0),ul([uu],hk.prototype,"_jointMonitor",void 0),ul([uu],hk.prototype,"_limits",void 0);var hz=(n9=e.Joint,us(n6=function(){var e;return e=n9.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},n9),(n7=n6.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new cZ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hF._nativePhysics.createSpringJoint(t.collider._nativeCollider)},n7._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},ui(n6,[{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))}}]),n6),hU=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},hG=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},hH=function(){function e(){this._isTrigger=!1,this._rotation=new cZ,this._position=new cZ,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new hI,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)},ui(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}();hH._idGenerator=0,ul([uu],hH.prototype,"_collider",void 0),ul([uu],hH.prototype,"_nativeShape",void 0),ul([uu],hH.prototype,"_id",void 0),ul([uu],hH.prototype,"_material",void 0),ul([uu],hH.prototype,"_isTrigger",void 0),ul([uu],hH.prototype,"_rotation",void 0),ul([uu],hH.prototype,"_position",void 0),ul([uu],hH.prototype,"_contactOffset",void 0);var hW=(us(ae=function(){var e;return(e=hH.call(this)||this)._size=new cZ(1,1,1),e._nativeShape=hF._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(un(e)),e._size._onValueChanged=e._setSize,e},hH),(at=ae.prototype)._cloneTo=function(e){hH.prototype._cloneTo.call(this,e),e.size=this.size},at._setSize=function(){this._nativeShape.setSize(this._size)},ui(ae,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),ae);ul([uu],hW.prototype,"_size",void 0);var hj=(us(ar=function(){var e;return(e=hH.call(this)||this)._radius=1,e._nativeShape=hF._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},hH),ar.prototype._cloneTo=function(e){hH.prototype._cloneTo.call(this,e),e.radius=this.radius},ui(ar,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),ar);ul([uu],hj.prototype,"_radius",void 0);var hK=(us(an=function(){var e;return(e=hH.call(this)||this)._nativeShape=hF._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},hH),an),hX=(us(aa=function(){var t;return(t=hH.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=hF._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},hH),aa.prototype._cloneTo=function(e){hH.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},ui(aa,[{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))}}]),aa);ul([uu],hX.prototype,"_radius",void 0),ul([uu],hX.prototype,"_height",void 0),ul([uu],hX.prototype,"_upAxis",void 0);var hY=((ao=(ai=function(t,r){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new dr,this._downList=new dr,this._nativeEvents=[],"undefined"!=typeof Window&&uc(r,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=t,this._target=r,this._canvas=t.canvas,this._htmlCanvas=t._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}).prototype)._update=function(){for(var t=this._pointers,r=this._nativeEvents,n=this._htmlCanvas,a=this._canvas,i=a.width,o=a.height,s=n.clientWidth,l=n.clientHeight,c=n.getBoundingClientRect(),u=c.left,d=c.top,h=i/s,_=o/l,f=t.length-1;f>=0;f--)t[f].phase===e.PointerPhase.Leave&&t.splice(f,1);for(var p=0,m=r.length;p<m;p++){var g=r[p],v=g.pointerId,y=this._getPointerByID(v);if(y)y._events.push(g);else{var x=t.length;if(0===x||this._multiPointerEnabled){for(var b,T=this._pointerPool,C=0;C<x&&!(t[C].id>C);C++);(y=T[b=C]||(T[b]=new hM(C)))._uniqueID=v,y._events.push(g),y.position.set((g.clientX-u)*h,(g.clientY-d)*_),t.splice(C,0,y)}}}r.length=0,this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None;for(var S=this._engine.time.frameCount,A=0,M=t.length;A<M;A++){var R=t[A];R._upList.length=R._downList.length=0,this._updatePointerInfo(S,R,u,d,h,_),this._buttons|=R.pressedButtons}},ao._firePointerScript=function(t){for(var r=this._pointers,n=this._canvas,a=0,i=r.length;a<i;a++){var o=r[a],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/n.width,l.y/n.height);o._firePointerExitAndEnter(c);var 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}}},ao._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},ao._onPointerEvent=function(e){this._nativeEvents.push(e)},ao._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},ao._updatePointerInfo=function(t,r,n,a,i,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)*i,m=(f.clientY-a)*o;r.deltaPosition.set(p-l.x,m-l.y),l.set(p,m);for(var g=0;g<c;g++){var v=s[g],y=v.button;switch(r.button=hR[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},ao._pointerRayCast=function(t,r,n){for(var a=ai._tempPoint,i=ai._tempRay,o=ai._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(l.isActive&&!l.destroyed)for(var c=l._componentsManager._activeCameras,u=c._elements,d=c.length-1;d>=0;d--){var h=u[d];if(!h.renderTarget){var _=h.viewport,f=_.x,p=_.y,m=_.z,g=_.w;if(r>=f&&n>=p&&r-f<=m&&n-p<=g){if(a.set((r-f)/m,(n-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},ao._addEventListener=function(){var e=this._target,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t)},ao._removeEventListener=function(){var e=this._target,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._nativeEvents.length=0,this._pointers.length=0,this._downList.length=0,this._upList.length=0},ai);hY._tempRay=new c5,hY._tempPoint=new c9,hY._tempHitResult=new hD;var hq=((al=(as=function(e,t){this._delta=new cZ,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var r=t.length-1;r>=0;r--){var n=t[r];e.x+=n.deltaX,e.y+=n.deltaY,e.z+=n.deltaZ}t.length=0}},al._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},al._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},al._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},al._onWheelEvent=function(e){this._nativeEvents.push(e)},as),hQ=((au=(ac=function(e,t){this._initialized=!1,this._engine=e;var r,n,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&uc(i,OffscreenCanvas)||(this._wheelManager=new hq(e,null!=(r=null==t?void 0:t.wheelTarget)?r:i),this._pointerManager=new hY(e,null!=(n=null==t?void 0:t.pointerTarget)?n:i),this._keyboardManager=new hP(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},au.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},au.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},au.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},au.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[hE[e]]===this._engine.time.frameCount)},au.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[hE[e]]===this._engine.time.frameCount)},au._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},au._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},au._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},ui(ac,[{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}}]),ac);(cA||(cA={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(ad=cM||(cM={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",ad.DirectionTime="a_DirectionTime",ad.StartColor="a_StartColor",ad.StartSize="a_StartSize",ad.StartRotation0="a_StartRotation0",ad.StartSpeed="a_StartSpeed",ad.Random0="a_Random0",ad.Random1="a_Random1",ad.SimulationWorldPosition="a_SimulationWorldPosition",ad.SimulationWorldRotation="a_SimulationWorldRotation",ad.SimulationUV="a_SimulationUV";var hZ=function t(r){this.billboardVertexElement=new dV(cA.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new dV(cM.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new dV(cM.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new dV(cM.StartColor,32,e.VertexElementFormat.Vector4,1,1),new dV(cM.StartSize,48,e.VertexElementFormat.Vector3,1,1),new dV(cM.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new dV(cM.StartSpeed,72,e.VertexElementFormat.Float,1,1),new dV(cM.Random0,76,e.VertexElementFormat.Vector4,1,1),new dV(cM.Random1,92,e.VertexElementFormat.Vector4,1,1),new dV(cM.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new dV(cM.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new dV(cM.SimulationUV,136,e.VertexElementFormat.Vector4,1,1)];var n,a,i=new dI(r,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);i.isGCIgnored=!0,this.billboardVertexBufferBinding=new dJ(i,16);var o=new dI(r,e.BufferBindFlag.IndexBuffer,t.billboardIndexCount,e.BufferUsage.Static,!1);o.isGCIgnored=!0,this.billboardIndexBufferBinding=new dX(o,e.IndexFormat.UInt8);var s=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),l=new Uint8Array([0,2,3,0,1,2]);i.setData(s),o.setData(l),r.resourceManager.addContentRestorer(new(us(n=function(){return dR.call(this,i)},dR),n.prototype.restoreContent=function(){i.setData(s)},n)),r.resourceManager.addContentRestorer(new(us(a=function(){return dR.call(this,o)},dR),a.prototype.restoreContent=function(){},a))};hZ.instanceVertexStride=152,hZ.instanceVertexFloatStride=hZ.instanceVertexStride/4,hZ.startLifeTimeOffset=3,hZ.timeOffset=7,hZ.simulationUVOffset=34,hZ.billboardIndexCount=6,hZ.boundsFloatStride=8,hZ.boundsTimeOffset=6,hZ.boundsMaxLifetimeOffset=7;var hJ="#define GLSLIFY 1\nattribute vec4 POSITION_UV;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION_UV.xy,0.0,1.0);v_uv=POSITION_UV.zw;}",h$="#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}",h0=((ah=function(){}).init=function(){var t=new uj("ShadowCaster","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\n#include <uv_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>\n#include <uv_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\nuniform vec4 material_BaseColor;uniform sampler2D material_BaseTexture;uniform float material_AlphaCutoff;varying vec2 v_uv;void main(){\n#if defined(MATERIAL_IS_ALPHA_CUTOFF) || (defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT))\nfloat alpha=material_BaseColor.a;\n#ifdef MATERIAL_HAS_BASETEXTURE\nalpha*=texture2D(material_BaseTexture,v_uv).a;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(alpha<material_AlphaCutoff){discard;}\n#endif\n#if defined(SCENE_ENABLE_TRANSPARENT_SHADOW) && defined(MATERIAL_IS_TRANSPARENT)\nfloat noise=fract(52.982919*fract(dot(vec2(0.06711,0.00584),gl_FragCoord.xy)));if(alpha<=noise){discard;};\n#endif\n#endif\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});t._renderState=new uJ,t._renderStateDataMap[e.RenderStateDataKey.RenderQueueType]=dk._shadowCasterRenderQueueProp;var r=new uj("DepthOnly","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\nuniform mat4 camera_VPMat;void main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <position_vert>\n}","#define GLSLIFY 1\nvoid main(){}",{pipelineStage:e.PipelineStage.DepthOnly}),n=[t,r],a={pipelineStage:e.PipelineStage.Forward};u$.create("blinn-phong",[].concat(new uj("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <ShadowFragmentDeclaration>\n#include <mobile_material_frag>\n#include <FogFragmentDeclaration>\n#include <normal_get>\nvoid main(){\n#include <begin_mobile_frag>\n#include <begin_viewdir_frag>\n#include <mobile_blinnphong_frag>\ngl_FragColor=emission+ambient+diffuse+specular;\n#ifdef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u$.create("pbr",[].concat(new uj("Forward",h$,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u$.create("pbr-specular",[].concat(new uj("Forward",h$,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u$.create("unlit",[].concat(new uj("Forward","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <position_vert>\n#include <FogVertex>\n}","#define GLSLIFY 1\n#include <common>\n#include <uv_share>\n#include <FogFragmentDeclaration>\nuniform vec4 material_BaseColor;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\nvoid main(){vec4 baseColor=material_BaseColor;\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<material_AlphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef MATERIAL_IS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a),n)),u$.create("blit",[new uj("Forward",hJ,"#define GLSLIFY 1\nuniform mediump sampler2D renderer_BlitTexture;\n#ifdef HAS_TEX_LOD\nuniform float renderer_BlitMipLevel;\n#endif\nvarying vec2 v_uv;void main(){\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,v_uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,v_uv);\n#endif\n}",a)]),u$.create("skybox",[new uj("Forward","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 camera_VPMat;varying vec3 v_cubeUV;uniform float material_Rotation;vec4 rotateY(vec4 v,float angle){const float deg2rad=3.1415926/180.0;float radian=angle*deg2rad;float sina=sin(radian);float cosa=cos(radian);mat2 m=mat2(cosa,-sina,sina,cosa);return vec4(m*v.xz,v.yw).xzyw;}void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=camera_VPMat*rotateY(vec4(POSITION,1.0),material_Rotation);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube material_CubeTexture;varying vec3 v_cubeUV;uniform float material_Exposure;uniform vec4 material_TintColor;void main(){vec4 textureColor=textureCube(material_CubeTexture,v_cubeUV);\n#ifdef MATERIAL_IS_DECODE_SKY_RGBM\ntextureColor=RGBMToLinear(textureColor,5.0);\n#elif !defined(ENGINE_IS_COLORSPACE_GAMMA)\ntextureColor=gammaToLinear(textureColor);\n#endif\ntextureColor.rgb*=material_Exposure*material_TintColor.rgb;gl_FragColor=textureColor;\n#if defined(MATERIAL_IS_DECODE_SKY_RGBM) || !defined(ENGINE_IS_COLORSPACE_GAMMA)\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u$.create("SkyProcedural",[new uj("Forward","#define GLSLIFY 1\n#define OUTER_RADIUS 1.025\n#define RAYLEIGH (mix(0.0, 0.0025, pow(material_AtmosphereThickness,2.5)))\n#define MIE 0.0010\n#define SUN_BRIGHTNESS 20.0\n#define MAX_SCATTER 50.0\nconst float SKY_GROUND_THRESHOLD=0.02;const float outerRadius=OUTER_RADIUS;const float outerRadius2=OUTER_RADIUS*OUTER_RADIUS;const float innerRadius=1.0;const float innerRadius2=1.0;const float cameraHeight=0.0001;const float HDSundiskIntensityFactor=15.0;const float simpleSundiskIntensityFactor=27.0;const float sunScale=400.0*SUN_BRIGHTNESS;const float kmESun=MIE*SUN_BRIGHTNESS;const float km4PI=MIE*4.0*3.14159265;const float scale=1.0/(OUTER_RADIUS-1.0);const float scaleDepth=0.25;const float scaleOverScaleDepth=(1.0/(OUTER_RADIUS-1.0))/0.25;const float samples=2.0;const vec3 c_DefaultScatteringWavelength=vec3(0.65,0.57,0.475);const vec3 c_VariableRangeForScatteringWavelength=vec3(0.15,0.15,0.15);attribute vec4 POSITION;uniform mat4 camera_VPMat;uniform vec3 material_SkyTint;uniform vec3 material_GroundTint;uniform float material_Exposure;uniform float material_AtmosphereThickness;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define COLOR_2_GAMMA(color) color\n#define COLOR_2_LINEAR(color) color*color\n#else\n#define GAMMA 2.2\n#define COLOR_2_GAMMA(color) pow(color,vec3(1.0/GAMMA))\n#define COLOR_2_LINEAR(color) color\n#endif\nfloat getRayleighPhase(vec3 light,vec3 ray){float eyeCos=dot(light,ray);return 0.75+0.75*eyeCos*eyeCos;}float scaleAngle(float inCos){float x=1.0-inCos;return 0.25*exp(-0.00287+x*(0.459+x*(3.83+x*(-6.80+x*5.25))));}void main(){gl_Position=camera_VPMat*vec4(POSITION.xyz,1.0);vec3 skyTintInGammaSpace=COLOR_2_GAMMA(material_SkyTint);vec3 scatteringWavelength=mix(c_DefaultScatteringWavelength-c_VariableRangeForScatteringWavelength,c_DefaultScatteringWavelength+c_VariableRangeForScatteringWavelength,vec3(1.0)-skyTintInGammaSpace);vec3 invWavelength=1.0/pow(scatteringWavelength,vec3(4.0));float krESun=RAYLEIGH*SUN_BRIGHTNESS;float kr4PI=RAYLEIGH*4.0*3.14159265;vec3 cameraPos=vec3(0.0,innerRadius+cameraHeight,0.0);vec3 eyeRay=normalize(POSITION.xyz);float far=0.0;vec3 cIn,cOut;if(eyeRay.y>=0.0){far=sqrt(outerRadius2+innerRadius2*eyeRay.y*eyeRay.y-innerRadius2)-innerRadius*eyeRay.y;float height=innerRadius+cameraHeight;float depth=exp(scaleOverScaleDepth*-cameraHeight);float startAngle=dot(eyeRay,cameraPos)/height;float startOffset=depth*scaleAngle(startAngle);float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0);{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float lightAngle=dot(-scene_SunlightDirection,samplePoint)/height;float cameraAngle=dot(eyeRay,samplePoint)/height;float scatter=(startOffset+depth*(scaleAngle(lightAngle)-scaleAngle(cameraAngle)));vec3 attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun);cOut=frontColor*kmESun;}else{far=(-cameraHeight)/(min(-0.001,eyeRay.y));vec3 pos=cameraPos+far*eyeRay;float depth=exp((-cameraHeight)*(1.0/scaleDepth));float cameraAngle=dot(-eyeRay,pos);float lightAngle=dot(-scene_SunlightDirection,pos);float cameraScale=scaleAngle(cameraAngle);float lightScale=scaleAngle(lightAngle);float cameraOffset=depth*cameraScale;float temp=lightScale+cameraScale;float sampleLength=far/samples;float scaledLength=sampleLength*scale;vec3 sampleRay=eyeRay*sampleLength;vec3 samplePoint=cameraPos+sampleRay*0.5;vec3 frontColor=vec3(0.0,0.0,0.0);vec3 attenuate;{float height=length(samplePoint);float depth=exp(scaleOverScaleDepth*(innerRadius-height));float scatter=depth*temp-cameraOffset;attenuate=exp(-clamp(scatter,0.0,MAX_SCATTER)*(invWavelength*kr4PI+km4PI));frontColor+=attenuate*(depth*scaledLength);samplePoint+=sampleRay;}cIn=frontColor*(invWavelength*krESun+kmESun);cOut=clamp(attenuate,0.0,1.0);}\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_Vertex=-POSITION.xyz;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_RayDir=-eyeRay;\n#else\nv_SkyGroundFactor=-eyeRay.y/SKY_GROUND_THRESHOLD;\n#endif\nv_GroundColor=material_Exposure*(cIn+COLOR_2_LINEAR(material_GroundTint)*cOut);v_SkyColor=material_Exposure*(cIn*getRayleighPhase(-scene_SunlightDirection,-eyeRay));float lightColorIntensity=clamp(length(scene_SunlightColor.xyz),0.25,1.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nv_SunColor=HDSundiskIntensityFactor*clamp(cOut,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#elif defined(MATERIAL_SUN_SIMPLE)\nv_SunColor=simpleSundiskIntensityFactor*clamp(cOut*sunScale,0.0,1.0)*scene_SunlightColor.xyz/lightColorIntensity;\n#endif\n}","#define GLSLIFY 1\n#include <common>\nconst float MIE_G=-0.990;const float MIE_G2=0.9801;const float SKY_GROUND_THRESHOLD=0.02;uniform float material_SunSize;uniform float material_SunSizeConvergence;uniform vec4 scene_SunlightColor;uniform vec3 scene_SunlightDirection;varying vec3 v_GroundColor;varying vec3 v_SkyColor;\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvarying vec3 v_Vertex;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_RayDir;\n#else\nvarying float v_SkyGroundFactor;\n#endif\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nvarying vec3 v_SunColor;\n#endif\n#if defined(ENGINE_IS_COLORSPACE_GAMMA)\n#define LINEAR_2_OUTPUT(color) sqrt(color)\n#endif\nfloat getMiePhase(float eyeCos,float eyeCos2){float temp=1.0+MIE_G2-2.0*MIE_G*eyeCos;temp=pow(temp,pow(material_SunSize,0.65)*10.0);temp=max(temp,1.0e-4);temp=1.5*((1.0-MIE_G2)/(2.0+MIE_G2))*(1.0+eyeCos2)/temp;return temp;}float calcSunAttenuation(vec3 lightPos,vec3 ray){\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nfloat focusedEyeCos=pow(clamp(dot(lightPos,ray),0.0,1.0),material_SunSizeConvergence);return getMiePhase(-focusedEyeCos,focusedEyeCos*focusedEyeCos);\n#else\nvec3 delta=lightPos-ray;float dist=length(delta);float spot=1.0-smoothstep(0.0,material_SunSize,dist);return spot*spot;\n#endif\n}void main(){vec3 col=vec3(0.0,0.0,0.0);\n#ifdef MATERIAL_SUN_HIGH_QUALITY\nvec3 ray=normalize(v_Vertex);float y=ray.y/SKY_GROUND_THRESHOLD;\n#elif defined(MATERIAL_SUN_SIMPLE)\nvec3 ray=v_RayDir;float y=ray.y/SKY_GROUND_THRESHOLD;\n#else\nfloat y=v_SkyGroundFactor;\n#endif\ncol=mix(v_SkyColor,v_GroundColor,clamp(y,0.0,1.0));\n#if defined(MATERIAL_SUN_HIGH_QUALITY)||defined(MATERIAL_SUN_SIMPLE)\nif(y<0.0)col+=v_SunColor*calcSunAttenuation(-scene_SunlightDirection,-ray);\n#endif\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\ncol=LINEAR_2_OUTPUT(col);\n#endif\ngl_FragColor=vec4(col,1.0);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u$.create("particle-shader",[new uj("Forward","#define GLSLIFY 1\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nattribute vec4 a_CornerTextureCoordinate;\n#endif\n#ifdef RENDERER_MODE_MESH\nattribute vec3 a_MeshPosition;attribute vec4 a_MeshColor;attribute vec2 a_MeshTextureCoordinate;varying vec4 v_MeshColor;\n#endif\nattribute vec4 a_ShapePositionStartLifeTime;attribute vec4 a_DirectionTime;attribute vec4 a_StartColor;attribute vec3 a_StartSize;attribute vec3 a_StartRotation0;attribute float a_StartSpeed;attribute vec4 a_Random0;\n#if defined(RENDERER_TSA_FRAME_RANDOM_CURVES) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nattribute vec4 a_Random1;\n#endif\nattribute vec3 a_SimulationWorldPosition;attribute vec4 a_SimulationWorldRotation;varying vec4 v_Color;\n#ifdef MATERIAL_HAS_BASETEXTURE\nattribute vec4 a_SimulationUV;varying vec2 v_TextureCoordinate;\n#endif\nuniform float renderer_CurrentTime;uniform vec3 renderer_Gravity;uniform vec2 u_DragConstant;uniform vec3 renderer_WorldPosition;uniform vec4 renderer_WorldRotation;uniform bool renderer_ThreeDStartRotation;uniform int renderer_ScalingMode;uniform vec3 renderer_PositionScale;uniform vec3 renderer_SizeScale;uniform vec3 renderer_PivotOffset;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;\n#ifdef RENDERER_MODE_STRETCHED_BILLBOARD\nuniform vec3 camera_Position;\n#endif\nuniform vec3 camera_Forward;uniform vec3 camera_Up;uniform float renderer_StretchedBillboardLengthScale;uniform float renderer_StretchedBillboardSpeedScale;uniform int renderer_SimulationSpace;\n#include <particle_common>\n#include <velocity_over_lifetime_module>\n#include <color_over_lifetime_module>\n#include <size_over_lifetime_module>\n#include <rotation_over_lifetime_module>\n#include <texture_sheet_animation_module>\nvoid main(){float age=renderer_CurrentTime-a_DirectionTime.w;float normalizedAge=age/a_ShapePositionStartLifeTime.w;vec3 lifeVelocity;if(normalizedAge<1.0){vec3 startVelocity=a_DirectionTime.xyz*a_StartSpeed;\n#if defined(RENDERER_VOL_CONSTANT) || defined(RENDERER_VOL_CURVE) || defined(RENDERER_VOL_RANDOM_CONSTANT) || defined(RENDERER_VOL_RANDOM_CURVE)\nlifeVelocity=computeParticleLifeVelocity(normalizedAge);\n#endif\nvec3 gravityVelocity=renderer_Gravity*age;vec4 worldRotation;if(renderer_SimulationSpace==0){worldRotation=renderer_WorldRotation;}else{worldRotation=a_SimulationWorldRotation;}vec3 dragData=a_DirectionTime.xyz*mix(u_DragConstant.x,u_DragConstant.y,a_Random0.x);vec3 center=computeParticlePosition(startVelocity,lifeVelocity,age,normalizedAge,gravityVelocity,worldRotation,dragData);\n#include <sphere_billboard>\n#include <stretched_billboard>\n#include <horizontal_billboard>\n#include <vertical_billboard>\n#include <particle_mesh>\ngl_Position=camera_ProjMat*camera_ViewMat*vec4(center,1.0);v_Color=computeParticleColor(a_StartColor,normalizedAge);\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec2 simulateUV;\n#if defined(RENDERER_MODE_SPHERE_BILLBOARD) || defined(RENDERER_MODE_STRETCHED_BILLBOARD) || defined(RENDERER_MODE_HORIZONTAL_BILLBOARD) || defined(RENDERER_MODE_VERTICAL_BILLBOARD)\nsimulateUV=a_CornerTextureCoordinate.zw*a_SimulationUV.xy+a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#ifdef RENDERER_MODE_MESH\nsimulateUV=a_SimulationUV.xy+a_MeshTextureCoordinate*a_SimulationUV.zw;v_TextureCoordinate=computeParticleUV(simulateUV,normalizedAge);\n#endif\n#endif\n}else{gl_Position=vec4(2.0,2.0,2.0,1.0);}}","#define GLSLIFY 1\n#include <common>\nvarying vec4 v_Color;varying vec2 v_TextureCoordinate;uniform sampler2D material_BaseTexture;uniform vec4 material_BaseColor;\n#ifdef RENDERER_MODE_MESH\nvarying vec4 v_MeshColor;\n#endif\nvoid main(){vec4 color=material_BaseColor*v_Color;\n#ifdef RENDERER_MODE_MESH\ncolor*=v_MeshColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 textureColor=texture2D(material_BaseTexture,v_TextureCoordinate);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\ncolor*=textureColor;\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}",a)]),u$.create("SpriteMask",[new uj("Forward","#define GLSLIFY 1\nuniform mat4 camera_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=camera_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_MaskTexture;uniform float renderer_MaskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(renderer_MaskTexture,v_uv);if(color.a<renderer_MaskAlphaCutoff){discard;}gl_FragColor=color;}",a)]),u$.create("Sprite",[new uj("Forward","#define GLSLIFY 1\nuniform mat4 renderer_MVPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){gl_Position=renderer_MVPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\nuniform sampler2D renderer_SpriteTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderer_SpriteTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),u$.create("Text",[new uj("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 renderElement_TextTexture;varying vec2 v_uv;varying vec4 v_color;void main(){vec4 baseColor=texture2D(renderElement_TextTexture,v_uv);gl_FragColor=baseColor*v_color;}",a)]),u$.create("background-texture",[new uj("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",a)])},ah),h1=((af=(a_=function(){this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,r=e._length,n=this._cacheHierarchyDepth;r>n&&(this._resizeCacheMapHierarchy(t,0,n,r-n),this._cacheHierarchyDepth=r);for(var a=e._mask,i=e._length-1,o=this._cacheHierarchyDepth-1,s=0;s<o;s++){var l=i<s?0:a[s],c=t[l];c||(t[l]=c=Object.create(null)),t=c}var u=i<o?0:a[o],d=t[u];return d||(this._lastQueryKey=u,this._lastQueryMap=t),d},af.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},af._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},af._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var r in t)t[r].destroy();return}for(var n in++e,t)this._recursiveDestroy(e,t[n])},af._resizeCacheMapHierarchy=function(e,t,r,n){if(t==r-1)for(var a in e){for(var i=e[a],o=e,s=0;s<n;s++)o[0==s?a:0]=o=Object.create(null);o[0]=i}else for(var l in t++,e)this._resizeCacheMapHierarchy(e[l],t,r,n)},a_),h2=(us(ap=function(e){var t;return(t=hd.call(this,e)||this)._usedElementCount=0,t._elements=[],t},hd),(am=ap.prototype).get=function(){var e=this._usedElementCount,t=this._elements;if(this._usedElementCount++,t.length!==e)return t[e];var r=new this._type;return t.push(r),r},am.clear=function(){this._usedElementCount=0},ap),h3=((av=(ag=function(){}).prototype)._initialize=function(e,t){},av._update=function(){},av._destroy=function(){},av._getRequestAnimationFrame=function(){return null},av._getCancelAnimationFrame=function(){return null},av._getCameraClearFlagsMask=function(t){return e.CameraClearFlags.None},ag);h0.init();var h4=function(t){function r(n,a,i){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new uJ,o._renderElementPool=new h2(dS),o._subRenderElementPool=new h2(dA),o._textSubRenderElementPool=new h2(dA),o._charRenderInfoPool=new hh(dL,50),o._spriteDefaultMaterials=[],o._renderContext=new df,o._renderCount=0,o._shaderProgramPools=[],o._fontMap={},o._macroCollection=new uR,o._settings={},o._resourceManager=new hb(un(o)),o._sceneManager=new hy(un(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new uV,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){if(o._vSyncCount){var e,t=(null==(e=o.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;o._requestId=t(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)}else o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update()},o._hardwareRenderer=a,o._hardwareRenderer.init(n,o._onDeviceLost.bind(un(o)),o._onDeviceRestored.bind(un(o))),o._canvas=n;var o,s=un(o)._spriteDefaultMaterials;o._spriteDefaultMaterial=s[e.SpriteMaskInteraction.None]=o._createSpriteMaterial(e.SpriteMaskInteraction.None),s[e.SpriteMaskInteraction.VisibleInsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleInsideMask),s[e.SpriteMaskInteraction.VisibleOutsideMask]=o._createSpriteMaterial(e.SpriteMaskInteraction.VisibleOutsideMask),o._textDefaultMaterial=o._createTextMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=dF.createFromOS(un(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o._batcherManager=new hg(un(o)),o.inputManager=new hQ(un(o),i.input);var l=i.xrDevice;if(l&&(o.xrManager=new h3,o.xrManager._initialize(un(o),l)),a.canIUse(e.GLCapabilityType.depthTexture)){var c=new ds(un(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(r._noDepthTextureMacro);var u=new dN(un(o),u$.find("unlit"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new c7(1,0,1.01,1)),o._meshMagentaMaterial=u;var d=new dN(un(o),u$.find("particle-shader"));d.isGCIgnored=!0,d.shaderData.setColor("material_BaseColor",new c7(1,0,1.01,1)),o._particleMagentaMaterial=d;var h=o._settings,_=i.colorSpace||e.ColorSpace.Linear;return _===e.ColorSpace.Gamma&&o._macroCollection.enable(r._gammaMacro),h.colorSpace=_,o._basicResources=new hu(un(o)),o._particleBufferUtils=new hZ(un(o)),o}us(r,t);var n=r.prototype;return n.createEntity=function(e){return new hs(this,e)},n.pause=function(){var e;this._isPaused=!0,((null==(e=this.xrManager)?void 0:e._getCancelAnimationFrame())||cancelAnimationFrame)(this._requestId),clearTimeout(this._timeoutId)},n.resume=function(){if(this._isPaused){if(this._isPaused=!1,this.time._reset(),this._vSyncCount){var e,t=(null==(e=this.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;this._requestId=t(this._animate)}else this._timeoutId=window.setTimeout(this._animate,this._targetFrameInterval)}},n.update=function(){var e,t=this._time;t._update();var r=t.deltaTime;this._frameInProcess=!0,this._subRenderElementPool.clear(),this._textSubRenderElementPool.clear(),this._renderElementPool.clear(),null==(e=this.xrManager)||e._update();var n=this.inputManager,a=this._physicsInitialized;n._update();for(var i=this._sceneManager._scenes.getLoopArray(),o=i.length,s=0;s<o;s++){var l=i[s];if(l.isActive&&!l.destroyed){var c=l._componentsManager;c.sortCameras(),c.callScriptOnStart()}}if(a)for(var u=0;u<o;u++){var d=i[u];d.isActive&&!d.destroyed&&d.physics._update(r)}a&&n._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(r)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(r)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(r)}if(this._isDeviceLost||this._render(i),this._waitingDestroy)this._destroy();else for(var v=0;v<o;v++){var y=i[v];y.isActive&&!y.destroyed&&y._componentsManager.handlingInvalidScripts()}this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1},n.run=function(){this.resume(),this.dispatch("run",this)},n.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},n.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},n._destroy=function(){var e;this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this._batcherManager.destroy(),null==(e=this.xrManager)||e._destroy(),this.dispatch("shutdown",this),this.pause(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},n.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},n._getShaderProgramPool=function(e){var t=e._shaderPassId,r=this._shaderProgramPools,n=r[t];if(!n){var a=t+1;a>r.length&&(r.length=a),r[t]=n=new h1,e._shaderProgramPools.push(n)}return n},n._render=function(e){for(var t=this,r=this.time.deltaTime,n=0,a=e.length;n<a;n++){var i=e[n];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(r),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(r,n){var a=e[r];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return uI.debug("No active camera in scene.");i.forEach(function(e){var r=a._componentsManager;r.callCameraOnBeginRender(e),e.render(),r.callCameraOnEndRender(e),t._hardwareRenderer._options._forceFlush&&t._hardwareRenderer.flush()},function(e,t){e._cameraIndex=t})}}(o)},n._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},n._initialize=function(e){var t=this,r=e.shaderLab,n=e.physics;r&&!u$._shaderLab&&(u$._shaderLab=r);var a=[];n&&a.push(n.initialize().then(function(){return hF._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=hb._loaders;for(var o in i){var s=i[o];s.initialize&&a.push(s.initialize(this,e))}return Promise.all(a).then(function(){return t})},n._createSpriteMaterial=function(t){var r=new dN(this,u$.find("Sprite")),n=r.renderState,a=n.blendState.targetBlendState;if(a.enabled=!0,a.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,a.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=e.BlendFactor.One,a.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=e.BlendOperation.Add,t!==e.SpriteMaskInteraction.None){var i=n.stencilState;i.enabled=!0,i.writeMask=0,i.referenceValue=1;var o=t===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;i.compareFunctionFront=o,i.compareFunctionBack=o}return n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,n.renderQueueType=e.RenderQueueType.Transparent,r.isGCIgnored=!0,r},n._createSpriteMaskMaterial=function(){var t=new dN(this,u$.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,r.renderQueueType=e.RenderQueueType.Transparent,t.isGCIgnored=!0,t},n._createTextMaterial=function(){var t=new dN(this,u$.find("Text")),r=t.renderState,n=r.blendState.targetBlendState;return n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.colorBlendOperation=n.alphaBlendOperation=e.BlendOperation.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=e.CullMode.Off,r.renderQueueType=e.RenderQueueType.Transparent,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 uJ,this._shaderProgramPools.length=0;var t=this.resourceManager;t._restoreGraphicResources(),console.log("Graphic resource restored."),t._restoreResourcesContent().then(function(){console.log("Graphic resource content restored.\n\nDevice restored."),e.dispatch("devicerestored",e),e._isDeviceLost=!1}).catch(function(e){console.error(e)})},n._gc=function(){this._subRenderElementPool.garbageCollection(),this._textSubRenderElementPool.garbageCollection(),this._renderElementPool.garbageCollection(),this._renderContext.garbageCollection()},ui(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}(uw);h4._gammaMacro=uM.getByName("ENGINE_IS_COLORSPACE_GAMMA"),h4._noDepthTextureMacro=uM.getByName("ENGINE_NO_DEPTH_TEXTURE"),h4._pixelsPerUnit=100;var h8=(ui(ay=function(){this._sizeUpdateFlagManager=new uT},[{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())}}]),ay),h5=((ab=(ax=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},ab._render=function(e){var t=this.material,r=this.mesh;if(!t){uI.warn("The material of sky is not defined.");return}if(t.destroyed){uI.warn("The material of sky is destroyed.");return}if(!r){uI.warn("The mesh of sky is not defined.");return}if(r.destroyed){uI.warn("The mesh of sky is destroyed.");return}var n=e.camera,a=n.engine,i=n.scene,o=n.aspectRatio,s=n.fieldOfView,l=n.viewMatrix,c=n.shaderData,u=i.shaderData,d=ax._viewProjMatrix,h=ax._projectionMatrix,_=a._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(cQ.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,c8.multiply(h,d,d);var y=c.getMatrix(df.vpMatrixProperty);e.flipProjection&&c8.multiply(df._flipYMatrix,d,d),c.setMatrix(df.vpMatrixProperty,d);var x=u$._compileMacros;uR.unionCollection(e.camera._globalShaderMacro,f._macroCollection,x);var b=p.subShaders[0].passes[0],T=b._getShaderProgram(a,x);T.bind(),T.groupingOtherUniformBlock(),T.uploadAll(T.sceneUniformBlock,u),T.uploadAll(T.cameraUniformBlock,c),T.uploadAll(T.materialUniformBlock,f),T.uploadUnGroupTextures(),m._applyStates(a,!1,b._renderStateDataMap,f),_.drawPrimitive(r._primitive,r.subMesh,T),c.setMatrix(df.vpMatrixProperty,y)},ui(ax,[{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}}}]),ax);h5._epsilon=1e-6,h5._viewProjMatrix=new c8,h5._projectionMatrix=new c8(1,0,0,0,0,1,0,0,0,0,h5._epsilon-1,-1,0,0,0,0);var h9=((aC=(aT=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new c7(.25,.25,.25,1),this.sky=new h5,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()},aC._resizeBackgroundTexture=function(){var t=this._texture,r=this._mesh;if(this._texture){var n=this._engine.canvas,a=n.width,i=n.height,o=r.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.Fill:o[0].set(-1,-1,1),o[1].set(1,-1,1),o[2].set(-1,1,1),o[3].set(1,1,1);break;case e.BackgroundTextureFillMode.AspectFitWidth:var s=t.height*a/t.width/i;o[0].set(-1,-s,1),o[1].set(1,-s,1),o[2].set(-1,s,1),o[3].set(1,s,1);break;case e.BackgroundTextureFillMode.AspectFitHeight:var l=t.width*i/t.height/a;o[0].set(-l,-1,1),o[1].set(l,-1,1),o[2].set(-l,1,1),o[3].set(l,1,1)}r.setPositions(o),r.uploadData(!1)}},aC._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},aC._initMaterial=function(t){var r=this._material=new dN(t,u$.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},aC._createPlane=function(e){for(var t=new d2(e),r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],a=[,,,,],i=0;i<4;++i)n[i]=new cZ,a[i]=new c9(i%2,1-(.5*i|0));return t.setPositions(n),t.setUVs(a),t.setIndices(r),t.uploadData(!1),t.addSubMesh(0,r.length),t},ui(aT,[{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())}}]),aT),h6=((aA=(aS=function(){this._cameraNeedSorting=!1,this._activeCameras=new dr,this._renderers=new dr,this._onStartScripts=new dr,this._onUpdateScripts=new dr,this._onLateUpdateScripts=new dr,this._onPhysicsUpdateScripts=new dr,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new dr,this._onUpdateRenderers=new dr,this._componentsContainerPool=[]}).prototype).addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},aA.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},aA.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,r=e.length;t<r;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},aA.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},aA.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},aA.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},aA.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},aA.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},aA.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},aA.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},aA.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},aA.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},aA.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},aA.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},aA.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aA.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},aA.callScriptOnStart=function(){var e=this,t=this._onStartScripts;t.length>0&&t.forEachAndClean(function(t){t._started=!0,e.removeOnStartScript(t),t.onStart()},function(e,t){e._onStartIndex=t})},aA.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},aA.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},aA.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},aA.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aA.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aA.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}},aA.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},aA.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},aA.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},aA.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},aA._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection(),this._activeCameras.garbageCollection()},aS);e.FogMode=void 0,(aM=e.FogMode||(e.FogMode={}))[aM.None=0]="None",aM[aM.Linear=1]="Linear",aM[aM.Exponential=2]="Exponential",aM[aM.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(aR=e.DiffuseMode||(e.DiffuseMode={}))[aR.SolidColor=0]="SolidColor",aR[aR.SphericalHarmonics=1]="SphericalHarmonics";var h7=(us(aE=function(t){var r;return(r=um.call(this,t)||this)._diffuseSolidColor=new c7(.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},um),(aw=aE.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(aE._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(aE._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(aE._specularIntensityProperty,this._specularIntensity),t.setFloatArray(aE._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},aw._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(aE._specularTextureProperty,null),n.disableMacro(aE._specularMacro)},aw._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(aE._shMacro):t.disableMacro(aE._shMacro)},aw._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(aE._specularTextureProperty,this._specularTexture),e.setFloat(aE._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(aE._specularMacro)):e.disableMacro(aE._specularMacro)},aw._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(aE._decodeRGBMMacro):e.disableMacro(aE._decodeRGBMMacro)},aw._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]},ui(aE,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTextureDecodeRGBM(t[r].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setDiffuseMode(t[r].shaderData)}},{key:"diffuseSolidColor",get:function(){return this._diffuseSolidColor},set:function(e){e!==this._diffuseSolidColor&&this._diffuseSolidColor.copyFrom(e)}},{key:"diffuseSphericalHarmonics",get:function(){return this._diffuseSphericalHarmonics},set:function(e){if(this._diffuseSphericalHarmonics=e,e){this._preComputeSH(e,this._shArray);for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloatArray(aE._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)t[r].shaderData.setFloat(aE._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,r=0,n=t.length;r<n;r++)this._setSpecularTexture(t[r].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var t=0,r=this._scenes.length;t<r;t++)this._scenes[t].shaderData.setFloat(aE._specularIntensityProperty,e)}}]),aE);h7._shMacro=uM.getByName("SCENE_USE_SH"),h7._specularMacro=uM.getByName("SCENE_USE_SPECULAR_ENV"),h7._decodeRGBMMacro=uM.getByName("SCENE_IS_DECODE_ENV_RGBM"),h7._diffuseColorProperty=uO.getByName("scene_EnvMapLight.diffuse"),h7._diffuseSHProperty=uO.getByName("scene_EnvSH"),h7._diffuseIntensityProperty=uO.getByName("scene_EnvMapLight.diffuseIntensity"),h7._specularTextureProperty=uO.getByName("scene_EnvSpecularSampler"),h7._specularIntensityProperty=uO.getByName("scene_EnvMapLight.specularIntensity"),h7._mipLevelProperty=uO.getByName("scene_EnvMapLight.mipMapLevel");var _e=(us(aP=function(){var t;return t=u4.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._lightIndex=-1,t._lightColor=new c7,t._shadowStrength=1,t._color=new c7(1,1,1,1),t},u4),aP.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},ui(aP,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=cQ.clamp(e,0,1)}},{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 c8),c8.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new c8),c8.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),aP);ul([uu],_e.prototype,"_lightIndex",void 0);var _t=(us(aF=function(){var e;return e=_e.apply(this,arguments)||this,e._reverseDirection=new cZ,e},_e),(aL=aF.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.direction,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c7.gammaToLinearSpace(o.r),r.color[a+1]=c7.gammaToLinearSpace(o.g),r.color[a+2]=c7.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.direction[i]=s.x,r.direction[i+1]=s.y,r.direction[i+2]=s.z},aL._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},aL._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},aF._updateShaderData=function(e,t){e.setIntArray(aF._cullingMaskProperty,t.cullingMask),e.setFloatArray(aF._colorProperty,t.color),e.setFloatArray(aF._directionProperty,t.direction)},ui(aF,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cZ.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aF);_t._cullingMaskProperty=uO.getByName("scene_DirectLightCullingMask"),_t._colorProperty=uO.getByName("scene_DirectLightColor"),_t._directionProperty=uO.getByName("scene_DirectLightDirection");var _r=(us(aB=function(){var e;return e=_e.apply(this,arguments)||this,e.distance=100,e},_e),(aD=aB.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.cullingMask;r.cullingMask[n]=65535&l,r.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c7.gammaToLinearSpace(o.r),r.color[a+1]=c7.gammaToLinearSpace(o.g),r.color[a+2]=c7.gammaToLinearSpace(o.b)):(r.color[a]=o.r,r.color[a+1]=o.g,r.color[a+2]=o.b),r.position[i]=s.x,r.position[i+1]=s.y,r.position[i+2]=s.z,r.distance[t]=this.distance},aD._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},aD._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},aB._updateShaderData=function(e,t){e.setIntArray(aB._cullingMaskProperty,t.cullingMask),e.setFloatArray(aB._colorProperty,t.color),e.setFloatArray(aB._positionProperty,t.position),e.setFloatArray(aB._distanceProperty,t.distance)},ui(aB,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aB);_r._cullingMaskProperty=uO.getByName("scene_PointLightCullingMask"),_r._colorProperty=uO.getByName("scene_PointLightColor"),_r._positionProperty=uO.getByName("scene_PointLightPosition"),_r._distanceProperty=uO.getByName("scene_PointLightDistance");var _n=(us(aI=function(){var e;return e=_e.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new cZ,e._projectMatrix=new c8,e},_e),(aO=aI.prototype)._appendData=function(t,r){var n=2*t,a=3*t,i=3*t,o=3*t,s=this._getLightIntensityColor(),l=this.position,c=this.direction,u=this.cullingMask;r.cullingMask[n]=65535&u,r.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(r.color[a]=c7.gammaToLinearSpace(s.r),r.color[a+1]=c7.gammaToLinearSpace(s.g),r.color[a+2]=c7.gammaToLinearSpace(s.b)):(r.color[a]=s.r,r.color[a+1]=s.g,r.color[a+2]=s.b),r.position[i]=l.x,r.position[i+1]=l.y,r.position[i+2]=l.z,r.direction[o]=c.x,r.direction[o+1]=c.y,r.direction[o+2]=c.z,r.distance[t]=this.distance,r.angleCos[t]=Math.cos(this.angle),r.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},aO._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},aO._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},aI._updateShaderData=function(e,t){e.setIntArray(aI._cullingMaskProperty,t.cullingMask),e.setFloatArray(aI._colorProperty,t.color),e.setFloatArray(aI._positionProperty,t.position),e.setFloatArray(aI._directionProperty,t.direction),e.setFloatArray(aI._distanceProperty,t.distance),e.setFloatArray(aI._angleCosProperty,t.angleCos),e.setFloatArray(aI._penumbraCosProperty,t.penumbraCos)},ui(aI,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return cZ.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 c8.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),aI);_n._cullingMaskProperty=uO.getByName("scene_SpotLightCullingMask"),_n._colorProperty=uO.getByName("scene_SpotLightColor"),_n._positionProperty=uO.getByName("scene_SpotLightPosition"),_n._directionProperty=uO.getByName("scene_SpotLightDirection"),_n._distanceProperty=uO.getByName("scene_SpotLightDistance"),_n._angleCosProperty=uO.getByName("scene_SpotLightAngleCos"),_n._penumbraCosProperty=uO.getByName("scene_SpotLightPenumbraCos");var _a=function(){function t(){this._spotLights=new dr,this._pointLights=new dr,this._directLights=new dr,this._directData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight)},this._pointData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight)},this._spotData={cullingMask:new Int32Array(2*t._maxLight),color:new Float32Array(3*t._maxLight),position:new Float32Array(3*t._maxLight),direction:new Float32Array(3*t._maxLight),distance:new Float32Array(t._maxLight),angleCos:new Float32Array(t._maxLight),penumbraCos:new Float32Array(t._maxLight)}}var r=t.prototype;return r._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},r._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},r._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},r._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},r._updateShaderData=function(e){for(var r=this._spotLights,n=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=t._maxLight,c=Math.min(r.length,l),u=Math.min(n.length,l),d=Math.min(a.length,l),h=0;h<c;h++)r.get(h)._appendData(h,i);for(var _=0;_<u;_++)n.get(_)._appendData(_,o);for(var f=0;f<d;f++)a.get(f)._appendData(f,s);d?(_t._updateShaderData(e,s),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(_r._updateShaderData(e,o),e.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(_n._updateShaderData(e,i),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},r._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},r._updateSunlightIndex=function(e){var t=this._directLights,r=e._lightIndex;if(r>0){var n=t.get(0),a=t.get(r);t.set(0,a),t.set(r,n),a._lightIndex=0,n._lightIndex=r}},r._getMaxBrightestSunlight=function(){for(var t=this._directLights,r=null,n=Number.NEGATIVE_INFINITY,a=!1,i=0,o=t.length;i<o;i++){var s=t.get(i);s.shadowType===e.ShadowType.None||a||(n=Number.NEGATIVE_INFINITY,a=!0);var l=s.intensity*s.color.getBrightness();a?s.shadowType!==e.ShadowType.None&&n<l&&(n=l,r=s):n<l&&(n=l,r=s)}return r},t}();_a._sunlightColorProperty=uO.getByName("scene_SunlightColor"),_a._sunlightDirectionProperty=uO.getByName("scene_SunlightDirection"),_a._maxLight=10,e.BloomDownScaleMode=void 0,(aV=e.BloomDownScaleMode||(e.BloomDownScaleMode={}))[aV.Half=0]="Half",aV[aV.Quarter=1]="Quarter";var _i=function(){function t(e){this._uberMaterial=e,this._highQualityFiltering=!1,this._mipDownRT=[],this._mipUpRT=[],this._maxIterations=6,this._enabled=!1,this.downScale=0;var r=e.engine,n=new dN(r,u$.find(t.SHADER_NAME)),a=n.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=n.shaderData,o=e.shaderData;i.setVector4(t._bloomParams,new c6),i.setVector4(t._lowMipTexelSizeProp,new c6),o.setVector4(t._bloomIntensityParams,new c6(1,1,0,0)),o.setVector4(t._dirtTilingOffsetProp,new c6),o.setColor(t._tintProp,new c7(1,1,1,1)),this._bloomMaterial=n,this.threshold=.9,this.scatter=.7,this.intensity=1,this.dirtIntensity=1}var r=t.prototype;return r.onRender=function(e,t){var r=e.camera,n=0===this.downScale?1:2,a=r.pixelViewport,i=a.width>>n,o=a.height>>n,s=this._calculateMipCount(i,o);this._prefilter(r,t,i,o,s),this._downsample(s),this._upsample(s),this._setupUber(r)},r._calculateMipCount=function(e,t){return Math.min(Math.max(Math.floor(Math.log2(Math.max(e,t))-1),1),this._maxIterations)},r._prefilter=function(t,r,n,a,i){for(var o=this._uberMaterial.engine,s=t._getInternalColorTextureFormat(),l=n,c=a,u=0;u<i;u++)this._mipUpRT[u]=du.recreateRenderTargetIfNeeded(o,this._mipUpRT[u],l,c,s,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear),this._mipDownRT[u]=du.recreateRenderTargetIfNeeded(o,this._mipDownRT[u],l,c,s,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear),l=Math.max(1,Math.floor(l/2)),c=Math.max(1,Math.floor(c/2));du.blitTexture(o,r,this._mipDownRT[0],void 0,void 0,this._bloomMaterial,0)},r._downsample=function(e){for(var t=this._bloomMaterial,r=t.engine,n=this._mipDownRT[0],a=1;a<e;a++)du.blitTexture(r,n.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),du.blitTexture(r,this._mipUpRT[a].getColorTexture(0),this._mipDownRT[a],void 0,void 0,t,2),n=this._mipDownRT[a]},r._upsample=function(e){for(var r=this._bloomMaterial,n=r.engine,a=r.shaderData,i=e-2;i>=0;i--){var o=i==e-2?this._mipDownRT[i+1]:this._mipUpRT[i+1],s=this._mipDownRT[i],l=this._mipUpRT[i];a.setTexture(t._lowMipTextureProp,o.getColorTexture(0)),this.highQualityFiltering&&a.getVector4(t._lowMipTexelSizeProp).set(1/o.width,1/o.height,o.width,o.height),du.blitTexture(n,s.getColorTexture(0),l,void 0,void 0,r,3)}},r._setupUber=function(e){var r=this._uberMaterial.shaderData,n=this.dirtTexture;if(n){var a=r.getVector4(t._dirtTilingOffsetProp),i=n.width/n.height,o=e.aspectRatio;i>o?a.set(o/i,1,(1-a.x)*.5,0):i<o?a.set(1,i/o,0,(1-a.y)*.5):a.set(1,1,0,0)}r.setTexture(t._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},r._releaseRenderTargets=function(){for(var e=this._mipDownRT.length,t=0;t<e;t++){var r=this._mipDownRT[t],n=this._mipUpRT[t];r&&(r.getColorTexture(0).destroy(!0),r.destroy(!0)),n&&(n.getColorTexture(0).destroy(!0),n.destroy(!0))}this._mipDownRT.length=0,this._mipUpRT.length=0},ui(t,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,e?this._uberMaterial.shaderData.enableMacro(t._enableMacro):(this._uberMaterial.shaderData.disableMacro(t._enableMacro),this._releaseRenderTargets()))}},{key:"threshold",get:function(){return this._threshold},set:function(e){if((e=Math.max(0,e))!==this._threshold){this._threshold=e;var r=c7.gammaToLinearSpace(e),n=.5*r,a=this._bloomMaterial.shaderData.getVector4(t._bloomParams);a.x=r,a.y=n}}},{key:"scatter",get:function(){return this._scatter},set:function(e){if((e=cQ.clamp(e,0,1))!==this._scatter){this._scatter=e;var r=this._bloomMaterial.shaderData.getVector4(t._bloomParams),n=cQ.lerp(.05,.95,e);r.z=n}}},{key:"intensity",get:function(){return this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).x},set:function(e){e=Math.max(0,e),this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).x=e}},{key:"tint",get:function(){return this._uberMaterial.shaderData.getColor(t._tintProp)},set:function(e){var r=this._uberMaterial.shaderData.getColor(t._tintProp);e!==r&&r.copyFrom(e)}},{key:"highQualityFiltering",get:function(){return this._highQualityFiltering},set:function(e){e!==this._highQualityFiltering&&(this._highQualityFiltering=e,e?(this._bloomMaterial.shaderData.enableMacro(t._hqMacro),this._uberMaterial.shaderData.enableMacro(t._hqMacro)):(this._bloomMaterial.shaderData.disableMacro(t._hqMacro),this._uberMaterial.shaderData.disableMacro(t._hqMacro)))}},{key:"dirtTexture",get:function(){return this._uberMaterial.shaderData.getTexture(t._dirtTextureProp)},set:function(e){this._uberMaterial.shaderData.setTexture(t._dirtTextureProp,e),e?this._uberMaterial.shaderData.enableMacro(t._dirtMacro):this._uberMaterial.shaderData.disableMacro(t._dirtMacro)}},{key:"dirtIntensity",get:function(){return this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).y},set:function(e){e=Math.max(0,e),this._uberMaterial.shaderData.getVector4(t._bloomIntensityParams).y=e}}]),t}();_i.SHADER_NAME="PostProcessEffect Bloom",_i._hqMacro=uM.getByName("BLOOM_HQ"),_i._dirtMacro=uM.getByName("BLOOM_DIRT"),_i._bloomParams=uO.getByName("material_BloomParams"),_i._lowMipTextureProp=uO.getByName("material_lowMipTexture"),_i._lowMipTexelSizeProp=uO.getByName("material_lowMipTexelSize"),_i._enableMacro=uM.getByName("ENABLE_EFFECT_BLOOM"),_i._bloomTextureProp=uO.getByName("material_BloomTexture"),_i._dirtTextureProp=uO.getByName("material_BloomDirtTexture"),_i._tintProp=uO.getByName("material_BloomTint"),_i._bloomIntensityParams=uO.getByName("material_BloomIntensityParams"),_i._dirtTilingOffsetProp=uO.getByName("material_BloomDirtTilingOffset"),u$.create(_i.SHADER_NAME,[new uj("Bloom Prefilter",hJ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 material_BloomParams;uniform vec4 renderer_texelSize;void main(){\n#ifdef BLOOM_HQ\nvec2 texelSize=renderer_texelSize.xy;mediump vec4 A=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,-1.0));mediump vec4 B=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,-1.0));mediump vec4 C=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,-1.0));mediump vec4 D=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,-0.5));mediump vec4 E=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,-0.5));mediump vec4 F=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,0.0));mediump vec4 G=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 H=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,0.0));mediump vec4 I=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-0.5,0.5));mediump vec4 J=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.5,0.5));mediump vec4 K=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(-1.0,1.0));mediump vec4 L=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(0.0,1.0));mediump vec4 M=sampleTexture(renderer_BlitTexture,v_uv+texelSize*vec2(1.0,1.0));mediump vec2 scale=vec2(0.5,0.125);mediump vec2 div=(1.0/4.0)*scale;mediump vec4 samplerColor=(D+E+I+J)*div.x;samplerColor+=(A+B+G+F)*div.y;samplerColor+=(B+C+H+G)*div.y;samplerColor+=(F+G+L+K)*div.y;samplerColor+=(G+H+M+L)*div.y;\n#else\nmediump vec4 samplerColor=sampleTexture(renderer_BlitTexture,v_uv);\n#endif\nmediump vec3 color=samplerColor.rgb;color=min(color,HALF_MAX);mediump float brightness=max3(color);float threshold=material_BloomParams.x;float thresholdKnee=material_BloomParams.y;mediump float softness=clamp(brightness-threshold+thresholdKnee,0.0,2.0*thresholdKnee);softness=(softness*softness)/(4.0*thresholdKnee+1e-4);mediump float multiplier=max(brightness-threshold,softness)/max(brightness,1e-4);color*=multiplier;color=max(color,0.0);gl_FragColor=vec4(color,samplerColor.a);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uj("Bloom Blur Horizontal",hJ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy*2.0;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*4.0,0.0));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*3.0,0.0));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*2.0,0.0));mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv-vec2(texelSize.x*1.0,0.0));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c5=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*1.0,0.0));mediump vec4 c6=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*2.0,0.0));mediump vec4 c7=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*3.0,0.0));mediump vec4 c8=sampleTexture(renderer_BlitTexture,v_uv+vec2(texelSize.x*4.0,0.0));gl_FragColor=c0*0.01621622+c1*0.05405405+c2*0.12162162+c3*0.19459459+c4*0.22702703+c5*0.19459459+c6*0.12162162+c7*0.05405405+c8*0.01621622;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uj("Bloom Blur Vertical",hJ,"#define GLSLIFY 1\n#include <PostCommon>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;void main(){vec2 texelSize=renderer_texelSize.xy;mediump vec4 c0=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*3.23076923));mediump vec4 c1=sampleTexture(renderer_BlitTexture,v_uv-vec2(0.0,texelSize.y*1.38461538));mediump vec4 c2=sampleTexture(renderer_BlitTexture,v_uv);mediump vec4 c3=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*1.38461538));mediump vec4 c4=sampleTexture(renderer_BlitTexture,v_uv+vec2(0.0,texelSize.y*3.23076923));gl_FragColor=c0*0.07027027+c1*0.31621622+c2*0.22702703+c3*0.31621622+c4*0.07027027;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),new uj("Bloom Upsample",hJ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform sampler2D material_lowMipTexture;uniform vec4 material_BloomParams;uniform vec4 material_lowMipTexelSize;void main(){mediump vec4 highMip=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef BLOOM_HQ\nmediump vec4 lowMip=sampleTexture2DBicubic(material_lowMipTexture,v_uv,material_lowMipTexelSize);\n#else\nmediump vec4 lowMip=sampleTexture(material_lowMipTexture,v_uv);\n#endif\ngl_FragColor=mix(highMip,lowMip,material_BloomParams.z);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}")]),e.TonemappingMode=void 0,(aN=e.TonemappingMode||(e.TonemappingMode={}))[aN.Neutral=0]="Neutral",aN[aN.ACES=1]="ACES";var _o=(ui(ak=function(e){this._uberMaterial=e,this._enabled=!1,this.mode=0},[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,e?this._uberMaterial.shaderData.enableMacro(ak._enableMacro):this._uberMaterial.shaderData.disableMacro(ak._enableMacro))}},{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._uberMaterial.shaderData.enableMacro("TONEMAPPING_MODE",e.toString()))}}]),ak);_o._enableMacro=uM.getByName("ENABLE_EFFECT_TONEMAPPING");var _s=function(){function e(t){this.scene=t,this.isActive=!0;var r=u$.find(e.UBER_SHADER_NAME),n=new dN(t.engine,r),a=n.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new _i(n),o=new _o(n);this._uberMaterial=n,this._bloomEffect=i,this._tonemappingEffect=o}return e.prototype._render=function(e,t,r){var n=e.camera,a=n.engine;t._blitRenderTarget();var i=t.getColorTexture(),o=this._bloomEffect;o.enabled&&o.onRender(e,i),du.blitTexture(a,i,r,0,n.viewport,this._uberMaterial)},ui(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();_s.UBER_SHADER_NAME="UberPost",Object.assign(uN,{PostCommon:"#define GLSLIFY 1\n#ifndef POST_COMMON\n#define POST_COMMON\n#include <common>\n#define FLT_MIN 1.175494351e-38\n#define HALF_MIN 6.103515625e-5\n#define HALF_MAX 65504.0\nfloat min3(vec3 val){return min(min(val.x,val.y),val.z);}float max3(vec3 val){return max(max(val.x,val.y),val.z);}const float INVERT_LOG10=0.43429448190325176;float log10(float x){return log(x)*INVERT_LOG10;}vec4 sampleTexture(sampler2D tex,vec2 uv){vec4 color=texture2D(tex,uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ncolor=gammaToLinear(color);\n#endif\nreturn color;}\n#endif\n",Filtering:"#define GLSLIFY 1\n#ifndef FILTERING\n#define FILTERING\nvec2 bSpline3MiddleLeft(vec2 x){return 0.16666667+x*(0.5+x*(0.5-x*0.5));}vec2 bSpline3MiddleRight(vec2 x){return 0.66666667+x*(-1.0+0.5*x)*x;}vec2 bSpline3Rightmost(vec2 x){return 0.16666667+x*(-0.5+x*(0.5-x*0.16666667));}void bicubicFilter(vec2 fracCoord,out vec2 weights[2],out vec2 offsets[2]){vec2 r=bSpline3Rightmost(fracCoord);vec2 mr=bSpline3MiddleRight(fracCoord);vec2 ml=bSpline3MiddleLeft(fracCoord);vec2 l=1.0-mr-ml-r;weights[0]=r+mr;weights[1]=ml+l;offsets[0]=-1.0+mr/weights[0];offsets[1]=1.0+l/weights[1];}vec4 sampleTexture2DBicubic(sampler2D tex,vec2 coord,vec4 texSize){vec2 xy=coord*texSize.zw+0.5;vec2 ic=floor(xy);vec2 fc=fract(xy);vec2 weights[2],offsets[2];bicubicFilter(fc,weights,offsets);return weights[0].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[0].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[0].y)-0.5)*texSize.xy))+weights[1].y*(weights[0].x*sampleTexture(tex,(ic+vec2(offsets[0].x,offsets[1].y)-0.5)*texSize.xy)+weights[1].x*sampleTexture(tex,(ic+vec2(offsets[1].x,offsets[1].y)-0.5)*texSize.xy));}\n#endif\n",ODT:"#define GLSLIFY 1\n#include <Tonescale>\nconst float CINEMA_WHITE=48.0;const float CINEMA_BLACK=0.02;const float ODT_SAT_FACTOR=0.93;mediump vec3 Y_2_linCV(mediump vec3 Y,mediump float Ymax,mediump float Ymin){return(Y-Ymin)/(Ymax-Ymin);}mediump vec3 XYZ_2_xyY(mediump vec3 XYZ){mediump float divisor=max(dot(XYZ,vec3(1.0)),1e-4);return vec3(XYZ.xy/divisor,XYZ.y);}mediump vec3 xyY_2_XYZ(mediump vec3 xyY){mediump float m=xyY.z/max(xyY.y,1e-4);mediump vec3 XYZ=vec3(xyY.xz,(1.0-xyY.x-xyY.y));XYZ.xz*=m;return XYZ;}const mediump float DIM_SURROUND_GAMMA=0.9811;mediump vec3 darkSurround_to_dimSurround(mediump vec3 linearCV){mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;mediump vec3 xyY=XYZ_2_xyY(XYZ);xyY.z=clamp(xyY.z,0.0,HALF_MAX);xyY.z=pow(xyY.z,DIM_SURROUND_GAMMA);XYZ=xyY_2_XYZ(xyY);return XYZ_2_AP1_MAT*XYZ;}mediump vec3 ODT_RGBmonitor_100nits_dim(mediump vec3 oces){mediump vec3 rgbPre=AP0_2_AP1_MAT*oces;mediump vec3 rgbPost;rgbPost.r=segmented_spline_c9_fwd(rgbPre.r);rgbPost.g=segmented_spline_c9_fwd(rgbPre.g);rgbPost.b=segmented_spline_c9_fwd(rgbPre.b);mediump vec3 linearCV=Y_2_linCV(rgbPost,CINEMA_WHITE,CINEMA_BLACK);linearCV=darkSurround_to_dimSurround(linearCV);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);mediump vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;linearCV=clamp(linearCV,vec3(0),vec3(1));return linearCV;}",RRT:"#define GLSLIFY 1\n#include <Tonescale>\nmediump float sigmoid_shaper(mediump float x){mediump float t=max(1.0-abs(x/2.0),0.0);mediump float y=1.0+sign(x)*(1.0-t*t);return y*0.5;}mediump float glow_fwd(mediump float ycIn,mediump float glowGainIn,mediump float glowMid){mediump float glowGainOut;if(ycIn<=2.0/3.0*glowMid){glowGainOut=glowGainIn;}else if(ycIn>=2.0*glowMid){glowGainOut=0.0;}else{glowGainOut=glowGainIn*(glowMid/ycIn-1.0/2.0);}return glowGainOut;}const mediump float RRT_GLOW_GAIN=0.05;const mediump float RRT_GLOW_MID=0.08;const mediump float RRT_RED_SCALE=0.82;const mediump float RRT_RED_PIVOT=0.03;const mediump float RRT_RED_HUE=0.0;const mediump float RRT_RED_WIDTH=135.0;const mediump float RRT_SAT_FACTOR=0.96;mediump vec3 RRT(mediump vec3 aces){mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);mediump float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(aces);mediump float centeredHue=center_hue(hue,RRT_RED_HUE);mediump float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);aces=clamp(aces,0.0,HALF_MAX);mediump vec3 rgbPre=AP0_2_AP1_MAT*aces;rgbPre=clamp(rgbPre,0.0,HALF_MAX);rgbPre=mix(vec3(dot(rgbPre,AP1_RGB2Y)),rgbPre,RRT_SAT_FACTOR);mediump vec3 rgbPost;rgbPost.x=segmented_spline_c5_fwd(rgbPre.x);rgbPost.y=segmented_spline_c5_fwd(rgbPre.y);rgbPost.z=segmented_spline_c5_fwd(rgbPre.z);mediump vec3 outputVal=AP1_2_AP0_MAT*rgbPost;return outputVal;}",Tonescale:"#define GLSLIFY 1\n#ifndef TONE_SCALE\n#define TONE_SCALE\nconst mediump mat3 M=mat3(vec3(0.5,-1.0,0.5),vec3(-1.0,1.0,0.5),vec3(0.5,0.0,0.0));mediump float segmented_spline_c5_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[6]=float[6](-4.0000000000,-4.0000000000,-3.1573765773,-0.4852499958,1.8477324706,1.8477324706);const mediump float coefsHigh[6]=float[6](-0.7185482425,2.0810307172,3.6681241237,4.0000000000,4.0000000000,4.0000000000);\n#else\nconst mediump float coefsLow_0=-4.0000000000;const mediump float coefsLow_1=-4.0000000000;const mediump float coefsLow_2=-3.1573765773;const mediump float coefsLow_3=-0.4852499958;const mediump float coefsLow_4=1.8477324706;const mediump float coefsLow_5=1.8477324706;const mediump float coefsHigh_0=-0.7185482425;const mediump float coefsHigh_1=2.0810307172;const mediump float coefsHigh_2=3.6681241237;const mediump float coefsHigh_3=4.0000000000;const mediump float coefsHigh_4=4.0000000000;const mediump float coefsHigh_5=4.0000000000;\n#endif\nconst mediump vec2 minPoint=vec2(0.0000054931640625,0.0001);const mediump vec2 midPoint=vec2(0.18,0.48);const mediump vec2 maxPoint=vec2(47185.92,10000.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.0;const int N_KNOTS_LOW=4;const int N_KNOTS_HIGH=4;mediump float logx=log10(max(x,HALF_MIN));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else{cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else{cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}mediump float segmented_spline_c9_fwd(mediump float x){\n#ifdef GRAPHICS_API_WEBGL2\nconst mediump float coefsLow[10]=float[10](-1.6989700043,-1.6989700043,-1.4779000000,-1.2291000000,-0.8648000000,-0.4480000000,0.0051800000,0.4511080334,0.9113744414,0.9113744414);const mediump float coefsHigh[10]=float[10](0.5154386965,0.8470437783,1.1358000000,1.3802000000,1.5197000000,1.5985000000,1.6467000000,1.6746091357,1.6878733390,1.6878733390);\n#else\nconst mediump float coefsLow_0=-1.6989700043;const mediump float coefsLow_1=-1.6989700043;const mediump float coefsLow_2=-1.4779000000;const mediump float coefsLow_3=-1.2291000000;const mediump float coefsLow_4=-0.8648000000;const mediump float coefsLow_5=-0.4480000000;const mediump float coefsLow_6=0.0051800000;const mediump float coefsLow_7=0.4511080334;const mediump float coefsLow_8=0.9113744414;const mediump float coefsLow_9=0.9113744414;const mediump float coefsHigh_0=0.5154386965;const mediump float coefsHigh_1=0.8470437783;const mediump float coefsHigh_2=1.1358000000;const mediump float coefsHigh_3=1.3802000000;const mediump float coefsHigh_4=1.5197000000;const mediump float coefsHigh_5=1.5985000000;const mediump float coefsHigh_6=1.6467000000;const mediump float coefsHigh_7=1.6746091357;const mediump float coefsHigh_8=1.6878733390;const mediump float coefsHigh_9=1.6878733390;\n#endif\nconst mediump vec2 minPoint=vec2(0.0028799,0.02);const mediump vec2 midPoint=vec2(4.799999,4.8);const mediump vec2 maxPoint=vec2(1005.719,48.0);const mediump float slopeLow=0.0;const mediump float slopeHigh=0.04;const int N_KNOTS_LOW=8;const int N_KNOTS_HIGH=8;mediump float logx=log10(max(x,1e-4));mediump float logy;if(logx<=log10(minPoint.x)){logy=logx*slopeLow+(log10(minPoint.y)-slopeLow*log10(minPoint.x));}else if((logx>log10(minPoint.x))&&(logx<log10(midPoint.x))){mediump float knot_coord=float(N_KNOTS_LOW-1)*(logx-log10(minPoint.x))/(log10(midPoint.x)-log10(minPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsLow[j],coefsLow[j+1],coefsLow[j+2]);\n#else\nif(j<=0){cf=vec3(coefsLow_0,coefsLow_1,coefsLow_2);}else if(j==1){cf=vec3(coefsLow_1,coefsLow_2,coefsLow_3);}else if(j==2){cf=vec3(coefsLow_2,coefsLow_3,coefsLow_4);}else if(j==3){cf=vec3(coefsLow_3,coefsLow_4,coefsLow_5);}else if(j==4){cf=vec3(coefsLow_4,coefsLow_5,coefsLow_6);}else if(j==5){cf=vec3(coefsLow_5,coefsLow_6,coefsLow_7);}else if(j==6){cf=vec3(coefsLow_6,coefsLow_7,coefsLow_8);}else{cf=vec3(coefsLow_7,coefsLow_8,coefsLow_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else if((logx>=log10(midPoint.x))&&(logx<log10(maxPoint.x))){mediump float knot_coord=float(N_KNOTS_HIGH-1)*(logx-log10(midPoint.x))/(log10(maxPoint.x)-log10(midPoint.x));int j=int(knot_coord);mediump float t=knot_coord-float(j);mediump vec3 cf;\n#ifdef GRAPHICS_API_WEBGL2\ncf=vec3(coefsHigh[j],coefsHigh[j+1],coefsHigh[j+2]);\n#else\nif(j<=0){cf=vec3(coefsHigh_0,coefsHigh_1,coefsHigh_2);}else if(j==1){cf=vec3(coefsHigh_1,coefsHigh_2,coefsHigh_3);}else if(j==2){cf=vec3(coefsHigh_2,coefsHigh_3,coefsHigh_4);}else if(j==3){cf=vec3(coefsHigh_3,coefsHigh_4,coefsHigh_5);}else if(j==4){cf=vec3(coefsHigh_4,coefsHigh_5,coefsHigh_6);}else if(j==5){cf=vec3(coefsHigh_5,coefsHigh_6,coefsHigh_7);}else if(j==6){cf=vec3(coefsHigh_6,coefsHigh_7,coefsHigh_8);}else{cf=vec3(coefsHigh_7,coefsHigh_8,coefsHigh_9);}\n#endif\nmediump vec3 monomials=vec3(t*t,t,1.0);logy=dot(monomials,M*cf);}else{logy=logx*slopeHigh+(log10(maxPoint.y)-slopeHigh*log10(maxPoint.x));}return pow(10.0,logy);}\n#endif\n",ColorTransform:"#define GLSLIFY 1\n#ifndef COLOR_TRANSFORM\n#define COLOR_TRANSFORM\nconst mediump mat3 sRGB_2_AP0=mat3(0.4397010,0.0897923,0.0175440,0.3829780,0.8134230,0.1115440,0.1773350,0.0967616,0.8707040);const mediump mat3 AP1_2_AP0_MAT=mat3(vec3(0.6954522414,0.0447945634,-0.0055258826),vec3(0.1406786965,0.8596711185,0.0040252103),vec3(0.1638690622,0.0955343182,1.0015006723));const mediump mat3 AP0_2_AP1_MAT=mat3(vec3(1.4514393161,-0.0765537734,0.0083161484),vec3(-0.2365107469,1.1762296998,-0.0060324498),vec3(-0.2149285693,-0.0996759264,0.9977163014));const mediump mat3 AP1_2_XYZ_MAT=mat3(vec3(0.6624541811,0.2722287168,-0.0055746495),vec3(0.1340042065,0.6740817658,0.0040607335),vec3(0.1561876870,0.0536895174,1.0103391003));const mediump mat3 XYZ_2_AP1_MAT=mat3(vec3(1.6410233797,-0.6636628587,0.0117218943),vec3(-0.3248032942,1.6153315917,-0.0082844420),vec3(-0.2364246952,0.0167563477,0.9883948585));const mediump mat3 D60_2_D65_CAT=mat3(vec3(0.987224,-0.00759836,0.00307257),vec3(-0.00611327,1.00186,-0.00509595),vec3(0.0159533,0.00533002,1.08168));const mediump mat3 XYZ_2_REC709_MAT=mat3(vec3(3.2409699419,-0.9692436363,0.0556300797),vec3(-1.5373831776,1.8759675015,-0.2039769589),vec3(-0.498610760,0.0415550574,1.0569715142));const mediump vec3 AP1_RGB2Y=vec3(0.2722287168,0.6740817658,0.0536895174);mediump float rgb_2_saturation(mediump vec3 rgb){const mediump float TINY=1e-4;mediump float mi=min3(rgb);mediump float ma=max3(rgb);return(max(ma,TINY)-max(mi,TINY))/max(ma,1e-2);}mediump float rgb_2_yc(mediump vec3 rgb){const mediump float ycRadiusWeight=1.75;mediump float r=rgb.x;mediump float g=rgb.y;mediump float b=rgb.z;mediump float k=b*(b-g)+g*(g-r)+r*(r-b);k=max(k,0.0);float chroma=k==0.0 ? 0.0 : sqrt(k);return(b+g+r+ycRadiusWeight*chroma)/3.0;}mediump float rgb_2_hue(mediump vec3 rgb){mediump float hue;if(rgb.x==rgb.y&&rgb.y==rgb.z){hue=0.0;}else{hue=(180.0/PI)*atan(sqrt(3.0)*(rgb.y-rgb.z),2.0*rgb.x-rgb.y-rgb.z);}if(hue<0.0){hue=hue+360.0;}return hue;}mediump float center_hue(mediump float hue,mediump float centerH){mediump float hueCentered=hue-centerH;if(hueCentered<-180.0){hueCentered=hueCentered+360.0;}else if(hueCentered>180.0){hueCentered=hueCentered-360.0;}return hueCentered;}\n#endif\n",NeutralTonemapping:"#define GLSLIFY 1\nvec3 neutralCurve(vec3 x,float a,float b,float c,float d,float e,float f){return vec3(((x*(a*x+c*b)+d*e)/(x*(a*x+b)+d*f))-e/f);}\n#define TONEMAPPING_CLAMP_MAX 435.18712\nvec3 neutralTonemap(vec3 color){const float a=0.2;const float b=0.29;const float c=0.24;const float d=0.272;const float e=0.02;const float f=0.3;\n#ifndef GL_FRAGMENT_PRECISION_HIGH\ncolor=min(color,TONEMAPPING_CLAMP_MAX);\n#endif\nconst float whiteScale=1.31338;color=neutralCurve(color*whiteScale,a,b,c,d,e,f);color*=whiteScale;return color;}",ACESTonemapping:"#define GLSLIFY 1\n#include <ColorTransform>\n#include <RRT>\n#include <ODT>\nvec3 ACESTonemap(vec3 color){vec3 aces=sRGB_2_AP0*color;mediump float saturation=rgb_2_saturation(aces);mediump float ycIn=rgb_2_yc(aces);mediump float s=sigmoid_shaper((saturation-0.4)/0.2);float addedGlow=1.0+glow_fwd(ycIn,RRT_GLOW_GAIN*s,RRT_GLOW_MID);aces*=addedGlow;mediump float hue=rgb_2_hue(vec3(aces));mediump float centeredHue=center_hue(hue,RRT_RED_HUE);float hueWeight=smoothstep(0.0,1.0,1.0-abs(2.0*centeredHue/RRT_RED_WIDTH));hueWeight*=hueWeight;aces.r+=hueWeight*saturation*(RRT_RED_PIVOT-aces.r)*(1.0-RRT_RED_SCALE);vec3 acescg=max(AP0_2_AP1_MAT*aces,0.0);acescg=mix(vec3(dot(acescg,AP1_RGB2Y)),acescg,RRT_SAT_FACTOR);const float a=0.0245786;const float b=0.000090537;const float c=0.983729;const float d=0.4329510;const float e=0.238081;vec3 rcpAcesCG=1.0/(acescg+FLT_MIN);mediump vec3 rgbPost=(acescg+a-b*rcpAcesCG)/(acescg*c+d+e*rcpAcesCG);vec3 linearCV=darkSurround_to_dimSurround(rgbPost);linearCV=mix(vec3(dot(linearCV,AP1_RGB2Y)),linearCV,ODT_SAT_FACTOR);vec3 XYZ=AP1_2_XYZ_MAT*linearCV;XYZ=D60_2_D65_CAT*XYZ;linearCV=XYZ_2_REC709_MAT*XYZ;return linearCV;}"}),u$.create(_s.UBER_SHADER_NAME,hJ,"#define GLSLIFY 1\n#include <PostCommon>\n#include <Filtering>\n#include <NeutralTonemapping>\n#include <ACESTonemapping>\nvarying vec2 v_uv;uniform sampler2D renderer_BlitTexture;uniform vec4 renderer_texelSize;\n#ifdef ENABLE_EFFECT_BLOOM\nuniform sampler2D material_BloomTexture;uniform sampler2D material_BloomDirtTexture;uniform vec4 material_BloomTint;uniform vec4 material_BloomDirtTilingOffset;uniform vec4 material_BloomIntensityParams;\n#endif\nvoid main(){mediump vec4 color=sampleTexture(renderer_BlitTexture,v_uv);\n#ifdef ENABLE_EFFECT_BLOOM\n#ifdef BLOOM_HQ\nmediump vec4 bloom=sampleTexture2DBicubic(material_BloomTexture,v_uv,renderer_texelSize);\n#else\nmediump vec4 bloom=sampleTexture(material_BloomTexture,v_uv);\n#endif\nbloom*=material_BloomIntensityParams.x;color+=bloom*material_BloomTint;\n#ifdef BLOOM_DIRT\nmediump vec4 dirt=sampleTexture(material_BloomDirtTexture,v_uv*material_BloomDirtTilingOffset.xy+material_BloomDirtTilingOffset.zw);dirt*=material_BloomIntensityParams.y;color+=dirt*bloom;\n#endif\n#endif\n#ifdef ENABLE_EFFECT_TONEMAPPING\n#if TONEMAPPING_MODE == 0\ncolor.rgb=neutralTonemap(color.rgb);\n#elif TONEMAPPING_MODE == 1\ncolor.rgb=ACESTonemap(color.rgb);\n#endif\ncolor.rgb=clamp(color.rgb,vec3(0),vec3(1));\n#endif\ngl_FragColor=color;\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}");var _l=function(t){function r(n,a){(i=t.call(this,n)||this).physics=new hF(un(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new cZ(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i._lightManager=new _a,i._componentsManager=new h6,i._maskManager=new dp,i._isActiveInEngine=!1,i._globalShaderMacro=new uR,i._rootEntities=[],i._postProcessManager=new _s(un(i)),i._background=new h9(i._engine),i._shaderData=new u2(cr.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new c7(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new c6,i._isActive=!0,i._enableTransparentShadow=!1,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new h7(n),n.sceneManager._allCreatedScenes.push(un(i)),o.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),o.setColor(r._fogColorProperty,i._fogColor),o.setVector4(r._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}us(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new hs(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?r=e:(r=void 0,t=e);var r,n=t._isRoot;n||(t._isRoot=!0,t._removeFromParent());var a=t._scene;a!==this?(a&&n&&a._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var i=ca.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=ca.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=ca.Scene),i&&t._processInActive(i),a!==this&&hs._traverseSetOwnerScene(t,this);var o=ca.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=ca.Hierarchy)),t._isActiveInScene&&a===this||(o|=ca.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=ca.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=ca.Hierarchy),e._isActiveInScene&&(t|=ca.Scene),t&&e._processInActive(t),hs._traverseSetOwnerScene(e,null)}},n.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},n.findEntityByName=function(e){for(var t=this._rootEntities,r=0,n=t.length;r<n;r++){var a=t[r].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),r=0,n=this.rootEntitiesCount;r<n;r++){var a=this.getRootEntity(r);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=hs._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,r=t.length-1;r>=0;r--){var n=t[r];n._isActive&&(e?n._processActive(ca.Hierarchy):n._processInActive(ca.Hierarchy))}},n._updateShaderData=function(){var t=this.shaderData,r=this._engine,n=this._lightManager;r.time._updateSceneShaderData(t),n._updateShaderData(this.shaderData);var a=this._lightManager._sunlight=this._getSunlight();a?(n._updateSunlightIndex(a),t.setColor(_a._sunlightColorProperty,a._lightColor),t.setVector3(_a._sunlightDirectionProperty,a.direction)):t.setVector3(_a._sunlightDirectionProperty,cZ._zero),this.castShadows&&a&&a.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",a.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.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts(),this._maskManager.destroy();var r=e._allCreatedScenes;r.splice(r.indexOf(this),1)},n._addToRootEntityList=function(e,t){var r=this._rootEntities,n=r.length;if(void 0===e)t._siblingIndex=n,r.push(t);else{if(e<0||e>n)throw"The index "+e+" is out of child list bounds "+n;t._siblingIndex=e,r.splice(e,0,t);for(var a=e+1,i=n+1;a<i;a++)r[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var r=t-e,n=this._fogParams;n.x=-1/r,n.y=t/r},n._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},n._getSunlight=function(){return this._sun?this._sun.enabled?this._sun:null:this._lightManager._getMaxBrightestSunlight()},ui(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){uI.warn("The scene must have one ambient light");return}var t=this._ambientLight;t!==e&&(t&&t._removeFromScene(this),e._addToScene(this),this._ambientLight=e)}},{key:"fogMode",get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this.shaderData.enableMacro("SCENE_FOG_MODE",e.toString()),this._fogMode=e)}},{key:"fogColor",get:function(){return this._fogColor},set:function(e){this._fogColor!==e&&this._fogColor.copyFrom(e)}},{key:"fogStart",get:function(){return this._fogStart},set:function(e){this._fogStart!==e&&(this._computeLinearFogParams(e,this._fogEnd),this._fogStart=e)}},{key:"fogEnd",get:function(){return this._fogEnd},set:function(e){this._fogEnd!==e&&(this._computeLinearFogParams(this._fogStart,e),this._fogEnd=e)}},{key:"fogDensity",get:function(){return this._fogDensity},set:function(e){this._fogDensity!==e&&(this._computeExponentialFogParams(e),this._fogDensity=e)}},{key:"rootEntitiesCount",get:function(){return this._rootEntities.length}},{key:"rootEntities",get:function(){return this._rootEntities}},{key:"sun",get:function(){return this._sun},set:function(e){this._sun=e}},{key:"enableTransparentShadow",get:function(){return this._enableTransparentShadow},set:function(e){e!==this._enableTransparentShadow&&(this._enableTransparentShadow=e,e?this.shaderData.enableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"):this.shaderData.disableMacro("SCENE_ENABLE_TRANSPARENT_SHADOW"))}}]),r}(up);_l._fogColorProperty=uO.getByName("scene_FogColor"),_l._fogParamsProperty=uO.getByName("scene_FogParams");var _c=(us(az=function(){var e;return e=u4.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},u4),(aU=az.prototype).onAwake=function(){},aU.onEnable=function(){},aU.onStart=function(){},aU.onUpdate=function(e){},aU.onLateUpdate=function(e){},aU.onBeginRender=function(e){},aU.onEndRender=function(e){},aU.onPhysicsUpdate=function(){},aU.onTriggerEnter=function(e){},aU.onTriggerExit=function(e){},aU.onTriggerStay=function(e){},aU.onCollisionEnter=function(e){},aU.onCollisionExit=function(e){},aU.onCollisionStay=function(e){},aU.onPointerDown=function(e){},aU.onPointerUp=function(e){},aU.onPointerClick=function(e){},aU.onPointerEnter=function(e){},aU.onPointerExit=function(e){},aU.onPointerDrag=function(e){},aU.onDisable=function(){},aU.onDestroy=function(){},aU._onAwake=function(){this.onAwake()},aU._onEnable=function(){this.onEnable()},aU._onDisable=function(){this.onDisable()},aU._onEnableInScene=function(){var e=this.scene._componentsManager,t=az.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)},aU._onDisableInScene=function(){var e=this.scene._componentsManager,t=az.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)},aU._onDestroy=function(){u4.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},az);ul([uu],_c.prototype,"_started",void 0),ul([uu],_c.prototype,"_onStartIndex",void 0),ul([uu],_c.prototype,"_onUpdateIndex",void 0),ul([uu],_c.prototype,"_onLateUpdateIndex",void 0),ul([uu],_c.prototype,"_onPhysicsUpdateIndex",void 0),ul([uu],_c.prototype,"_onPreRenderIndex",void 0),ul([uu],_c.prototype,"_onPostRenderIndex",void 0),ul([uu],_c.prototype,"_entityScriptsIndex",void 0);var _u={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},_d=1/0;function _h(e,t){return void 0===t&&(t={}),new hx(function(r,n,a,i){var o,s,l,c,u=null!=(o=t.retryCount)?o:1,d=null!=(s=t.retryInterval)?s:500;t.timeout=null!=(l=t.timeout)?l:_d,t.type=null!=(c=t.type)?c:_u[e.substring(e.lastIndexOf(".")+1)],new __(function(){var r;return(r=t,new hx(function(t,n,a,i){var o,s=new XMLHttpRequest,l="image"===r.type;s.timeout=r.timeout,r.method=null!=(o=r.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){n(Error("request failed from: "+e));return}var r,i=null!=(r=s.response)?r:s.responseText;if(l){var o=new Image;o.onload=function(){requestAnimationFrame(function(){a(1,1),t(o),o.onload=null,o.onerror=null,o.onabort=null,URL.revokeObjectURL(o.src)})},o.onerror=o.onabort=function(){n(Error("request "+o.src+" fail")),URL.revokeObjectURL(o.src)},o.crossOrigin="anonymous",o.src=URL.createObjectURL(i)}else a(1,1),t(i)},s.onerror=function(){n(Error("request failed from: "+e))},s.ontimeout=function(){n(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(r.method,e,!0),s.withCredentials="include"===r.credentials,s.responseType=l?"blob":r.type;var c=r.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(r.body)})).onProgress(a,i)},u,d).start().onError(n).onComplete(r)})}var __=((aH=(aG=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},aH.onComplete=function(e){return this._onComplete=e,this},aH.onError=function(e){return this._onError=e,this},aH.cancel=function(){window.clearTimeout(this._timeoutId)},aH.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)})},aG),_f=((aW=function(e){this.useCache=e,this.request=_h}).registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},aW.getClass=function(e){return this._engineObjects[e]},aW.getClassName=function(e){return this._classNameMap.get(e)},aW);_f._engineObjects={},_f._classNameMap=new Map;var _p=((aK=(aj=function(){}).prototype).initialize=function(e){var t=e.component,r=e.property.split(".");if(e.getProperty){var n=e.getProperty.split(".");this._initializeMounted(t,n,1),this._initializeMounted(t,r,2)}else this._initializeMounted(t,r,3)},aK.getTargetValue=function(){switch(this._getType){case 2:return this._getMounted[this._getArrayIndex];case 1:return this._getMounted[this._getValueName].apply(this._getMounted,this._getArgs);case 0:return this._getMounted[this._getValueName]}},aK.setTargetValue=function(e){switch(this._setType){case 2:this._setMounted[this._setArrayIndex]=e;break;case 1:var t=this._setArgs;t[this._replaceValueIndex]=e,this._setMounted[this._setValueName].apply(this._setMounted,t);break;case 0:this._setMounted[this._setValueName]=e}},aK._initializeMounted=function(e,t,r){for(var n,a,i,o,s=t.length-1,l=0;l<s;l++){var c=t[l];if(c.indexOf("[")>-1){var u=c.indexOf("[");e=(e=e[c.slice(0,u)])[parseInt(c.slice(u+1,-1))]}else if(c.endsWith(")")){var d=c.slice(0,c.indexOf("(")),h=c.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e});e=e[d].apply(e,h)}else e=e[c]}var _=t[s];if(_.indexOf("[")>-1){var f=_.indexOf("[");n=2,e=e[_.slice(0,f)],a=parseInt(_.slice(f+1,-1))}else if(_.endsWith(")")){if(i=_.slice(0,_.indexOf("(")),o=_.match(/\w+\(([^)]*)\)/)[1].split(",").map(function(e){return e.trim().replace(/['"]+/g,"")}).filter(function(e){return""!==e}),n=1,2&r){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else n=0;2&r&&(this._setMounted=e,this._setType=n,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&r&&(this._getMounted=e,this._getType=n,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},aj);(aX=cR||(cR={}))[aX.Property=0]="Property",aX[aX.Method=1]="Method",aX[aX.Array=2]="Array",(aY=cE||(cE={}))[aY.Get=1]="Get",aY[aY.Set=2]="Set",aY[aY.Both=3]="Both";var _m=function(){function e(t,r,n,a,i,o){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.property=a,this.getProperty=i,this.component=n,this.cureType=o;var s=e.getAssemblerType(r,a);this._assembler=new s,this._assembler.initialize(this),o._isCopyMode&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateValue=function(e,t,r){return r?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,r,n,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,n,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(r,this.baseEvaluateData):e._evaluate(r,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(n,this.crossEvaluateData):t._evaluate(n,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,r,n){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=n?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?n?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):n?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,r)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.getEvaluateValue=function(e){return this.cureType._isCopyMode?(this.cureType._setValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isCopyMode?this.cureType._setValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,r){var n=this.cureType;if(r){var a=this._assembler;if(n._isCopyMode)n._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=n._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)n._isCopyMode?n._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(n._isCopyMode){var s=this.referenceTargetValue;n._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=n._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,r){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,r,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,r),this.baseEvaluateData.value)},e.registerAssembler=function(t,r,n){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[r]=n},e.getAssemblerType=function(t,r){var n=e._assemblerMap.get(t),a=n?n[r]:void 0;return null!=a?a:_p},e}();_m._components=[],_m._assemblerMap=new Map;var _g=((aQ=(aq=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aQ.getTargetValue=function(){return this._transform.position},aQ.setTargetValue=function(e){this._transform.position=e},aq);_m.registerAssembler(u6,"position",_g);var _v=((aJ=(aZ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aJ.getTargetValue=function(){return this._transform.rotationQuaternion},aJ.setTargetValue=function(e){this._transform.rotationQuaternion=e},aZ);_m.registerAssembler(u6,"rotationQuaternion",_v);var _y=((a0=(a$=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},a0.getTargetValue=function(){return this._transform.scale},a0.setTargetValue=function(e){this._transform.scale=e},a$);_m.registerAssembler(u6,"scale",_y);var _x=((a2=(a1=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.component},a2.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},a2.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},a1);_m.registerAssembler(hc,"blendShapeWeights",_x);var _b=((a4=(a3=function(){this.crossCurveMark=0,this.isActive=!0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,r=e.defaultValue;t._isCopyMode?t._setValue(r,this.finalValue):this.finalValue=r},a4.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},a3),_T=((a5=(a8=function(){this.typeIndex=0,this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new _m(e,this.type,t,this.property,this.getProperty,r);return r._initializeOwner(n),n.saveDefaultValue(),n},a5._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new _b;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},a5._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},a8),_C=function(){},_S=(us(a9=function(e){var t;return(t=up.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new uT,t._length=0,t._events=[],t},up),(a6=a9.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,a=new _C;a.functionName=e,a.time=t,a.parameter=r,n=a}else n=e;var i=this._events,o=i.length,s=n.time;if(s>=(o?i[o-1].time:0))i.push(n);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,n)}this._updateFlagManager.dispatch()},a6.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},a6.addCurveBinding=function(e,t,r,n,a,i){var o=new _T;o.relativePath=e,o.type=t,"number"==typeof r?(o.typeIndex=r,o.property=n,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=r,"string"==typeof n?(o.getProperty=n,o.curve=a):o.curve=n),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},a6.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},a6._sampleAnimation=function(e,t){for(var r=this._curveBindings,n=r.length-1;n>=0;n--){var a=r[n],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,_m._components)[a.typeIndex]:i.getComponent(a.type);if(!o)continue;var s=a._getTempCurveOwner(i,o);if(s&&a.curve.keys.length){var l=s.evaluateValue(a.curve,t,!1);s.applyValue(l,1,!1)}}}},ui(a9,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),a9);e.InterpolationType=void 0,(a7=e.InterpolationType||(e.InterpolationType={}))[a7.Linear=0]="Linear",a7[a7.CubicSpine=1]="CubicSpine",a7[a7.Step=2]="Step",a7[a7.Hermite=3]="Hermite";var _A=((it=(ie=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)}},it.evaluate=function(e){return this._evaluate(e,this._evaluateData)},it.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,r=0,n=t.length-1;n>=0;n--){var a=t[n];a.time>this._length&&(r=a.time)}this._length=r},it._evaluate=function(t,r){var n,a=this.keys.length;if(!a){console.warn("This curve don't have any keyframes: ",this);return}var i=this.keys,o=this.interpolation,s=r.curKeyframeIndex;-1!==s&&(s>=a||t<i[s].time)&&(s=-1);for(var l=s+1;l<a&&!(t<i[l].time);)s++,l++;if(r.curKeyframeIndex=s,-1===s)n=this._type._setValue(i[0].value,r.value);else if(l===a)n=this._type._setValue(i[s].value,r.value);else{var c=i[s],u=i[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},it._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},ui(ie,[{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}}]),ie);e.AnimationArrayCurve=(us(ir=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=[],e},_A),ir._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},ir._initializeLayerOwner=function(e){e.finalValue=[]},ir._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},ir._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},ir._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},ir._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},ir._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},ir._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=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(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},ir._isCopyMode=!0,ir._supportInterpolationMode=!0,ir),e.AnimationArrayCurve=ul([u7()],e.AnimationArrayCurve),e.AnimationBoolCurve=(us(ia=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=!1,e},_A),ia._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},ia._initializeLayerOwner=function(e){e.finalValue=!1},ia._lerpValue=function(e,t){return e},ia._subtractValue=function(e,t,r){return e},ia._getZeroValue=function(){return!1},ia._additiveValue=function(e,t,r){return e},ia._setValue=function(e){return e},ia._hermiteInterpolationValue=function(e){return e.value},ia._isCopyMode=!1,ia._supportInterpolationMode=!1,ia),e.AnimationBoolCurve=ul([u7()],e.AnimationBoolCurve),e.AnimationColorCurve=(us(ii=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new c7,e},_A),ii._initializeOwner=function(e){e.defaultValue=new c7,e.fixedPoseValue=new c7,e.baseEvaluateData.value=new c7,e.crossEvaluateData.value=new c7},ii._initializeLayerOwner=function(e){e.finalValue=new c7},ii._lerpValue=function(e,t,r,n){return c7.lerp(e,t,r,n),n},ii._subtractValue=function(e,t,r){return c7.subtract(e,t,r),r},ii._getZeroValue=function(e){return e.set(0,0,0,0),e},ii._additiveValue=function(e,t,r){return c7.scale(e,t,e),c7.add(r,e,r),r},ii._setValue=function(e,t){return t.copyFrom(e),t},ii._hermiteInterpolationValue=function(e,t,r,n,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=r*r,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)?a.r=d*i.r+h*p*n+_*m*n+f*s.r:a.r=i.r,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.g=d*i.g+h*p*n+_*m*n+f*s.g:a.g=i.g,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.b=d*i.b+h*p*n+_*m*n+f*s.b:a.b=i.b,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.a=d*i.a+h*p*n+_*m*n+f*s.a:a.a=i.a,a},ii._isCopyMode=!0,ii._supportInterpolationMode=!0,ii),e.AnimationColorCurve=ul([u7()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(us(io=function(){return _A.apply(this,arguments)},_A),io.prototype.addKey=function(e){_A.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)}},io._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)},io._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},io._lerpValue=function(e,t,r,n){for(var a=0,i=n.length;a<i;++a){var o=e[a];n[a]=o+(t[a]-o)*r}return n},io._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},io._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},io._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},io._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},io._hermiteInterpolationValue=function(e,t,r,n,a){for(var i=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(i[p])&&Number.isFinite(o[p])?a[p]=d*s[p]+h*i[p]*n+_*o[p]*n+f*l[p]:a[p]=e.value[p];return a},io._isCopyMode=!0,io._supportInterpolationMode=!0,io),e.AnimationFloatArrayCurve=ul([u7()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(us(is=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=0,e},_A),is._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},is._initializeLayerOwner=function(e){e.finalValue=0},is._lerpValue=function(e,t,r){return e+(t-e)*r},is._additiveValue=function(e,t,r){return r+e*t},is._subtractValue=function(e,t){return e-t},is._getZeroValue=function(){return 0},is._setValue=function(e){return e},is._hermiteInterpolationValue=function(e,t,r,n){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=r*r,s=o*r;return(2*s-3*o+1)*e.value+(s-2*o+r)*a*n+(s-o)*i*n+(-2*s+3*o)*t.value},is._isCopyMode=!1,is._supportInterpolationMode=!0,is),e.AnimationFloatCurve=ul([u7()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(us(il=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new c4,e},_A),il._initializeOwner=function(e){e.defaultValue=new c4,e.fixedPoseValue=new c4,e.baseEvaluateData.value=new c4,e.crossEvaluateData.value=new c4},il._initializeLayerOwner=function(e){e.finalValue=new c4},il._lerpValue=function(e,t,r,n){return c4.slerp(e,t,r,n),n},il._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},il._subtractValue=function(t,r,n){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return c4.conjugate(r,a),c4.multiply(a,t,n),n},il._getZeroValue=function(e){return e.set(0,0,0,1),e},il._setValue=function(e,t){return t.copyFrom(e),t},il._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},il._supportInterpolationMode=!0,il._isCopyMode=!0,il._tempConjugateQuat=new c4,il),e.AnimationQuaternionCurve=ul([u7()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(us(ic=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new c9,e},_A),ic._initializeOwner=function(e){e.defaultValue=new c9,e.fixedPoseValue=new c9,e.baseEvaluateData.value=new c9,e.crossEvaluateData.value=new c9},ic._initializeLayerOwner=function(e){e.finalValue=new c9},ic._lerpValue=function(e,t,r,n){return c9.lerp(e,t,r,n),n},ic._additiveValue=function(e,t,r){return c9.scale(e,t,e),c9.add(r,e,r),r},ic._subtractValue=function(e,t,r){return c9.subtract(e,t,r),r},ic._getZeroValue=function(e){return e.set(0,0),e},ic._setValue=function(e,t){return t.copyFrom(e),t},ic._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,a},ic._isCopyMode=!0,ic._supportInterpolationMode=!0,ic),e.AnimationVector2Curve=ul([u7()],e.AnimationVector2Curve),e.AnimationVector3Curve=(us(iu=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new cZ,e},_A),iu._initializeOwner=function(e){e.defaultValue=new cZ,e.fixedPoseValue=new cZ,e.baseEvaluateData.value=new cZ,e.crossEvaluateData.value=new cZ},iu._initializeLayerOwner=function(e){e.finalValue=new cZ},iu._lerpValue=function(e,t,r,n){return cZ.lerp(e,t,r,n),n},iu._relativeBaseValue=function(e,t){return cZ.subtract(t,e,t),t},iu._additiveValue=function(e,t,r){return cZ.scale(e,t,e),cZ.add(r,e,r),r},iu._subtractValue=function(e,t,r){return cZ.subtract(e,t,r),r},iu._getZeroValue=function(e){return e.set(0,0,0),e},iu._setValue=function(e,t){return t.copyFrom(e),t},iu._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,a},iu._isCopyMode=!0,iu._supportInterpolationMode=!0,iu),e.AnimationVector3Curve=ul([u7()],e.AnimationVector3Curve),e.AnimationVector4Curve=(us(id=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new c6,e},_A),id._initializeOwner=function(e){e.defaultValue=new c6,e.fixedPoseValue=new c6,e.baseEvaluateData.value=new c6,e.crossEvaluateData.value=new c6},id._initializeLayerOwner=function(e){e.finalValue=new c6},id._lerpValue=function(e,t,r,n){return c6.lerp(e,t,r,n),n},id._additiveValue=function(e,t,r){return c6.scale(e,t,e),c6.add(r,e,r),r},id._subtractValue=function(e,t,r){return c6.subtract(e,t,r),r},id._getZeroValue=function(e){return e.set(0,0,0,0),e},id._setValue=function(e,t){return t.copyFrom(e),t},id._hermiteInterpolationValue=function(e,t,r,n,a){var i=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)?a.x=d*i.x+h*p*n+_*m*n+f*s.x:a.x=i.x,p=o.y,m=l.y,Number.isFinite(p)&&Number.isFinite(m)?a.y=d*i.y+h*p*n+_*m*n+f*s.y:a.y=i.y,p=o.z,m=l.z,Number.isFinite(p)&&Number.isFinite(m)?a.z=d*i.z+h*p*n+_*m*n+f*s.z:a.z=i.z,p=o.w,m=l.w,Number.isFinite(p)&&Number.isFinite(m)?a.w=d*i.w+h*p*n+_*m*n+f*s.w:a.w=i.w,a},id._isCopyMode=!0,id._supportInterpolationMode=!0,id),e.AnimationVector4Curve=ul([u7()],e.AnimationVector4Curve),e.AnimationRefCurve=(us(ih=function(){return _A.call(this)},_A),ih._initializeOwner=function(e){},ih._initializeLayerOwner=function(e){},ih._setValue=function(e){return e},ih._isCopyMode=!1,ih._supportInterpolationMode=!1,ih),e.AnimationRefCurve=ul([u7()],e.AnimationRefCurve),e.AnimationRectCurve=(us(i_=function(){var e;return(e=_A.call(this)||this)._evaluateData.value=new ue,e},_A),i_._initializeOwner=function(e){e.defaultValue=new ue,e.fixedPoseValue=new ue,e.baseEvaluateData.value=new ue,e.crossEvaluateData.value=new ue},i_._initializeLayerOwner=function(e){e.finalValue=new ue},i_._setValue=function(e,t){return t.copyFrom(e),t},i_._isCopyMode=!0,i_._supportInterpolationMode=!1,i_),e.AnimationRectCurve=ul([u7()],e.AnimationRectCurve),e.AnimationStringCurve=(us(ip=function(){var e;return(e=_A.call(this)||this)._evaluateData.value="",e},_A),ip._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},ip._initializeLayerOwner=function(e){e.finalValue=""},ip._lerpValue=function(e,t){return e},ip._subtractValue=function(e,t,r){return e},ip._getZeroValue=function(){return""},ip._additiveValue=function(e,t,r){return e},ip._setValue=function(e){return e},ip._hermiteInterpolationValue=function(e){return e.value},ip._isCopyMode=!1,ip._supportInterpolationMode=!1,ip),e.AnimationStringCurve=ul([u7()],e.AnimationStringCurve),e.AnimatorConditionMode=void 0,(im=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[im.If=0]="If",im[im.IfNot=1]="IfNot",im[im.Greater=2]="Greater",im[im.Less=3]="Less",im[im.Equals=4]="Equals",im[im.NotEquals=5]="NotEquals",e.AnimatorCullingMode=void 0,(ig=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[ig.None=0]="None",ig[ig.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iv=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iv.Override=0]="Override",iv[iv.Additive=1]="Additive",(iy=cw||(cw={}))[iy.UnStarted=0]="UnStarted",iy[iy.Playing=1]="Playing",iy[iy.Finished=2]="Finished",(ix=cP||(cP={}))[ix.Standby=0]="Standby",ix[ix.Playing=1]="Playing",ix[ix.CrossFading=2]="CrossFading",ix[ix.FixedCrossFading=3]="FixedCrossFading",ix[ix.Finished=4]="Finished";var _M=((ib=function(){this.handlers=[]}).prototype.dispose=function(){},ib),_R=function(){},_E=((iC=(iT=function(){this.duration=0,this.offset=0,this.exitTime=1,this.mute=!1,this._isExit=!1,this._conditions=[],this._solo=!1}).prototype).addCondition=function(e,t,r){if("object"==typeof e)return this._conditions.push(e),e;var n=new _R;return n.mode=e,n.parameterName=t,n.threshold=r,this._conditions.push(n),n},iC.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},ui(iT,[{key:"isExit",get:function(){return this._isExit}},{key:"solo",get:function(){return this._solo},set:function(e){var t;this._solo!==e&&(this._solo=e,null==(t=this._srcState)||t._updateSoloTransition(!!e||void 0))}},{key:"conditions",get:function(){return this._conditions}}]),iT);e.WrapMode=void 0,(iS=e.WrapMode||(e.WrapMode={}))[iS.Once=0]="Once",iS[iS.Loop=1]="Loop";var _w=((iM=(iA=function(){this.isForwards=!0,this._changedOrientation=!1}).prototype).reset=function(e,t,r){this.state=e,this.frameTime=r,this.stateData=t,this.playState=cw.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0,this.isForwards=!0},iM.updateOrientation=function(e){if(0!==e){var t=this.isForwards;this.isForwards=e>0,this.isForwards!==t&&(this._changedOrientation=!0,this.isForwards||this._correctTime())}},iM.update=function(t){this.frameTime+=t;var r=this.state,n=this.frameTime,a=r._getDuration();this.playState=cw.Playing,r.wrapMode===e.WrapMode.Loop?n=a?n%a:0:Math.abs(n)>=a&&(n=n<0?-a:a,this.playState=cw.Finished),n<0&&(n+=a),this.clipTime=n+r.clipStartTime*r.clip.length,this._changedOrientation&&(this.isForwards||this._correctTime(),this._changedOrientation=!1)},iM._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},iA),_P=((iR=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new _w,this.destPlayData=new _w,this.layerState=cP.Standby,this.crossCurveMark=0,this.manuallyTransition=new _E,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iR),_F=function(){this.curveLayerOwner=[],this.eventHandlers=[]},_L=(us(iE=function(t){var r;return(r=u4.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 h2(_M),r._parametersValueMap=Object.create(null),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},u4),(iw=iE.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();var n,a=this._getAnimatorStateInfo(e,t),i=a.state;i&&this._preparePlay(i,a.layerIndex,r)&&(this._playFrameCount=this.engine.time.frameCount)},iw.crossFade=function(e,t,r,n){void 0===r&&(r=-1),void 0===n&&(n=0),(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset();var a,i=this._getAnimatorStateInfo(e,r),o=i.state,s=i.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=n,l.destinationState=o,this._prepareCrossFadeByTransition(l,s)&&(this._playFrameCount=this.engine.time.frameCount)},iw.update=function(t){if(this._playFrameCount===this.engine.time.frameCount&&(t=0),this.cullingMode===e.AnimatorCullingMode.Complete){n=!1;for(var r,n,a=this._controlledRenderers,i=0,o=a.length;i<o;i++)if(!a[i].isCulled){n=!0;break}}else n=!0;var s=this._animatorController;if(s){(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset(),this._updateMark++;for(var l=s.layers,c=0,u=l.length;c<u;c++){var d=this._getAnimatorLayerData(c);this._updateState(c,d,l[c],t,n)}}},iw.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},iw.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iw.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},iw.getParameter=function(e){var t,r;return null!=(r=null==(t=this._animatorController)?void 0:t._parametersMap[e])?r:null},iw.getParameterValue=function(e){var t,r,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];if(n)return null!=(r=this._parametersValueMap[e])?r:n.defaultValue},iw.setParameterValue=function(e,t){var r;(null==(r=this._animatorController)?void 0:r._parametersMap[e])&&(this._parametersValueMap[e]=t)},iw._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iw._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},iw._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},iw._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=Object.create(null),this._parametersValueMap=Object.create(null),this._animationEventHandlerPool.clear(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},iw._getAnimatorStateInfo=function(e,t){var r=this._animatorController,n=this._tempAnimatorStateInfo,a=null;if(r){var i=r.layers;if(-1===t){for(var o=0,s=i.length;o<s;o++)if(a=i[o].stateMachine.findStateByName(e)){t=o;break}}else a=i[t].stateMachine.findStateByName(e)}return n.layerIndex=t,n.state=a,n},iw._getAnimatorStateData=function(e,t,r,n){var a=r.animatorStateDataMap,i=a[e];return i||(i=new _F,a[e]=i,this._saveAnimatorStateData(t,i,r,n),this._saveAnimatorEventHandlers(t,i)),i},iw._saveAnimatorStateData=function(e,t,r,n){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[n].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=r.curveOwnerPool,u=l.length-1;u>=0;u--){var d=l[u],h=d.relativePath,_=""===d.relativePath?a:a.findByPath(d.relativePath);if(_){var f,p,m=d.typeIndex>0?_.getComponents(d.type,_m._components)[d.typeIndex]:_.getComponent(d.type);if(!m)continue;var g=d.property,v=m.instanceId,y=i[v]||(i[v]=Object.create(null)),x=y[g]||(y[g]=d._createCurveOwner(_,m)),b=c[v]||(c[v]=Object.create(null)),T=b[g]||(b[g]=d._createCurveLayerOwner(x));o&&o.pathMasks.length&&(T.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[u]=T}else s[u]=null,uI.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},iw._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){r._entity.getComponents(_c,a);var t=a.length,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.get(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f=a[_],p=f[d].bind(f);p&&h.push(p)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},iw._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},iw._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},iw._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},iw._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},iw._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)},iw._prepareSrcCrossData=function(e,t){for(var r=e.srcPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,n,-1))}},iw._prepareDestCrossData=function(e,t){for(var r=e.destPlayData.stateData.curveLayerOwner,n=r.length-1;n>=0;n--){var a=r[n];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=n;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,n)}}}},iw._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new _P),t},iw._updateState=function(t,r,n,a,i){var o=n.weight,s=n.blendingMode===e.AnimatorLayerBlendingMode.Additive;switch(0===t&&(o=1),r.layerState){case cP.Standby:this._checkAnyAndEntryState(t,r,n,a,i);break;case cP.Playing:this._updatePlayingState(t,r,n,o,s,a,i);break;case cP.Finished:this._updateFinishedState(t,r,n,o,s,a,i);break;case cP.CrossFading:this._updateCrossFadeState(t,r,n,o,s,a,i);break;case cP.FixedCrossFading:this._updateCrossFadeFromPoseState(t,r,n,o,s,a,i)}},iw._updatePlayingState=function(e,t,r,n,a,i,o){var s,l=t.srcPlayData,c=l.state,u=c.speed*this.speed,d=u*i;l.updateOrientation(d);var h=l.clipTime,_=l.playState;l.update(d);var f=l.clipTime,p=l.isForwards,m=this._applyTransitionsByCondition(e,t,r,c,r.stateMachine.anyStateTransitions,o)||this._applyStateTransitions(e,t,r,p,l,c.transitions,h,f,d,o);if(m){var g=c.clip.length,v=c.clipEndTime*g,y=m.exitTime*c._getDuration();if(p)s=y<h?y+v-h:y-h;else{var x=c.clipStartTime*g;s=-(s=h<y?v-y+h-x:h-y)}l.update(s-d)}else s=d,l.playState===cw.Finished&&(t.layerState=cP.Finished);if(this._evaluatePlayingState(l,n,a,o),this._fireAnimationEventsAndCallScripts(e,l,c,h,_,s),m){var b=i-s/u;b>0&&this._updateState(e,t,r,b,o)}},iw._evaluatePlayingState=function(e,t,r,n){var a=e.state.clip._curveBindings,i=e.playState===cw.Finished;if(n||i)for(var o=e.stateData.curveLayerOwner,s=a.length-1;s>=0;s--){var l=o[s],c=null==l?void 0:l.curveOwner;if(c&&l.isActive){var u=a[s].curve;if(u.keys.length){this._checkRevertOwner(c,r);var d=c.evaluateValue(u,e.clipTime,r);n&&c.applyValue(d,t,r),i&&l.saveFinalValue()}}}},iw._updateCrossFadeState=function(e,t,r,n,a,i,o){var s,l=t.srcPlayData,c=t.destPlayData,u=this.speed,d=l.state,h=c.state,_=h._getDuration(),f=_*t.crossFadeTransition.duration,p=d.speed*u,m=h.speed*u,g=m*i;l&&l.updateOrientation(p*i),c&&c.updateOrientation(g);var v=l.clipTime,y=l.playState,x=c.clipTime,b=c.playState;if(c.isForwards)s=x+g>f?f-x:g;else{var T=_-x;s=T-g>f?T-f:g}var C=0===m?0:s/m,S=C*p;l.update(S),c.update(s);var A=Math.abs(c.frameTime)/f;(A>=1-cQ.zeroTolerance||0===f)&&(A=1);var M=1===A;if(M?(this._preparePlayOwner(t,h),this._evaluatePlayingState(c,n,a,o)):this._evaluateCrossFadeState(t,l,c,n,A,a,o),this._fireAnimationEventsAndCallScripts(e,l,d,v,y,S),this._fireAnimationEventsAndCallScripts(e,c,h,x,b,s),M){this._updateCrossFadeData(t);var R=i-C;R>0&&this._updateState(e,t,r,R,o)}},iw._evaluateCrossFadeState=function(e,t,r,n,a,i,o){var s=e.crossLayerOwnerCollection,l=t.state.clip._curveBindings,c=r.state.clip._curveBindings,u=r.playState===cw.Finished;if(o||u)for(var d=s.length-1;d>=0;d--){var h=s[d],_=null==h?void 0:h.curveOwner;if(_){var f=h.crossSrcCurveIndex,p=h.crossDestCurveIndex;this._checkRevertOwner(_,i);var m=_.evaluateCrossFadeValue(f>=0?l[f].curve:null,p>=0?c[p].curve:null,t.clipTime,r.clipTime,a,i);o&&_.applyValue(m,n,i),u&&h.saveFinalValue()}}},iw._updateCrossFadeFromPoseState=function(e,t,r,n,a,i,o){var s,l=t.destPlayData,c=l.state,u=c._getDuration(),d=u*t.crossFadeTransition.duration,h=c.speed*this.speed,_=h*i;l.updateOrientation(_);var f=l.clipTime,p=l.playState;if(l.isForwards)s=f+_>d?d-f:_;else{var m=u-f;s=m-_>d?m-d:_}var g=0===h?0:s/h;l.update(s);var v=Math.abs(l.frameTime)/d;(v>=1-cQ.zeroTolerance||0===d)&&(v=1);var y=1===v;if(y?(this._preparePlayOwner(t,c),this._evaluatePlayingState(l,n,a,o)):this._evaluateCrossFadeFromPoseState(t,l,n,v,a,o),this._fireAnimationEventsAndCallScripts(e,l,c,f,p,s),y){this._updateCrossFadeData(t);var x=i-g;x>0&&this._updateState(e,t,r,x,o)}},iw._evaluateCrossFadeFromPoseState=function(e,t,r,n,a,i){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===cw.Finished;if(i||c)for(var u=o.length-1;u>=0;u--){var d=o[u],h=null==d?void 0:d.curveOwner;if(h){var _=d.crossDestCurveIndex;this._checkRevertOwner(h,a);var f=d.curveOwner.crossFadeFromPoseAndApplyValue(_>=0?s[_].curve:null,l,n,a);i&&h.applyValue(f,r,a),c&&d.saveFinalValue()}}},iw._updateFinishedState=function(e,t,r,n,a,i,o){var s=r.stateMachine,l=t.srcPlayData,c=l.state,u=c.speed*this.speed*i;l.updateOrientation(u);var d=l.clipTime,h=l.isForwards;this._applyTransitionsByCondition(e,t,r,c,s.anyStateTransitions,o)||this._applyStateTransitions(e,t,r,h,l,c.transitions,d,d,u,o)?this._updateState(e,t,r,i,o):this._evaluateFinishedState(l,n,a,o)},iw._evaluateFinishedState=function(e,t,r,n){if(n)for(var a=e.stateData.curveLayerOwner,i=e.state.clip._curveBindings,o=i.length-1;o>=0;o--){var s=a[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,r),l.applyValue(s.finalValue,t,r))}},iw._updateCrossFadeData=function(e){e.destPlayData.playState===cw.Finished?e.layerState=cP.Finished:e.layerState=cP.Playing,e.switchPlayData(),e.crossFadeTransition=null},iw._preparePlayOwner=function(e,t){if(e.layerState===cP.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,a=r.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(n=a[i])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},iw._applyStateTransitions=function(e,t,r,n,a,i,o,s,l,c){var u=a.state,d=u.clip.length,h=null,_=u.clipStartTime*d,f=u.clipEndTime*d;return n?o+l>=f?(h=this._checkSubTransition(e,t,r,a,i,o,f,c))||(a.currentTransitionIndex=0,h=this._checkSubTransition(e,t,r,a,i,_,s,c)):h=this._checkSubTransition(e,t,r,a,i,o,s,c):o+l<=_?(h=this._checkBackwardsSubTransition(e,t,r,a,i,o,_,c))||(a.currentTransitionIndex=i.length-1,h=this._checkBackwardsSubTransition(e,t,r,a,i,s,f,c)):h=this._checkBackwardsSubTransition(e,t,r,a,i,o,s,c),h},iw._checkSubTransition=function(e,t,r,n,a,i,o,s){for(var l=n.state,c=n.currentTransitionIndex,u=l._getDuration(),d=a.length;c<d;c++){var h=a[c],_=h.exitTime*u;if(_>o)break;if(_>=i&&(n.currentTransitionIndex=Math.min(c+1,d-1),this._checkConditions(l,h))){if(this._applyTransition(e,t,r,h,s))return h;break}}return null},iw._checkBackwardsSubTransition=function(e,t,r,n,a,i,o,s){for(var l=n.state,c=n.currentTransitionIndex,u=n.state._getDuration();c>=0;c--){var d=a[c],h=d.exitTime*u;if(h<o)break;if(h<=i&&(n.currentTransitionIndex=Math.max(c-1,0),this._checkConditions(l,d))){if(this._applyTransition(e,t,r,d,s))return d;break}}return null},iw._applyTransitionsByCondition=function(e,t,r,n,a,i){for(var o=0,s=a.length;o<s;o++){var l=a[o];if(this._checkConditions(n,l)){if(this._applyTransition(e,t,r,l,i))return l;return null}}},iw._preparePlay=function(e,t,r){void 0===r&&(r=0);var n=e.name;if(!e.clip)return uI.warn("The state named "+n+" has no AnimationClip data."),!1;var a=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(n,e,a,t);return this._preparePlayOwner(a,e),a.layerState=cP.Playing,a.srcPlayData.reset(e,i,e._getDuration()*r),!0},iw._applyTransition=function(e,t,r,n,a){var i=this._prepareCrossFadeByTransition(n,e);return n.isExit?(this._checkAnyAndEntryState(e,t,r,0,a),!0):i},iw._checkConditions=function(t,r){if(r.mute||(null==t?void 0:t._hasSoloTransition)&&!r.solo)return!1;for(var n=r.conditions,a=!0,i=0,o=n.length;i<o;++i){var s=!1,l=n[i],c=l.mode,u=l.parameterName,d=l.threshold,h=this.getParameterValue(u);if(void 0===h)return!1;switch(c){case e.AnimatorConditionMode.Equals:h===d&&(s=!0);break;case e.AnimatorConditionMode.Greater:h>d&&(s=!0);break;case e.AnimatorConditionMode.Less:h<d&&(s=!0);break;case e.AnimatorConditionMode.NotEquals:h!==d&&(s=!0);break;case e.AnimatorConditionMode.If:!0===h&&(s=!0);break;case e.AnimatorConditionMode.IfNot:!1===h&&(s=!0)}if(!s){a=!1;break}}return a},iw._prepareCrossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return uI.warn("The state named "+name+" has no AnimationClip data."),!1;var n=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(r.name,r,n,t),i=r._getDuration()*e.offset;switch(n.destPlayData.reset(r,a,i),n.layerState){case cP.Standby:case cP.Finished:n.layerState=cP.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case cP.Playing:n.layerState=cP.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case cP.CrossFading:n.layerState=cP.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case cP.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},iw._fireAnimationEvents=function(e,t,r,n){var a=e.state,i=e.isForwards,o=e.clipTime,s=a.clip.length,l=a.clipStartTime*s,c=a.clipEndTime*s;i?r+n>=c?(this._fireSubAnimationEvents(e,t,r,a.clipEndTime*s),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,a.clipStartTime*s,o)):this._fireSubAnimationEvents(e,t,r,o):r+n<=l?(this._fireBackwardSubAnimationEvents(e,t,r,a.clipStartTime*s),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,a.clipEndTime*s,o)):this._fireBackwardSubAnimationEvents(e,t,r,o)},iw._fireSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex,i=t.length;a<i;a++){var o=t[a],s=o.event,l=s.time,c=s.parameter;if(l>n)break;var u=o.handlers;if(l>=r){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(a+1,i-1)}}},iw._fireBackwardSubAnimationEvents=function(e,t,r,n){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<n)break;if(s<=r){for(var c=i.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(a-1,0)}}},iw._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,a=r.length;n<a;n++)r[n].onStateEnter(this,e,t)},iw._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,a=r.length;n<a;n++)r[n].onStateUpdate(this,e,t)},iw._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,a=r.length;n<a;n++)r[n].onStateExit(this,e,t)},iw._checkAnyAndEntryState=function(e,t,r,n,a){var i,o=r.stateMachine,s=o.anyStateTransitions,l=o.entryTransitions;if((i=s.length&&this._applyTransitionsByCondition(e,t,r,null,s,a))||(i=l.length&&this._applyTransitionsByCondition(e,t,r,null,l,a)),i)this._updateState(e,t,r,n,a);else{var c=o.defaultState;c&&(this._preparePlay(c,e),this._updateState(e,t,r,n,a))}},iw._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},iw._fireAnimationEventsAndCallScripts=function(e,t,r,n,a,i){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,n,i),a===cw.UnStarted&&this._callAnimatorScriptOnEnter(r,e),a!==cw.Finished&&t.playState===cw.Finished?this._callAnimatorScriptOnExit(r,e):this._callAnimatorScriptOnUpdate(r,e)},ui(iE,[{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)}},{key:"layers",get:function(){var e;return null==(e=this._animatorController)?void 0:e._layers}},{key:"parameters",get:function(){var e;return null==(e=this._animatorController)?void 0:e._parameters}}]),iE);ul([ud],_L.prototype,"speed",void 0),ul([uu],_L.prototype,"_controllerUpdateFlag",void 0),ul([uu],_L.prototype,"_updateMark",void 0),ul([uu],_L.prototype,"_animatorLayersData",void 0),ul([uu],_L.prototype,"_curveOwnerPool",void 0),ul([uu],_L.prototype,"_animationEventHandlerPool",void 0),ul([uu],_L.prototype,"_parametersValueMap",void 0),ul([uu],_L.prototype,"_tempAnimatorStateInfo",void 0),ul([uu],_L.prototype,"_controlledRenderers",void 0);var _B=(ui(iP=function(){this._onNameChanged=null},[{key:"name",get:function(){return this._name},set:function(e){if(this._name!==e){var t,r=this._name;this._name=e,null==(t=this._onNameChanged)||t.call(this,r,e)}}}]),iP),_D=(us(iF=function(e){var t,r,n;return e&&((t=um.call(this,e)||this)._parameters=[],t._parametersMap={},t._layers=[],t._layersMap={},t._updateFlagManager=new uT),r=t,n&&("object"==(n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof n)?n:un(r)},um),(iL=iF.prototype).addParameter=function(e,t){var r=this;if(this._parametersMap[e])return console.warn("Parameter "+e+" already exists."),null;var n=new _B;return n.name=e,n.defaultValue=t,n._onNameChanged=function(e,t){delete r._parametersMap[e],r._parametersMap[t]=n},this._parametersMap[e]=n,this._parameters.push(n),n},iL.removeParameter=function(e){var t=this._parametersMap[e],r=this._parameters.indexOf(t);-1!==r&&(this._parameters.splice(r,1),delete this._parametersMap[t.name])},iL.getParameter=function(e){return this._parametersMap[e]||null},iL.findLayerByName=function(e){return this._layersMap[e]},iL.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iL.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iL.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iL._registerChangeFlag=function(){return this._updateFlagManager.createFlag(u9)},ui(iF,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),iF),_I=((iD=(iB=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},iD.onStateUpdate=function(e,t,r){},iD.onStateExit=function(e,t,r){},iD.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iB),_O=((iO=(iI=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new uT,this._hasSoloTransition=!1,this._clipStartTime=0,this._clipEndTime=1,this._transitions=[],this._onClipChanged=this._onClipChanged.bind(this)}).prototype).addTransition=function(e){uc(e,iI)?(t=new _E).destinationState=e:t=e,t._srcState=this;var t,r=this._transitions,n=r.length,a=t.exitTime;if(a>=(n?r[n-1].exitTime:0))r.push(t);else{for(var i=n;--i>=0&&a<r[i].exitTime;);r.splice(i+1,0,t)}return t.solo&&!this._hasSoloTransition&&this._updateSoloTransition(!0),t},iO.addExitTransition=function(e){void 0===e&&(e=1);var t=new _E;return t._srcState=this,t._isExit=!0,t.exitTime=e,this.addTransition(t)},iO.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1),e._srcState=null,this._updateSoloTransition()},iO.addStateMachineScript=function(e){var t=new e;t._state=this;var r=_I.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},iO.clearTransitions=function(){this._transitions.length=0},iO._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iO._removeStateMachineScript=function(e){var t=_I.prototype;if(e.onStateEnter!==t.onStateEnter){var r=this._onStateEnterScripts.indexOf(e);-1!==r&&this._onStateEnterScripts.splice(r,1)}if(e.onStateUpdate!==t.onStateUpdate){var n=this._onStateUpdateScripts.indexOf(e);-1!==n&&this._onStateUpdateScripts.splice(n,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},iO._onClipChanged=function(){this._updateFlagManager.dispatch()},iO._updateSoloTransition=function(e){if(void 0!==e)this._hasSoloTransition=e;else{this._hasSoloTransition=!1;for(var t=0,r=this.transitions.length;t<r;++t)if(this.transitions[t].solo){this._hasSoloTransition=!0;return}}},ui(iI,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._updateFlagManager.removeListener(this._onClipChanged),this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1),this._onClipChanged(),e&&e._updateFlagManager.addListener(this._onClipChanged))}},{key:"clipStartTime",get:function(){return this._clipStartTime},set:function(e){this._clipStartTime=Math.max(e,0)}},{key:"clipEndTime",get:function(){return this._clipEndTime},set:function(e){this._clipEndTime=Math.min(e,1)}}]),iI),_V=((iN=(iV=function(){this.states=[],this._entryTransitions=[],this._anyStateTransitions=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new _O(e),this.states.push(t),this._statesMap[e]=t),t},iN.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},iN.findStateByName=function(e){return this._statesMap[e]},iN.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},iN.addEntryStateTransition=function(e){return this._addTransition(e,this._entryTransitions)},iN.removeEntryStateTransition=function(e){this._removeTransition(e,this._entryTransitions)},iN.addAnyStateTransition=function(e){return this._addTransition(e,this._anyStateTransitions)},iN.removeAnyStateTransition=function(e){this._removeTransition(e,this._anyStateTransitions)},iN._addTransition=function(e,t){var r;return uc(e,_O)?(r=new _E).destinationState=e:r=e,t.push(r),r},iN._removeTransition=function(e,t){var r=t.indexOf(e);-1!==r&&t.splice(r,1)},ui(iV,[{key:"entryTransitions",get:function(){return this._entryTransitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitions}}]),iV),_N=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override,this.stateMachine=new _V},_k=function(){},_z=function(){},_U=((iz=(ik=function(){this._pathMasks=[],this._pathMaskMap={}}).prototype).addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var r=new _z;return r.path=e,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[e]=r,r},iz.removePathMask=function(e){for(var t=this._pathMasks,r=0,n=this._pathMasks.length;r<n;++r)if(t[r].path===e){t.splice(r,1),delete this._pathMaskMap[e];break}},iz.getPathMask=function(e){return this._pathMaskMap[e]},iz.setPathMaskActive=function(e,t,r){void 0===r&&(r=!1);var n=this._pathMaskMap[e];if(n&&(n.active=t),r)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},ik.createByEntity=function(e){var t=new ik;return t.addPathMask(""),ik._addPathMaskWithChildren(t,e,""),t},ik._addPathMaskWithChildren=function(e,t,r){for(var n=t.children,a=0,i=n.length;a<i;++a){var o=n[a],s=r?r+"/"+o.name:o.name;e.addPathMask(s),ik._addPathMaskWithChildren(e,o,s)}},ui(ik,[{key:"pathMasks",get:function(){return this._pathMasks}}]),ik),_G=function(t){function r(n){var a;return(a=t.call(this,n,u$.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new c7(1,1,1,1),a.renderState.rasterState.cullMode=e.CullMode.Off,a.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,a.shaderData.setFloat(r._rotationProp,0),a.shaderData.setFloat(r._exposureProp,1),a.shaderData.setColor(r._tintColorProp,a._tintColor),a}return us(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},ui(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}(dN);_G._tintColorProp=uO.getByName("material_TintColor"),_G._textureCubeProp=uO.getByName("material_CubeTexture"),_G._rotationProp=uO.getByName("material_Rotation"),_G._exposureProp=uO.getByName("material_Exposure"),_G._decodeSkyRGBMMacro=uM.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iU=e.SunMode||(e.SunMode={}))[iU.None=0]="None",iU[iU.Simple=1]="Simple",iU[iU.HighQuality=2]="HighQuality";var _H=(us(iG=function(t){var r;return(r=dN.call(this,t,u$.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new c7(.5,.5,.5,1),r.groundTint=new c7(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},dN),iG.prototype.clone=function(){var e=new iG(this._engine);return this.cloneTo(e),e},ui(iG,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iG._sunSimpleMacro),t.enableMacro(iG._sunHighQualityMacro);break;case 1:t.disableMacro(iG._sunHighQualityMacro),t.enableMacro(iG._sunSimpleMacro);break;case 0:t.disableMacro(iG._sunHighQualityMacro),t.disableMacro(iG._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iG._sunSizeProp)},set:function(e){this.shaderData.setFloat(iG._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iG._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iG._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iG._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iG._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iG._skyTintProp)},set:function(e){this.shaderData.setColor(iG._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iG._groundTintProp)},set:function(e){this.shaderData.setColor(iG._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iG._exposureProp)},set:function(e){this.shaderData.setFloat(iG._exposureProp,Math.min(Math.max(0,e),8))}}]),iG);_H._sunSizeProp=uO.getByName("material_SunSize"),_H._sunSizeConvergenceProp=uO.getByName("material_SunSizeConvergence"),_H._atmosphereThicknessProp=uO.getByName("material_AtmosphereThickness"),_H._skyTintProp=uO.getByName("material_SkyTint"),_H._groundTintProp=uO.getByName("material_GroundTint"),_H._exposureProp=uO.getByName("material_Exposure"),_H._sunHighQualityMacro=uM.getByName("MATERIAL_SUN_HIGH_QUALITY"),_H._sunSimpleMacro=uM.getByName("MATERIAL_SUN_SIMPLE"),e.ParticleRenderMode=void 0,(iH=e.ParticleRenderMode||(e.ParticleRenderMode={}))[iH.Billboard=0]="Billboard",iH[iH.StretchBillboard=1]="StretchBillboard",iH[iH.HorizontalBillboard=2]="HorizontalBillboard",iH[iH.VerticalBillboard=3]="VerticalBillboard",iH[iH.Mesh=4]="Mesh",iH[iH.None=5]="None",e.ParticleSimulationSpace=void 0,(iW=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[iW.Local=0]="Local",iW[iW.World=1]="World",e.ParticleStopMode=void 0,(ij=e.ParticleStopMode||(e.ParticleStopMode={}))[ij.StopEmittingAndClear=0]="StopEmittingAndClear",ij[ij.StopEmitting=1]="StopEmitting";var _W=function(t){function r(n){var a;return(a=t.call(this,n)||this).velocityScale=0,a.lengthScale=2,a.pivot=new cZ,a._generatorBounds=new c$,a._transformedBounds=new c$,a._onGeneratorParamsChanged=a._onGeneratorParamsChanged.bind(un(a)),a.generator=new _5(un(a)),a._currentRenderModeMacro=r._billboardModeMacro,a.shaderData.enableMacro(r._billboardModeMacro),a._supportInstancedArrays=a.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),a._onGeneratorParamsChanged(),a}us(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){this._supportInstancedArrays&&t.prototype._prepareRender.call(this,e)},n._updateTransformShaderData=function(e,r,n){t.prototype._updateTransformShaderData.call(this,e,r,!0)},n._updateBounds=function(t){var r=this.generator;if(!r.isAlive){var n=this.entity.transform.worldPosition;t.min.copyFrom(n),t.max.copyFrom(n);return}r.main.simulationSpace===e.ParticleSimulationSpace.Local?r._updateBoundsSimulationLocal(t):(this._isContainDirtyFlag(2)&&(r._generateTransformedBounds(),this._setDirtyFlagFalse(2)),r._updateBoundsSimulationWorld(t))},n._update=function(e){var t=this.generator;if(t._update(this.engine.time.deltaTime),t._firstActiveElement!==t._firstFreeElement){var n=this.shaderData;n.setFloat(r._lengthScale,this.lengthScale),n.setFloat(r._speedScale,this.velocityScale),n.setFloat(r._currentTime,this.generator._playTime),n.setVector3(r._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(n)}},n._render=function(e){var t=this.generator;t._primitive.instanceCount=t._getAliveParticleCount();var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var n=this._engine,a=n._renderElementPool.get();a.set(this.priority,this._distanceForSort);var i=n._subRenderElementPool.get();i.set(this,r,t._primitive,t._subPrimitive),a.addSubRenderElement(i),e.camera._renderPipeline.pushRenderElement(e,a)}},n._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||this._addResourceReferCount(e,-1)),this.generator._destroy()},n._isContainDirtyFlag=function(e){return(this._dirtyUpdateFlag&e)!=0},n._setDirtyFlagFalse=function(e){this._dirtyUpdateFlag&=~e},n._onWorldVolumeChanged=function(){this._dirtyUpdateFlag|=co.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|co.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|co.WorldVolume},ui(r,[{key:"renderMode",get:function(){return this._renderMode},set:function(t){if(this._renderMode!==t){var n=this._renderMode;this._renderMode=t;var a=null,i=this.shaderData;switch(t){case e.ParticleRenderMode.Billboard:a=r._billboardModeMacro;break;case e.ParticleRenderMode.StretchBillboard:a=r._stretchedBillboardModeMacro;break;case e.ParticleRenderMode.HorizontalBillboard:case e.ParticleRenderMode.VerticalBillboard:case e.ParticleRenderMode.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==a&&(this._currentRenderModeMacro&&i.disableMacro(this._currentRenderModeMacro),a&&i.enableMacro(a),this._currentRenderModeMacro=a),n!==e.ParticleRenderMode.Mesh!=(t===e.ParticleRenderMode.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(t){var r=this._mesh;r!==t&&(this._mesh=t,r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),this.renderMode===e.ParticleRenderMode.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),r}(e.Renderer);_W._billboardModeMacro=uM.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),_W._stretchedBillboardModeMacro=uM.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),_W._horizontalBillboardModeMacro=uM.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),_W._verticalBillboardModeMacro=uM.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),_W._renderModeMeshMacro=uM.getByName("RENDERER_MODE_MESH"),_W._pivotOffsetProperty=uO.getByName("renderer_PivotOffset"),_W._lengthScale=uO.getByName("renderer_StretchedBillboardLengthScale"),_W._speedScale=uO.getByName("renderer_StretchedBillboardSpeedScale"),_W._currentTime=uO.getByName("renderer_CurrentTime"),ul([u_],_W.prototype,"generator",void 0),ul([uh],_W.prototype,"pivot",void 0),ul([uu],_W.prototype,"_generatorBounds",void 0),ul([uu],_W.prototype,"_transformedBounds",void 0),ul([uu],_W.prototype,"_onGeneratorParamsChanged",null),(iK=cF||(cF={}))[iK.TransformVolume=2]="TransformVolume",iK[iK.GeneratorVolume=4]="GeneratorVolume",e.ParticleCurveMode=void 0,(iX=e.ParticleCurveMode||(e.ParticleCurveMode={}))[iX.Constant=0]="Constant",iX[iX.TwoConstants=1]="TwoConstants",iX[iX.Curve=2]="Curve",iX[iX.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(iY=e.ParticleGradientMode||(e.ParticleGradientMode={}))[iY.Constant=0]="Constant",iY[iY.TwoConstants=1]="TwoConstants",iY[iY.Gradient=2]="Gradient",iY[iY.TwoGradients=3]="TwoGradients",(iq=cL||(cL={}))[iq.Burst=592910910]="Burst",iq[iq.StartDelay=322376503]="StartDelay",iq[iq.StartColor=306581307]="StartColor",iq[iq.StartSize=1793934638]="StartSize",iq[iq.StartRotation=3737431713]="StartRotation",iq[iq.randomizeRotationDirection=2527743459]="randomizeRotationDirection",iq[iq.StartLifetime=2368504881]="StartLifetime",iq[iq.StartSpeed=4085612399]="StartSpeed",iq[iq.VelocityOverLifetime=3774601268]="VelocityOverLifetime",iq[iq.ColorOverLifetime=326370691]="ColorOverLifetime",iq[iq.SizeOverLifetime=1494990940]="SizeOverLifetime",iq[iq.RotationOverLifetime=1089181156]="RotationOverLifetime",iq[iq.TextureSheetAnimation=197469413]="TextureSheetAnimation",iq[iq.Shape=2941263940]="Shape",iq[iq.GravityModifier=2759560269]="GravityModifier";var _j=((iZ=(iQ=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=null),this._colorKeys=[],this._alphaKeys=[],this._colorTypeArrayDirty=!1,this._alphaTypeArrayDirty=!1,e)for(var r=0,n=e.length;r<n;r++){var a=e[r];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}).prototype).addColorKey=function(e,t){var r=this._colorKeys;if(4===r.length)throw Error("Gradient can only have 4 color keys");var n="number"==typeof e?new _K(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},iZ.addAlphaKey=function(e,t){var r=this._alphaKeys;if(4===r.length)throw Error("Gradient can only have 4 alpha keys");var n="number"==typeof e?new _X(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},iZ.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},iZ.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},iZ.setKeys=function(e,t){for(var r=this._colorKeys,n=this._alphaKeys,a=0,i=r.length;a<i;a++)r[a]._onValueChanged=null;for(var o=0,s=n.length;o<s;o++)n[o]._onValueChanged=null;r.length=0,n.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(r,e[l]);for(var u=0,d=t.length;u<d;u++)this._addKey(n,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},iZ._getColorTypeArray=function(t){var r=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,a=0,i=Math.min(n.length,4);a<i;a++){var o=4*a,s=n[a];r[o]=s.time;var l=s.color;t===e.ColorSpace.Linear?(r[o+1]=c7.gammaToLinearSpace(l.r),r[o+2]=c7.gammaToLinearSpace(l.g),r[o+3]=c7.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},iZ._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},iZ._addKey=function(e,t){var r=t.time,n=e.length;if(r>=(n?e[n-1].time:0))e.push(t);else{for(var a=n;--a>=0&&r<e[a].time;);e.splice(a+1,0,t)}},iZ._removeKey=function(e,t){e.splice(t,1)},iZ._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},iZ._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},ui(iQ,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),iQ);ul([u_],_j.prototype,"_colorKeys",void 0),ul([u_],_j.prototype,"_alphaKeys",void 0),ul([uu],_j.prototype,"_colorTypeArray",void 0),ul([uu],_j.prototype,"_alphaTypeArray",void 0),ul([uu],_j.prototype,"_setColorTypeArrayDirty",null),ul([uu],_j.prototype,"_setAlphaTypeArrayDirty",null);var _K=(ui(iJ=function(e,t){this._onValueChanged=null,this._color=new c7,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)}}]),iJ),_X=(ui(i$=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()}}]),i$),_Y=((i0=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new c7,this.constantMax=new c7,this.gradientMin=new _j,this.gradientMax=new _j,t.constructor===c7?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:c7.lerp(this.constantMin,this.constantMax,r,n)}},ui(i0,[{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}}]),i0);ul([u_],_Y.prototype,"constantMin",void 0),ul([u_],_Y.prototype,"constantMax",void 0),ul([u_],_Y.prototype,"gradientMin",void 0),ul([u_],_Y.prototype,"gradientMax",void 0);var _q=((i1=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},ui(i1,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),i1);ul([uu],_q.prototype,"_generator",void 0);var _Q=(us(i2=function(){var e;return e=_q.apply(this,arguments)||this,e.color=new _Y(new _j([new _K(0,new c7(1,1,1)),new _K(1,new c7(1,1,1))],[new _X(0,1),new _X(1,1)])),e._colorGradientRand=new ur(0,cL.ColorOverLifetime),e._gradientKeysCount=new c6(0,0,0,0),e},_q),(i3=i2.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.color.mode;if(n!==e.ParticleGradientMode.Gradient&&n!==e.ParticleGradientMode.TwoGradients)throw Error("Invalid color mode, only gradient and two gradients are supported in color over lifetime.");var a=this.color,i=this._generator._renderer.engine.settings.colorSpace;t.setFloatArray(i2._maxGradientColor,a.gradientMax._getColorTypeArray(i)),t.setFloatArray(i2._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=i2._gradientMacro:(t.setFloatArray(i2._minGradientColor,a.gradientMin._getColorTypeArray(i)),t.setFloatArray(i2._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),r=i2._randomGradientsMacro);var o=a.gradientMin.colorKeys,s=a.gradientMin.alphaKeys,l=a.gradientMax.colorKeys,c=a.gradientMax.alphaKeys;this._gradientKeysCount.set(o.length?o[o.length-1].time:0,s.length?s[s.length-1].time:0,l.length?l[l.length-1].time:0,c.length?c[c.length-1].time:0),t.setVector4(i2._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},i3._resetRandomSeed=function(e){this._colorGradientRand.reset(e,cL.ColorOverLifetime)},i2);_Q._gradientMacro=uM.getByName("RENDERER_COL_GRADIENT"),_Q._randomGradientsMacro=uM.getByName("RENDERER_COL_RANDOM_GRADIENTS"),_Q._minGradientColor=uO.getByName("renderer_COLMinGradientColor"),_Q._minGradientAlpha=uO.getByName("renderer_COLMinGradientAlpha"),_Q._maxGradientColor=uO.getByName("renderer_COLMaxGradientColor"),_Q._maxGradientAlpha=uO.getByName("renderer_COLMaxGradientAlpha"),_Q._gradientKeysCount=uO.getByName("renderer_COLGradientKeysMaxTime"),ul([u_],_Q.prototype,"color",void 0),ul([uu],_Q.prototype,"_colorGradientRand",void 0),ul([uu],_Q.prototype,"_gradientKeysCount",void 0),ul([uu],_Q.prototype,"_colorMacro",void 0);var _Z=((i8=(i4=function(t,r){this._updateManager=new uT,this._mode=e.ParticleCurveMode.Constant,this._constantMin=0,this._constantMax=0,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager),"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}},i8._getMax=function(){switch(this.mode){case e.ParticleCurveMode.Constant:return this.constantMax;case e.ParticleCurveMode.TwoConstants:return Math.max(this.constantMin,this.constantMax);case e.ParticleCurveMode.Curve:var t;return this._getMaxKeyValue(null==(t=this.curveMax)?void 0:t.keys);case e.ParticleCurveMode.TwoCurves:var r,n,a=this._getMaxKeyValue(null==(r=this.curveMin)?void 0:r.keys),i=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return a>i?a:i}},i8._getMinMax=function(t){switch(this.mode){case e.ParticleCurveMode.Constant:t.x=t.y=this.constantMax;break;case e.ParticleCurveMode.TwoConstants:t.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case e.ParticleCurveMode.Curve:var r,n;t.set(this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys));break;case e.ParticleCurveMode.TwoCurves:var a,i,o,s,l=this._getMinKeyValue(null==(a=this.curveMax)?void 0:a.keys),c=this._getMinKeyValue(null==(i=this.curveMin)?void 0:i.keys),u=this._getMaxKeyValue(null==(o=this.curveMax)?void 0:o.keys),d=this._getMaxKeyValue(null==(s=this.curveMin)?void 0:s.keys),h=l<c?l:c,_=u>d?u:d;t.set(h,_)}},i8._registerOnValueChanged=function(e){this._updateManager.addListener(e)},i8._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},i8._getMaxKeyValue=function(e){var t,r=void 0,n=null!=(t=null==e?void 0:e.length)?t:0;if(n>0){r=e[0].value;for(var a=1;a<n;a++)r=Math.max(r,e[a].value)}return r},i8._getMinKeyValue=function(e){var t,r=void 0,n=null!=(t=null==e?void 0:e.length)?t:0;if(n>0){r=e[0].value;for(var a=1;a<n;a++)r=Math.min(r,e[a].value)}return r},i8._onCurveChange=function(e,t){var r=this._updateDispatch;null==e||e._unRegisterOnValueChanged(r),null==t||t._registerOnValueChanged(r),r()},ui(i4,[{key:"mode",get:function(){return this._mode},set:function(e){e!==this._mode&&(this._mode=e,this._updateDispatch())}},{key:"constantMin",get:function(){return this._constantMin},set:function(e){e!==this._constantMin&&(this._constantMin=e,this._updateDispatch())}},{key:"constantMax",get:function(){return this._constantMax},set:function(e){e!==this._constantMax&&(this._constantMax=e,this._updateDispatch())}},{key:"curveMin",get:function(){return this._curveMin},set:function(e){var t=this._curveMin;e!==t&&(this._curveMin=e,this._onCurveChange(t,e))}},{key:"curveMax",get:function(){return this._curveMax},set:function(e){var t=this._curveMax;e!==t&&(this._curveMax=e,this._onCurveChange(t,e))}},{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}}]),i4);ul([uu],_Z.prototype,"_updateManager",void 0),ul([u_],_Z.prototype,"_curveMin",void 0),ul([u_],_Z.prototype,"_curveMax",void 0),ul([uu],_Z.prototype,"_updateDispatch",void 0);var _J=(us(i5=function(){var e;return e=_q.apply(this,arguments)||this,e.rateOverTime=new _Z(10),e.rateOverDistance=new _Z(0),e._shapeRand=new ur(0,cL.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new ur(0,cL.Burst),e},_q),(i9=i5.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)},i9.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},i9.removeBurstByIndex=function(e){this._bursts.splice(e,1)},i9.clearBurst=function(){this._bursts.length=0},i9._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},i9._resetRandomSeed=function(e){this._burstRand.reset(e,cL.Burst),this._shapeRand.reset(e,cL.Shape)},i9._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},i9._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},i9._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var r=this._generator,n=1/t,a=e-this._frameRateTime;a>=n;)a-=n,this._frameRateTime+=n,r._emit(this._frameRateTime,1)},i9._emitByBurst=function(e,t){var r=this._generator.main,n=r.duration,a=Math.floor((t-e)/n);if(r.isLoop&&(a>0||t%n<e%n)){var i=Math.ceil(e/n)*n;this._emitBySubBurst(e,i,n),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=n,this._emitBySubBurst(s,i,n),this._currentBurstIndex=0}this._emitBySubBurst(i,t,n)}else this._emitBySubBurst(e,t,n)},i9._emitBySubBurst=function(e,t,r){for(var n=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/r)*r,s=e%r,l=s+(t-e),c=this._currentBurstIndex,u=i.length;c<u;c++){var d=i[c],h=d.time;if(h>l)break;if(h>=s){var _=d.count.evaluate(void 0,a.random());n._emit(o+h,_)}}this._currentBurstIndex=c},ui(i5,[{key:"shape",get:function(){return this._shape},set:function(e){var t=this._shape;if(e!==t){this._shape=e;var r=this._generator._renderer;null==t||t._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==e||e._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),i5);ul([u_],_J.prototype,"rateOverTime",void 0),ul([u_],_J.prototype,"rateOverDistance",void 0),ul([u_],_J.prototype,"_shape",void 0),ul([uu],_J.prototype,"_shapeRand",void 0),ul([u_],_J.prototype,"_bursts",void 0),ul([uu],_J.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(i6=e.ParticleScaleMode||(e.ParticleScaleMode={}))[i6.Hierarchy=0]="Hierarchy",i6[i6.Local=1]="Local",i6[i6.World=2]="World";var _$=((oe=(i7=function(t){this.duration=5,this.isLoop=!0,this.startDelay=new _Z(0),this.startRotation3D=!1,this.startRotationX=new _Z(0),this.startRotationY=new _Z(0),this.startRotationZ=new _Z(0),this.flipRotation=0,this.startColor=new _Y(new c7(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startSpeedRand=new ur(0,cL.StartSpeed),this._startLifeTimeRand=new ur(0,cL.StartLifetime),this._startColorRand=new ur(0,cL.StartColor),this._startSizeRand=new ur(0,cL.StartSize),this._startRotationRand=new ur(0,cL.StartRotation),this._gravityModifierRand=new ur(0,cL.GravityModifier),this._startSize3D=!1,this._simulationSpace=e.ParticleSimulationSpace.Local,this._gravity=new cZ,this._generator=t,this.startLifetime=new _Z(5),this.startSpeed=new _Z(5),this.startSizeX=new _Z(1),this.startSizeY=new _Z(1),this.startSizeZ=new _Z(1),this.gravityModifier=new _Z(0)}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,cL.StartSpeed),this._startLifeTimeRand.reset(e,cL.StartLifetime),this._startColorRand.reset(e,cL.StartColor),this._startSizeRand.reset(e,cL.StartSize),this._startRotationRand.reset(e,cL.StartRotation)},oe._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}},oe._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(i7._worldPosition,n.worldPosition);var a=n.worldRotationQuaternion,i=i7._tempVector40;i.copyFrom(a),t.setVector4(i7._worldRotation,i);break;case e.ParticleSimulationSpace.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case e.ParticleScaleMode.Hierarchy:var o=n.lossyWorldScale;t.setVector3(i7._positionScale,o),t.setVector3(i7._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(i7._positionScale,o),t.setVector3(i7._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(i7._positionScale,n.lossyWorldScale),t.setVector3(i7._sizeScale,i7._vector3One)}var s=this._gravity,l=this.gravityModifier.evaluate(void 0,this._gravityModifierRand.random());cZ.scale(r.scene.physics.gravity,l,s),t.setVector3(i7._gravity,s),t.setInt(i7._simulationSpace,this.simulationSpace),t.setFloat(i7._startRotation3D,+this.startRotation3D),t.setInt(i7._scaleMode,this.scalingMode)},oe._cloneTo=function(t){t.maxParticles=this.maxParticles,t._simulationSpace===e.ParticleSimulationSpace.World&&t._generator._generateTransformedBounds()},oe._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ui(i7,[{key:"startLifetime",get:function(){return this._startLifetime},set:function(e){var t=this._startLifetime;e!==t&&(this._startLifetime=e,this._onCompositeCurveChange(t,e))}},{key:"startSpeed",get:function(){return this._startSpeed},set:function(e){var t=this._startSpeed;e!==t&&(this._startSpeed=e,this._onCompositeCurveChange(t,e))}},{key:"startSize3D",get:function(){return this._startSize3D},set:function(e){e!==this._startSize3D&&(this._startSize3D=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"startSizeX",get:function(){return this._startSizeX},set:function(e){var t=this._startSizeX;e!==t&&(this._startSizeX=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeY",get:function(){return this._startSizeY},set:function(e){var t=this._startSizeY;e!==t&&(this._startSizeY=e,this._onCompositeCurveChange(t,e))}},{key:"startSizeZ",get:function(){return this._startSizeZ},set:function(e){var t=this._startSizeZ;e!==t&&(this._startSizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"gravityModifier",get:function(){return this._gravityModifier},set:function(e){var t=this._gravityModifier;e!==t&&(this._gravityModifier=e,this._onCompositeCurveChange(t,e))}},{key:"simulationSpace",get:function(){return this._simulationSpace},set:function(t){if(t!==this._simulationSpace){this._simulationSpace=t;var r=this._generator;r._renderer._onTransformChanged(ci.WorldMatrix),t===e.ParticleSimulationSpace.Local&&r._freeBoundsArray()}}},{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}}]),i7);_$._tempVector40=new c6,_$._vector3One=new cZ(1,1,1),_$._positionScale=uO.getByName("renderer_PositionScale"),_$._sizeScale=uO.getByName("renderer_SizeScale"),_$._worldPosition=uO.getByName("renderer_WorldPosition"),_$._worldRotation=uO.getByName("renderer_WorldRotation"),_$._gravity=uO.getByName("renderer_Gravity"),_$._simulationSpace=uO.getByName("renderer_SimulationSpace"),_$._startRotation3D=uO.getByName("renderer_ThreeDStartRotation"),_$._scaleMode=uO.getByName("renderer_ScalingMode"),ul([u_],_$.prototype,"startDelay",void 0),ul([u_],_$.prototype,"startRotationX",void 0),ul([u_],_$.prototype,"startRotationY",void 0),ul([u_],_$.prototype,"startRotationZ",void 0),ul([u_],_$.prototype,"startColor",void 0),ul([uu],_$.prototype,"_maxParticleBuffer",void 0),ul([uu],_$.prototype,"_startSpeedRand",void 0),ul([uu],_$.prototype,"_startLifeTimeRand",void 0),ul([uu],_$.prototype,"_startColorRand",void 0),ul([uu],_$.prototype,"_startSizeRand",void 0),ul([uu],_$.prototype,"_startRotationRand",void 0),ul([uu],_$.prototype,"_gravityModifierRand",void 0),ul([u_],_$.prototype,"_startLifetime",void 0),ul([u_],_$.prototype,"_startSpeed",void 0),ul([u_],_$.prototype,"_startSizeX",void 0),ul([u_],_$.prototype,"_startSizeY",void 0),ul([u_],_$.prototype,"_startSizeZ",void 0),ul([u_],_$.prototype,"_gravityModifier",void 0),ul([uu],_$.prototype,"_generator",void 0),ul([uu],_$.prototype,"_gravity",void 0);var _0=(us(ot=function(){var e;return e=_q.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new _Z(0),e.rotationY=new _Z(0),e.rotationZ=new _Z(45),e._rotationRand=new ur(0,cL.RotationOverLifetime),e._rotationMinConstant=new cZ,e._rotationMaxConstant=new cZ,e},_q),(or=ot.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:s.mode===e.ParticleCurveMode.TwoCurves;if(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:s.mode===e.ParticleCurveMode.Curve)t.setFloatArray(ot._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(ot._maxCurveXProperty,i.curveMax._getTypeArray()),t.setFloatArray(ot._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(ot._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(ot._minCurveXProperty,i.curveMin._getTypeArray()),t.setFloatArray(ot._minCurveYProperty,o.curveMin._getTypeArray())),a=ot._isRandomTwoMacro),n=ot._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(cQ.degreeToRadian(i.constantMax),cQ.degreeToRadian(o.constantMax),cQ.degreeToRadian(s.constantMax)),t.setVector3(ot._maxConstantProperty,u),l?i.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(cQ.degreeToRadian(i.constantMin),cQ.degreeToRadian(o.constantMin),cQ.degreeToRadian(s.constantMin)),t.setVector3(ot._minConstantProperty,d),a=ot._isRandomTwoMacro}n=ot._constantModeMacro}l&&(r=ot._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},or._resetRandomSeed=function(e){this._rotationRand.reset(e,cL.RotationOverLifetime)},ot);_0._constantModeMacro=uM.getByName("RENDERER_ROL_CONSTANT_MODE"),_0._curveModeMacro=uM.getByName("RENDERER_ROL_CURVE_MODE"),_0._isSeparateMacro=uM.getByName("RENDERER_ROL_IS_SEPARATE"),_0._isRandomTwoMacro=uM.getByName("RENDERER_ROL_IS_RANDOM_TWO"),_0._minConstantProperty=uO.getByName("renderer_ROLMinConst"),_0._minCurveXProperty=uO.getByName("renderer_ROLMinCurveX"),_0._minCurveYProperty=uO.getByName("renderer_ROLMinCurveY"),_0._minCurveZProperty=uO.getByName("renderer_ROLMinCurveZ"),_0._maxConstantProperty=uO.getByName("renderer_ROLMaxConst"),_0._maxCurveXProperty=uO.getByName("renderer_ROLMaxCurveX"),_0._maxCurveYProperty=uO.getByName("renderer_ROLMaxCurveY"),_0._maxCurveZProperty=uO.getByName("renderer_ROLMaxCurveZ"),ul([u_],_0.prototype,"rotationX",void 0),ul([u_],_0.prototype,"rotationY",void 0),ul([u_],_0.prototype,"rotationZ",void 0),ul([uu],_0.prototype,"_rotationRand",void 0),ul([uu],_0.prototype,"_rotationMinConstant",void 0),ul([uu],_0.prototype,"_rotationMaxConstant",void 0),ul([uu],_0.prototype,"_enableSeparateMacro",void 0),ul([uu],_0.prototype,"_isCurveMacro",void 0),ul([uu],_0.prototype,"_isRandomTwoMacro",void 0);var _1=((oa=(on=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this._updateManager=new uT,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var n=0,a=t.length;n<a;n++){var i=t[n];this.addKey(i)}}).prototype).addKey=function(e,t){var r=this._keys;if(4===r.length)throw Error("Curve can only have 4 keys");var n="number"==typeof e?new _2(e,t):e;this._addKey(r,n),n._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},oa.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},oa.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},oa._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,r=0,n=Math.min(t.length,4);r<n;r++){var a=2*r,i=t[r];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},oa._registerOnValueChanged=function(e){this._updateManager.addListener(e)},oa._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},oa._addKey=function(e,t){var r=e.length,n=t.time;if(n>=(r?e[r-1].time:0))e.push(t);else{for(var a=r;--a>=0&&n<e[a].time;);e.splice(a+1,0,t)}},ui(on,[{key:"keys",get:function(){return this._keys}}]),on);ul([uu],_1.prototype,"_updateManager",void 0),ul([u_],_1.prototype,"_keys",void 0),ul([uu],_1.prototype,"_typeArray",void 0),ul([uu],_1.prototype,"_updateDispatch",void 0);var _2=((oo=(oi=function(e,t){this._updateManager=new uT,this._time=e,this._value=t}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},oo._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},ui(oi,[{key:"time",get:function(){return this._time},set:function(e){e!==this._time&&(this._time=e,this._updateManager.dispatch())}},{key:"value",get:function(){return this._value},set:function(e){e!==this._value&&(this._value=e,this._updateManager.dispatch())}}]),oi);ul([uu],_2.prototype,"_updateManager",void 0);var _3=(us(os=function(e){var t;return(t=_q.call(this,e)||this)._separateAxes=!1,t.sizeX=new _Z(new _1(new _2(0,0),new _2(1,1))),t.sizeY=new _Z(new _1(new _2(0,0),new _2(1,1))),t.sizeZ=new _Z(new _1(new _2(0,0),new _2(1,1))),t},_q),(ol=os.prototype)._updateShaderData=function(t){var r=null,n=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===e.ParticleCurveMode.TwoCurves&&o.mode===e.ParticleCurveMode.TwoCurves&&s.mode===e.ParticleCurveMode.TwoCurves:i.mode===e.ParticleCurveMode.TwoCurves;(c||l?i.mode===e.ParticleCurveMode.Curve&&o.mode===e.ParticleCurveMode.Curve&&s.mode===e.ParticleCurveMode.Curve:i.mode===e.ParticleCurveMode.Curve)&&(t.setFloatArray(os._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(t.setFloatArray(os._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(os._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(os._minCurveXProperty,i.curveMin._getTypeArray()),l&&(t.setFloatArray(os._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(os._minCurveZProperty,s.curveMin._getTypeArray())),a=os._isRandomTwoMacro),n=os._curveModeMacro),l&&(r=os._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(t,this._enableSeparateMacro,r),this._isCurveMacro=this._enableMacro(t,this._isCurveMacro,n),this._isRandomTwoMacro=this._enableMacro(t,this._isRandomTwoMacro,a)},ol._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ui(os,[{key:"separateAxes",get:function(){return this._separateAxes},set:function(e){e!==this._separateAxes&&(this._separateAxes=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"sizeX",get:function(){return this._sizeX},set:function(e){var t=this._sizeX;e!==t&&(this._sizeX=e,this._onCompositeCurveChange(t,e))}},{key:"sizeY",get:function(){return this._sizeY},set:function(e){var t=this._sizeY;e!==t&&(this._sizeY=e,this._onCompositeCurveChange(t,e))}},{key:"sizeZ",get:function(){return this._sizeZ},set:function(e){var t=this._sizeZ;e!==t&&(this._sizeZ=e,this._onCompositeCurveChange(t,e))}},{key:"size",get:function(){return this.sizeX},set:function(e){this.sizeX=e}}]),os);_3._curveModeMacro=uM.getByName("RENDERER_SOL_CURVE_MODE"),_3._isSeparateMacro=uM.getByName("RENDERER_SOL_IS_SEPARATE"),_3._isRandomTwoMacro=uM.getByName("RENDERER_SOL_IS_RANDOM_TWO"),_3._minCurveXProperty=uO.getByName("renderer_SOLMinCurveX"),_3._minCurveYProperty=uO.getByName("renderer_SOLMinCurveY"),_3._minCurveZProperty=uO.getByName("renderer_SOLMinCurveZ"),_3._maxCurveXProperty=uO.getByName("renderer_SOLMaxCurveX"),_3._maxCurveYProperty=uO.getByName("renderer_SOLMaxCurveY"),_3._maxCurveZProperty=uO.getByName("renderer_SOLMaxCurveZ"),ul([u_],_3.prototype,"_sizeX",void 0),ul([u_],_3.prototype,"_sizeY",void 0),ul([u_],_3.prototype,"_sizeZ",void 0),ul([uu],_3.prototype,"_enableSeparateMacro",void 0),ul([uu],_3.prototype,"_isCurveMacro",void 0),ul([uu],_3.prototype,"_isRandomTwoMacro",void 0);var _4=(us(oc=function(){var e;return e=_q.apply(this,arguments)||this,e.startFrame=new _Z(0),e.frameOverTime=new _Z(new _1(new _2(0,0),new _2(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new cZ(1,1,1),e._frameOverTimeRand=new ur(0,cL.TextureSheetAnimation),e._tiling=new c9(1,1),e},_q),(ou=oc.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.frameOverTime.mode;if(n===e.ParticleCurveMode.Curve||n===e.ParticleCurveMode.TwoCurves){var a=this.frameOverTime;t.setFloatArray(oc._frameMaxCurveProperty,a.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=oc._frameCurveMacro:(t.setFloatArray(oc._frameMinCurveProperty,a.curveMin._getTypeArray()),r=oc._frameRandomCurvesMacro),t.setFloat(oc._cycleCountProperty,this.cycleCount),t.setVector3(oc._tillingParamsProperty,this._tillingInfo)}}this._textureSheetMacro=this._enableMacro(t,this._textureSheetMacro,r)},ou._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,cL.TextureSheetAnimation)},ui(oc,[{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)}}]),oc);_4._frameCurveMacro=uM.getByName("RENDERER_TSA_FRAME_CURVE"),_4._frameRandomCurvesMacro=uM.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),_4._cycleCountProperty=uO.getByName("renderer_TSACycles"),_4._tillingParamsProperty=uO.getByName("renderer_TSATillingParams"),_4._frameMinCurveProperty=uO.getByName("renderer_TSAFrameMinCurve"),_4._frameMaxCurveProperty=uO.getByName("renderer_TSAFrameMaxCurve"),ul([u_],_4.prototype,"startFrame",void 0),ul([u_],_4.prototype,"frameOverTime",void 0),ul([uh],_4.prototype,"_tillingInfo",void 0),ul([uu],_4.prototype,"_frameOverTimeRand",void 0),ul([u_],_4.prototype,"_tiling",void 0),ul([uu],_4.prototype,"_textureSheetMacro",void 0),(od=cB||(cB={}))[od.WholeSheet=0]="WholeSheet",od[od.SingleRow=1]="SingleRow";var _8=(us(oh=function(t){var r;return(r=_q.call(this,t)||this)._velocityRand=new ur(0,cL.VelocityOverLifetime),r._velocityMinConstant=new cZ,r._velocityMaxConstant=new cZ,r._space=e.ParticleSimulationSpace.Local,r.velocityX=new _Z(0),r.velocityY=new _Z(0),r.velocityZ=new _Z(0),r},_q),(o_=oh.prototype)._updateShaderData=function(t){var r=null;if(this.enabled){var n=this.velocityX,a=this.velocityY,i=this.velocityZ,o=n.mode===e.ParticleCurveMode.TwoCurves&&a.mode===e.ParticleCurveMode.TwoCurves&&i.mode===e.ParticleCurveMode.TwoCurves;if(o||n.mode===e.ParticleCurveMode.Curve&&a.mode===e.ParticleCurveMode.Curve&&i.mode===e.ParticleCurveMode.Curve)t.setFloatArray(oh._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(oh._maxGradientYProperty,a.curveMax._getTypeArray()),t.setFloatArray(oh._maxGradientZProperty,i.curveMax._getTypeArray()),o?(t.setFloatArray(oh._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(oh._minGradientYProperty,a.curveMin._getTypeArray()),t.setFloatArray(oh._minGradientZProperty,i.curveMin._getTypeArray()),r=oh._randomCurveMacro):r=oh._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,a.constantMax,i.constantMax),t.setVector3(oh._maxConstantProperty,s),n.mode===e.ParticleCurveMode.TwoConstants&&a.mode===e.ParticleCurveMode.TwoConstants&&i.mode===e.ParticleCurveMode.TwoConstants){var l=this._velocityMinConstant;l.set(n.constantMin,a.constantMin,i.constantMin),t.setVector3(oh._minConstantProperty,l),r=oh._randomConstantMacro}else r=oh._constantMacro}t.setInt(oh._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},o_._resetRandomSeed=function(e){this._velocityRand.reset(e,cL.VelocityOverLifetime)},o_._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},ui(oh,[{key:"velocityX",get:function(){return this._velocityX},set:function(e){var t=this._velocityX;e!==t&&(this._velocityX=e,this._onCompositeCurveChange(t,e))}},{key:"velocityY",get:function(){return this._velocityY},set:function(e){var t=this._velocityY;e!==t&&(this._velocityY=e,this._onCompositeCurveChange(t,e))}},{key:"velocityZ",get:function(){return this._velocityZ},set:function(e){var t=this._velocityZ;e!==t&&(this._velocityZ=e,this._onCompositeCurveChange(t,e))}},{key:"space",get:function(){return this._space},set:function(e){e!==this._space&&(this._space=e,this._generator._renderer._onGeneratorParamsChanged())}},{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._generator._renderer._onGeneratorParamsChanged())}}]),oh);_8._constantMacro=uM.getByName("RENDERER_VOL_CONSTANT"),_8._curveMacro=uM.getByName("RENDERER_VOL_CURVE"),_8._randomConstantMacro=uM.getByName("RENDERER_VOL_RANDOM_CONSTANT"),_8._randomCurveMacro=uM.getByName("RENDERER_VOL_RANDOM_CURVE"),_8._minConstantProperty=uO.getByName("renderer_VOLMinConst"),_8._maxConstantProperty=uO.getByName("renderer_VOLMaxConst"),_8._minGradientXProperty=uO.getByName("renderer_VOLMinGradientX"),_8._minGradientYProperty=uO.getByName("renderer_VOLMinGradientY"),_8._minGradientZProperty=uO.getByName("renderer_VOLMinGradientZ"),_8._maxGradientXProperty=uO.getByName("renderer_VOLMaxGradientX"),_8._maxGradientYProperty=uO.getByName("renderer_VOLMaxGradientY"),_8._maxGradientZProperty=uO.getByName("renderer_VOLMaxGradientZ"),_8._spaceProperty=uO.getByName("renderer_VOLSpace"),ul([uu],_8.prototype,"_velocityRand",void 0),ul([uu],_8.prototype,"_velocityMinConstant",void 0),ul([uu],_8.prototype,"_velocityMaxConstant",void 0),ul([uu],_8.prototype,"_velocityMacro",void 0),ul([u_],_8.prototype,"_velocityX",void 0),ul([u_],_8.prototype,"_velocityY",void 0),ul([u_],_8.prototype,"_velocityZ",void 0);var _5=function(){function t(r){this.useAutoRandomSeed=!0,this.emission=new _J(this),this.rotationOverLifetime=new _0(this),this.colorOverLifetime=new _Q(this),this.textureSheetAnimation=new _4(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new dq(0,0,e.MeshTopology.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._renderer=r,new dY().start=0,this._primitive=new dQ(r.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,t._particleIncreaseCount),this.main=new _$(this),this.velocityOverLifetime=new _8(this),this.sizeOverLifetime=new _3(this),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(_W,t._tempParticleRenderers),n=0,a=r.length;n<a;n++)r[n].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(4294967295*Math.random()))},r.stop=function(r,n){if(void 0===r&&(r=!0),void 0===n&&(n=e.ParticleStopMode.StopEmitting),r)for(var a=this._renderer.entity.getComponentsIncludeChildren(_W,t._tempParticleRenderers),i=0,o=a.length;i<o;i++)a[i].generator.stop(!1,n);else if(this._isPlaying=!1,n===e.ParticleStopMode.StopEmittingAndClear){var s=this._firstFreeElement;this._firstRetiredElement=s,this._firstActiveElement=s,this._firstNewElement=s,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},r.emit=function(e){this._emit(this._playTime,e)},r._emit=function(e,r){if(this.emission.enabled&&!(this.main._maxParticleBuffer<this._currentParticleCount))for(var n=t._tempVector30,a=t._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<r;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,e,n,a);var l=this.main._getPositionScale();n.multiply(l),a.normalize().multiply(l)}else n.set(0,0,0),a.set(0,0,-1);this._addNewParticle(n,a,i,e)}},r._update=function(t){var r=this.isAlive,n=this.main,a=this.emission,i=n.duration,o=this._playTime;if(this._playTime+=t*n.simulationSpeed,this._retireActiveParticles(),this._freeRetiredParticles(),n.simulationSpace===e.ParticleSimulationSpace.World&&this._retireTransformedBounds(),a.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),a._emit(o,this._playTime),!n.isLoop&&this._playTime>i&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===e.ParticleSimulationSpace.World&&this._generateTransformedBounds();else{var s=Math.min(a._frameRateTime,Math.floor(this._playTime/i)*i);this._playTime-=s,a._frameRateTime-=s}this.isAlive!==r&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},r._reorganizeGeometryBuffers=function(){var t=this._renderer,r=t.engine._particleBufferUtils,n=this._primitive,a=this._vertexBufferBindings;if(n.clearVertexElements(),a.length=0,t.renderMode===e.ParticleRenderMode.Mesh){var i=t.mesh;if(!i)return;var o=i.getVertexElement(e.VertexAttribute.Position),s=i.getVertexElement(e.VertexAttribute.Color),l=i.getVertexElement(e.VertexAttribute.UV),c=o?i.vertexBufferBindings[o.bindingIndex]:null,u=s?i.vertexBufferBindings[s.bindingIndex]:null,d=l?i.vertexBufferBindings[l.bindingIndex]:null;if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,a);n.addVertexElement(new dV(e.VertexAttribute.Position,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,a);n.addVertexElement(new dV(e.VertexAttribute.Color,s.offset,s.format,_))}if(d){var f=this._addVertexBufferBindingsFilterDuplicate(d,a);n.addVertexElement(new dV(e.VertexAttribute.UV,l.offset,l.format,f))}var p=i._primitive.indexBufferBinding;n.setIndexBufferBinding(p),this._subPrimitive.count=p.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(r.billboardVertexElement),a.push(r.billboardVertexBufferBinding),n.setIndexBufferBinding(r.billboardIndexBufferBinding),this._subPrimitive.count=hZ.billboardIndexCount;n.setVertexBufferBindings(a);for(var m=r.instanceVertexElements,g=a.length,v=0,y=m.length;v<y;v++){var x=m[v];n.addVertexElement(new dV(x.attribute,x.offset,x.format,g,x.instanceStepRate))}},r._resizeInstanceBuffer=function(t,r){null==(h=this._instanceVertexBufferBinding)||h.buffer.destroy();var n=hZ.instanceVertexStride,a=t?this._currentParticleCount+r:this.main._maxParticleBuffer,i=n*a,o=this._renderer.engine,s=new dI(o,e.BufferBindFlag.VertexBuffer,i,e.BufferUsage.Dynamic,!1);s.isGCIgnored=!0;var l=this._primitive.vertexBufferBindings,c=new dJ(s,n),u=new Float32Array(i/4),d=this._instanceVertices;if(d){var h,_,f,p=hZ.instanceVertexFloatStride,m=this._firstFreeElement,g=this._firstRetiredElement;if(t){u.set(new Float32Array(d.buffer,0,m*p));var v=m+1,y=(v+r)*p;u.set(new Float32Array(d.buffer,v*p*4),y),this._firstNewElement>m&&(this._firstNewElement+=r),this._firstActiveElement>m&&(this._firstActiveElement+=r),g>m&&(this._firstRetiredElement+=r)}else g<=m?(_=m-g,f=0,this._firstFreeElement-=g,this._firstNewElement-=g,this._firstActiveElement-=g,this._firstRetiredElement=0):(_=this._currentParticleCount-g,f=m,this._firstNewElement>m&&(this._firstNewElement-=m),this._firstActiveElement>m&&(this._firstActiveElement-=m),g>m&&(this._firstRetiredElement-=m)),u.set(new Float32Array(d.buffer,g*p*4,_*p),f*p);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(d?l.length-1:l.length,c),this._instanceVertices=u,this._instanceVertexBufferBinding=c,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(),this.emission._destroy()},r._updateBoundsSimulationLocal=function(e){var t=this._renderer,r=this.main.startLifetime._getMax(),n=t._generatorBounds,a=t._transformedBounds;t._isContainDirtyFlag(cF.GeneratorVolume)&&(this._calculateGeneratorBounds(r,n),t._setDirtyFlagFalse(cF.GeneratorVolume)),t._isContainDirtyFlag(cF.TransformVolume)&&(this._calculateTransformedBounds(r,n,a),t._setDirtyFlagFalse(cF.TransformVolume)),this._addGravityToBounds(r,a,e)},r._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,r=this._firstActiveTransformedBoundingBox,n=this._firstFreeTransformedBoundingBox,a=r*hZ.boundsFloatStride;if(e.min.copyFromArray(t,a),e.max.copyFromArray(t,a+3),r<n)for(var i=r+1;i<n;i++)this._mergeTransformedBounds(i,e);else{for(var o=r+1,s=this._transformedBoundsCount;o<s;o++)this._mergeTransformedBounds(o,e);if(n>0)for(var l=0;l<n;l++)this._mergeTransformedBounds(l,e)}var c=this.main.startLifetime._getMax();this._addGravityToBounds(c,e,e)},r._freeBoundsArray=function(){this._transformedBoundsArray=null,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0},r._generateTransformedBounds=function(){var e=this._renderer,t=this.main.startLifetime._getMax(),r=e._generatorBounds;e._isContainDirtyFlag(cF.GeneratorVolume)&&(this._calculateGeneratorBounds(t,r),e._setDirtyFlagFalse(cF.GeneratorVolume));var n=hZ.boundsFloatStride,a=hZ.boundsTimeOffset,i=hZ.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(cF.TransformVolume)){var s=o+1;s>=this._transformedBoundsCount&&(s=0),s===this._firstActiveTransformedBoundingBox&&(this._resizeTransformedBoundsArray(),s=o+1);var l=e._transformedBounds;this._calculateTransformedBounds(t,r,l);var c=o*n,u=this._transformedBoundsArray;l.min.copyToArray(u,c),l.max.copyToArray(u,c+3),u[c+a]=this._playTime,u[c+i]=t,this._firstFreeTransformedBoundingBox=s,e._setDirtyFlagFalse(cF.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*hZ.boundsFloatStride+a]=this._playTime}},r._addNewParticle=function(r,n,a,i){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=a.worldPosition,s=a.worldRotationQuaternion);var h=u.startSpeed.evaluate(void 0,u._startSpeedRand.random()),_=this._instanceVertices,f=l*hZ.instanceVertexFloatStride;_[f]=r.x,_[f+1]=r.y,_[f+2]=r.z,_[f+hZ.startLifeTimeOffset]=u.startLifetime.evaluate(void 0,u._startLifeTimeRand.random()),_[f+4]=n.x,_[f+5]=n.y,_[f+6]=n.z,_[f+hZ.timeOffset]=i;var p=t._tempColor0;u.startColor.evaluate(void 0,u._startColorRand.random(),p),this._renderer.engine.settings.colorSpace===e.ColorSpace.Linear&&p.toLinear(p),_[f+8]=p.r,_[f+9]=p.g,_[f+10]=p.b,_[f+11]=p.a;var m=u._startSizeRand;if(u.startSize3D)_[f+12]=u.startSizeX.evaluate(void 0,m.random()),_[f+13]=u.startSizeY.evaluate(void 0,m.random()),_[f+14]=u.startSizeZ.evaluate(void 0,m.random());else{var g=u.startSize.evaluate(void 0,m.random());_[f+12]=g,_[f+13]=g,_[f+14]=g}var v=u._startRotationRand;u.startRotation3D?(_[f+15]=cQ.degreeToRadian(u.startRotationX.evaluate(void 0,v.random())),_[f+16]=cQ.degreeToRadian(u.startRotationY.evaluate(void 0,v.random())),_[f+17]=cQ.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random()))):_[f+15]=cQ.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random())),_[f+18]=h;var y=this.colorOverLifetime;y.enabled&&y.color.mode===e.ParticleGradientMode.TwoGradients&&(_[f+20]=y._colorGradientRand.random());var x=this.rotationOverLifetime;x.enabled&&x.rotationZ.mode===e.ParticleCurveMode.TwoConstants&&(_[f+22]=x._rotationRand.random());var b=this.textureSheetAnimation;b.enabled&&b.frameOverTime.mode===e.ParticleCurveMode.TwoCurves&&(_[f+23]=b._frameOverTimeRand.random());var T=this.velocityOverLifetime;if(T.enabled&&T.velocityX.mode===e.ParticleCurveMode.TwoConstants&&T.velocityY.mode===e.ParticleCurveMode.TwoConstants&&T.velocityZ.mode===e.ParticleCurveMode.TwoConstants){var C=T._velocityRand;_[f+24]=C.random(),_[f+25]=C.random(),_[f+26]=C.random()}if(this.main.simulationSpace===e.ParticleSimulationSpace.World&&(_[f+27]=o.x,_[f+28]=o.y,_[f+29]=o.z,_[f+30]=s.x,_[f+31]=s.y,_[f+32]=s.z,_[f+33]=s.w),this.textureSheetAnimation.enabled){var S=this.textureSheetAnimation._tillingInfo;_[f+hZ.simulationUVOffset]=S.x,_[f+35]=S.y,_[f+36]=0,_[f+37]=0}else _[f+hZ.simulationUVOffset]=1,_[f+35]=1,_[f+36]=0,_[f+37]=0;this._firstFreeElement=c},r._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var r=this._firstActiveElement*hZ.instanceVertexFloatStride,n=r+hZ.timeOffset;if(Math.fround(this._playTime-t[n])<t[r+hZ.startLifeTimeOffset])break;t[n]=e,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},r._freeRetiredParticles=function(){for(var e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var t=this._firstRetiredElement*hZ.instanceVertexFloatStride+hZ.startLifeTimeOffset;if(e-this._instanceVertices[t]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},r._addActiveParticlesToVertexBuffer=function(){var t=this._firstActiveElement,r=this._firstFreeElement;if(t!==r){var n=hZ.instanceVertexStride,a=t*n,i=this._instanceVertexBufferBinding.buffer,o=this._instanceVertices.buffer;if(t<r)i.setData(o,0,a,(r-t)*n,e.SetDataOptions.Discard);else{var s=(this._currentParticleCount-t)*n;i.setData(o,0,a,s,e.SetDataOptions.Discard),r>0&&i.setData(o,s,0,r*n)}this._firstNewElement=r,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},r._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return t.push(e),r},r._resizeTransformedBoundsArray=function(){var e=hZ.boundsFloatStride,r=t._transformedBoundsIncreaseCount;this._transformedBoundsCount+=r;var n=this._transformedBoundsArray,a=new Float32Array(this._transformedBoundsCount*e);if(n){var i=this._firstFreeTransformedBoundingBox;a.set(new Float32Array(n.buffer,0,i*e));var o=i+1,s=(o+r)*e;a.set(new Float32Array(n.buffer,o*e*4),s),this._firstActiveTransformedBoundingBox>i&&(this._firstActiveTransformedBoundingBox+=r)}this._transformedBoundsArray=a},r._retireTransformedBounds=function(){for(var e=hZ.boundsFloatStride,t=hZ.boundsTimeOffset,r=hZ.boundsMaxLifetimeOffset,n=this._transformedBoundsArray,a=this._firstFreeTransformedBoundingBox,i=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==a;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-n[o+t]<=n[o+r])break;++this._firstActiveTransformedBoundingBox>=i&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},r._calculateGeneratorBounds=function(r,n){var a=t._tempVector30,i=t._tempVector31,o=t._tempVector20,s=n.min,l=n.max,c=this.main,u=this.emission.shape;(null==u?void 0:u.enabled)?(u._getPositionRange(s,l),u._getDirectionRange(i,a)):(s.set(0,0,0),l.set(0,0,0),i.set(0,0,-1),a.set(0,0,0)),this._getExtremeValueFromZero(c.startSpeed,o);var d=o.x,h=o.y,_=i.x,f=i.y,p=i.z,m=a.x,g=a.y,v=a.z;s.set(s.x+Math.min(_*h,m*d)*r,s.y+Math.min(f*h,g*d)*r,s.z+Math.min(p*h,v*d)*r),l.set(l.x+Math.max(_*d,m*h)*r,l.y+Math.max(f*d,g*h)*r,l.z+Math.max(p*d,v*h)*r);var y=c.startSize._getMax();if(c.startSize3D){var x=c.startSizeY._getMax();y=this._renderer.renderMode===e.ParticleRenderMode.Billboard||e.ParticleRenderMode.StretchBillboard||e.ParticleRenderMode.HorizontalBillboard?Math.max(y,x):Math.max(y,x,c.startSizeZ._getMax())}y*=1.414;var b=this.sizeOverLifetime;if(b.enabled){var T=b.size._getMax();b.separateAxes&&(T=Math.max(T,b.sizeY._getMax(),b.sizeZ._getMax())),y*=T}s.set(s.x-y,s.y-y,s.z-y),l.set(l.x+y,l.y+y,l.z+y)},r._mergeTransformedBounds=function(e,t){var r=t.min,n=t.max,a=this._transformedBoundsArray,i=e*hZ.boundsFloatStride;r.set(Math.min(r.x,a[i]),Math.min(r.y,a[i+1]),Math.min(r.z,a[i+2])),n.set(Math.max(n.x,a[i+3]),Math.max(n.y,a[i+4]),Math.max(n.z,a[i+5]))},r._calculateTransformedBounds=function(r,n,a){var i=t._tempVector20,o=t._tempVector21,s=t._tempVector22,l=t._tempMat,c=this._renderer.entity.transform,u=c.worldPosition;c8.rotationQuaternion(c.worldRotationQuaternion,l);var d=n.min,h=n.max,_=a.min,f=a.max,p=this.velocityOverLifetime;p.enabled?(this._getExtremeValueFromZero(p.velocityX,i),this._getExtremeValueFromZero(p.velocityY,o),this._getExtremeValueFromZero(p.velocityZ,s),p.space===e.ParticleSimulationSpace.Local?(_.set(d.x+i.x*r,d.y+o.x*r,d.z+s.x*r),f.set(h.x+i.y*r,h.y+o.y*r,h.z+s.y*r),a.transform(l)):(a.transform(l),_.set(d.x+i.x*r,d.y+o.x*r,d.z+s.x*r),f.set(h.x+i.y*r,h.y+o.y*r,h.z+s.y*r))):c$.transform(n,l,a),_.add(u),f.add(u)},r._addGravityToBounds=function(e,r,n){var a=r.min,i=r.max,o=t._tempVector20;this._getExtremeValueFromZero(this.main.gravityModifier,o);var s=this._renderer.scene.physics.gravity,l=s.x,c=s.y,u=s.z,d=.5*e*e,h=o.x*d,_=o.y*d,f=l*h,p=l*_,m=c*h,g=c*_,v=u*h,y=u*_;n.min.set(Math.min(f,p)+a.x,Math.min(m,g)+a.y,Math.min(v,y)+a.z),n.max.set(Math.max(f,p)+i.x,Math.max(m,g)+i.y,Math.max(v,y)+i.z)},r._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},ui(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}();_5._tempVector20=new c9,_5._tempVector21=new c9,_5._tempVector22=new c9,_5._tempVector30=new cZ,_5._tempVector31=new cZ,_5._tempMat=new c8,_5._tempColor0=new c7,_5._tempParticleRenderers=[],_5._particleIncreaseCount=128,_5._transformedBoundsIncreaseCount=16,ul([u_],_5.prototype,"main",void 0),ul([u_],_5.prototype,"emission",void 0),ul([u_],_5.prototype,"velocityOverLifetime",void 0),ul([u_],_5.prototype,"sizeOverLifetime",void 0),ul([u_],_5.prototype,"rotationOverLifetime",void 0),ul([u_],_5.prototype,"colorOverLifetime",void 0),ul([u_],_5.prototype,"textureSheetAnimation",void 0),ul([uu],_5.prototype,"_playTime",void 0),ul([uu],_5.prototype,"_firstNewElement",void 0),ul([uu],_5.prototype,"_firstActiveElement",void 0),ul([uu],_5.prototype,"_firstFreeElement",void 0),ul([uu],_5.prototype,"_firstRetiredElement",void 0),ul([uu],_5.prototype,"_primitive",void 0),ul([uu],_5.prototype,"_vertexBufferBindings",void 0),ul([uu],_5.prototype,"_subPrimitive",void 0),ul([uu],_5.prototype,"_renderer",void 0),ul([uu],_5.prototype,"_isPlaying",void 0),ul([uu],_5.prototype,"_instanceBufferResized",void 0),ul([uu],_5.prototype,"_waitProcessRetiredElementCount",void 0),ul([uu],_5.prototype,"_instanceVertexBufferBinding",void 0),ul([uu],_5.prototype,"_instanceVertices",void 0),ul([uu],_5.prototype,"_transformedBoundsArray",void 0),ul([uu],_5.prototype,"_transformedBoundsCount",void 0),ul([uu],_5.prototype,"_firstActiveTransformedBoundingBox",void 0),ul([uu],_5.prototype,"_firstFreeTransformedBoundingBox",void 0);var _9=(us(of=function(e){var t;return(t=dk.call(this,e,u$.find("particle-shader"))||this).shaderData.setColor(dk._baseColorProp,new c7(1,1,1,1)),t.isTransparent=!0,t},dk),of.prototype.clone=function(){var e=new of(this._engine);return this.cloneTo(e),e},ui(of,[{key:"baseColor",get:function(){return this.shaderData.getColor(dk._baseColorProp)},set:function(e){var t=this.shaderData.getColor(dk._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(dk._baseTextureProp)},set:function(e){this.shaderData.setTexture(dk._baseTextureProp,e),e?this.shaderData.enableMacro(dk._baseTextureMacro):this.shaderData.disableMacro(dk._baseTextureMacro)}}]),of),_6=function(e,t){this.time=e,this.count=t};ul([u_],_6.prototype,"count",void 0);var _7=((om=(op=function(){this._updateManager=new uT,this._enabled=!0,this._randomDirectionAmount=0}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},om._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},ui(op,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._updateManager.dispatch())}},{key:"randomDirectionAmount",get:function(){return this._randomDirectionAmount},set:function(e){e!==this._randomDirectionAmount&&(this._randomDirectionAmount=e,this._updateManager.dispatch())}}]),op);ul([uu],_7.prototype,"_updateManager",void 0);var fe=((og=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},og.randomPointInsideUnitArcCircle=function(e,t,r){og.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},og.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},og.randomPointInsideUnitCircle=function(e,t){og.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},og._randomPointUnitSphere=function(e,t){var r=2*t.random()-1,n=t.random()*Math.PI*2,a=Math.sqrt(1-r*r);e.x=a*Math.cos(n),e.y=a*Math.sin(n),e.z=r},og._randomPointInsideUnitSphere=function(e,t){og._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},og._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},og);e.ParticleShapeType=void 0,(ov=e.ParticleShapeType||(e.ParticleShapeType={}))[ov.Box=0]="Box",ov[ov.Circle=1]="Circle",ov[ov.Cone=2]="Cone",ov[ov.Hemisphere=3]="Hemisphere",ov[ov.Sphere=4]="Sphere";var ft=(us(oy=function(){var t;return(t=_7.call(this)||this).shapeType=e.ParticleShapeType.Box,t._size=new cZ(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t},_7),(ox=oy.prototype)._generatePositionAndDirection=function(e,t,r,n){fe._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=oy._tempVector30;a.set(0,0,-1),fe._randomPointUnitSphere(n,e),cZ.lerp(a,n,this.randomDirectionAmount,n)},ox._getDirectionRange=function(e,t){var r=Math.PI*this.randomDirectionAmount;if(this.randomDirectionAmount<.5){var n=Math.sin(r);e.set(-n,-n,-1),t.set(n,n,0)}else{var a=Math.cos(r);e.set(-1,-1,-1),t.set(1,1,-a)}},ox._getPositionRange=function(e,t){var r=this._size,n=r.x,a=r.y,i=r.z;e.set(-(.5*n),-(.5*a),-(.5*i)),t.set(.5*n,.5*a,.5*i)},ui(oy,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),oy);ft._tempVector30=new cZ,ul([u_],ft.prototype,"_size",void 0),e.ParticleShapeArcMode=void 0,(ob=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[ob.Random=0]="Random",ob[ob.Loop=1]="Loop";var fr=(us(oT=function(){var t;return t=_7.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Circle,t._radius=1,t._arc=360,t._arcMode=e.ParticleShapeArcMode.Random,t._arcSpeed=1,t},_7),(oC=oT.prototype)._generatePositionAndDirection=function(t,r,n,a){var i=oT._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=cQ.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(t.random());break;case e.ParticleShapeArcMode.Random:fe.randomPointInsideUnitArcCircle(cQ.degreeToRadian(this.arc),i,t)}n.set(i.x,i.y,0),n.scale(this.radius),fe._randomPointUnitSphere(a,t),cZ.lerp(n,a,this.randomDirectionAmount,a)},oC._getDirectionRange=function(e,t){var r=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),n=.5*(360-this._arc)*this.randomDirectionAmount,a=n>90?-1:-Math.sin(n);this._getUnitArcRange(this._arc+n,e,t,a,r)},oC._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},oC._getUnitArcRange=function(e,t,r,n,a){var i=cQ.degreeToRadian(e),o=Math.sin(i);e<90?(t.set(0,n,-a),r.set(1,o,a)):(e<180?t.set(Math.cos(i),n,-a):e<270?t.set(-1,Math.min(o,n),-a):t.set(-1,-1,-a),r.set(1,1,a))},ui(oT,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"arc",get:function(){return this._arc},set:function(e){e!==this._arc&&(this._arc=e,this._updateManager.dispatch())}},{key:"arcMode",get:function(){return this._arcMode},set:function(e){e!==this._arcMode&&(this._arcMode=e,this._updateManager.dispatch())}},{key:"arcSpeed",get:function(){return this._arcSpeed},set:function(e){e!==this._arcSpeed&&(this._arcSpeed=e,this._updateManager.dispatch())}}]),oT);fr._tempPositionPoint=new c9;var fn=(us(oS=function(){var t;return t=_7.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t},_7),(oA=oS.prototype)._generatePositionAndDirection=function(e,t,r,n){var a=oS._tempVector20,i=cQ.degreeToRadian(this.angle),o=Math.sin(i),s=Math.cos(i);switch(this.emitType){case 0:fe.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var l=oS._tempVector21;fe.randomPointInsideUnitCircle(l,e),c9.lerp(a,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:fe.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0),n.set(a.x*o,a.y*o,-s),n.normalize();var c=oS._tempVector30;cZ.scale(n,this.length*e.random(),c),r.add(c);var u=oS._tempVector31;fe._randomPointUnitSphere(u,e),cZ.lerp(n,u,this.randomDirectionAmount,n)}},oA._getDirectionRange=function(e,t){var r=0;switch(this.emitType){case 0:r=cQ.degreeToRadian(this._angle);break;case 1:r=Math.sin(cQ.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var n=Math.sin(r);e.set(-n,-n,-1),t.set(n,n,0)},oA._getPositionRange=function(e,t){var r=this.radius;switch(this.emitType){case 0:e.set(-r,-r,0),t.set(r,r,0);break;case 1:var n=this.length,a=Math.sin(cQ.degreeToRadian(this._angle));e.set(-r-a*n,-r-a*n,-n),t.set(r+a*n,r+a*n,0)}},ui(oS,[{key:"angle",get:function(){return this._angle},set:function(e){e!==this._angle&&(this._angle=e,this._updateManager.dispatch())}},{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}},{key:"length",get:function(){return this._length},set:function(e){e!==this._length&&(this._length=e,this._updateManager.dispatch())}},{key:"emitType",get:function(){return this._emitType},set:function(e){e!==this._emitType&&(this._emitType=e,this._updateManager.dispatch())}}]),oS);fn._tempVector20=new c9,fn._tempVector21=new c9,fn._tempVector30=new cZ,fn._tempVector31=new cZ,e.ConeEmitType=void 0,(oM=e.ConeEmitType||(e.ConeEmitType={}))[oM.Base=0]="Base",oM[oM.Volume=1]="Volume";var fa=(us(oR=function(){var t;return t=_7.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Hemisphere,t._radius=1,t},_7),(oE=oR.prototype)._generatePositionAndDirection=function(e,t,r,n){fe._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var a=r.z;a>0&&(r.z=-a),fe._randomPointUnitSphere(n,e),cZ.lerp(r,n,this.randomDirectionAmount,n)},oE._getDirectionRange=function(e,t){var r=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,r)},oE._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,0)},ui(oR,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),oR),fi=(us(ow=function(){var t;return t=_7.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Sphere,t._radius=1,t},_7),(oP=ow.prototype)._generatePositionAndDirection=function(e,t,r,n){fe._randomPointInsideUnitSphere(r,e),r.scale(this.radius),fe._randomPointUnitSphere(n,e),cZ.lerp(r,n,this.randomDirectionAmount,n)},oP._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},oP._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,r)},ui(ow,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),ow);u$.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 fo=(us(oF=function(t){var r,n=(r=dN.call(this,t,u$.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},dN),oF),fs=new cZ,fl=(us(oL=function(e,t){(r=d0.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 cZ),r._pointStates.push(r._lifetime),r._strapPoints.push(new cZ),r._strapPoints.push(new cZ);r._curPointNum=0;var a=t.material||new fo(r.engine);return r.setMaterial(a),r.setTexture(t.texture),r._initGeometry(),r},d0),(oB=oL.prototype).update=function(e){for(var t=0,r=0,n=0;n<this._curPointNum;n++)this._pointStates[n]-=e,this._pointStates[n]<0?t++:t>0&&(r=n-t,this._pointStates[r]=this._pointStates[n],this._points[r].copyFrom(this._points[n]));this._curPointNum-=t;var a=!0;if(this._curPointNum===this._maxPointNum)a=!1;else if(this._curPointNum>0){var i=this._points[this._points.length-1];cZ.distance(this.entity.transform.worldPosition,i)<this._minSeg&&(a=!1)}a&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},oB.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},oB._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),d0.prototype._render.call(this,e)},oB._initGeometry=function(){var t=new d$(this._entity.engine),r=2*this._maxPointNum,n=20*r,a=new Float32Array(n),i=[new dV("POSITION",0,e.VertexElementFormat.Vector3,0),new dV("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new dI(this.engine,4*n,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(i),t.addSubMesh(0,r,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=a,this.mesh=t},oB._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new cZ(r[0],r[4],r[8]),a=new cZ(r[1],r[5],r[9]),i=new cZ(r[2],r[6],r[10]),o=this._stroke;a.scale(o);var s=new cZ,l=new cZ,c=new c4;cZ.transformByQuat(n,c,n),cZ.transformByQuat(a,c,a);var u=new cZ,d=new cZ,h=new cZ;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?cZ.subtract(p,t[f-1],h):cZ.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(cZ.dot(n,h));cZ.cross(n,h,d),0>=cZ.dot(d,i)&&(m=2*Math.PI-m),c4.rotationAxisAngle(i,m,c),cZ.transformByQuat(a,c,u),cZ.add(p,u,s),cZ.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}},oB._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,r=this._vertices,n=0;n<e;n++){var a=1-n*t,i=2*n*this._vertexStride/4,o=(2*n+1)*this._vertexStride/4;r[i]=0,r[i+1]=a,r[o]=1,r[o+1]=a}}},oB._projectOnVector=function(e,t,r){var n=t.clone();cZ.normalize(n,n);var a=cZ.dot(e,n);r.x=n.x*a,r.y=n.y*a,r.z=n.z*a},oB._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,fs),cZ.subtract(e,fs,r)},oL),fc=(us(oD=function(){var t;return t=_c.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},_c),(oI=oD.prototype).onTextureChange=function(e){},oI.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 di(this.engine,this.width,this.height,this._isCube?new dc(this.engine,this.width):new ds(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new di(this.engine,this.width,this.height,this._isCube?new dc(this.engine,this.width):new ds(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},oI.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},oI._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},ui(oD,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),oD),fu=new cZ,fd=new cZ,fh=new cZ,f_=(us(oO=function(){var e;return e=fc.apply(this,arguments)||this,e.position=new cZ(0,0,0),e._isCube=!0,e.oriViewMatrix=new c8,e},fc),(oV=oO.prototype).onBeginRender=function(t){if(this.enabled){fc.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),fc.prototype._reset.call(this)}},oV._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},oV._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},oV._setCamera=function(e,t){switch(e){case 0:fd.set(0,-1,0),fh.set(1,0,0);break;case 1:fd.set(0,-1,0),fh.set(-1,0,0);break;case 2:fd.set(0,0,1),fh.set(0,1,0);break;case 3:fd.set(0,0,-1),fh.set(0,-1,0);break;case 4:fd.set(0,-1,0),fh.set(0,0,1);break;case 5:fd.set(0,-1,0),fh.set(0,0,-1)}cZ.add(this.position,fh,fu),c8.lookAt(this.position,fu,fd,t.viewMatrix),t.fieldOfView=90},oO),ff=Object.freeze({__proto__:null,AmbientLight:h7,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:_S,AnimationClipCurveBinding:_T,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:_A,AnimationEvent:_C,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationRectCurve(){return e.AnimationRectCurve},get AnimationRefCurve(){return e.AnimationRefCurve},get AnimationStringCurve(){return e.AnimationStringCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:_L,AnimatorCondition:_R,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:_D,AnimatorControllerLayer:_N,AnimatorControllerParameter:_B,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorLayerMask:_U,AnimatorState:_O,AnimatorStateMachine:_V,AnimatorStateTransition:_E,AssetPromise:hx,get AssetType(){return e.AssetType},Background:h9,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:dk,BasicRenderPipeline:dC,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:dK,BlendShapeFrame:dj,BlendState:uY,BlinnPhongMaterial:dz,get BloomDownScaleMode(){return e.BloomDownScaleMode},BloomEffect:_i,BoolUpdateFlag:u9,BoxColliderShape:hW,BoxShape:ft,Buffer:dI,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:d$,get BufferUsage(){return e.BufferUsage},BufferUtil:dO,Burst:_6,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},get CameraType(){return e.CameraType},Canvas:h8,CapsuleColliderShape:hX,CharacterController:hL,CircleShape:fr,ClearableObjectPool:h2,CloneManager:uf,get Collider(){return e.Collider},ColliderShape:hH,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:_Q,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:u4,get ConeEmitType(){return e.ConeEmitType},ConeShape:fn,ContentRestorer:dR,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:f_,get CullMode(){return e.CullMode},CurveKey:_2,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:uq,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:_t,get Downsampling(){return e.Downsampling},DynamicCollider:hB,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:_J,Engine:h4,EngineObject:up,Entity:hs,EventDispatcher:uw,FixedJoint:hN,get FogMode(){return e.FogMode},Font:dF,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:_X,GradientColorKey:_K,HemisphereShape:fa,HingeJoint:hk,HitResult:hD,IndexBufferBinding:dX,get IndexFormat(){return e.IndexFormat},InputManager:hQ,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:hU,JointMotor:hG,Keyframe:_k,get Keys(){return e.Keys},get Layer(){return e.Layer},LayerPathMask:_z,Light:_e,Loader:_f,Logger:uI,get MSAASamples(){return e.MSAASamples},MainModule:_$,Material:dN,Mesh:dZ,MeshRenderer:d0,get MeshTopology(){return e.MeshTopology},ModelMesh:d2,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:dU,PBRMaterial:dG,PBRSpecularMaterial:dH,ParticleCompositeCurve:_Z,ParticleCompositeGradient:_Y,ParticleCurve:_1,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:_5,ParticleGradient:_j,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:_9,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:_W,get ParticleScaleMode(){return e.ParticleScaleMode},get ParticleShapeArcMode(){return e.ParticleShapeArcMode},get ParticleShapeType(){return e.ParticleShapeType},get ParticleSimulationSpace(){return e.ParticleSimulationSpace},get ParticleStopMode(){return e.ParticleStopMode},PhysicsMaterial:hI,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:hF,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:hK,get Platform(){return e.Platform},PointLight:_r,Pointer:hM,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:dQ,PrimitiveMesh:ha,Probe:fc,RasterState:uQ,ReferResource:um,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderQueue:dm,get RenderQueueType(){return e.RenderQueueType},RenderState:uJ,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:di,RenderTargetBlendState:uX,get Renderer(){return e.Renderer},get ReplacementFailureStrategy(){return e.ReplacementFailureStrategy},ResourceManager:hb,ReturnableObjectPool:hh,RotationOverLifetimeModule:_0,SafeLoopArray:hv,Scene:_l,SceneManager:hy,Script:_c,get SetDataOptions(){return e.SetDataOptions},Shader:u$,ShaderData:u2,ShaderFactory:uk,ShaderLib:uN,ShaderMacro:uM,ShaderMacroCollection:uR,ShaderPass:uj,get ShaderPlatformTarget(){return e.ShaderPlatformTarget},ShaderProperty:uO,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:uz,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:_3,Skin:hl,SkinnedMeshRenderer:hc,Sky:h5,SkyBoxMaterial:_G,SkyProceduralMaterial:_H,SphereColliderShape:hj,SphereShape:fi,SpotLight:_n,SpringJoint:hz,Sprite:uC,SpriteAtlas:ug,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:dM,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:da,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:_I,StaticCollider:hO,get StencilOperation(){return e.StencilOperation},StencilState:uZ,SubMesh:dq,SubPrimitive:dY,SubShader:uK,get SunMode(){return e.SunMode},SystemInfo:hw,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:dB,TextUtils:dw,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:u1,Texture2D:ds,Texture2DArray:dl,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:dc,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:_4,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:uV,TonemappingEffect:_o,get TonemappingMode(){return e.TonemappingMode},TrailMaterial:fo,TrailRenderer:fl,Transform:u6,UnlitMaterial:dW,Utils:uv,VelocityOverLifetimeModule:_8,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:dJ,VertexElement:dV,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},XRManager:h3,_PostProcessManager:_s,assignmentClone:ud,deepClone:u_,dependentComponents:u5,ignoreClone:uu,request:_h,resourceLoader:hT,shallowClone:uh});function fp(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 fm(e,t,r){return t&&fp(e.prototype,t),r&&fp(e,r),e}function fg(e,t){return(fg=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fv(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&&fg(e,t)}function fy(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oN=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oN.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oN[oN.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oN[oN.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oN[oN.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oN[oN.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oN[oN.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oN[oN.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oN[oN.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oN[oN.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oN[oN.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oN[oN.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oN[oN.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oN[oN.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oN[oN.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oN[oN.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oN[oN.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oN[oN.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oN[oN.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oN[oN.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oN[oN.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oN[oN.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oN[oN.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oN[oN.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oN[oN.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oN[oN.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oN[oN.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oN[oN.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oN[oN.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oN[oN.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oN[oN.R11_EAC=37488]="R11_EAC",oN[oN.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oN[oN.RG11_EAC=37490]="RG11_EAC",oN[oN.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oN[oN.RGB8_ETC2=37492]="RGB8_ETC2",oN[oN.SRGB8_ETC2=37493]="SRGB8_ETC2",oN[oN.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oN[oN.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oN[oN.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oN[oN.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oN[oN.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oN[oN.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oN[oN.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oN[oN.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oN[oN.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oN[oN.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oN[oN.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oN[oN.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oN[oN.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oN[oN.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oN[oN.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oN[oN.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var fx=(fv(ok=function(e){(t=h8.call(this)||this)._scale=new c9;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},h8),(oz=ok.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!fy(t,OffscreenCanvas)){var r=t.clientWidth*e,n=t.clientHeight*e;this.width=r,this.height=n}},oz.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},oz._onWidthChanged=function(e){this._webCanvas.width=e},oz._onHeightChange=function(e){this._webCanvas.height=e},fm(ok,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&fy(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&&fy(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),ok),fb=(fv(oU=function(){return h4.apply(this,arguments)},h4),oU.create=function(e){var t=e.canvas,r=new fx("string"==typeof t?document.getElementById(t):t),n=new fB(e.graphicDeviceOptions),a=new oU(r,n,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new _l(a,"DefaultScene")),a})},fm(oU,[{key:"canvas",get:function(){return this._canvas}}]),oU);function fT(){return(fT=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 fC=((oH=(oG=function(t,r,n,a,i){void 0===a&&(a=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,a),c=r===e.BufferBindFlag.VertexBuffer?o.ARRAY_BUFFER:o.ELEMENT_ARRAY_BUFFER;this._gl=o,this._glBuffer=s,this._glBufferUsage=l,this._glBindTarget=c,this._isWebGL2=t.isWebGL2,this.bind(),i?o.bufferData(c,i,l):o.bufferData(c,n,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},oH.setData=function(t,r,n,a,i,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=r.BYTES_PER_ELEMENT||1,u=i?c*i:r.byteLength;if(0!==a||u<r.byteLength){var d=void 0!==r.byteOffset;if(this._isWebGL2&&d)s.bufferSubData(l,n,r,a,u/c);else{var h=new Uint8Array(d?r.buffer:r,a*c,u);s.bufferSubData(l,n,h)}}else s.bufferSubData(l,n,r);s.bindBuffer(l,null)},oH.getData=function(e,t,r,n){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,r,n)}else throw"Buffer is write-only on WebGL1.0 platforms."},oH.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},oH._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}},oG),fS=((oj=(oW=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oj.canIUseCompressedTextureInternalFormat=function(t){var r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,a=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR,o=e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,s=e.GLCompressedTextureInternalFormat.R11_EAC,l=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC,c=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,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>=a&&t<=i?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=u?this.canIUse(e.GLCapabilityType.pvrtc):t>=d&&t<=h?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},oj._init=function(){var t=this.capabilityList,r=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),a=e.GLCapabilityType.shaderVertexID,i=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,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,b=e.GLCapabilityType.pvrtc_webkit,T=e.GLCapabilityType.s3tc,C=e.GLCapabilityType.s3tc_webkit,S=e.GLCapabilityType.bptc,A=e.GLCapabilityType.textureFloat,M=e.GLCapabilityType.textureHalfFloat,R=e.GLCapabilityType.textureFloatLinear,E=e.GLCapabilityType.textureHalfFloatLinear,w=e.GLCapabilityType.WEBGL_colorBufferFloat,P=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,L=e.GLCapabilityType.textureFilterAnisotropic,B=e.GLCapabilityType.fragDepth;t.set(a,r),t.set(i,r||!!n(i)),t.set(o,r||!!n(o)),t.set(s,r||!!n(s)),t.set(l,r||!!n(l)),t.set(c,r||!!n(c)),t.set(u,r||!!n(u)),t.set(d,r),t.set(h,r||!!n(h)),t.set(_,r||!!n(_)),t.set(A,r||!!n(A)),t.set(M,r||!!n(M)),t.set(R,!!n(R)),t.set(E,r||!!n(E)),t.set(P,r&&!!n(P)||!!n(w)),t.set(F,r&&!!n(P)||!!n(F)),t.set(L,!!n(L)),t.set(B,r||!!n(B)),t.set(f,!!(n(f)||n(p))),t.set(m,!!(n(m)||n(g))),t.set(v,!!(n(v)||n(y))),t.set(x,!!(n(x)||n(b))),t.set(T,!!(n(T)||n(C))),t.set(S,!!n(S))},oj._compatibleInterface=function(e,t){var r=this.rhi,n=r.gl,a=null;if(a=r.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?n[i]=o.bind(a):n[i]=o}},oj._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,r=e.GLCapabilityType.vertexArrayObject,n=e.GLCapabilityType.instancedArrays,a=e.GLCapabilityType.drawBuffers,i=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat,c=e.GLCapabilityType.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(c,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(r,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var 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(a,fT({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(i,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},fm(oW,[{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}}]),oW),fA=((oK=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]},oK),fM=((oY=(oX=function(t,r){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=r,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._isSupportVAO=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var r=this._gl,n=this._primitive,a=this._isSupportVAO&&n.enableVAO;if(a){n._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);r.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=n.indexBufferBinding,s=n.instanceCount,l=n._glIndexType,c=n._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)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 uI.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)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);a?r.bindVertexArray(null):this._disableAttrib()},oY.destroy=function(){this._isSupportVAO&&this._clearVAO()},oY._bindBufferAndAttrib=function(e){var t,r,n=this._gl,a=this._primitive,i=a.vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=a._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var d=i[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 uI.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},oY._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},oY._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)},oY._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},oX),fR=((oq=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]},oq),fE=((oZ=(oQ=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},oZ.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},oZ.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},oZ._bind=function(){this._rhi.bindTexture(this)},oZ._init=function(t){var r=this._gl,n=this._isWebGL2,a=this._formatDetail,i=a.internalFormat,o=a.baseFormat,s=a.dataType,l=this._texture,c=l.mipmapCount,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,i,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,i,p,p,0,o,s,null);else if(_)r.texImage2D(this._target,0,i,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,i,v,y,0,o,s,null)}},oZ._getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),i>0&&!this._isWebGL2&&(i=0,uI.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,i):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,i),s.readPixels(t,r,n,a,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},oZ._setWrapMode=function(t,r){var n=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===e.TextureWrapMode.Clamp||oQ._isPowerOf2(s)&&oQ._isPowerOf2(l)||(uI.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=e.TextureWrapMode.Clamp),t){case e.TextureWrapMode.Clamp:n.texParameteri(i,r,n.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:n.texParameteri(i,r,n.REPEAT);break;case e.TextureWrapMode.Mirror:n.texParameteri(i,r,n.MIRRORED_REPEAT)}},oZ._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},oQ._isPowerOf2=function(e){return(e&e-1)==0},oQ._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.R11G11B10_UFloat:return{internalFormat:n?r.R11F_G11F_B10F:r.NONE,baseFormat:r.RGB,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:n?r.RGBA16F:r.RGBA,baseFormat:r.RGBA,dataType:r.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:n?r.RGBA32F:r.RGBA,baseFormat:r.RGBA,dataType:r.FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32_UInt:return{internalFormat:n?r.RGBA32UI:r.NONE,baseFormat:r.RGBA_INTEGER,dataType:r.UNSIGNED_INT,isCompressed:!1};case e.TextureFormat.BC1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.BC3:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case e.TextureFormat.BC7:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case e.TextureFormat.ETC1_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,isCompressed:!0};case e.TextureFormat.ETC2_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC,isCompressed:!0};case e.TextureFormat.PVRTC_RGB2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGB4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.ASTC_4x4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,isCompressed:!0};case e.TextureFormat.ASTC_5x5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,isCompressed:!0};case e.TextureFormat.ASTC_6x6:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,isCompressed:!0};case e.TextureFormat.ASTC_8x8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,isCompressed:!0};case e.TextureFormat.ASTC_10x10:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,isCompressed:!0};case e.TextureFormat.ASTC_12x12:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,isCompressed:!0};case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:n?r.DEPTH_COMPONENT16:r.DEPTH_COMPONENT,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oQ._getRenderBufferDepthFormatDetail=function(t,r,n){switch(t){case e.TextureFormat.Depth:return{internalFormat:n?r.DEPTH_COMPONENT32F:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:n?r.FLOAT:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:n?r.DEPTH32F_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:n?r.FLOAT_32_UNSIGNED_INT_24_8_REV:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Stencil:return{internalFormat:r.STENCIL_INDEX8,baseFormat:r.STENCIL_ATTACHMENT,dataType:r.UNSIGNED_BYTE,isCompressed:!1,attachment:r.STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r.DEPTH_COMPONENT16,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_SHORT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:n?r.DEPTH24_STENCIL8:r.DEPTH_STENCIL,baseFormat:r.DEPTH_STENCIL,dataType:r.UNSIGNED_INT_24_8,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:r.DEPTH_COMPONENT24,baseFormat:r.DEPTH_COMPONENT,dataType:r.UNSIGNED_INT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:r.DEPTH_COMPONENT32F,baseFormat:r.DEPTH_COMPONENT,dataType:r.FLOAT,isCompressed:!1,attachment:r.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:r.DEPTH32F_STENCIL8,baseFormat:r.DEPTH_STENCIL,dataType:r.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:r.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},oQ._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.R11G11B10_UFloat:case e.TextureFormat.R32G32B32A32_UInt:case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return r.isWebGL2}return!0},oQ._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);break;case e.TextureFormat.R11G11B10_UFloat:n=r.isWebGL2}return n},oQ._supportRenderBufferDepthFormat=function(t,r){if(!r.isWebGL2)switch(t){case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return!1}return!0},fm(oQ,[{key:"wrapModeU",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_S)}},{key:"wrapModeV",set:function(e){this._bind(),this._setWrapMode(e,this._gl.TEXTURE_WRAP_T)}},{key:"filterMode",set:function(t){var r=this._gl,n=this._target,a=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.NEAREST_MIPMAP_NEAREST:r.NEAREST);break;case e.TextureFilterMode.Bilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_NEAREST:r.LINEAR);break;case e.TextureFilterMode.Trilinear:r.texParameteri(n,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(n,r.TEXTURE_MIN_FILTER,a?r.LINEAR_MIPMAP_LINEAR:r.LINEAR)}}},{key:"anisoLevel",set:function(e){var t=this._gl;this._bind(),t.texParameterf(this._target,t.TEXTURE_MAX_ANISOTROPY_EXT,e)}},{key:"depthCompareFunction",set:function(t){this._bind();var r=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NEVER);break;case e.TextureDepthCompareFunction.Less:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LESS);break;case e.TextureDepthCompareFunction.Equal:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.GEQUAL);break;case e.TextureDepthCompareFunction.Always:r.texParameteri(this._target,r.TEXTURE_COMPARE_FUNC,r.ALWAYS)}}}]),oQ),fw=((o$=(oJ=function(t,r){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=r;for(var n=r._colorTextures,a=r._depth,i=r.width,o=r.height,s=fy(a,u1),l=0,c=n.length;l<c;l++){var u=n[l]._format;if(!fE._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!fE._supportRenderBufferDepthFormat(a,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[a]+" in RenderTarget");if(n.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==i||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(a.width!==i||a.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return fy(e,dc)}))throw Error("MRT+Cube+[,MSAA] is not supported");var d=t.capability.maxAntiAliasing;r.antiAliasing>d&&(uI.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).activeRenderTarget=function(e,t){var r=this._gl,n=this._target;r.bindFramebuffer(r.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=n.getColorTexture(0);if(o){var s=fy(o,dc);(a||s&&i)&&r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,s?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=n.depthTexture;if(l){var c=fy(l,dc);if(a||c){var u=l._platformTexture;r.framebufferTexture2D(r.FRAMEBUFFER,u._formatDetail.attachment,c?r.TEXTURE_CUBE_MAP_POSITIVE_X+t:r.TEXTURE_2D,u._glTexture,e)}}else if(a){var d=fE._getRenderBufferDepthFormatDetail(n._depth,r,this._isWebGL2).internalFormat;r.bindRenderbuffer(r.RENDERBUFFER,this._depthRenderBuffer),r.renderbufferStorage(r.RENDERBUFFER,d,n.width>>e,n.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&r.bindFramebuffer(r.FRAMEBUFFER,this._MSAAFrameBuffer)},o$.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),r=this._target,n=r.colorTextureCount,a=r.width,i=r.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<n;o++){var s=e.COLOR_ATTACHMENT0+o;this._blitDrawBuffers[o]=s,e.readBuffer(s),e.drawBuffers(this._blitDrawBuffers),e.blitFramebuffer(0,0,a,i,0,0,a,i,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},o$.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},o$._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,r=this._target,n=r._depth,a=r.colorTextureCount,i=r.width,o=r.height,s=Array(a);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<a;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,fy(c,dc)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(fy(n,u1)&&!fy(n,dc)){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=fE._getRenderBufferDepthFormatDetail(n,e,t),_=h.internalFormat,f=h.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,i,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},o$._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,r=e.createRenderbuffer(),n=this._target,a=n._depth,i=n.colorTextureCount,o=n.antiAliasing,s=n.width,l=n.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=r,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<i;c++){var 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!==a){var d=fy(a,u1)?a._platformTexture._formatDetail:fE._getRenderBufferDepthFormatDetail(a,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)},o$._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.")},oJ),fP=(fv(o0=function(t,r){(n=fE.call(this,t,r,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var n,a=r.format,i=r._mipmap,o=r.width,s=r.height,l=n._isWebGL2;if(!fE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||fE._isPowerOf2(o)&&fE._isPowerOf2(s)||(uI.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=fE._getFormatDetail(a,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},fE),(o1=o0.prototype).setPixelBuffer=function(e,t,r,n,a,i){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,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(a=a||_-r,i=i||f-n,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),h){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,r,n,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,r,n,a,i,u,d,e)},o1.setImageSource=function(t,r,n,a,i,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,+a),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,r,c,u,d,t):s.texSubImage2D(this._target,r,i||0,o||0,u,d,t)},o1.getPixelBuffer=function(e,t,r,n,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fE.prototype._getPixelBuffer.call(this,null,e,t,r,n,a,i)},o0),fF=(fv(o2=function(t,r){n=fE.call(this,t,r,t.gl.TEXTURE_2D_ARRAY)||this;var n,a=r.format,i=r.width,o=r.height,s=r.length,l=r.mipmapCount;if(!n._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!fE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return n._bind(),n._formatDetail=fE._getFormatDetail(a,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,i,o,s),n},fE),(o3=o2.prototype).setPixelBuffer=function(e,t,r,n,a,i,o,s){var l=this._target,c=this._gl,u=this._formatDetail,d=u.internalFormat,h=u.baseFormat,_=u.dataType,f=u.isCompressed;i=i||Math.max(1,this._texture.width>>r)-n,o=o||Math.max(1,this._texture.height>>r)-a,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,r,n,a,e,i,o,s,d,t):c.texSubImage3D(l,r,n,a,e,i,o,s,h,_,t)},o3.setImageSource=function(e,t,r,n,a,i,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,+a),c.texSubImage3D(this._target,r,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},o3.getPixelBuffer=function(e,t,r,n,a,i,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,i,e),s.readPixels(t,r,n,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},o2),fL=(fv(o4=function(t,r){(n=fE.call(this,t,r,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var n,a=r.format,i=r._mipmap,o=r.width,s=n._isWebGL2;if(!fE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||fE._isPowerOf2(o)||(uI.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=fE._getFormatDetail(a,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},fE),(o8=o4.prototype).setPixelBuffer=function(e,t,r,n,a,i,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(i=i||f-n,o=o||f-a,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<r;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,u,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,n,a,i,o,d,h,t)},o8.setImageSource=function(e,t,r,n,a,i,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,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,r,i||0,o||0,c,u,t)},o8.getPixelBuffer=function(e,t,r,n,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fE.prototype._getPixelBuffer.call(this,e,t,r,n,a,i,o)},o4);e.WebGLMode=void 0,(o5=e.WebGLMode||(e.WebGLMode={}))[o5.Auto=0]="Auto",o5[o5.WebGL2=1]="WebGL2",o5[o5.WebGL1=2]="WebGL1";var fB=((o6=(o9=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new c6(null,null,null,null),this._lastScissor=new c6(null,null,null,null),this._lastClearColor=new c7(null,null,null,null),this._scissorEnable=!1;var r=fT({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(hw.platform===e.Platform.IPhone||hw.platform===e.Platform.IPad){var n=hw.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var a=parseInt(n[1]),i=parseInt(n[2]);15===a&&i>=0&&i<=4&&(r._forceFlush=!0)}}this._options=r,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).init=function(e,t,r){var n,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=r,i.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),i.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),i.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=i,(0==o||1==o)&&((n=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&fy(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,n&&!n.deleteQuery&&(this._isWebGL2=!1)),n||0!=o&&2!=o||((n=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&fy(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},o6.createPlatformPrimitive=function(e){return new fM(this,e)},o6.createPlatformTexture2D=function(e){return new fP(this,e)},o6.createPlatformTexture2DArray=function(e){return new fF(this,e)},o6.createPlatformTextureCube=function(e){return new fL(this,e)},o6.createPlatformRenderTarget=function(e){return new fw(this,e)},o6.createPlatformBuffer=function(t,r,n,a){return void 0===n&&(n=e.BufferUsage.Static),new fC(this,t,r,n,a)},o6.requireExtension=function(e){return this._extensions.requireExtension(e)},o6.canIUse=function(e){return this.capability.canIUse(e)},o6.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},o6.viewport=function(e,t,r,n){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||r!==i.z||n!==i.w)&&(a.viewport(e,t,r,n),i.set(e,t,r,n))},o6.scissor=function(e,t,r,n){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||r!==i.z||n!==i.w){var o=this._webCanvas;0===e&&0===t&&r===o.width&&n===o.height?this._scissorEnable&&(a.disable(a.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(a.enable(a.SCISSOR_TEST),this._scissorEnable=!0),a.scissor(e,t,r,n)),i.set(e,t,r,n)}},o6.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},o6.clearRenderTarget=function(t,r,n){var a=this._gl,i=t._lastRenderState,o=i.blendState.targetBlendState,s=i.depthState,l=i.stencilState,c=0;if(r&e.CameraClearFlags.Color){c|=a.COLOR_BUFFER_BIT;var 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)&&(a.clearColor(d,h,_,f),u.set(d,h,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(a.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}r&e.CameraClearFlags.Depth&&(c|=a.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(a.depthMask(!0),s.writeEnabled=!0)),r&e.CameraClearFlags.Stencil&&(c|=a.STENCIL_BUFFER_BIT,255!==l.writeMask&&(a.stencilMask(255),l.writeMask=255)),a.clear(c)},o6.drawPrimitive=function(e,t,r){e?e.draw(r,t):uI.error("draw primitive failed.")},o6.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},o6.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},o6.activeRenderTarget=function(e,t,r,n,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(n,a),i=e.width>>n,o=e.height>>n}else{var s=this._gl;s.bindFramebuffer(s.FRAMEBUFFER,this._mainFrameBuffer),i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight()}var l=i*t.z,c=o*t.w,u=t.x*i,d=r?t.y*o:o-t.y*o-c;this.viewport(u,d,l,c),this.scissor(u,d,l,c)},o6.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},o6.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)},o6.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},o6.flush=function(){this._gl.flush()},o6.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},o6.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},o6.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)},o6._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new fR(e),this._extensions=new fA(this),this._capability=new fS(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},o6.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},o6._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},o6._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},o6._onWebGLContextRestored=function(e){this._onDeviceRestored()},fm(o9,[{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}}]),o9);function fD(){return(fD=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 fI(e,t){return(fI=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fO(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&&fI(e,t)}function fV(e,t,r,n){var a,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,r,o):a(t,r))||o);return i>3&&o&&Object.defineProperty(t,r,o),o}function fN(e,t){var r,n,a,i,o=function(e){return function(t){return s([e,t])}},s=function(o){if(r)throw TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,n=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(a=(a=l.trys).length>0&&a[a.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){l.label=o[1];break}if(6===o[0]&&l.label<a[1]){l.label=a[1],a=o;break}if(a&&l.label<a[2]){l.label=a[2],l.ops.push(o);break}a[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}},l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i}function fk(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 fz(e,t,r){return t&&fk(e.prototype,t),r&&fk(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var fU=((se=(o7=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},se.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},se.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},se.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},se.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},se.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},se.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},se.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},se.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},se.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},se.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,uv.decodeText(t)},se.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},se.nextImagesData=function(e){for(var t=Array(e),r=0;r<e;r++){var n=this._dataView.getUint32(this._position,this._littleEndian);t[r]=n,this._position+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._position,o);this._position+=o,a.push(s)}return a},se.skip=function(e){return this._position+=e,this},se.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)},fz(o7,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),o7),fG={};function fH(e){return function(t){fG[e]=t}}var fW=((st=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint8(4),a=t.getUint16(5,!0),i=new Uint8Array(e,7,a),o=t.getUint16(7+a,!0),s=new Uint8Array(e,9+a,o),l=uv.decodeText(s),c=uv.decodeText(i),u=new st;return u.totalLength=r,u.name=l,u.type=c,u.version=n,u.headerLength=s.byteLength+i.byteLength+9,u},fz(st,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),st);function fj(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c6(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function fK(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new cZ(e[3*n],e[3*n+1],e[3*n+2]);return r}function fX(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c9(e[2*n],e[2*n+1]);return r}function fY(e,t,r){return(fY=!function(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}()?function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&fI(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((sr=function(){}).decode=function(e,t){return new Promise(function(r){var n=new d2(e),a=JSON.parse(t.nextStr());a.bounds&&n.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4)+t.data.byteOffset,o=t.data.buffer,s=new Float32Array(o,a.positions.start+i,(a.positions.end-a.positions.start)/4),l=s.length/3,c=fK(s,l);if(n.setPositions(c),a.normals){var u=fK(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);n.setNormals(u)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);n.setUVs(fX(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);n.setUVs(fX(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);n.setUVs(fX(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);n.setUVs(fX(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);n.setUVs(fX(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);n.setUVs(fX(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);n.setUVs(fX(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);n.setUVs(fX(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);n.setColors(function(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c7(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);n.setBoneWeights(fj(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);n.setBoneIndices(fj(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new dK(e.name);e.frames.forEach(function(e){var r=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),n=r.length/3,a=fK(r,n);e.deltaNormals&&fK(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&fj(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),n),t.addFrame(e.weight,a)}),n.addBlendShape(t)}),a.indices){var T=null;T=0===a.indices.type?new Uint16Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i,(a.indices.end-a.indices.start)/4),n.setIndices(T)}a.subMeshes.forEach(function(e){return n.addSubMesh(e)}),n.uploadData(!1),r(n)})},sr),e.MeshDecoder=fV([fH("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((sn=function(){}).decode=function(e,t){return new Promise(function(r,n){var a=t.nextStr(),i=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),d=t.nextUint16(),h=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),m=new ds(e,d,h,u,i);if(m.filterMode=o,m.anisoLevel=s,m.wrapModeU=l,m.wrapModeV=c,_){var g=p[0];if(m.setPixelBuffer(g),i){m.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];m.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=m,r(m)}else{var x=new window.Blob([p[0]]),b=new Image;b.onload=function(){m.setImageSource(b);var e=0,t=function(){++e>=f&&r(m)};if(t(),i){var n=function(e){var r=new window.Blob([p[e]]),n=new Image;n.onload=function(){m.setImageSource(n,e),t()},n.src=URL.createObjectURL(r)};m.generateMipmaps();for(var a=1;a<f;a++)n(a)}},b.src=URL.createObjectURL(x)}})},sn),e.Texture2DDecoder=fV([fH("Texture2D")],e.Texture2DDecoder),e.ParserType=void 0,(sa=e.ParserType||(e.ParserType={}))[sa.Prefab=0]="Prefab",sa[sa.Scene=1]="Scene";var fq=((si=function(e,t,r){void 0===t&&(t=1),this.engine=e,this.type=t,this.resource=r,this.entityMap=new Map,this.entityConfigMap=new Map,this.components=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=e.resourceManager}).prototype.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},si),fQ=((ss=(so=function(e){this._context=e}).prototype).parseEntity=function(t){var r=this;return this._getEntityByConfig(t).then(function(n){n.isActive=null==(a=t.isActive)||a;var a,i,o=t.position,s=t.rotation,l=t.scale;return o&&n.transform.position.copyFrom(o),s&&n.transform.rotation.copyFrom(s),l&&n.transform.scale.copyFrom(l),n.layer=null!=(i=t.layer)?i:n.layer,r._context.type===e.ParserType.Prefab&&n._markAsTemplate(r._context.resource),n})},ss.parseClassObject=function(e){var t,r=this,n=_f.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return fY(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},ss.parsePropsAndMethods=function(e,t){var r=[];if(t.methods)for(var n in t.methods)for(var a=t.methods[n],i=0,o=a.length;i<o;i++)r.push(this.parseMethod(e,n,a[i]));if(t.props){var s=this,l=function(n){var a=t.props[n],i=s.parseBasicType(a,e[n]).then(function(t){return e[n]=t});r.push(i)};for(var c in t.props)l(c)}return Promise.all(r).then(function(){var r=so.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},ss.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))})},ss.parseBasicType=function(t,r){var n=this;if(Array.isArray(t))return Promise.all(t.map(function(e){return n.parseBasicType(e)}));if("object"==typeof t&&null!=t){if(so._isClass(t))return this.parseClassObject(t);if(so._isAssetRef(t)){var a=this._context;return a.resourceManager.getResourceByRef(t).then(function(t){return a.type===e.ParserType.Prefab&&a.resource._addDependenceAsset(t),t})}if(so._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));if(r){var i=this,o=function(e){if("methods"===e){var n=t[e];for(var a in n)for(var o=n[a],l=0,c=o.length;l<c;l++){var u=o[l];s.push(i.parseMethod(r,a,u))}}else s.push(i.parseBasicType(t[e],r[e]).then(function(t){return r[e]=t}))},s=[];for(var l in t)o(l);return Promise.all(s).then(function(){return r})}}return Promise.resolve(t)},ss._getEntityByConfig=function(t){var r=this,n=t.assetRefId,a=this._context.engine;return n?a.resourceManager.getResourceByRef({refId:n,key:t.key,isClone:t.isClone}).then(function(i){var o=a.resourceManager._objectPool[n];return r._context.type===e.ParserType.Prefab&&r._context.resource._addDependenceAsset(o),i.name=t.name,i}):Promise.resolve(new hs(a,t.name))},so.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},so._isClass=function(e){return void 0!=e.class},so._isAssetRef=function(e){return void 0!=e.refId},so._isEntityRef=function(e){return void 0!=e.entityId},so);function fZ(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function fJ(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 f$(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 fJ(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 fJ(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.")}fQ.customParseComponentHandles=new Map,e.InterpolableValueType=void 0,(sl=e.InterpolableValueType||(e.InterpolableValueType={}))[sl.Float=0]="Float",sl[sl.FloatArray=1]="FloatArray",sl[sl.Vector2=2]="Vector2",sl[sl.Vector3=3]="Vector3",sl[sl.Vector4=4]="Vector4",sl[sl.Quaternion=5]="Quaternion",sl[sl.Color=6]="Color",sl[sl.Array=7]="Array",sl[sl.Boolean=8]="Boolean",sl[sl.Rect=9]="Rect",sl[sl.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((sc=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),a=new _S(n),i=r.nextUint16(),o=0;o<i;++o){var s=new _C;s.time=r.nextFloat32(),s.functionName=r.nextStr(),s.parameter=JSON.parse(r.nextStr()).val,a.addEvent(s)}for(var l=r.nextUint16(),c=0;c<l;++c){var u=r.nextStr(),d=r.nextStr(),h=_f.getClass(d),_=r.nextStr(),f=r.nextStr(),p=void 0,m=r.nextUint8(),g=r.nextUint16();switch(r.nextStr()){case"AnimationFloatCurve":(p=new e.AnimationFloatCurve).interpolation=m;for(var v=0;v<g;++v){var y=new _k;y.time=r.nextFloat32(),y.value=r.nextFloat32(),y.inTangent=r.nextFloat32(),y.outTangent=r.nextFloat32(),p.addKey(y)}break;case"AnimationArrayCurve":(p=new e.AnimationArrayCurve).interpolation=m;for(var x=0;x<g;++x){var b=new _k;b.time=r.nextFloat32();var T=r.nextUint16();b.value=Array.from(r.nextFloat32Array(T)),b.inTangent=Array.from(r.nextFloat32Array(T)),b.outTangent=Array.from(r.nextFloat32Array(T)),p.addKey(b)}break;case"AnimationFloatArrayCurve":(p=new e.AnimationFloatArrayCurve).interpolation=m;for(var C=0;C<g;++C){var S=new _k;S.time=r.nextFloat32();var A=r.nextUint16();S.value=r.nextFloat32Array(A),S.inTangent=Array.from(r.nextFloat32Array(A)),S.outTangent=Array.from(r.nextFloat32Array(A)),p.addKey(S)}break;case"AnimationVector2Curve":(p=new e.AnimationVector2Curve).interpolation=m;for(var M=0;M<g;++M){var R=new _k;R.time=r.nextFloat32(),R.value=new c9(r.nextFloat32(),r.nextFloat32()),R.inTangent=new c9(r.nextFloat32(),r.nextFloat32()),R.outTangent=new c9(r.nextFloat32(),r.nextFloat32()),p.addKey(R)}break;case"AnimationVector3Curve":(p=new e.AnimationVector3Curve).interpolation=m;for(var E=0;E<g;++E){var w=new _k;w.time=r.nextFloat32(),w.value=new cZ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new cZ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new cZ(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(w)}break;case"AnimationVector4Curve":(p=new e.AnimationVector4Curve).interpolation=m;var P=new _k;P.time=r.nextFloat32(),P.value=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(P);break;case"AnimationColorCurve":(p=new e.AnimationColorCurve).interpolation=m;for(var F=0;F<g;++F){var L=new _k;L.time=r.nextFloat32(),L.value=new c7(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(L)}break;case"AnimationQuaternionCurve":(p=new e.AnimationQuaternionCurve).interpolation=m;for(var B=0;B<g;++B){var D=new _k;D.time=r.nextFloat32(),D.value=new c4(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.inTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.outTangent=new c6(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(D)}break;case"AnimationRefCurve":(p=new e.AnimationRefCurve).interpolation=m;for(var I=0;I<g;++I){var O=new _k;O.time=r.nextFloat32();var V=r.nextStr();V?O.value=JSON.parse(V):O.value=null,p.addKey(O)}break;case"AnimationBoolCurve":(p=new e.AnimationBoolCurve).interpolation=m;for(var N=0;N<g;++N){var k=new _k;k.time=r.nextFloat32(),k.value=1===r.nextUint8(),p.addKey(k)}break;case"AnimationStringCurve":(p=new e.AnimationStringCurve).interpolation=m;for(var z=0;z<g;++z){var U=new _k;U.time=r.nextFloat32(),U.value=r.nextStr(),p.addKey(U)}}a.addCurveBinding(u,h,_,f,p)}t(a)})},sc),e.AnimationClipDecoder=fV([fH("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(su=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",su.Custom="Custom";var f0=(fO(sd=function(e,t){var r;return(r=um.call(this,e)||this).url=t,r._dependenceAssets=new Set,r},um),(sh=sd.prototype).instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},sh._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},sh._onDestroy=function(){var e=this;um.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(t){t._disassociationSuperResource(e)})},sd),f1=((sf=(s_=function(e,t){var r=this;this.data=e,this.context=t,this._prefabContextMap=new WeakMap,this._prefabPromiseMap=new Map,this._engine=this.context.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._parsePrefabModification=this._parsePrefabModification.bind(this),this._parsePrefabRemovedEntities=this._parsePrefabRemovedEntities.bind(this),this._parsePrefabRemovedComponents=this._parsePrefabRemovedComponents.bind(this),this._clearAndResolve=this._clearAndResolve.bind(this),this.promise=new Promise(function(e,t){r._reject=t,r._resolve=e}),this._reflectionParser=new fQ(t)}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._parsePrefabModification).then(this._parsePrefabRemovedEntities).then(this._parsePrefabRemovedComponents).then(this._clearAndResolve).then(this._resolve).catch(this._reject)},sf._parseEntities=function(){var e=this,t=this.data.entities,r=this.context.entityConfigMap,n=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var n,i=null!=(n=t.strippedId)?n:t.id;return t.id=i,r.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var r=0,a=e.length;r<a;r++)n.set(t[r].id,e[r]);return e})},sf._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,r=this.context.components,n=[],a=0,i=e.length;a<i;a++)for(var o=e[a],s=t.get(o.id),l=0;l<o.components.length;l++){var c=o.components[l],u=c.refId?c.refId:c.class,d=s.addComponent(_f.getClass(u));r.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);n.push(h)}return Promise.all(n)},sf._parsePrefabModification=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.modifications;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.target,n=t.props,a=t.methods,i=r.entityId,o=r.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(i),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:n,methods:a}):l?Promise.resolve(e._applyEntityData(l,n)):void 0})))}}(a);return Promise.all(n)},sf._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedEntities;if(null==l?void 0:l.length){var c=r.get(s);n.push.apply(n,[].concat(l.map(function(t){var r=t.entityId,n=e._prefabContextMap.get(c).entityMap.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},sf._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,r=this.context.entityMap,n=[],a=0,i=t.length;a<i;a++)!function(a,i){var o=t[a],s=o.id,l=o.removedComponents;if(null==l?void 0:l.length){var c=r.get(s);n.concat.apply(n,[].concat(l.map(function(t){var r=t.componentId,n=e._prefabContextMap.get(c).components.get(r);n&&n.destroy()})))}}(a);return Promise.all(n)},sf._organizeEntities=function(){for(var e,t=this.context,r=t.rootIds,n=t.strippedIds,a=r.concat(n),i=f$(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<r.length;s++)this._handleRootEntity(r[s])},sf._getEntityByConfig=function(e,t){var r=this;return(e.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return r._applyEntityData(t,e)})},sf._parseEntity=function(e,t){var r=new hs(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(r)},sf._parsePrefab=function(t,r){var n=this,a=t.assetRefId;return r.resourceManager.getResourceByRef({refId:a}).then(function(a){var i=fZ(a,f0)?a.instantiate():a.instantiateSceneRoot(),o=new fq(r,e.ParserType.Prefab,null);t.parent||n.context.rootIds.push(t.id),n._generateInstanceContext(i,o,""),n._prefabContextMap.set(i,o);var s=n._prefabPromiseMap.get(t.id);if(s)for(var l=0,c=s.length;l<c;l++)s[l].resolve(o);return i})},sf._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(r,n){var a,i=null!=(a=t._prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:r,reject:n}),t._prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var r=e.prefabSource.entityId;return t.entityMap.get(r)})},sf._parseChildren=function(e){var t=this.context,r=t.entityConfigMap,n=t.entityMap,a=r.get(e).children;if(a&&a.length>0)for(var i=n.get(e),o=0;o<a.length;o++){var s=a[o],l=n.get(s);i.addChild(l),this._parseChildren(s)}},sf._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(r=t.isActive)?r:e.isActive,e.name=null!=(n=t.name)?n:e.name;var r,n,a=t.position,i=t.rotation,o=t.scale,s=t.layer;return a&&e.transform.position.copyFrom(a),i&&e.transform.rotation.copyFrom(i),o&&e.transform.scale.copyFrom(o),s&&(e.layer=s),e},sf._generateInstanceContext=function(e,t,r){var n=t.entityMap,a=t.components,i={},o={};n.set(r,e),e._components.forEach(function(t){var n=_f.getClassName(t.constructor);i[n]||(i[n]=e.getComponents(t.constructor,[]),o[n]=0),a.set(r+":"+n+"/"+o[n]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],u=r?r+"/"+s:""+s;this._generateInstanceContext(c,t,u)}},s_),f2=(fO(sp=function(e,t,r){var n;return(n=f1.call(this,e,t)||this).scene=r,n},f1),(sm=sp.prototype)._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},sm._clearAndResolve=function(){return this.context.clear(),this.scene},sp.parse=function(t,r){var n=new _l(t),a=new fq(t,e.ParserType.Scene,n),i=new sp(r,a,n);return i.start(),i.promise.then(function(){return n})},sp);function f3(e,t){var r=fW.decode(e),n=new fU(new Uint8Array(e),r.headerLength,r.dataLength);return fG[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.MeshLoader=(fO(sg=function(){return _f.apply(this,arguments)},_f),sg.prototype.load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"arraybuffer"})).then(function(e){f3(e,t.engine).then(function(e){n(e)})}).catch(a)})},sg),e.MeshLoader=fV([hT("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(fO(sv=function(){return _f.apply(this,arguments)},_f),sv.prototype.load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"arraybuffer"})).then(function(e){f3(e,t.engine).then(function(e){n(e)})}).catch(a)})},sv),e.EditorTextureLoader=fV([hT("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var f4=(fO(sy=function(){return _f.apply(this,arguments)},_f),(sx=sy.prototype).load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"arraybuffer"})).then(function(e){return f3(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return r._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){n(e)})}).catch(a)}).catch(a)})},sx._parseKeyframeValue=function(e,t){var r=e.value;return"object"==typeof r&&(null==r?void 0:r.refId)?new Promise(function(n){t.getResourceByRef(r).then(function(t){e.value=t,n(e.value)})}):Promise.resolve(e.value)},sy);f4=fV([hT(e.AssetType.AnimationClip,["ani"])],f4);var f8=(fO(sb=function(){return _f.apply(this,arguments)},_f),(sT=sb.prototype).load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"json"})).then(function(e){var a=new _D(t.engine),i=e.layers,o=e.parameters,s=[];i.forEach(function(e,n){var i=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new _N(i);if(u.blendingMode=o,u.weight=l,c){var d=c.states,h=c.transitions,_=c.entryTransitions,f=c.anyTransitions,p=u.stateMachine,m={},g={};d.forEach(function(e,r){var a=e.id,i=e.name,o=e.speed,l=e.wrapMode,c=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,d=e.clip,h=e.scripts,_=p.addState(i);_.speed=o,_.wrapMode=l,_.clipStartTime=c,_.clipEndTime=u,h.forEach(function(e){_.addStateMachineScript(_f.getClass(e))}),m[a]=_,d&&s.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:n,stateIndex:r,clip:t})})}))}),h.forEach(function(e){var t=r._createTransition(e,m[e.destinationStateId]);g[e.id]=t}),d.forEach(function(e){var t=e.id;e.transitions.forEach(function(e){var r=g[e];r&&m[t].addTransition(r)})}),_.forEach(function(e){p.addEntryStateTransition(r._createTransition(e,m[e.destinationStateId]))}),f.forEach(function(e){p.addAnyStateTransition(r._createTransition(e,m[e.destinationStateId]))})}a.addLayer(u)}),o.forEach(function(e){a.addParameter(e.name,e.defaultValue)}),Promise.all(s).then(function(e){e.forEach(function(e){var t=e.layerIndex,r=e.stateIndex,n=e.clip;a.layers[t].stateMachine.states[r].clip=n}),n(a)})}).catch(a)})},sT._createTransition=function(e,t){var r=new _E;return r.duration=e.duration,r.offset=e.offset,r.exitTime=e.exitTime,r.solo=e.solo,r.mute=e.mute,r._isExit=e.isExit,r.destinationState=t,e.conditions.forEach(function(e){r.addCondition(e.mode,e.parameterName,e.threshold)}),r},sb);f8=fV([hT(e.AssetType.AnimatorController,["json"],!1)],f8);var f5=(fO(sC=function(){return _f.apply(this,arguments)},_f),sC.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new hx(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,fD({},e,{type:"arraybuffer"}))},sC);f5=fV([hT(e.AssetType.Buffer,["bin","r3bin"],!1)],f5);var f9=(fO(sS=function(){return _f.apply(this,arguments)},_f),sS.prototype.load=function(t,r){var n=this;return new hx(function(a,i){n.request(t.url,fD({},t,{type:"arraybuffer"})).then(function(t){var n=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=r.engine,s=new dc(o,i);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var d=i>>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 h7(o),m=new ut;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(n),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,a(p)}).catch(function(e){i(e)})})},sS);function f6(e,t,r,n,a,i,o){try{var s=e[i](o),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,a)}function f7(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var i=e.apply(t,r);function o(e){f6(i,n,a,o,s,"next",e)}function s(e){f6(i,n,a,o,s,"throw",e)}o(void 0)})}}f9=fV([hT(e.AssetType.Env,["env"])],f9);var pe=(fO(sA=function(){return _f.apply(this,arguments)},_f),(sM=sA.prototype).load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?r._registerFont(i,o).then(function(){n(new dF(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):n(new dF(t.engine,i))}).catch(function(e){a(e)})})},sM._registerFont=function(e,t){return f7(function(){var r;return fN(this,function(n){switch(n.label){case 0:return[4,(r=new FontFace(e,"url("+t+")")).load()];case 1:return n.sent(),document.fonts.add(r),[2]}})})()},sA);pe=fV([hT(e.AssetType.Font,["font"],!1)],pe);var pt=(fO(sR=function(e,t){var r;return(r=um.call(this,e)||this).url=t,r},um),(sE=sR.prototype).instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},sE._onDestroy=function(){um.prototype._onDestroy.call(this);var e=this.textures,t=this.materials,r=this.meshes;if(e&&this._disassociationSuperResource(e),t&&this._disassociationSuperResource(t),r)for(var n=0,a=r.length;n<a;n++)this._disassociationSuperResource(r[n])},sE._disassociationSuperResource=function(e){for(var t=0,r=e.length;t<r;t++)e[t]._disassociationSuperResource(this)},fz(sR,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),sR);(sw=cD||(cD={}))[sw.BYTE=5120]="BYTE",sw[sw.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",sw[sw.SHORT=5122]="SHORT",sw[sw.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",sw[sw.UNSIGNED_INT=5125]="UNSIGNED_INT",sw[sw.FLOAT=5126]="FLOAT",e.AccessorType=void 0,(sP=e.AccessorType||(e.AccessorType={})).SCALAR="SCALAR",sP.VEC2="VEC2",sP.VEC3="VEC3",sP.VEC4="VEC4",sP.MAT2="MAT2",sP.MAT3="MAT3",sP.MAT4="MAT4",(sF=cI||(cI={})).TRANSLATION="translation",sF.ROTATION="rotation",sF.SCALE="scale",sF.WEIGHTS="weights",(sL=cO||(cO={})).Linear="LINEAR",sL.Step="STEP",sL.CubicSpine="CUBICSPLINE",(sB=cV||(cV={})).PERSPECTIVE="perspective",sB.ORTHOGRAPHIC="orthographic",(sD=cN||(cN={})).JPEG="image/jpeg",sD.PNG="image/png",(sI=ck||(ck={})).OPAQUE="OPAQUE",sI.MASK="MASK",sI.BLEND="BLEND",(sO=cz||(cz={}))[sO.NEAREST=9728]="NEAREST",sO[sO.LINEAR=9729]="LINEAR",(sV=cU||(cU={}))[sV.NEAREST=9728]="NEAREST",sV[sV.LINEAR=9729]="LINEAR",sV[sV.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sV[sV.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sV[sV.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sV[sV.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sN=cG||(cG={}))[sN.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sN[sN.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sN[sN.REPEAT=10497]="REPEAT";var pr=((sz=(sk=function(e,t,r){var n=this;this.glTFResource=e,this.resourceManager=t,this.params=r,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,r){var a,i=(a=n._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=r,n._setTaskDetailProgress(e,t,r)},this.contentRestorer=new pg(e)}).prototype).get=function(e,t){var r=this,n=sk._parsers[e];if(!n)return Promise.resolve(null);var a=this._resourceCache,i=void 0===t?""+e:e+":"+t,o=a.get(i);if(o)return o;var s=pa[e],l=!!pi[e];if(s){var c=this.glTF[s];c&&(void 0===t||c[t])?void 0===t?o=8===e?c.map(function(t,n){return r.get(e,n)}):Promise.all(c.map(function(t,n){return r.get(e,n)})):(o=n.parse(this,t),l&&this._handleSubAsset(o,e,t)):o=Promise.resolve(null)}else o=n.parse(this,t),l&&this._handleSubAsset(o,e,t);return a.set(i,o),o},sz.parse=function(){var e=this,t=this.get(0).then(function(t){return e.glTF=t,e.needAnimatorController=!!(t.skins||t.animations),Promise.all([e.get(1),e.get(5),e.get(6),e.get(7),e.get(9),e.get(10),e.get(11),e.get(2)]).then(function(){var t=e.glTFResource,r=t.animatorController;return r&&(t._defaultSceneRoot.addComponent(_L).animatorController=r),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},sz._addTaskCompletePromise=function(e){var t=this,r=this._progress.taskComplete;r.total+=1,e.then(function(){t._setTaskCompleteProgress(++r.loaded,r.total)})},sz._handleSubAsset=function(e,t,r){var n,a=this,i=pi[t];if(8===t)((n=this.glTFResource)[i]||(n[i]=[]))[r]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==r?a.glTFResource[i]=e:((n=a.glTFResource)[i]||(n[i]=[]))[r]=e,7===t)for(var n,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+r+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===r?"":"["+r+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===r&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},sk.addParser=function(e,t){this._parsers[e]=t},sk);pr._parsers={};var pn=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(sU=e.GLTFParserType||(e.GLTFParserType={}))[sU.Schema=0]="Schema",sU[sU.Validator=1]="Validator",sU[sU.Scene=2]="Scene",sU[sU.Buffer=3]="Buffer",sU[sU.BufferView=4]="BufferView",sU[sU.Texture=5]="Texture",sU[sU.Material=6]="Material",sU[sU.Mesh=7]="Mesh",sU[sU.Entity=8]="Entity",sU[sU.Skin=9]="Skin",sU[sU.Animation=10]="Animation",sU[sU.AnimatorController=11]="AnimatorController";var pa=((cH={})[2]="scenes",cH[3]="buffers",cH[5]="textures",cH[6]="materials",cH[7]="meshes",cH[8]="nodes",cH[9]="skins",cH[10]="animations",cH[4]="bufferViews",cH),pi=((cW={})[2]="_sceneRoots",cW[5]="textures",cW[6]="materials",cW[7]="meshes",cW[8]="entities",cW[9]="skins",cW[10]="animations",cW[11]="animatorController",cW);function po(e){return function(t){var r=new t;pr.addParser(e,r)}}var ps=((sG=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new c9(e[n],e[n+1]);return r},sG.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new cZ(e[n],e[n+1],e[n+2]);return r},sG.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new c6(e[n],e[n+1],e[n+2],e[n+3]);return r},sG.floatBufferToColorArray=function(e,t){var r=e.length,n=Array(r/(t?3:4));if(t)for(var a=0;a<r;a+=3)n[a/3]=new c7(e[a],e[a+1],e[a+2],1);else for(var i=0;i<r;i+=4)n[i/4]=new c7(e[i],e[i+1],e[i+2],e[i+3]);return n},sG.getAccessorTypeSize=function(t){switch(t){case e.AccessorType.SCALAR:return 1;case e.AccessorType.VEC2:return 2;case e.AccessorType.VEC3:return 3;case e.AccessorType.VEC4:case e.AccessorType.MAT2:return 4;case e.AccessorType.MAT3:return 9;case e.AccessorType.MAT4:return 16}},sG.getComponentType=function(e){switch(e){case cD.BYTE:return Int8Array;case cD.UNSIGNED_BYTE:return Uint8Array;case cD.SHORT:return Int16Array;case cD.UNSIGNED_SHORT:return Uint16Array;case cD.UNSIGNED_INT:return Uint32Array;case cD.FLOAT:return Float32Array}},sG.getNormalizedComponentScale=function(e){switch(e){case cD.BYTE:return 1/127;case cD.UNSIGNED_BYTE:return 1/255;case cD.SHORT:return 1/32767;case cD.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},sG.getAccessorBuffer=function(t,r,n){var a,i=n.componentType,o=sG.getComponentType(i),s=sG.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];a=t.get(e.GLTFParserType.BufferView,n.bufferView).then(function(e){var r,a,_,f=h.buffer,p=null!=(r=e.byteOffset)?r:0,m=null!=(a=n.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+i+":"+v+":"+u,x=t.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,T=u*(g/l),C=new o(e.buffer,b,T);x[y]=_=new pn(C,!0,g),_.restoreInfo=new pT(new pC(f,o,b,T))}}else{var S=p+m,A=u*s,M=new o(e.buffer,S,A);(_=new pn(M,!1,c)).restoreInfo=new pT(new pC(f,o,S,A))}return _})}else{var _=u*s,f=new o(_),p=new pn(f,!1,c);p.restoreInfo=new pT(new pC(void 0,o,void 0,_)),a=Promise.resolve(p)}return n.sparse?a.then(function(e){return sG.processingSparseData(t,n,e).then(function(){return e})}):a},sG.bufferToVector3Array=function(e,t,r,n,a){for(var i=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?sG.getNormalizedComponentScale(a):1,c=0;c<r;c++){var u=i+c*o;s[c]=new cZ(e[u]*l,e[u+1]*l,e[u+2]*l)}return s},sG.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},sG.processingSparseData=function(t,r,n){var a=n.restoreInfo,i=t.glTF.bufferViews,o=sG.getAccessorTypeSize(r.type),s=sG.getComponentType(r.componentType),l=n.data.slice(),c=r.sparse,u=c.count,d=c.indices,h=c.values,_=i[d.bufferView],f=i[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,i,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!=(i=h.byteOffset)?i:0)+(null!=(c=m.byteOffset)?c:0),x=m.byteLength;a.typeSize=o,a.sparseCount=u;var b=sG.getComponentType(d.componentType),T=v/b.BYTES_PER_ELEMENT,C=new b(p.buffer,g,T);a.sparseIndices=new pC(_.buffer,b,g,T);var S=x/s.BYTES_PER_ELEMENT,A=new s(m.buffer,y,S);a.sparseValues=new pC(f.buffer,s,y,S);for(var M=0;M<u;M++)for(var R=C[M],E=0;E<o;E++)l[R*o+E]=A[M*o+E];n.data=l})},sG.getIndexFormat=function(t){switch(t){case cD.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case cD.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case cD.UNSIGNED_INT:return e.IndexFormat.UInt32}},sG.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==cD.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==cD.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==cD.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==cD.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==cD.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},sG.loadImageBuffer=function(e,t){return new Promise(function(r,n){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){n(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){r(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},sG.parseGLB=function(e,t){var r={JSON:1313821514,BIN:5130562},n=new DataView(t),a={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==a.magic)return{originBuffer:t};var i=n.getUint32(12,!0),o=n.getUint32(16,!0);if(o!==r.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+o.toString(16)),null;for(var s=new Uint8Array(t,20,i),l=JSON.parse(uv.decodeText(s)),c=[],u=20+i,d=e.contentRestorer.glbBufferSlices;u<a.length;){if(i=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+i);c.push(_),d.push(new c9(h,i)),u+=i+8}return{glTF:l,buffers:c}},sG.parseSampler=function(e,t){var r=t.filterMode,n=t.wrapModeU,a=t.wrapModeV;void 0!==r&&(e.filterMode=r),void 0!==n&&(e.wrapModeU=n),void 0!==a&&(e.wrapModeV=a)},sG.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=cU.NEAREST_MIPMAP_NEAREST,n===cz.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=cU.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},sG);(sH=cj||(cj={}))[sH.linear=1]="linear",sH[sH.sRGB=2]="sRGB",(sW=cK||(cK={}))[sW.ETC1S=163]="ETC1S",sW[sW.UASTC=166]="UASTC",(sj=cX||(cX={}))[sj.None=0]="None",sj[sj.BasisLZ=1]="BasisLZ",sj[sj.Zstd=2]="Zstd",sj[sj.ZLib=3]="ZLib";var pl=((sK=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 fU(e,12);this.vkFormat=n.nextUint32(),this.typeSize=n.nextUint32(),this.pixelWidth=n.nextUint32(),this.pixelHeight=n.nextUint32(),this.pixelDepth=n.nextUint32(),this.layerCount=n.nextUint32(),this.faceCount=n.nextUint32();var a=Math.max(1,n.nextUint32());this.supercompressionScheme=n.nextUint32();var i=n.nextUint32(),o=n.nextUint32(),s=n.nextUint32(),l=n.nextUint32(),c=n.nextUint64(),u=n.nextUint64(),d=Array(a),h=24*a,_=new fU(e,n.offset,h);this.levels=d;for(var f=0;f<a;f++)d[f]={levelData:new Uint8Array(t,r+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new fU(e,i,o),m={vendorId:p.skip(4).nextUint16(),descriptorType:p.nextUint16(),versionNumber:p.nextUint16(),descriptorBlockSize:p.nextUint16(),colorModel:p.nextUint8(),colorPrimaries:p.nextUint8(),transferFunction:p.nextUint8(),flags:p.nextUint8(),texelBlockDimension:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],bytesPlane:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],samples:[]};this.dataFormatDescriptor=m;for(var g=(m.descriptorBlockSize/4-6)/4,v=0;v<g;v++){var y={bitOffset:p.nextUint16(),bitLength:p.nextUint8(),channelType:p.nextUint8(),samplePosition:[p.nextUint8(),p.nextUint8(),p.nextUint8(),p.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&y.channelType?(y.sampleLower=p.nextInt32(),y.sampleUpper=p.nextInt32()):(y.sampleLower=p.nextUint32(),y.sampleUpper=p.nextUint32()),m.samples[v]=y}for(var x=new fU(e,s,l,!0);x.position<l;){var b=x.nextUint32(),T=x.scan(b),C=uv.decodeText(T),S=x.nextUint8Array(b-T.byteLength-1);this.keyValue[C]=C.match(/^ktx/i)?uv.decodeText(S).replace(/^(.*)\x00$/,"$1"):S;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var M=new fU(e,c,u,!0),R=M.nextUint16(),E=M.nextUint16(),w=M.nextUint32(),P=M.nextUint32(),F=M.nextUint32(),L=M.nextUint32(),B=Array(a),D=0;D<a;D++)B[D]={imageFlags:M.nextUint32(),rgbSliceByteOffset:M.nextUint32(),rgbSliceByteLength:M.nextUint32(),alphaSliceByteOffset:M.nextUint32(),alphaSliceByteLength:M.nextUint32()};var I=c+M.position,O=I+w,V=O+P,N=V+F,k=new Uint8Array(t,r+I,w),z=new Uint8Array(t,r+O,P),U=new Uint8Array(t,r+V,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:R,selectorCount:E,imageDescs:B,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},fz(sK,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sK);e.KTX2TargetFormat=void 0,(sX=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sX.ASTC=0]="ASTC",sX[sX.BC7=1]="BC7",sX[sX.BC1_BC3=2]="BC1_BC3",sX[sX.PVRTC=3]="PVRTC",sX[sX.ETC=4]="ETC",sX[sX.R8=5]="R8",sX[sX.R8G8=6]="R8G8",sX[sX.R8G8B8A8=7]="R8G8B8A8";var pc=((sq=(sY=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)},sq.postMessage=function(e){var t=this;return new Promise(function(r,n){var a=t._getIdleWorkerId();if(-1!==a){t._workerStatus|=1<<a;var i,o=t._workerItems;Promise.resolve(null!=(i=o[a])?i:t._initWorker(a)).then(function(){var t=o[a];t.resolve=r,t.reject=n,t.worker.postMessage(e)}).catch(n)}else t._taskQueue.push({resolve:r,reject:n,message:e})})},sq.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},sq._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})},sq._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sq._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sq._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},sY),pu=((sZ=(sQ=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},sZ.destroy=function(){this._transcodeWorkerPool.destroy()},sZ._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new pc(this.workerLimitCount,function(){return new Promise(function(r,n){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?n(e.data.error):r(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},sQ);function pd(){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=p_(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var ph=function(e){return sJ||(sJ=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})),sJ};function p_(e,t,r){var n,a,i,o,s=function(){l.close(),l.delete()};(i=n||(n={}))[i.ETC1=0]="ETC1",i[i.ETC2=1]="ETC2",i[i.BC1=2]="BC1",i[i.BC3=3]="BC3",i[i.BC4=4]="BC4",i[i.BC5=5]="BC5",i[i.BC7=7]="BC7",i[i.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",i[i.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",i[i.ASTC_4x4=10]="ASTC_4x4",i[i.RGBA8=13]="RGBA8",(o=a||(a={}))[o.ASTC=0]="ASTC",o[o.BC7=1]="BC7",o[o.BC1_BC3=2]="BC1_BC3",o[o.PVRTC=3]="PVRTC",o[o.ETC=4]="ETC",o[o.R8=5]="R8",o[o.RG8=6]="RG8",o[o.RGBA8=7]="RGBA8";var l=new r(new Uint8Array(e));if(!l.isValid())throw s(),Error("Invalid or unsupported .ktx2 file");if(!l.startTranscoding())throw s(),Error("KTX2 startTranscoding failed");for(var c=l.getWidth(),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 b=Array(d),T=void 0,C=void 0,S=0;S<d;S++){var A=l.getImageLevelInfo(x,S,v);g&&0===x&&(c!==A.width||u!==A.height)?console.warn("KTX2 transcode to BC will resize to width: "+(c=T=A.width)+", height: "+(u=C=A.height)+". You'd better use an image whose size if multiple of 4."):(T=A.origWidth,C=A.origHeight);var M=new Uint8Array(l.getImageTranscodedSizeInBytes(x,S,0,p));if(!l.transcodeImage(M,x,S,v,p,0,-1,-1))throw s(),Error("transcodeImage failed.");b[S]=M}y[x]={data:function(e){if(1===e.length)return e[0];for(var t=0,r=0;r<e.length;r++)t+=e[r].byteLength;for(var n=new Uint8Array(t),a=0,i=0;i<e.length;i++)n.set(e[i],a),a+=e[i].byteLength;return n}(b),width:T,height:C}}m[v]=y}return s(),{faces:m,width:c,height:u,hasAlpha:_,faceCount:f,format:p}}var pf=(fO(s$=function(e){return pu.call(this,e)},pu),(s0=s$.prototype)._initTranscodeWorkerPool=function(){var e=this;return Promise.all([fetch("https://mdn.alipayobjects.com/rms/afts/file/A*nG8SR6vCgXgAAAAAAAAAAAAAARQnAQ/basis_transcoder.js").then(function(e){return e.text()}),fetch("https://mdn.alipayobjects.com/rms/afts/file/A*qEUfQ7317KsAAAAAAAAAAAAAARQnAQ/basis_transcoder.wasm").then(function(e){return e.arrayBuffer()})]).then(function(t){var r=t[0],n=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([r],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){ph(n).then(function(){e(null)})},a.onerror=function(){t()}});var a=pd.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+r+"\n "+p_.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},s0.transcode=function(e,t){return 0===this.workerLimitCount?ph().then(function(r){return p_(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},s$);function pp(){var e,t,r,n=function(e,t,r,n){var a=(r+3>>2)*(n+3>>2),i=16*a+65535>>16,o=e.memory,s=i+1-(o.buffer.byteLength>>16);s>0&&o.grow(s);var l=new Uint8Array(o.buffer,65536,16*a);return l.set(t),0===e.transcode(a)?l:null},a=function(e,t,r){var a=e.length,i=Array(a),s=Promise.resolve();return t&&(o.init(),s=o._initPromise),s.then(function(){for(var s=0;s<a;s++){for(var l=e[s].length,c=Array(l),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/a,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"}i[s]=c}return i})},i=((t=(e=function(){}).prototype).init=function(){return this._initPromise||(this._initPromise=fetch(e.WasmModuleURL).then(function(e){if(e.ok)return e.arrayBuffer();throw Error("Could not fetch the wasm component for the Zstandard decompression lib: "+e.status+" - "+e.statusText)}).then(function(t){return WebAssembly.instantiate(t,e.IMPORT_OBJECT)}).then(this._init)),this._initPromise},t._init=function(t){e.instance=t.instance,e.IMPORT_OBJECT.env.emscripten_notify_memory_growth()},t.decode=function(t,r){if(void 0===r&&(r=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var n=e.instance.exports,a=t.byteLength,i=n.malloc(a);e.heap.set(t,i),r=r||Number(n.ZSTD_findDecompressedSize(i,a));var o=n.malloc(r),s=n.ZSTD_decompress(o,r,i,a),l=e.heap.slice(o,o+s);return n.free(i),n.free(o),l},e);i.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){i.heap=new Uint8Array(i.instance.exports.memory.buffer)}}},i.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var o=new i;self.onmessage=function(e){var t,n=e.data;switch(n.type){case"init":(t=n.transcoderWasm,r=WebAssembly.instantiate(t,{env:{memory:new WebAssembly.Memory({initial:16})}}).then(function(e){return e.instance.exports})).then(function(){self.postMessage("init-completed")}).catch(function(e){self.postMessage({error:e})});break;case"transcode":r.then(function(e){a(n.data,n.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var pm=(fO(s1=function(e,t){var r;return(r=pu.call(this,e)||this).type=t,r},pu),(s2=s1.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(s1.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=pp.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},s2.transcode=function(e){for(var t=e.supercompressionScheme===cX.Zstd,r=e.levels.length,n=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(n)},o=i.data,s=0;s<n;s++){for(var l=Array(r),c=0;c<r;c++){var 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(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},s1);pm.transcoderMap=((s3={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",s3),e.KTX2Loader=(fO(s4=function(){return _f.apply(this,arguments)},_f),(s8=s4.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()}},s8.load=function(t,r){var n=this;return new hx(function(a,i,o,s){n.request(t.url,{type:"arraybuffer"}).onProgress(o,s).then(function(n){return e.KTX2Loader._parseBuffer(new Uint8Array(n),r.engine,t.params).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)})}).then(a).catch(i)})},s4.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},s4._parseBuffer=function(t,r,n){var a,i,o=new pl(t),s=null!=(a=null==n?void 0:n.priorityFormats)?a:e.KTX2Loader._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=e.KTX2Loader._decideTargetFormat(r,o,s);if(!e.KTX2Loader._isBinomialInit&&pm.transcoderMap[l]&&o.isUASTC){var c=e.KTX2Loader._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var u=e.KTX2Loader._getBinomialLLCTranscoder();i=u.init().then(function(){return u.transcode(t,l)})}return i.then(function(e){return{engine:r,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},s4._createTextureByBuffer=function(t,r,n,a){var i,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){i=new ds(t,o,s,h,d);for(var _=0;_<u.length;_++){var f=u[_].data;i.setPixelBuffer(f,_)}}else{i=new dc(t,s,h,d);for(var p=0;p<l.length;p++)for(var m=l[p],g=0;g<u.length;g++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+p,m[g].data,g)}return a&&(i.wrapModeU=a[0],i.wrapModeV=a[1],i.filterMode=a[2],i.anisoLevel=a[3]),i},s4._decideTargetFormat=function(t,r,n){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,n);return i!==e.KTX2TargetFormat.PVRTC||cQ.isPowerOf2(r.pixelWidth)&&cQ.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===i?(uI.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(uI.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},s4._detectSupportedFormat=function(t,r){for(var n=0;n<r.length;n++){var a=r[n],i=this._supportedMap[a];if(i){for(var o=0;o<i.length;o++)if(t.canIUse(i[o]))return a}else switch(r[n]){case e.KTX2TargetFormat.R8G8B8A8:return a;case e.KTX2TargetFormat.R8:case e.KTX2TargetFormat.R8G8:if(t.isWebGL2)return a}}return null},s4._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new pf(t)},s4._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new pm(t,e.KTX2TargetFormat.ASTC)},s4._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}},s4._isBinomialInit=!1,s4._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]},s4._supportedMap=((s5={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],s5[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],s5[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],s5[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],s5[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],s5),s4),e.KTX2Loader=fV([hT(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(s9=e.KTX2Transcoder||(e.KTX2Transcoder={}))[s9.BinomialLLC=0]="BinomialLLC",s9[s9.Khronos=1]="Khronos";var pg=(fO(s6=function(){var e;return e=dR.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},dR),(s7=s6.prototype).restoreContent=function(){var t=this;return new hx(function(r,n){Promise.all(t.bufferRequests.map(function(e){return _h(e.url,e.config)})).then(function(a){if(t.isGLB){var i=t.glbBufferSlices,o=a[0],s=i.length;a.length=s;for(var l=0;l<s;l++){var c=i[l];a[l]=o.slice(c.x,c.x+c.y)}}hx.all(t.bufferTextures.map(function(t){var r,n=t.bufferView,i=a[n.buffer],o=new Uint8Array(i,null!=(r=n.byteOffset)?r:0,n.byteLength),s=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(o,s.engine).then(function(e){for(var t=e.result.faces[0],r=0;r<t.length;r++)s.setPixelBuffer(t[r].data,r)}):ps.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=f$(t.meshes);!(e=n()).done;){for(var i,o=e.value,s=o.mesh,l=f$(o.vertexBuffers);!(i=l()).done;){var c=i.value,u=t._getBufferData(a,c.data);c.buffer.setData(u)}if(o.indexBuffer){var d=t._getBufferData(a,o.indexBuffer);s.setIndices(d)}for(var h,_=f$(o.blendShapes);!(h=_()).done;){var f=h.value,p=f.blendShape.frames[0],m=f.position,g=t._getBufferData(a,m.buffer);if(p.deltaPositions=ps.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=ps.bufferToVector3Array(y,v.byteOffset,v.count,v.normalized,v.componentType)}if(f.tangent){var x=f.tangent,b=t._getBufferData(a,x.buffer);p.deltaTangents=ps.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},s7._getBufferData=function(e,t){var r,n=t.main;if(n){var a=e[n.bufferIndex];r=new n.TypedArray(a,n.byteOffset,n.length)}else r=new n.TypedArray(n.length);var i=t.sparseCount;if(i)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],d=new c.TypedArray(u,c.byteOffset,c.length),h=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<h;p++)r[f*h+p]=d[_*h+p];return r},s6),pv=function(e,t){this.url=e,this.config=t},py=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},px=function(){this.vertexBuffers=[],this.blendShapes=[]},pb=function(e,t){this.buffer=e,this.data=t},pT=function(e,t,r,n,a){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=a},pC=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},pS=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},pA=function(e,t,r,n,a){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=a},pM=((lt=(le=function(){}).prototype).createAndParse=function(e,t,r){for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];throw"Not implemented."},lt.additiveParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];throw"Not implemented."},le);e.GLTFExtensionMode=void 0,(lr=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[lr.CreateAndParse=0]="CreateAndParse",lr[lr.AdditiveParse=1]="AdditiveParse";var pR=((ln=function(){}).executeExtensionsCreateAndParse=function(e,t,r){void 0===e&&(e={});for(var n=arguments.length,a=Array(n>3?n-3:0),i=3;i<n;i++)a[i-3]=arguments[i];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],u=e[c];if(o=ln._createAndParse.apply(ln,[].concat(c,t,u,r,a)))return o}},ln.executeExtensionsAdditiveAndParse=function(e,t,r,n){for(var a=arguments.length,i=Array(a>4?a-4:0),o=4;o<a;o++)i[o-4]=arguments[o];for(var s in e){var l=e[s];ln._additiveParse.apply(ln,[].concat(s,t,r,l,n,i))}},ln.hasExtensionParser=function(e){var t;return!!(null==(t=ln._extensionParsers[e])?void 0:t.length)},ln.getExtensionParser=function(e,t){var r=ln._extensionParsers[e],n=null==r?void 0:r.length;if(n)for(var a=n-1;a>=0;--a){var i=r[a];if(i._mode===t)return i}},ln._addExtensionParser=function(e,t){ln._extensionParsers[e]||(ln._extensionParsers[e]=[]),ln._extensionParsers[e].push(t)},ln._createAndParse=function(t,r,n,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];var l=ln.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,a,o))},ln._additiveParse=function(t,r,n,a,i){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=ln.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,a,i,s))},ln);function pE(e,t){return function(r){var n=new r;n._mode=t,pR._addExtensionParser(e,n)}}function pw(){var e,t=function(e){for(var t=new Uint8Array(e.length),r=0;r<e.length;++r){var n=e.charCodeAt(r);t[r]=n>96?n-97:n>64?n-39:n+4}for(var a=0,i=0;i<e.length;++i)t[a++]=t[i]<60?o[t[i]]:(t[i]-60)*64+t[++i];return t.buffer.slice(0,a)},r=function(t,r,n,a,i,o){var s=e.exports.sbrk,l=n+3&-4,c=s(l*a),u=s(i.length),d=new Uint8Array(e.exports.memory.buffer);d.set(i,u);var h=t(c,n,a,u,i.length);if(0==h&&o&&o(c,l,a),r.set(d.subarray(c,c+n*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)},n=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var r=e.data;t.pending-=r.count,t.requests[r.id][r.action](r.value),delete t.requests[r.id]},t},a=function(e){for(var r="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(t(s))+']), {}).then(function(result) {instance = result.instance; instance.exports.__wasm_call_ctors();});\nself.onmessage = workerProcess;\nfunction decode(fun, target, count, size, source, filter) {\n const sbrk = instance.exports.sbrk;\n const count4 = (count + 3) & ~3;\n const tp = sbrk(count4 * size);\n const sp = sbrk(source.length);\n const heap = new Uint8Array(instance.exports.memory.buffer);\n heap.set(source, sp);\n const res = fun(tp, count, size, sp, source.length);\n if (res == 0 && filter) {\n filter(tp, count4, size);\n }\n target.set(heap.subarray(tp, tp + count * size));\n sbrk(tp - sbrk(0));\n if (res != 0) {\n throw new Error("Malformed buffer data: " + res);\n }\n }\nfunction workerProcess(event) {\n ready.then(function () {\n const data = event.data;\n try {\n const target = new Uint8Array(data.count * data.size);\n decode(instance.exports[data.mode], target, data.count, data.size, data.source, instance.exports[data.filter]);\n self.postMessage({ id: data.id, count: data.count, action: "resolve", value: target }, [target.buffer]);\n } catch (error) {\n self.postMessage({\n id: data.id,\n count: data.count,\n action: "reject",\n value: error\n });\n }\n });\n }',a=new Blob([r],{type:"text/javascript"}),i=URL.createObjectURL(a),o=0;o<e;++o)u[o]=n(i);URL.revokeObjectURL(i)},i=function(e,t,r,n,a){for(var i=u[0],o=1;o<u.length;++o)u[o].pending<i.pending&&(i=u[o]);return new Promise(function(o,s){var l=new Uint8Array(r),c=d++;i.pending+=e,i.requests[c]={resolve:o,reject:s},i.object.postMessage({id:c,count:e,size:t,source:l,mode:n,filter:a},[l.buffer])})};if(cY)return cY;var o=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]),s=hw._detectSIMDSupported()?"b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb":"b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb";cY=WebAssembly.instantiate(t(s)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:cY,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,a(this.workerCount)},decodeGltfBuffer:function(t,n,a,o,s){return(this.workerCount>0&&0===u.length&&this.useWorkers(),u.length>0)?i(t,n,a,c[o],l[s]):cY.then(function(){var i=new Uint8Array(t*n);return r(e.exports[c[o]],i,t,n,a,e.exports[l[s]]),i})},release:function(){for(var e=0;e<u.length;e++)u[e].object.terminate()}}});var l={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},c={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;return cY}pR._extensionParsers={},e.GLTFSchemaParser=(fO(la=function(){return pR.apply(this,arguments)},pR),la.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=t.url,a=r.bufferRequests,i={type:"arraybuffer"};return _h(n,i).onProgress(void 0,e._onTaskDetail).then(function(t){return a.push(new pv(n,i)),ps.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(uv.decodeText(new Uint8Array(t.originBuffer))))})},la),e.GLTFSchemaParser=fV([po(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(fO(li=function(){return pR.apply(this,arguments)},pR),li.prototype.parse=function(t,r){var n=t.glTF.animations[r],a=n.name,i=void 0===a?"AnimationClip"+r:a;return Promise.resolve(pR.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new _S(i),n)).then(function(e){return pR.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},li._parseStandardProperty=function(t,r,n){for(var a=function(r,n){var a=u[r],i=s[a.input],o=s[a.output],c=Promise.all([ps.getAccessorBuffer(t,l,i),ps.getAccessorBuffer(t,l,o)]).then(function(t){var n,i,s=t[0].data,l=t[1].data;if(o.normalized){for(var c=ps.getNormalizedComponentScale(o.componentType),u=new Float32Array(l.length),d=0,_=l.length;d<_;d++)u[d]=l[d]*c;l=u}var f=l.length/s.length;switch(null!=(n=a.interpolation)?n:cO.Linear){case cO.CubicSpine:i=e.InterpolationType.CubicSpine;break;case cO.Step:i=e.InterpolationType.Step;break;case cO.Linear:i=e.InterpolationType.Linear}s[s.length-1],h[r]={type:o.type,interpolation:i,input:s,output:l,outputSize:f}});f.push(c)},i=this,o=t.glTF,s=o.accessors,l=o.bufferViews,c=n.channels,u=n.samplers,d=u.length,h=Array(d),_=t.get(e.GLTFParserType.Entity),f=[],p=0;p<d;p++)a(p);return f.push(t.get(e.GLTFParserType.Scene)),Promise.all(f).then(function(){for(var e=0,n=c.length;e<n;e++){for(var a=c[e],s=a.target,l=_[s.node],u="",d=l;d.parent;)u=""===u?""+d.name:d.name+"/"+u,d=d.parent;if(-1!==t.glTFResource.sceneRoots.indexOf(d)){var f=void 0,p=void 0;switch(s.path){case cI.TRANSLATION:f=u6,p="position";break;case cI.ROTATION:f=u6,p="rotationQuaternion";break;case cI.SCALE:f=u6,p="scale";break;case cI.WEIGHTS:f=hc,p="blendShapeWeights"}var m=i._addCurve(s.path,a,h);if(s.path===cI.WEIGHTS)for(var g=o.nodes[s.node].mesh,v=0,y=o.meshes[g].primitives.length;v<y;v++)r.addCurveBinding(u,f,v,p,m);else r.addCurveBinding(u,f,p,m)}}return r})},li._addCurve=function(t,r,n){var a=n[r.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case cI.TRANSLATION:case cI.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new _k;_.time=i[d],c===e.InterpolationType.CubicSpine?(_.inTangent=new cZ(o[u++],o[u++],o[u++]),_.value=new cZ(o[u++],o[u++],o[u++]),_.outTangent=new cZ(o[u++],o[u++],o[u++])):_.value=new cZ(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case cI.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,m=0,g=0,v=i.length;g<v;g++){var y=new _k;y.time=i[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new c6(o[m++],o[m++],o[m++],o[m++]),y.value=new c4(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new c6(o[m++],o[m++],o[m++],o[m++])):y.value=new c4(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case cI.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,T=0,C=i.length;T<C;T++){var S=new _k;S.time=i[T],x.interpolation===e.InterpolationType.CubicSpine?(S.inTangent=Array.from(o.subarray(b,b+s)),b+=s,S.value=o.slice(b,b+s),b+=s,S.outTangent=Array.from(o.subarray(b,b+s))):S.value=o.slice(b,b+s),b+=s,x.addKey(S)}return x}},li),e.GLTFAnimationParser=fV([po(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(fO(lo=function(){return pR.apply(this,arguments)},pR),(ls=lo.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},ls._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,a=r.url,i=n.bufferRequests,o={type:"arraybuffer"},s=uv.resolveAbsoluteUrl(a,t.uri);i.push(new pv(s,o));var l=_h(s,o).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(l),l},lo),e.GLTFBufferParser=fV([po(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(fO(ll=function(){return pR.apply(this,arguments)},pR),ll.prototype.parse=function(t,r){var n=t.glTFResource,a=t.glTF.nodes[r],i=n.engine,o=a.matrix,s=a.translation,l=a.rotation,c=a.scale,u=a.extensions,d=new hs(i,a.name||"_GLTF_ENTITY_"+r);d._markAsTemplate(n);var h=d.transform;if(o){var _=h.localMatrix;_.copyFromArray(o),h.localMatrix=_}else s&&h.setPosition(s[0],s[1],s[2]),l&&h.setRotationQuaternion(l[0],l[1],l[2],l[3]),c&&h.setScale(c[0],c[1],c[2]);var f=a.children;if(f)for(var p=0;p<f.length;p++){var m=f[p],g=t.get(e.GLTFParserType.Entity,m);d.addChild(g)}return pR.executeExtensionsAdditiveAndParse(u,t,d,a),d},ll),e.GLTFEntityParser=fV([po(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(fO(lc=function(){return pR.apply(this,arguments)},pR),lc.prototype.parse=function(t,r){var n=t.glTF.materials[r],a=t.glTFResource,i=a.engine,o=pR.executeExtensionsCreateAndParse(n.extensions,t,n);return o||((o=new dG(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,o,n)),Promise.resolve(o).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(i)),pR.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r._associationSuperResource(a),r})},lc._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new dz(t))},lc._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&uI.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},lc._parseStandardProperty=function(t,r,n){var a=n.pbrMetallicRoughness,i=n.normalTexture,o=n.occlusionTexture,s=n.emissiveTexture,l=n.emissiveFactor,c=n.alphaMode,u=n.alphaCutoff,d=n.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(r.baseColor=new c7(c7.linearToGammaSpace(h[0]),c7.linearToGammaSpace(h[1]),c7.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,pR.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===dG&&(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===dG||r.constructor===dH){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new c7(c7.linearToGammaSpace(l[0]),c7.linearToGammaSpace(l[1]),c7.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;e.GLTFMaterialParser._checkOtherTextureTransform(i,"Normal"),t.get(e.GLTFParserType.Texture,g).then(function(e){r.normalTexture=e}),void 0!==v&&(r.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;e.GLTFMaterialParser._checkOtherTextureTransform(o,"Occlusion"),t.get(e.GLTFParserType.Texture,y).then(function(e){r.occlusionTexture=e}),void 0!==x&&(r.occlusionTextureIntensity=x),b===e.TextureCoordinate.UV1?r.occlusionTextureCoord=e.TextureCoordinate.UV1:b>e.TextureCoordinate.UV1&&uI.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case ck.OPAQUE:r.isTransparent=!1;break;case ck.BLEND:r.isTransparent=!0;break;case ck.MASK:r.alphaCutoff=null!=u?u:.5}},lc),e.GLTFMaterialParser=fV([po(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(fO(lu=function(){return pR.apply(this,arguments)},pR),lu.prototype.parse=function(t,r){for(var n=function(r,n){var c=a.primitives[r];l[r]=new Promise(function(n){var l=pR.executeExtensionsCreateAndParse(c.extensions,t,c,a);if(l)fZ(l,d2)?(l._associationSuperResource(o),n(l)):l.then(function(e){e._associationSuperResource(o),n(e)});else{var u=new d2(s,a.name||r+"");u._associationSuperResource(o);var d=new px;d.mesh=u,t.contentRestorer.meshes.push(d),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,u,d,a,c,i,t.params.keepMeshData).then(n)}})},a=t.glTF.meshes[r],i=t.glTF,o=t.glTFResource,s=o.engine,l=[],c=0,u=a.primitives.length;c<u;c++)n(c);return Promise.all(l)},lu._parseMeshFromGLTFPrimitive=function(t,r,n,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=ps.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,c,u,d=ps.getAccessorTypeSize(i.type),h=i.count,_=t.data,f=r.instanceId,v=t.vertexBindingInfos,y=i.normalized,x=ps.getElementFormat(i.componentType,d,y);if(y&&(c=ps.getNormalizedComponentScale(i.componentType)),t.interleaved){var b=i.byteOffset||0,T=t.stride;if(u=b%T,void 0===v[f]){o=new dV(a,u,x,g);var C=t.vertexBuffer;C||(C=new dI(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=C,n.vertexBuffers.push(new pb(C,t.restoreInfo))),r.setVertexBufferBinding(C,T,g),v[f]=g++}else o=new dV(a,u,x,v[f])}else{u=0,o=new dV(a,u,x,g);var S=t.vertexBuffer;S||(S=new dI(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new pb(S,t.restoreInfo))),r.setVertexBufferBinding(S,t.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=r.bounds,M=A.min,R=A.max;if(i.min&&i.max)M.copyFromArray(i.min),R.copyFromArray(i.max);else{var E=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 w=u/_.BYTES_PER_ELEMENT,P=_.length/h,F=0;F<h;F++){var L=w+F*P;E.copyFromArray(_,L),cZ.min(M,E,M),cZ.max(R,E,R)}}y&&(M.scale(c),R.scale(c))}});v.push(c)},u=o.accessors,d=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=r.engine,m=[],g=0,v=[];for(var y in d)c(y);return Promise.all(v).then(function(){if(r.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=ps.getAccessorBuffer(t,o.bufferViews,c).then(function(e){r.setIndices(e.data),r.addSubMesh(0,c.count,f),n.indexBuffer=e.restoreInfo});v.push(u)}else r.addSubMesh(0,l,f);return h&&v.push(e.GLTFMeshParser._createBlendShape(t,r,n,a,i,h)),Promise.all(v).then(function(){return r.uploadData(!s),r})})},lu._getBlendShapeData=function(e,t,r){return ps.getAccessorBuffer(e,t.bufferViews,r).then(function(e){var t,n=e.data,a=e.interleaved?(null!=(t=r.byteOffset)?t:0)%e.stride:0,i=r.count,o=r.normalized,s=r.componentType;return{vertices:ps.bufferToVector3Array(n,a,i,o,s),restoreInfo:new pA(e.restoreInfo,a,i,o,s)}})},lu._createBlendShape=function(e,t,r,n,a,i){for(var o=this,s=e.glTF,l=s.accessors,c=n.extras?n.extras.targetNames:null,u=[],d=i.length,h=Array(d),_=0;_<d;_++)(function(t){var r={};h[t]=r;var n=c?c[t]:"blendShape"+t,i=a.targets[t],d=i.NORMAL,_=i.TANGENT,f=void 0!==d,p=void 0!==_;u.push(Promise.all([o._getBlendShapeData(e,s,l[i.POSITION]),f?o._getBlendShapeData(e,s,l[d]):null,p?o._getBlendShapeData(e,s,l[_]):null]).then(function(e){var t=e[0],a=e[1],i=e[2],o=new dK(n);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),r.blendShape=o,r.restoreInfo=new pS(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))})(_);return Promise.all(u).then(function(){for(var e,n=f$(h);!(e=n()).done;){var a=e.value;t.addBlendShape(a.blendShape),r.blendShapes.push(a.restoreInfo)}})},lu._tempVector3=new cZ,lu),e.GLTFMeshParser=fV([po(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(fO(ld=function(){return pR.apply(this,arguments)},pR),(lh=ld.prototype).parse=function(t,r){var n,a=t.glTF,i=a.scene,o=t.glTFResource,s=a.scenes[r],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=t.get(e.GLTFParserType.Entity,u[0]);else{(n=new hs(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=t.get(e.GLTFParserType.Entity,u[d]);n.addChild(h)}}(void 0===i?0:i)===r&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(t,u[f]));return Promise.all(_).then(function(){return pR.executeExtensionsAdditiveAndParse(l,t,n,s),n})},lh._parseEntityComponent=function(t,r){var n,a=this,i=t.glTF,o=t.glTFResource,s=i.nodes[r],l=s.camera,c=s.mesh,u=t.get(e.GLTFParserType.Entity,r);return void 0!==l&&this._createCamera(o,i.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(a._parseEntityComponent(t,r[n]));return Promise.all(e)})},lh._createCamera=function(t,r,n){var a=r.orthographic,i=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===cV.ORTHOGRAPHIC){var l=a.xmag,c=a.ymag,u=a.zfar,d=a.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===cV.PERSPECTIVE){var h=i.aspectRatio,_=i.yfov,f=i.zfar,p=i.znear;void 0!==h&&(s.aspectRatio=h),void 0!==_&&(s.fieldOfView=180*_/Math.PI),void 0!==f&&(s.farClipPlane=f),void 0!==p&&(s.nearClipPlane=p)}t.cameras||(t.cameras=[]),t.cameras.push(s),s.enabled=!1},lh._createRenderer=function(t,r,n){for(var a,i=this,o=r.mesh,s=r.skin,l=t.glTF.meshes[o],c=l.primitives,u=c.length,d=r.weights||l.weights,h=Array(u),_=0;_<u;_++)h[_]=t.get(e.GLTFParserType.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(e.GLTFParserType.Mesh,o),void 0!==s&&t.get(e.GLTFParserType.Skin,s),Promise.all(h)]).then(function(r){for(var a=r[0],o=r[1],s=r[2],l=0;l<u;l++)!function(r){var l=s[r]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),u=c[r],h=a[r],_=void 0;if(o||d){var f=n.addComponent(hc);f.mesh=h,o&&(i._computeLocalBounds(f,h,o.bones,o.rootBone,o.inverseBindMatrices),f.skin=o),d&&(f.blendShapeWeights=new Float32Array(d)),_=f}else(_=n.addComponent(d0)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),pR.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},lh._computeLocalBounds=function(e,t,r,n,a){var i=r.indexOf(n);if(-1!==i)c$.transform(t.bounds,a[i],e.localBounds);else{var o=new c8(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(r,a,n,o);0!==s?(c8.multiplyScalar(o,1/s,o),c$.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},lh._computeApproximateBindMatrix=function(e,t,r,n){for(var a=0,i=r.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(c8.add(n,t[c],n),a++):a+=this._computeApproximateBindMatrix(e,t,l,n)}return a},ld),e.GLTFSceneParser=fV([po(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(fO(l_=function(){return pR.apply(this,arguments)},pR),(lf=l_.prototype).parse=function(t,r){var n=this,a=t.glTF,i=a.skins[r],o=i.inverseBindMatrices,s=i.skeleton,l=i.joints,c=i.name,u=l.length,d=new hl(void 0===c?"SKIN_"+r:c);d.inverseBindMatrices.length=u;var h=Array(u),_=a.accessors[o];return Promise.resolve(ps.getAccessorBuffer(t,a.bufferViews,_).then(function(r){for(var a=t.get(e.GLTFParserType.Entity),i=r.data,o=0;o<u;o++){var c=new c8;c.copyFromArray(i,16*o),d.inverseBindMatrices[o]=c;var _=a[l[o]];h[o]=_,d.joints[o]=_.name}if(d.bones=h,void 0!==s){var f=a[s];d.rootBone=f}else{var p=n._findSkeletonRootBone(l,a);if(p)d.rootBone=p;else throw"Failed to find skeleton root bone."}return d}))},lf._findSkeletonRootBone=function(e,t){for(var r,n={},a=f$(e);!(r=a()).done;){for(var i=r.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;n[i]=o}for(var l=null,c=0;;c++){var 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}},l_),e.GLTFSkinParser=fV([po(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(fO(lp=function(){return pR.apply(this,arguments)},pR),lp.prototype.parse=function(t,r){var n=t.glTF.textures[r],a=t.glTFResource,i=t.glTF,o=a.engine,s=a.url,l=n.sampler,c=n.source,u=n.name,d=n.extensions,h=i.images[void 0===c?0:c],_=h.uri,f=h.bufferView,p=h.mimeType,m=h.name,g=pR.executeExtensionsCreateAndParse(d,t,n);if(!g){var v=void 0!==l,y=void 0!==l&&ps.getSamplerInfo(i.samplers[l]);if(_){var x=_.lastIndexOf("."),b=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=o.resourceManager.load({url:uv.resolveAbsoluteUrl(s,_),type:b,params:{mipmap:null==y?void 0:y.mipmap}}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name=u||m||e.name||"texture_"+r,v&&ps.parseSampler(e,y),e}),t._addTaskCompletePromise(g)}else{var T=i.bufferViews[f];g=t.get(e.GLTFParserType.Buffer).then(function(e){var n=e[T.buffer],a=new Uint8Array(n,T.byteOffset,T.byteLength);return ps.loadImageBuffer(a,p).then(function(e){var n=new ds(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&&ps.parseSampler(n,y);var a=new py(n,T,p);return t.contentRestorer.bufferTextures.push(a),n})})}}return Promise.resolve(g).then(function(e){return pR.executeExtensionsAdditiveAndParse(d,t,e,n),e._associationSuperResource(a),e})},lp._wrapMap=((lm={})[cG.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,lm[cG.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,lm[cG.REPEAT]=e.TextureWrapMode.Repeat,lm),lp),e.GLTFTextureParser=fV([po(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(fO(lg=function(){return pR.apply(this,arguments)},pR),lg.prototype.parse=function(e){var t=e.glTF,r=t.asset.version,n=t.extensionsUsed,a=t.extensionsRequired,i=Number(r);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(n){uI.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];pR.hasExtensionParser(s)||uI.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){uI.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];pR.hasExtensionParser(c)||uI.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},lg),e.GLTFValidator=fV([po(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(fO(lv=function(){return pR.apply(this,arguments)},pR),lv.prototype.parse=function(t,r){var n=t.glTF.bufferViews[r],a=n.extensions,i=n.byteOffset,o=void 0===i?0:i,s=n.byteLength,l=n.buffer;return a?pR.executeExtensionsCreateAndParse(a,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},lv),e.GLTFBufferViewParser=fV([po(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=(fO(ly=function(){return pR.apply(this,arguments)},pR),(lx=ly.prototype).parse=function(t){var r=this;return t.needAnimatorController?t.get(e.GLTFParserType.Animation).then(function(e){return Promise.resolve(r._createAnimatorController(t,e))}):Promise.resolve(null)},lx._createAnimatorController=function(e,t){var r=e.glTFResource.engine,n=new _D(r),a=new _N("layer"),i=new _V;if(n.addLayer(a),a.stateMachine=i,t)for(var o=0;o<t.length;o++){var s=t[o],l=s.name,c=i.makeUniqueStateName(l);c!==l&&console.warn("AnimatorState name is existed, name: "+l+" reset to "+c),i.addState(c).clip=s}return n},ly),e.GLTFAnimatorControllerParser=fV([po(e.GLTFParserType.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=(fO(lb=function(){return _f.apply(this,arguments)},_f),(lT=lb.prototype).initialize=function(e,t){var r,n,a,i=null!=(a=null==(r=t.glTFLoader)?void 0:r.meshOpt)?a:null==(n=t.glTF)?void 0:n.meshOpt;return i?pw().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},lT.load=function(e,t){var r=e.url,n=e.params,a=new pt(t.engine,r),i=new pr(a,t,fD({keepMeshData:!1},n));return new hx(function(e,t,r,n){i._setTaskCompleteProgress=r,i._setTaskDetailProgress=n,i.parse().then(e).catch(t)})},lb.release=function(){cY&&pw().then(function(e){e.release()})},lb),e.GLTFLoader=fV([hT(e.AssetType.GLTF,["gltf","glb"])],e.GLTFLoader);var pP=(fO(lC=function(e,t,r){var n;return(n=f1.call(this,e,t)||this).prefabResource=r,n},f1),(lS=lC.prototype)._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},lS._clearAndResolve=function(){return this.context.clear(),this.prefabResource},lC.parse=function(t,r,n){var a=new f0(t,r),i=new fq(t,e.ParserType.Prefab,a),o=new lC(n,i,a);return o.start(),o.promise.then(function(){return a})},lC),pF=(fO(lA=function(){return _f.apply(this,arguments)},_f),lA.prototype.load=function(e,t){var r=this,n=t.engine;return new hx(function(t,a){r.request(e.url,fD({},e,{type:"json"})).then(function(r){pP.parse(n,e.url,r).then(t).catch(a)})})},lA);pF=fV([hT(e.AssetType.Prefab,["prefab"])],pF);var pL=Math.PI,pB=(fO(lM=function(){return _f.apply(this,arguments)},_f),lM.prototype.load=function(t,r){var n=this;return new hx(function(a,i){var o=r.engine;n.request(t.url,fD({},t,{type:"arraybuffer"})).then(function(t){for(var r=new Uint8Array(t),n=pB._parseHeader(r),i=n.width,s=n.height,l=n.dataPosition,c=pB._readPixels(r.subarray(l),i,s),u=s>>1,d=pB._convertToCubemap(c,i,s,u),h=new dc(o,u),_=0;_<6;_++)h.setPixelBuffer(e.TextureCubeFace.PositiveX+_,d[_],0);h.generateMipmaps(),a(h)}).catch(i)})},lM._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)]},lM._createCubemapData=function(e,t,r,n,a){for(var i=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,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,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var m=u*e*4+4*_;i[m]=p.r,i[m+1]=p.g,i[m+2]=p.b,i[m+3]=p.a,d.add(o),h.add(s)}c+=l}return i},lM._calcProjectionSpherical=function(e,t,r,n){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-pL;)a+=2*pL;for(;a>pL;)a-=2*pL;var o=a/pL,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(i/pL*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 c7(u,d,h,_)},lM._readStringLine=function(e,t){for(var r="",n="",a=t;a<e.length-t&&"\n"!=(n=String.fromCharCode(e[a]));a++)r+=n;return r},lM._parseHeader=function(e){var t=0,r=0,n=this._readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this._readStringLine(e,o))?i=!0:0==n.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=n.length+1,n=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(n);if(!s||s.length<3)throw"HDR Bad header format, no size";if(r=parseInt(s[2]),t=parseInt(s[1]),r<8||r>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:r,dataPosition:o+=n.length+1}},lM._readPixels=function(e,t,r){for(var n=e.byteLength,a=new Uint8Array(4*t*r),i=0,o=0,s=4*t,l=new Uint8Array(s),c=r;c>0&&o<n;){var u=e[o++],d=e[o++],h=e[o++],_=e[o++];if(2!=u||2!=d||128&h||t<8||t>32767)return e;if((h<<8|_)!=t)throw"HDR Bad header format, wrong scan line width";for(var f=0,p=void 0;f<s&&o<n;){var m=(p=e[o++])>128;if(m&&(p-=128),0===p||f+p>s)throw"HDR Bad Format, bad scanline data (run)";if(m)for(var g=e[o++],v=0;v<p;v++)l[f++]=g;else l.set(e.subarray(o,o+p),f),f+=p,o+=p}for(var y=0;y<t;y++){var x=0;a[i]=l[y+x],x+=t,a[i+1]=l[y+x],x+=t,a[i+2]=l[y+x],x+=t,a[i+3]=l[y+x],i+=4}c--}return a},lM._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},lM._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},lM._rightBottomBack=new cZ(1,-1,-1),lM._rightBottomFront=new cZ(1,-1,1),lM._rightUpBack=new cZ(1,1,-1),lM._rightUpFront=new cZ(1,1,1),lM._leftBottomBack=new cZ(-1,-1,-1),lM._leftBottomFront=new cZ(-1,-1,1),lM._leftUpBack=new cZ(-1,1,-1),lM._leftUpFront=new cZ(-1,1,1),lM._faceRight=[lM._rightBottomBack,lM._rightBottomFront,lM._rightUpBack,lM._rightUpFront],lM._faceLeft=[lM._leftBottomFront,lM._leftBottomBack,lM._leftUpFront,lM._leftUpBack],lM._faceUp=[lM._leftBottomFront,lM._rightBottomFront,lM._leftBottomBack,lM._rightBottomBack],lM._faceBottom=[lM._leftUpBack,lM._rightUpBack,lM._leftUpFront,lM._rightUpFront],lM._faceFront=[lM._leftBottomBack,lM._rightBottomBack,lM._leftUpBack,lM._rightUpBack],lM._faceBack=[lM._rightBottomFront,lM._leftBottomFront,lM._rightUpFront,lM._leftUpFront],lM._tempVector3=new cZ,lM._temp2Vector3=new cZ,lM._temp3Vector3=new cZ,lM._temp4Vector3=new cZ,lM._temp5Vector3=new cZ,lM);pB=fV([hT(e.AssetType.HDR,["hdr"])],pB);var pD=(fO(lR=function(){return _f.apply(this,arguments)},_f),lR.prototype.load=function(e){return this.request(e.url,fD({},e,{type:"json"}))},lR);pD=fV([hT(e.AssetType.JSON,["json"],!1)],pD);var pI={parse:function(t,r,n,a){if(void 0===a&&(a=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(t))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var i=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*i),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*i,s),glTypeSize:o.getUint32(2*i,s),glFormat:o.getUint32(3*i,s),glInternalFormat:o.getUint32(4*i,s),glBaseInternalFormat:o.getUint32(5*i,s),pixelWidth:o.getUint32(6*i,s),pixelHeight:o.getUint32(7*i,s),pixelDepth:o.getUint32(8*i,s),numberOfArrayElements:o.getUint32(9*i,s),numberOfFaces:o.getUint32(10*i,s),numberOfMipmapLevels:o.getUint32(11*i,s),bytesOfKeyValueData:o.getUint32(12*i,s),loadType:0};if(0!==l.glType)throw Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),0===l.pixelHeight||0!==l.pixelDepth)throw Error("only 2D textures currently supported");if(0!==l.numberOfArrayElements)throw Error("texture arrays not currently supported");if(l.numberOfFaces!==r)throw Error("number of faces expected"+r+", but found "+l.numberOfFaces);return n&&(l.mipmaps=function(e,t){for(var r=[],n=64+e.bytesOfKeyValueData,a=e.pixelWidth,i=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,n,1)[0];n+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,n,l);r.push({data:u,width:a,height:i}),n+=l+(3-(l+3)%4)}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return r}(l,!0)),a&&(l.engineFormat=function(t){switch(t){case e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:return e.TextureFormat.BC1;case e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:return e.TextureFormat.BC3;case e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT:return e.TextureFormat.BC7;case e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL:return e.TextureFormat.ETC1_RGB;case e.GLCompressedTextureInternalFormat.RGB8_ETC2:return e.TextureFormat.ETC2_RGB;case e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return e.TextureFormat.ETC2_RGBA5;case e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC:return e.TextureFormat.ETC2_RGBA8;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGB2;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA2;case e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGB4;case e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG:return e.TextureFormat.PVRTC_RGBA4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR:return e.TextureFormat.ASTC_4x4;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR:return e.TextureFormat.ASTC_5x5;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR:return e.TextureFormat.ASTC_6x6;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR:return e.TextureFormat.ASTC_8x8;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR:return e.TextureFormat.ASTC_10x10;case e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR:return e.TextureFormat.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+e.GLCompressedTextureInternalFormat[t])}}(l.glInternalFormat)),l}};function pO(e){var t=pI.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var pV=(fO(lE=function(){return _f.apply(this,arguments)},_f),lE.prototype.load=function(t,r){var n=this;return new hx(function(a,i){Promise.all(t.urls.map(function(e){return n.request(e,fD({},t,{type:"arraybuffer"}))})).then(function(t){for(var n=function(e){for(var t,r,n,a,i=[],o=0;o<e.length;o++){var s=pI.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(n=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,r=s.engineFormat)}return{mipmapsFaces:i,engineFormat:r,internalFormat:t,width:n,height:a}}(t),i=n.width,o=n.mipmapsFaces,s=n.engineFormat,l=o[0].length>1,c=new dc(r.engine,i,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)}a(c)}).catch(function(e){i(e)})})},lE);pV=fV([hT(e.AssetType.KTXCube,[])],pV);var pN=(fO(lw=function(){return _f.apply(this,arguments)},_f),lw.prototype.load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"arraybuffer"})).then(function(e){for(var r=pO(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new ds(t.engine,a,i,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){a(e)})})},lw);pN=fV([hT(e.AssetType.KTX,["ktx"])],pN);var pk=(fO(lP=function(){return _f.apply(this,arguments)},_f),lP.prototype.load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"json"})).then(function(e){var r=function(e){var r=s[e],n=r.type,a=r.value;switch(n){case"Vector2":h.setVector2(e,new c9(a.x,a.y));break;case"Vector3":h.setVector3(e,new cZ(a.x,a.y,a.z));break;case"Vector4":h.setVector4(e,new c6(a.x,a.y,a.z,a.w));break;case"Color":h.setColor(e,new c7(a.r,a.g,a.b,a.a));break;case"Float":h.setFloat(e,a);break;case"Texture":d.push(t.getResourceByRef(a).then(function(t){h.setTexture(e,t)}));break;case"Boolean":h.setInt(e,a?1:0);break;case"Integer":h.setInt(e,Number(a))}},a=t.engine,i=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new dN(a,u$.find(o));u.name=i;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 a in n)e(t[r],a,n[a]);else t[r]=n}(u,"renderState",c),Promise.all(d).then(function(){n(u)})}).catch(a)})},lP);pk=fV([hT(e.AssetType.Material,["json"])],pk);var pz=(fO(lF=function(){return _f.apply(this,arguments)},_f),lF.prototype.load=function(e,t){var r=this;return new hx(function(n,a){r.request(e.url,fD({},e,{type:"arraybuffer"})).then(function(e){return f3(e,t.engine)}).then(function(e){n(e)}).catch(a)})},lF);pz=fV([hT(e.AssetType.Mesh,["mesh"])],pz);var pU=(fO(lL=function(){return _f.apply(this,arguments)},_f),lL.prototype.load=function(e,t){var r=t.engine;return this.request(e.url,fD({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return ha.createSubdivisionSurfaceSphere(r,e.sphereRadius,e.sphereStep);case"capsule":return ha.createCapsule(r,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return ha.createCone(r,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return ha.createCuboid(r,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return ha.createCylinder(r,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return ha.createPlane(r,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return ha.createTorus(r,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},lL);pU=fV([hT(e.AssetType.PrimitiveMesh,["mesh"],!1)],pU),(lB=cq||(cq={})).Sphere="sphere",lB.Cuboid="cuboid",lB.Plane="plane",lB.Cylinder="cylinder",lB.Torus="torus",lB.Cone="cone",lB.Capsule="capsule";var pG=(fO(lD=function(){return _f.apply(this,arguments)},_f),lD.prototype.load=function(t,r){var n=this,a=r.engine;return new hx(function(i,o){n.request(t.url,fD({},t,{type:"json"})).then(function(t){return a.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){a.sceneManager.activeScene=e,i()})}).catch(o)})},lD);pG=fV([hT(e.AssetType.Project,["proj"],!1)],pG);var pH=(fO(lI=function(){return _f.apply(this,arguments)},_f),(lO=lI.prototype).load=function(e,t){var r=this;return new hx(function(n,a){var i=e.url;r._registerFont(i,i).then(function(){n(new dF(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},lO._registerFont=function(e,t){return f7(function(){var r;return fN(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]}})})()},lI);pH=fV([hT(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],pH);var pW=(fO(lV=function(){var e;return e=_f.apply(this,arguments)||this,e._tempRect=new ue,e._tempVec2=new c9,e._tempVec4=new c6,e},_f),(lN=lV.prototype).load=function(t,r){var n=this;return new hx(function(a,i,o,s,l){var c=[];l(function(){for(var e=0;e<c.length;e++)c[e].cancel()});var u=n.request(t.url,fD({},t,{type:"json"}));c.push(u),u.then(function(o){var s=o.atlasItems,l=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 ug(m);if(p<=0){a(g);return}c.length=0;for(var v=0;v<p;v++)!function(a){var o,p=s[a];if(p.img)c.push(r.load({url:uv.resolveAbsoluteUrl(t.url,p.img),type:null!=(o=p.type)?o:e.AssetType.Texture2D,params:{format:f,mipmap:l}}).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(i));else for(var v=0;v<p.sprites.length;v++)g._addSprite(n._makeSprite(m,p.sprites[v]))}(v);hx.all(c).then(function(){a(g)}).catch(i)}).catch(i)})},lN._makeSprite=function(e,t,r){var n=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new uC(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(i.x*d,i.y*h,i.w*d,i.h*h),a){var _=a.x,f=a.y,p=a.z,m=a.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},lV);pW=fV([hT(e.AssetType.SpriteAtlas,["atlas"],!1)],pW);var pj=(fO(lk=function(){return _f.apply(this,arguments)},_f),(lz=lk.prototype).load=function(e,t){var r=this;return this.request(e.url,fD({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},lz._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},lz._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new uC(e.engine,r,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),n}):new hx(function(r){var n=new uC(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(n.width=a),isNaN(i)||(n.height=i),r(n)})},lk);pj=fV([hT(e.AssetType.Sprite,["sprite"],!1)],pj);var pK=(fO(lU=function(e,t,r){var n;return(n=dR.call(this,e)||this).url=t,n.requestConfig=r,n},dR),lU.prototype.restoreContent=function(){var e=this;return _h(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},lU),pX=(fO(lG=function(){return _f.apply(this,arguments)},_f),lG.prototype.load=function(e,t){var r=this;return new hx(function(n,a,i,o){var s=e.url,l=fD({},e,{type:"image"});r.request(s,l).onProgress(i,o).then(function(r){var a,i=null!=(a=e.params)?a:{},o=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new ds(t.engine,r.width,r.height,o,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!==s.indexOf("data:")){var p=s.lastIndexOf("/");f.name=s.substring(p+1)}t.addContentRestorer(new pK(f,s,l)),n(f)}).catch(function(e){a(e)})})},lG);pX=fV([hT(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],pX);var pY=(fO(lH=function(e,t,r){var n;return(n=dR.call(this,e)||this).urls=t,n.requestConfig=r,n},dR),lH.prototype.restoreContent=function(){var t=this;return new hx(function(r,n){Promise.all(t.urls.map(function(e){return _h(e,t.requestConfig)})).then(function(n){for(var a=t.resource,i=0;i<6;i++)a.setImageSource(e.TextureCubeFace.PositiveX+i,n[i],0);a.generateMipmaps(),r(a)}).catch(function(e){n(e)})})},lH),pq=(fO(lW=function(){return _f.apply(this,arguments)},_f),lW.prototype.load=function(t,r){var n=this;return new hx(function(a,i){var o=t.urls,s=fD({},t,{type:"image"});Promise.all(o.map(function(e){return n.request(e,s)})).then(function(t){var n=t[0],i=n.width;if(i!==n.height){console.error("The cube texture must have the same width and height");return}for(var l=new dc(r.engine,i),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new pY(l,o,s)),a(l)}).catch(function(e){i(e)})})},lW);pq=fV([hT(e.AssetType.TextureCube,[""])],pq);var pQ=(fO(lj=function(){return _f.apply(this,arguments)},_f),lj.prototype.load=function(t,r){var n=this,a=r.engine;return new hx(function(i,o){n.request(t.url,fD({},t,{type:"json"})).then(function(t){return f2.parse(a,t).then(function(n){var a,o,s=[],l=t.scene.ambient;if(l){var c=l.specularMode===e.SpecularMode.Custom,u=l.diffuseMode===e.DiffuseMode.SphericalHarmonics;n.ambientLight.diffuseIntensity=l.diffuseIntensity,n.ambientLight.specularIntensity=l.specularIntensity,n.ambientLight.diffuseMode=l.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(l.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,c&&l.customAmbientLight&&s.push(r.getResourceByRef(l.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),l.ambientLight&&(!c||u)&&s.push(r.getResourceByRef(l.ambientLight).then(function(e){c||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),u&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var d=t.scene.background;switch(n.background.mode=d.mode,n.background.mode){case e.BackgroundMode.SolidColor:n.background.solidColor.copyFrom(d.color);break;case e.BackgroundMode.Sky:if(d.skyMesh&&d.skyMaterial){var h=r.getResourceByRef(d.skyMesh).then(function(e){n.background.sky.mesh=e}),_=r.getResourceByRef(d.skyMaterial).then(function(e){n.background.sky.material=e});s.push(h,_)}else uI.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(d.texture){var f,p=r.getResourceByRef(d.texture).then(function(e){n.background.texture=e});s.push(p),n.background.textureFillMode=null!=(f=d.textureFillMode)?f:n.background.textureFillMode}}var m=t.scene.shadow;m&&(void 0!=m.castShadows&&(n.castShadows=m.castShadows),void 0!=m.shadowResolution&&(n.shadowResolution=m.shadowResolution),void 0!=m.shadowDistance&&(n.shadowDistance=m.shadowDistance),void 0!=m.shadowCascades&&(n.shadowCascades=m.shadowCascades),void 0!=m.enableTransparentShadow&&(n.enableTransparentShadow=m.enableTransparentShadow),n.shadowTwoCascadeSplits=null!=(a=m.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,m.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(m.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(o=m.shadowFadeBorder)?o:n.shadowFadeBorder);var g=t.scene.fog;g&&(void 0!=g.fogMode&&(n.fogMode=g.fogMode),void 0!=g.fogStart&&(n.fogStart=g.fogStart),void 0!=g.fogEnd&&(n.fogEnd=g.fogEnd),void 0!=g.fogDensity&&(n.fogDensity=g.fogDensity),void 0!=g.fogColor&&n.fogColor.copyFrom(g.fogColor));var v=t.scene.postProcess;if(v){var y=n._postProcessManager,x=y._bloomEffect,b=y._tonemappingEffect;if(y.isActive=v.isActive,x.enabled=v.bloom.enabled,x.downScale=v.bloom.downScale,x.threshold=v.bloom.threshold,x.scatter=v.bloom.scatter,x.intensity=v.bloom.intensity,x.tint.copyFrom(v.bloom.tint),x.dirtIntensity=v.bloom.dirtIntensity,b.enabled=v.tonemapping.enabled,b.mode=v.tonemapping.mode,v.bloom.dirtTexture){var T=r.getResourceByRef(v.bloom.dirtTexture).then(function(e){x.dirtTexture=e});s.push(T)}}return Promise.all(s).then(function(){i(n)})})}).catch(o)})},lj);pQ=fV([hT(e.AssetType.Scene,["scene"],!0)],pQ),fQ.registerCustomParseComponent("TextRenderer",f7(function(e,t){var r;return fN(this,function(n){return(r=t.props).font||(e.font=dF.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var pZ=(fO(lK=function(){return pM.apply(this,arguments)},pM),lK.prototype.additiveParse=function(e,t,r){var n,a=e.glTF.extensions.KHR_lights_punctual.lights[r.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,u=e.glTFResource;if("directional"===s?n=t.addComponent(_t):"point"===s?n=t.addComponent(_r):"spot"===s&&(n=t.addComponent(_n)),i&&n.color.set(i[0],i[1],i[2],1),n.intensity=void 0===o?1:o,l&&!fZ(n,_t)&&(n.distance=l),c&&fZ(n,_n)){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)},lK);pZ=fV([pE("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],pZ);var pJ=(fO(lX=function(){return pM.apply(this,arguments)},pM),lX.prototype.additiveParse=function(t,r,n){var a=n.clearcoatFactor,i=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;r.clearCoat=void 0===a?0:a,r.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(e.GLTFParserType.Texture,i.index).then(function(e){r.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(e.GLTFParserType.Texture,l.index).then(function(e){r.clearCoatNormalTexture=e}))},lX);pJ=fV([pE("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],pJ);var p$=(fO(lY=function(){return pM.apply(this,arguments)},pM),lY.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},lY);p$=fV([pE("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],p$);var p0=(fO(lq=function(){return pM.apply(this,arguments)},pM),lq.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dH(a),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,u=r.specularGlossinessTexture;return o&&(i.baseColor=new c7(c7.linearToGammaSpace(o[0]),c7.linearToGammaSpace(o[1]),c7.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,pR.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new c7(c7.linearToGammaSpace(l[0]),c7.linearToGammaSpace(l[1]),c7.linearToGammaSpace(l[2]))),void 0!==c&&(i.glossiness=c),u&&(e.GLTFMaterialParser._checkOtherTextureTransform(u,"Specular glossiness"),t.get(e.GLTFParserType.Texture,u.index).then(function(e){i.specularGlossinessTexture=e})),i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lq);p0=fV([pE("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],p0);var p1=(fO(lQ=function(){return pM.apply(this,arguments)},pM),lQ.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dW(a);return i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},lQ);p1=fV([pE("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],p1);var p2=(fO(lZ=function(){return pM.apply(this,arguments)},pM),lZ.prototype.additiveParse=function(t,r,n){var a=t.glTF.extensions.KHR_materials_variants.variants,i=t.glTFResource,o=n.mappings;i._extensionsData||(i._extensionsData={});var s=[];i.extensionsData.variants=s;for(var l=0;l<o.length;l++)!function(n){var i=o[n],l=i.material,c=i.variants;t.get(e.GLTFParserType.Material,l).then(function(e){s.push({renderer:r,material:e,variants:c.map(function(e){return a[e].name})})})}(l)},lZ);p2=fV([pE("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],p2);var p3=(fO(lJ=function(){return pM.apply(this,arguments)},pM),lJ);p3=fV([pE("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],p3);var p4=(fO(l$=function(){return pM.apply(this,arguments)},pM),l$.prototype.createAndParse=function(t,r,n){return f7(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return fN(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=n.sampler,c=n.name,u=r.source,h=(d=a.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&ps.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:uv.resolveAbsoluteUrl(s,h),type:e.AssetType.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&ps.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,y.buffer).then(function(r){var n=new Uint8Array(r,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(n,o).then(function(t){var r=t.engine,n=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(r,n,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&ps.parseSampler(e,m);var r=new py(e,y,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},l$);p4=fV([pE("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],p4);var p8=(fO(l0=function(){return pM.apply(this,arguments)},pM),l0.prototype.additiveParse=function(e,t,r){var n=r.offset,a=r.rotation,i=r.scale,o=r.texCoord;n&&(t.tilingOffset.z=n[0],t.tilingOffset.w=n[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&uI.warn("rotation in KHR_texture_transform is not supported now"),o&&uI.warn("texCoord in KHR_texture_transform is not supported now")},l0);p8=fV([pE("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],p8);var p5=(fO(l1=function(){return pM.apply(this,arguments)},pM),l1.prototype.createAndParse=function(e,t){var r=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(r),r},l1);p5=fV([pE("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],p5);var p9=(fO(l2=function(){return pM.apply(this,arguments)},pM),l2.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new _C;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},l2);p9=fV([pE("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],p9);var p6=(fO(l3=function(){return pM.apply(this,arguments)},pM),l3.prototype.createAndParse=function(t,r){return t.get(e.GLTFParserType.Buffer,r.buffer).then(function(e){return pw().then(function(t){return t.decodeGltfBuffer(r.count,r.byteStride,new Uint8Array(e,r.byteOffset,r.byteLength),r.mode,r.filter)})})},l3);p6=fV([pE("EXT_meshopt_compression",e.GLTFExtensionMode.CreateAndParse)],p6);var p7=(fO(l4=function(){return pM.apply(this,arguments)},pM),l4.prototype.additiveParse=function(t,r,n){var a=n.anisotropyStrength,i=n.anisotropyRotation,o=n.anisotropyTexture;r.anisotropy=void 0===a?0:a,r.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(e.GLTFParserType.Texture,o.index).then(function(e){r.anisotropyTexture=e}))},l4);p7=fV([pE("KHR_materials_anisotropy",e.GLTFExtensionMode.AdditiveParse)],p7);var me="1.3.0-beta.9";for(var mt in console.log("Galacean engine version: "+me),ff)_f.registerClass(mt,ff[mt]);e.AmbientLight=h7,e.AnimationClip=_S,e.AnimationClipCurveBinding=_T,e.AnimationCurve=_A,e.AnimationEvent=_C,e.Animator=_L,e.AnimatorCondition=_R,e.AnimatorController=_D,e.AnimatorControllerLayer=_N,e.AnimatorControllerParameter=_B,e.AnimatorLayerMask=_U,e.AnimatorState=_O,e.AnimatorStateMachine=_V,e.AnimatorStateTransition=_E,e.AssetPromise=hx,e.Background=h9,e.BaseMaterial=dk,e.BasicRenderPipeline=dC,e.BlendShape=dK,e.BlendShapeFrame=dj,e.BlendState=uY,e.BlinnPhongMaterial=dz,e.BloomEffect=_i,e.BoolUpdateFlag=u9,e.BoundingBox=c$,e.BoundingFrustum=c2,e.BoundingSphere=cJ,e.BoxColliderShape=hW,e.BoxShape=ft,e.Buffer=dI,e.BufferInfo=pn,e.BufferMesh=d$,e.BufferReader=fU,e.BufferUtil=dO,e.Burst=_6,e.Canvas=h8,e.CapsuleColliderShape=hX,e.CharacterController=hL,e.CircleShape=fr,e.ClearableObjectPool=h2,e.CloneManager=uf,e.ColliderShape=hH,e.CollisionUtil=c0,e.Color=c7,e.ColorOverLifetimeModule=_Q,e.Component=u4,e.ConeShape=fn,e.ContentRestorer=dR,e.CubeProbe=f_,e.CurveKey=_2,e.DepthState=uq,e.DirectLight=_t,e.DynamicCollider=hB,e.EmissionModule=_J,e.Engine=h4,e.EngineObject=up,e.Entity=hs,e.EventDispatcher=uw,e.FileHeader=fW,e.FixedJoint=hN,e.Font=dF,e.GLTFExtensionParser=pM,e.GLTFParser=pR,e.GLTFParserContext=pr,e.GLTFResource=pt,e.GLTFUtils=ps,e.GradientAlphaKey=_X,e.GradientColorKey=_K,e.HemisphereShape=fa,e.HingeJoint=hk,e.HitResult=hD,e.IndexBufferBinding=dX,e.InputManager=hQ,e.JointLimits=hU,e.JointMotor=hG,e.Keyframe=_k,e.LayerPathMask=_z,e.Light=_e,e.Loader=_f,e.Logger=uI,e.MainModule=_$,e.Material=dN,e.MathUtil=cQ,e.Matrix=c8,e.Matrix3x3=c3,e.Mesh=dZ,e.MeshRenderer=d0,e.ModelMesh=d2,e.PBRBaseMaterial=dU,e.PBRMaterial=dG,e.PBRSpecularMaterial=dH,e.ParserContext=fq,e.ParticleCompositeCurve=_Z,e.ParticleCompositeGradient=_Y,e.ParticleCurve=_1,e.ParticleGenerator=_5,e.ParticleGradient=_j,e.ParticleMaterial=_9,e.ParticleRenderer=_W,e.PhysicsMaterial=hI,e.PhysicsScene=hF,e.Plane=c1,e.PlaneColliderShape=hK,e.PointLight=_r,e.Pointer=hM,e.PrefabResource=f0,e.Primitive=dQ,e.PrimitiveMesh=ha,e.Probe=fc,e.Quaternion=c4,e.Rand=ur,e.RasterState=uQ,e.Ray=c5,e.Rect=ue,e.ReferResource=um,e.ReflectionParser=fQ,e.RenderQueue=dm,e.RenderState=uJ,e.RenderTarget=di,e.RenderTargetBlendState=uX,e.ResourceManager=hb,e.ReturnableObjectPool=hh,e.RotationOverLifetimeModule=_0,e.SafeLoopArray=hv,e.Scene=_l,e.SceneManager=hy,e.SceneParser=f2,e.Script=_c,e.Shader=u$,e.ShaderData=u2,e.ShaderFactory=uk,e.ShaderLib=uN,e.ShaderMacro=uM,e.ShaderMacroCollection=uR,e.ShaderPass=uj,e.ShaderProperty=uO,e.ShaderTagKey=uz,e.SizeOverLifetimeModule=_3,e.Skin=hl,e.SkinnedMeshRenderer=hc,e.Sky=h5,e.SkyBoxMaterial=_G,e.SkyProceduralMaterial=_H,e.SphereColliderShape=hj,e.SphereShape=fi,e.SphericalHarmonics3=ut,e.SpotLight=_n,e.SpringJoint=hz,e.Sprite=uC,e.SpriteAtlas=ug,e.SpriteMask=dM,e.SpriteRenderer=da,e.StateMachineScript=_I,e.StaticCollider=hO,e.StencilState=uZ,e.SubMesh=dq,e.SubPrimitive=dY,e.SubShader=uK,e.SystemInfo=hw,e.TextRenderer=dB,e.TextUtils=dw,e.Texture=u1,e.Texture2D=ds,e.Texture2DArray=dl,e.TextureCube=dc,e.TextureSheetAnimationModule=_4,e.Time=uV,e.TonemappingEffect=_o,e.TrailMaterial=fo,e.TrailRenderer=fl,e.Transform=u6,e.UnlitMaterial=dW,e.Utils=uv,e.Vector2=c9,e.Vector3=cZ,e.Vector4=c6,e.VelocityOverLifetimeModule=_8,e.VertexBufferBinding=dJ,e.VertexElement=dV,e.WebCanvas=fx,e.WebGLEngine=fb,e.WebGLGraphicDevice=fB,e.XRManager=h3,e._PostProcessManager=_s,e.assignmentClone=ud,e.decode=f3,e.decoder=fH,e.decoderMap=fG,e.deepClone=u_,e.dependentComponents=u5,e.ignoreClone=uu,e.parseSingleKTX=pO,e.registerGLTFExtension=pE,e.registerGLTFParser=po,e.request=_h,e.resourceLoader=hT,e.shallowClone=uh,e.version=me,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|