@galacean/engine 1.3.24 → 1.4.0-alpha.1
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/README.md +1 -1
- package/dist/browser.js +15568 -15291
- 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/main.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +5 -5
- package/dist/miniprogram.js +0 -61
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,(cn=e.ContainmentType||(e.ContainmentType={}))[cn.Disjoint=0]="Disjoint",cn[cn.Contains=1]="Contains",cn[cn.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(ca=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[ca.Back=0]="Back",ca[ca.Front=1]="Front",ca[ca.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(ci=e.FrustumFace||(e.FrustumFace={}))[ci.Near=0]="Near",ci[ci.Far=1]="Far",ci[ci.Left=2]="Left",ci[ci.Right=3]="Right",ci[ci.Bottom=4]="Bottom",ci[ci.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,V,O,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,eV,eO,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,tV,tO,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,rV,rO,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,nV,nO,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,aV,aO,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,iV,iO,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,oV,oO,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,sV,sO,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,lV,lO,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,cV,cO,cN,ck,cz,cU,cG,cH,cW,cj,cK,cX,cY,cq,cQ,cZ,cJ,c$,c0,c1,c2,c3,c4=((co=function(){}).clamp=function(e,t,r){return Math.max(t,Math.min(r,e))},co.equals=function(e,t){return Math.abs(e-t)<=co.zeroTolerance},co.isPowerOf2=function(e){return(e&e-1)==0},co.radianToDegree=function(e){return e*co.radToDegreeFactor},co.degreeToRadian=function(e){return e*co.degreeToRadFactor},co.lerp=function(e,t,r){return e+(t-e)*r},co);c4.zeroTolerance=1e-6,c4.radToDegreeFactor=180/Math.PI,c4.degreeToRadFactor=Math.PI/180;var c8=((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.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e},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 c4.equals(e._x,t._x)&&c4.equals(e._y,t._y)&&c4.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>c4.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);c8._zero=new c8(0,0,0),c8._one=new c8(1,1,1);var c5=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new c8,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)c8.add(e[a],n,n);c8.scale(n,1/r,t.center);for(var i=0,s=0;s<r;++s){var l=c8.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=c8.distance(r,a)},o);c5._tempVec30=new c8;var c9=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new c8,this.max=new c8,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 c8;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){c8.subtract(e,t,r.min),c8.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];c8.min(r,o,r),c8.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),c8.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))),c8.subtract(n,a,r.min),c8.add(n,a,r.max)},l.merge=function(e,t,r){return c8.min(e.min,t.min,r.min),c8.max(e.max,t.max,r.max),r},l);c9._tempVec30=new c8,c9._tempVec31=new c8;var c6=((u=function(){}).intersectionPointThreePlanes=function(e,t,r,n){var a=e.normal,i=t.normal,o=r.normal;c8.cross(i,o,u._tempVec30),c8.cross(o,a,u._tempVec31),c8.cross(a,i,u._tempVec32);var s=-c8.dot(a,u._tempVec30),l=-c8.dot(i,u._tempVec31),c=-c8.dot(o,u._tempVec32);c8.scale(u._tempVec30,e.distance/s,u._tempVec30),c8.scale(u._tempVec31,t.distance/l,u._tempVec31),c8.scale(u._tempVec32,r.distance/c,u._tempVec32),c8.add(u._tempVec30,u._tempVec31,n),c8.add(n,u._tempVec32,n)},u.distancePlaneAndPoint=function(e,t){return c8.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=c4.zeroTolerance,a=c8.dot(r,e.direction);if(Math.abs(a)<n)return -1;var i=c8.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=c4.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;c8.subtract(r,a,o);var s=c8.dot(o,n),l=c8.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 c8.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))),c8.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),c8.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)<c4.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.far,r))<c4.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.left,r))<c4.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.right,r))<c4.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.top,r))<c4.zeroTolerance?e.ContainmentType.Intersects:n<0?e.ContainmentType.Disjoint:Math.abs(n=u.distancePlaneAndPoint(t.bottom,r))<c4.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);c6._tempVec30=new c8,c6._tempVec31=new c8,c6._tempVec32=new c8;var c7=((h=(d=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new c8,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();c8.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),ue=((f=(_=function(e){void 0===e&&(e=null),this.near=new c7,this.far=new c7,this.left=new c7,this.right=new c7,this.top=new c7,this.bottom=new c7,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 c6.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return c6.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},_),ut=((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 c4.equals(r[0],n[0])&&c4.equals(r[1],n[1])&&c4.equals(r[2],n[2])&&c4.equals(r[3],n[3])&&c4.equals(r[4],n[4])&&c4.equals(r[5],n[5])&&c4.equals(r[6],n[6])&&c4.equals(r[7],n[7])&&c4.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),ur=((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<c4.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.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},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-c4.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-c4.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 c4.equals(e._x,t._x)&&c4.equals(e._y,t._y)&&c4.equals(e._z,t._z)&&c4.equals(e._w,t._w)},g.rotationAxisAngle=function(e,t,r){var n=g._tempVector3;c8.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>c4.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-c4.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>c4.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)<c4.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),g);ur._tempVector3=new c8,ur._tempQuat1=new ur;var un=((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)<c4.zeroTolerance||Math.abs(m)<c4.zeroTolerance||Math.abs(g)<c4.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,ur.rotationMatrix3x3(n,t),!0},x.getRotation=function(e){var t=this.elements,r=t[0]+t[5]+t[10];if(r>c4.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],V=a[14],O=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*V+v*O,i[13]=s*D+d*I+p*V+y*O,i[14]=l*D+h*I+m*V+x*O,i[15]=c*D+_*I+g*V+b*O},y.equals=function(e,t){var r=e.elements,n=t.elements;return c4.equals(r[0],n[0])&&c4.equals(r[1],n[1])&&c4.equals(r[2],n[2])&&c4.equals(r[3],n[3])&&c4.equals(r[4],n[4])&&c4.equals(r[5],n[5])&&c4.equals(r[6],n[6])&&c4.equals(r[7],n[7])&&c4.equals(r[8],n[8])&&c4.equals(r[9],n[9])&&c4.equals(r[10],n[10])&&c4.equals(r[11],n[11])&&c4.equals(r[12],n[12])&&c4.equals(r[13],n[13])&&c4.equals(r[14],n[14])&&c4.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)<c4.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;c8.subtract(e,t,s),s.normalize(),c8.cross(r,s,i),i.normalize(),c8.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]=-c8.dot(i,e),a[13]=-c8.dot(o,e),a[14]=-c8.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)<c4.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);un._tempVec30=new c8,un._tempVec31=new c8,un._tempVec32=new c8,un._tempMat30=new ut,un._identity=new un(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var ua=((T=(b=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new c8,this.direction=new c8,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return c6.intersectsRayAndPlane(this,e)},T.intersectSphere=function(e){return c6.intersectsRayAndSphere(this,e)},T.intersectBox=function(e){return c6.intersectsRayAndBox(this,e)},T.getPoint=function(e,t){return c8.scale(this.direction,e,t),t.add(this.origin)},b),ui=((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.copyTo=function(e){return e.x=this._x,e.y=this._y,e},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 c4.equals(e._x,t._x)&&c4.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>c4.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);ui._zero=new ui(0,0),ui._one=new ui(1,1);var uo=((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.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},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 c4.equals(e._x,t._x)&&c4.equals(e._y,t._y)&&c4.equals(e._z,t._z)&&c4.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>c4.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);uo._zero=new uo(0,0,0,0),uo._one=new uo(1,1,1,1);var us=((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.copyTo=function(e){return e.r=this._r,e.g=this._g,e.b=this._b,e.a=this._a,e},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),e._onValueChanged&&e._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),e._onValueChanged&&e._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 c4.equals(e._r,t._r)&&c4.equals(e._g,t._g)&&c4.equals(e._b,t._b)&&c4.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),ul=((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),uc=((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),uu=((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 ud(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function uh(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 u_(e,t,r){return t&&uh(e.prototype,t),r&&uh(e,r),e}function uf(e,t){return(uf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function up(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&&uf(e,t)}function um(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 ug(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function uv(e,t){uT.registerCloneMode(e,t,cs.Ignore)}function uy(e,t){uT.registerCloneMode(e,t,cs.Assignment)}function ux(e,t){uT.registerCloneMode(e,t,cs.Shallow)}function ub(e,t){uT.registerCloneMode(e,t,cs.Deep)}e.Platform=void 0,(I=e.Platform||(e.Platform={}))[I.Android=0]="Android",I[I.IPhone=1]="IPhone",I[I.IPad=2]="IPad",I[I.Mac=3]="Mac",I[I.Unknown=4]="Unknown",e.SpriteMaskInteraction=void 0,(V=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[V.None=0]="None",V[V.VisibleInsideMask=1]="VisibleInsideMask",V[V.VisibleOutsideMask=2]="VisibleOutsideMask",e.SpriteMaskLayer=void 0,(O=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[O.Layer0=1]="Layer0",O[O.Layer1=2]="Layer1",O[O.Layer2=4]="Layer2",O[O.Layer3=8]="Layer3",O[O.Layer4=16]="Layer4",O[O.Layer5=32]="Layer5",O[O.Layer6=64]="Layer6",O[O.Layer7=128]="Layer7",O[O.Layer8=256]="Layer8",O[O.Layer9=512]="Layer9",O[O.Layer10=1024]="Layer10",O[O.Layer11=2048]="Layer11",O[O.Layer12=4096]="Layer12",O[O.Layer13=8192]="Layer13",O[O.Layer14=16384]="Layer14",O[O.Layer15=32768]="Layer15",O[O.Layer16=65536]="Layer16",O[O.Layer17=131072]="Layer17",O[O.Layer18=262144]="Layer18",O[O.Layer19=524288]="Layer19",O[O.Layer20=1048576]="Layer20",O[O.Layer21=2097152]="Layer21",O[O.Layer22=4194304]="Layer22",O[O.Layer23=8388608]="Layer23",O[O.Layer24=16777216]="Layer24",O[O.Layer25=33554432]="Layer25",O[O.Layer26=67108864]="Layer26",O[O.Layer27=134217728]="Layer27",O[O.Layer28=268435456]="Layer28",O[O.Layer29=536870912]="Layer29",O[O.Layer30=1073741824]="Layer30",O[O.Layer31=2147483648]="Layer31",O[O.Everything=4294967295]="Everything",e.TextHorizontalAlignment=void 0,(N=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[N.Left=0]="Left",N[N.Center=1]="Center",N[N.Right=2]="Right",e.TextVerticalAlignment=void 0,(k=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[k.Top=0]="Top",k[k.Center=1]="Center",k[k.Bottom=2]="Bottom",e.OverflowMode=void 0,(z=e.OverflowMode||(e.OverflowMode={}))[z.Overflow=0]="Overflow",z[z.Truncate=1]="Truncate",e.FontStyle=void 0,(U=e.FontStyle||(e.FontStyle={}))[U.None=0]="None",U[U.Bold=1]="Bold",U[U.Italic=2]="Italic","function"==typeof SuppressedError&&SuppressedError,(G=cs||(cs={}))[G.Ignore=0]="Ignore",G[G.Assignment=1]="Assignment",G[G.Shallow=2]="Shallow",G[G.Deep=3]="Deep";var uT=((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!==cs.Ignore){var s=e[r];if(ug(s,Object)){if(void 0===n||n===cs.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,cs.Deep,null,null,r)},H);uT._subCloneModeMap=new Map,uT._cloneModeMap=new Map,uT._objectType=Object.getPrototypeOf(Object);var uC=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)},u_(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();uC._instanceIdCounter=0,um([uv],uC.prototype,"instanceId",void 0),um([uv],uC.prototype,"_engine",void 0);var uS=(up(W=function(e){var t;return(t=uC.call(this,e)||this).isGCIgnored=!1,t._refCount=0,t._superResources=null,e.resourceManager._addReferResource(ud(t)),t},uC),(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 uC.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(){uC.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},u_(W,[{key:"refCount",get:function(){return this._refCount}}]),W),uA=(up(K=function(e){var t;return(t=uS.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},uS),(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(){uS.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},u_(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 uM=((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){if(Q.isAbsoluteUrl(t)||Q.isBase64Url(t))return t;if(!/^https?:/.test(e)){var r="files://";return e=r+e,new URL(t,e).href.substring(r.length)}return 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],V=t[r+14],O=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*V+v*O,n[a+13]=s*D+d*I+p*V+y*O,n[a+14]=l*D+h*I+m*V+x*O,n[a+15]=c*D+_*I+g*V+b*O},Q._reflectGet=function(e,t){for(var r=this._stringToPath(t),n=e,a=0,i=r.length;null!=n&&a<i;)n=n[r[a++]];return a&&a==i?n:void 0},Q._quickSort=function(e,t,r,n){for(;;){if(r-t<=10){this._insertionSort(e,t,r,n);return}var a=t+r>>1,i=e[t],o=e[r-1],s=e[a];if(n(i,o)>0){var l=i;i=o,o=l}if(n(i,s)>=0){var c=i;i=s,s=o,o=c}else if(n(o,s)>0){var 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)===uR&&t.push(""),e.replace(uw,function(e,r,n,a){var i=e;n?i=a.replace(uE,"$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),uR=46,uE=/\\(\\)?/g,uw=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),uP=((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){uM.removeFromArray(this._updateFlags,e)&&uM.removeFromArray(e._flagManagers,this)},J.addListener=function(e){this._listeners.push(e)},J.removeListener=function(e){uM.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);($=cl||(cl={}))[$.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 uF=(up(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=uS.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new ui,new ui,new ui,new ui],o._uvs=[new ui,new ui,new ui,new ui],o._bounds=new c9,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new ul(0,0,1,1),o._atlasRegionOffset=new uo(0,0,0,0),o._region=new ul(0,0,1,1),o._pivot=new ui(.5,.5),o._border=new uo(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new uP,o._texture=t,o._onRegionChange=o._onRegionChange.bind(ud(o)),o._onPivotChange=o._onPivotChange.bind(ud(o)),o._onBorderChange=o._onBorderChange.bind(ud(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},uS),(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;uS.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},et._onDestroy=function(){this._dispatchSpriteChange(cl.destroy),uS.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/_o._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 cl.texture:this._dirtyUpdateFlag|=4;break;case cl.atlasRegionOffset:case cl.region:this._dirtyUpdateFlag|=7;break;case cl.atlasRegion:this._dirtyUpdateFlag|=6;break;case cl.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},et._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=c4.clamp(e.x,0,1),r=c4.clamp(e.y,0,1);e.set(t,r,c4.clamp(e.width,0,1-t),c4.clamp(e.height,0,1-r)),this._dispatchSpriteChange(cl.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(cl.size),e._onValueChanged=this._onRegionChange},et._onPivotChange=function(){this._dispatchSpriteChange(cl.pivot)},et._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=c4.clamp(e.x,0,1),r=c4.clamp(e.y,0,1);e.set(t,r,c4.clamp(e.z,0,1-t),c4.clamp(e.w,0,1-r)),this._dispatchSpriteChange(cl.border),e._onValueChanged=this._onBorderChange},u_(ee,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(cl.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(cl.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(cl.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(cl.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=c4.clamp(e.x,0,1),r=c4.clamp(e.y,0,1);this._atlasRegion.set(t,r,c4.clamp(e.width,0,1-t),c4.clamp(e.height,0,1-r)),this._dispatchSpriteChange(cl.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(cl.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=c4.clamp(e.x,0,1),r=c4.clamp(e.y,0,1);this._atlasRegionOffset.set(t,r,c4.clamp(e.z,0,1-t),c4.clamp(e.w,0,1-r)),this._dispatchSpriteChange(cl.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(cl.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 uL(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 uB(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 uL(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 uL(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=cc||(cc={}))[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 uD=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}();uD._macroMaskMap=[],uD._macroNameIdMap=Object.create(null),uD._macroNameCounter=0,uD._macroCounter=0,uD._macroMap=Object.create(null);var uI=((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 uV(){return(uV=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 uO=((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);uO._dispatchingListenersPool=[];var uN=function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]},uk=console.log.bind(console),uz=console.info.bind(console),uU=console.warn.bind(console),uG=console.error.bind(console),uH={debug:uN,info:uN,warn:uN,error:uN,isEnabled:!1,enable:function(){this.debug=uk,this.info=uz,this.warn=uU,this.error=uG,this.isEnabled=!0},disable:function(){this.debug=uN,this.info=uN,this.warn=uN,this.error=uN,this.isEnabled=!1}},uW=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},u_(e,[{key:"type",get:function(){return this._type}}]),e}();uW._propertyIdMap=Object.create(null),uW._propertyNameCounter=0,uW._propertyNameMap=Object.create(null);var uj=((ey=(ev=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new uo,this._deltaTimeValue=new uo,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)},u_(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);uj._elapsedTimeProperty=uW.getByName("scene_ElapsedTime"),uj._deltaTimeProperty=uW.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 uK=uV({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#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\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 tileRow=frame*renderer_TSATillingParams.x;float tileRowIndex=floor(tileRow);uv.x+=tileRow-tileRowIndex;uv.y+=tileRowIndex*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"}),uX=((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(uK[e])throw'The "'+e+'" shader include already exist';uK[e]=t},eT.unRegisterInclude=function(e){delete uK[e]},eT.parseIncludes=function(e,t){return void 0===t&&(t=/^[ \t]*#include +<([\w\d.]+)>/gm),e.replace(t,function(e,r){var n=uK[r];return void 0===n?(uH.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);uX._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(""),uX._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var uY=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}();uY._nameCounter=0,uY._nameMap=Object.create(null);var uq=((eS=(eC=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var r="string"==typeof e?uY.getByName(e):e,n=this._tagsMap;void 0!==n[r._uniqueId]&&uH.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?uY.getByName(e):e)._uniqueId]},eS.getTagValue=function(e){return this._tagsMap["string"==typeof e?uY.getByName(e)._uniqueId:e._uniqueId]},u_(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 uQ=((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,us.gammaToLinearSpace(r.r),us.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,us.gammaToLinearSpace(r.r),us.gammaToLinearSpace(r.g),us.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,us.gammaToLinearSpace(r.r),us.gammaToLinearSpace(r.g),us.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),uZ=function(){this.constUniforms=[],this.textureUniforms=[]};(eE=cu||(cu={}))[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 uJ=function(){function e(t,r,n){this.sceneUniformBlock=new uZ,this.cameraUniformBlock=new uZ,this.rendererUniformBlock=new uZ,this.materialUniformBlock=new uZ,this.renderElementUniformBlock=new uZ,this.otherUniformBlock=new uZ,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=uW._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 cu.Scene:r?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case cu.Camera:r?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case cu.Renderer:r?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case cu.Material:r?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case cu.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),!uH.isEnabled||r.getProgramParameter(i,r.LINK_STATUS)||r.isContextLost())?i:(uH.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),!uH.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 uQ(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=uW.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 ui(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new c8(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new uo(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 ui(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new c8(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new uo(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=uW._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")},u_(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();uJ._counter=0,(ew=cd||(cd={}))[ew.Canonical=0]="Canonical",ew[ew.ShaderLab=1]="ShaderLab";var u$=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=cd.Canonical,"string"==typeof o?(l._name=n,l._shaderLabSource=a,l._vertexEntry=i,l._fragmentEntry=o,s=uV({pipelineStage:e.PipelineStage.Forward},s),l._type=cd.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}up(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===cd.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++){var n=e[t];n._destroy(),delete n.engine._shaderProgramPools[this._shaderPassId]}e.length=0},n._compileShaderProgram=function(t,n,a,i){var o=this._path,s=this._platformMacros,l=t._hardwareRenderer.isWebGL2,c=[];uD._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=u9._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 uH.info("[ShaderLab compilation] cost time: "+(performance.now()-u)+"ms"),new uJ(t,h,_)},n._getCanonicalShaderProgram=function(t,r){var n=t._hardwareRenderer.isWebGL2,a=[];uD._getMacrosElements(r,a);var i=uX.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 "+uX.parseIncludes(this._vertexSource),u=" "+o+"\n "+s+"\n "+(n?"":uX._shaderExtension)+"\n "+l+"\n "+i+"\n "+uX.parseIncludes(this._fragmentSource);return n&&(c=uX.convertTo300(c),u=uX.convertTo300(u,!0)),new uJ(t,c,u)},r}(uq);u$._shaderPassCounter=0,u$._shaderRootPath="shaders://root/";var u0=(up(eP=function(e,t,r){var n;if((n=uq.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},uq),u_(eP,[{key:"passes",get:function(){return this._passes}}]),eP),u1=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},u2=((eL=(eF=function(){this.targetBlendState=new u1,this.blendColor=new us(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;us.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);um([ub],u2.prototype,"targetBlendState",void 0),um([ub],u2.prototype,"blendColor",void 0);var u3=((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),u4=((eV=(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)},eV._apply=function(e,t,r){this._platformApply(e,t.rasterState,r)},eV._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),u8=((eN=(eO=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,eO._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(r.stencilFuncSeparate(r.BACK,eO._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,eO._getGLStencilOperation(e,l),eO._getGLStencilOperation(e,c),eO._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(d!==t.failOperationBack||h!==t.zFailOperationBack||_!==t.passOperationBack)&&(r.stencilOpSeparate(r.BACK,eO._getGLStencilOperation(e,d),eO._getGLStencilOperation(e,h),eO._getGLStencilOperation(e,_)),t.failOperationBack=d,t.zFailOperationBack=h,t.passOperationBack=_),f!==t.writeMask&&(r.stencilMask(f),t.writeMask=f)}},eO._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}},eO._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}},eO),u5=((ez=(ek=function(){this.blendState=new u2,this.depthState=new u3,this.stencilState=new u8,this.rasterState=new u4,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);um([ub],u5.prototype,"blendState",void 0),um([ub],u5.prototype,"depthState",void 0),um([ub],u5.prototype,"stencilState",void 0),um([ub],u5.prototype,"rasterState",void 0);var u9=((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=uB(this._subShaders);!(t=r()).done;)for(var n,a=t.value,i=uB(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(uD.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 u$(t,r);n=new eU(e,[new u0("Default",[i])])}else if(t.length>0)n=t[0].constructor===u$?new eU(e,[new u0("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 u$(e.name,e.contents,e.vertexEntry,e.fragmentEntry,e.tags),i=e.renderStates,o=new u5;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]=uW.getByName(l[d]);return a._renderStateDataMap=u,a});return new u0(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 uD.getByName(e,t)},eU.getPropertyByName=function(e){return uW.getByName(e)},u_(eU,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),eU);u9._compileMacros=new uI,u9._shaderMap=Object.create(null);var u6=(up(eH=function(e){var t;return(t=uS.call(this,e)||this)._isContentLost=!1,e.resourceManager._addGraphicResource(ud(t)),t},uS),eH.prototype._onDestroy=function(){uS.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},u_(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 u7=(up(eK=function(){var e;return e=u6.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},u6),(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(){u6.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},u_(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,uH.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&&(uH.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(uH.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),de=((eq=(eY=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new uI,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=uW.getByName(e)),this._propertyValueMap[e._uniqueId]},eq.enableMacro=function(e,t){"string"==typeof e&&(e=uD.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=uD._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=uW._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){uT.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(ug(l,u7))n[s]=l,t>0&&l._addReferCount(t);else if(ug(l,Array)||ug(l,Float32Array)||ug(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=uW.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 "+cu[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&&ug(n,u7)&&n._addReferCount(e)}},eY);um([uv],de.prototype,"_group",void 0),um([uv],de.prototype,"_propertyValueMap",void 0),um([uv],de.prototype,"_macroCollection",void 0),um([uv],de.prototype,"_macroMap",void 0),um([uv],de.prototype,"_refCount",void 0);var dt=((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=dD._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);dt._disableBatchTag=uY.getByName("spriteDisableBatching"),(eZ=ch||(ch={}))[eZ.None=0]="None",eZ[eZ.Scene=1]="Scene",eZ[eZ.Hierarchy=2]="Hierarchy",eZ[eZ.All=3]="All";var dr=(up(eJ=function(e){var t;return(t=uC.call(this,e.engine)||this)._awoken=!1,t._phasedActiveInScene=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},uC),(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&ch.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&ch.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(){uC.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},u_(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);um([uv],dr.prototype,"_entity",void 0),um([uv],dr.prototype,"_awoken",void 0),um([uv],dr.prototype,"_phasedActiveInScene",void 0),um([uv],dr.prototype,"_phasedActive",void 0),um([uy],dr.prototype,"_enabled",void 0);var dn=((e0=function(){})._addCheck=function(e,t){for(;t!==dr;){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!==dr;){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 da(e,t){void 0===t&&(t=0);var r=Array.isArray(e)?e:[e];return function(e){dn._dependenciesMap.set(e,{mode:t,components:r}),r.forEach(function(t){return dn._addInvDependency(t,e)})}}dn._invDependenciesMap=new Map,dn._dependenciesMap=new Map,e.DependentMode=void 0,(e1=e.DependentMode||(e.DependentMode={}))[e1.CheckOnly=0]="CheckOnly",e1[e1.AutoAdd=1]="AutoAdd";var di=((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++)uM.removeFromArray(e[t]._updateFlags,this)},up(e4=function(){var e;return e=e2.apply(this,arguments)||this,e.flag=!0,e},e2),e4.prototype.dispatch=function(){this.flag=!0},e4),ds=(up(e8=function(e){var t;return(t=dr.call(this,e)||this)._position=new c8,t._rotation=new c8,t._rotationQuaternion=new ur,t._scale=new c8(1,1,1),t._worldPosition=new c8,t._worldRotation=new c8,t._worldRotationQuaternion=new ur,t._lossyWorldScale=new c8(1,1,1),t._localMatrix=new un,t._worldMatrix=new un,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new uP,t._onPositionChanged=t._onPositionChanged.bind(ud(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(ud(t)),t._onRotationChanged=t._onRotationChanged.bind(ud(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(ud(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(ud(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(ud(t)),t._onScaleChanged=t._onScaleChanged.bind(ud(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},dr),(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*c4.degreeToRadFactor;ur.rotationAxisAngle(e,n,e8._tempQuat0),this._rotateByQuat(e8._tempQuat0,r)},e5.lookAt=function(e,t){var r=e8._tempVec30;c8.subtract(this.worldPosition,e,r);var n=r.length();if(!(n<=c4.zeroTolerance)){r.scale(1/n);var a=e8._tempVec31;if(t?c8.cross(t,r,a):a.set(r.z,0,-r.x),!((n=a.length())<=c4.zeroTolerance)){a.scale(1/n);var i=e8._tempVec32;c8.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(di)},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(){dr.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),ur.invert(this.worldRotationQuaternion,e),ut.rotationQuaternion(e,t),ut.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?ur.multiply(this.rotationQuaternion,e,this._rotationQuaternion):ur.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},e5._translate=function(e,t){if(void 0===t&&(t=!0),t){var r=e8._tempVec30;c8.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=c4.degreeToRadFactor,i=e8._tempQuat0;ur.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?(un.invert(t.worldMatrix,e8._tempMat41),c8.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;ur.rotationEuler(c4.degreeToRadian(e.x),c4.degreeToRadian(e.y),c4.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;ur.invert(t.worldRotationQuaternion,r),ur.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},e5._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},u_(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(c4.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(c4.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,ur.rotationEuler(c4.degreeToRadian(this._rotation.x),c4.degreeToRadian(this._rotation.y),c4.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):ur.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?ur.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):ur.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)&&(un.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?un.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?(un.invert(t.worldMatrix,e8._tempMat42),un.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 c8),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 c8),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 c8),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),e8);function dl(){return function(e){}}ds._tempQuat0=new ur,ds._tempVec30=new c8,ds._tempVec31=new c8,ds._tempVec32=new c8,ds._tempMat30=new ut,ds._tempMat31=new ut,ds._tempMat32=new ut,ds._tempMat41=new un,ds._tempMat42=new un,um([ub],ds.prototype,"_position",void 0),um([ub],ds.prototype,"_rotation",void 0),um([ub],ds.prototype,"_rotationQuaternion",void 0),um([ub],ds.prototype,"_scale",void 0),um([ub],ds.prototype,"_worldPosition",void 0),um([ub],ds.prototype,"_worldRotation",void 0),um([ub],ds.prototype,"_worldRotationQuaternion",void 0),um([ub],ds.prototype,"_lossyWorldScale",void 0),um([ub],ds.prototype,"_localMatrix",void 0),um([ub],ds.prototype,"_worldMatrix",void 0),um([uv],ds.prototype,"_worldForward",void 0),um([uv],ds.prototype,"_worldRight",void 0),um([uv],ds.prototype,"_worldUp",void 0),um([uv],ds.prototype,"_isParentDirty",void 0),um([uv],ds.prototype,"_parentTransformCache",void 0),um([uv],ds.prototype,"_updateFlagManager",void 0),um([uv],ds.prototype,"_onPositionChanged",null),um([uv],ds.prototype,"_onWorldPositionChanged",null),um([uv],ds.prototype,"_onRotationChanged",null),um([uv],ds.prototype,"_onWorldRotationChanged",null),um([uv],ds.prototype,"_onRotationQuaternionChanged",null),um([uv],ds.prototype,"_onWorldRotationQuaternionChanged",null),um([uv],ds.prototype,"_onScaleChanged",null),(e9=c_||(c_={}))[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=(up(e6=function(t){(r=dr.call(this,t)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new uI,r._bounds=new c9,r._maskInteraction=e.SpriteMaskInteraction.None,r._maskLayer=e.SpriteMaskLayer.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new uo,r._shaderData=new de(cu.Renderer),r._mvMatrix=new un,r._mvpMatrix=new un,r._mvInvMatrix=new un,r._normalMatrix=new un,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(ud(r)),r._setTransform(t.transform),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,r._rendererLayer),r},dr),(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?(c8.subtract(a,n,a),this._distanceForSort=c8.dot(a,r.forward)):this._distanceForSort=c8.distanceSquared(a,n),this._render(t),uI.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(){dr.prototype._onDestroy.call(this),this._setTransform(null),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._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=un._identity;un.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;un.multiply(t.viewMatrix,r,s),un.invert(s,i),un.invert(r,l),l.transpose(),a.setMatrix(e.Renderer._localMatrixProperty,this._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;un.multiply(t.viewProjectionMatrix,r,a),this.shaderData.setMatrix(e.Renderer._mvpMatrixProperty,a)}},e7._setTransform=function(e){var t;null==(t=this._transform)||t._updateFlagManager.removeListener(this._onTransformChanged),null==e||e._updateFlagManager.addListener(this._onTransformChanged),this._transform=e},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},u_(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 c8,e6._receiveShadowMacro=uD.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e6._localMatrixProperty=uW.getByName("renderer_LocalMat"),e6._worldMatrixProperty=uW.getByName("renderer_ModelMat"),e6._mvMatrixProperty=uW.getByName("renderer_MVMat"),e6._mvpMatrixProperty=uW.getByName("renderer_MVPMat"),e6._mvInvMatrixProperty=uW.getByName("renderer_MVInvMat"),e6._normalMatrixProperty=uW.getByName("renderer_NormalMat"),e6._rendererLayerProperty=uW.getByName("renderer_Layer"),e6),um([uv],e.Renderer.prototype,"_distanceForSort",void 0),um([uv],e.Renderer.prototype,"_onUpdateIndex",void 0),um([uv],e.Renderer.prototype,"_rendererIndex",void 0),um([uv],e.Renderer.prototype,"_globalShaderMacro",void 0),um([uv],e.Renderer.prototype,"_bounds",void 0),um([uv],e.Renderer.prototype,"_renderFrameCount",void 0),um([uy],e.Renderer.prototype,"_maskInteraction",void 0),um([uy],e.Renderer.prototype,"_maskLayer",void 0),um([uv],e.Renderer.prototype,"_batchedTransformShaderData",void 0),um([uv],e.Renderer.prototype,"_overrideUpdate",void 0),um([uv],e.Renderer.prototype,"_materials",void 0),um([uv],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),um([uv],e.Renderer.prototype,"_rendererLayer",void 0),um([uv],e.Renderer.prototype,"_transform",void 0),um([ub],e.Renderer.prototype,"_shaderData",void 0),um([uv],e.Renderer.prototype,"_mvMatrix",void 0),um([uv],e.Renderer.prototype,"_mvpMatrix",void 0),um([uv],e.Renderer.prototype,"_mvInvMatrix",void 0),um([uv],e.Renderer.prototype,"_normalMatrix",void 0),um([uv],e.Renderer.prototype,"_materialsInstanced",void 0),um([uy],e.Renderer.prototype,"_priority",void 0),um([uy],e.Renderer.prototype,"_receiveShadows",void 0),um([uv],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=um([da(ds,e.DependentMode.CheckOnly)],e.Renderer),(te=cf||(cf={}))[te.WorldVolume=1]="WorldVolume";var dc=((tt=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(4);n.indices=dc._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=dc._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]}c9.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 un,tt);dc=um([dl()],dc);var du=((tr=function(){}).resetData=function(e){var t=e._getChunkManager(),r=e._subChunk;r&&t.freeSubChunk(r);var n=t.allocateSubChunk(16);n.indices=du._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=du._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 V=t[D],O=0;O<4;O++,I+=9){var N=r[O];B[I]=E[0]*V+E[4]*N+E[12],B[I+1]=E[1]*V+E[5]*N+E[13],B[I+2]=E[2]*V+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 un,tr);du=um([dl()],du);var dd=((ta=(tn=function(e){void 0===e&&(e=0),this.length=0,this._loopCounter=0,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._loopCounter>0)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,n)}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,a)}this._endLoopAndClean(r,n,t)},ta.sort=function(e){uM._quickSort(this._elements,0,this.length,e)},ta.garbageCollection=function(){this._elements.length=this.length},ta._startLoop=function(){++this._loopCounter},ta._endLoop=function(e){if(0==--this._loopCounter&&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];null==e||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){if(0==--this._loopCounter){for(var n=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[n]=o,null==r||r(o,n),n++)}this.length=n,this._blankCount=0}},u_(tn,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),tn),dh=((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,_=dh._posRow,f=dh._posColumn,p=dh._uvRow,m=dh._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===e.SpriteTileMode.Adaptive?dh._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):dh._calculateContinuousDividing(u,l,c,_,f,p,m,g);dh.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,T=t.width*x,C=t.height*b,S=dh._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,V=D.indices,O=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))){V[N++]=O,V[N++]=O+1,V[N++]=O+2,V[N++]=O+2,V[N++]=O+1,V[N++]=O+3,O+=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=dh._posRow,r=dh._posColumn,n=dh._uvRow,a=dh._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,V=P*m.y,O=I+V,N=P-O;B>=t?(h=3,u=0):D>c4.zeroTolerance?(h=4+(f=(f=(t-B)/D)%1>=n?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),O>=r?(_=3,d=0):N>c4.zeroTolerance?(_=4+(p=(p=(r-O)/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,uH.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/O,i.add(P*x*c),i.add(V*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(V),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/(O+p*N),i.add(P*x*c),i.add(V*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(V+(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,V=E-I;F>=t?(u=3,l=0):L>c4.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=r?(d=3,c=0):V>c4.zeroTolerance?(d=4+(0|(_=(r-I)/V)),c=2):(d=4,c=1);var O=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),O+=2,N+=2,uH.warn("The number of vertices exceeds the upper limit("+s+")."),O*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),O+=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),O+=4;break;case 2:n.add(R*g),n.add(w),i.add(C.x),i.add(S.x),i.add(S.x),O+=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),O+=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),O+=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)*V),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 O*N},ti._worldMatrix=new un,ti._posRow=new dd,ti._posColumn=new dd,ti._uvRow=new dd,ti._uvColumn=new dd,ti);dh=um([dl()],dh),(to=cp||(cp={}))[to.Compressed=0]="Compressed",to[to.WithoutTiled=1]="WithoutTiled",to[to.WithTiled=2]="WithTiled";var d_=(ts=e.Renderer,up(tl=function(t){var r;return(r=ts.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,r._tiledAdaptiveThreshold=.5,r._color=new us(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(ud(r)),r._color._onValueChanged=r._onColorChanged.bind(ud(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 dt.canBatchSprite(e,t)},tc._batch=function(e,t){dt.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&cf.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~cf.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 cl.texture:this.shaderData.setTexture(tl._textureProperty,this.sprite.texture);break;case cl.size:var r=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=cf.WorldVolume:r===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=cm.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=cf.WorldVolume);break;case cl.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=cm.WorldVolumeAndUV);break;case cl.region:case cl.atlasRegionOffset:this._dirtyUpdateFlag|=cm.WorldVolumeAndUV;break;case cl.atlasRegion:this._dirtyUpdateFlag|=2;break;case cl.pivot:this._dirtyUpdateFlag|=cf.WorldVolume;break;case cl.destroy:this.sprite=null}},tc._onColorChanged=function(){this._dirtyUpdateFlag|=4},u_(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=dc;break;case e.SpriteDrawMode.Sliced:this._assembler=du;break;case e.SpriteDrawMode.Tiled:this._assembler=dh}this._assembler.resetData(this),this._dirtyUpdateFlag|=cm.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cm.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=c4.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=cm.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?cm.VertexData:cf.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?cm.VertexData:cf.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=cf.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=cf.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);d_._textureProperty=uW.getByName("renderer_SpriteTexture"),um([uv],d_.prototype,"_subChunk",void 0),um([uv],d_.prototype,"_drawMode",void 0),um([uy],d_.prototype,"_assembler",void 0),um([uy],d_.prototype,"_tileMode",void 0),um([uy],d_.prototype,"_tiledAdaptiveThreshold",void 0),um([ub],d_.prototype,"_color",void 0),um([uv],d_.prototype,"_sprite",void 0),um([uv],d_.prototype,"_automaticWidth",void 0),um([uv],d_.prototype,"_automaticHeight",void 0),um([uy],d_.prototype,"_customWidth",void 0),um([uy],d_.prototype,"_customHeight",void 0),um([uy],d_.prototype,"_flipX",void 0),um([uy],d_.prototype,"_flipY",void 0),um([uv],d_.prototype,"_onSpriteChange",null),um([uv],d_.prototype,"_onColorChanged",null),(tu=cm||(cm={}))[tu.UV=2]="UV",tu[tu.Color=4]="Color",tu[tu.AutomaticSize=8]="AutomaticSize",tu[tu.WorldVolumeAndUV=2|cf.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 df=(up(tg=function(t,r,n,a,i,o){if(void 0===i&&(i=e.TextureFormat.Depth),void 0===o&&(o=1),(s=u6.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=ug(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(ug(i,u7)){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(ud(s)),s},u6),(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(){u6.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)},u_(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),dp=(up(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=u7.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(ud(s)),s.filterMode=s._isIntFormat()?e.TextureFilterMode.Point:e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u7),(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),u7.prototype._rebuild.call(this)},ty),dm=(up(tb=function(t,r,n,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=u7.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(ud(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},u7),(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),u7.prototype._rebuild.call(this)},u_(tb,[{key:"length",get:function(){return this._length}}]),tb),dg=(up(tC=function(t,r,n,a){var i;return void 0===n&&(n=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=u7.call(this,t)||this)._mipmap=a,i._width=r,i._height=r,i._format=n,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(ud(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},u7),(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),u7.prototype._rebuild.call(this)},tC),dv=((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 dp(e,r,n,a,i)).isGCIgnored=!0):(t=new dp(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 df(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 df(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=u9._compileMacros;uI.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);dv._blitTextureProperty=uW.getByName("renderer_BlitTexture"),dv._blitMipLevelProperty=uW.getByName("renderer_BlitMipLevel"),dv._blitTexelSizeProperty=uW.getByName("renderer_texelSize"),dv._rendererShaderData=new de(cu.Renderer),dv._texelSize=new uo,dv.defaultViewport=new uo(0,0,1,1);var dy=function(){this.position=new c8,this.isOrthographic=!1,this.viewMatrix=new un,this.projectionMatrix=new un,this.viewProjectionMatrix=new un,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new c8};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 dx=function(){};dx.tempVec4=new uo,dx.tempVec3=new c8,dx.tempVec2=new ui,e.Camera=(up(tL=function(t){(r=dr.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 uI,r._frustum=new ue,r._virtualCamera=new dy,r._replacementShader=null,r._replacementSubShaderTag=null,r._replacementFailureStrategy=null,r._cameraIndex=-1,r._priority=0,r._shaderData=new de(cu.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 uo,r._opaqueTextureEnabled=!1,r._enableHDR=!1,r._enablePostProcess=!1,r._viewport=new uo(0,0,1,1),r._pixelViewport=new ul(0,0,0,0),r._inverseProjectionMatrix=new un,r._invViewProjMat=new un;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 dF(ud(r)),r._addResourceReferCount(r.shaderData,1),r._updatePixelViewport(),r._onPixelViewportChanged=r._onPixelViewportChanged.bind(ud(r)),r._viewport._onValueChanged=r._onPixelViewportChanged,r.engine.canvas._sizeUpdateFlagManager.addListener(r._onPixelViewportChanged),r},dr),(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=dx.tempVec3,n=dx.tempVec4;c8.transformCoordinate(e,this.viewMatrix,r),c8.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-c4.zeroTolerance,r,t.direction);return c8.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=dx.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,i=a._renderContext,o=this._virtualCamera,s=this.entity.transform;un.multiply(this.projectionMatrix,this.viewMatrix,o.viewProjectionMatrix),o.position.copyFrom(s.worldPosition),o.isOrthographic&&o.forward.copyFrom(s.worldForward),i.camera=this,i.virtualCamera=o,i.replacementShader=this._replacementShader,i.replacementTag=this._replacementSubShaderTag,i.replacementFailureStrategy=this._replacementFailureStrategy,this.enableFrustumCulling&&this._frustumChangeFlag.flag&&(this._frustum.calculateFromMatrix(o.viewProjectionMatrix),this._frustumChangeFlag.flag=!1),this._updateShaderData(),uI.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),r>0&&!a._hardwareRenderer.isWebGL2&&(r=0,uH.error("mipLevel only take effect in WebGL2.0")),this._cameraType===e.CameraType.Normal||this._renderTarget||this.independentCanvasEnabled||(n=a.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(i,t,r,n),a._renderCount++},tB.setReplacementShader=function(t,r,n){void 0===n&&(n=e.ReplacementFailureStrategy.KeepOriginalShader),this._replacementShader=t,this._replacementSubShaderTag="string"==typeof r?uY.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;dr.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=dx.tempVec3;return i.set(2*e-1,1-2*t,2*r-1),c8.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,un.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},tB._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,un.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&&uo.equals(this._viewport,dv.defaultViewport)&&uH.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.")},u_(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 un.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;un.ortho(-n,n,-a,a,this.nearClipPlane,this.farClipPlane,t)}else un.perspective(c4.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){uH.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=uW.getByName("camera_DepthTexture"),tL._cameraOpaqueTextureProperty=uW.getByName("camera_OpaqueTexture"),tL._inverseViewMatrixProperty=uW.getByName("camera_ViewInvMat"),tL._cameraPositionProperty=uW.getByName("camera_Position"),tL._cameraForwardProperty=uW.getByName("camera_Forward"),tL._cameraUpProperty=uW.getByName("camera_Up"),tL._cameraDepthBufferParamsProperty=uW.getByName("camera_DepthBufferParams"),tL),um([ub],e.Camera.prototype,"_frustum",void 0),um([uv],e.Camera.prototype,"_renderPipeline",void 0),um([uv],e.Camera.prototype,"_virtualCamera",void 0),um([uv],e.Camera.prototype,"_cameraIndex",void 0),um([uv],e.Camera.prototype,"_frustumChangeFlag",void 0),um([uv],e.Camera.prototype,"_transform",void 0),um([uv],e.Camera.prototype,"_isViewMatrixDirty",void 0),um([uv],e.Camera.prototype,"_isInvViewProjDirty",void 0),um([ub],e.Camera.prototype,"_viewport",void 0),um([ub],e.Camera.prototype,"_pixelViewport",void 0),um([ub],e.Camera.prototype,"_inverseProjectionMatrix",void 0),um([ub],e.Camera.prototype,"_invViewProjMat",void 0),um([uv],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=um([da(ds,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 db=function(e){this.engine=e},dT=((tO=(tV=function(){this._projectionParams=new uo,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&&(un.multiply(tV._flipYMatrix,a,tV._flipYProjectionMatrix),un.multiply(tV._flipYProjectionMatrix,n,tV._flipYViewProjectionMatrix),a=tV._flipYProjectionMatrix,i=tV._flipYViewProjectionMatrix),this.viewMatrix=n,this.projectionMatrix=a,this.viewProjectionMatrix=i,r.setMatrix(tV._viewMatrixProperty,n),r.setMatrix(tV._projectionMatrixProperty,a),r.setMatrix(tV.vpMatrixProperty,i);var o=this._projectionParams;o.set(t?-1:1,e.nearClipPlane,e.farClipPlane,0),r.setVector4(tV._cameraProjectionProperty,o)},tO.garbageCollection=function(){this.camera=null},tV);dT.vpMatrixProperty=uW.getByName("camera_VPMat"),dT.pipelineStageKey=uY.getByName("pipelineStage"),dT._flipYMatrix=new un(1,0,0,0,0,-1),dT._cameraProjectionProperty=uW.getByName("camera_ProjectionParams"),dT._viewMatrixProperty=uW.getByName("camera_ViewMat"),dT._projectionMatrixProperty=uW.getByName("camera_ProjMat"),dT._flipYProjectionMatrix=new un,dT._flipYViewProjectionMatrix=new un,(tN=cg||(cg={}))[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 dC=((tz=(tk=function(){this.allSpriteMasks=new dd,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 dS(e.RenderQueueType.Transparent))},tk.getMaskDecrementRenderQueue=function(){return tk._maskDecrementRenderQueue||(tk._maskDecrementRenderQueue=new dS(e.RenderQueueType.Transparent))},tk),dS=((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=dT.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&cg.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(t,!1,b),x._batchedTransformShaderData=b):o&cg.ProjectionMatrix&&x._updateTransformShaderData(t,!0,b),x._maskInteraction!==e.SpriteMaskInteraction.None&&this._drawMask(t,r,y);var T=u9._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(uI.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 V,O,N=A[D];if(N.getTagValue(m)===r&&(null!=(V=N._renderState)?V: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!=(O=N._renderState)?O: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){uM._quickSort(this.elements,0,this.elements.length,e)},tG._batch=function(e){e.batch(this)},tG._drawMask=function(e,t,r){var n=dC.getMaskIncrementRenderQueue();n.renderQueueType=this.renderQueueType,n.clear();var a=dC.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=cv||(cv={}))[tH.No=0]="No",tH[tH.Increment=1]="Increment",tH[tH.Decrement=2]="Decrement";var dA=function(){this.virtualCamera=new dy,this.cullPlanes=[new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8),new c7(new c8)],this.splitBoundSphere=new c5(new c8,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=cy||(cy={}))[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 dM=((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(c4.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,c8.scale(n,i,_),c8.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),c6.intersectionPointThreePlanes(v,m,p,o[7]),c6.intersectionPointThreePlanes(v,g,p,o[6]),c6.intersectionPointThreePlanes(v,g,f,o[5]),c6.intersectionPointThreePlanes(v,m,f,o[4]),c6.intersectionPointThreePlanes(y,m,p,o[3]),c6.intersectionPointThreePlanes(y,g,p,o[2]),c6.intersectionPointThreePlanes(y,g,f,o[1]),c6.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>c8.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]];c8.add(L,a,u),c7.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(c8.dot(c,e)*f)*p,g=Math.ceil(c8.dot(c,t)*f)*p,v=c8.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;c8.scale(r,u+a,x),c8.subtract(c,x,x),un.lookAt(x,c,e,b),un.ortho(-h,h,-h,h,0,2*u+a,T);var C=y.viewProjectionMatrix;un.multiply(T,b,C),uM._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;uM._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);dM._tempMatrix0=new un,dM._shadowMapCoordMatrix=new un(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),dM._frustumCorners=[new c8,new c8,new c8,new c8,new c8,new c8,new c8,new c8],dM._adjustNearPlane=new c7(new c8),dM._adjustFarPlane=new c7(new c8),dM._backPlaneFaces=[,,,,,],dM._edgePlanePoint2=new c8,dM._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]],dM._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]]],dM.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 dR=function(t){function r(n){var a;return(a=t.call(this,n.engine)||this)._shadowMapSize=new uo,a._shadowBias=new ui,a._shadowSliceData=new dA,a._lightUp=new c8,a._lightSide=new c8,a._splitBoundSpheres=new Float32Array(4*r._maxCascades),a._shadowMatrices=new Float32Array((r._maxCascades+1)*16),a._shadowInfos=new uo,a._viewportOffsets=[new ui,new ui,new ui,new ui],a._camera=n,a._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}up(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=dv.recreateRenderTargetIfNeeded(o,this._renderTarget,R,E,null,w,!0,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear)).depthTexture:(a=dv.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),un.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++){dM.getBoundSphereByFrustum(y[L],y[L+1],s,P,c),dM.getDirectionLightShadowCullPlanes(s._frustum,y[L],s.nearClipPlane,A,c),dM.getDirectionalLightMatrices(C,S,A,L,n.shadowNearPlane,F,c,d),v>1&&dM.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 V=m._renderers,O=V._elements,N=V.length-1;N>=0;--N)dM.shadowCullFrustum(t,n,O[N],c);if(_.elements.length||f.elements.length){o._renderCount++;var k=o._batcherManager;_.sortBatch(dS.compareForOpaque,k),f.sortBatch(dS.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(dM.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*c4.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=dM.shadowDepthFormat(r.shadowResolution,this._supportDepthTexture),a=dM.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=dM.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;dM.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|=cg.viewProjectionMatrix,n.applyVirtualCamera(a,!0)},r}(db);dR._lightShadowBiasProperty=uW.getByName("scene_ShadowBias"),dR._lightDirectionProperty=uW.getByName("scene_LightDirection"),dR._shadowMatricesProperty=uW.getByName("scene_ShadowMatrices"),dR._shadowMapSize=uW.getByName("scene_ShadowMapSize"),dR._shadowInfosProperty=uW.getByName("scene_ShadowInfo"),dR._shadowMapsProperty=uW.getByName("scene_ShadowMap"),dR._shadowSplitSpheresProperty=uW.getByName("scene_ShadowSplitSpheres"),dR._maxCascades=4,dR._cascadesSplitDistance=Array(dR._maxCascades+1),dR._viewport=new uo(0,0,1,1),dR._clearColor=new us(1,1,1,1),dR._tempVector=new c8,dR._tempMatrix0=new un;var dE=((tQ=(tq=function(){this.opaqueQueue=new dS(e.RenderQueueType.Opaque),this.transparentQueue=new dS(e.RenderQueueType.Transparent),this.alphaTestQueue=new dS(e.RenderQueueType.AlphaTest)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},tQ.sortBatch=function(e){this.opaqueQueue.sortBatch(dS.compareForOpaque,e),this.alphaTestQueue.sortBatch(dS.compareForOpaque,e),this.transparentQueue.sortBatch(dS.compareForTransparent,e)},tQ.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},tq),dw=(up(tZ=function(t){var r;return(r=db.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),r},db),(tJ=tZ.prototype).onConfig=function(t){var r=this.engine,n=t.pixelViewport,a=n.width,i=n.height,o=dv.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,dv.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),dP=(up(t$=function(e){return db.call(this,e)},db),(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=dv.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){dv.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},t$),dF=((t2=(t1=function(e){this._lastCanvasSize=new ui,this._internalColorTarget=null,this._camera=e;var t=e.engine;this._cullingResults=new dE,this._cascadedShadowCasterPass=new dR(e),this._depthOnlyPass=new dw(t),this._opaqueTexturePass=new dP(t)}).prototype).destroy=function(){this._cullingResults.destroy(),this._camera=null},t2.render=function(t,r,n,a){t.rendererUpdateFlag=cg.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=cg.None);var h=s._batcherManager;if(l.reset(),t.rendererUpdateFlag|=cg.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,d),this._prepareRender(t),l.sortBatch(h),h.uploadBuffer(),d?(u.onConfig(i),u.onRender(t,l),t.rendererUpdateFlag=cg.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),i.independentCanvasEnabled){var _=i.pixelViewport,f=dv.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?dv.defaultViewport:r.viewport,g=!!f||r.renderTarget&&void 0==n;t.flipProjection!==g&&(t.rendererUpdateFlag|=cg.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(r,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(),dv.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.engine,a=n._hardwareRenderer,i=n.canvas,o=r._material,s=r._mesh;(this._lastCanvasSize.x!==i.width||this._lastCanvasSize.y!==i.height)&&r._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(i.width,i.height),r._resizeBackgroundTexture());var l=o.shader.subShaders[0].passes[0],c=l._getShaderProgram(n,u9._compileMacros);c.bind(),c.uploadAll(c.materialUniformBlock,o.shaderData),c.uploadAll(c.cameraUniformBlock,t.shaderData),c.uploadUnGroupTextures(),(l._renderState||o.renderState)._applyStates(n,!1,l._renderStateDataMap,o.shaderData),a.drawPrimitive(s._primitive,s.subMesh,c)},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=cx||(cx={}))[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 dL=((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),dB=((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),dD=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,dc.resetData(ud(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(r._alphaCutoffProperty,a._alphaCutoff),a._renderElement=new dL,a._renderElement.addSubRenderElement(new dB),a._onSpriteChange=a._onSpriteChange.bind(ud(a)),a}up(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 dt.canBatchSpriteMask(e,t)},n._batch=function(e,t){dt.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?dc.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&cf.WorldVolume&&(dc.updatePositions(this),this._dirtyUpdateFlag&=~cf.WorldVolume),2&this._dirtyUpdateFlag&&(dc.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=cx.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 cl.texture:this.shaderData.setTexture(r._textureProperty,this.sprite.texture);break;case cl.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=cf.WorldVolume);break;case cl.region:case cl.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case cl.atlasRegion:this._dirtyUpdateFlag|=2;break;case cl.pivot:this._dirtyUpdateFlag|=cf.WorldVolume;break;case cl.destroy:this.sprite=null}},u_(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|=cf.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|=cf.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=cf.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=cf.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);dD._textureProperty=uW.getByName("renderer_MaskTexture"),dD._alphaCutoffProperty=uW.getByName("renderer_MaskAlphaCutoff"),um([uy],dD.prototype,"influenceLayers",void 0),um([uv],dD.prototype,"_renderElement",void 0),um([uv],dD.prototype,"_subChunk",void 0),um([uv],dD.prototype,"_maskIndex",void 0),um([uv],dD.prototype,"_sprite",void 0),um([uv],dD.prototype,"_automaticWidth",void 0),um([uv],dD.prototype,"_automaticHeight",void 0),um([uy],dD.prototype,"_customWidth",void 0),um([uy],dD.prototype,"_customHeight",void 0),um([uy],dD.prototype,"_flipX",void 0),um([uy],dD.prototype,"_flipY",void 0),um([uy],dD.prototype,"_alphaCutoff",void 0),um([uv],dD.prototype,"_onSpriteChange",null),(t6=cb||(cb={}))[t6.UV=2]="UV",t6[t6.RenderData=3]="RenderData",t6[t6.AutomaticSize=4]="AutomaticSize",t6[t6.All=7]="All";var dI=function(e){this.resource=e},dV=(up(t7=function(e){var t;return(t=uS.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},uS),(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 ui(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(){uS.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t7),dO=((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=_o._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,V=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=V)):(x+=R,b+=E.xAdvance,T=Math.max(T,I),C=Math.max(C,V))):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=V):(m+=R,g+=E.xAdvance,v=Math.max(v,I),y=Math.max(y,V))}}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 O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=u*o.length),{width:h,height:O,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},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=_o._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=s.actualBoundingBoxLeft,c=s.actualBoundingBoxRight,u=s.width,d=Math.max(1,Math.round(Math.max(c+Math.abs(l),u))),h=Math.ceil(o.measureText(rt._measureBaseline).width),_=h*rt._heightMultiplier;h=rt._baselineMultiplier*h|0;var f=rt._extendHeight;_+=f,h+=.5*f,i.width=d,i.height=_,o.font=e,o.fillStyle="#000",o.clearRect(0,0,d,_),o.textBaseline="middle",o.fillStyle="#fff",l>0?o.fillText(t,l,h):o.fillText(t,0,h);for(var p=o.getImageData(0,0,d,_).data,m=p.length,g=-1,v=-1,y=0,x=0,b=0,T=i.width,C=1/T,S=0;S<m;S+=4)0!==p[S+3]?(n=~~(.25*S*C),-1===g&&(g=n),n>v&&(v=n)):p[S]=p[S+1]=p[S+2]=255;if(-1!==g&&-1!==v&&(b=(y=h-g)+(x=v-h+1)),!r)return{ascent:y,descent:x,size:b};var A=null;if(b>0){var M=4*T;A=new Uint8Array(p.buffer,g*M,b*M)}return{char:t,x:0,y:0,w:d,h:b,offsetX:l>0?l:0,offsetY:(y-x)*.5,xAdvance:Math.round(u),uvs:[new ui,new ui,new ui,new ui],ascent:y,descent:x,index:0,data:A}},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);dO._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],dO._extendHeight=0,dO._measureString="|\xc9q\xc5",dO._measureBaseline="M",dO._heightMultiplier=2,dO._baselineMultiplier=1.4,dO._fontSizeInfoCache={},dO._textContext=null;var dN=((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 dV(r),a=new dp(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(up(t=function(){return dI.call(this,n)},dI),t.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,r=e.texture;for(var n in t){var a=t[n],o=dO.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),dk=(up(ra=function(e,t){var r;return void 0===t&&(t=""),(r=uS.call(this,e)||this)._name="",r._subFontMap={},r._name=t,r},uS),(ri=ra.prototype)._getSubFont=function(e,t){var r=e+"-"+t,n=this._subFontMap,a=n[r];return a||(a=new dN(this.engine),n[r]=a),a},ri._onDestroy=function(){uS.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},u_(ra,[{key:"name",get:function(){return this._name}}]),ra),dz=((ro=function(){this.localPositions=new uo}).prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},ro);dz.triangles=[0,2,1,2,0,3];var dU=(rs=e.Renderer,up(rl=function(t){(r=rs.call(this,t)||this)._textChunks=[],r._subFont=null,r._dirtyFlag=15,r._color=new us(1,1,1,1),r._text="",r._width=0,r._height=0,r._localBounds=new c9,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=ud(r).engine;return r._font=n._textDefaultFont,r._addResourceReferCount(r._font,1),r.setMaterial(n._textDefaultMaterial),r._color._onValueChanged=r._onColorChanged.bind(ud(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 dt.canBatchSprite(e,t)},rc._batch=function(e,t){dt.batchFor2D(e,t)},rc._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},rc._updateBounds=function(e){c9.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 de(cu.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=dO.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),c8.scale(d,M.z-R,f),c8.add(_,f,f),c8.scale(u,M.w-E,p),c8.add(_,p,m),c8.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?dO.measureTextWithWrap(this):dO.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=_o._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 V=F[D],O=i._getCharInfo(V);if(O.h>0){B<0&&(B=D);var N=a[f++]=h.get(),k=N.localPositions;N.texture=i._getTextureByIndex(O.index),N.uvs=O.uvs;var z=O.w,U=O.ascent,G=O.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+=O.xAdvance+O.offsetX}}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 dG;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 dG,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=dz.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)},u_(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);dU._textureProperty=uW.getByName("renderElement_TextTexture"),dU._tempVec30=new c8,dU._tempVec31=new c8,dU._worldPositions=[new c8,new c8,new c8,new c8],dU._charRenderInfos=[],um([uv],dU.prototype,"_textChunks",void 0),um([uy],dU.prototype,"_subFont",void 0),um([uv],dU.prototype,"_dirtyFlag",void 0),um([ub],dU.prototype,"_color",void 0),um([uy],dU.prototype,"_text",void 0),um([uy],dU.prototype,"_width",void 0),um([uy],dU.prototype,"_height",void 0),um([uv],dU.prototype,"_localBounds",void 0),um([uy],dU.prototype,"_font",void 0),um([uy],dU.prototype,"_fontSize",void 0),um([uy],dU.prototype,"_fontStyle",void 0),um([uy],dU.prototype,"_lineSpacing",void 0),um([uy],dU.prototype,"_horizontalAlignment",void 0),um([uy],dU.prototype,"_verticalAlignment",void 0),um([uy],dU.prototype,"_enableWrapping",void 0),um([uy],dU.prototype,"_overflowMode",void 0),um([uv],dU.prototype,"_onColorChanged",null);var dG=function(){this.charRenderInfos=[]};(ru=cT||(cT={}))[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 dH=(up(r_=function(t,r,n,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=u6.call(this,t)||this)._dataUpdateManager=new uP,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},u6),(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(){u6.prototype._onDestroy.call(this),this._platformBuffer.destroy()},u_(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 dW=((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),dj=(u_(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=dW._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 dK=(up(rC=function(e,t){var r;return(r=uS.call(this,e)||this)._renderStates=[],r._shaderData=new de(cu.Material),r.shader=t,r},uS),(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),uT.deepCloneObject(this.renderStates,e.renderStates,new Map)},rS._addReferCount=function(e){this._destroyed||(uS.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e),this._shader._addReferCount(e))},rS._onDestroy=function(){uS.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},u_(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 u5);else n.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rC),dX=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=ud(i).shaderData;return o.setFloat(r._alphaCutoffProp,0),o.setFloat(r._shadowCasterRenderQueueProp,e.RenderQueueType.Opaque),i}up(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},u_(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 u5),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}(dK);dX._shadowCasterRenderQueueProp=uW.getByName("material_ShadowCasterRenderQueue"),dX._baseTextureMacro=uD.getByName("MATERIAL_HAS_BASETEXTURE"),dX._normalTextureMacro=uD.getByName("MATERIAL_HAS_NORMALTEXTURE"),dX._emissiveTextureMacro=uD.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),dX._transparentMacro=uD.getByName("MATERIAL_IS_TRANSPARENT"),dX._baseColorProp=uW.getByName("material_BaseColor"),dX._baseTextureProp=uW.getByName("material_BaseTexture"),dX._tilingOffsetProp=uW.getByName("material_TilingOffset"),dX._normalTextureProp=uW.getByName("material_NormalTexture"),dX._normalIntensityProp=uW.getByName("material_NormalIntensity"),dX._emissiveColorProp=uW.getByName("material_EmissiveColor"),dX._emissiveTextureProp=uW.getByName("material_EmissiveTexture"),dX._alphaCutoffProp=uW.getByName("material_AlphaCutoff"),dX._alphaCutoffMacro=uD.getByName("MATERIAL_IS_ALPHA_CUTOFF");var dY=function(e){function t(r){var n,a=(n=e.call(this,r,u9.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new us(1,1,1,1)),a.setColor(t._specularColorProp,new us(1,1,1,1)),a.setColor(t._emissiveColorProp,new us(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new uo(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),n}return up(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},u_(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}(dX);dY._specularColorProp=uW.getByName("material_SpecularColor"),dY._shininessProp=uW.getByName("material_Shininess"),dY._specularTextureProp=uW.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 dq=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 us(1,1,1,1)),o.setColor(r._emissiveColorProp,new us(0,0,0,1)),o.setVector4(r._tilingOffsetProp,new uo(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 up(r,t),u_(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&&uH.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}(dX);dq._occlusionTextureIntensityProp=uW.getByName("material_OcclusionIntensity"),dq._occlusionTextureCoordProp=uW.getByName("material_OcclusionTextureCoord"),dq._occlusionTextureProp=uW.getByName("material_OcclusionTexture"),dq._clearCoatProp=uW.getByName("material_ClearCoat"),dq._clearCoatTextureProp=uW.getByName("material_ClearCoatTexture"),dq._clearCoatRoughnessProp=uW.getByName("material_ClearCoatRoughness"),dq._clearCoatRoughnessTextureProp=uW.getByName("material_ClearCoatRoughnessTexture"),dq._clearCoatNormalTextureProp=uW.getByName("material_ClearCoatNormalTexture");var dQ=function(e){function t(r){(n=e.call(this,r,u9.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 c8(1,0,0)),n}return up(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},u_(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=c4.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}(dq);dQ._metallicProp=uW.getByName("material_Metal"),dQ._roughnessProp=uW.getByName("material_Roughness"),dQ._roughnessMetallicTextureProp=uW.getByName("material_RoughnessMetallicTexture"),dQ._iorProp=uW.getByName("material_IOR"),dQ._anisotropyInfoProp=uW.getByName("material_AnisotropyInfo"),dQ._anisotropyTextureProp=uW.getByName("material_AnisotropyTexture");var dZ=function(e){function t(r){var n;return(n=e.call(this,r,u9.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new us(1,1,1,1)),n.shaderData.setFloat(t._glossinessProp,1),n}return up(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},u_(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}(dq);dZ._specularColorProp=uW.getByName("material_PBRSpecularColor"),dZ._glossinessProp=uW.getByName("material_Glossiness"),dZ._specularGlossinessTextureProp=uW.getByName("material_SpecularGlossinessTexture"),dZ._specularGlossinessTextureMacro=uD.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var dJ=function(e){function t(r){var n,a=(n=e.call(this,r,u9.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new us(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new uo(1,1,0,0)),n}return up(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},u_(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}(dX),d$=((rM=function(e,t,r,n){if(void 0===r&&(r=null),void 0===n&&(n=null),this._dataChangeManager=new uP,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},u_(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=cC||(cC={}))[rR.Position=1]="Position",rR[rR.Normal=2]="Normal",rR[rR.Tangent=4]="Tangent",rR[rR.All=7]="All";var d0=((rw=(rE=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new uP,this._dataChangeManager=new uP,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 d$(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(cC.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()},u_(rE,[{key:"frames",get:function(){return this._frames}}]),rE),d1=(u_(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),d2=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},d3=(up(rF=function(){return d2.apply(this,arguments)},d2),rF.prototype.dispose=function(){},rF),d4=(up(rL=function(e){var t;return(t=u6.call(this,e)||this).enableVAO=!0,t.instanceCount=0,t.vertexBufferBindings=[],t._vertexElementMap={},t._bufferStructChanged=!1,t._vertexElements=[],t._platformPrimitive=e._hardwareRenderer.createPlatformPrimitive(ud(t)),t},u6),(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=dW._getGLIndexType(e.format),this._glIndexByteCount=dW._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){u6.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(){u6.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},u_(rL,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),rL),d8=(up(rD=function(e,t){(r=uS.call(this,e)||this)._updateFlagManager=new uP,r._bounds=new c9,r._subMeshes=[],r.name=t,r._primitive=new d4(e),r._onBoundsChanged=r._onBoundsChanged.bind(ud(r));var r,n=r._bounds;return n.min._onValueChanged=r._onBoundsChanged,n.max._onValueChanged=r._onBoundsChanged,r},uS),(rI=rD.prototype).addSubMesh=function(t,r,n){return void 0===n&&(n=e.MeshTopology.Triangles),"number"==typeof t&&(t=new d3(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){uS.prototype._addReferCount.call(this,e),this._primitive._addReferCount(e)},rI._onDestroy=function(){uS.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)},u_(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);(rV=cS||(cS={}))[rV.Bounds=1]="Bounds",rV[rV.VertexElements=2]="VertexElements";var d5=(u_(rO=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),rO),d9=(up(rN=function(){return d8.apply(this,arguments)},d8),(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 d5(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 d1(e,t))),this._setIndexBufferBinding(r)},u_(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),d6=(rz=e.Renderer,up(rU=function(e){var t;return(t=rz.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(ud(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){uH.error("mesh is null.");return}if(this._mesh.destroyed){uH.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;c9.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&cS.Bounds&&(this._dirtyUpdateFlag|=cf.WorldVolume),e&cS.VertexElements&&(this._dirtyUpdateFlag|=2)},u_(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);d6._uvMacro=uD.getByName("RENDERER_HAS_UV"),d6._uv1Macro=uD.getByName("RENDERER_HAS_UV1"),d6._normalMacro=uD.getByName("RENDERER_HAS_NORMAL"),d6._tangentMacro=uD.getByName("RENDERER_HAS_TANGENT"),d6._enableVertexColorMacro=uD.getByName("RENDERER_ENABLE_VERTEXCOLOR"),um([uv],d6.prototype,"_mesh",void 0),um([uv],d6.prototype,"_onMeshChanged",null),(rH=cA||(cA={}))[rH.VertexElementMacro=2]="VertexElementMacro",rH[rH.All=3]="All";var d7=((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 uo,this._canUseTextureStoreData=!0,this._dataTextureInfo=new c8,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(di))},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 dj("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12,this._useBlendNormal&&(t._setVertexElement(r++,new dj("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,n)),a+=12),this._useBlendTangent&&(t._setVertexElement(r++,new dj("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 dH(n,e.BufferBindFlag.VertexBuffer,m,g);a._setVertexBufferBinding(h+_,new d5(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 dm(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 ui),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);d7._blendShapeMacro=uD.getByName("RENDERER_HAS_BLENDSHAPE"),d7._blendShapeTextureMacro=uD.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),d7._blendShapeNormalMacro=uD.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),d7._blendShapeTangentMacro=uD.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),d7._blendShapeWeightsProperty=uW.getByName("renderer_BlendShapeWeights"),d7._blendShapeTextureProperty=uW.getByName("renderer_BlendShapeTexture"),d7._blendShapeTextureInfoProperty=uW.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 he=(up(rX=function(e,t){var r;return(r=d8.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 c8(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 d7(e,ud(r)),r},d8),(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,ug(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:ug(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:ug(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 d5(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 d1(u,this._indicesFormat));else{null==u||u.destroy();var d,h=new dH(this._engine,e.BufferBindFlag.IndexBuffer,c);this._setIndexBufferBinding(new d1(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 uo,h[_]=new c8;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];c8.subtract(y,v,i),c8.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);c8.scale(i,R*E,s),c8.scale(o,M*E,c),c8.subtract(s,c,s),c8.scale(o,S*E,l),c8.scale(i,A*E,c),c8.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),c8.cross(s,L,c);var D=c8.dot(c,F)>0?1:-1;c8.scale(F,c8.dot(s,F),c),c8.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),d8.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(i),(a[e]||(a[e]=new ht)).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(){d8.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 dH(this._engine,e.BufferBindFlag.VertexBuffer,i,u,!0);this._setVertexBufferBinding(l,new d5(d,r))}a.set(r,n,c?l:-1)}},rY._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new ui(e[t],e[t+1])})},rY._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new c8(e[t],e[t+1],e[t+2])})},rY._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new uo(e[t],e[t+1],e[t+2],e[t+3])})},rY._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new us(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 dj(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)}}},u_(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);he._tempVec0=new c8,he._tempVec1=new c8,he._tempVec2=new c8,he._tempVec3=new c8,he._tempVec4=new c8;var ht=((rq=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},rq);(rQ=cM||(cM={}))[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=cR||(cR={}))[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 hr=(up(rJ=function(e,t){var r;return(r=dI.call(this,e)||this).primitiveInfo=t,r},dI),rJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:hh._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:hh._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:hh._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:hh._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:hh._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:hh._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:hh._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:hh._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},rJ);(r$=cE||(cE={}))[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 hn=function(e,t,r){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=r},ha=(up(r0=function(e,t,r,n){var a;return(a=hn.call(this,0,r,n)||this).radius=e,a.segments=t,a},hn),r0),hi=(up(r1=function(e,t,r,n){var a;return(a=hn.call(this,7,r,n)||this).radius=e,a.step=t,a},hn),r1),ho=(up(r2=function(e,t,r,n,a){var i;return(i=hn.call(this,1,n,a)||this).width=e,i.height=t,i.depth=r,i},hn),r2),hs=(up(r3=function(e,t,r,n,a,i){var o;return(o=hn.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=r,o.verticalSegments=n,o},hn),r3),hl=(up(r4=function(e,t,r,n,a,i,o){var s;return(s=hn.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=r,s.radialSegments=n,s.heightSegments=a,s},hn),r4),hc=(up(r8=function(e,t,r,n,a,i,o){var s;return(s=hn.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=r,s.tubularSegments=n,s.arc=a,s},hn),r8),hu=(up(r5=function(e,t,r,n,a,i){var o;return(o=hn.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},hn),r5),hd=(up(r9=function(e,t,r,n,a,i){var o;return(o=hn.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=r,o.heightSegments=n,o},hn),r9),hh=((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 he(e);r6._setSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(a,new ha(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 he(e);r6._setSubdivisionSurfaceSphereData(a,t,r,n,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(a,new hi(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 he(e);r6._setCuboidData(i,t,r,n,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(i,new ho(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 he(e);r6._setPlaneData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(o,new hs(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 he(e);r6._setCylinderData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(s,new hl(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 he(e);r6._setTorusData(s,t,r,n,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(s,new hc(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 he(e);r6._setConeData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(o,new hu(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 he(e);r6._setCapsuleData(o,t,r,n,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new hr(o,new hd(t,r,n,a,s,i))),o},r6._setSubdivisionSurfaceSphereData=function(e,t,r,n,a,i){r=c4.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 c8,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 c8,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 V=R.adjacentEdges[L%4];w=P,P=this._calculateEdgeIndex(t,V,C);break;case 3:w=P,P=F}var O=4*(4*M+L);r[O]=B,r[O+1]=P,r[O+2]=E,r[O+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),V=r-P*R,O=V*D,N=P*h-d,k=V*I,z=8*E;b[z++]=O,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,V=8*S;y[V++]=B,y[V++]=D,y[V++]=I,y[V++]=P,y[V++]=C,y[V++]=F,y[V++]=R,y[V++]=1-E}for(var O=0;O<_;++O){var N=O%n,k=(O*g|0)*l+N,z=k+1,U=k+l,G=U+1;p[x++]=z,p[x++]=U,p[x++]=k,p[x++]=z,p[x++]=G,p[x++]=U}var H=8*h;y[H++]=0,y[H++]=-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,V=(D*y|0)*l+I,O=V+1,N=V+l,k=N+1;g[S++]=O,g[S++]=N,g[S++]=V,g[S++]=O,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 dj(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new dj(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new dj(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new dH(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 h_(e,t,r){return(h_=!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&&uf(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}hh._tempVec30=new c8,hh._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]),hh._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]),hh._sphereEdgeIdx=0,hh._spherePoleIdx=0;var hf=((r7=function(){}).cloneComponent=function(e,t,r,n,a){var i=uT.getCloneMode(e.constructor);for(var o in e)uT.cloneProperty(e,t,o,i[o],r,n,a);e._cloneTo&&e._cloneTo(t,r,n)},r7),hp=(up(ne=function(t,r){var n;return(n=uC.call(this,t)||this).layer=e.Layer.Layer0,n._isActiveInHierarchy=!1,n._isActiveInScene=!1,n._components=[],n._scripts=new dd,n._children=[],n._isRoot=!1,n._isActive=!0,n._siblingIndex=-1,n._isTemplate=!1,n._parent=null,n._invModelMatrix=new un,n.name=r,n.transform=n.addComponent(ds),n._inverseWorldMatFlag=n.transform.registerWorldChangeFlag(),n},uC),(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];dn._addCheck(this,e);var a=h_(e,[].concat(this,r));return this._components.push(a),a._setActive(!0,ch.All),a},nt.getComponent=function(e){for(var t=this._components,r=0,n=t.length;r<n;r++){var a=t[r];if(ug(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];ug(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=ch.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=ch.Hierarchy),t._isActiveInScene&&(this._isActiveInScene?n!==a&&(i|=ch.Scene):i|=ch.Scene),i&&t._processInActive(i),t._scene!==a&&ne._traverseSetOwnerScene(t,a);var o=ch.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=ch.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&n===a||(o|=ch.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=ch.None;r._isActiveInHierarchy&&(n|=ch.Hierarchy),r._isActiveInScene&&(n|=ch.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(!ug(h,ds)){var _=t.addComponent(h.constructor);hf.cloneComponent(h,_,r,n,a)}}},nt.destroy=function(){if(!this._destroyed){uC.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){dn._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._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._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=ch.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=ch.Hierarchy),e._isActiveInScene?this._isActiveInScene&&n!==a&&(i|=ch.Scene):this._isActiveInScene&&(i|=ch.Scene),i&&this._processInActive(i),n!==a&&ne._traverseSetOwnerScene(this,a);var o=ch.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=ch.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&n===a||(o|=ch.Scene))),o&&this._processActive(o)}else{var s=ch.None;this._isActiveInHierarchy&&(s|=ch.Hierarchy),this._isActiveInScene&&(s|=ch.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];ug(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&ch.Hierarchy&&(this._isActiveInHierarchy=!0),t&ch.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&ch.Hierarchy&&(this._isActiveInHierarchy=!1),t&ch.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._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&&(un.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},u_(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=ch.None;this._isRoot&&this._scene._isActiveInEngine?r|=ch.All:((null==t?void 0:t._isActiveInHierarchy)&&(r|=ch.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(r|=ch.Scene)),r&&this._processActive(r)}else{var n=ch.None;this._isActiveInHierarchy&&(n|=ch.Hierarchy),this._isActiveInScene&&(n|=ch.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),hm=(up(nr=function(e){var t;return(t=uC.call(this,null)||this).name=e,t.inverseBindMatrices=[],t._updatedManager=new uP,t._bones=[],t._updateMark=-1,t.joints=[],t},uC),(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?uM._floatMatrixMultiply(s.transform.worldMatrix,n[o].elements,0,a,l):a.set(n[o].elements,l),uM._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=hp._getEntityHierarchyPath(t,a,n);e.rootBone=i?hp._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=hp._getEntityHierarchyPath(t,u,n);l[c]=d?hp._getEntityByHierarchyPath(r,n):u}e.bones=l}},u_(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);um([ub],hm.prototype,"inverseBindMatrices",void 0),um([uv],hm.prototype,"_skinMatrices",void 0),um([uv],hm.prototype,"_updatedManager",void 0),um([uv],hm.prototype,"_rootBone",void 0),um([uv],hm.prototype,"_bones",void 0),um([uv],hm.prototype,"_updateMark",void 0),(na=cw||(cw={}))[na.BoneCountChanged=0]="BoneCountChanged",na[na.RootBoneChanged=1]="RootBoneChanged";var hg=(up(ni=function(e){(t=d6.call(this,e)||this)._localBounds=new c9,t._jointDataCreateCache=new ui(-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(ud(t)),t._onSkinUpdated=t._onSkinUpdated.bind(ud(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},d6),(no=ni.prototype)._updateTransformShaderData=function(e,t,r){var n=this._transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,n,r):this._updateWorldViewRelatedShaderData(e,n,r)},no._onDestroy=function(){var e;d6.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){d6.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 dp(_,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)):uH.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)}d6.prototype._update.call(this,t)},no._updateBounds=function(e){var t;(null==(t=this.skin)?void 0:t.rootBone)?c9.transform(this._localBounds,this._transform.worldMatrix,e):d6.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|=cf.WorldVolume},no._onSkinUpdated=function(e,t){switch(e){case cw.BoneCountChanged:var r=this.shaderData;t>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(ni._jointCountProperty,t)):r.disableMacro("RENDERER_HAS_SKIN");break;case cw.RootBoneChanged:this._setTransform(t.transform),this._dirtyUpdateFlag|=cf.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(cw.BoneCountChanged,u),c!==d&&this._onSkinUpdated(cw.RootBoneChanged,d)},u_(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);hg._jointCountProperty=uW.getByName("renderer_JointCount"),hg._jointSamplerProperty=uW.getByName("renderer_JointSampler"),hg._jointMatrixProperty=uW.getByName("renderer_JointMatrix"),um([uv],hg.prototype,"_condensedBlendShapeWeights",void 0),um([ub],hg.prototype,"_localBounds",void 0),um([uv],hg.prototype,"_jointDataCreateCache",void 0),um([uv],hg.prototype,"_blendShapeWeights",void 0),um([uv],hg.prototype,"_maxVertexUniformVectors",void 0),um([uv],hg.prototype,"_jointTexture",void 0),um([ub],hg.prototype,"_skin",void 0),um([uv],hg.prototype,"_onLocalBoundsChanged",null),um([uv],hg.prototype,"_onSkinUpdated",null);var hv=((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 dK(t,u9.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,a=new he(t);a._addReferCount(1),a.setVertexElements([new dj("POSITION_UV",0,e.VertexElementFormat.Vector4,0)]);var i=new dH(t,e.BufferBindFlag.VertexBuffer,r,e.BufferUsage.Static,!0);return a.setVertexBufferBinding(i,16),a.addSubMesh(0,3,e.MeshTopology.Triangles),t.resourceManager.addContentRestorer(new(up(n=function(){return dI.call(this,a)},dI),n.prototype.restoreContent=function(){i.setData(i.data)},n)),a},nl._create1x1Texture=function(t,r,n,a){switch(r){case 0:var i,o,s=new dp(t,1,1,n,!1);s.setPixelBuffer(a),i=s;break;case 2:var l=new dm(t,1,1,1,n,!1);l.setPixelBuffer(0,a),i=l;break;case 1:for(var c=new dg(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(up(o=function(){return dI.call(this,i)},dI),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=cP||(cP={}))[nc.Texture2D=0]="Texture2D",nc[nc.TextureCube=1]="TextureCube",nc[nc.Texture2DArray=2]="Texture2DArray";var hy=((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),hx=(up(nd=function(e,t){void 0===t&&(t=1),(r=hy.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},hy),(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),hb=((n_=function(){}).prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},n_),hT=((nf=function(e,t){this.start=e,this.size=t}).prototype.dispose=function(){},nf),hC=((nm=(np=function(t,r){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new d4(t);n.addVertexElement(new dj("POSITION",0,e.VertexElementFormat.Vector3,0)),n.addVertexElement(new dj("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)),n.addVertexElement(new dj("COLOR_0",20,e.VertexElementFormat.Vector4,0)),n._addReferCount(1);var a=new dH(t,e.BufferBindFlag.VertexBuffer,36*r,e.BufferUsage.Dynamic,!0);n.setVertexBufferBinding(0,new d5(a,36));var i=new dH(t,e.BufferBindFlag.IndexBuffer,8*r,e.BufferUsage.Dynamic,!0);n.setIndexBufferBinding(new d1(i,e.IndexFormat.UInt16)),this.primitive=n,this.vertices=new Float32Array(a.data.buffer),this.indices=new Uint16Array(i.data.buffer),this.vertexFreeAreas=[new hT(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){for(var t=e.start,r=e.size,n=this.vertexFreeAreas,a=t+r,i=np.areaPool,o=0,s=n.length;o<s;++o){var l=n[o],c=l.start,u=c+l.size;if(a<c){n.splice(o,0,e);return}if(a===c){l.start=t,l.size+=r,i.return(e);return}if(t===u){l.size+=r,i.return(e);var d=o+1;if(d<s){var h=n[d];a===h.start&&(l.size+=h.size,n.splice(d,1),i.return(h))}return}}n.push(e)},np);hC.areaPool=new hx(hT,10),hC.subChunkPool=new hx(hb,10),hC.subMeshPool=new hx(d3,10);var hS=((nv=(ng=function(e,t){void 0===t&&(t=4096),this.engine=e,this.maxVertexCount=t,this.primitiveChunks=[]}).prototype).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 hC(this.engine,this.maxVertexCount))).allocateSubChunk(e)},nv.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},nv.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,r=e.length;t<r;++t)e[t].uploadBuffer()},nv.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},ng),hA=((nx=(ny=function(e){this.primitiveChunkManager2D=new hS(e),this.primitiveChunkManagerMask=new hS(e,128)}).prototype).destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},nx.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)},nx.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},ny);e.AssetType=void 0,(nb=e.AssetType||(e.AssetType={})).Text="Text",nb.JSON="JSON",nb.Buffer="Buffer",nb.Texture2D="Texture2D",nb.TextureCube="TextureCube",nb.Material="Material",nb.Shader="Shader",nb.Mesh="Mesh",nb.AnimationClip="AnimationClip",nb.AnimatorController="AnimatorController",nb.Prefab="Prefab",nb.GLTF="GLTF",nb.KTX="KTX",nb.KTXCube="KTXCube",nb.KTX2="KTX2",nb.Sprite="Sprite",nb.PrimitiveMesh="PrimitiveMesh",nb.SpriteAtlas="SpriteAtlas",nb.Env="Environment",nb.Scene="Scene",nb.HDR="HDR",nb.Font="Font",nb.SourceFont="SourceFont",nb.Project="project";var hM=((nC=(nT=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},nC.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},nC.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},nC.findAndRemove=function(e){for(var t=this._array,r=t.length-1;r>=0;r--)e(t[r])&&this.removeByIndex(r)},nC.indexOf=function(e){return this._array.indexOf(e)},nC.getArray=function(){return this._array},nC.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},u_(nT,[{key:"length",get:function(){return this._array.length}}]),nT),hR=((nA=(nS=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new hM}).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)},nA.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)}},nA.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},nA.mergeScenes=function(e,t){for(var r=e.rootEntities;r.length>0;)t.addRootEntity(r[0])},nA._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},u_(nS,[{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)}}]),nS),hE=((nR=(nM=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},nR.then=function(e,t){var r=this;return new nM(function(n,a){r._promise.then(e,t).then(n).catch(a)})},nR.catch=function(e){var t=this;return new nM(function(r,n){t._promise.catch(e).then(r).catch(n)})},nR.finally=function(e){return this._promise.finally(e)},nR.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nM.all=function(e){return new nM(function(t,r,n){var a=function(e,r){l++,s[e]=r,n(l,o),l===o&&t(s)},i=function(e,t){ug(e,Promise)||ug(e,nM)?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)})},u_(nM,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nM);(nE=cF||(cF={})).Pending="pending",nE.Fulfilled="fulfilled",nE.Rejected="rejected",nE.Canceled="canceled";var hw={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hP=1/0;function hF(e,t){return void 0===t&&(t={}),new hE(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:hP,t.type=null!=(c=t.type)?c:hw[e.substring(e.lastIndexOf(".")+1)],new hL(function(){var r;return(r=t,new hE(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 hL=((nP=(nw=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},nP.onComplete=function(e){return this._onComplete=e,this},nP.onError=function(e){return this._onError=e,this},nP.cancel=function(){window.clearTimeout(this._timeoutId)},nP.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)})},nw),hB=((nL=(nF=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 hE.all(r)},nL.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},nL.findResourcesByType=function(e){var t=[],r=this._referResourcePool;for(var n in r){var a=r[n];ug(a,e)&&t.push(a)}return t},nL.getAssetPath=function(e){return this._assetPool[e]},nL.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()}):uM.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},nL.gc=function(){this._gc(!1),this.engine._pendingGC()},nL.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},nL._getRemoteUrl=function(e){var t;return null!=(t=this._virtualPathMap[e])?t:e},nL._requestByRemoteUrl=function(e,t){return hF(e,t)},nL._request=function(e,t){var r=this._getRemoteUrl(e);return this._requestByRemoteUrl(r,t)},nL._onSubAssetSuccess=function(e,t,r){var n,a,i,o=null!=(a=this._virtualPathMap[e])?a:e,s=null==(n=this._subAssetPromiseCallbacks[o])?void 0:n[t];s?s.resolve(r):((i=this._subAssetPromiseCallbacks)[o]||(i[o]={}))[t]={resolvedValue:r}},nL._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}},nL._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},nL._deleteAsset=function(e){var t=e.instanceId,r=this._assetPool[t];r&&(delete this._assetPool[t],delete this._assetUrlPool[r])},nL._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},nL._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},nL._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},nL._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},nL._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},nL._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},nL._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},nL._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)},nL._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},nL._assignDefaultOptions=function(e){var t,r,n,a,i;if(e.type=null!=(t=e.type)?t:nF._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},nL._loadSingleItem=function(e){var t,r,n=this,a=this._assignDefaultOptions("string"==typeof e?{url:e}:e),i=a.url;!uM.isAbsoluteUrl(i)&&this.baseUrl&&(i=uM.resolveAbsoluteUrl(this.baseUrl,i));var o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=null!=(t=this._virtualPathMap[s])?t:s,d=this._assetUrlPool[u];if(d)return new hE(function(e){e(n._getResolveResource(d,c))});var h=u;if(l)for(h+="?q="+c.shift();r=c.shift();)h+="["+r+"]";var _=this._loadingPromises,f=_[h];if(f)return new hE(function(e,t,r,n){f.onProgress(r,n).then(function(t){e(t)}).catch(function(e){t(e)})});var p=nF._loaders[a.type];if(!p)throw"loader not found: "+a.type;return l?((_[u]||this._loadMainAsset(p,a,u,s)).catch(function(e){n._onSubAssetFail(u,l,e)}),this._createSubAssetPromiseCallback(u,h,l)):this._loadMainAsset(p,a,u,s)},nL._loadMainAsset=function(e,t,r,n){var a=this;t.url=n;var i=this._loadingPromises,o=e.load(t,this);return i[r]=o,o.then(function(t){e.useCache&&a._addAsset(r,t),delete i[r],a._releaseSubAssetPromiseCallback(r)},function(){delete i[r],a._releaseSubAssetPromiseCallback(r)}),o},nL._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 hE(function(e,t){s?e(s):l&&t(l)});var c=new hE(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},nL._gc=function(e){for(var t=uM.objectValues(this._referResourcePool),r=0,n=t.length;r<n;r++){var a=t[r];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},nL._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},nL._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=o.length-1;s>=0;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}},nL._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===hI&&t.push(""),e.replace(hO,function(e,r,n,a){var i=e;n?i=a.replace(hV,"$1"):r&&(i=r.trim()),t.push(i)}),t},nL._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},nL.getResourceByRef=function(e){var t,r=e.refId,n=e.key,a=e.isClone,i=this._objectPool[r];if(i)t=Promise.resolve(i);else{var o=this._editorResourceConfig[r];if(!o)return uH.warn("refId:"+r+" is not find in this._editorResourceConfig."),Promise.resolve(null);var s=o.virtualPath;n&&(s+="?q="+n),t=this.load({url:s,type:o.type})}return t.then(function(e){return a?e.clone():e})},nL.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},nF._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},nF._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},nF);function hD(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 hI=46,hV=/\\(\\)?/g,hO=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(nB=e.PointerPhase||(e.PointerPhase={}))[nB.Down=0]="Down",nB[nB.Move=1]="Move",nB[nB.Stationary=2]="Stationary",nB[nB.Up=3]="Up",nB[nB.Leave=4]="Leave";var hN=((nI=(nD=function(t){this.phase=e.PointerPhase.Leave,this.position=new ui,this.deltaPosition=new ui,this._events=[],this._upMap=[],this._downMap=[],this._upList=new dd,this._downList=new dd,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)},nI._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},nI._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},nI._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}},nD);e.PointerButton=void 0,(nV=e.PointerButton||(e.PointerButton={}))[nV.None=0]="None",nV[nV.Primary=1]="Primary",nV[nV.Secondary=2]="Secondary",nV[nV.Auxiliary=4]="Auxiliary",nV[nV.XButton1=8]="XButton1",nV[nV.XButton2=16]="XButton2",nV[nV.XButton3=32]="XButton3",nV[nV.XButton4=64]="XButton4",nV[nV.XButton5=128]="XButton5",nV[nV.XButton6=256]="XButton6",nV[nV.XButton7=512]="XButton7",nV[nV.XButton8=1024]="XButton8";var hk=[1,4,2,8,16,32,64,128,256,512,1024],hz={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},hU=((nO=function(){})._initialize=function(){if("undefined"==typeof navigator){nO._isBrowser=!1;return}var t,r=navigator.userAgent;switch(/iPhone/i.test(r)?nO.platform=e.Platform.IPhone:/iPad/i.test(r)?nO.platform=e.Platform.IPad:/Android/i.test(r)?nO.platform=e.Platform.Android:/Macintosh/i.test(r)&&(nO.platform=e.Platform.Mac),nO.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"}},nO._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},u_(nO,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nO);hU.platform=e.Platform.Unknown,hU.operatingSystem="",hU._isBrowser=!0,hU._simdSupported=null,hU._initialize(),e.Keys=void 0,(nN=e.Keys||(e.Keys={}))[nN.Backquote=0]="Backquote",nN[nN.Backslash=1]="Backslash",nN[nN.Backspace=2]="Backspace",nN[nN.BracketLeft=3]="BracketLeft",nN[nN.BracketRight=4]="BracketRight",nN[nN.Comma=5]="Comma",nN[nN.Digit0=6]="Digit0",nN[nN.Digit1=7]="Digit1",nN[nN.Digit2=8]="Digit2",nN[nN.Digit3=9]="Digit3",nN[nN.Digit4=10]="Digit4",nN[nN.Digit5=11]="Digit5",nN[nN.Digit6=12]="Digit6",nN[nN.Digit7=13]="Digit7",nN[nN.Digit8=14]="Digit8",nN[nN.Digit9=15]="Digit9",nN[nN.Equal=16]="Equal",nN[nN.IntlBackslash=17]="IntlBackslash",nN[nN.IntlRo=18]="IntlRo",nN[nN.IntlYen=19]="IntlYen",nN[nN.KeyA=20]="KeyA",nN[nN.KeyB=21]="KeyB",nN[nN.KeyC=22]="KeyC",nN[nN.KeyD=23]="KeyD",nN[nN.KeyE=24]="KeyE",nN[nN.KeyF=25]="KeyF",nN[nN.KeyG=26]="KeyG",nN[nN.KeyH=27]="KeyH",nN[nN.KeyI=28]="KeyI",nN[nN.KeyJ=29]="KeyJ",nN[nN.KeyK=30]="KeyK",nN[nN.KeyL=31]="KeyL",nN[nN.KeyM=32]="KeyM",nN[nN.KeyN=33]="KeyN",nN[nN.KeyO=34]="KeyO",nN[nN.KeyP=35]="KeyP",nN[nN.KeyQ=36]="KeyQ",nN[nN.KeyR=37]="KeyR",nN[nN.KeyS=38]="KeyS",nN[nN.KeyT=39]="KeyT",nN[nN.KeyU=40]="KeyU",nN[nN.KeyV=41]="KeyV",nN[nN.KeyW=42]="KeyW",nN[nN.KeyX=43]="KeyX",nN[nN.KeyY=44]="KeyY",nN[nN.KeyZ=45]="KeyZ",nN[nN.Minus=46]="Minus",nN[nN.Period=47]="Period",nN[nN.Quote=48]="Quote",nN[nN.Semicolon=49]="Semicolon",nN[nN.Slash=50]="Slash",nN[nN.AltLeft=51]="AltLeft",nN[nN.AltRight=52]="AltRight",nN[nN.CapsLock=53]="CapsLock",nN[nN.ContextMenu=54]="ContextMenu",nN[nN.ControlLeft=55]="ControlLeft",nN[nN.ControlRight=56]="ControlRight",nN[nN.Enter=57]="Enter",nN[nN.MetaLeft=58]="MetaLeft",nN[nN.MetaRight=59]="MetaRight",nN[nN.ShiftLeft=60]="ShiftLeft",nN[nN.ShiftRight=61]="ShiftRight",nN[nN.Space=62]="Space",nN[nN.Tab=63]="Tab",nN[nN.Convert=64]="Convert",nN[nN.KanaMode=65]="KanaMode",nN[nN.Lang1=66]="Lang1",nN[nN.Lang2=67]="Lang2",nN[nN.Lang3=68]="Lang3",nN[nN.Lang4=69]="Lang4",nN[nN.Lang5=70]="Lang5",nN[nN.NonConvert=71]="NonConvert",nN[nN.Delete=72]="Delete",nN[nN.End=73]="End",nN[nN.Help=74]="Help",nN[nN.Home=75]="Home",nN[nN.Insert=76]="Insert",nN[nN.PageDown=77]="PageDown",nN[nN.PageUp=78]="PageUp",nN[nN.ArrowDown=79]="ArrowDown",nN[nN.ArrowLeft=80]="ArrowLeft",nN[nN.ArrowRight=81]="ArrowRight",nN[nN.ArrowUp=82]="ArrowUp",nN[nN.NumLock=83]="NumLock",nN[nN.Numpad0=84]="Numpad0",nN[nN.Numpad1=85]="Numpad1",nN[nN.Numpad2=86]="Numpad2",nN[nN.Numpad3=87]="Numpad3",nN[nN.Numpad4=88]="Numpad4",nN[nN.Numpad5=89]="Numpad5",nN[nN.Numpad6=90]="Numpad6",nN[nN.Numpad7=91]="Numpad7",nN[nN.Numpad8=92]="Numpad8",nN[nN.Numpad9=93]="Numpad9",nN[nN.NumpadAdd=94]="NumpadAdd",nN[nN.NumpadBackspace=95]="NumpadBackspace",nN[nN.NumpadClear=96]="NumpadClear",nN[nN.NumpadClearEntry=97]="NumpadClearEntry",nN[nN.NumpadComma=98]="NumpadComma",nN[nN.NumpadDecimal=99]="NumpadDecimal",nN[nN.NumpadDivide=100]="NumpadDivide",nN[nN.NumpadEnter=101]="NumpadEnter",nN[nN.NumpadEqual=102]="NumpadEqual",nN[nN.NumpadHash=103]="NumpadHash",nN[nN.NumpadMemoryAdd=104]="NumpadMemoryAdd",nN[nN.NumpadMemoryClear=105]="NumpadMemoryClear",nN[nN.NumpadMemoryRecall=106]="NumpadMemoryRecall",nN[nN.NumpadMemoryStore=107]="NumpadMemoryStore",nN[nN.NumpadMemorySubtract=108]="NumpadMemorySubtract",nN[nN.NumpadMultiply=109]="NumpadMultiply",nN[nN.NumpadParenLeft=110]="NumpadParenLeft",nN[nN.NumpadParenRight=111]="NumpadParenRight",nN[nN.NumpadStar=112]="NumpadStar",nN[nN.NumpadSubtract=113]="NumpadSubtract",nN[nN.Escape=114]="Escape",nN[nN.F1=115]="F1",nN[nN.F2=116]="F2",nN[nN.F3=117]="F3",nN[nN.F4=118]="F4",nN[nN.F5=119]="F5",nN[nN.F6=120]="F6",nN[nN.F7=121]="F7",nN[nN.F8=122]="F8",nN[nN.F9=123]="F9",nN[nN.F10=124]="F10",nN[nN.F11=125]="F11",nN[nN.F12=126]="F12",nN[nN.F13=127]="F13",nN[nN.F14=128]="F14",nN[nN.F15=129]="F15",nN[nN.Fn=130]="Fn",nN[nN.FnLock=131]="FnLock",nN[nN.PrintScreen=132]="PrintScreen",nN[nN.ScrollLock=133]="ScrollLock",nN[nN.Pause=134]="Pause",nN[nN.BrowserBack=135]="BrowserBack",nN[nN.BrowserFavorites=136]="BrowserFavorites",nN[nN.BrowserForward=137]="BrowserForward",nN[nN.BrowserHome=138]="BrowserHome",nN[nN.BrowserRefresh=139]="BrowserRefresh",nN[nN.BrowserSearch=140]="BrowserSearch",nN[nN.BrowserStop=141]="BrowserStop",nN[nN.Eject=142]="Eject",nN[nN.LaunchApp1=143]="LaunchApp1",nN[nN.LaunchApp2=144]="LaunchApp2",nN[nN.LaunchMail=145]="LaunchMail",nN[nN.MediaPlayPause=146]="MediaPlayPause",nN[nN.MediaSelect=147]="MediaSelect",nN[nN.MediaStop=148]="MediaStop",nN[nN.MediaTrackNext=149]="MediaTrackNext",nN[nN.MediaTrackPrevious=150]="MediaTrackPrevious",nN[nN.Power=151]="Power",nN[nN.Sleep=152]="Sleep",nN[nN.AudioVolumeDown=153]="AudioVolumeDown",nN[nN.AudioVolumeMute=154]="AudioVolumeMute",nN[nN.AudioVolumeUp=155]="AudioVolumeUp",nN[nN.WakeUp=156]="WakeUp",nN[nN.Hyper=157]="Hyper",nN[nN.Super=158]="Super",nN[nN.Turbo=159]="Turbo",nN[nN.Abort=160]="Abort",nN[nN.Resume=161]="Resume",nN[nN.Suspend=162]="Suspend",nN[nN.Again=163]="Again",nN[nN.Copy=164]="Copy",nN[nN.Cut=165]="Cut",nN[nN.Find=166]="Find",nN[nN.Open=167]="Open",nN[nN.Paste=168]="Paste",nN[nN.Props=169]="Props",nN[nN.Select=170]="Select",nN[nN.Undo=171]="Undo",nN[nN.Hiragana=172]="Hiragana",nN[nN.Katakana=173]="Katakana",nN[nN.Unidentified=174]="Unidentified";var hG=((nz=(nk=function(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new dd,this._curFrameDownList=new dd,this._curFrameUpList=new dd,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,hU.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}},nz._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},nz._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},nz._onKeyEvent=function(e){this._nativeEvents.push(e)},nz._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},nz._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},nk);e.Collider=(up(nU=function(e){var t;return(t=dr.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},dr),(nG=nU.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))},nG.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))},nG.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},nG._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}},nG._onLateUpdate=function(){},nG._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])},nG._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])},nG._cloneTo=function(e){for(var t=e._shapes,r=0,n=t.length;r<n;r++)e._addPhysicsShape(t[r])},nG._onDestroy=function(){dr.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nG._addPhysicsShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape),this._phasedActiveInScene&&this.scene.physics._addColliderShape(e)},u_(nU,[{key:"shapes",get:function(){return this._shapes}}]),nU),um([uv],e.Collider.prototype,"_index",void 0),um([uv],e.Collider.prototype,"_nativeCollider",void 0),um([uv],e.Collider.prototype,"_updateFlag",void 0),um([ub],e.Collider.prototype,"_shapes",void 0),e.Collider=um([da(ds,e.DependentMode.CheckOnly)],e.Collider);var hH=function(){function t(e){var r=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new dd,this._gravity=new c8(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)},u_(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,c4.zeroTolerance)}}]),t}();hH._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nH=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nH.PreventClimbing=0]="PreventClimbing",nH[nH.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var hW=(nW=e.Collider,up(nj=function(t){var r;return(r=nW.call(this,t)||this)._stepOffset=.5,r._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,r._upDirection=new c8(0,1,0),r._slopeLimit=.707,r._nativeCollider=hH._nativePhysics.createCharacterController(),r._setUpDirection=r._setUpDirection.bind(ud(r)),r._upDirection._onValueChanged=r._setUpDirection,r._onUpdate(),r},nW),(nK=nj.prototype).move=function(e,t,r){var n=this._nativeCollider.move(e,t,r);return this._syncWorldPositionFromPhysicalSpace(),n},nK.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nW.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nK.clearShapes=function(){this._shapes.length>0&&nW.prototype.removeShape.call(this,this._shapes[0])},nK._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}},nK._onLateUpdate=function(){this._syncWorldPositionFromPhysicalSpace(),this._updateFlag.flag=!1},nK._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])},nK._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])},nK._syncWorldPositionFromPhysicalSpace=function(){this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition)},nK._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},u_(nj,[{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))}}]),nj),hj=(nX=e.Collider,up(nY=function(e){(t=nX.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new c8,t._angularVelocity=new c8,t._mass=1,t._centerOfMass=new c8,t._inertiaTensor=new c8(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=hH._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(ud(t)),t._setAngularVelocity=t._setAngularVelocity.bind(ud(t)),t._setCenterOfMass=t._setCenterOfMass.bind(ud(t)),t._setInertiaTensor=t._setInertiaTensor.bind(ud(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},nX),(nq=nY.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},nq.applyTorque=function(e){this._nativeCollider.addTorque(e)},nq.move=function(e,t){this._nativeCollider.move(e,t)},nq.sleep=function(){this._nativeCollider.sleep()},nq.wakeUp=function(){this._nativeCollider.wakeUp()},nq._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,r=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,r),this._updateFlag.flag=!1},nq._cloneTo=function(e){nX.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},nq._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},nq._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},nq._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},nq._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},u_(nY,[{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))}}]),nY);um([uv],hj.prototype,"_linearDamping",void 0),um([uv],hj.prototype,"_angularDamping",void 0),um([uv],hj.prototype,"_linearVelocity",void 0),um([uv],hj.prototype,"_angularVelocity",void 0),um([uv],hj.prototype,"_mass",void 0),um([uv],hj.prototype,"_centerOfMass",void 0),um([uv],hj.prototype,"_inertiaTensor",void 0),um([uv],hj.prototype,"_maxAngularVelocity",void 0),um([uv],hj.prototype,"_maxDepenetrationVelocity",void 0),um([uv],hj.prototype,"_solverIterations",void 0),um([uv],hj.prototype,"_isKinematic",void 0),um([uv],hj.prototype,"_constraints",void 0),um([uv],hj.prototype,"_collisionDetectionMode",void 0),um([uv],hj.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(nQ=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nQ.Discrete=0]="Discrete",nQ[nQ.Continuous=1]="Continuous",nQ[nQ.ContinuousDynamic=2]="ContinuousDynamic",nQ[nQ.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(nZ=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[nZ.None=0]="None",nZ[nZ.FreezePositionX=1]="FreezePositionX",nZ[nZ.FreezePositionY=2]="FreezePositionY",nZ[nZ.FreezePositionZ=4]="FreezePositionZ",nZ[nZ.FreezeRotationX=8]="FreezeRotationX",nZ[nZ.FreezeRotationY=16]="FreezeRotationY",nZ[nZ.FreezeRotationZ=32]="FreezeRotationZ";var hK=function(){this.entity=null,this.distance=0,this.point=new c8,this.normal=new c8,this.shape=null};e.PhysicsMaterialCombineMode=void 0,(nJ=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nJ.Average=0]="Average",nJ[nJ.Minimum=1]="Minimum",nJ[nJ.Multiply=2]="Multiply",nJ[nJ.Maximum=3]="Maximum";var hX=((n$=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=hH._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},u_(n$,[{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))}}]),n$),hY=(n0=e.Collider,up(n1=function(e){var t,r=(t=n0.call(this,e)||this).entity.transform;return t._nativeCollider=hH._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),t},n0),n1);e.ColliderShapeUpAxis=void 0,(n2=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[n2.X=0]="X",n2[n2.Y=1]="Y",n2[n2.Z=2]="Z",e.ControllerCollisionFlag=void 0,(n3=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[n3.Sides=1]="Sides",n3[n3.Up=2]="Up",n3[n3.Down=4]="Down",e.Joint=(up(n4=function(e){var t;return(t=dr.call(this,e)||this)._colliderInfo=new hq,t._connectedColliderInfo=new hq,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new c8,t},dr),n4.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},u_(n4,[{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))}}]),n4),um([uv],e.Joint.prototype,"_colliderInfo",void 0),um([uv],e.Joint.prototype,"_connectedColliderInfo",void 0),um([uv],e.Joint.prototype,"_nativeJoint",void 0),um([uv],e.Joint.prototype,"_force",void 0),um([uv],e.Joint.prototype,"_torque",void 0),e.Joint=um([da(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var hq=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},hQ=(n8=e.Joint,up(n5=function(){return n8.apply(this,arguments)},n8),n5.prototype._onAwake=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hH._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n5);(n9=cL||(cL={}))[n9.None=0]="None",n9[n9.LimitEnabled=1]="LimitEnabled",n9[n9.DriveEnabled=2]="DriveEnabled",n9[n9.DriveFreeSpin=4]="DriveFreeSpin";var hZ=(n6=e.Joint,up(n7=function(){var e;return e=n6.apply(this,arguments)||this,e._axis=new c8(1,0,0),e._hingeFlags=cL.None,e._useSpring=!1,e},n6),(ae=n7.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new c8,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hH._nativePhysics.createHingeJoint(t.collider._nativeCollider)},ae._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},u_(n7,[{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&cL.LimitEnabled)==cL.LimitEnabled},set:function(e){e!==this.useLimits&&(e?this._hingeFlags|=cL.LimitEnabled:this._hingeFlags&=~cL.LimitEnabled,this._nativeJoint.setHingeJointFlag(cL.LimitEnabled,e))}},{key:"useMotor",get:function(){return(this._hingeFlags&cL.DriveEnabled)==cL.DriveEnabled},set:function(e){e!==this.useMotor&&(e?this._hingeFlags|=cL.DriveEnabled:this._hingeFlags&=~cL.DriveEnabled,this._nativeJoint.setHingeJointFlag(cL.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(cL.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))}}]),n7);um([uv],hZ.prototype,"_axis",void 0),um([uv],hZ.prototype,"_hingeFlags",void 0),um([uv],hZ.prototype,"_useSpring",void 0),um([uv],hZ.prototype,"_jointMonitor",void 0),um([uv],hZ.prototype,"_limits",void 0);var hJ=(at=e.Joint,up(ar=function(){var e;return e=at.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},at),(an=ar.prototype)._onAwake=function(){var t=this._colliderInfo;t.localPosition=new c8,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=hH._nativePhysics.createSpringJoint(t.collider._nativeCollider)},an._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},u_(ar,[{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))}}]),ar),h$=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},h0=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},h1=function(){function e(){this._isTrigger=!1,this._rotation=new c8,this._position=new c8,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new hX,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)},u_(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}();h1._idGenerator=0,um([uv],h1.prototype,"_collider",void 0),um([uv],h1.prototype,"_nativeShape",void 0),um([uv],h1.prototype,"_id",void 0),um([uv],h1.prototype,"_material",void 0),um([uv],h1.prototype,"_isTrigger",void 0),um([uv],h1.prototype,"_rotation",void 0),um([uv],h1.prototype,"_position",void 0),um([uv],h1.prototype,"_contactOffset",void 0);var h2=(up(aa=function(){var e;return(e=h1.call(this)||this)._size=new c8(1,1,1),e._nativeShape=hH._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(ud(e)),e._size._onValueChanged=e._setSize,e},h1),(ai=aa.prototype)._cloneTo=function(e){h1.prototype._cloneTo.call(this,e),e.size=this.size},ai._setSize=function(){this._nativeShape.setSize(this._size)},u_(aa,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),aa);um([uv],h2.prototype,"_size",void 0);var h3=(up(ao=function(){var e;return(e=h1.call(this)||this)._radius=1,e._nativeShape=hH._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},h1),ao.prototype._cloneTo=function(e){h1.prototype._cloneTo.call(this,e),e.radius=this.radius},u_(ao,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),ao);um([uv],h3.prototype,"_radius",void 0);var h4=(up(as=function(){var e;return(e=h1.call(this)||this)._nativeShape=hH._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},h1),as),h8=(up(al=function(){var t;return(t=h1.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=hH._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},h1),al.prototype._cloneTo=function(e){h1.prototype._cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},u_(al,[{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))}}]),al);um([uv],h8.prototype,"_radius",void 0),um([uv],h8.prototype,"_height",void 0),um([uv],h8.prototype,"_upAxis",void 0);var h5=((au=(ac=function(t,r){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new dd,this._downList=new dd,this._nativeEvents=[],"undefined"!=typeof Window&&ug(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 hN(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}},au._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}}},au._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},au._onPointerEvent=function(e){this._nativeEvents.push(e)},au._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},au._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=hk[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},au._pointerRayCast=function(t,r,n){for(var a=ac._tempPoint,i=ac._tempRay,o=ac._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},au._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)},au._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},ac);h5._tempRay=new ua,h5._tempPoint=new ui,h5._tempHitResult=new hK;var h9=((ah=(ad=function(e,t){this._delta=new c8,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}},ah._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},ah._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},ah._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},ah._onWheelEvent=function(e){this._nativeEvents.push(e)},ad),h6=((af=(a_=function(e,t){this._initialized=!1,this._engine=e;var r,n,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&ug(i,OffscreenCanvas)||(this._wheelManager=new h9(e,null!=(r=null==t?void 0:t.wheelTarget)?r:i),this._pointerManager=new h5(e,null!=(n=null==t?void 0:t.pointerTarget)?n:i),this._keyboardManager=new hG(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])},af.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},af.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},af.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},af.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[hz[e]]===this._engine.time.frameCount)},af.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[hz[e]]===this._engine.time.frameCount)},af._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},af._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},af._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},u_(a_,[{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}}]),a_);(cB||(cB={})).cornerTextureCoordinate="a_CornerTextureCoordinate",(ap=cD||(cD={})).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",ap.DirectionTime="a_DirectionTime",ap.StartColor="a_StartColor",ap.StartSize="a_StartSize",ap.StartRotation0="a_StartRotation0",ap.StartSpeed="a_StartSpeed",ap.Random0="a_Random0",ap.Random1="a_Random1",ap.SimulationWorldPosition="a_SimulationWorldPosition",ap.SimulationWorldRotation="a_SimulationWorldRotation",ap.SimulationUV="a_SimulationUV";var h7=function t(r){this.billboardVertexElement=new dj(cB.cornerTextureCoordinate,0,e.VertexElementFormat.Vector4,0),this.instanceVertexElements=[new dj(cD.ShapePositionStartLifeTime,0,e.VertexElementFormat.Vector4,1,1),new dj(cD.DirectionTime,16,e.VertexElementFormat.Vector4,1,1),new dj(cD.StartColor,32,e.VertexElementFormat.Vector4,1,1),new dj(cD.StartSize,48,e.VertexElementFormat.Vector3,1,1),new dj(cD.StartRotation0,60,e.VertexElementFormat.Vector3,1,1),new dj(cD.StartSpeed,72,e.VertexElementFormat.Float,1,1),new dj(cD.Random0,76,e.VertexElementFormat.Vector4,1,1),new dj(cD.Random1,92,e.VertexElementFormat.Vector4,1,1),new dj(cD.SimulationWorldPosition,108,e.VertexElementFormat.Vector3,1,1),new dj(cD.SimulationWorldRotation,120,e.VertexElementFormat.Vector4,1,1),new dj(cD.SimulationUV,136,e.VertexElementFormat.Vector4,1,1)];var n,a,i=new dH(r,e.BufferBindFlag.VertexBuffer,64,e.BufferUsage.Static,!1);i.isGCIgnored=!0,this.billboardVertexBufferBinding=new d5(i,16);var o=new dH(r,e.BufferBindFlag.IndexBuffer,t.billboardIndexCount,e.BufferUsage.Static,!1);o.isGCIgnored=!0,this.billboardIndexBufferBinding=new d1(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(up(n=function(){return dI.call(this,i)},dI),n.prototype.restoreContent=function(){i.setData(s)},n)),r.resourceManager.addContentRestorer(new(up(a=function(){return dI.call(this,o)},dI),a.prototype.restoreContent=function(){},a))};h7.instanceVertexStride=152,h7.instanceVertexFloatStride=h7.instanceVertexStride/4,h7.startLifeTimeOffset=3,h7.timeOffset=7,h7.simulationUVOffset=34,h7.billboardIndexCount=6,h7.boundsFloatStride=8,h7.boundsTimeOffset=6,h7.boundsMaxLifetimeOffset=7;var _e="#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;}",_t="#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}",_r=((am=function(){}).init=function(){var t=new u$("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 u5,t._renderStateDataMap[e.RenderStateDataKey.RenderQueueType]=dX._shadowCasterRenderQueueProp;var r=new u$("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};u9.create("blinn-phong",[].concat(new u$("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)),u9.create("pbr",[].concat(new u$("Forward",_t,"#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)),u9.create("pbr-specular",[].concat(new u$("Forward",_t,"#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)),u9.create("unlit",[].concat(new u$("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)),u9.create("blit",[new u$("Forward",_e,"#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)]),u9.create("skybox",[new u$("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)]),u9.create("SkyProcedural",[new u$("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)]),u9.create("particle-shader",[new u$("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*a_Random0.x*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)]),u9.create("SpriteMask",[new u$("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)]),u9.create("Sprite",[new u$("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)]),u9.create("Text",[new u$("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)]),u9.create("background-texture",[new u$("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform vec4 camera_ProjectionParams;void main(){gl_Position=vec4(POSITION,1.0);gl_Position.y*=camera_ProjectionParams.x;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)])},am),_n=((av=(ag=function(e){this.engine=e,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},av.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},av._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},av._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])},av._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)},ag),_a=(up(ay=function(e){var t;return(t=hy.call(this,e)||this)._usedElementCount=0,t._elements=[],t},hy),(ax=ay.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},ax.clear=function(){this._usedElementCount=0},ay),_i=((aT=(ab=function(){}).prototype)._initialize=function(e,t){},aT._update=function(){},aT._destroy=function(){},aT._getRequestAnimationFrame=function(){return null},aT._getCancelAnimationFrame=function(){return null},aT._getCameraIgnoreClearFlags=function(t){return e.CameraClearFlags.None},ab);_r.init();var _o=function(t){function r(n,a,i){(o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new u5,o._renderElementPool=new _a(dL),o._subRenderElementPool=new _a(dB),o._textSubRenderElementPool=new _a(dB),o._charRenderInfoPool=new hx(dz,50),o._spriteDefaultMaterials=[],o._renderContext=new dT,o._renderCount=0,o._shaderProgramPools=[],o._fontMap={},o._macroCollection=new uI,o._settings={},o._resourceManager=new hB(ud(o)),o._sceneManager=new hR(ud(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new uj,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(ud(o)),o._onDeviceRestored.bind(ud(o))),o._canvas=n;var o,s=ud(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=dk.createFromOS(ud(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o._batcherManager=new hA(ud(o)),o.inputManager=new h6(ud(o),i.input);var l=i.xrDevice;if(l&&(o.xrManager=new _i,o.xrManager._initialize(ud(o),l)),a.canIUse(e.GLCapabilityType.depthTexture)){var c=new dp(ud(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(r._noDepthTextureMacro);var u=new dK(ud(o),u9.find("unlit"));u.isGCIgnored=!0,u.shaderData.setColor("material_BaseColor",new us(1,0,1.01,1)),o._meshMagentaMaterial=u;var d=new dK(ud(o),u9.find("particle-shader"));d.isGCIgnored=!0,d.shaderData.setColor("material_BaseColor",new us(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 hv(ud(o)),o._particleBufferUtils=new h7(ud(o)),o}up(r,t);var n=r.prototype;return n.createEntity=function(e){return new hp(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 _n(this),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 uH.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&&!u9._shaderLab&&(u9._shaderLab=r);var a=[];n&&a.push(n.initialize().then(function(){return hH._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 dK(this,u9.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 dK(this,u9.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 dK(this,u9.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 u5,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()},u_(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}(uO);_o._gammaMacro=uD.getByName("ENGINE_IS_COLORSPACE_GAMMA"),_o._noDepthTextureMacro=uD.getByName("ENGINE_NO_DEPTH_TEXTURE"),_o._pixelsPerUnit=100;var _s=(u_(aC=function(){this._sizeUpdateFlagManager=new uP},[{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())}}]),aC),_l=((aA=(aS=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},aA._render=function(e){var t=this.material,r=this.mesh;if(!t){uH.warn("The material of sky is not defined.");return}if(t.destroyed){uH.warn("The material of sky is destroyed.");return}if(!r){uH.warn("The mesh of sky is not defined.");return}if(r.destroyed){uH.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=aS._viewProjMatrix,h=aS._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(c4.degreeToRadian(s)/2);h.elements[0]=v/o,h.elements[5]=v,un.multiply(h,d,d);var y=c.getMatrix(dT.vpMatrixProperty);e.flipProjection&&un.multiply(dT._flipYMatrix,d,d),c.setMatrix(dT.vpMatrixProperty,d);var x=u9._compileMacros;uI.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(dT.vpMatrixProperty,y)},u_(aS,[{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}}}]),aS);_l._epsilon=1e-6,_l._viewProjMatrix=new un,_l._projectionMatrix=new un(1,0,0,0,0,1,0,0,0,0,_l._epsilon-1,-1,0,0,0,0);var _c=((aR=(aM=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new us(.25,.25,.25,1),this.sky=new _l,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()},aR._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)}},aR._initMesh=function(e){var t,r=this._mesh=this._createPlane(e);e.resourceManager.addContentRestorer(new(up(t=function(){return dI.call(this,r)},dI),t.prototype.restoreContent=function(){r.setPositions(r.getPositions()),r.setUVs(r.getUVs()),r.setIndices(r.getIndices()),r.uploadData(!1)},t)),this._mesh._addReferCount(1)},aR._initMaterial=function(t){var r=this._material=new dK(t,u9.find("background-texture"));r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r._addReferCount(1)},aR._createPlane=function(e){for(var t=new he(e),r=new Uint8Array([1,2,0,1,3,2]),n=[,,,,],a=[,,,,],i=0;i<4;++i)n[i]=new c8,a[i]=new ui(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},u_(aM,[{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())}}]),aM),_u=((aw=(aE=function(){this._cameraNeedSorting=!1,this._activeCameras=new dd,this._renderers=new dd,this._onStartScripts=new dd,this._onUpdateScripts=new dd,this._onLateUpdateScripts=new dd,this._onPhysicsUpdateScripts=new dd,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new dd,this._onUpdateRenderers=new dd,this._componentsContainerPool=[]}).prototype).addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},aw.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},aw.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}},aw.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},aw.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},aw.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},aw.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},aw.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},aw.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aw.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},aw.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},aw.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},aw.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},aw.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},aw.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aw.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},aw.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},aw.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},aw.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})},aw.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},aw.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},aw.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},aw.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aw.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},aw.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}},aw.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},aw.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},aw.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},aw.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},aw._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()},aE);e.FogMode=void 0,(aP=e.FogMode||(e.FogMode={}))[aP.None=0]="None",aP[aP.Linear=1]="Linear",aP[aP.Exponential=2]="Exponential",aP[aP.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(aF=e.DiffuseMode||(e.DiffuseMode={}))[aF.SolidColor=0]="SolidColor",aF[aF.SphericalHarmonics=1]="SphericalHarmonics";var _d=(up(aL=function(t){var r;return(r=uS.call(this,t)||this)._diffuseSolidColor=new us(.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},uS),(aB=aL.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(aL._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(aL._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(aL._specularIntensityProperty,this._specularIntensity),t.setFloatArray(aL._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},aB._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,r=t.indexOf(e);t.splice(r,1);var n=e.shaderData;n.setTexture(aL._specularTextureProperty,null),n.disableMacro(aL._specularMacro)},aB._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(aL._shMacro):t.disableMacro(aL._shMacro)},aB._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(aL._specularTextureProperty,this._specularTexture),e.setFloat(aL._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(aL._specularMacro)):e.disableMacro(aL._specularMacro)},aB._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(aL._decodeRGBMMacro):e.disableMacro(aL._decodeRGBMMacro)},aB._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]},u_(aL,[{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(aL._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(aL._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(aL._specularIntensityProperty,e)}}]),aL);_d._shMacro=uD.getByName("SCENE_USE_SH"),_d._specularMacro=uD.getByName("SCENE_USE_SPECULAR_ENV"),_d._decodeRGBMMacro=uD.getByName("SCENE_IS_DECODE_ENV_RGBM"),_d._diffuseColorProperty=uW.getByName("scene_EnvMapLight.diffuse"),_d._diffuseSHProperty=uW.getByName("scene_EnvSH"),_d._diffuseIntensityProperty=uW.getByName("scene_EnvMapLight.diffuseIntensity"),_d._specularTextureProperty=uW.getByName("scene_EnvSpecularSampler"),_d._specularIntensityProperty=uW.getByName("scene_EnvMapLight.specularIntensity"),_d._mipLevelProperty=uW.getByName("scene_EnvMapLight.mipMapLevel");var _h=(up(aD=function(){var t;return t=dr.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 us,t._shadowStrength=1,t._color=new us(1,1,1,1),t},dr),aD.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},u_(aD,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=c4.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 un),un.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new un),un.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),aD);um([uv],_h.prototype,"_lightIndex",void 0);var __=(up(aI=function(){var e;return e=_h.apply(this,arguments)||this,e._reverseDirection=new c8,e},_h),(aV=aI.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]=us.gammaToLinearSpace(o.r),r.color[a+1]=us.gammaToLinearSpace(o.g),r.color[a+2]=us.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},aV._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},aV._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},aI._updateShaderData=function(e,t){e.setIntArray(aI._cullingMaskProperty,t.cullingMask),e.setFloatArray(aI._colorProperty,t.color),e.setFloatArray(aI._directionProperty,t.direction)},u_(aI,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return c8.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aI);__._cullingMaskProperty=uW.getByName("scene_DirectLightCullingMask"),__._colorProperty=uW.getByName("scene_DirectLightColor"),__._directionProperty=uW.getByName("scene_DirectLightDirection");var _f=(up(aO=function(){var e;return e=_h.apply(this,arguments)||this,e.distance=100,e},_h),(aN=aO.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]=us.gammaToLinearSpace(o.r),r.color[a+1]=us.gammaToLinearSpace(o.g),r.color[a+2]=us.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},aN._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},aN._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},aO._updateShaderData=function(e,t){e.setIntArray(aO._cullingMaskProperty,t.cullingMask),e.setFloatArray(aO._colorProperty,t.color),e.setFloatArray(aO._positionProperty,t.position),e.setFloatArray(aO._distanceProperty,t.distance)},u_(aO,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),aO);_f._cullingMaskProperty=uW.getByName("scene_PointLightCullingMask"),_f._colorProperty=uW.getByName("scene_PointLightColor"),_f._positionProperty=uW.getByName("scene_PointLightPosition"),_f._distanceProperty=uW.getByName("scene_PointLightDistance");var _p=(up(ak=function(){var e;return e=_h.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new c8,e._projectMatrix=new un,e},_h),(az=ak.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]=us.gammaToLinearSpace(s.r),r.color[a+1]=us.gammaToLinearSpace(s.g),r.color[a+2]=us.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)},az._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},az._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},ak._updateShaderData=function(e,t){e.setIntArray(ak._cullingMaskProperty,t.cullingMask),e.setFloatArray(ak._colorProperty,t.color),e.setFloatArray(ak._positionProperty,t.position),e.setFloatArray(ak._directionProperty,t.direction),e.setFloatArray(ak._distanceProperty,t.distance),e.setFloatArray(ak._angleCosProperty,t.angleCos),e.setFloatArray(ak._penumbraCosProperty,t.penumbraCos)},u_(ak,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return c8.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 un.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),ak);_p._cullingMaskProperty=uW.getByName("scene_SpotLightCullingMask"),_p._colorProperty=uW.getByName("scene_SpotLightColor"),_p._positionProperty=uW.getByName("scene_SpotLightPosition"),_p._directionProperty=uW.getByName("scene_SpotLightDirection"),_p._distanceProperty=uW.getByName("scene_SpotLightDistance"),_p._angleCosProperty=uW.getByName("scene_SpotLightAngleCos"),_p._penumbraCosProperty=uW.getByName("scene_SpotLightPenumbraCos");var _m=function(){function t(){this._spotLights=new dd,this._pointLights=new dd,this._directLights=new dd,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?(__._updateShaderData(e,s),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(_f._updateShaderData(e,o),e.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(_p._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}();_m._sunlightColorProperty=uW.getByName("scene_SunlightColor"),_m._sunlightDirectionProperty=uW.getByName("scene_SunlightDirection"),_m._maxLight=10,e.BloomDownScaleMode=void 0,(aU=e.BloomDownScaleMode||(e.BloomDownScaleMode={}))[aU.Half=0]="Half",aU[aU.Quarter=1]="Quarter";var _g=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 dK(r,u9.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 uo),i.setVector4(t._lowMipTexelSizeProp,new uo),o.setVector4(t._bloomIntensityParams,new uo(1,1,0,0)),o.setVector4(t._dirtTilingOffsetProp,new uo),o.setColor(t._tintProp,new us(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]=dv.recreateRenderTargetIfNeeded(o,this._mipUpRT[u],l,c,s,null,!1,!1,1,e.TextureWrapMode.Clamp,e.TextureFilterMode.Bilinear),this._mipDownRT[u]=dv.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));dv.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++)dv.blitTexture(r,n.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),dv.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),dv.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},u_(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=us.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=c4.clamp(e,0,1))!==this._scatter){this._scatter=e;var r=this._bloomMaterial.shaderData.getVector4(t._bloomParams),n=c4.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}();_g.SHADER_NAME="PostProcessEffect Bloom",_g._hqMacro=uD.getByName("BLOOM_HQ"),_g._dirtMacro=uD.getByName("BLOOM_DIRT"),_g._bloomParams=uW.getByName("material_BloomParams"),_g._lowMipTextureProp=uW.getByName("material_lowMipTexture"),_g._lowMipTexelSizeProp=uW.getByName("material_lowMipTexelSize"),_g._enableMacro=uD.getByName("ENABLE_EFFECT_BLOOM"),_g._bloomTextureProp=uW.getByName("material_BloomTexture"),_g._dirtTextureProp=uW.getByName("material_BloomDirtTexture"),_g._tintProp=uW.getByName("material_BloomTint"),_g._bloomIntensityParams=uW.getByName("material_BloomIntensityParams"),_g._dirtTilingOffsetProp=uW.getByName("material_BloomDirtTilingOffset"),u9.create(_g.SHADER_NAME,[new u$("Bloom Prefilter",_e,"#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 u$("Bloom Blur Horizontal",_e,"#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 u$("Bloom Blur Vertical",_e,"#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 u$("Bloom Upsample",_e,"#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,(aG=e.TonemappingMode||(e.TonemappingMode={}))[aG.Neutral=0]="Neutral",aG[aG.ACES=1]="ACES";var _v=(u_(aH=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(aH._enableMacro):this._uberMaterial.shaderData.disableMacro(aH._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()))}}]),aH);_v._enableMacro=uD.getByName("ENABLE_EFFECT_TONEMAPPING");var _y=function(){function e(t){this.scene=t,this.isActive=!0;var r=u9.find(e.UBER_SHADER_NAME),n=new dK(t.engine,r),a=n.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new _g(n),o=new _v(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),dv.blitTexture(a,i,r,0,n.viewport,this._uberMaterial)},u_(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();_y.UBER_SHADER_NAME="UberPost",Object.assign(uK,{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;}"}),u9.create(_y.UBER_SHADER_NAME,_e,"#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 _x=function(t){function r(n,a){(i=t.call(this,n)||this).physics=new hH(ud(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new c8(1/15,.2,7/15),i.shadowDistance=50,i.shadowFadeBorder=.1,i._lightManager=new _m,i._componentsManager=new _u,i._maskManager=new dC,i._isActiveInEngine=!1,i._globalShaderMacro=new uI,i._rootEntities=[],i._postProcessManager=new _y(ud(i)),i._background=new _c(i._engine),i._shaderData=new de(cu.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new us(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new uo,i._isActive=!0,i._enableTransparentShadow=!1,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new _d(n),n.sceneManager._allCreatedScenes.push(ud(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}up(r,t);var n=r.prototype;return n.createRootEntity=function(e){var t=new hp(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(),t._setTransformDirty());var a=t._scene;a!==this?(a&&n&&a._removeFromEntityList(t),this._addToRootEntityList(r,t)):n||this._addToRootEntityList(r,t);var i=ch.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=ch.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=ch.Scene),i&&t._processInActive(i),a!==this&&hp._traverseSetOwnerScene(t,this);var o=ch.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=ch.Hierarchy)),t._isActiveInScene&&a===this||(o|=ch.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=ch.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=ch.Hierarchy),e._isActiveInScene&&(t|=ch.Scene),t&&e._processInActive(t),hp._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=hp._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(ch.Hierarchy):n._processInActive(ch.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(_m._sunlightColorProperty,a._lightColor),t.setVector3(_m._sunlightDirectionProperty,a.direction)):t.setVector3(_m._sunlightDirectionProperty,c8._zero),this.castShadows&&a&&a.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",a.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),uI.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()},u_(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){uH.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}(uC);_x._fogColorProperty=uW.getByName("scene_FogColor"),_x._fogParamsProperty=uW.getByName("scene_FogParams");var _b=(up(aW=function(){var e;return e=dr.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},dr),(aj=aW.prototype).onAwake=function(){},aj.onEnable=function(){},aj.onStart=function(){},aj.onUpdate=function(e){},aj.onLateUpdate=function(e){},aj.onBeginRender=function(e){},aj.onEndRender=function(e){},aj.onPhysicsUpdate=function(){},aj.onTriggerEnter=function(e){},aj.onTriggerExit=function(e){},aj.onTriggerStay=function(e){},aj.onCollisionEnter=function(e){},aj.onCollisionExit=function(e){},aj.onCollisionStay=function(e){},aj.onPointerDown=function(e){},aj.onPointerUp=function(e){},aj.onPointerClick=function(e){},aj.onPointerEnter=function(e){},aj.onPointerExit=function(e){},aj.onPointerDrag=function(e){},aj.onDisable=function(){},aj.onDestroy=function(){},aj._onAwake=function(){this.onAwake()},aj._onEnable=function(){this.onEnable()},aj._onDisable=function(){this.onDisable()},aj._onEnableInScene=function(){var e=this.scene._componentsManager,t=aW.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)},aj._onDisableInScene=function(){var e=this.scene._componentsManager,t=aW.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)},aj._onDestroy=function(){dr.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},aW);um([uv],_b.prototype,"_started",void 0),um([uv],_b.prototype,"_onStartIndex",void 0),um([uv],_b.prototype,"_onUpdateIndex",void 0),um([uv],_b.prototype,"_onLateUpdateIndex",void 0),um([uv],_b.prototype,"_onPhysicsUpdateIndex",void 0),um([uv],_b.prototype,"_onPreRenderIndex",void 0),um([uv],_b.prototype,"_onPostRenderIndex",void 0),um([uv],_b.prototype,"_entityScriptsIndex",void 0);var _T=((aK=function(e){this.useCache=e}).registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},aK.getClass=function(e){return this._engineObjects[e]},aK.getClassName=function(e){return this._classNameMap.get(e)},aK);_T._engineObjects={},_T._classNameMap=new Map;var _C=((aY=(aX=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)},aY.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]}},aY.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}},aY._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)},aX);(aq=cI||(cI={}))[aq.Property=0]="Property",aq[aq.Method=1]="Method",aq[aq.Array=2]="Array",(aQ=cV||(cV={}))[aQ.Get=1]="Get",aQ[aQ.Set=2]="Set",aQ[aQ.Both=3]="Both";var _S=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:_C},e}();_S._components=[],_S._assemblerMap=new Map;var _A=((aJ=(aZ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aJ.getTargetValue=function(){return this._transform.position},aJ.setTargetValue=function(e){this._transform.position=e},aZ);_S.registerAssembler(ds,"position",_A);var _M=((a0=(a$=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},a0.getTargetValue=function(){return this._transform.rotationQuaternion},a0.setTargetValue=function(e){this._transform.rotationQuaternion=e},a$);_S.registerAssembler(ds,"rotationQuaternion",_M);var _R=((a2=(a1=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},a2.getTargetValue=function(){return this._transform.scale},a2.setTargetValue=function(e){this._transform.scale=e},a1);_S.registerAssembler(ds,"scale",_R);var _E=((a4=(a3=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.component},a4.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},a4.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},a3);_S.registerAssembler(hg,"blendShapeWeights",_E);var _w=((a5=(a8=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},a5.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},a8),_P=((a6=(a9=function(){this.typeIndex=0,this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e,t){var r=this.curve.constructor,n=new _S(e,this.type,t,this.property,this.getProperty,r);return r._initializeOwner(n),n.saveDefaultValue(),n},a6._createCurveLayerOwner=function(e){var t=this.curve.constructor,r=new _w;return r.curveOwner=e,t._initializeLayerOwner(r),r.initFinalValue(),r},a6._getTempCurveOwner=function(e,t){var r=e.instanceId;return this._tempCurveOwner[r]||(this._tempCurveOwner[r]=this._createCurveOwner(e,t)),this._tempCurveOwner[r]},a9),_F=function(){},_L=(up(a7=function(e){var t;return(t=uC.call(this,null)||this).name=e,t._curveBindings=[],t._updateFlagManager=new uP,t._length=0,t._events=[],t},uC),(ie=a7.prototype).addEvent=function(e,t,r){if("string"==typeof e){var n,a=new _F;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()},ie.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},ie.addCurveBinding=function(e,t,r,n,a,i){var o=new _P;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)},ie.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},ie._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,_S._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)}}}},u_(a7,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),a7);e.InterpolationType=void 0,(it=e.InterpolationType||(e.InterpolationType={}))[it.Linear=0]="Linear",it[it.CubicSpine=1]="CubicSpine",it[it.Step=2]="Step",it[it.Hermite=3]="Hermite";var _B=((ia=(ir=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)}},ia.evaluate=function(e){return this._evaluate(e,this._evaluateData)},ia.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},ia._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},ia._evaluateAdditive=function(e,t){var r=this._evaluate(e,t);return this._type._subtractValue(r,this.keys[0].value,t.value)},u_(ir,[{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}}]),ir);e.AnimationArrayCurve=(up(ii=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=[],e},_B),ii._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},ii._initializeLayerOwner=function(e){e.finalValue=[]},ii._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},ii._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},ii._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},ii._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},ii._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},ii._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},ii._isCopyMode=!0,ii._supportInterpolationMode=!0,ii),e.AnimationArrayCurve=um([dl()],e.AnimationArrayCurve),e.AnimationBoolCurve=(up(io=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=!1,e},_B),io._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},io._initializeLayerOwner=function(e){e.finalValue=!1},io._lerpValue=function(e,t){return e},io._subtractValue=function(e,t,r){return e},io._getZeroValue=function(){return!1},io._additiveValue=function(e,t,r){return e},io._setValue=function(e){return e},io._hermiteInterpolationValue=function(e){return e.value},io._isCopyMode=!1,io._supportInterpolationMode=!1,io),e.AnimationBoolCurve=um([dl()],e.AnimationBoolCurve),e.AnimationColorCurve=(up(is=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new us,e},_B),is._initializeOwner=function(e){e.defaultValue=new us,e.fixedPoseValue=new us,e.baseEvaluateData.value=new us,e.crossEvaluateData.value=new us},is._initializeLayerOwner=function(e){e.finalValue=new us},is._lerpValue=function(e,t,r,n){return us.lerp(e,t,r,n),n},is._subtractValue=function(e,t,r){return us.subtract(e,t,r),r},is._getZeroValue=function(e){return e.set(0,0,0,0),e},is._additiveValue=function(e,t,r){return us.scale(e,t,e),us.add(r,e,r),r},is._setValue=function(e,t){return t.copyFrom(e),t},is._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},is._isCopyMode=!0,is._supportInterpolationMode=!0,is),e.AnimationColorCurve=um([dl()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(up(il=function(){return _B.apply(this,arguments)},_B),il.prototype.addKey=function(e){_B.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)}},il._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)},il._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},il._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},il._subtractValue=function(e,t,r){for(var n=0,a=e.length;n<a;n++)r[n]=e[n]-t[n];return r},il._getZeroValue=function(e){for(var t=0,r=e.length;t<r;t++)e[t]=0;return e},il._additiveValue=function(e,t,r){for(var n=0,a=r.length;n<a;++n)r[n]+=e[n]*t;return r},il._setValue=function(e,t){for(var r=0,n=t.length;r<n;++r)t[r]=e[r];return t},il._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},il._isCopyMode=!0,il._supportInterpolationMode=!0,il),e.AnimationFloatArrayCurve=um([dl()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(up(ic=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=0,e},_B),ic._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},ic._initializeLayerOwner=function(e){e.finalValue=0},ic._lerpValue=function(e,t,r){return e+(t-e)*r},ic._additiveValue=function(e,t,r){return r+e*t},ic._subtractValue=function(e,t){return e-t},ic._getZeroValue=function(){return 0},ic._setValue=function(e){return e},ic._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},ic._isCopyMode=!1,ic._supportInterpolationMode=!0,ic),e.AnimationFloatCurve=um([dl()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(up(iu=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new ur,e},_B),iu._initializeOwner=function(e){e.defaultValue=new ur,e.fixedPoseValue=new ur,e.baseEvaluateData.value=new ur,e.crossEvaluateData.value=new ur},iu._initializeLayerOwner=function(e){e.finalValue=new ur},iu._lerpValue=function(e,t,r,n){return ur.slerp(e,t,r,n),n},iu._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},iu._subtractValue=function(t,r,n){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return ur.conjugate(r,a),ur.multiply(a,t,n),n},iu._getZeroValue=function(e){return e.set(0,0,0,1),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,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},iu._supportInterpolationMode=!0,iu._isCopyMode=!0,iu._tempConjugateQuat=new ur,iu),e.AnimationQuaternionCurve=um([dl()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(up(id=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new ui,e},_B),id._initializeOwner=function(e){e.defaultValue=new ui,e.fixedPoseValue=new ui,e.baseEvaluateData.value=new ui,e.crossEvaluateData.value=new ui},id._initializeLayerOwner=function(e){e.finalValue=new ui},id._lerpValue=function(e,t,r,n){return ui.lerp(e,t,r,n),n},id._additiveValue=function(e,t,r){return ui.scale(e,t,e),ui.add(r,e,r),r},id._subtractValue=function(e,t,r){return ui.subtract(e,t,r),r},id._getZeroValue=function(e){return e.set(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,a},id._isCopyMode=!0,id._supportInterpolationMode=!0,id),e.AnimationVector2Curve=um([dl()],e.AnimationVector2Curve),e.AnimationVector3Curve=(up(ih=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new c8,e},_B),ih._initializeOwner=function(e){e.defaultValue=new c8,e.fixedPoseValue=new c8,e.baseEvaluateData.value=new c8,e.crossEvaluateData.value=new c8},ih._initializeLayerOwner=function(e){e.finalValue=new c8},ih._lerpValue=function(e,t,r,n){return c8.lerp(e,t,r,n),n},ih._relativeBaseValue=function(e,t){return c8.subtract(t,e,t),t},ih._additiveValue=function(e,t,r){return c8.scale(e,t,e),c8.add(r,e,r),r},ih._subtractValue=function(e,t,r){return c8.subtract(e,t,r),r},ih._getZeroValue=function(e){return e.set(0,0,0),e},ih._setValue=function(e,t){return t.copyFrom(e),t},ih._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},ih._isCopyMode=!0,ih._supportInterpolationMode=!0,ih),e.AnimationVector3Curve=um([dl()],e.AnimationVector3Curve),e.AnimationVector4Curve=(up(i_=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new uo,e},_B),i_._initializeOwner=function(e){e.defaultValue=new uo,e.fixedPoseValue=new uo,e.baseEvaluateData.value=new uo,e.crossEvaluateData.value=new uo},i_._initializeLayerOwner=function(e){e.finalValue=new uo},i_._lerpValue=function(e,t,r,n){return uo.lerp(e,t,r,n),n},i_._additiveValue=function(e,t,r){return uo.scale(e,t,e),uo.add(r,e,r),r},i_._subtractValue=function(e,t,r){return uo.subtract(e,t,r),r},i_._getZeroValue=function(e){return e.set(0,0,0,0),e},i_._setValue=function(e,t){return t.copyFrom(e),t},i_._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},i_._isCopyMode=!0,i_._supportInterpolationMode=!0,i_),e.AnimationVector4Curve=um([dl()],e.AnimationVector4Curve),e.AnimationRefCurve=(up(ip=function(){return _B.call(this)},_B),ip._initializeOwner=function(e){},ip._initializeLayerOwner=function(e){},ip._setValue=function(e){return e},ip._isCopyMode=!1,ip._supportInterpolationMode=!1,ip),e.AnimationRefCurve=um([dl()],e.AnimationRefCurve),e.AnimationRectCurve=(up(im=function(){var e;return(e=_B.call(this)||this)._evaluateData.value=new ul,e},_B),im._initializeOwner=function(e){e.defaultValue=new ul,e.fixedPoseValue=new ul,e.baseEvaluateData.value=new ul,e.crossEvaluateData.value=new ul},im._initializeLayerOwner=function(e){e.finalValue=new ul},im._setValue=function(e,t){return t.copyFrom(e),t},im._isCopyMode=!0,im._supportInterpolationMode=!1,im),e.AnimationRectCurve=um([dl()],e.AnimationRectCurve),e.AnimationStringCurve=(up(ig=function(){var e;return(e=_B.call(this)||this)._evaluateData.value="",e},_B),ig._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},ig._initializeLayerOwner=function(e){e.finalValue=""},ig._lerpValue=function(e,t){return e},ig._subtractValue=function(e,t,r){return e},ig._getZeroValue=function(){return""},ig._additiveValue=function(e,t,r){return e},ig._setValue=function(e){return e},ig._hermiteInterpolationValue=function(e){return e.value},ig._isCopyMode=!1,ig._supportInterpolationMode=!1,ig),e.AnimationStringCurve=um([dl()],e.AnimationStringCurve),e.AnimatorConditionMode=void 0,(iv=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iv.If=0]="If",iv[iv.IfNot=1]="IfNot",iv[iv.Greater=2]="Greater",iv[iv.Less=3]="Less",iv[iv.Equals=4]="Equals",iv[iv.NotEquals=5]="NotEquals",e.AnimatorCullingMode=void 0,(iy=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[iy.None=0]="None",iy[iy.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(ix=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[ix.Override=0]="Override",ix[ix.Additive=1]="Additive",(ib=cO||(cO={}))[ib.UnStarted=0]="UnStarted",ib[ib.Playing=1]="Playing",ib[ib.Finished=2]="Finished",(iT=cN||(cN={}))[iT.Standby=0]="Standby",iT[iT.Playing=1]="Playing",iT[iT.CrossFading=2]="CrossFading",iT[iT.FixedCrossFading=3]="FixedCrossFading",iT[iT.Finished=4]="Finished";var _D=((iC=function(){this.handlers=[]}).prototype.dispose=function(){},iC),_I=function(){},_V=((iA=(iS=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 _I;return n.mode=e,n.parameterName=t,n.threshold=r,this._conditions.push(n),n},iA.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},u_(iS,[{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}}]),iS);e.WrapMode=void 0,(iM=e.WrapMode||(e.WrapMode={}))[iM.Once=0]="Once",iM[iM.Loop=1]="Loop";var _O=((iE=(iR=function(){this.isForwards=!0,this._changedOrientation=!1}).prototype).reset=function(e,t,r){this.state=e,this.playedTime=0,this.offsetFrameTime=r,this.stateData=t,this.playState=cO.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0,this.isForwards=!0},iE.updateOrientation=function(e){if(0!==e){var t=this.isForwards;this.isForwards=e>0,this.isForwards!==t&&(this._changedOrientation=!0,this.isForwards||this._correctTime())}},iE.update=function(t){this.playedTime+=t;var r=this.state,n=this.playedTime+this.offsetFrameTime,a=r._getDuration();this.playState=cO.Playing,r.wrapMode===e.WrapMode.Loop?n=a?n%a:0:Math.abs(n)>=a&&(n=n<0?-a:a,this.playState=cO.Finished),n<0&&(n+=a),this.clipTime=n+r.clipStartTime*r.clip.length,this._changedOrientation&&(this.isForwards||this._correctTime(),this._changedOrientation=!1)},iE._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},iR),_N=((iw=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new _O,this.destPlayData=new _O,this.layerState=cN.Standby,this.crossCurveMark=0,this.manuallyTransition=new _V,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iw),_k=function(){this.curveLayerOwner=[],this.eventHandlers=[]},_z=(up(iP=function(t){var r;return(r=dr.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 _a(_D),r._parametersValueMap=Object.create(null),r._tempAnimatorStateInfo={layerIndex:-1,state:null},r._controlledRenderers=[],r},dr),(iF=iP.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)},iF.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)},iF.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)}}},iF.getCurrentAnimatorState=function(e){var t,r;return null==(r=this._animatorLayersData[e])?void 0:null==(t=r.srcPlayData)?void 0:t.state},iF.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iF.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},iF.getParameter=function(e){var t,r;return null!=(r=null==(t=this._animatorController)?void 0:t._parametersMap[e])?r:null},iF.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},iF.setParameterValue=function(e,t){var r;(null==(r=this._animatorController)?void 0:r._parametersMap[e])&&(this._parametersValueMap[e]=t)},iF._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iF._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},iF._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},iF._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)},iF._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},iF._getAnimatorStateData=function(e,t,r,n){var a=r.animatorStateDataMap,i=a[e];return i||(i=new _k,a[e]=i,this._saveAnimatorStateData(t,i,r,n),this._saveAnimatorEventHandlers(t,i)),i},iF._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,_S._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,uH.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},iF._saveAnimatorEventHandlers=function(e,t){var r=this,n=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){r._entity.getComponents(_b,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,p=a[_],m=null==(f=p[d])?void 0:f.bind(p);m&&h.push(m)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},iF._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},iF._addCrossOwner=function(e,t,r,n){t.crossSrcCurveIndex=r,t.crossDestCurveIndex=n,e.crossLayerOwnerCollection.push(t)},iF._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},iF._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},iF._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)},iF._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))}},iF._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)}}}},iF._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new _N),t},iF._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 cN.Standby:this._checkAnyAndEntryState(t,r,n,a,i);break;case cN.Playing:this._updatePlayingState(t,r,n,o,s,a,i);break;case cN.Finished:this._updateFinishedState(t,r,n,o,s,a,i);break;case cN.CrossFading:this._updateCrossFadeState(t,r,n,o,s,a,i);break;case cN.FixedCrossFading:this._updateCrossFadeFromPoseState(t,r,n,o,s,a,i)}},iF._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=c.transitions,g=r.stateMachine.anyStateTransitions,v=g.length&&this._applyTransitionsByCondition(e,t,r,c,g,o)||m.length&&this._applyStateTransitions(e,t,r,p,l,m,h,f,d,o);if(v){var y=c._getClipActualEndTime(),x=v.exitTime*c._getDuration()+c._getClipActualStartTime();if(p)s=x<h?x+y-h:x-h;else{var b=c._getClipActualStartTime();s=-(s=h<x?y-x+h-b:h-x)}l.update(s-d)}else s=d,l.playState===cO.Finished&&(t.layerState=cN.Finished);if(this._evaluatePlayingState(l,n,a,o),this._fireAnimationEventsAndCallScripts(e,l,c,h,_,s),v){var T=i-s/u;T>0&&this._updateState(e,t,r,T,o)}},iF._evaluatePlayingState=function(e,t,r,n){var a=e.state.clip._curveBindings,i=e.playState===cO.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()}}}},iF._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()*t.crossFadeTransition.duration,f=d.speed*u,p=h.speed*u,m=p*i;l&&l.updateOrientation(f*i),c&&c.updateOrientation(m);var g=l.clipTime,v=l.playState,y=c.clipTime,x=c.playState;if(c.isForwards){var b=c.playedTime;s=b+m>_?_-b:m}else{var T=c.playedTime;s=T-m>_?T-_:m}var C=0===p?i:s/p,S=C*f;l.update(S),c.update(s);var A=Math.abs(c.playedTime)/_;(A>=1-c4.zeroTolerance||0===_)&&(A=1);var M=1===A;if(M?(l.playState=cO.Finished,this._preparePlayOwner(t,h),this._evaluatePlayingState(c,n,a,o)):this._evaluateCrossFadeState(t,l,c,n,A,a,o),this._fireAnimationEventsAndCallScripts(e,l,d,g,v,S),this._fireAnimationEventsAndCallScripts(e,c,h,y,x,s),M){this._updateCrossFadeData(t);var R=i-C;R>0&&this._updateState(e,t,r,R,o)}},iF._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===cO.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()}}},iF._updateCrossFadeFromPoseState=function(e,t,r,n,a,i,o){var s,l=t.destPlayData,c=l.state,u=c._getDuration()*t.crossFadeTransition.duration,d=c.speed*this.speed,h=d*i;l.updateOrientation(h);var _=l.clipTime,f=l.playState;if(l.isForwards){var p=l.playedTime;s=p+h>u?u-p:h}else{var m=l.playedTime;s=m-h>u?m-u:h}var g=0===d?i:s/d;l.update(s);var v=Math.abs(l.playedTime)/u;(v>=1-c4.zeroTolerance||0===u)&&(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,s),y){this._updateCrossFadeData(t);var x=i-g;x>0&&this._updateState(e,t,r,x,o)}},iF._evaluateCrossFadeFromPoseState=function(e,t,r,n,a,i){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===cO.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()}}},iF._updateFinishedState=function(e,t,r,n,a,i,o){r.stateMachine;var s=t.srcPlayData,l=s.state,c=l.speed*this.speed*i;s.updateOrientation(c);var u=s.clipTime,d=s.isForwards,h=l.transitions,_=r.stateMachine.anyStateTransitions;_.length&&this._applyTransitionsByCondition(e,t,r,l,_,o)||h.length&&this._applyStateTransitions(e,t,r,d,s,h,u,u,c,o)?this._updateState(e,t,r,i,o):this._evaluateFinishedState(s,n,a,o)},iF._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))}},iF._updateCrossFadeData=function(e){e.destPlayData.playState===cO.Finished?e.layerState=cN.Finished:e.layerState=cN.Playing,e.switchPlayData(),e.crossFadeTransition=null},iF._preparePlayOwner=function(e,t){if(e.layerState===cN.Playing){var r=e.srcPlayData;if(r.state!==t)for(var n,a=r.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(n=a[i])||n.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},iF._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},iF._checkSubTransition=function(e,t,r,n,a,i,o,s){for(var l=n.state,c=n.currentTransitionIndex,u=a.length;c<u;c++){var d=a[c],h=d.exitTime*l._getDuration()+l._getClipActualStartTime();if(h>o)break;if(h>=i&&(n.currentTransitionIndex=Math.min(c+1,u-1),this._checkConditions(l,d))){if(this._applyTransition(e,t,r,d,s))return d;break}}return null},iF._checkBackwardsSubTransition=function(e,t,r,n,a,i,o,s){for(var l=n.state,c=n.currentTransitionIndex;c>=0;c--){var u=a[c],d=u.exitTime*l._getDuration()+l._getClipActualStartTime();if(d<o)break;if(d<=i&&(n.currentTransitionIndex=Math.max(c-1,0),this._checkConditions(l,u))){if(this._applyTransition(e,t,r,u,s))return u;break}}return null},iF._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}}},iF._preparePlay=function(e,t,r){void 0===r&&(r=0);var n=e.name;if(!e.clip)return uH.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=cN.Playing,a.srcPlayData.reset(e,i,e._getDuration()*r),!0},iF._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},iF._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},iF._prepareCrossFadeByTransition=function(e,t){var r=e.destinationState;if(!r)return!1;if(!r.clip)return uH.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 cN.Standby:case cN.Finished:n.layerState=cN.FixedCrossFading,this._clearCrossData(n),this._prepareStandbyCrossFading(n);break;case cN.Playing:n.layerState=cN.CrossFading,this._clearCrossData(n),this._prepareCrossFading(n);break;case cN.CrossFading:n.layerState=cN.FixedCrossFading,this._prepareFixedPoseCrossFading(n);break;case cN.FixedCrossFading:this._prepareFixedPoseCrossFading(n)}return n.crossFadeTransition=e,!0},iF._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)},iF._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)}}},iF._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)}}},iF._callAnimatorScriptOnEnter=function(e,t){for(var r=e._onStateEnterScripts,n=0,a=r.length;n<a;n++)r[n].onStateEnter(this,e,t)},iF._callAnimatorScriptOnUpdate=function(e,t){for(var r=e._onStateUpdateScripts,n=0,a=r.length;n<a;n++)r[n].onStateUpdate(this,e,t)},iF._callAnimatorScriptOnExit=function(e,t){for(var r=e._onStateExitScripts,n=0,a=r.length;n<a;n++)r[n].onStateExit(this,e,t)},iF._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))}},iF._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},iF._fireAnimationEventsAndCallScripts=function(e,t,r,n,a,i){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,n,i),a===cO.UnStarted&&this._callAnimatorScriptOnEnter(r,e),a!==cO.Finished&&t.playState===cO.Finished?this._callAnimatorScriptOnExit(r,e):this._callAnimatorScriptOnUpdate(r,e)},u_(iP,[{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}}]),iP);um([uy],_z.prototype,"speed",void 0),um([uv],_z.prototype,"_controllerUpdateFlag",void 0),um([uv],_z.prototype,"_updateMark",void 0),um([uv],_z.prototype,"_animatorLayersData",void 0),um([uv],_z.prototype,"_curveOwnerPool",void 0),um([uv],_z.prototype,"_animationEventHandlerPool",void 0),um([uv],_z.prototype,"_parametersValueMap",void 0),um([uv],_z.prototype,"_tempAnimatorStateInfo",void 0),um([uv],_z.prototype,"_controlledRenderers",void 0);var _U=(u_(iL=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)}}}]),iL),_G=(up(iB=function(e){var t,r,n;return e&&((t=uS.call(this,e)||this)._parameters=[],t._parametersMap={},t._layers=[],t._layersMap={},t._updateFlagManager=new uP),r=t,n&&("object"==(n&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof n)?n:ud(r)},uS),(iD=iB.prototype).addParameter=function(e,t){var r=this;if(this._parametersMap[e])return console.warn("Parameter "+e+" already exists."),null;var n=new _U;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},iD.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])},iD.getParameter=function(e){return this._parametersMap[e]||null},iD.findLayerByName=function(e){return this._layersMap[e]},iD.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iD.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iD.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iD._registerChangeFlag=function(){return this._updateFlagManager.createFlag(di)},u_(iB,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),iB),_H=((iV=(iI=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,r){},iV.onStateUpdate=function(e,t,r){},iV.onStateExit=function(e,t,r){},iV.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iI),_W=((iN=(iO=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new uP,this._hasSoloTransition=!1,this._clipStartTime=0,this._clipEndTime=1,this._transitions=[],this._onClipChanged=this._onClipChanged.bind(this)}).prototype).addTransition=function(e){ug(e,iO)?(t=new _V).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},iN.addExitTransition=function(e){void 0===e&&(e=1);var t=new _V;return t._srcState=this,t._isExit=!0,t.exitTime=e,this.addTransition(t)},iN.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1),e._srcState=null,this._updateSoloTransition()},iN.addStateMachineScript=function(e){var t=new e;t._state=this;var r=_H.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},iN.clearTransitions=function(){this._transitions.length=0},iN._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iN._removeStateMachineScript=function(e){var t=_H.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)}},iN._onClipChanged=function(){this._updateFlagManager.dispatch()},iN._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}}},iN._getClipActualStartTime=function(){return this._clipStartTime*this.clip.length},iN._getClipActualEndTime=function(){return this._clipEndTime*this.clip.length},u_(iO,[{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)}}]),iO),_j=((iz=(ik=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 _W(e),this.states.push(t),this._statesMap[e]=t),t},iz.removeState=function(e){var t=e.name,r=this.states.indexOf(e);r>-1&&this.states.splice(r,1),delete this._statesMap[t]},iz.findStateByName=function(e){return this._statesMap[e]},iz.makeUniqueStateName=function(e){for(var t=this._statesMap,r=e,n=0;t[e];)e=r+" "+n,n++;return e},iz.addEntryStateTransition=function(e){return this._addTransition(e,this._entryTransitions)},iz.removeEntryStateTransition=function(e){this._removeTransition(e,this._entryTransitions)},iz.addAnyStateTransition=function(e){return this._addTransition(e,this._anyStateTransitions)},iz.removeAnyStateTransition=function(e){this._removeTransition(e,this._anyStateTransitions)},iz._addTransition=function(e,t){var r;return ug(e,_W)?(r=new _V).destinationState=e:r=e,t.push(r),r},iz._removeTransition=function(e,t){var r=t.indexOf(e);-1!==r&&t.splice(r,1)},u_(ik,[{key:"entryTransitions",get:function(){return this._entryTransitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitions}}]),ik),_K=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override,this.stateMachine=new _j},_X=function(){},_Y=function(){},_q=((iG=(iU=function(){this._pathMasks=[],this._pathMaskMap={}}).prototype).addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var r=new _Y;return r.path=e,r.active=!0,this._pathMasks.push(r),this._pathMaskMap[e]=r,r},iG.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}},iG.getPathMask=function(e){return this._pathMaskMap[e]},iG.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)},iU.createByEntity=function(e){var t=new iU;return t.addPathMask(""),iU._addPathMaskWithChildren(t,e,""),t},iU._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),iU._addPathMaskWithChildren(e,o,s)}},u_(iU,[{key:"pathMasks",get:function(){return this._pathMasks}}]),iU),_Q=function(t){function r(n){var a;return(a=t.call(this,n,u9.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new us(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 up(r,t),r.prototype.clone=function(){var e=new r(this._engine);return this.cloneTo(e),e},u_(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}(dK);_Q._tintColorProp=uW.getByName("material_TintColor"),_Q._textureCubeProp=uW.getByName("material_CubeTexture"),_Q._rotationProp=uW.getByName("material_Rotation"),_Q._exposureProp=uW.getByName("material_Exposure"),_Q._decodeSkyRGBMMacro=uD.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iH=e.SunMode||(e.SunMode={}))[iH.None=0]="None",iH[iH.Simple=1]="Simple",iH[iH.HighQuality=2]="HighQuality";var _Z=(up(iW=function(t){var r;return(r=dK.call(this,t,u9.find("SkyProcedural"))||this).sunMode=2,r.sunSize=.04,r.sunSizeConvergence=5,r.atmosphereThickness=1,r.skyTint=new us(.5,.5,.5,1),r.groundTint=new us(.369,.349,.341,1),r.exposure=1.3,r.renderState.rasterState.cullMode=e.CullMode.Off,r.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,r},dK),iW.prototype.clone=function(){var e=new iW(this._engine);return this.cloneTo(e),e},u_(iW,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iW._sunSimpleMacro),t.enableMacro(iW._sunHighQualityMacro);break;case 1:t.disableMacro(iW._sunHighQualityMacro),t.enableMacro(iW._sunSimpleMacro);break;case 0:t.disableMacro(iW._sunHighQualityMacro),t.disableMacro(iW._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iW._sunSizeProp)},set:function(e){this.shaderData.setFloat(iW._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iW._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iW._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iW._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iW._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iW._skyTintProp)},set:function(e){this.shaderData.setColor(iW._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iW._groundTintProp)},set:function(e){this.shaderData.setColor(iW._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iW._exposureProp)},set:function(e){this.shaderData.setFloat(iW._exposureProp,Math.min(Math.max(0,e),8))}}]),iW);_Z._sunSizeProp=uW.getByName("material_SunSize"),_Z._sunSizeConvergenceProp=uW.getByName("material_SunSizeConvergence"),_Z._atmosphereThicknessProp=uW.getByName("material_AtmosphereThickness"),_Z._skyTintProp=uW.getByName("material_SkyTint"),_Z._groundTintProp=uW.getByName("material_GroundTint"),_Z._exposureProp=uW.getByName("material_Exposure"),_Z._sunHighQualityMacro=uD.getByName("MATERIAL_SUN_HIGH_QUALITY"),_Z._sunSimpleMacro=uD.getByName("MATERIAL_SUN_SIMPLE"),e.ParticleRenderMode=void 0,(ij=e.ParticleRenderMode||(e.ParticleRenderMode={}))[ij.Billboard=0]="Billboard",ij[ij.StretchBillboard=1]="StretchBillboard",ij[ij.HorizontalBillboard=2]="HorizontalBillboard",ij[ij.VerticalBillboard=3]="VerticalBillboard",ij[ij.Mesh=4]="Mesh",ij[ij.None=5]="None",e.ParticleSimulationSpace=void 0,(iK=e.ParticleSimulationSpace||(e.ParticleSimulationSpace={}))[iK.Local=0]="Local",iK[iK.World=1]="World",e.ParticleStopMode=void 0,(iX=e.ParticleStopMode||(e.ParticleStopMode={}))[iX.StopEmittingAndClear=0]="StopEmittingAndClear",iX[iX.StopEmitting=1]="StopEmitting";var _J=function(t){function r(n){var a;return(a=t.call(this,n)||this).velocityScale=0,a.lengthScale=2,a.pivot=new c8,a._generatorBounds=new c9,a._transformedBounds=new c9,a._onGeneratorParamsChanged=a._onGeneratorParamsChanged.bind(ud(a)),a.generator=new fa(ud(a)),a._currentRenderModeMacro=r._billboardModeMacro,a.shaderData.enableMacro(r._billboardModeMacro),a._supportInstancedArrays=a.engine._hardwareRenderer.canIUse(e.GLCapabilityType.instancedArrays),a._onGeneratorParamsChanged(),a}up(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,r=t._getAliveParticleCount();if(r){t._primitive.instanceCount=r;var n=this.getMaterial();if(n){(n.destroyed||n.shader.destroyed)&&(n=this.engine._particleMagentaMaterial);var a=this._engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get();o.set(this,n,t._primitive,t._subPrimitive),i.addSubRenderElement(o),e.camera._renderPipeline.pushRenderElement(e,i)}}},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|=cf.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|cf.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|cf.WorldVolume},u_(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);_J._billboardModeMacro=uD.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),_J._stretchedBillboardModeMacro=uD.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),_J._horizontalBillboardModeMacro=uD.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),_J._verticalBillboardModeMacro=uD.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),_J._renderModeMeshMacro=uD.getByName("RENDERER_MODE_MESH"),_J._pivotOffsetProperty=uW.getByName("renderer_PivotOffset"),_J._lengthScale=uW.getByName("renderer_StretchedBillboardLengthScale"),_J._speedScale=uW.getByName("renderer_StretchedBillboardSpeedScale"),_J._currentTime=uW.getByName("renderer_CurrentTime"),um([ub],_J.prototype,"generator",void 0),um([ux],_J.prototype,"pivot",void 0),um([uv],_J.prototype,"_generatorBounds",void 0),um([uv],_J.prototype,"_transformedBounds",void 0),um([uv],_J.prototype,"_onGeneratorParamsChanged",null),(iY=ck||(ck={}))[iY.TransformVolume=2]="TransformVolume",iY[iY.GeneratorVolume=4]="GeneratorVolume",e.ParticleCurveMode=void 0,(iq=e.ParticleCurveMode||(e.ParticleCurveMode={}))[iq.Constant=0]="Constant",iq[iq.TwoConstants=1]="TwoConstants",iq[iq.Curve=2]="Curve",iq[iq.TwoCurves=3]="TwoCurves",e.ParticleGradientMode=void 0,(iQ=e.ParticleGradientMode||(e.ParticleGradientMode={}))[iQ.Constant=0]="Constant",iQ[iQ.TwoConstants=1]="TwoConstants",iQ[iQ.Gradient=2]="Gradient",iQ[iQ.TwoGradients=3]="TwoGradients",(iZ=cz||(cz={}))[iZ.Burst=592910910]="Burst",iZ[iZ.StartDelay=322376503]="StartDelay",iZ[iZ.StartColor=306581307]="StartColor",iZ[iZ.StartSize=1793934638]="StartSize",iZ[iZ.StartRotation=3737431713]="StartRotation",iZ[iZ.randomizeRotationDirection=2527743459]="randomizeRotationDirection",iZ[iZ.StartLifetime=2368504881]="StartLifetime",iZ[iZ.StartSpeed=4085612399]="StartSpeed",iZ[iZ.VelocityOverLifetime=3774601268]="VelocityOverLifetime",iZ[iZ.ColorOverLifetime=326370691]="ColorOverLifetime",iZ[iZ.SizeOverLifetime=1494990940]="SizeOverLifetime",iZ[iZ.RotationOverLifetime=1089181156]="RotationOverLifetime",iZ[iZ.TextureSheetAnimation=197469413]="TextureSheetAnimation",iZ[iZ.Shape=2941263940]="Shape",iZ[iZ.GravityModifier=2759560269]="GravityModifier";var _$=((i$=(iJ=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 _0(e,t):e;n._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(r,n),this._colorTypeArrayDirty=!0},i$.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 _1(e,t):e;n._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(r,n),this._alphaTypeArrayDirty=!0},i$.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},i$.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},i$.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},i$._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]=us.gammaToLinearSpace(l.r),r[o+2]=us.gammaToLinearSpace(l.g),r[o+3]=us.gammaToLinearSpace(l.b)):(r[o+1]=l.r,r[o+2]=l.g,r[o+3]=l.b)}this._colorTypeArrayDirty=!1}return r},i$._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},i$._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)}},i$._removeKey=function(e,t){e.splice(t,1)},i$._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},i$._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},u_(iJ,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),iJ);um([ub],_$.prototype,"_colorKeys",void 0),um([ub],_$.prototype,"_alphaKeys",void 0),um([uv],_$.prototype,"_colorTypeArray",void 0),um([uv],_$.prototype,"_alphaTypeArray",void 0),um([uv],_$.prototype,"_setColorTypeArrayDirty",null),um([uv],_$.prototype,"_setAlphaTypeArrayDirty",null);var _0=(u_(i0=function(e,t){this._onValueChanged=null,this._color=new us,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)}}]),i0),_1=(u_(i1=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()}}]),i1),_2=((i2=function(t,r){this.mode=e.ParticleGradientMode.Constant,this.constantMin=new us,this.constantMax=new us,this.gradientMin=new _$,this.gradientMax=new _$,t.constructor===us?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:us.lerp(this.constantMin,this.constantMax,r,n)}},u_(i2,[{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}}]),i2);um([ub],_2.prototype,"constantMin",void 0),um([ub],_2.prototype,"constantMax",void 0),um([ub],_2.prototype,"gradientMin",void 0),um([ub],_2.prototype,"gradientMax",void 0);var _3=((i3=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},u_(i3,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),i3);um([uv],_3.prototype,"_generator",void 0);var _4=(up(i4=function(){var e;return e=_3.apply(this,arguments)||this,e.color=new _2(new _$([new _0(0,new us(1,1,1)),new _0(1,new us(1,1,1))],[new _1(0,1),new _1(1,1)])),e._colorGradientRand=new uu(0,cz.ColorOverLifetime),e._gradientKeysCount=new uo(0,0,0,0),e},_3),(i8=i4.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(i4._maxGradientColor,a.gradientMax._getColorTypeArray(i)),t.setFloatArray(i4._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),n===e.ParticleGradientMode.Gradient?r=i4._gradientMacro:(t.setFloatArray(i4._minGradientColor,a.gradientMin._getColorTypeArray(i)),t.setFloatArray(i4._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),r=i4._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(i4._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(t,this._colorMacro,r)},i8._resetRandomSeed=function(e){this._colorGradientRand.reset(e,cz.ColorOverLifetime)},i4);_4._gradientMacro=uD.getByName("RENDERER_COL_GRADIENT"),_4._randomGradientsMacro=uD.getByName("RENDERER_COL_RANDOM_GRADIENTS"),_4._minGradientColor=uW.getByName("renderer_COLMinGradientColor"),_4._minGradientAlpha=uW.getByName("renderer_COLMinGradientAlpha"),_4._maxGradientColor=uW.getByName("renderer_COLMaxGradientColor"),_4._maxGradientAlpha=uW.getByName("renderer_COLMaxGradientAlpha"),_4._gradientKeysCount=uW.getByName("renderer_COLGradientKeysMaxTime"),um([ub],_4.prototype,"color",void 0),um([uv],_4.prototype,"_colorGradientRand",void 0),um([uv],_4.prototype,"_gradientKeysCount",void 0),um([uv],_4.prototype,"_colorMacro",void 0);var _8=((i9=(i5=function(t,r){this._updateManager=new uP,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}},i9._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}},i9._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,_)}},i9._registerOnValueChanged=function(e){this._updateManager.addListener(e)},i9._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},i9._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},i9._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},i9._onCurveChange=function(e,t){var r=this._updateDispatch;null==e||e._unRegisterOnValueChanged(r),null==t||t._registerOnValueChanged(r),r()},u_(i5,[{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}}]),i5);um([uv],_8.prototype,"_updateManager",void 0),um([ub],_8.prototype,"_curveMin",void 0),um([ub],_8.prototype,"_curveMax",void 0),um([uv],_8.prototype,"_updateDispatch",void 0);var _5=(up(i6=function(){var e;return e=_3.apply(this,arguments)||this,e.rateOverTime=new _8(10),e.rateOverDistance=new _8(0),e._shapeRand=new uu(0,cz.Shape),e._frameRateTime=0,e._bursts=[],e._currentBurstIndex=0,e._burstRand=new uu(0,cz.Burst),e},_3),(i7=i6.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)},i7.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},i7.removeBurstByIndex=function(e){this._bursts.splice(e,1)},i7.clearBurst=function(){this._bursts.length=0},i7._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},i7._resetRandomSeed=function(e){this._burstRand.reset(e,cz.Burst),this._shapeRand.reset(e,cz.Shape)},i7._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},i7._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},i7._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)},i7._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)},i7._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},u_(i6,[{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}}]),i6);um([ub],_5.prototype,"rateOverTime",void 0),um([ub],_5.prototype,"rateOverDistance",void 0),um([ub],_5.prototype,"_shape",void 0),um([uv],_5.prototype,"_shapeRand",void 0),um([ub],_5.prototype,"_bursts",void 0),um([uv],_5.prototype,"_burstRand",void 0),e.ParticleScaleMode=void 0,(oe=e.ParticleScaleMode||(e.ParticleScaleMode={}))[oe.Hierarchy=0]="Hierarchy",oe[oe.Local=1]="Local",oe[oe.World=2]="World";var _9=((or=(ot=function(t){this._tempVector40=new uo,this.duration=5,this.isLoop=!0,this.startDelay=new _8(0),this.startRotation3D=!1,this.startRotationX=new _8(0),this.startRotationY=new _8(0),this.startRotationZ=new _8(0),this.flipRotation=0,this.startColor=new _2(new us(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=e.ParticleScaleMode.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new uu(0,cz.StartDelay),this._startSpeedRand=new uu(0,cz.StartSpeed),this._startLifeTimeRand=new uu(0,cz.StartLifetime),this._startColorRand=new uu(0,cz.StartColor),this._startSizeRand=new uu(0,cz.StartSize),this._startRotationRand=new uu(0,cz.StartRotation),this._gravityModifierRand=new uu(0,cz.GravityModifier),this._startSize3D=!1,this._simulationSpace=e.ParticleSimulationSpace.Local,this._generator=t,this.startLifetime=new _8(5),this.startSpeed=new _8(5),this.startSizeX=new _8(1),this.startSizeY=new _8(1),this.startSizeZ=new _8(1),this.gravityModifier=new _8(0)}).prototype)._resetRandomSeed=function(e){this._startSpeedRand.reset(e,cz.StartSpeed),this._startLifeTimeRand.reset(e,cz.StartLifetime),this._startColorRand.reset(e,cz.StartColor),this._startSizeRand.reset(e,cz.StartSize),this._startRotationRand.reset(e,cz.StartRotation)},or._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}},or._updateShaderData=function(t){var r=this._generator._renderer,n=r.entity.transform;switch(this.simulationSpace){case e.ParticleSimulationSpace.Local:t.setVector3(ot._worldPosition,n.worldPosition);var a=n.worldRotationQuaternion,i=this._tempVector40.copyFrom(a);t.setVector4(ot._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(ot._positionScale,o),t.setVector3(ot._sizeScale,o);break;case e.ParticleScaleMode.Local:var o=n.scale;t.setVector3(ot._positionScale,o),t.setVector3(ot._sizeScale,o);break;case e.ParticleScaleMode.World:t.setVector3(ot._positionScale,n.lossyWorldScale),t.setVector3(ot._sizeScale,ot._vector3One)}t.setVector3(ot._gravity,r.scene.physics.gravity),t.setInt(ot._simulationSpace,this.simulationSpace),t.setFloat(ot._startRotation3D,+this.startRotation3D),t.setInt(ot._scaleMode,this.scalingMode)},or._cloneTo=function(t){t.maxParticles=this.maxParticles,t._simulationSpace===e.ParticleSimulationSpace.World&&t._generator._generateTransformedBounds()},or._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},u_(ot,[{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(c_.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}}]),ot);_9._vector3One=new c8(1,1,1),_9._positionScale=uW.getByName("renderer_PositionScale"),_9._sizeScale=uW.getByName("renderer_SizeScale"),_9._worldPosition=uW.getByName("renderer_WorldPosition"),_9._worldRotation=uW.getByName("renderer_WorldRotation"),_9._gravity=uW.getByName("renderer_Gravity"),_9._simulationSpace=uW.getByName("renderer_SimulationSpace"),_9._startRotation3D=uW.getByName("renderer_ThreeDStartRotation"),_9._scaleMode=uW.getByName("renderer_ScalingMode"),um([ub],_9.prototype,"startDelay",void 0),um([ub],_9.prototype,"startRotationX",void 0),um([ub],_9.prototype,"startRotationY",void 0),um([ub],_9.prototype,"startRotationZ",void 0),um([ub],_9.prototype,"startColor",void 0),um([uv],_9.prototype,"_maxParticleBuffer",void 0),um([uv],_9.prototype,"_startDelayRand",void 0),um([uv],_9.prototype,"_startSpeedRand",void 0),um([uv],_9.prototype,"_startLifeTimeRand",void 0),um([uv],_9.prototype,"_startColorRand",void 0),um([uv],_9.prototype,"_startSizeRand",void 0),um([uv],_9.prototype,"_startRotationRand",void 0),um([uv],_9.prototype,"_gravityModifierRand",void 0),um([ub],_9.prototype,"_startLifetime",void 0),um([ub],_9.prototype,"_startSpeed",void 0),um([ub],_9.prototype,"_startSizeX",void 0),um([ub],_9.prototype,"_startSizeY",void 0),um([ub],_9.prototype,"_startSizeZ",void 0),um([ub],_9.prototype,"_gravityModifier",void 0),um([uv],_9.prototype,"_generator",void 0);var _6=(up(on=function(){var e;return e=_3.apply(this,arguments)||this,e.separateAxes=!1,e.rotationX=new _8(0),e.rotationY=new _8(0),e.rotationZ=new _8(45),e._rotationRand=new uu(0,cz.RotationOverLifetime),e._rotationMinConstant=new c8,e._rotationMaxConstant=new c8,e},_3),(oa=on.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(on._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(t.setFloatArray(on._maxCurveXProperty,i.curveMax._getTypeArray()),t.setFloatArray(on._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(t.setFloatArray(on._minCurveZProperty,s.curveMin._getTypeArray()),l&&(t.setFloatArray(on._minCurveXProperty,i.curveMin._getTypeArray()),t.setFloatArray(on._minCurveYProperty,o.curveMin._getTypeArray())),a=on._isRandomTwoMacro),n=on._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(c4.degreeToRadian(i.constantMax),c4.degreeToRadian(o.constantMax),c4.degreeToRadian(s.constantMax)),t.setVector3(on._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(c4.degreeToRadian(i.constantMin),c4.degreeToRadian(o.constantMin),c4.degreeToRadian(s.constantMin)),t.setVector3(on._minConstantProperty,d),a=on._isRandomTwoMacro}n=on._constantModeMacro}l&&(r=on._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)},oa._resetRandomSeed=function(e){this._rotationRand.reset(e,cz.RotationOverLifetime)},on);_6._constantModeMacro=uD.getByName("RENDERER_ROL_CONSTANT_MODE"),_6._curveModeMacro=uD.getByName("RENDERER_ROL_CURVE_MODE"),_6._isSeparateMacro=uD.getByName("RENDERER_ROL_IS_SEPARATE"),_6._isRandomTwoMacro=uD.getByName("RENDERER_ROL_IS_RANDOM_TWO"),_6._minConstantProperty=uW.getByName("renderer_ROLMinConst"),_6._minCurveXProperty=uW.getByName("renderer_ROLMinCurveX"),_6._minCurveYProperty=uW.getByName("renderer_ROLMinCurveY"),_6._minCurveZProperty=uW.getByName("renderer_ROLMinCurveZ"),_6._maxConstantProperty=uW.getByName("renderer_ROLMaxConst"),_6._maxCurveXProperty=uW.getByName("renderer_ROLMaxCurveX"),_6._maxCurveYProperty=uW.getByName("renderer_ROLMaxCurveY"),_6._maxCurveZProperty=uW.getByName("renderer_ROLMaxCurveZ"),um([ub],_6.prototype,"rotationX",void 0),um([ub],_6.prototype,"rotationY",void 0),um([ub],_6.prototype,"rotationZ",void 0),um([uv],_6.prototype,"_rotationRand",void 0),um([uv],_6.prototype,"_rotationMinConstant",void 0),um([uv],_6.prototype,"_rotationMaxConstant",void 0),um([uv],_6.prototype,"_enableSeparateMacro",void 0),um([uv],_6.prototype,"_isCurveMacro",void 0),um([uv],_6.prototype,"_isRandomTwoMacro",void 0);var _7=((oo=(oi=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];this._updateManager=new uP,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 fe(e,t):e;this._addKey(r,n),n._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},oo.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},oo.setKeys=function(e){this._keys.length=0;for(var t=0,r=e.length;t<r;t++)this.addKey(e[t]);this._typeArrayDirty=!0},oo._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},oo._registerOnValueChanged=function(e){this._updateManager.addListener(e)},oo._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},oo._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)}},u_(oi,[{key:"keys",get:function(){return this._keys}}]),oi);um([uv],_7.prototype,"_updateManager",void 0),um([ub],_7.prototype,"_keys",void 0),um([uv],_7.prototype,"_typeArray",void 0),um([uv],_7.prototype,"_updateDispatch",void 0);var fe=((ol=(os=function(e,t){this._updateManager=new uP,this._time=e,this._value=t}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},ol._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},u_(os,[{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())}}]),os);um([uv],fe.prototype,"_updateManager",void 0);var ft=(up(oc=function(e){var t;return(t=_3.call(this,e)||this)._separateAxes=!1,t.sizeX=new _8(new _7(new fe(0,0),new fe(1,1))),t.sizeY=new _8(new _7(new fe(0,0),new fe(1,1))),t.sizeZ=new _8(new _7(new fe(0,0),new fe(1,1))),t},_3),(ou=oc.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(oc._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(t.setFloatArray(oc._maxCurveYProperty,o.curveMax._getTypeArray()),t.setFloatArray(oc._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(t.setFloatArray(oc._minCurveXProperty,i.curveMin._getTypeArray()),l&&(t.setFloatArray(oc._minCurveYProperty,o.curveMin._getTypeArray()),t.setFloatArray(oc._minCurveZProperty,s.curveMin._getTypeArray())),a=oc._isRandomTwoMacro),n=oc._curveModeMacro),l&&(r=oc._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)},ou._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},u_(oc,[{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}}]),oc);ft._curveModeMacro=uD.getByName("RENDERER_SOL_CURVE_MODE"),ft._isSeparateMacro=uD.getByName("RENDERER_SOL_IS_SEPARATE"),ft._isRandomTwoMacro=uD.getByName("RENDERER_SOL_IS_RANDOM_TWO"),ft._minCurveXProperty=uW.getByName("renderer_SOLMinCurveX"),ft._minCurveYProperty=uW.getByName("renderer_SOLMinCurveY"),ft._minCurveZProperty=uW.getByName("renderer_SOLMinCurveZ"),ft._maxCurveXProperty=uW.getByName("renderer_SOLMaxCurveX"),ft._maxCurveYProperty=uW.getByName("renderer_SOLMaxCurveY"),ft._maxCurveZProperty=uW.getByName("renderer_SOLMaxCurveZ"),um([ub],ft.prototype,"_sizeX",void 0),um([ub],ft.prototype,"_sizeY",void 0),um([ub],ft.prototype,"_sizeZ",void 0),um([uv],ft.prototype,"_enableSeparateMacro",void 0),um([uv],ft.prototype,"_isCurveMacro",void 0),um([uv],ft.prototype,"_isRandomTwoMacro",void 0);var fr=(up(od=function(){var e;return e=_3.apply(this,arguments)||this,e.frameOverTime=new _8(new _7(new fe(0,0),new fe(1,1))),e.type=0,e.cycleCount=1,e._tillingInfo=new c8(1,1,1),e._frameOverTimeRand=new uu(0,cz.TextureSheetAnimation),e._tiling=new ui(1,1),e},_3),(oh=od.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(od._frameMaxCurveProperty,a.curveMax._getTypeArray()),n===e.ParticleCurveMode.Curve?r=od._frameCurveMacro:(t.setFloatArray(od._frameMinCurveProperty,a.curveMin._getTypeArray()),r=od._frameRandomCurvesMacro),t.setFloat(od._cycleCountProperty,this.cycleCount),t.setVector3(od._tillingParamsProperty,this._tillingInfo)}}this._frameCurveMacro=this._enableMacro(t,this._frameCurveMacro,r)},oh._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,cz.TextureSheetAnimation)},u_(od,[{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)}}]),od);fr._frameCurveMacro=uD.getByName("RENDERER_TSA_FRAME_CURVE"),fr._frameRandomCurvesMacro=uD.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),fr._frameMinCurveProperty=uW.getByName("renderer_TSAFrameMinCurve"),fr._frameMaxCurveProperty=uW.getByName("renderer_TSAFrameMaxCurve"),fr._cycleCountProperty=uW.getByName("renderer_TSACycles"),fr._tillingParamsProperty=uW.getByName("renderer_TSATillingParams"),um([ub],fr.prototype,"frameOverTime",void 0),um([ux],fr.prototype,"_tillingInfo",void 0),um([uv],fr.prototype,"_frameOverTimeRand",void 0),um([ub],fr.prototype,"_tiling",void 0),um([uv],fr.prototype,"_frameCurveMacro",void 0),(o_=cU||(cU={}))[o_.WholeSheet=0]="WholeSheet",o_[o_.SingleRow=1]="SingleRow";var fn=(up(of=function(t){var r;return(r=_3.call(this,t)||this)._velocityRand=new uu(0,cz.VelocityOverLifetime),r._velocityMinConstant=new c8,r._velocityMaxConstant=new c8,r._space=e.ParticleSimulationSpace.Local,r.velocityX=new _8(0),r.velocityY=new _8(0),r.velocityZ=new _8(0),r},_3),(op=of.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(of._maxGradientXProperty,n.curveMax._getTypeArray()),t.setFloatArray(of._maxGradientYProperty,a.curveMax._getTypeArray()),t.setFloatArray(of._maxGradientZProperty,i.curveMax._getTypeArray()),o?(t.setFloatArray(of._minGradientXProperty,n.curveMin._getTypeArray()),t.setFloatArray(of._minGradientYProperty,a.curveMin._getTypeArray()),t.setFloatArray(of._minGradientZProperty,i.curveMin._getTypeArray()),r=of._randomCurveMacro):r=of._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(n.constantMax,a.constantMax,i.constantMax),t.setVector3(of._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(of._minConstantProperty,l),r=of._randomConstantMacro}else r=of._constantMacro}t.setInt(of._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(t,this._velocityMacro,r)},op._resetRandomSeed=function(e){this._velocityRand.reset(e,cz.VelocityOverLifetime)},op._onCompositeCurveChange=function(e,t){var r=this._generator._renderer;null==e||e._unRegisterOnValueChanged(r._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(r._onGeneratorParamsChanged),r._onGeneratorParamsChanged()},u_(of,[{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())}}]),of);fn._constantMacro=uD.getByName("RENDERER_VOL_CONSTANT"),fn._curveMacro=uD.getByName("RENDERER_VOL_CURVE"),fn._randomConstantMacro=uD.getByName("RENDERER_VOL_RANDOM_CONSTANT"),fn._randomCurveMacro=uD.getByName("RENDERER_VOL_RANDOM_CURVE"),fn._minConstantProperty=uW.getByName("renderer_VOLMinConst"),fn._maxConstantProperty=uW.getByName("renderer_VOLMaxConst"),fn._minGradientXProperty=uW.getByName("renderer_VOLMinGradientX"),fn._minGradientYProperty=uW.getByName("renderer_VOLMinGradientY"),fn._minGradientZProperty=uW.getByName("renderer_VOLMinGradientZ"),fn._maxGradientXProperty=uW.getByName("renderer_VOLMaxGradientX"),fn._maxGradientYProperty=uW.getByName("renderer_VOLMaxGradientY"),fn._maxGradientZProperty=uW.getByName("renderer_VOLMaxGradientZ"),fn._spaceProperty=uW.getByName("renderer_VOLSpace"),um([uv],fn.prototype,"_velocityRand",void 0),um([uv],fn.prototype,"_velocityMinConstant",void 0),um([uv],fn.prototype,"_velocityMaxConstant",void 0),um([uv],fn.prototype,"_velocityMacro",void 0),um([ub],fn.prototype,"_velocityX",void 0),um([ub],fn.prototype,"_velocityY",void 0),um([ub],fn.prototype,"_velocityZ",void 0);var fa=function(){function t(r){this.useAutoRandomSeed=!0,this.emission=new _5(this),this.rotationOverLifetime=new _6(this),this.colorOverLifetime=new _4(this),this.textureSheetAnimation=new fr(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new d3(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._playStartDelay=0,this._renderer=r,new d2().start=0,this._primitive=new d4(r.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,t._particleIncreaseCount),this.main=new _9(this),this.velocityOverLifetime=new fn(this),this.sizeOverLifetime=new ft(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(_J,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())),this._playStartDelay=this.main.startDelay.evaluate(void 0,this.main._startDelayRand.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(_J,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._getNotRetiredParticleCount()>=this.main.maxParticles))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,s=t*n.simulationSpeed;if(this._playStartDelay>0){var l=this._playStartDelay-=s;if(!(l<0))return;this._playTime-=l,this._playStartDelay=0}if(this._playTime+=s,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 c=Math.min(a._frameRateTime,Math.floor(this._playTime/i)*i);this._playTime-=c,a._frameRateTime-=c}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 dj(e.VertexAttribute.Position,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,a);n.addVertexElement(new dj(e.VertexAttribute.Color,s.offset,s.format,_))}if(d){var f=this._addVertexBufferBindingsFilterDuplicate(d,a);n.addVertexElement(new dj(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=h7.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 dj(x.attribute,x.offset,x.format,g,x.instanceStepRate))}},r._resizeInstanceBuffer=function(t,r){null==(h=this._instanceVertexBufferBinding)||h.buffer.destroy();var n=h7.instanceVertexStride,a=t?this._currentParticleCount+r:this.main._maxParticleBuffer,i=n*a,o=this._renderer.engine,s=new dH(o,e.BufferBindFlag.VertexBuffer,i,e.BufferUsage.Dynamic,!1);s.isGCIgnored=!0;var l=this._primitive.vertexBufferBindings,c=new d5(s,n),u=new Float32Array(i/4),d=this._instanceVertices;if(d){var h,_,f,p=h7.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(ck.GeneratorVolume)&&(this._calculateGeneratorBounds(r,n),t._setDirtyFlagFalse(ck.GeneratorVolume)),t._isContainDirtyFlag(ck.TransformVolume)&&(this._calculateTransformedBounds(r,n,a),t._setDirtyFlagFalse(ck.TransformVolume)),this._addGravityToBounds(r,a,e)},r._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,r=this._firstActiveTransformedBoundingBox,n=this._firstFreeTransformedBoundingBox,a=r*h7.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(ck.GeneratorVolume)&&(this._calculateGeneratorBounds(t,r),e._setDirtyFlagFalse(ck.GeneratorVolume));var n=h7.boundsFloatStride,a=h7.boundsTimeOffset,i=h7.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(ck.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(ck.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*h7.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*h7.instanceVertexFloatStride;_[f]=r.x,_[f+1]=r.y,_[f+2]=r.z,_[f+h7.startLifeTimeOffset]=u.startLifetime.evaluate(void 0,u._startLifeTimeRand.random()),_[f+4]=n.x,_[f+5]=n.y,_[f+6]=n.z,_[f+h7.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;switch(u.startRotation3D?(_[f+15]=c4.degreeToRadian(u.startRotationX.evaluate(void 0,v.random())),_[f+16]=c4.degreeToRadian(u.startRotationY.evaluate(void 0,v.random())),_[f+17]=c4.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random()))):_[f+15]=c4.degreeToRadian(u.startRotationZ.evaluate(void 0,v.random())),_[f+18]=h,u.gravityModifier.mode){case e.ParticleCurveMode.Constant:_[f+19]=u.gravityModifier.constant;break;case e.ParticleCurveMode.TwoConstants:_[f+19]=u.gravityModifier.evaluate(void 0,u._gravityModifierRand.random())}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),b.enabled){var S=b.frameOverTime,A=b._tillingInfo,M=A.x,R=A.y,E=A.z,w=0;(S.mode===e.ParticleCurveMode.Constant||S.mode===e.ParticleCurveMode.TwoConstants)&&(w=Math.floor(S.evaluate(void 0,b._frameOverTimeRand.random())*E)*M);var P=Math.floor(w);_[f+h7.simulationUVOffset]=M,_[f+35]=R,_[f+36]=w-P,_[f+37]=P*R}else _[f+h7.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*h7.instanceVertexFloatStride,n=r+h7.timeOffset;if(Math.fround(this._playTime-t[n])<t[r+h7.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*h7.instanceVertexFloatStride+h7.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=h7.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=h7.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=h7.boundsFloatStride,t=h7.boundsTimeOffset,r=h7.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*h7.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;un.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))):c9.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)},u_(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}();fa._tempVector20=new ui,fa._tempVector21=new ui,fa._tempVector22=new ui,fa._tempVector30=new c8,fa._tempVector31=new c8,fa._tempMat=new un,fa._tempColor0=new us,fa._tempParticleRenderers=[],fa._particleIncreaseCount=128,fa._transformedBoundsIncreaseCount=16,um([ub],fa.prototype,"main",void 0),um([ub],fa.prototype,"emission",void 0),um([ub],fa.prototype,"velocityOverLifetime",void 0),um([ub],fa.prototype,"sizeOverLifetime",void 0),um([ub],fa.prototype,"rotationOverLifetime",void 0),um([ub],fa.prototype,"colorOverLifetime",void 0),um([ub],fa.prototype,"textureSheetAnimation",void 0),um([uv],fa.prototype,"_playTime",void 0),um([uv],fa.prototype,"_firstNewElement",void 0),um([uv],fa.prototype,"_firstActiveElement",void 0),um([uv],fa.prototype,"_firstFreeElement",void 0),um([uv],fa.prototype,"_firstRetiredElement",void 0),um([uv],fa.prototype,"_primitive",void 0),um([uv],fa.prototype,"_vertexBufferBindings",void 0),um([uv],fa.prototype,"_subPrimitive",void 0),um([uv],fa.prototype,"_renderer",void 0),um([uv],fa.prototype,"_isPlaying",void 0),um([uv],fa.prototype,"_instanceBufferResized",void 0),um([uv],fa.prototype,"_waitProcessRetiredElementCount",void 0),um([uv],fa.prototype,"_instanceVertexBufferBinding",void 0),um([uv],fa.prototype,"_instanceVertices",void 0),um([uv],fa.prototype,"_transformedBoundsArray",void 0),um([uv],fa.prototype,"_transformedBoundsCount",void 0),um([uv],fa.prototype,"_firstActiveTransformedBoundingBox",void 0),um([uv],fa.prototype,"_firstFreeTransformedBoundingBox",void 0),um([uv],fa.prototype,"_playStartDelay",void 0);var fi=(up(om=function(e){var t;return(t=dX.call(this,e,u9.find("particle-shader"))||this).shaderData.setColor(dX._baseColorProp,new us(1,1,1,1)),t.isTransparent=!0,t},dX),om.prototype.clone=function(){var e=new om(this._engine);return this.cloneTo(e),e},u_(om,[{key:"baseColor",get:function(){return this.shaderData.getColor(dX._baseColorProp)},set:function(e){var t=this.shaderData.getColor(dX._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(dX._baseTextureProp)},set:function(e){this.shaderData.setTexture(dX._baseTextureProp,e),e?this.shaderData.enableMacro(dX._baseTextureMacro):this.shaderData.disableMacro(dX._baseTextureMacro)}}]),om),fo=function(e,t){this.time=e,this.count=t};um([ub],fo.prototype,"count",void 0);var fs=((ov=(og=function(){this._updateManager=new uP,this._enabled=!0,this._randomDirectionAmount=0}).prototype)._registerOnValueChanged=function(e){this._updateManager.addListener(e)},ov._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},u_(og,[{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())}}]),og);um([uv],fs.prototype,"_updateManager",void 0);var fl=((oy=function(){}).randomPointUnitArcCircle=function(e,t,r){var n=r.random()*e;t.x=Math.cos(n),t.y=Math.sin(n)},oy.randomPointInsideUnitArcCircle=function(e,t,r){oy.randomPointUnitArcCircle(e,t,r);var n=Math.sqrt(r.random());t.x=t.x*n,t.y=t.y*n},oy.randomPointUnitCircle=function(e,t){var r=t.random()*Math.PI*2;e.x=Math.cos(r),e.y=Math.sin(r)},oy.randomPointInsideUnitCircle=function(e,t){oy.randomPointUnitCircle(e,t);var r=Math.sqrt(t.random());e.x=e.x*r,e.y=e.y*r},oy._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},oy._randomPointInsideUnitSphere=function(e,t){oy._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},oy._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},oy);e.ParticleShapeType=void 0,(ox=e.ParticleShapeType||(e.ParticleShapeType={}))[ox.Box=0]="Box",ox[ox.Circle=1]="Circle",ox[ox.Cone=2]="Cone",ox[ox.Hemisphere=3]="Hemisphere",ox[ox.Sphere=4]="Sphere";var fc=(up(ob=function(){var t;return(t=fs.call(this)||this).shapeType=e.ParticleShapeType.Box,t._size=new c8(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t},fs),(oT=ob.prototype)._generatePositionAndDirection=function(e,t,r,n){fl._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var a=ob._tempVector30;a.set(0,0,-1),fl._randomPointUnitSphere(n,e),c8.lerp(a,n,this.randomDirectionAmount,n)},oT._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)}},oT._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)},u_(ob,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),ob);fc._tempVector30=new c8,um([ub],fc.prototype,"_size",void 0),e.ParticleShapeArcMode=void 0,(oC=e.ParticleShapeArcMode||(e.ParticleShapeArcMode={}))[oC.Random=0]="Random",oC[oC.Loop=1]="Loop";var fu=(up(oS=function(){var t;return t=fs.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Circle,t._radius=1,t._arc=360,t._arcMode=e.ParticleShapeArcMode.Random,t._arcSpeed=1,t},fs),(oA=oS.prototype)._generatePositionAndDirection=function(t,r,n,a){var i=oS._tempPositionPoint;switch(this.arcMode){case e.ParticleShapeArcMode.Loop:var o=r*this.arcSpeed*(360/this.arc)%1,s=c4.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(t.random());break;case e.ParticleShapeArcMode.Random:fl.randomPointInsideUnitArcCircle(c4.degreeToRadian(this.arc),i,t)}n.set(i.x,i.y,0),n.scale(this.radius),fl._randomPointUnitSphere(a,t),c8.lerp(n,a,this.randomDirectionAmount,a)},oA._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)},oA._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},oA._getUnitArcRange=function(e,t,r,n,a){var i=c4.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))},u_(oS,[{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())}}]),oS);fu._tempPositionPoint=new ui;var fd=(up(oM=function(){var t;return t=fs.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t},fs),(oR=oM.prototype)._generatePositionAndDirection=function(e,t,r,n){var a=oM._tempVector20,i=c4.degreeToRadian(this.angle),o=Math.sin(i),s=Math.cos(i);switch(this.emitType){case 0:fl.randomPointInsideUnitCircle(a,e),r.set(a.x*this.radius,a.y*this.radius,0);var l=oM._tempVector21;fl.randomPointInsideUnitCircle(l,e),ui.lerp(a,l,this.randomDirectionAmount,l),n.set(l.x*o,l.y*o,-s);break;case 1:fl.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=oM._tempVector30;c8.scale(n,this.length*e.random(),c),r.add(c);var u=oM._tempVector31;fl._randomPointUnitSphere(u,e),c8.lerp(n,u,this.randomDirectionAmount,n)}},oR._getDirectionRange=function(e,t){var r=0;switch(this.emitType){case 0:r=c4.degreeToRadian(this._angle);break;case 1:r=Math.sin(c4.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var n=Math.sin(r);e.set(-n,-n,-1),t.set(n,n,0)},oR._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(c4.degreeToRadian(this._angle));e.set(-r-a*n,-r-a*n,-n),t.set(r+a*n,r+a*n,0)}},u_(oM,[{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())}}]),oM);fd._tempVector20=new ui,fd._tempVector21=new ui,fd._tempVector30=new c8,fd._tempVector31=new c8,e.ConeEmitType=void 0,(oE=e.ConeEmitType||(e.ConeEmitType={}))[oE.Base=0]="Base",oE[oE.Volume=1]="Volume";var fh=(up(ow=function(){var t;return t=fs.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Hemisphere,t._radius=1,t},fs),(oP=ow.prototype)._generatePositionAndDirection=function(e,t,r,n){fl._randomPointInsideUnitSphere(r,e),r.scale(this.radius);var a=r.z;a>0&&(r.z=-a),fl._randomPointUnitSphere(n,e),c8.lerp(r,n,this.randomDirectionAmount,n)},oP._getDirectionRange=function(e,t){var r=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,r)},oP._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,0)},u_(ow,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),ow),f_=(up(oF=function(){var t;return t=fs.apply(this,arguments)||this,t.shapeType=e.ParticleShapeType.Sphere,t._radius=1,t},fs),(oL=oF.prototype)._generatePositionAndDirection=function(e,t,r,n){fl._randomPointInsideUnitSphere(r,e),r.scale(this.radius),fl._randomPointUnitSphere(n,e),c8.lerp(r,n,this.randomDirectionAmount,n)},oL._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},oL._getPositionRange=function(e,t){var r=this._radius;e.set(-r,-r,-r),t.set(r,r,r)},u_(oF,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),oF);u9.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 ff=(up(oB=function(t){var r,n=(r=dK.call(this,t,u9.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},dK),oB),fp=new c8,fm=(up(oD=function(e,t){(r=d6.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 c8),r._pointStates.push(r._lifetime),r._strapPoints.push(new c8),r._strapPoints.push(new c8);r._curPointNum=0;var a=t.material||new ff(r.engine);return r.setMaterial(a),r.setTexture(t.texture),r._initGeometry(),r},d6),(oI=oD.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];c8.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++)},oI.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},oI._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),d6.prototype._render.call(this,e)},oI._initGeometry=function(){var t=new d9(this._entity.engine),r=2*this._maxPointNum,n=20*r,a=new Float32Array(n),i=[new dj("POSITION",0,e.VertexElementFormat.Vector3,0),new dj("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new dH(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},oI._updateStrapVertices=function(e,t){var r=e.viewMatrix.elements,n=new c8(r[0],r[4],r[8]),a=new c8(r[1],r[5],r[9]),i=new c8(r[2],r[6],r[10]),o=this._stroke;a.scale(o);var s=new c8,l=new c8,c=new ur;c8.transformByQuat(n,c,n),c8.transformByQuat(a,c,a);var u=new c8,d=new c8,h=new c8;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?c8.subtract(p,t[f-1],h):c8.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(c8.dot(n,h));c8.cross(n,h,d),0>=c8.dot(d,i)&&(m=2*Math.PI-m),ur.rotationAxisAngle(i,m,c),c8.transformByQuat(a,c,u),c8.add(p,u,s),c8.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}},oI._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}}},oI._projectOnVector=function(e,t,r){var n=t.clone();c8.normalize(n,n);var a=c8.dot(e,n);r.x=n.x*a,r.y=n.y*a,r.z=n.z*a},oI._projectOnPlane=function(e,t,r){this._projectOnVector(e,t,fp),c8.subtract(e,fp,r)},oD),fg=(up(oV=function(){var t;return t=_b.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},_b),(oO=oV.prototype).onTextureChange=function(e){},oO.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 df(this.engine,this.width,this.height,this._isCube?new dg(this.engine,this.width):new dp(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new df(this.engine,this.width,this.height,this._isCube?new dg(this.engine,this.width):new dp(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},oO.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},oO._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},u_(oV,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),oV),fv=new c8,fy=new c8,fx=new c8,fb=(up(oN=function(){var e;return e=fg.apply(this,arguments)||this,e.position=new c8(0,0,0),e._isCube=!0,e.oriViewMatrix=new un,e},fg),(ok=oN.prototype).onBeginRender=function(t){if(this.enabled){fg.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),fg.prototype._reset.call(this)}},ok._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ok._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ok._setCamera=function(e,t){switch(e){case 0:fy.set(0,-1,0),fx.set(1,0,0);break;case 1:fy.set(0,-1,0),fx.set(-1,0,0);break;case 2:fy.set(0,0,1),fx.set(0,1,0);break;case 3:fy.set(0,0,-1),fx.set(0,-1,0);break;case 4:fy.set(0,-1,0),fx.set(0,0,1);break;case 5:fy.set(0,-1,0),fx.set(0,0,-1)}c8.add(this.position,fx,fv),un.lookAt(this.position,fv,fy,t.viewMatrix),t.fieldOfView=90},oN),fT=Object.freeze({__proto__:null,AmbientLight:_d,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:_L,AnimationClipCurveBinding:_P,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:_B,AnimationEvent:_F,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:_z,AnimatorCondition:_I,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:_G,AnimatorControllerLayer:_K,AnimatorControllerParameter:_U,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorLayerMask:_q,AnimatorState:_W,AnimatorStateMachine:_j,AnimatorStateTransition:_V,AssetPromise:hE,get AssetType(){return e.AssetType},Background:_c,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:dX,BasicRenderPipeline:dF,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:d0,BlendShapeFrame:d$,BlendState:u2,BlinnPhongMaterial:dY,get BloomDownScaleMode(){return e.BloomDownScaleMode},BloomEffect:_g,BoolUpdateFlag:di,BoxColliderShape:h2,BoxShape:fc,Buffer:dH,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:d9,get BufferUsage(){return e.BufferUsage},BufferUtil:dW,Burst:fo,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},get CameraType(){return e.CameraType},Canvas:_s,CapsuleColliderShape:h8,CharacterController:hW,CircleShape:fu,ClearableObjectPool:_a,CloneManager:uT,get Collider(){return e.Collider},ColliderShape:h1,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},ColorOverLifetimeModule:_4,get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:dr,get ConeEmitType(){return e.ConeEmitType},ConeShape:fd,ContentRestorer:dI,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:fb,get CullMode(){return e.CullMode},CurveKey:fe,get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:u3,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:__,DisorderedArray:dd,get Downsampling(){return e.Downsampling},DynamicCollider:hj,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},EmissionModule:_5,Engine:_o,EngineObject:uC,Entity:hp,EventDispatcher:uO,FixedJoint:hQ,get FogMode(){return e.FogMode},Font:dk,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},GradientAlphaKey:_1,GradientColorKey:_0,HemisphereShape:fh,HingeJoint:hZ,HitResult:hK,IndexBufferBinding:d1,get IndexFormat(){return e.IndexFormat},InputManager:h6,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:h$,JointMotor:h0,Keyframe:_X,get Keys(){return e.Keys},get Layer(){return e.Layer},LayerPathMask:_Y,Light:_h,Loader:_T,Logger:uH,get MSAASamples(){return e.MSAASamples},MainModule:_9,Material:dK,Mesh:d8,MeshRenderer:d6,get MeshTopology(){return e.MeshTopology},ModelMesh:he,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:dq,PBRMaterial:dQ,PBRSpecularMaterial:dZ,ParticleCompositeCurve:_8,ParticleCompositeGradient:_2,ParticleCurve:_7,get ParticleCurveMode(){return e.ParticleCurveMode},ParticleGenerator:fa,ParticleGradient:_$,get ParticleGradientMode(){return e.ParticleGradientMode},ParticleMaterial:fi,get ParticleRenderMode(){return e.ParticleRenderMode},ParticleRenderer:_J,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:hX,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:hH,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:h4,get Platform(){return e.Platform},PointLight:_f,Pointer:hN,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},Primitive:d4,PrimitiveMesh:hh,Probe:fg,RasterState:u4,ReferResource:uS,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderQueue:dS,get RenderQueueType(){return e.RenderQueueType},RenderState:u5,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:df,RenderTargetBlendState:u1,get Renderer(){return e.Renderer},get ReplacementFailureStrategy(){return e.ReplacementFailureStrategy},ResourceManager:hB,ReturnableObjectPool:hx,RotationOverLifetimeModule:_6,SafeLoopArray:hM,Scene:_x,SceneManager:hR,Script:_b,get SetDataOptions(){return e.SetDataOptions},Shader:u9,ShaderData:de,ShaderFactory:uX,ShaderLib:uK,ShaderMacro:uD,ShaderMacroCollection:uI,ShaderPass:u$,get ShaderPlatformTarget(){return e.ShaderPlatformTarget},ShaderProperty:uW,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:uY,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},SizeOverLifetimeModule:ft,Skin:hm,SkinnedMeshRenderer:hg,Sky:_l,SkyBoxMaterial:_Q,SkyProceduralMaterial:_Z,SphereColliderShape:h3,SphereShape:f_,SpotLight:_p,SpringJoint:hJ,Sprite:uF,SpriteAtlas:uA,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:dD,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:d_,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:_H,StaticCollider:hY,get StencilOperation(){return e.StencilOperation},StencilState:u8,SubMesh:d3,SubPrimitive:d2,SubShader:u0,get SunMode(){return e.SunMode},SystemInfo:hU,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:dU,TextUtils:dO,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:u7,Texture2D:dp,Texture2DArray:dm,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:dg,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},TextureSheetAnimationModule:fr,get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:uj,TonemappingEffect:_v,get TonemappingMode(){return e.TonemappingMode},TrailMaterial:ff,TrailRenderer:fm,Transform:ds,UnlitMaterial:dJ,Utils:uM,VelocityOverLifetimeModule:fn,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:d5,VertexElement:dj,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},XRManager:_i,_PostProcessManager:_y,assignmentClone:uy,deepClone:ub,dependentComponents:da,ignoreClone:uv,request:hF,resourceLoader:hD,shallowClone:ux});function fC(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 fS(e,t,r){return t&&fC(e.prototype,t),r&&fC(e,r),e}function fA(e,t){return(fA=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fM(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&&fA(e,t)}function fR(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}e.GLCompressedTextureInternalFormat=void 0,(oz=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[oz.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",oz[oz.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",oz[oz.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",oz[oz.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",oz[oz.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",oz[oz.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",oz[oz.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",oz[oz.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",oz[oz.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",oz[oz.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",oz[oz.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",oz[oz.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",oz[oz.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",oz[oz.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",oz[oz.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",oz[oz.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",oz[oz.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",oz[oz.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",oz[oz.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",oz[oz.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",oz[oz.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",oz[oz.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",oz[oz.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",oz[oz.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",oz[oz.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",oz[oz.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",oz[oz.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",oz[oz.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",oz[oz.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",oz[oz.R11_EAC=37488]="R11_EAC",oz[oz.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",oz[oz.RG11_EAC=37490]="RG11_EAC",oz[oz.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",oz[oz.RGB8_ETC2=37492]="RGB8_ETC2",oz[oz.SRGB8_ETC2=37493]="SRGB8_ETC2",oz[oz.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",oz[oz.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",oz[oz.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",oz[oz.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",oz[oz.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",oz[oz.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",oz[oz.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",oz[oz.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",oz[oz.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",oz[oz.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",oz[oz.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",oz[oz.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",oz[oz.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",oz[oz.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",oz[oz.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",oz[oz.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var fE=(fM(oU=function(e){(t=_s.call(this)||this)._scale=new ui;var t,r=e.width,n=e.height;return t._webCanvas=e,t.width=r,t.height=n,t},_s),(oG=oU.prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!fR(t,OffscreenCanvas)){var r=t.clientWidth*e,n=t.clientHeight*e;this.width=r,this.height=n}},oG.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},oG._onWidthChanged=function(e){this._webCanvas.width=e},oG._onHeightChange=function(e){this._webCanvas.height=e},fS(oU,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&fR(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&&fR(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),oU),fw=(fM(oH=function(){return _o.apply(this,arguments)},_o),oH.create=function(e){var t=e.canvas,r=new fE("string"==typeof t?document.getElementById(t):t),n=new fU(e.graphicDeviceOptions),a=new oH(r,n,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new _x(a,"DefaultScene")),a})},fS(oH,[{key:"canvas",get:function(){return this._canvas}}]),oH);function fP(){return(fP=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 fF=((oj=(oW=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)},oj.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)},oj.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."},oj.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},oj._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}},oW),fL=((oX=(oK=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},oX.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)},oX._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))},oX._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}},oX._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,fP({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"})},fS(oK,[{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}}]),oK),fB=((oY=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]},oY),fD=((oQ=(oq=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 uH.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()},oQ.destroy=function(){this._isSupportVAO&&this._clearVAO()},oQ._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 uH.warn("vertex attribute not found: "+l)}}n.bindBuffer(n.ARRAY_BUFFER,null)},oQ._disableAttrib=function(){for(var e=this._gl,t=0,r=this._attribLocArray.length;t<r;t++)e.disableVertexAttribArray(this._attribLocArray[t])},oQ._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)},oQ._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},oq),fI=((oZ=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]},oZ),fV=((o$=(oJ=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},o$.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},o$.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},o$._bind=function(){this._rhi.bindTexture(this)},o$._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)}},o$._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,uH.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)},o$._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||oJ._isPowerOf2(s)&&oJ._isPowerOf2(l)||(uH.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)}},o$._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},oJ._isPowerOf2=function(e){return(e&e-1)==0},oJ._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)}},oJ._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)}},oJ._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},oJ._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},oJ._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},fS(oJ,[{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)}}}]),oJ),fO=((o1=(o0=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=fR(a,u7),l=0,c=n.length;l<c;l++){var u=n[l]._format;if(!fV._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!fV._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 fR(e,dg)}))throw Error("MRT+Cube+[,MSAA] is not supported");var d=t.capability.maxAntiAliasing;r.antiAliasing>d&&(uH.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=fR(o,dg);(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=fR(l,dg);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=fV._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)},o1.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)}},o1.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},o1._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,fR(c,dg)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==n){if(fR(n,u7)&&!fR(n,dg)){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=fV._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)},o1._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=fR(a,u7)?a._platformTexture._formatDetail:fV._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)},o1._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.")},o0),fN=(fM(o2=function(t,r){(n=fV.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(!fV._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||fV._isPowerOf2(o)&&fV._isPowerOf2(s)||(uH.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=fV._getFormatDetail(a,n._gl,l),n._formatDetail.isCompressed&&!l||n._init(!1),n},fV),(o3=o2.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)},o3.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)},o3.getPixelBuffer=function(e,t,r,n,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fV.prototype._getPixelBuffer.call(this,null,e,t,r,n,a,i)},o2),fk=(fM(o4=function(t,r){n=fV.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(!fV._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return n._bind(),n._formatDetail=fV._getFormatDetail(a,n._gl,!0),n._gl.texStorage3D(n._target,l,n._formatDetail.internalFormat,i,o,s),n},fV),(o8=o4.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)},o8.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)},o8.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)},o4),fz=(fM(o5=function(t,r){(n=fV.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(!fV._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||fV._isPowerOf2(o)||(uH.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=fV._getFormatDetail(a,n._gl,s),n._formatDetail.isCompressed&&!s||n._init(!0),n},fV),(o9=o5.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)},o9.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)},o9.getPixelBuffer=function(e,t,r,n,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");fV.prototype._getPixelBuffer.call(this,e,t,r,n,a,i,o)},o5);e.WebGLMode=void 0,(o6=e.WebGLMode||(e.WebGLMode={}))[o6.Auto=0]="Auto",o6[o6.WebGL2=1]="WebGL2",o6[o6.WebGL1=2]="WebGL1";var fU=((se=(o7=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 uo(null,null,null,null),this._lastScissor=new uo(null,null,null,null),this._lastClearColor=new us(null,null,null,null),this._scissorEnable=!1;var r=fP({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(hU.platform===e.Platform.IPhone||hU.platform===e.Platform.IPad){var n=hU.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&&fR(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&&fR(i,OffscreenCanvas)||(n=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!n)throw Error("Get GL Context FAILED.");this._gl=n,this._initGLState(n)},se.createPlatformPrimitive=function(e){return new fD(this,e)},se.createPlatformTexture2D=function(e){return new fN(this,e)},se.createPlatformTexture2DArray=function(e){return new fk(this,e)},se.createPlatformTextureCube=function(e){return new fz(this,e)},se.createPlatformRenderTarget=function(e){return new fO(this,e)},se.createPlatformBuffer=function(t,r,n,a){return void 0===n&&(n=e.BufferUsage.Static),new fF(this,t,r,n,a)},se.requireExtension=function(e){return this._extensions.requireExtension(e)},se.canIUse=function(e){return this.capability.canIUse(e)},se.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},se.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))},se.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)}},se.colorMask=function(e,t,r,n){this._gl.colorMask(e,t,r,n)},se.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)},se.drawPrimitive=function(e,t,r){e?e.draw(r,t):uH.error("draw primitive failed.")},se.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},se.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},se.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)},se.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},se.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)},se.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},se.flush=function(){this._gl.flush()},se.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},se.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},se.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)},se._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new fI(e),this._extensions=new fB(this),this._capability=new fL(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},se.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},se._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},se._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},se._onWebGLContextRestored=function(e){this._onDeviceRestored()},fS(o7,[{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}}]),o7);function fG(){return(fG=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 fH(e,t){return(fH=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function fW(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&&fH(e,t)}function fj(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 fK(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 fX(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 fY(e,t,r){return t&&fX(e.prototype,t),r&&fX(e,r),e}"function"==typeof SuppressedError&&SuppressedError;var fq=((sr=(st=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},sr.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},sr.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},sr.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},sr.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},sr.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},sr.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},sr.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},sr.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},sr.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},sr.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,uM.decodeText(t)},sr.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},sr.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},sr.skip=function(e){return this._position+=e,this},sr.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)},fY(st,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),st),fQ={};function fZ(e){return function(t){fQ[e]=t}}var fJ=((sn=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=uM.decodeText(s),c=uM.decodeText(i),u=new sn;return u.totalLength=r,u.name=l,u.type=c,u.version=n,u.headerLength=s.byteLength+i.byteLength+9,u},fY(sn,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),sn);function f$(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new uo(e[4*n],e[4*n+1],e[4*n+2],e[4*n+3]);return r}function f0(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new c8(e[3*n],e[3*n+1],e[3*n+2]);return r}function f1(e,t){for(var r=Array(t),n=0;n<t;n++)r[n]=new ui(e[2*n],e[2*n+1]);return r}function f2(e,t,r){return(f2=!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&&fH(a,r.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((sa=function(){}).decode=function(e,t){return new Promise(function(r){var n=new he(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=f0(s,l);if(n.setPositions(c),a.normals){var u=f0(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(f1(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);n.setUVs(f1(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);n.setUVs(f1(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);n.setUVs(f1(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);n.setUVs(f1(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);n.setUVs(f1(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);n.setUVs(f1(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);n.setUVs(f1(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 us(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(f$(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);n.setBoneIndices(f$(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new d0(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=f0(r,n);e.deltaNormals&&f0(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),n),e.deltaTangents&&f$(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)})},sa),e.MeshDecoder=fj([fZ("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((si=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 dp(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)}})},si),e.Texture2DDecoder=fj([fZ("Texture2D")],e.Texture2DDecoder),e.ParserType=void 0,(so=e.ParserType||(e.ParserType={}))[so.Prefab=0]="Prefab",so[so.Scene=1]="Scene";var f3=((ss=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},ss),f4=((sc=(sl=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})},sc.parseClassObject=function(e){var t,r=this,n=_T.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return r.parseBasicType(e)})).then(function(e){return f2(n,[].concat(e))}).then(function(t){return r.parsePropsAndMethods(t,e)})},sc.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=sl.customParseComponentHandles[e.constructor.name];return r?r(e,t):e})},sc.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))})},sc.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(sl._isClass(t))return this.parseClassObject(t);if(sl._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(sl._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)},sc._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 hp(a,t.name))},sl.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},sl._isClass=function(e){return void 0!=e.class},sl._isAssetRef=function(e){return void 0!=e.refId},sl._isEntityRef=function(e){return void 0!=e.entityId},sl);function f8(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):t(e,r)}function f5(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 f9(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 f5(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 f5(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.")}f4.customParseComponentHandles=new Map,e.InterpolableValueType=void 0,(su=e.InterpolableValueType||(e.InterpolableValueType={}))[su.Float=0]="Float",su[su.FloatArray=1]="FloatArray",su[su.Vector2=2]="Vector2",su[su.Vector3=3]="Vector3",su[su.Vector4=4]="Vector4",su[su.Quaternion=5]="Quaternion",su[su.Color=6]="Color",su[su.Array=7]="Array",su[su.Boolean=8]="Boolean",su[su.Rect=9]="Rect",su[su.ReferResource=10]="ReferResource",e.AnimationClipDecoder=((sd=function(){}).decode=function(t,r){return new Promise(function(t){for(var n=r.nextStr(),a=new _L(n),i=r.nextUint16(),o=0;o<i;++o){var s=new _F;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=_T.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 _X;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 _X;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 _X;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 _X;R.time=r.nextFloat32(),R.value=new ui(r.nextFloat32(),r.nextFloat32()),R.inTangent=new ui(r.nextFloat32(),r.nextFloat32()),R.outTangent=new ui(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 _X;w.time=r.nextFloat32(),w.value=new c8(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.inTangent=new c8(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),w.outTangent=new c8(r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),p.addKey(w)}break;case"AnimationVector4Curve":(p=new e.AnimationVector4Curve).interpolation=m;var P=new _X;P.time=r.nextFloat32(),P.value=new uo(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.inTangent=new uo(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),P.outTangent=new uo(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 _X;L.time=r.nextFloat32(),L.value=new us(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.inTangent=new uo(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),L.outTangent=new uo(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 _X;D.time=r.nextFloat32(),D.value=new ur(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.inTangent=new uo(r.nextFloat32(),r.nextFloat32(),r.nextFloat32(),r.nextFloat32()),D.outTangent=new uo(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 V=new _X;V.time=r.nextFloat32();var O=r.nextStr();O?V.value=JSON.parse(O):V.value=null,p.addKey(V)}break;case"AnimationBoolCurve":(p=new e.AnimationBoolCurve).interpolation=m;for(var N=0;N<g;++N){var k=new _X;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 _X;U.time=r.nextFloat32(),U.value=r.nextStr(),p.addKey(U)}}a.addCurveBinding(u,h,_,f,p)}t(a)})},sd),e.AnimationClipDecoder=fj([fZ("AnimationClip")],e.AnimationClipDecoder),e.MaterialLoaderType=void 0,(sh=e.MaterialLoaderType||(e.MaterialLoaderType={})).Vector2="Vector2",sh.Vector3="Vector3",sh.Vector4="Vector4",sh.Color="Color",sh.Float="Float",sh.Texture="Texture",sh.Boolean="Boolean",sh.Integer="Integer",e.SpecularMode=void 0,(s_=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",s_.Custom="Custom";var f6=(fW(sf=function(e,t){var r;return(r=uS.call(this,e)||this).url=t,r._dependenceAssets=new Set,r},uS),(sp=sf.prototype).instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},sp._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},sp._onDestroy=function(){var e=this;uS.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(t){t._disassociationSuperResource(e)})},sf),f7=((sg=(sm=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 f4(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)},sg._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})},sg._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(_T.getClass(u));r.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);n.push(h)}return Promise.all(n)},sg._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)},sg._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)},sg._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)},sg._organizeEntities=function(){for(var e,t=this.context,r=t.rootIds,n=t.strippedIds,a=r.concat(n),i=f9(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<r.length;s++)this._handleRootEntity(r[s])},sg._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)})},sg._parseEntity=function(e,t){var r=new hp(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(r)},sg._parsePrefab=function(t,r){var n=this,a=t.assetRefId;return r.resourceManager.getResourceByRef({refId:a}).then(function(a){var i=f8(a,f6)?a.instantiate():a.instantiateSceneRoot(),o=new f3(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})},sg._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)})},sg._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)}},sg._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},sg._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=_T.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)}},sm),pe=(fW(sv=function(e,t,r){var n;return(n=f7.call(this,e,t)||this).scene=r,n},f7),(sy=sv.prototype)._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},sy._clearAndResolve=function(){return this.context.clear(),this.scene},sv.parse=function(t,r){var n=new _x(t),a=new f3(t,e.ParserType.Scene,n),i=new sv(r,a,n);return i.start(),i.promise.then(function(){return n})},sv);function pt(e,t){var r=fJ.decode(e),n=new fq(new Uint8Array(e),r.headerLength,r.dataLength);return fQ[r.type].decode(t,n).then(function(e){return e.name=r.name,e})}e.EditorTextureLoader=(fW(sx=function(){return _T.apply(this,arguments)},_T),sx.prototype.load=function(e,t){return new hE(function(r,n){t._request(e.url,fG({},e,{type:"arraybuffer"})).then(function(e){pt(e,t.engine).then(function(e){r(e)})}).catch(n)})},sx),e.EditorTextureLoader=fj([hD("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var pr=(fW(sb=function(){return _T.apply(this,arguments)},_T),(sT=sb.prototype).load=function(e,t){var r=this;return new hE(function(n,a){t._request(e.url,fG({},e,{type:"arraybuffer"})).then(function(e){return pt(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)})},sT._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)},sb);pr=fj([hD(e.AssetType.AnimationClip,["ani"])],pr);var pn=(fW(sC=function(){return _T.apply(this,arguments)},_T),(sS=sC.prototype).load=function(e,t){var r=this;return new hE(function(n,a){t._request(e.url,fG({},e,{type:"json"})).then(function(e){var a=new _G(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 _K(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(_T.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)})},sS._createTransition=function(e,t){var r=new _V;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},sC);pn=fj([hD(e.AssetType.AnimatorController,["json"],!1)],pn);var pa=(fW(sA=function(){return _T.apply(this,arguments)},_T),sA.prototype.load=function(e,t){var r=e.url;return/^data:(.+?);base64,/.test(r)?new hE(function(e){var t=r.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(t),function(e){return e.charCodeAt(0)}).buffer)}):t._request(r,fG({},e,{type:"arraybuffer"}))},sA);pa=fj([hD(e.AssetType.Buffer,["bin","r3bin"],!1)],pa);var pi=(fW(sM=function(){return _T.apply(this,arguments)},_T),sM.prototype.load=function(t,r){return new hE(function(n,a){r._request(t.url,fG({},t,{type:"arraybuffer"})).then(function(t){var a=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=r.engine,s=new dg(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 _d(o),m=new uc;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,m.copyFromArray(a),p.diffuseSphericalHarmonics=m,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,n(p)}).catch(function(e){a(e)})})},sM);function po(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 ps(e){return function(){var t=this,r=arguments;return new Promise(function(n,a){var i=e.apply(t,r);function o(e){po(i,n,a,o,s,"next",e)}function s(e){po(i,n,a,o,s,"throw",e)}o(void 0)})}}pi=fj([hD(e.AssetType.Env,["env"])],pi);var pl=(fW(sR=function(){return _T.apply(this,arguments)},_T),(sE=sR.prototype).load=function(e,t){var r=this;return new hE(function(n,a){t._request(e.url,fG({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?r._registerFont(i,o).then(function(){n(new dk(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):n(new dk(t.engine,i))}).catch(function(e){a(e)})})},sE._registerFont=function(e,t){return ps(function(){var r;return fK(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]}})})()},sR);pl=fj([hD(e.AssetType.Font,["font"],!1)],pl);var pc=(fW(sw=function(e,t){var r;return(r=uS.call(this,e)||this).url=t,r},uS),(sP=sw.prototype).instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},sP._onDestroy=function(){uS.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])},sP._disassociationSuperResource=function(e){for(var t=0,r=e.length;t<r;t++)e[t]._disassociationSuperResource(this)},fY(sw,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),sw);(sF=cG||(cG={}))[sF.BYTE=5120]="BYTE",sF[sF.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",sF[sF.SHORT=5122]="SHORT",sF[sF.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",sF[sF.UNSIGNED_INT=5125]="UNSIGNED_INT",sF[sF.FLOAT=5126]="FLOAT",e.AccessorType=void 0,(sL=e.AccessorType||(e.AccessorType={})).SCALAR="SCALAR",sL.VEC2="VEC2",sL.VEC3="VEC3",sL.VEC4="VEC4",sL.MAT2="MAT2",sL.MAT3="MAT3",sL.MAT4="MAT4",(sB=cH||(cH={})).TRANSLATION="translation",sB.ROTATION="rotation",sB.SCALE="scale",sB.WEIGHTS="weights",(sD=cW||(cW={})).Linear="LINEAR",sD.Step="STEP",sD.CubicSpine="CUBICSPLINE",(sI=cj||(cj={})).PERSPECTIVE="perspective",sI.ORTHOGRAPHIC="orthographic",(sV=cK||(cK={})).JPEG="image/jpeg",sV.PNG="image/png",(sO=cX||(cX={})).OPAQUE="OPAQUE",sO.MASK="MASK",sO.BLEND="BLEND",(sN=cY||(cY={}))[sN.NEAREST=9728]="NEAREST",sN[sN.LINEAR=9729]="LINEAR",(sk=cq||(cq={}))[sk.NEAREST=9728]="NEAREST",sk[sk.LINEAR=9729]="LINEAR",sk[sk.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",sk[sk.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",sk[sk.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",sk[sk.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(sz=cQ||(cQ={}))[sz.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",sz[sz.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",sz[sz.REPEAT=10497]="REPEAT";var pu=((sG=(sU=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 pA(e)}).prototype).get=function(e,t){var r=this,n=sU._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=ph[e],l=!!p_[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},sG.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(_z).animatorController=r),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},sG._addTaskCompletePromise=function(e){var t=this,r=this._progress.taskComplete;r.total+=1,e.then(function(){t._setTaskCompleteProgress(++r.loaded,r.total)})},sG._handleSubAsset=function(e,t,r){var n,a=this,i=p_[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)})}},sU.addParser=function(e,t){this._parsers[e]=t},sU);pu._parsers={};var pd=function(e,t,r){this.data=e,this.interleaved=t,this.stride=r,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(sH=e.GLTFParserType||(e.GLTFParserType={}))[sH.Schema=0]="Schema",sH[sH.Validator=1]="Validator",sH[sH.Scene=2]="Scene",sH[sH.Buffer=3]="Buffer",sH[sH.BufferView=4]="BufferView",sH[sH.Texture=5]="Texture",sH[sH.Material=6]="Material",sH[sH.Mesh=7]="Mesh",sH[sH.Entity=8]="Entity",sH[sH.Skin=9]="Skin",sH[sH.Animation=10]="Animation",sH[sH.AnimatorController=11]="AnimatorController";var ph=((cZ={})[2]="scenes",cZ[3]="buffers",cZ[5]="textures",cZ[6]="materials",cZ[7]="meshes",cZ[8]="nodes",cZ[9]="skins",cZ[10]="animations",cZ[4]="bufferViews",cZ),p_=((cJ={})[2]="_sceneRoots",cJ[5]="textures",cJ[6]="materials",cJ[7]="meshes",cJ[8]="entities",cJ[9]="skins",cJ[10]="animations",cJ[11]="animatorController",cJ);function pf(e){return function(t){var r=new t;pu.addParser(e,r)}}var pp=((sW=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,r=Array(t/2),n=0;n<t;n+=2)r[n/2]=new ui(e[n],e[n+1]);return r},sW.floatBufferToVector3Array=function(e){for(var t=e.length,r=Array(t/3),n=0;n<t;n+=3)r[n/3]=new c8(e[n],e[n+1],e[n+2]);return r},sW.floatBufferToVector4Array=function(e){for(var t=e.length,r=Array(t/4),n=0;n<t;n+=4)r[n/4]=new uo(e[n],e[n+1],e[n+2],e[n+3]);return r},sW.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 us(e[a],e[a+1],e[a+2],1);else for(var i=0;i<r;i+=4)n[i/4]=new us(e[i],e[i+1],e[i+2],e[i+3]);return n},sW.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}},sW.getComponentType=function(e){switch(e){case cG.BYTE:return Int8Array;case cG.UNSIGNED_BYTE:return Uint8Array;case cG.SHORT:return Int16Array;case cG.UNSIGNED_SHORT:return Uint16Array;case cG.UNSIGNED_INT:return Uint32Array;case cG.FLOAT:return Float32Array}},sW.getNormalizedComponentScale=function(e){switch(e){case cG.BYTE:return 1/127;case cG.UNSIGNED_BYTE:return 1/255;case cG.SHORT:return 1/32767;case cG.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},sW.getAccessorBuffer=function(t,r,n){var a,i=n.componentType,o=sW.getComponentType(i),s=sW.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 pd(C,!0,g),_.restoreInfo=new pP(new pF(f,o,b,T))}}else{var S=p+m,A=u*s,M=new o(e.buffer,S,A);(_=new pd(M,!1,c)).restoreInfo=new pP(new pF(f,o,S,A))}return _})}else{var _=u*s,f=new o(_),p=new pd(f,!1,c);p.restoreInfo=new pP(new pF(void 0,o,void 0,_)),a=Promise.resolve(p)}return n.sparse?a.then(function(e){return sW.processingSparseData(t,n,e).then(function(){return e})}):a},sW.bufferToVector3Array=function(e,t,r,n,a){for(var i=t/e.BYTES_PER_ELEMENT,o=e.length/r,s=Array(r),l=n?sW.getNormalizedComponentScale(a):1,c=0;c<r;c++){var u=i+c*o;s[c]=new c8(e[u]*l,e[u+1]*l,e[u+2]*l)}return s},sW.getBufferViewData=function(e,t){var r=e.byteOffset,n=void 0===r?0:r;return t[e.buffer].slice(n,n+e.byteLength)},sW.processingSparseData=function(t,r,n){var a=n.restoreInfo,i=t.glTF.bufferViews,o=sW.getAccessorTypeSize(r.type),s=sW.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=sW.getComponentType(d.componentType),T=v/b.BYTES_PER_ELEMENT,C=new b(p.buffer,g,T);a.sparseIndices=new pF(_.buffer,b,g,T);var S=x/s.BYTES_PER_ELEMENT,A=new s(m.buffer,y,S);a.sparseValues=new pF(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})},sW.getIndexFormat=function(t){switch(t){case cG.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case cG.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case cG.UNSIGNED_INT:return e.IndexFormat.UInt32}},sW.getElementFormat=function(t,r,n){if(void 0===n&&(n=!1),t==cG.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==cG.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==cG.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==cG.BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==cG.UNSIGNED_BYTE)switch(r){case 2:case 3:case 4:return n?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},sW.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)})},sW.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(uM.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 ui(h,i)),u+=i+8}return{glTF:l,buffers:c}},sW.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)},sW.getSamplerInfo=function(t){var r=t.minFilter,n=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(r||n)&&(o.mipmap=r>=cq.NEAREST_MIPMAP_NEAREST,n===cY.NEAREST?o.filterMode=e.TextureFilterMode.Point:r<=cq.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},sW);(sj=c$||(c$={}))[sj.linear=1]="linear",sj[sj.sRGB=2]="sRGB",(sK=c0||(c0={}))[sK.ETC1S=163]="ETC1S",sK[sK.UASTC=166]="UASTC",(sX=c1||(c1={}))[sX.None=0]="None",sX[sX.BasisLZ=1]="BasisLZ",sX[sX.Zstd=2]="Zstd",sX[sX.ZLib=3]="ZLib";var pm=((sY=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 fq(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 fq(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 fq(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 fq(e,s,l,!0);x.position<l;){var b=x.nextUint32(),T=x.scan(b),C=uM.decodeText(T),S=x.nextUint8Array(b-T.byteLength-1);this.keyValue[C]=C.match(/^ktx/i)?uM.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 fq(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,V=I+w,O=V+P,N=O+F,k=new Uint8Array(t,r+I,w),z=new Uint8Array(t,r+V,P),U=new Uint8Array(t,r+O,F),G=new Uint8Array(t,r+N,L);this.globalData={endpointCount:R,selectorCount:E,imageDescs:B,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},fY(sY,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),sY);e.KTX2TargetFormat=void 0,(sq=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[sq.ASTC=0]="ASTC",sq[sq.BC7=1]="BC7",sq[sq.BC1_BC3=2]="BC1_BC3",sq[sq.PVRTC=3]="PVRTC",sq[sq.ETC=4]="ETC",sq[sq.R8=5]="R8",sq[sq.R8G8=6]="R8G8",sq[sq.R8G8B8A8=7]="R8G8B8A8";var pg=((sZ=(sQ=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)},sZ.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})})},sZ.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},sZ._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})},sZ._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},sZ._onMessage=function(e,t){var r=t.data.error;r?this._workerItems[e].reject(r):this._workerItems[e].resolve(t.data),this._nextTask(e)},sZ._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},sQ),pv=((s$=(sJ=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},s$.destroy=function(){this._transcodeWorkerPool.destroy()},s$._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new pg(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()},sJ);function py(){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=pb(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var px=function(e){return s0||(s0=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})),s0};function pb(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 pT=(fW(s1=function(e){return pv.call(this,e)},pv),(s2=s1.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(){px(n).then(function(){e(null)})},a.onerror=function(){t()}});var a=py.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+r+"\n "+pb.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,n)})},s2.transcode=function(e,t){return 0===this.workerLimitCount?px().then(function(r){return pb(e,t,r)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},s1);function pC(){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 pS=(fW(s3=function(e,t){var r;return(r=pv.call(this,e)||this).type=t,r},pv),(s4=s3.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(s3.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var r=pC.toString(),n=URL.createObjectURL(new Blob([r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(n,t)})},s4.transcode=function(e){for(var t=e.supercompressionScheme===c1.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})},s3);pS.transcoderMap=((s8={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",s8),e.KTX2Loader=(fW(s5=function(){return _T.apply(this,arguments)},_T),(s9=s5.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()}},s9.load=function(t,r){return new hE(function(n,a,i,o){r._request(t.url,{type:"arraybuffer"}).onProgress(i,o).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(n).catch(a)})},s5.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},s5._parseBuffer=function(t,r,n){var a,i,o=new pm(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&&pS.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}})},s5._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 dp(t,o,s,h,d);for(var _=0;_<u.length;_++){var f=u[_].data;i.setPixelBuffer(f,_)}}else{i=new dg(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},s5._decideTargetFormat=function(t,r,n){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,n);return i!==e.KTX2TargetFormat.PVRTC||c4.isPowerOf2(r.pixelWidth)&&c4.isPowerOf2(r.pixelHeight)&&r.pixelWidth===r.pixelHeight?null===i?(uH.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(uH.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},s5._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},s5._getBinomialLLCTranscoder=function(t){var r;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(r=this._binomialLLCTranscoder)?r:this._binomialLLCTranscoder=new pT(t)},s5._getKhronosTranscoder=function(t){var r;return void 0===t&&(t=4),null!=(r=this._khronosTranscoder)?r:this._khronosTranscoder=new pS(t,e.KTX2TargetFormat.ASTC)},s5._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}},s5._isBinomialInit=!1,s5._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]},s5._supportedMap=((s6={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],s6[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],s6[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],s6[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],s6[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],s6),s5),e.KTX2Loader=fj([hD(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader),e.KTX2Transcoder=void 0,(s7=e.KTX2Transcoder||(e.KTX2Transcoder={}))[s7.BinomialLLC=0]="BinomialLLC",s7[s7.Khronos=1]="Khronos";var pA=(fW(le=function(){var e;return e=dI.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},dI),(lt=le.prototype).restoreContent=function(){var t=this;return new hE(function(r,n){Promise.all(t.bufferRequests.map(function(e){return hF(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)}}hE.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)}):pp.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,n=f9(t.meshes);!(e=n()).done;){for(var i,o=e.value,s=o.mesh,l=f9(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,_=f9(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=pp.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=pp.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=pp.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}r(t.resource)}).catch(n)}).catch(n)})},lt._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},le),pM=function(e,t){this.url=e,this.config=t},pR=function(e,t,r){this.texture=e,this.bufferView=t,this.mimeType=r},pE=function(){this.vertexBuffers=[],this.blendShapes=[]},pw=function(e,t){this.buffer=e,this.data=t},pP=function(e,t,r,n,a){this.main=e,this.typeSize=t,this.sparseCount=r,this.sparseIndices=n,this.sparseValues=a},pF=function(e,t,r,n){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=r,this.length=n},pL=function(e,t,r,n){this.blendShape=e,this.position=t,this.normal=r,this.tangent=n},pB=function(e,t,r,n,a){this.buffer=e,this.byteOffset=t,this.count=r,this.normalized=n,this.componentType=a},pD=((ln=(lr=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."},ln.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."},lr);e.GLTFExtensionMode=void 0,(la=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[la.CreateAndParse=0]="CreateAndParse",la[la.AdditiveParse=1]="AdditiveParse";var pI=((li=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=li._createAndParse.apply(li,[].concat(c,t,u,r,a)))return o}},li.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];li._additiveParse.apply(li,[].concat(s,t,r,l,n,i))}},li.hasExtensionParser=function(e){var t;return!!(null==(t=li._extensionParsers[e])?void 0:t.length)},li.getExtensionParser=function(e,t){var r=li._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}},li._addExtensionParser=function(e,t){li._extensionParsers[e]||(li._extensionParsers[e]=[]),li._extensionParsers[e].push(t)},li._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=li.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat(r,n,a,o))},li._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=li.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[].concat(r,n,a,i,s))},li);function pV(e,t){return function(r){var n=new r;n._mode=t,pI._addExtensionParser(e,n)}}function pO(){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(c2)return c2;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=hU._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";c2=WebAssembly.instantiate(t(s)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:c2,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]):c2.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 c2}pI._extensionParsers={},e.GLTFSchemaParser=(fW(lo=function(){return pI.apply(this,arguments)},pI),lo.prototype.parse=function(e){var t=e.glTFResource,r=e.contentRestorer,n=e.resourceManager,a=t.url,i=r.bufferRequests,o={type:"arraybuffer"},s=n._getRemoteUrl(a);return n._requestByRemoteUrl(s,o).onProgress(void 0,e._onTaskDetail).then(function(t){var r=pp.parseGLB(e,t);return(null==r?void 0:r.glTF)&&i.push(new pM(s,o)),r}).then(function(t){return(null==t?void 0:t.glTF)?(r.isGLB=!0,e.buffers=t.buffers,t.glTF):(r.isGLB=!1,JSON.parse(uM.decodeText(new Uint8Array(t.originBuffer))))})},lo),e.GLTFSchemaParser=fj([pf(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(fW(ls=function(){return pI.apply(this,arguments)},pI),ls.prototype.parse=function(t,r){var n=t.glTF.animations[r],a=n.name,i=void 0===a?"AnimationClip"+r:a;return Promise.resolve(pI.executeExtensionsCreateAndParse(n.extensions,t,n)||e.GLTFAnimationParser._parseStandardProperty(t,new _L(i),n)).then(function(e){return pI.executeExtensionsAdditiveAndParse(n.extensions,t,e,n),e})},ls._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([pp.getAccessorBuffer(t,l,i),pp.getAccessorBuffer(t,l,o)]).then(function(t){var n,i,s=t[0].data,l=t[1].data;if(o.normalized){for(var c=pp.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:cW.Linear){case cW.CubicSpine:i=e.InterpolationType.CubicSpine;break;case cW.Step:i=e.InterpolationType.Step;break;case cW.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 cH.TRANSLATION:f=ds,p="position";break;case cH.ROTATION:f=ds,p="rotationQuaternion";break;case cH.SCALE:f=ds,p="scale";break;case cH.WEIGHTS:f=hg,p="blendShapeWeights"}var m=i._addCurve(s.path,a,h);if(s.path===cH.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})},ls._addCurve=function(t,r,n){var a=n[r.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case cH.TRANSLATION:case cH.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new _X;_.time=i[d],c===e.InterpolationType.CubicSpine?(_.inTangent=new c8(o[u++],o[u++],o[u++]),_.value=new c8(o[u++],o[u++],o[u++]),_.outTangent=new c8(o[u++],o[u++],o[u++])):_.value=new c8(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case cH.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 _X;y.time=i[g],p===e.InterpolationType.CubicSpine?(y.inTangent=new uo(o[m++],o[m++],o[m++],o[m++]),y.value=new ur(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new uo(o[m++],o[m++],o[m++],o[m++])):y.value=new ur(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case cH.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 _X;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}},ls),e.GLTFAnimationParser=fj([pf(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(fW(ll=function(){return pI.apply(this,arguments)},pI),(lc=ll.prototype).parse=function(e,t){var r=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,r[t])},lc._parseSingleBuffer=function(e,t){var r=e.glTFResource,n=e.contentRestorer,a=e.resourceManager,i=r.url,o=a._getRemoteUrl(i),s=n.bufferRequests,l={type:"arraybuffer"},c=uM.resolveAbsoluteUrl(o,t.uri);s.push(new pM(c,l));var u=a._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},ll),e.GLTFBufferParser=fj([pf(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(fW(lu=function(){return pI.apply(this,arguments)},pI),lu.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 hp(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 pI.executeExtensionsAdditiveAndParse(u,t,d,a),d},lu),e.GLTFEntityParser=fj([pf(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(fW(ld=function(){return pI.apply(this,arguments)},pI),ld.prototype.parse=function(t,r){var n=t.glTF.materials[r],a=t.glTFResource,i=a.engine,o=pI.executeExtensionsCreateAndParse(n.extensions,t,n);return o||((o=new dQ(i)).name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,o,n)),Promise.resolve(o).then(function(r){return r||(r=e.GLTFMaterialParser._getDefaultMaterial(i)),pI.executeExtensionsAdditiveAndParse(n.extensions,t,r,n),r._associationSuperResource(a),r})},ld._getDefaultMaterial=function(t){var r;return(r=e.GLTFMaterialParser)._defaultMaterial||(r._defaultMaterial=new dY(t))},ld._checkOtherTextureTransform=function(e,t){var r;(null==(r=e.extensions)?void 0:r.KHR_texture_transform)&&uH.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},ld._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 us(us.linearToGammaSpace(h[0]),us.linearToGammaSpace(h[1]),us.linearToGammaSpace(h[2]),h[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){r.baseTexture=e,pI.executeExtensionsAdditiveAndParse(_.extensions,t,r,_)}),r.constructor===dQ&&(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===dQ||r.constructor===dZ){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){r.emissiveTexture=e})),l&&(r.emissiveColor=new us(us.linearToGammaSpace(l[0]),us.linearToGammaSpace(l[1]),us.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&&uH.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?r.renderFace=e.RenderFace.Double:r.renderFace=e.RenderFace.Front,c){case cX.OPAQUE:r.isTransparent=!1;break;case cX.BLEND:r.isTransparent=!0;break;case cX.MASK:r.alphaCutoff=null!=u?u:.5}},ld),e.GLTFMaterialParser=fj([pf(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(fW(lh=function(){return pI.apply(this,arguments)},pI),lh.prototype.parse=function(t,r){for(var n=function(r,n){var c=a.primitives[r];l[r]=new Promise(function(n){var l=pI.executeExtensionsCreateAndParse(c.extensions,t,c,a);if(l)f8(l,he)?(l._associationSuperResource(o),n(l)):l.then(function(e){e._associationSuperResource(o),n(e)});else{var u=new he(s,a.name||r+"");u._associationSuperResource(o);var d=new pE;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)},lh._parseMeshFromGLTFPrimitive=function(t,r,n,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=pp.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,c,u,d=pp.getAccessorTypeSize(i.type),h=i.count,_=t.data,f=r.instanceId,v=t.vertexBindingInfos,y=i.normalized,x=pp.getElementFormat(i.componentType,d,y);if(y&&(c=pp.getNormalizedComponentScale(i.componentType)),t.interleaved){var b=i.byteOffset||0,T=t.stride;if(u=b%T,void 0===v[f]){o=new dj(a,u,x,g);var C=t.vertexBuffer;C||(C=new dH(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),t.vertexBuffer=C,n.vertexBuffers.push(new pw(C,t.restoreInfo))),r.setVertexBufferBinding(C,T,g),v[f]=g++}else o=new dj(a,u,x,v[f])}else{u=0,o=new dj(a,u,x,g);var S=t.vertexBuffer;S||(S=new dH(p,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,s),n.vertexBuffers.push(new pw(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),c8.min(M,E,M),c8.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=pp.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})})},lh._getBlendShapeData=function(e,t,r){return pp.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:pp.bufferToVector3Array(n,a,i,o,s),restoreInfo:new pB(e.restoreInfo,a,i,o,s)}})},lh._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 d0(n);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),r.blendShape=o,r.restoreInfo=new pL(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=f9(h);!(e=n()).done;){var a=e.value;t.addBlendShape(a.blendShape),r.blendShapes.push(a.restoreInfo)}})},lh._tempVector3=new c8,lh),e.GLTFMeshParser=fj([pf(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(fW(l_=function(){return pI.apply(this,arguments)},pI),(lf=l_.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 hp(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 pI.executeExtensionsAdditiveAndParse(l,t,n,s),n})},lf._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)})},lf._createCamera=function(t,r,n){var a=r.orthographic,i=r.perspective,o=r.type,s=n.addComponent(e.Camera);if(o===cj.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===cj.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},lf._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(hg);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(d6)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),pI.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},lf._computeLocalBounds=function(e,t,r,n,a){var i=r.indexOf(n);if(-1!==i)c9.transform(t.bounds,a[i],e.localBounds);else{var o=new un(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?(un.multiplyScalar(o,1/s,o),c9.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},lf._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?(un.add(n,t[c],n),a++):a+=this._computeApproximateBindMatrix(e,t,l,n)}return a},l_),e.GLTFSceneParser=fj([pf(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(fW(lp=function(){return pI.apply(this,arguments)},pI),(lm=lp.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 hm(void 0===c?"SKIN_"+r:c);d.inverseBindMatrices.length=u;var h=Array(u),_=a.accessors[o];return Promise.resolve(pp.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 un;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}))},lm._findSkeletonRootBone=function(e,t){for(var r,n={},a=f9(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}},lp),e.GLTFSkinParser=fj([pf(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(fW(lg=function(){return pI.apply(this,arguments)},pI),lg.prototype.parse=function(t,r){var n=t.glTF.textures[r],a=t.glTFResource,i=n.sampler,o=n.source,s=n.name,l=n.extensions,c=pI.executeExtensionsCreateAndParse(l,t,n,r);return c||(c=e.GLTFTextureParser._parseTexture(t,void 0===o?0:o,r,i,s)),Promise.resolve(c).then(function(e){return pI.executeExtensionsAdditiveAndParse(l,t,e,n),e._associationSuperResource(a),e})},lg._parseTexture=function(t,r,n,a,i){var o=t.glTFResource,s=t.glTF,l=o.engine,c=o.url,u=s.images[r],d=u.uri,h=u.bufferView,_=u.mimeType,f=u.name,p=void 0!==a,m=p&&pp.getSamplerInfo(s.samplers[a]);if(d){var g,v=d.lastIndexOf("."),y=d.substring(v+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;g=l.resourceManager.load({url:uM.resolveAbsoluteUrl(c,d),type:y,params:{mipmap:null==m?void 0:m.mipmap}}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name=i||f||e.name||"texture_"+n,p&&pp.parseSampler(e,m),e}),t._addTaskCompletePromise(g)}else{var x=s.bufferViews[h];g=t.get(e.GLTFParserType.Buffer).then(function(e){var r=e[x.buffer],a=new Uint8Array(r,x.byteOffset,x.byteLength);return pp.loadImageBuffer(a,_).then(function(e){var r=new dp(l,e.width,e.height,void 0,null==m?void 0:m.mipmap);r.setImageSource(e),r.generateMipmaps(),r.name=i||f||"texture_"+n,p&&pp.parseSampler(r,m);var a=new pR(r,x,_);return t.contentRestorer.bufferTextures.push(a),r})})}return g},lg._wrapMap=((lv={})[cQ.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,lv[cQ.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,lv[cQ.REPEAT]=e.TextureWrapMode.Repeat,lv),lg),e.GLTFTextureParser=fj([pf(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(fW(ly=function(){return pI.apply(this,arguments)},pI),ly.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){uH.info("extensionsUsed: ",n);for(var o=0;o<n.length;o++){var s=n[o];pI.hasExtensionParser(s)||uH.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){uH.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];pI.hasExtensionParser(c)||uH.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},ly),e.GLTFValidator=fj([pf(e.GLTFParserType.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=(fW(lx=function(){return pI.apply(this,arguments)},pI),lx.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?pI.executeExtensionsCreateAndParse(a,t,n):t.get(e.GLTFParserType.Buffer,l).then(function(e){return new Uint8Array(e,o,s)})},lx),e.GLTFBufferViewParser=fj([pf(e.GLTFParserType.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=(fW(lb=function(){return pI.apply(this,arguments)},pI),(lT=lb.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)},lT._createAnimatorController=function(e,t){var r=e.glTFResource.engine,n=new _G(r),a=new _K("layer"),i=new _j;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},lb),e.GLTFAnimatorControllerParser=fj([pf(e.GLTFParserType.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=(fW(lC=function(){return _T.apply(this,arguments)},_T),(lS=lC.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?pO().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},lS.load=function(e,t){var r=e.params,n=new pc(t.engine,e.url),a=new pu(n,t,fG({keepMeshData:!1},r));return new hE(function(e,t,r,n){a._setTaskCompleteProgress=r,a._setTaskDetailProgress=n,a.parse().then(e).catch(t)})},lC.release=function(){c2&&pO().then(function(e){e.release()})},lC),e.GLTFLoader=fj([hD(e.AssetType.GLTF,["gltf","glb"])],e.GLTFLoader);var pN=(fW(lA=function(e,t,r){var n;return(n=f7.call(this,e,t)||this).prefabResource=r,n},f7),(lM=lA.prototype)._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},lM._clearAndResolve=function(){return this.context.clear(),this.prefabResource},lA.parse=function(t,r,n){var a=new f6(t,r),i=new f3(t,e.ParserType.Prefab,a),o=new lA(n,i,a);return o.start(),o.promise.then(function(){return a})},lA),pk=(fW(lR=function(){return _T.apply(this,arguments)},_T),lR.prototype.load=function(e,t){var r=t.engine;return new hE(function(n,a){t._request(e.url,fG({},e,{type:"json"})).then(function(t){pN.parse(r,e.url,t).then(n).catch(a)})})},lR);pk=fj([hD(e.AssetType.Prefab,["prefab"])],pk);var pz=Math.PI,pU=(fW(lE=function(){return _T.apply(this,arguments)},_T),lE.prototype.load=function(e,t){return new hE(function(r,n){var a=t.engine,i=fG({},e,{type:"arraybuffer"});t._request(e.url,i).then(function(t){var n=pU._setTextureByBuffer(a,t);a.resourceManager.addContentRestorer(new pG(n,e.url,i)),r(n)}).catch(n)})},lE._setTextureByBuffer=function(t,r,n){var a=new Uint8Array(r),i=pU._parseHeader(a),o=i.width,s=i.height,l=i.dataPosition,c=s>>1;n||(n=new dg(t,c));for(var u=pU._readPixels(a.subarray(l),o,s),d=pU._convertToCubemap(u,o,s,c),h=0;h<6;h++)n.setPixelBuffer(e.TextureCubeFace.PositiveX+h,d[h],0);return n.generateMipmaps(),n},lE._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)]},lE._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},lE._calcProjectionSpherical=function(e,t,r,n){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-pz;)a+=2*pz;for(;a>pz;)a-=2*pz;var o=a/pz,s=Math.round((o=.5*o+.5)*r);s<0?s=0:s>=r&&(s=r-1);var l=Math.round(i/pz*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 us(u,d,h,_)},lE._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},lE._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}},lE._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},lE._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},lE._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},lE._rightBottomBack=new c8(1,-1,-1),lE._rightBottomFront=new c8(1,-1,1),lE._rightUpBack=new c8(1,1,-1),lE._rightUpFront=new c8(1,1,1),lE._leftBottomBack=new c8(-1,-1,-1),lE._leftBottomFront=new c8(-1,-1,1),lE._leftUpBack=new c8(-1,1,-1),lE._leftUpFront=new c8(-1,1,1),lE._faceRight=[lE._rightBottomBack,lE._rightBottomFront,lE._rightUpBack,lE._rightUpFront],lE._faceLeft=[lE._leftBottomFront,lE._leftBottomBack,lE._leftUpFront,lE._leftUpBack],lE._faceUp=[lE._leftBottomFront,lE._rightBottomFront,lE._leftBottomBack,lE._rightBottomBack],lE._faceBottom=[lE._leftUpBack,lE._rightUpBack,lE._leftUpFront,lE._rightUpFront],lE._faceFront=[lE._leftBottomBack,lE._rightBottomBack,lE._leftUpBack,lE._rightUpBack],lE._faceBack=[lE._rightBottomFront,lE._leftBottomFront,lE._rightUpFront,lE._leftUpFront],lE._tempVector3=new c8,lE._temp2Vector3=new c8,lE._temp3Vector3=new c8,lE._temp4Vector3=new c8,lE._temp5Vector3=new c8,lE);pU=fj([hD(e.AssetType.HDR,["hdr"])],pU);var pG=(fW(lw=function(e,t,r){var n;return(n=dI.call(this,e)||this).url=t,n.requestConfig=r,n},dI),lw.prototype.restoreContent=function(){var e=this;return new hE(function(t,r){hF(e.url,e.requestConfig).then(function(r){pU._setTextureByBuffer(e.resource.engine,r,e.resource),t(e.resource)}).catch(r)})},lw),pH=(fW(lP=function(){return _T.apply(this,arguments)},_T),lP.prototype.load=function(e,t){return t._request(e.url,fG({},e,{type:"json"}))},lP);pH=fj([hD(e.AssetType.JSON,["json"],!1)],pH);var pW={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 pj(e){var t=pW.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var pK=(fW(lF=function(){return _T.apply(this,arguments)},_T),lF.prototype.load=function(t,r){return new hE(function(n,a){Promise.all(t.urls.map(function(e){return r._request(e,fG({},t,{type:"arraybuffer"}))})).then(function(t){for(var a=function(e){for(var t,r,n,a,i=[],o=0;o<e.length;o++){var s=pW.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=a.width,o=a.mipmapsFaces,s=a.engineFormat,l=o[0].length>1,c=new dg(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)}n(c)}).catch(function(e){a(e)})})},lF);pK=fj([hD(e.AssetType.KTXCube,[])],pK);var pX=(fW(lL=function(){return _T.apply(this,arguments)},_T),lL.prototype.load=function(e,t){return new hE(function(r,n){t._request(e.url,fG({},e,{type:"arraybuffer"})).then(function(e){for(var n=pj(e),a=n.width,i=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new dp(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,_)}r(c)}).catch(function(e){n(e)})})},lL);pX=fj([hD(e.AssetType.KTX,["ktx"])],pX);var pY=(fW(lB=function(){return _T.apply(this,arguments)},_T),(lD=lB.prototype).load=function(e,t){var r=this;return new hE(function(n,a){t._request(e.url,fG({},e,{type:"json"})).then(function(e){var a=t.engine,i=e.shaderRef,o=e.shader,s=u9.find(o);s?n(r._getMaterialByShader(e,s,a)):i&&n(t.getResourceByRef(i).then(function(t){return r._getMaterialByShader(e,t,a)}))}).catch(a)})},lD._getMaterialByShader=function(t,r,n){var a=function(t){var r=o[t],a=r.type,i=r.value;switch(a){case e.MaterialLoaderType.Vector2:d.setVector2(t,new ui(i.x,i.y));break;case e.MaterialLoaderType.Vector3:d.setVector3(t,new c8(i.x,i.y,i.z));break;case e.MaterialLoaderType.Vector4:d.setVector4(t,new uo(i.x,i.y,i.z,i.w));break;case e.MaterialLoaderType.Color:d.setColor(t,new us(i.r,i.g,i.b,i.a));break;case e.MaterialLoaderType.Float:d.setFloat(t,i);break;case e.MaterialLoaderType.Texture:u.push(n.resourceManager.getResourceByRef(i).then(function(e){d.setTexture(t,e)}));break;case e.MaterialLoaderType.Boolean:d.setInt(t,i?1:0);break;case e.MaterialLoaderType.Integer:d.setInt(t,Number(i))}},i=t.name,o=t.shaderData,s=t.macros,l=t.renderState,c=new dK(n,r);c.name=i;var u=[],d=c.shaderData;for(var h in o)a(h);for(var _=0,f=s.length;_<f;_++){var p=s[_],m=p.name,g=p.value;void 0==g?d.enableMacro(m):d.enableMacro(m,g)}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}(c,"renderState",l),Promise.all(u).then(function(){return c})},lB);pY=fj([hD(e.AssetType.Material,["json"])],pY);var pq=(fW(lI=function(){return _T.apply(this,arguments)},_T),lI.prototype.load=function(e,t){return new hE(function(r,n){t._request(e.url,fG({},e,{type:"arraybuffer"})).then(function(e){return pt(e,t.engine)}).then(function(e){r(e)}).catch(n)})},lI);pq=fj([hD(e.AssetType.Mesh,["mesh"])],pq);var pQ=(fW(lV=function(){return _T.apply(this,arguments)},_T),lV.prototype.load=function(e,t){var r=t.engine;return t._request(e.url,fG({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return hh.createSubdivisionSurfaceSphere(r,e.sphereRadius,e.sphereStep);case"capsule":return hh.createCapsule(r,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return hh.createCone(r,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return hh.createCuboid(r,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return hh.createCylinder(r,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return hh.createPlane(r,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return hh.createTorus(r,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},lV);pQ=fj([hD(e.AssetType.PrimitiveMesh,["mesh"],!1)],pQ),(lO=c3||(c3={})).Sphere="sphere",lO.Cuboid="cuboid",lO.Plane="plane",lO.Cylinder="cylinder",lO.Torus="torus",lO.Cone="cone",lO.Capsule="capsule";var pZ=(fW(lN=function(){return _T.apply(this,arguments)},_T),lN.prototype.load=function(t,r){var n=r.engine;return new hE(function(a,i){r._request(t.url,fG({},t,{type:"json"})).then(function(t){return n.resourceManager.initVirtualResources(t.files),r.load({type:e.AssetType.Scene,url:t.scene}).then(function(e){n.sceneManager.activeScene=e,a()})}).catch(i)})},lN);pZ=fj([hD(e.AssetType.Project,["proj"],!1)],pZ);var pJ=(fW(lk=function(){return _T.apply(this,arguments)},_T),(lz=lk.prototype).load=function(e,t){var r=this;return new hE(function(n,a){var i=t._getRemoteUrl(e.url);r._registerFont(i,i).then(function(){n(new dk(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},lz._registerFont=function(e,t){return ps(function(){var r;return fK(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]}})})()},lk);pJ=fj([hD(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],pJ);var p$=(fW(lU=function(){var e;return e=_T.apply(this,arguments)||this,e._tempRect=new ul,e._tempVec2=new ui,e._tempVec4=new uo,e},_T),(lG=lU.prototype).load=function(t,r){var n=this;return new hE(function(a,i,o,s,l){var c=[];l(function(){for(var e=0;e<c.length;e++)c[e].cancel()});var u=r._request(t.url,fG({},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 uA(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:uM.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);hE.all(c).then(function(){a(g)}).catch(i)}).catch(i)})},lG._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 uF(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},lU);p$=fj([hD(e.AssetType.SpriteAtlas,["atlas"],!1)],p$);var p0=(fW(lH=function(){return _T.apply(this,arguments)},_T),(lW=lH.prototype).load=function(e,t){var r=this;return t._request(e.url,fG({},e,{type:"json"})).then(function(e){return e.belongToAtlas?r._loadFromAtlas(t,e):r._loadFromTexture(t,e)})},lW._loadFromAtlas=function(e,t){var r=this;return e.getResourceByRef(t.belongToAtlas).then(function(n){return n.getSprite(t.fullPath)||r._loadFromTexture(e,t)})},lW._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(r){var n=new uF(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 hE(function(r){var n=new uF(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)})},lH);p0=fj([hD(e.AssetType.Sprite,["sprite"],!1)],p0);var p1=(fW(lj=function(e,t,r){var n;return(n=dI.call(this,e)||this).url=t,n.requestConfig=r,n},dI),lj.prototype.restoreContent=function(){var e=this;return hF(this.url,this.requestConfig).then(function(t){var r=e.resource;return r.setImageSource(t),r.generateMipmaps(),r})},lj),p2=(fW(lK=function(){return _T.apply(this,arguments)},_T),lK.prototype.load=function(e,t){return new hE(function(r,n,a,i){var o=e.url,s=fG({},e,{type:"image"});t._request(o,s).onProgress(a,i).then(function(n){var a,i=null!=(a=e.params)?a:{},l=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new dp(t.engine,n.width,n.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(n),f.generateMipmaps(),0!==o.indexOf("data:")){var p=o.lastIndexOf("/");f.name=o.substring(p+1)}t.addContentRestorer(new p1(f,o,s)),r(f)}).catch(function(e){n(e)})})},lK);p2=fj([hD(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],p2);var p3=(fW(lX=function(e,t,r){var n;return(n=dI.call(this,e)||this).urls=t,n.requestConfig=r,n},dI),lX.prototype.restoreContent=function(){var t=this;return new hE(function(r,n){Promise.all(t.urls.map(function(e){return hF(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)})})},lX),p4=(fW(lY=function(){return _T.apply(this,arguments)},_T),lY.prototype.load=function(t,r){return new hE(function(n,a){var i=t.urls,o=fG({},t,{type:"image"});Promise.all(i.map(function(e){return r._request(e,o)})).then(function(t){var a=t[0],s=a.width;if(s!==a.height){console.error("The cube texture must have the same width and height");return}for(var l=new dg(r.engine,s),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),r.addContentRestorer(new p3(l,i,o)),n(l)}).catch(function(e){a(e)})})},lY);p4=fj([hD(e.AssetType.TextureCube,[""])],p4);var p8=(fW(lq=function(){return _T.apply(this,arguments)},_T),lq.prototype.load=function(e,t){var r=e.url;return t._request(r,fG({},e,{type:"text"})).then(function(e){return uX.registerInclude(r.substring(1),e),p8._loadChunksInCode(e,r,t)})},lq._loadChunksInCode=function(e,t,r){for(var n,a=[],i=e.matchAll(p8._shaderIncludeRegex),o=f9(i);!(n=o()).done;){var s=n.value,l=uM.resolveAbsoluteUrl(t,s[1]);uK[l.substring(1)]||a.push(l)}return Promise.all(a.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},lq._shaderIncludeRegex=/\s#include\s+"([./][^\\"]+)"/gm,lq);p8=fj([hD("ShaderChunk",["glsl"])],p8);var p5=(fW(lQ=function(){return _T.apply(this,arguments)},_T),(lZ=lQ.prototype).load=function(e,t){var r=this,n=e.url;return t._request(n,fG({},e,{type:"text"})).then(function(e){var a=r._getBuiltinShader(e);return a?u9.find(a):p8._loadChunksInCode(e,n,t).then(function(){var t=u9.create(e);return t._registerPath(n),t})})},lZ._getBuiltinShader=function(e){var t=e.match(p5._builtinRegex);if(t&&t[1])return t[1]},lQ._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,lQ);p5=fj([hD(e.AssetType.Shader,["gs","gsl"])],p5);var p9=(fW(lJ=function(){return _T.apply(this,arguments)},_T),lJ.prototype.load=function(t,r){var n=r.engine;return new hE(function(a,i){r._request(t.url,fG({},t,{type:"json"})).then(function(t){return pe.parse(n,t).then(function(n){var i,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 uH.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!=(i=m.shadowTwoCascadeSplits)?i: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(){a(n)})})}).catch(i)})},lJ);p9=fj([hD(e.AssetType.Scene,["scene"],!0)],p9),f4.registerCustomParseComponent("TextRenderer",ps(function(e,t){var r;return fK(this,function(n){return(r=t.props).font||(e.font=dk.createFromOS(e.engine,r.fontFamily||"Arial")),[2,e]})}));var p6=(fW(l$=function(){return pD.apply(this,arguments)},pD),l$.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(__):"point"===s?n=t.addComponent(_f):"spot"===s&&(n=t.addComponent(_p)),i&&n.color.set(i[0],i[1],i[2],1),n.intensity=void 0===o?1:o,l&&!f8(n,__)&&(n.distance=l),c&&f8(n,_p)){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)},l$);p6=fj([pV("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],p6);var p7=(fW(l0=function(){return pD.apply(this,arguments)},pD),l0.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}))},l0);p7=fj([pV("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],p7);var me=(fW(l1=function(){return pD.apply(this,arguments)},pD),l1.prototype.additiveParse=function(e,t,r){var n=r.ior;t.ior=void 0===n?1.5:n},l1);me=fj([pV("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],me);var mt=(fW(l2=function(){return pD.apply(this,arguments)},pD),l2.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dZ(a),o=r.diffuseFactor,s=r.diffuseTexture,l=r.specularFactor,c=r.glossinessFactor,u=r.specularGlossinessTexture;return o&&(i.baseColor=new us(us.linearToGammaSpace(o[0]),us.linearToGammaSpace(o[1]),us.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,pI.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new us(us.linearToGammaSpace(l[0]),us.linearToGammaSpace(l[1]),us.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},l2);mt=fj([pV("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],mt);var mr=(fW(l3=function(){return pD.apply(this,arguments)},pD),l3.prototype.createAndParse=function(t,r,n){var a=t.glTFResource.engine,i=new dJ(a);return i.name=n.name,e.GLTFMaterialParser._parseStandardProperty(t,i,n),i},l3);mr=fj([pV("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],mr);var mn=(fW(l4=function(){return pD.apply(this,arguments)},pD),l4.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)},l4);mn=fj([pV("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],mn);var ma=(fW(l8=function(){return pD.apply(this,arguments)},pD),l8);ma=fj([pV("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],ma);var mi=(fW(l5=function(){return pD.apply(this,arguments)},pD),l5.prototype.createAndParse=function(t,r,n){return ps(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return fK(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&&pp.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:uM.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&&pp.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&&pp.parseSampler(e,m);var r=new pR(e,y,f);return t.contentRestorer.bufferTextures.push(r),e})})])})})()},l5);mi=fj([pV("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],mi);var mo=(fW(l9=function(){return pD.apply(this,arguments)},pD),l9.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&&uH.warn("rotation in KHR_texture_transform is not supported now"),o&&uH.warn("texCoord in KHR_texture_transform is not supported now")},l9);mo=fj([pV("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],mo);var ms=(fW(l6=function(){return pD.apply(this,arguments)},pD),l6.prototype.createAndParse=function(e,t){var r=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(r),r},l6);ms=fj([pV("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],ms);var ml=(fW(l7=function(){return pD.apply(this,arguments)},pD),l7.prototype.additiveParse=function(e,t,r){e.glTFResource.engine,r.events.map(function(e){var r=new _F;r.functionName=e.functionName,r.time=e.time,r.parameter=e.parameter,t.addEvent(r)})},l7);ml=fj([pV("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],ml);var mc=(fW(ce=function(){return pD.apply(this,arguments)},pD),ce.prototype.createAndParse=function(t,r){return t.get(e.GLTFParserType.Buffer,r.buffer).then(function(e){return pO().then(function(t){return t.decodeGltfBuffer(r.count,r.byteStride,new Uint8Array(e,r.byteOffset,r.byteLength),r.mode,r.filter)})})},ce);mc=fj([pV("EXT_meshopt_compression",e.GLTFExtensionMode.CreateAndParse)],mc);var mu=(fW(ct=function(){return pD.apply(this,arguments)},pD),ct.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}))},ct);mu=fj([pV("KHR_materials_anisotropy",e.GLTFExtensionMode.AdditiveParse)],mu);var md=(fW(cr=function(){var e;if((e=pD.call(this)||this)._supportWebP=!1,hU._isBrowser){var t=document.createElement("canvas");t.width=t.height=1,e._supportWebP=0==t.toDataURL("image/webp").indexOf("data:image/webp")}else e._supportWebP=!1;return e},pD),cr.prototype.createAndParse=function(t,r,n,a){var i=this;return ps(function(){var o,s,l,c,u;return fK(this,function(d){return o=r.source,s=n.sampler,c=void 0===(l=n.source)?0:l,u=n.name,[2,e.GLTFTextureParser._parseTexture(t,i._supportWebP?o:c,a,s,u)]})})()},cr);md=fj([pV("EXT_texture_webp",e.GLTFExtensionMode.CreateAndParse)],md);var mh="1.3.24";for(var m_ in console.log("Galacean engine version: "+mh),fT)_T.registerClass(m_,fT[m_]);e.AmbientLight=_d,e.AnimationClip=_L,e.AnimationClipCurveBinding=_P,e.AnimationCurve=_B,e.AnimationEvent=_F,e.Animator=_z,e.AnimatorCondition=_I,e.AnimatorController=_G,e.AnimatorControllerLayer=_K,e.AnimatorControllerParameter=_U,e.AnimatorLayerMask=_q,e.AnimatorState=_W,e.AnimatorStateMachine=_j,e.AnimatorStateTransition=_V,e.AssetPromise=hE,e.Background=_c,e.BaseMaterial=dX,e.BasicRenderPipeline=dF,e.BlendShape=d0,e.BlendShapeFrame=d$,e.BlendState=u2,e.BlinnPhongMaterial=dY,e.BloomEffect=_g,e.BoolUpdateFlag=di,e.BoundingBox=c9,e.BoundingFrustum=ue,e.BoundingSphere=c5,e.BoxColliderShape=h2,e.BoxShape=fc,e.Buffer=dH,e.BufferInfo=pd,e.BufferMesh=d9,e.BufferReader=fq,e.BufferUtil=dW,e.Burst=fo,e.Canvas=_s,e.CapsuleColliderShape=h8,e.CharacterController=hW,e.CircleShape=fu,e.ClearableObjectPool=_a,e.CloneManager=uT,e.ColliderShape=h1,e.CollisionUtil=c6,e.Color=us,e.ColorOverLifetimeModule=_4,e.Component=dr,e.ConeShape=fd,e.ContentRestorer=dI,e.CubeProbe=fb,e.CurveKey=fe,e.DepthState=u3,e.DirectLight=__,e.DisorderedArray=dd,e.DynamicCollider=hj,e.EmissionModule=_5,e.Engine=_o,e.EngineObject=uC,e.Entity=hp,e.EventDispatcher=uO,e.FileHeader=fJ,e.FixedJoint=hQ,e.Font=dk,e.GLTFExtensionParser=pD,e.GLTFParser=pI,e.GLTFParserContext=pu,e.GLTFResource=pc,e.GLTFUtils=pp,e.GradientAlphaKey=_1,e.GradientColorKey=_0,e.HemisphereShape=fh,e.HingeJoint=hZ,e.HitResult=hK,e.IndexBufferBinding=d1,e.InputManager=h6,e.JointLimits=h$,e.JointMotor=h0,e.Keyframe=_X,e.LayerPathMask=_Y,e.Light=_h,e.Loader=_T,e.Logger=uH,e.MainModule=_9,e.Material=dK,e.MathUtil=c4,e.Matrix=un,e.Matrix3x3=ut,e.Mesh=d8,e.MeshRenderer=d6,e.ModelMesh=he,e.PBRBaseMaterial=dq,e.PBRMaterial=dQ,e.PBRSpecularMaterial=dZ,e.ParserContext=f3,e.ParticleCompositeCurve=_8,e.ParticleCompositeGradient=_2,e.ParticleCurve=_7,e.ParticleGenerator=fa,e.ParticleGradient=_$,e.ParticleMaterial=fi,e.ParticleRenderer=_J,e.PhysicsMaterial=hX,e.PhysicsScene=hH,e.Plane=c7,e.PlaneColliderShape=h4,e.PointLight=_f,e.Pointer=hN,e.PrefabResource=f6,e.Primitive=d4,e.PrimitiveMesh=hh,e.Probe=fg,e.Quaternion=ur,e.Rand=uu,e.RasterState=u4,e.Ray=ua,e.Rect=ul,e.ReferResource=uS,e.ReflectionParser=f4,e.RenderQueue=dS,e.RenderState=u5,e.RenderTarget=df,e.RenderTargetBlendState=u1,e.ResourceManager=hB,e.ReturnableObjectPool=hx,e.RotationOverLifetimeModule=_6,e.SafeLoopArray=hM,e.Scene=_x,e.SceneManager=hR,e.SceneParser=pe,e.Script=_b,e.Shader=u9,e.ShaderData=de,e.ShaderFactory=uX,e.ShaderLib=uK,e.ShaderMacro=uD,e.ShaderMacroCollection=uI,e.ShaderPass=u$,e.ShaderProperty=uW,e.ShaderTagKey=uY,e.SizeOverLifetimeModule=ft,e.Skin=hm,e.SkinnedMeshRenderer=hg,e.Sky=_l,e.SkyBoxMaterial=_Q,e.SkyProceduralMaterial=_Z,e.SphereColliderShape=h3,e.SphereShape=f_,e.SphericalHarmonics3=uc,e.SpotLight=_p,e.SpringJoint=hJ,e.Sprite=uF,e.SpriteAtlas=uA,e.SpriteMask=dD,e.SpriteRenderer=d_,e.StateMachineScript=_H,e.StaticCollider=hY,e.StencilState=u8,e.SubMesh=d3,e.SubPrimitive=d2,e.SubShader=u0,e.SystemInfo=hU,e.TextRenderer=dU,e.TextUtils=dO,e.Texture=u7,e.Texture2D=dp,e.Texture2DArray=dm,e.TextureCube=dg,e.TextureSheetAnimationModule=fr,e.Time=uj,e.TonemappingEffect=_v,e.TrailMaterial=ff,e.TrailRenderer=fm,e.Transform=ds,e.UnlitMaterial=dJ,e.Utils=uM,e.Vector2=ui,e.Vector3=c8,e.Vector4=uo,e.VelocityOverLifetimeModule=fn,e.VertexBufferBinding=d5,e.VertexElement=dj,e.WebCanvas=fE,e.WebGLEngine=fw,e.WebGLGraphicDevice=fU,e.XRManager=_i,e._PostProcessManager=_y,e.assignmentClone=uy,e.decode=pt,e.decoder=fZ,e.decoderMap=fQ,e.deepClone=ub,e.dependentComponents=da,e.ignoreClone=uv,e.parseSingleKTX=pj,e.registerGLTFExtension=pV,e.registerGLTFParser=pf,e.request=hF,e.resourceLoader=hD,e.shallowClone=ux,e.version=mh,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 n(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var r,a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y,x,b,C,S,T,A,E,R,M,w,P,F,L,D,B,I,O,N,V,k,z,U,G,H,W,j,X,K,Y,q,Q,J,Z,$,ee,et,en,er,ea,ei,eo,es,el,ec,eu,ed,eh,e_,ef,ep,em,eg,ev,ey,ex,eb,eC,eS,eT,eA,eE,eR,eM,ew,eP,eF,eL,eD,eB,eI,eO,eN,eV,ek,ez,eU,eG,eH,eW,ej,eX,eK,eY,eq,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e8,e5,e9,e6,e7,te,tt,tn,tr,ta,ti,to,ts,tl,tc,tu,td,th,t_,tf,tp,tm,tg,tv=((td={})[td.Disjoint=0]="Disjoint",td[td.Contains=1]="Contains",td[td.Intersects=2]="Intersects",td),ty=((r={})[r.Back=0]="Back",r[r.Front=1]="Front",r[r.Intersecting=2]="Intersecting",r),tx=((a={})[a.Near=0]="Near",a[a.Far=1]="Far",a[a.Left=2]="Left",a[a.Right=3]="Right",a[a.Bottom=4]="Bottom",a[a.Top=5]="Top",a);function tb(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tC(e,t,n){return t&&tb(e.prototype,t),n&&tb(e,n),e}var tS=/*#__PURE__*/function(){function e(){}return e.clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},e.equals=function(t,n){return Math.abs(t-n)<=e.zeroTolerance},e.isPowerOf2=function(e){return(e&e-1)==0},e.radianToDegree=function(t){return t*e.radToDegreeFactor},e.degreeToRadian=function(t){return t*e.degreeToRadFactor},e.lerp=function(e,t,n){return e+(t-e)*n},e}();tS.zeroTolerance=1e-6,tS.radToDegreeFactor=180/Math.PI,tS.degreeToRadFactor=Math.PI/180;var tT=/*#__PURE__*/function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n}var t=e.prototype;return t.set=function(e,t,n){return this._x=e,this._y=t,this._z=n,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z;return Math.sqrt(e*e+t*t+n*n)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z;return e*e+t*t+n*n},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},t.transformNormal=function(t){return e.transformNormal(this,t,this),this},t.transformToVec3=function(t){return e.transformToVec3(this,t,this),this},t.transformCoordinate=function(t){return e.transformCoordinate(this,t,this),this},t.transformByQuat=function(t){return e.transformByQuat(this,t,this),this},t.clone=function(){return new e(this._x,this._y,this._z)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e},t.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},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},e.cross=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z;n.set(a*l-i*s,i*o-r*l,r*s-a*o)},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return Math.sqrt(n*n+r*r+a*a)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z;return n*n+r*r+a*a},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=Math.sqrt(n*n+r*r+a*a);i>tS.zeroTolerance&&(i=1/i,t.set(n*i,r*i,a*i))},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._onValueChanged&&n._onValueChanged()},e.transformNormal=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8],n._y=r*o[1]+a*o[5]+i*o[9],n._z=r*o[2]+a*o[6]+i*o[10],n._onValueChanged&&n._onValueChanged()},e.transformToVec3=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._onValueChanged&&n._onValueChanged()},e.transformToVec4=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements;n._x=r*o[0]+a*o[4]+i*o[8]+o[12],n._y=r*o[1]+a*o[5]+i*o[9]+o[13],n._z=r*o[2]+a*o[6]+i*o[10]+o[14],n._w=r*o[3]+a*o[7]+i*o[11]+o[15],n._onValueChanged&&n._onValueChanged()},e.transformCoordinate=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t.elements,s=r*o[3]+a*o[7]+i*o[11]+o[15];s=1/s,n._x=(r*o[0]+a*o[4]+i*o[8]+o[12])*s,n._y=(r*o[1]+a*o[5]+i*o[9]+o[13])*s,n._z=(r*o[2]+a*o[6]+i*o[10]+o[14])*s,n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*r+s*i-l*a,d=c*a+l*r-o*i,h=c*i+o*a-s*r,_=-o*r-s*a-l*i;n._x=u*c-_*o-d*l+h*s,n._y=d*c-_*s-h*o+u*l,n._z=h*c-_*l-u*s+d*o,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tT._zero=new tT(0,0,0),tT._one=new tT(1,1,1);var tA=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new tT,this.radius=0,e&&this.center.copyFrom(e),this.radius=t}var t=e.prototype;return t.clone=function(){return new e(this.center,this.radius)},t.copyFrom=function(e){return this.center.copyFrom(e.center),this.radius=e.radius,this},e.fromPoints=function(t,n){if(!t||0===t.length)throw Error("points must be array and length must > 0");var r=t.length,a=e._tempVec30;a.x=a.y=a.z=0;for(var i=0;i<r;++i)tT.add(t[i],a,a);tT.scale(a,1/r,n.center);for(var o=0,s=0;s<r;++s){var l=tT.distanceSquared(a,t[s]);l>o&&(o=l)}n.radius=Math.sqrt(o)},e.fromBox=function(e,t){var n=t.center,r=e.min,a=e.max;n.x=(r.x+a.x)*.5,n.y=(r.y+a.y)*.5,n.z=(r.z+a.z)*.5,t.radius=tT.distance(n,a)},e}();tA._tempVec30=new tT;var tE=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new tT,this.max=new tT,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}var t=e.prototype;return t.getCenter=function(e){var t=this.min,n=this.max,r=n._x+t._x,a=n._y+t._y,i=n._z+t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getExtent=function(e){var t=this.min,n=this.max,r=n._x-t._x,a=n._y-t._y,i=n._z-t._z;return e.set(isNaN(r)?0:.5*r,isNaN(a)?0:.5*a,isNaN(i)?0:.5*i),e},t.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,n=this.max,r=t.x,a=t.y,i=t.z,o=n.x,s=n.y,l=n.z,c=e.length;if(c<8)for(var u=0,d=8-c;u<d;++u)e[c+u]=new tT;return e[0].set(r,s,l),e[1].set(o,s,l),e[2].set(o,a,l),e[3].set(r,a,l),e[4].set(r,s,i),e[5].set(o,s,i),e[6].set(o,a,i),e[7].set(r,a,i),e},t.transform=function(t){return e.transform(this,t,this),this},t.clone=function(){return new e(this.min,this.max)},t.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},e.fromCenterAndExtent=function(e,t,n){tT.subtract(e,t,n.min),tT.add(e,t,n.max)},e.fromPoints=function(e,t){if(!e||0===e.length)throw Error("points must be array and length must > 0");var n=t.min,r=t.max;n.x=n.y=n.z=Number.MAX_VALUE,r.x=r.y=r.z=-Number.MAX_VALUE;for(var a=0,i=e.length;a<i;++a){var o=e[a];tT.min(n,o,n),tT.max(r,o,r)}},e.fromSphere=function(e,t){var n=e.center,r=e.radius,a=t.min,i=t.max;a.x=n.x-r,a.y=n.y-r,a.z=n.z-r,i.x=n.x+r,i.y=n.y+r,i.z=n.z+r},e.transform=function(t,n,r){var a=e._tempVec30,i=e._tempVec31;t.getCenter(a),t.getExtent(i),tT.transformCoordinate(a,n,a);var o=i.x,s=i.y,l=i.z,c=n.elements,u=c[0],d=c[1],h=c[2],_=c[4],f=c[5],p=c[6],m=c[8],g=c[9],v=c[10];i.set((0===u?0:Math.abs(o*u))+(0===_?0:Math.abs(s*_))+(0===m?0:Math.abs(l*m)),(0===d?0:Math.abs(o*d))+(0===f?0:Math.abs(s*f))+(0===g?0:Math.abs(l*g)),(0===h?0:Math.abs(o*h))+(0===p?0:Math.abs(s*p))+(0===v?0:Math.abs(l*v))),tT.subtract(a,i,r.min),tT.add(a,i,r.max)},e.merge=function(e,t,n){return tT.min(e.min,t.min,n.min),tT.max(e.max,t.max,n.max),n},e}();tE._tempVec30=new tT,tE._tempVec31=new tT;var tR=/*#__PURE__*/function(){function e(){}return e.intersectionPointThreePlanes=function(t,n,r,a){var i=t.normal,o=n.normal,s=r.normal;tT.cross(o,s,e._tempVec30),tT.cross(s,i,e._tempVec31),tT.cross(i,o,e._tempVec32);var l=-tT.dot(i,e._tempVec30),c=-tT.dot(o,e._tempVec31),u=-tT.dot(s,e._tempVec32);tT.scale(e._tempVec30,t.distance/l,e._tempVec30),tT.scale(e._tempVec31,n.distance/c,e._tempVec31),tT.scale(e._tempVec32,r.distance/u,e._tempVec32),tT.add(e._tempVec30,e._tempVec31,a),tT.add(a,e._tempVec32,a)},e.distancePlaneAndPoint=function(e,t){return tT.dot(e.normal,t)+e.distance},e.intersectsPlaneAndPoint=function(t,n){var r=e.distancePlaneAndPoint(t,n);return r>0?ty.Front:r<0?ty.Back:ty.Intersecting},e.intersectsPlaneAndBox=function(t,n){var r=n.min,a=n.max,i=t.normal,o=e._tempVec30,s=e._tempVec31;return(i.x>=0?(o.x=a.x,s.x=r.x):(o.x=r.x,s.x=a.x),i.y>=0?(o.y=a.y,s.y=r.y):(o.y=r.y,s.y=a.y),i.z>=0?(o.z=a.z,s.z=r.z):(o.z=r.z,s.z=a.z),0>e.distancePlaneAndPoint(t,o))?ty.Back:e.distancePlaneAndPoint(t,s)>0?ty.Front:ty.Intersecting},e.intersectsPlaneAndSphere=function(t,n){var r=n.center,a=n.radius,i=e.distancePlaneAndPoint(t,r);return i>a?ty.Front:i<-a?ty.Back:ty.Intersecting},e.intersectsRayAndPlane=function(e,t){var n=t.normal,r=tS.zeroTolerance,a=tT.dot(n,e.direction);if(Math.abs(a)<r)return -1;var i=tT.dot(n,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-r)return -1;o=0}return o},e.intersectsRayAndBox=function(e,t){var n=tS.zeroTolerance,r=e.origin,a=e.direction,i=t.min,o=t.max,s=a.x,l=a.y,c=a.z,u=r.x,d=r.y,h=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){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)<n){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 C=x;x=b,b=C}if((_=Math.max(x,_))>(f=Math.min(b,f)))return -1}if(Math.abs(c)<n){if(h<i.z||h>o.z)return -1}else{var S=1/c,T=(i.z-h)*S,A=(o.z-h)*S;if(T>A){var E=T;T=A,A=E}if((_=Math.max(T,_))>(f=Math.min(A,f)))return -1}return _},e.intersectsRayAndSphere=function(t,n){var r=t.origin,a=t.direction,i=n.center,o=n.radius,s=e._tempVec30;tT.subtract(r,i,s);var l=tT.dot(s,a),c=tT.dot(s,s)-o*o;if(l>0&&c>0)return -1;var u=l*l-c;if(u<0)return -1;var d=-l-Math.sqrt(u);return d<0&&(d=0),d},e.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)},e.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return tT.distanceSquared(e.center,t.center)<n*n},e.intersectsSphereAndBox=function(t,n){var r=t.center,a=n.max,i=n.min,o=e._tempVec30;return o.set(Math.max(i.x,Math.min(r.x,a.x)),Math.max(i.y,Math.min(r.y,a.y)),Math.max(i.z,Math.min(r.z,a.z))),tT.distanceSquared(r,o)<=t.radius*t.radius},e.intersectsFrustumAndBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=0;o<6;++o){var s=t.getPlane(o),l=s.normal;if(i.set(l.x>=0?a.x:r.x,l.y>=0?a.y:r.y,l.z>=0?a.z:r.z),tT.dot(l,i)<-s.distance)return!1}return!0},e.frustumContainsPoint=function(t,n){var r=e.distancePlaneAndPoint(t.near,n);return Math.abs(r)<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.far,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.left,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.right,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.top,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:Math.abs(r=e.distancePlaneAndPoint(t.bottom,n))<tS.zeroTolerance?tv.Intersects:r<0?tv.Disjoint:tv.Contains},e.frustumContainsBox=function(t,n){for(var r=n.min,a=n.max,i=e._tempVec30,o=e._tempVec31,s=tv.Contains,l=0;l<6;++l){var c=t.getPlane(l),u=c.normal;if(u.x>=0?(i.x=a.x,o.x=r.x):(i.x=r.x,o.x=a.x),u.y>=0?(i.y=a.y,o.y=r.y):(i.y=r.y,o.y=a.y),u.z>=0?(i.z=a.z,o.z=r.z):(i.z=r.z,o.z=a.z),e.intersectsPlaneAndPoint(c,i)===ty.Back)return tv.Disjoint;e.intersectsPlaneAndPoint(c,o)===ty.Back&&(s=tv.Intersects)}return s},e.frustumContainsSphere=function(t,n){for(var r=tv.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=e.intersectsPlaneAndSphere(i,n);if(o===ty.Back)return tv.Disjoint;if(o===ty.Intersecting){r=tv.Intersects;break}}return r},e}();tR._tempVec30=new tT,tR._tempVec31=new tT,tR._tempVec32=new tT;var tM=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new tT,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}var t=e.prototype;return t.normalize=function(){return e.normalize(this,this),this},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},e.normalize=function(e,t){var n=e.normal,r=1/n.length();tT.scale(n,r,t.normal),t.distance=e.distance*r},e.fromPoints=function(e,t,n,r){var a=e.x,i=e.y,o=e.z,s=t.x-a,l=t.y-i,c=t.z-o,u=n.x-a,d=n.y-i,h=n.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=r.normal;x.x=g,x.y=v,x.z=y,r.distance=-(g*a+v*i+y*o)},e}(),tw=/*#__PURE__*/function(){function e(e){void 0===e&&(e=null),this.near=new tM,this.far=new tM,this.left=new tM,this.right=new tM,this.top=new tM,this.bottom=new tM,e&&this.calculateFromMatrix(e)}var t=e.prototype;return t.getPlane=function(e){switch(e){case tx.Near:return this.near;case tx.Far:return this.far;case tx.Left:return this.left;case tx.Right:return this.right;case tx.Bottom:return this.bottom;case tx.Top:return this.top;default:return null}},t.calculateFromMatrix=function(e){var t=e.elements,n=t[0],r=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+n,c+o,_+u),this.left.distance=g+f,this.left.normalize(),this.right.normal.set(i-n,c-o,_-u),this.right.distance=g-f,this.right.normalize(),this.bottom.normal.set(i+r,c+s,_+d),this.bottom.distance=g+p,this.bottom.normalize(),this.top.normal.set(i-r,c-s,_-d),this.top.distance=g-p,this.top.normalize()},t.intersectsBox=function(e){return tR.intersectsFrustumAndBox(this,e)},t.intersectsSphere=function(e){return tR.frustumContainsSphere(this,e)!==tv.Disjoint},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.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},e}(),tP=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=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]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=a,c[5]=i,c[6]=o,c[7]=s,c[8]=l,this},t.add=function(t){return e.add(this,t,this),this},t.subtract=function(t){return e.subtract(this,t,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=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)+n*(-c*a+o*s)+r*(l*a-i*s)},t.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},t.invert=function(){return e.invert(this,this),this},t.rotate=function(t){return e.rotate(this,t,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<12;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8]},t.copyFromMatrix=function(e){var t=e.elements,n=this.elements;return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[4],n[4]=t[5],n[5]=t[6],n[6]=t[8],n[7]=t[9],n[8]=t[10],this},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8]},e.subtract=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]-a[0],i[1]=r[1]-a[1],i[2]=r[2]-a[2],i[3]=r[3]-a[3],i[4]=r[4]-a[4],i[5]=r[5]-a[5],i[6]=r[6]-a[6],i[7]=r[7]-a[7],i[8]=r[8]-a[8]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=a[0],m=a[1],g=a[2],v=a[3],y=a[4],x=a[5],b=a[6],C=a[7],S=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*C+h*S,i[7]=s*b+u*C+_*S,i[8]=l*b+d*C+f*S},e.equals=function(e,t){var n=e.elements,r=t.elements;return tS.equals(n[0],r[0])&&tS.equals(n[1],r[1])&&tS.equals(n[2],r[2])&&tS.equals(n[3],r[3])&&tS.equals(n[4],r[4])&&tS.equals(n[5],r[5])&&tS.equals(n[6],r[6])&&tS.equals(n[7],r[7])&&tS.equals(n[8],r[8])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[3]=d-v,n[6]=_+g,n[1]=d+v,n[4]=1-u-p,n[7]=f-m,n[2]=_-g,n[5]=f+m,n[8]=1-u-h},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=e._y,n[5]=0,n[6]=0,n[7]=0,n[8]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=1,n[5]=0,n[6]=e._x,n[7]=e._y,n[8]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[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,r[0]=_*m,r[1]=(-h*i+o*d)*m,r[2]=(c*i-o*l)*m,r[3]=f*m,r[4]=(h*a-o*u)*m,r[5]=(-c*a+o*s)*m,r[6]=p*m,r[7]=(-d*a+i*u)*m,r[8]=(l*a-i*s)*m)},e.normalMatrix=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,C=a*d-s*l,S=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+C*w+S*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(u*M-l*F-d*R)*L,r[2]=(l*P-c*M+d*E)*L,r[3]=(o*P-i*F-s*w)*L,r[4]=(a*F-o*M+s*R)*L,r[5]=(i*M-a*P-s*E)*L,r[6]=(g*A-v*T+y*S)*L,r[7]=(v*C-m*A-y*b)*L,r[8]=(m*T-g*C+y*x)*L},e.rotate=function(e,t,n){var r=e.elements,a=n.elements,i=Math.sin(t),o=Math.cos(t),s=r[0],l=r[1],c=r[2],u=r[3],d=r[4],h=r[5],_=r[6],f=r[7],p=r[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},e.scale=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.elements;o[0]=r*i[0],o[1]=r*i[1],o[2]=r*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]},e.translate=function(e,t,n){var r=t._x,a=t._y,i=e.elements,o=n.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]=r*s+a*u+_,o[7]=r*l+a*d+f,o[8]=r*c+a*h+p},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[5];r[1]=n[3],r[2]=n[6],r[3]=a,r[5]=n[7],r[6]=i,r[7]=o}else r[0]=n[0],r[1]=n[3],r[2]=n[6],r[3]=n[1],r[4]=n[4],r[5]=n[7],r[6]=n[2],r[7]=n[5],r[8]=n[8]},e}(),tF=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=1),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onValueChanged&&this._onValueChanged(),this},t.getAxisAngle=function(e){var t=this._x,n=this._y,r=this._z,a=t*t+n*n+r*r;if(a<tS.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)},t.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.normalize=function(){return e.normalize(this,this),this},t.toEuler=function(e){this._toYawPitchRoll(e);var t=e._x;return e._x=e._y,e._y=t,e._onValueChanged&&e._onValueChanged(),e},t.toYawPitchRoll=function(e){return this._toYawPitchRoll(e),e._onValueChanged&&e._onValueChanged(),e},t.rotateX=function(t){return e.rotateX(this,t,this),this},t.rotateY=function(t){return e.rotateY(this,t,this),this},t.rotateZ=function(t){return e.rotateZ(this,t,this),this},t.rotationAxisAngle=function(t,n){return e.rotationAxisAngle(t,n,this),this},t.multiply=function(t){return e.multiply(this,t,this),this},t.invert=function(){return e.invert(this,this),this},t.dot=function(t){return e.dot(this,t)},t.lerp=function(t,n){return e.lerp(this,t,n,this),this},t.rotateAxisAngle=function(t,n){return e._tempQuat1.rotationAxisAngle(t,n),this.multiply(e._tempQuat1),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.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},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.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},t.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},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},t._toYawPitchRoll=function(e){var t=this._x,n=this._y,r=this._z,a=this._w,i=t*t,o=n*n,s=r*r,l=a*a,c=i+o+s+l,u=2*(t*a-n*r);u>(1-tS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=Math.PI/2,e._z=0):u<-(1-tS.zeroTolerance)*c?(e._x=Math.atan2(2*(a*n-t*r),i+l-o-s),e._y=-Math.PI/2,e._z=0):(e._x=Math.atan2(2*(r*t+n*a),s+l-o-i),e._y=Math.asin(u/c),e._z=Math.atan2(2*(t*n+r*a),o+l-s-i))},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;n._x=r*u+o*s+a*c-i*l,n._y=a*u+o*l+i*s-r*c,n._z=i*u+o*c+r*l-a*s,n._w=o*u-r*s-a*l-i*c,n._onValueChanged&&n._onValueChanged()},e.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)&&tS.equals(e._w,t._w)},e.rotationAxisAngle=function(t,n,r){var a=e._tempVector3;tT.normalize(t,a);var i=Math.sin(n*=.5);r._x=a._x*i,r._y=a._y*i,r._z=a._z*i,r._w=Math.cos(n),r._onValueChanged&&r._onValueChanged()},e.rotationEuler=function(t,n,r,a){e.rotationYawPitchRoll(n,t,r,a)},e.rotationYawPitchRoll=function(e,t,n,r){var a=.5*n,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;r._x=h*c*l+d*u*s,r._y=d*u*l-h*c*s,r._z=_*s-f*l,r._w=_*l+f*s,r._onValueChanged&&r._onValueChanged()},e.rotationMatrix3x3=function(e,t){var n,r,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?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(u-h)*n,t._y=(d-s)*n,t._z=(o-l)*n):i>=c&&i>=_?(r=.5/(n=Math.sqrt(1+i-c-_)),t._x=.5*n,t._y=(o+l)*r,t._z=(s+d)*r,t._w=(u-h)*r):c>_?(r=.5/(n=Math.sqrt(1+c-i-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(h+u)*r,t._w=(d-s)*r):(r=.5/(n=Math.sqrt(1+_-i-c)),t._x=(s+d)*r,t._y=(u+h)*r,t._z=.5*n,t._w=(o-l)*r),t._onValueChanged&&t._onValueChanged()},e.invert=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=n*n+r*r+a*a+i*i;if(o>tS.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-a*s,t._w=i*s,t._onValueChanged&&t._onValueChanged()}},e.lerp=function(t,n,r,a){var i=1-r;e.dot(t,n)>=0?(a._x=t._x*i+n._x*r,a._y=t._y*i+n._y*r,a._z=t._z*i+n._z*r,a._w=t._w*i+n._w*r):(a._x=t._x*i-n._x*r,a._y=t._y*i-n._y*r,a._z=t._z*i-n._z*r,a._w=t._w*i-n._w*r),a.normalize()},e.slerp=function(t,n,r,a){var i,o,s=e.dot(t,n);if(Math.abs(s)>1-tS.zeroTolerance)o=1-r,i=r*Math.sign(s);else{var l=Math.acos(Math.abs(s)),c=1/Math.sin(l);o=Math.sin((1-r)*l)*c,i=Math.sin(r*l)*c*Math.sign(s)}a.x=o*t.x+i*n.x,a.y=o*t.y+i*n.y,a.z=o*t.z+i*n.z,a.w=o*t.w+i*n.w,a._onValueChanged&&a._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tS.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.rotationX=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=n,t._y=0,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationY=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=n,t._z=0,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotationZ=function(e,t){var n=Math.sin(e*=.5),r=Math.cos(e);t._x=0,t._y=0,t._z=n,t._w=r,t._onValueChanged&&t._onValueChanged()},e.rotateX=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+o*s,n._y=a*l+i*s,n._z=i*l-a*s,n._w=o*l-r*s,n._onValueChanged&&n._onValueChanged()},e.rotateY=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l-i*s,n._y=a*l+o*s,n._z=i*l+r*s,n._w=o*l-a*s,n._onValueChanged&&n._onValueChanged()},e.rotateZ=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+a*s,n._y=a*l-r*s,n._z=i*l+o*s,n._w=o*l-i*s,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"normalized",get:function(){return Math.abs(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w-1)<tS.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tF._tempVector3=new tT,tF._tempQuat1=new tF;var tL=/*#__PURE__*/function(){function e(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=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]=n,m[3]=r,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}var t=e.prototype;return t.set=function(e,t,n,r,a,i,o,s,l,c,u,d,h,_,f,p){var m=this.elements;return m[0]=e,m[1]=t,m[2]=n,m[3]=r,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},t.multiply=function(t){return e.multiply(this,t,this),this},t.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=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-n*i)*(d*m-h*p)-(t*s-r*i)*(u*m-h*f)+(t*l-a*i)*(u*p-d*f)+(n*s-r*o)*(c*m-h*_)-(n*l-a*o)*(c*p-d*_)+(r*l-a*s)*(c*f-u*_)},t.decompose=function(t,n,r){var a=e._tempMat30,i=this.elements,o=a.elements,s=i[0],l=i[1],c=i[2],u=i[4],d=i[5],h=i[6],_=i[8],f=i[9],p=i[10];t.set(i[12],i[13],i[14]);var m=Math.sqrt(s*s+l*l+c*c),g=Math.sqrt(u*u+d*d+h*h),v=Math.sqrt(_*_+f*f+p*p);if(0>this.determinant()&&(m=-m),r.set(m,g,v),Math.abs(m)<tS.zeroTolerance||Math.abs(g)<tS.zeroTolerance||Math.abs(v)<tS.zeroTolerance)return n.identity(),!1;var y=1/m,x=1/g,b=1/v;return o[0]=s*y,o[1]=l*y,o[2]=c*y,o[3]=u*x,o[4]=d*x,o[5]=h*x,o[6]=_*b,o[7]=f*b,o[8]=p*b,tF.rotationMatrix3x3(a,n),!0},t.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>tS.zeroTolerance){var r=2*Math.sqrt(n+1);e._w=.25*r,e._x=(t[6]-t[9])/r,e._y=(t[8]-t[2])/r,e._z=(t[1]-t[4])/r}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},t.getScaling=function(e){var t=this.elements,n=t[0],r=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(n*n+r*r+a*a),Math.sqrt(i*i+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),e},t.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},t.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},t.invert=function(){return e.invert(this,this),this},t.rotateAxisAngle=function(t,n){return e.rotateAxisAngle(this,t,n,this),this},t.scale=function(t){return e.scale(this,t,this),this},t.translate=function(t){return e.translate(this,t,this),this},t.transpose=function(){return e.transpose(this,this),this},t.clone=function(){var t=this.elements;return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])},t.copyFrom=function(e){var t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this},t.copyFromArray=function(e,t){void 0===t&&(t=0);for(var n=this.elements,r=0;r<16;r++)n[r]=e[r+t];return this},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.elements;e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15]},e.multiply=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],_=r[7],f=r[8],p=r[9],m=r[10],g=r[11],v=r[12],y=r[13],x=r[14],b=r[15],C=a[0],S=a[1],T=a[2],A=a[3],E=a[4],R=a[5],M=a[6],w=a[7],P=a[8],F=a[9],L=a[10],D=a[11],B=a[12],I=a[13],O=a[14],N=a[15];i[0]=o*C+u*S+f*T+v*A,i[1]=s*C+d*S+p*T+y*A,i[2]=l*C+h*S+m*T+x*A,i[3]=c*C+_*S+g*T+b*A,i[4]=o*E+u*R+f*M+v*w,i[5]=s*E+d*R+p*M+y*w,i[6]=l*E+h*R+m*M+x*w,i[7]=c*E+_*R+g*M+b*w,i[8]=o*P+u*F+f*L+v*D,i[9]=s*P+d*F+p*L+y*D,i[10]=l*P+h*F+m*L+x*D,i[11]=c*P+_*F+g*L+b*D,i[12]=o*B+u*I+f*O+v*N,i[13]=s*B+d*I+p*O+y*N,i[14]=l*B+h*I+m*O+x*N,i[15]=c*B+_*I+g*O+b*N},e.equals=function(e,t){var n=e.elements,r=t.elements;return tS.equals(n[0],r[0])&&tS.equals(n[1],r[1])&&tS.equals(n[2],r[2])&&tS.equals(n[3],r[3])&&tS.equals(n[4],r[4])&&tS.equals(n[5],r[5])&&tS.equals(n[6],r[6])&&tS.equals(n[7],r[7])&&tS.equals(n[8],r[8])&&tS.equals(n[9],r[9])&&tS.equals(n[10],r[10])&&tS.equals(n[11],r[11])&&tS.equals(n[12],r[12])&&tS.equals(n[13],r[13])&&tS.equals(n[14],r[14])&&tS.equals(n[15],r[15])},e.lerp=function(e,t,n,r){var a=e.elements,i=t.elements,o=r.elements,s=1-n;o[0]=a[0]*s+i[0]*n,o[1]=a[1]*s+i[1]*n,o[2]=a[2]*s+i[2]*n,o[3]=a[3]*s+i[3]*n,o[4]=a[4]*s+i[4]*n,o[5]=a[5]*s+i[5]*n,o[6]=a[6]*s+i[6]*n,o[7]=a[7]*s+i[7]*n,o[8]=a[8]*s+i[8]*n,o[9]=a[9]*s+i[9]*n,o[10]=a[10]*s+i[10]*n,o[11]=a[11]*s+i[11]*n,o[12]=a[12]*s+i[12]*n,o[13]=a[13]*s+i[13]*n,o[14]=a[14]*s+i[14]*n,o[15]=a[15]*s+i[15]*n},e.add=function(e,t,n){var r=e.elements,a=t.elements,i=n.elements;i[0]=r[0]+a[0],i[1]=r[1]+a[1],i[2]=r[2]+a[2],i[3]=r[3]+a[3],i[4]=r[4]+a[4],i[5]=r[5]+a[5],i[6]=r[6]+a[6],i[7]=r[7]+a[7],i[8]=r[8]+a[8],i[9]=r[9]+a[9],i[10]=r[10]+a[10],i[11]=r[11]+a[11],i[12]=r[12]+a[12],i[13]=r[13]+a[13],i[14]=r[14]+a[14],i[15]=r[15]+a[15]},e.multiplyScalar=function(e,t,n){var r=e.elements,a=n.elements;a[0]=r[0]*t,a[1]=r[1]*t,a[2]=r[2]*t,a[3]=r[3]*t,a[4]=r[4]*t,a[5]=r[5]*t,a[6]=r[6]*t,a[7]=r[7]*t,a[8]=r[8]*t,a[9]=r[9]*t,a[10]=r[10]*t,a[11]=r[11]*t,a[12]=r[12]*t,a[13]=r[13]*t,a[14]=r[14]*t,a[15]=r[15]*t},e.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,a=e._y,i=e._z,o=e._w,s=r+r,l=a+a,c=i+i,u=r*s,d=a*s,h=a*l,_=i*s,f=i*l,p=i*c,m=o*s,g=o*l,v=o*c;n[0]=1-h-p,n[1]=d+v,n[2]=_-g,n[3]=0,n[4]=d-v,n[5]=1-u-p,n[6]=f+m,n[7]=0,n[8]=_+g,n[9]=f-m,n[10]=1-u-h,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.rotationAxisAngle=function(e,t,n){var r,a,i,o=n.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<tS.zeroTolerance||(s*=u=1/u,l*=u,c*=u,r=Math.sin(t),i=1-(a=Math.cos(t)),o[0]=s*s*i+a,o[1]=l*s*i+c*r,o[2]=c*s*i-l*r,o[3]=0,o[4]=s*l*i-c*r,o[5]=l*l*i+a,o[6]=c*l*i+s*r,o[7]=0,o[8]=s*c*i+l*r,o[9]=l*c*i-s*r,o[10]=c*c*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},e.rotationTranslation=function(t,n,r){e.rotationQuaternion(t,r);var a=r.elements;a[12]=n._x,a[13]=n._y,a[14]=n._z},e.affineTransformation=function(e,t,n,r){var a=r.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,C=e._y,S=e._z;a[0]=(1-(p+g))*b,a[1]=(_+x)*b,a[2]=(f-y)*b,a[3]=0,a[4]=(_-x)*C,a[5]=(1-(h+g))*C,a[6]=(m+v)*C,a[7]=0,a[8]=(f+y)*S,a[9]=(m-v)*S,a[10]=(1-(h+p))*S,a[11]=0,a[12]=n._x,a[13]=n._y,a[14]=n._z,a[15]=1},e.scaling=function(e,t){var n=t.elements;n[0]=e._x,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=e._y,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=e._z,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},e.translation=function(e,t){var n=t.elements;n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=e._x,n[13]=e._y,n[14]=e._z,n[15]=1},e.invert=function(e,t){var n=e.elements,r=t.elements,a=n[0],i=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],d=n[7],h=n[8],_=n[9],f=n[10],p=n[11],m=n[12],g=n[13],v=n[14],y=n[15],x=a*c-i*l,b=a*u-o*l,C=a*d-s*l,S=i*u-o*c,T=i*d-s*c,A=o*d-s*u,E=h*g-_*m,R=h*v-f*m,M=h*y-p*m,w=_*v-f*g,P=_*y-p*g,F=f*y-p*v,L=x*F-b*P+C*w+S*M-T*R+A*E;if(!L)return null;L=1/L,r[0]=(c*F-u*P+d*w)*L,r[1]=(o*P-i*F-s*w)*L,r[2]=(g*A-v*T+y*S)*L,r[3]=(f*T-_*A-p*S)*L,r[4]=(u*M-l*F-d*R)*L,r[5]=(a*F-o*M+s*R)*L,r[6]=(v*C-m*A-y*b)*L,r[7]=(h*A-f*C+p*b)*L,r[8]=(l*P-c*M+d*E)*L,r[9]=(i*M-a*P-s*E)*L,r[10]=(m*T-g*C+y*x)*L,r[11]=(_*C-h*T-p*x)*L,r[12]=(c*R-l*w-u*E)*L,r[13]=(a*w-i*R+o*E)*L,r[14]=(g*b-m*S-v*x)*L,r[15]=(h*S-_*b+f*x)*L},e.lookAt=function(t,n,r,a){var i=a.elements,o=e._tempVec30,s=e._tempVec31,l=e._tempVec32;tT.subtract(t,n,l),l.normalize(),tT.cross(r,l,o),o.normalize(),tT.cross(l,o,s),i[0]=o._x,i[1]=s._x,i[2]=l._x,i[3]=0,i[4]=o._y,i[5]=s._y,i[6]=l._y,i[7]=0,i[8]=o._z,i[9]=s._z,i[10]=l._z,i[11]=0,i[12]=-tT.dot(o,t),i[13]=-tT.dot(s,t),i[14]=-tT.dot(l,t),i[15]=1},e.ortho=function(e,t,n,r,a,i,o){var s=o.elements,l=1/(e-t),c=1/(n-r),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]=(r+n)*c,s[14]=(i+a)*u,s[15]=1},e.perspective=function(e,t,n,r,a){var i=a.elements,o=1/Math.tan(e/2),s=1/(n-r);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]=(r+n)*s,i[11]=-1,i[12]=0,i[13]=0,i[14]=2*r*n*s,i[15]=0},e.rotateAxisAngle=function(e,t,n,r){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)<tS.zeroTolerance)){var d=e.elements,h=r.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(n),o=1-(i=Math.cos(n));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],C=d[9],S=d[10],T=d[11],A=s*s*o+i,E=l*s*o+c*a,R=c*s*o-l*a,M=s*l*o-c*a,w=l*l*o+i,P=c*l*o+s*a,F=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;h[0]=_*A+g*E+b*R,h[1]=f*A+v*E+C*R,h[2]=p*A+y*E+S*R,h[3]=m*A+x*E+T*R,h[4]=_*M+g*w+b*P,h[5]=f*M+v*w+C*P,h[6]=p*M+y*w+S*P,h[7]=m*M+x*w+T*P,h[8]=_*F+g*L+b*D,h[9]=f*F+v*L+C*D,h[10]=p*F+y*L+S*D,h[11]=m*F+x*L+T*D,e!==r&&(h[12]=d[12],h[13]=d[13],h[14]=d[14],h[15]=d[15])}},e.scale=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;a[0]=r[0]*i,a[1]=r[1]*i,a[2]=r[2]*i,a[3]=r[3]*i,a[4]=r[4]*o,a[5]=r[5]*o,a[6]=r[6]*o,a[7]=r[7]*o,a[8]=r[8]*s,a[9]=r[9]*s,a[10]=r[10]*s,a[11]=r[11]*s,a[12]=r[12],a[13]=r[13],a[14]=r[14],a[15]=r[15]},e.translate=function(e,t,n){var r=e.elements,a=n.elements,i=t._x,o=t._y,s=t._z;if(e===n)a[12]=r[0]*i+r[4]*o+r[8]*s+r[12],a[13]=r[1]*i+r[5]*o+r[9]*s+r[13],a[14]=r[2]*i+r[6]*o+r[10]*s+r[14],a[15]=r[3]*i+r[7]*o+r[11]*s+r[15];else{var l=r[0],c=r[1],u=r[2],d=r[3],h=r[4],_=r[5],f=r[6],p=r[7],m=r[8],g=r[9],v=r[10],y=r[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+r[12],a[13]=c*i+_*o+g*s+r[13],a[14]=u*i+f*o+v*s+r[14],a[15]=d*i+p*o+y*s+r[15]}},e.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var a=n[1],i=n[2],o=n[3],s=n[6],l=n[7],c=n[11];r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=a,r[6]=n[9],r[7]=n[13],r[8]=i,r[9]=s,r[11]=n[14],r[12]=o,r[13]=l,r[14]=c}else r[0]=n[0],r[1]=n[4],r[2]=n[8],r[3]=n[12],r[4]=n[1],r[5]=n[5],r[6]=n[9],r[7]=n[13],r[8]=n[2],r[9]=n[6],r[10]=n[10],r[11]=n[14],r[12]=n[3],r[13]=n[7],r[14]=n[11],r[15]=n[15]},e}();tL._tempVec30=new tT,tL._tempVec31=new tT,tL._tempVec32=new tT,tL._tempMat30=new tP,tL._identity=new tL(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var tD=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new tT,this.direction=new tT,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}var t=e.prototype;return t.intersectPlane=function(e){return tR.intersectsRayAndPlane(this,e)},t.intersectSphere=function(e){return tR.intersectsRayAndSphere(this,e)},t.intersectBox=function(e){return tR.intersectsRayAndBox(this,e)},t.getPoint=function(e,t){return tT.scale(this.direction,e,t),t.add(this.origin)},e}(),tB=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}var t=e.prototype;return t.set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},t.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},t.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},t.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},t.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},t.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},t.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y)},t.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e},t.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},t.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},t.toJSON=function(){return{x:this._x,y:this._y}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y;return Math.sqrt(n*n+r*r)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y;return n*n+r*r},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=Math.sqrt(n*n+r*r);a>tS.zeroTolerance&&(a=1/a,t._x=n*a,t._y=r*a,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tB._zero=new tB(0,0),tB._one=new tB(1,1);var tI=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._z=n,this._w=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},t.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},t.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},t.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},t.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},t.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},t.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},t.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},t.normalize=function(){return e.normalize(this,this),this},t.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._x,this._y,this._z,this._w)},t.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},t.copyTo=function(e){return e.x=this._x,e.y=this._y,e.z=this._z,e.w=this._w,e},t.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},t.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},t.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},e.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._w=e._w+t._w,n._onValueChanged&&n._onValueChanged()},e.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._z=e._z-t._z,n._w=e._w-t._w,n._onValueChanged&&n._onValueChanged()},e.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._z=e._z*t._z,n._w=e._w*t._w,n._onValueChanged&&n._onValueChanged()},e.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._z=e._z/t._z,n._w=e._w/t._w,n._onValueChanged&&n._onValueChanged()},e.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},e.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return Math.sqrt(n*n+r*r+a*a+i*i)},e.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,a=t._z-e._z,i=t._w-e._w;return n*n+r*r+a*a+i*i},e.equals=function(e,t){return tS.equals(e._x,t._x)&&tS.equals(e._y,t._y)&&tS.equals(e._z,t._z)&&tS.equals(e._w,t._w)},e.lerp=function(e,t,n,r){var a=e._x,i=e._y,o=e._z,s=e._w;r._x=a+(t._x-a)*n,r._y=i+(t._y-i)*n,r._z=o+(t._z-o)*n,r._w=s+(t._w-s)*n,r._onValueChanged&&r._onValueChanged()},e.max=function(e,t,n){n._x=Math.max(e._x,t._x),n._y=Math.max(e._y,t._y),n._z=Math.max(e._z,t._z),n._w=Math.max(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.min=function(e,t,n){n._x=Math.min(e._x,t._x),n._y=Math.min(e._y,t._y),n._z=Math.min(e._z,t._z),n._w=Math.min(e._w,t._w),n._onValueChanged&&n._onValueChanged()},e.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},e.normalize=function(e,t){var n=e._x,r=e._y,a=e._z,i=e._w,o=Math.sqrt(n*n+r*r+a*a+i*i);o>tS.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},e.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._w=e._w*t,n._onValueChanged&&n._onValueChanged()},e.transform=function(e,t,n){var r=e._x,a=e._y,i=e._z,o=e._w,s=t.elements;n._x=r*s[0]+a*s[4]+i*s[8]+o*s[12],n._y=r*s[1]+a*s[5]+i*s[9]+o*s[13],n._z=r*s[2]+a*s[6]+i*s[10]+o*s[14],n._w=r*s[3]+a*s[7]+i*s[11]+o*s[15],n._onValueChanged&&n._onValueChanged()},e.transformByQuat=function(e,t,n){var r=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*r+l*i-c*a,h=u*a+c*r-s*i,_=u*i+s*a-l*r,f=-s*r-l*a-c*i;n._x=d*u-f*s-h*c+_*l,n._y=h*u-f*l-_*s+d*c,n._z=_*u-f*c-d*l+h*s,n._w=o,n._onValueChanged&&n._onValueChanged()},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),e}();tI._zero=new tI(0,0,0,0),tI._one=new tI(1,1,1,1);var tO=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=n,this._a=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},t.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},t.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this._r,this._g,this._b,this._a)},t.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},t.copyTo=function(e){return e.r=this._r,e.g=this._g,e.b=this._b,e.a=this._a,e},t.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},t.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},t.toLinear=function(t){return t._r=e.gammaToLinearSpace(this._r),t._g=e.gammaToLinearSpace(this._g),t._b=e.gammaToLinearSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.toGamma=function(t){return t._r=e.linearToGammaSpace(this._r),t._g=e.linearToGammaSpace(this._g),t._b=e.linearToGammaSpace(this._b),t._onValueChanged&&t._onValueChanged(),t},t.getBrightness=function(){var e=this.r,t=this.g,n=this.b,r=e,a=e;return t>r&&(r=t),n>r&&(r=n),t<a&&(a=t),n<a&&(a=n),(r+a)/2},t.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},e.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},e.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},e.equals=function(e,t){return tS.equals(e._r,t._r)&&tS.equals(e._g,t._g)&&tS.equals(e._b,t._b)&&tS.equals(e._a,t._a)},e.add=function(e,t,n){return n._r=e._r+t._r,n._g=e._g+t._g,n._b=e._b+t._b,n._a=e._a+t._a,n._onValueChanged&&n._onValueChanged(),n},e.subtract=function(e,t,n){n._r=e._r-t._r,n._g=e._g-t._g,n._b=e._b-t._b,n._a=e._a-t._a,n._onValueChanged&&n._onValueChanged()},e.scale=function(e,t,n){return n._r=e._r*t,n._g=e._g*t,n._b=e._b*t,n._a=e._a*t,n._onValueChanged&&n._onValueChanged(),n},e.lerp=function(e,t,n,r){var a=e._r,i=e._g,o=e._b,s=e._a;return r._r=a+(t._r-a)*n,r._g=i+(t._g-i)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},tC(e,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),e}(),tN=/*#__PURE__*/function(){function e(e,t,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._onValueChanged=null,this._x=e,this._y=t,this._width=n,this._height=r}var t=e.prototype;return t.set=function(e,t,n,r){return this._x=e,this._y=t,this._width=n,this._height=r,this._onValueChanged&&this._onValueChanged(),this},t.clone=function(){return new e(this.x,this.y,this.width,this.height)},t.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},tC(e,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"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()}}]),e}(),tV=/*#__PURE__*/function(){function e(){this.coefficients=new Float32Array(27)}var t=e.prototype;return t.addLight=function(e,t,n){t.scale(n);var r=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,_=a*i*1.092548,f=-(i*o*1.092548),p=.315392*(3*o*o-1),m=-(a*o*1.092548),g=.546274*(a*a-i*i);r[0]+=.282095*s,r[1]+=.282095*l,r[2]+=.282095*c,r[3]+=s*u,r[4]+=l*u,r[5]+=c*u,r[6]+=s*d,r[7]+=l*d,r[8]+=c*d,r[9]+=s*h,r[10]+=l*h,r[11]+=c*h,r[12]+=s*_,r[13]+=l*_,r[14]+=c*_,r[15]+=s*f,r[16]+=l*f,r[17]+=c*f,r[18]+=s*p,r[19]+=l*p,r[20]+=c*p,r[21]+=s*m,r[22]+=l*m,r[23]+=c*m,r[24]+=s*g,r[25]+=l*g,r[26]+=c*g},t.evaluate=function(e,t){var n=this.coefficients,r=e._x,a=e._y,i=e._z,o=-1.023327*a,s=1.023327*i,l=-1.023327*r,c=.858086*a*r,u=-.858086*a*i,d=.247708*(3*i*i-1),h=-.858086*i*r,_=.429042*(r*r-a*a),f=.886227*n[0],p=.886227*n[1],m=.886227*n[2];return f+=n[3]*o+n[6]*s+n[9]*l,p+=n[4]*o+n[7]*s+n[10]*l,m+=n[5]*o+n[8]*s+n[11]*l,f+=n[12]*c+n[15]*u+n[18]*d+n[21]*h+n[24]*_,p+=n[13]*c+n[16]*u+n[19]*d+n[22]*h+n[25]*_,m+=n[14]*c+n[17]*u+n[20]*d+n[23]*h+n[26]*_,t.set(f,p,m,1),t},t.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},t.clone=function(){var t=new e;return t.copyFrom(this),t},t.copyFrom=function(e){return e.copyToArray(this.coefficients),this},t.copyFromArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;n[0]=e[t],n[1]=e[1+t],n[2]=e[2+t],n[3]=e[3+t],n[4]=e[4+t],n[5]=e[5+t],n[6]=e[6+t],n[7]=e[7+t],n[8]=e[8+t],n[9]=e[9+t],n[10]=e[10+t],n[11]=e[11+t],n[12]=e[12+t],n[13]=e[13+t],n[14]=e[14+t],n[15]=e[15+t],n[16]=e[16+t],n[17]=e[17+t],n[18]=e[18+t],n[19]=e[19+t],n[20]=e[20+t],n[21]=e[21+t],n[22]=e[22+t],n[23]=e[23+t],n[24]=e[24+t],n[25]=e[25+t],n[26]=e[26+t]},t.copyToArray=function(e,t){void 0===t&&(t=0);var n=this.coefficients;e[0+t]=n[0],e[1+t]=n[1],e[2+t]=n[2],e[3+t]=n[3],e[4+t]=n[4],e[5+t]=n[5],e[6+t]=n[6],e[7+t]=n[7],e[8+t]=n[8],e[9+t]=n[9],e[10+t]=n[10],e[11+t]=n[11],e[12+t]=n[12],e[13+t]=n[13],e[14+t]=n[14],e[15+t]=n[15],e[16+t]=n[16],e[17+t]=n[17],e[18+t]=n[18],e[19+t]=n[19],e[20+t]=n[20],e[21+t]=n[21],e[22+t]=n[22],e[23+t]=n[23],e[24+t]=n[24],e[25+t]=n[25],e[26+t]=n[26]},e}(),tk=/*#__PURE__*/function(){function e(e,t){this.reset(e,t)}var t=e.prototype;return t.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},t.random=function(){return this.randomInt32()/0xffffffff},t.reset=function(e,t){this._state0=e>>>0,this._state1=t>>>0},e}(),tz=((i={})[i.Android=0]="Android",i[i.IPhone=1]="IPhone",i[i.IPad=2]="IPad",i[i.Mac=3]="Mac",i[i.Unknown=4]="Unknown",i);function tU(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function tG(e,t,n){return t&&tU(e.prototype,t),n&&tU(e,n),e}function tH(e,t){return(tH=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function tW(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&&tH(e,t)}var tj=/*#__PURE__*/function(){function e(){this.localPositions=new tI}return e.prototype.dispose=function(){this.texture=null,this.localPositions=null,this.uvs=null},e}();function tX(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function tK(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}tj.triangles=[0,2,1,2,0,3],"function"==typeof SuppressedError&&SuppressedError;var tY=((o={})[o.Ignore=0]="Ignore",o[o.Assignment=1]="Assignment",o[o.Shallow=2]="Shallow",o[o.Deep=3]="Deep",o);function tq(e,t){t$.registerCloneMode(e,t,tY.Ignore)}function tQ(e,t){t$.registerCloneMode(e,t,tY.Assignment)}function tJ(e,t){t$.registerCloneMode(e,t,tY.Shallow)}function tZ(e,t){t$.registerCloneMode(e,t,tY.Deep)}var t$=/*#__PURE__*/function(){function e(){}return e.registerCloneMode=function(t,n,r){var a=e._subCloneModeMap.get(t.constructor);a||(a=Object.create(null),e._subCloneModeMap.set(t.constructor,a)),a[n]=r},e.getCloneMode=function(t){var n=e._cloneModeMap.get(t);if(!n){n=Object.create(null),e._cloneModeMap.set(t,n);for(var r=e._objectType,a=e._subCloneModeMap;t!==r;){var i=a.get(t);i&&Object.assign(n,i),t=Object.getPrototypeOf(t)}}return n},e.cloneProperty=function(t,n,r,a,i,o,s){if(a!==tY.Ignore){var l=t[r];if(tK(l,Object)){if(void 0===a||a===tY.Assignment){n[r]=l;return}switch(l.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var c=n[r];null==c||c.length!==l.length?n[r]=l.slice():c.set(l);break;case Array:var u=n[r],d=l.length;null==u?n[r]=u=Array(d):u.length=d;for(var h=0;h<d;h++)e.cloneProperty(l,u,h,a,i,o,s);break;default:var _=n[r];if(_||((_=s.get(l))||(_=new l.constructor,s.set(l,_)),n[r]=_),l.copyFrom)_.copyFrom(l);else{var f=e.getCloneMode(l.constructor);for(var p in l)e.cloneProperty(l,_,p,f[p],i,o,s);l._cloneTo&&l._cloneTo(_,i,o)}}}else n[r]=l}},e.deepCloneObject=function(t,n,r){for(var a in t)e.cloneProperty(t,n,a,tY.Deep,null,null,r)},e}();t$._subCloneModeMap=new Map,t$._cloneModeMap=new Map,t$._objectType=Object.getPrototypeOf(Object);var t0=/*#__PURE__*/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)},tG(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();t0._instanceIdCounter=0,tX([tq],t0.prototype,"instanceId",void 0),tX([tq],t0.prototype,"_engine",void 0);var t1=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).isGCIgnored=!1,n._refCount=0,n._superResources=null,t.resourceManager._addReferResource(n),n}tW(t,e);var n=t.prototype;return n.destroy=function(t,n){if(void 0===t&&(t=!1),!t){if(0!==this._refCount)return!1;var r=this._superResources;if(null==r?void 0:r.length){if(!n)return!1;for(var a=0,i=r.length;a<i;a++)if(r[a].refCount>0)return!1}}return e.prototype.destroy.call(this),!0},n._associationSuperResource=function(e){(this._superResources||(this._superResources=[])).push(e)},n._disassociationSuperResource=function(e){var t=this._superResources,n=t.indexOf(e);t.splice(n,1)},n._getReferCount=function(){return this._refCount},n._addReferCount=function(e){this._refCount+=e},n._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var t=this._getReferCount();t>0&&this._addReferCount(-t)},tG(t,[{key:"refCount",get:function(){return this._refCount}}]),t}(t0),t2=function(e){this.resource=e},t3=((s={})[s.Depth=27]="Depth",s[s.Stencil=28]="Stencil",s[s.DepthStencil=29]="DepthStencil",s[s.Depth16=30]="Depth16",s[s.Depth24=31]="Depth24",s[s.Depth32=32]="Depth32",s[s.Depth24Stencil8=33]="Depth24Stencil8",s[s.Depth32Stencil8=34]="Depth32Stencil8",s),t4=((l={})[l.PositiveX=0]="PositiveX",l[l.NegativeX=1]="NegativeX",l[l.PositiveY=2]="PositiveY",l[l.NegativeY=3]="NegativeY",l[l.PositiveZ=4]="PositiveZ",l[l.NegativeZ=5]="NegativeZ",l),t8=((c={})[c.Never=0]="Never",c[c.Less=1]="Less",c[c.Equal=2]="Equal",c[c.LessEqual=3]="LessEqual",c[c.Greater=4]="Greater",c[c.NotEqual=5]="NotEqual",c[c.GreaterEqual=6]="GreaterEqual",c[c.Always=7]="Always",c),t5=((u={})[u.Point=0]="Point",u[u.Bilinear=1]="Bilinear",u[u.Trilinear=2]="Trilinear",u),t9=((d={})[d.R8G8B8=0]="R8G8B8",d[d.R8G8B8A8=1]="R8G8B8A8",d[d.R4G4B4A4=2]="R4G4B4A4",d[d.R5G5B5A1=3]="R5G5B5A1",d[d.R5G6B5=4]="R5G6B5",d[d.Alpha8=5]="Alpha8",d[d.LuminanceAlpha=6]="LuminanceAlpha",d[d.R16G16B16A16=7]="R16G16B16A16",d[d.R32G32B32A32=8]="R32G32B32A32",d[d.R32G32B32A32_UInt=9]="R32G32B32A32_UInt",d[d.R11G11B10_UFloat=35]="R11G11B10_UFloat",d[d.BC1=10]="BC1",d[d.BC3=11]="BC3",d[d.BC7=12]="BC7",d[d.ETC1_RGB=13]="ETC1_RGB",d[d.ETC2_RGB=14]="ETC2_RGB",d[d.ETC2_RGBA5=15]="ETC2_RGBA5",d[d.ETC2_RGBA8=16]="ETC2_RGBA8",d[d.PVRTC_RGB2=17]="PVRTC_RGB2",d[d.PVRTC_RGBA2=18]="PVRTC_RGBA2",d[d.PVRTC_RGB4=19]="PVRTC_RGB4",d[d.PVRTC_RGBA4=20]="PVRTC_RGBA4",d[d.ASTC_4x4=21]="ASTC_4x4",d[d.ASTC_5x5=22]="ASTC_5x5",d[d.ASTC_6x6=23]="ASTC_6x6",d[d.ASTC_8x8=24]="ASTC_8x8",d[d.ASTC_10x10=25]="ASTC_10x10",d[d.ASTC_12x12=26]="ASTC_12x12",d[d.Depth=27]="Depth",d[d.Stencil=28]="Stencil",d[d.DepthStencil=29]="DepthStencil",d[d.Depth16=30]="Depth16",d[d.Depth24=31]="Depth24",d[d.Depth32=32]="Depth32",d[d.Depth24Stencil8=33]="Depth24Stencil8",d[d.Depth32Stencil8=34]="Depth32Stencil8",d[d.DXT1=10]="DXT1",d[d.DXT5=11]="DXT5",d),t6=((h={})[h.Static=0]="Static",h[h.Dynamic=1]="Dynamic",h),t7=((_={})[_.Clamp=0]="Clamp",_[_.Repeat=1]="Repeat",_[_.Mirror=2]="Mirror",_),ne=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._isContentLost=!1,t.resourceManager._addGraphicResource(n),n}return tW(t,e),t.prototype._onDestroy=function(){e.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},tG(t,[{key:"isContentLost",get:function(){return this._isContentLost}}]),t}(t1),nt=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},nn=console.log.bind(console),nr=console.info.bind(console),na=console.warn.bind(console),ni=console.error.bind(console),no={debug:nt,info:nt,warn:nt,error:nt,isEnabled:!1,enable:function(){this.debug=nn,this.info=nr,this.warn=na,this.error=ni,this.isEnabled=!0},disable:function(){this.debug=nt,this.info=nt,this.warn=nt,this.error=nt,this.isEnabled=!1}},ns=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._isDepthTexture=!1,t._anisoLevel=1,t._useDepthCompareMode=!1,t}tW(t,e);var n=t.prototype;return n.generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},n._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},n._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))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},n._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},n._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},n._isIntFormat=function(){return t9.R32G32B32A32_UInt===this._format},tG(t,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){if(e!==this._filterMode){if(e!==t5.Point&&this._isIntFormat()){e=t5.Point,no.warn("Int or UInt format texture only support TextureFilterMode.Point");return}this._filterMode=e,this._platformTexture.filterMode=e}}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(no.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(no.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)}}]),t}(ne),nl=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){if(void 0===i&&(i=t9.Depth),void 0===o&&(o=1),(s=e.call(this,t)||this)._depthFormat=null,s._autoGenerateMipmaps=!0,s._depthTexture=null,s._width=n,s._height=r,s._antiAliasing=o,s._depth=i,a){for(var s,l=tK(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(tK(i,ns)){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(s),s}tW(t,e);var n=t.prototype;return n.getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},n.generateMipmaps=function(){if(this._autoGenerateMipmaps){for(var e=this._colorTextures,t=0,n=e.length;t<n;t++)e[t].generateMipmaps();this._depthTexture&&this._depthTexture.generateMipmaps()}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var t,n=this._colorTextures,r=0,a=n.length;r<a;r++)n[r]._addReferCount(-1);n.length=0,null==(t=this._depthTexture)||t._addReferCount(-1),this._depthTexture=null,this._depth=null},n._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},n._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},tG(t,[{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}}]),t}(ne),nc=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===a&&(a=t9.R8G8B8A8),void 0===i&&(i=!0),void 0===o&&(o=t6.Static),(s=e.call(this,t)||this)._mipmap=i,s._width=n,s._height=r,s._usage=o,s._format=a,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=a==t9.Depth||a==t9.DepthStencil||a==t9.Depth16||a==t9.Depth24||a==t9.Depth32||a==t9.Depth24Stencil8||a==t9.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s),s.filterMode=s._isIntFormat()?t5.Point:t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===a&&(a=0),void 0===i&&(i=0),this._platformTexture.setImageSource(e,t,n,r,a,i),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,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,n,r,0,a):6===o&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),e.prototype._rebuild.call(this)},t}(ns),nu=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===i&&(i=t9.R8G8B8A8),void 0===o&&(o=!0),(s=e.call(this,t)||this)._mipmap=o,s._width=n,s._height=r,s._length=a,s._format=i,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(s),s.filterMode=t5.Bilinear,s.wrapModeU=s.wrapModeV=t7.Repeat,s}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o,s){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o,s),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,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,n):5===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):6===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),e.prototype._rebuild.call(this)},tG(t,[{key:"length",get:function(){return this._length}}]),t}(ns),nd=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return void 0===r&&(r=t9.R8G8B8A8),void 0===a&&(a=!0),(i=e.call(this,t)||this)._mipmap=a,i._width=n,i._height=n,i._format=r,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(i),i.filterMode=t5.Bilinear,i.wrapModeU=i.wrapModeV=t7.Clamp,i}tW(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=0),this._platformTexture.setPixelBuffer(e,t,n,r,a,i,o),this._isContentLost=!1},n.setImageSource=function(e,t,n,r,a,i,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===a&&(a=!1),void 0===i&&(i=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,a,i,o),this._isContentLost=!1},n.getPixelBuffer=function(e,t,n,r,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,n):6===s?this._platformTexture.getPixelBuffer(e,t,n,r,a,0,i):7===s&&this._platformTexture.getPixelBuffer(e,t,n,r,a,i,o)},n._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),e.prototype._rebuild.call(this)},t}(ns),nh=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._charInfoMap={},n._space=1,n._curX=1,n._curY=1,n._nextY=1,n}tW(t,e);var n=t.prototype;return n.uploadCharTexture=function(e){var t=e.w,n=e.h,r=e.data,a=this._space,i=this.texture,o=i.width,s=t+a,l=n+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&&n>0&&r&&(e.bufferOffset=new tB(this._curX,this._curY),i.setPixelBuffer(r,0,this._curX,this._curY,t,n),i.generateMipmaps());var u=1/o,d=this._curX,h=this._curY,_=d*u,f=(d+t)*u,p=h*u,m=(h+n)*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},n.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},n.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},t}(t1),n_=((f={})[f.None=0]="None",f[f.Bold=1]="Bold",f[f.Italic=2]="Italic",f),nf=((p={})[p.Overflow=0]="Overflow",p[p.Truncate=1]="Truncate",p),np=/*#__PURE__*/function(){function e(){}return e.textContext=function(){var t=e._textContext;if(!t){try{n=new OffscreenCanvas(0,0)}catch(e){n=document.createElement("canvas")}var n,r=n.getContext("2d",{willReadFrequently:!0});t={canvas:n,context:r},e._textContext=t}return t},e.measureFont=function(t){var n=e._fontSizeInfoCache,r=n[t];return r||(r=e._measureFontOrChar(t,e._measureString,!1),n[t]=r),r},e.getNativeFontString=function(t,n,r){var a=r&n_.Bold?"bold ":"";return r&n_.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=n+"px "+t},e.measureChar=function(t,n){return e._measureFontOrChar(n,t,!0)},e.measureTextWithWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=iJ._pixelsPerUnit,u=a.size+t.lineSpacing*c,d=t.width*c,h=0;n.nativeFontString=r;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,C=0,S=0,T=!1,A=0,E=p.length;A<E;++A){var R=p[A],M=e._getCharInfo(R,r,n),w=R.charCodeAt(0),P=32===w;if(!P||!T||0!==x.length||0!==m.length){var F=P||w>=19968&&w<=40959,L=M.w,D=M.offsetY,B=.5*M.h,I=B+D,O=B-D;F?(m.length>0&&(b+g>d?(b>0&&this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),T=!0,x=m,b=g,C=v,S=y):(x+=m,b+=g,C=Math.max(C,v),S=Math.max(S,y)),m="",g=v=y=0),b+L>d&&b>0?(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),T=!0,P?(x="",b=C=S=0):(x=R,b=M.xAdvance,C=I,S=O)):(x+=R,b+=M.xAdvance,C=Math.max(C,I),S=Math.max(S,O))):g+M.w>d?(b>0&&(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b),x="",b=C=S=0),g>0&&this._pushLine(o,s,l,m,g,v,y),h=Math.max(h,g),T=!0,m=R,g=M.xAdvance,v=I,y=O):(m+=R,g+=M.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,C,S),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,C=Math.max(C,v),S=Math.max(S,y))),b>0&&(this._pushLine(o,s,l,x,b,C,S),h=Math.max(h,b))}var N=t.height*c;return t.overflowMode===nf.Overflow&&(N=u*o.length),{width:h,height:N,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},e.measureTextWithoutWrap=function(t){var n=t._getSubFont(),r=n.nativeFontString,a=e.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=iJ._pixelsPerUnit,d=a.size+t.lineSpacing*u,h=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=i[_],p=0,m=0,g=0,v=0,y=f.length;v<y;++v){var x=e._getCharInfo(f[v],r,n);p+=x.xAdvance;var b=x.offsetY,C=.5*x.h,S=C+b,T=C-b;m<S&&(m=S),g<T&&(g=T)}p>0&&(this._pushLine(s,l,c,f,p,m,g),h=Math.max(h,p))}var A=t.height*u;return t.overflowMode===nf.Overflow&&(A=d*s.length),{width:h,height:A,lines:s,lineWidths:l,lineHeight:d,lineMaxSizes:c}},e.getNativeFontHash=function(t,n,r){var a=r&n_.Bold?"bold":"";return r&n_.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=e._genericFontFamilies.indexOf(t)||(t=""+t),a+=n+"px"+t},e._measureFontOrChar=function(t,n,r){var a,i=e.textContext(),o=i.canvas,s=i.context;s.font=t;var l=s.measureText(n),c=l.actualBoundingBoxLeft,u=l.actualBoundingBoxRight,d=l.width,h=Math.max(1,Math.round(Math.max(u+Math.abs(c),d))),_=Math.ceil(s.measureText(e._measureBaseline).width),f=_*e._heightMultiplier;_=e._baselineMultiplier*_|0;var p=e._extendHeight;f+=p,_+=.5*p,o.width=h,o.height=f,s.font=t,s.fillStyle="#000",s.clearRect(0,0,h,f),s.textBaseline="middle",s.fillStyle="#fff",c>0?s.fillText(n,c,_):s.fillText(n,0,_);for(var m=s.getImageData(0,0,h,f).data,g=m.length,v=-1,y=-1,x=0,b=0,C=0,S=o.width,T=1/S,A=0;A<g;A+=4)0!==m[A+3]?(a=~~(.25*A*T),-1===v&&(v=a),a>y&&(y=a)):m[A]=m[A+1]=m[A+2]=255;if(-1!==v&&-1!==y&&(C=(x=_-v)+(b=y-_+1)),!r)return{ascent:x,descent:b,size:C};var E=null;if(C>0){var R=4*S;E=new Uint8Array(m.buffer,v*R,C*R)}return{char:n,x:0,y:0,w:h,h:C,offsetX:c>0?c:0,offsetY:(x-b)*.5,xAdvance:Math.round(d),uvs:[new tB,new tB,new tB,new tB],ascent:x,descent:b,index:0,data:E}},e._getCharInfo=function(t,n,r){var a=r._getCharInfo(t);return a||(a=e.measureChar(t,n),r._uploadCharTexture(a),r._addCharInfo(t,a)),a},e._pushLine=function(e,t,n,r,a,i,o){e.push(r),t.push(a),n.push({ascent:i,descent:o,size:i+o})},e}();np._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],np._extendHeight=0,np._measureString="|\xc9q\xc5",np._measureBaseline="M",np._heightMultiplier=2,np._baselineMultiplier=1.4,np._fontSizeInfoCache={},np._textContext=null;var nm=/*#__PURE__*/function(){function e(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}var t=e.prototype;return t.destroy=function(){for(var e=this._fontAtlases,t=0,n=e.length;t<n;++t)e[t].destroy(!0);e.length=0},t._uploadCharTexture=function(e){var t=this._fontAtlases,n=this._lastIndex;-1===n&&(this._createFontAtlas(),n++);var r=t[n];!r.uploadCharTexture(e)&&((r=this._createFontAtlas()).uploadCharTexture(e),n++),this._lastIndex=n,e.data=null},t._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},t._getCharInfo=function(e){for(var t=this._fontAtlases,n=0,r=t.length;n<r;++n){var a=t[n].getCharInfo(e);if(a)return a}return null},t._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},t._getLastIndex=function(){return this._lastIndex},t._createFontAtlas=function(){var e=this._engine,t=new nh(e),n=new nc(e,256,256,t9.R8G8B8A8,!1);n.filterMode=t5.Bilinear,t.texture=n,t.isGCIgnored=n.isGCIgnored=!0,this._fontAtlases.push(t);var r=this.nativeFontString;return e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var a in t){var i=t[a],o=np.measureChar(i.char,r).data;if(i.w>0&&i.h>0&&o){var s=i.bufferOffset;n.setPixelBuffer(o,0,s.x,s.y,i.w,i.h)}}n.generateMipmaps()},n}(t2))),t},e}(),ng=/*#__PURE__*/function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t)||this)._name="",r._subFontMap={},r._name=n,r}tW(t,e);var n=t.prototype;return n._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,a=r[n];return a||(a=new nm(this.engine),r[n]=a),a},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._subFontMap;for(var n in t)t[n].destroy();this._subFontMap=null,delete this.engine._fontMap[this._name]},t.createFromOS=function(e,n){if(n){var r=e._fontMap,a=r[n];return a||(a=new t(e,n),r[n]=a),a}return null},tG(t,[{key:"name",get:function(){return this._name}}]),t}(t1),nv=((m={})[m.None=0]="None",m[m.VisibleInsideMask=1]="VisibleInsideMask",m[m.VisibleOutsideMask=2]="VisibleOutsideMask",m),ny=((g={})[g.Left=0]="Left",g[g.Center=1]="Center",g[g.Right=2]="Right",g),nx=((v={})[v.Top=0]="Top",v[v.Center=1]="Center",v[v.Bottom=2]="Bottom",v),nb=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._sprites=[],n._spriteNamesToIndex={},n}tW(t,e);var n=t.prototype;return n.getSprite=function(e){var t=this._sprites[this._spriteNamesToIndex[e]];return t||console.warn("There is no sprite named "+e+" in the atlas."),t},n.getSprites=function(e,t){t.length=0;var n=this._spriteNamesToIndex[e];if(void 0!==n)for(var r=this._sprites;n>=0;n--){var a=r[n];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},n._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},n._onDestroy=function(){e.prototype._onDestroy.call(this);for(var t=this._sprites,n=0,r=t.length;n<r;n++)t[n].destroy();t.length=0,this._sprites=null,this._spriteNamesToIndex=null},tG(t,[{key:"sprites",get:function(){return this._sprites}}]),t}(t1),nC=((y={})[y.Simple=0]="Simple",y[y.Sliced=1]="Sliced",y[y.Tiled=2]="Tiled",y),nS=((x={})[x.Continuous=0]="Continuous",x[x.Adaptive=1]="Adaptive",x),nT=/*#__PURE__*/function(){function e(){}return e.removeFromArray=function(e,t){var n=e.indexOf(t);if(n<0)return!1;var r=e.length-1;if(n!==r){var a=e[r];e[n]=a}return e.length--,!0},e.decodeText=function(e){if("undefined"!=typeof TextDecoder)return new TextDecoder().decode(e);for(var t="",n=0,r=e.length;n<r;n++)t+=String.fromCharCode(e[n]);return decodeURIComponent(encodeURIComponent(t))},e.isAbsoluteUrl=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)},e.isBase64Url=function(e){return/^data:.*,.*$/i.test(e)},e.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},e.resolveAbsoluteUrl=function(t,n){if(e.isAbsoluteUrl(n)||e.isBase64Url(n))return n;if(!/^https?:/.test(t)){var r="files://";return new URL(n,t=r+t).href.substring(r.length)}return n?new URL(n,t).href:t},e._floatMatrixMultiply=function(e,t,n,r,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],C=t[n],S=t[n+1],T=t[n+2],A=t[n+3],E=t[n+4],R=t[n+5],M=t[n+6],w=t[n+7],P=t[n+8],F=t[n+9],L=t[n+10],D=t[n+11],B=t[n+12],I=t[n+13],O=t[n+14],N=t[n+15];r[a]=o*C+u*S+f*T+v*A,r[a+1]=s*C+d*S+p*T+y*A,r[a+2]=l*C+h*S+m*T+x*A,r[a+3]=c*C+_*S+g*T+b*A,r[a+4]=o*E+u*R+f*M+v*w,r[a+5]=s*E+d*R+p*M+y*w,r[a+6]=l*E+h*R+m*M+x*w,r[a+7]=c*E+_*R+g*M+b*w,r[a+8]=o*P+u*F+f*L+v*D,r[a+9]=s*P+d*F+p*L+y*D,r[a+10]=l*P+h*F+m*L+x*D,r[a+11]=c*P+_*F+g*L+b*D,r[a+12]=o*B+u*I+f*O+v*N,r[a+13]=s*B+d*I+p*O+y*N,r[a+14]=l*B+h*I+m*O+x*N,r[a+15]=c*B+_*I+g*O+b*N},e._reflectGet=function(e,t){for(var n=this._stringToPath(t),r=e,a=0,i=n.length;null!=r&&a<i;)r=r[n[a++]];return a&&a==i?r:void 0},e._quickSort=function(e,t,n,r){for(;;){if(n-t<=10){this._insertionSort(e,t,n,r);return}var a=t+n>>1,i=e[t],o=e[n-1],s=e[a];if(r(i,o)>0){var l=i;i=o,o=l}if(r(i,s)>=0){var c=i;i=s,s=o,o=c}else if(r(o,s)>0){var u=o;o=s,s=u}e[t]=i,e[n-1]=s;var d=o,h=t+1,_=n-1;e[a]=e[h],e[h]=d;e:for(var f=h+1;f<_;f++){var p=e[f],m=r(p,d);if(m<0)e[f]=e[h],e[h]=p,h++;else if(m>0){do{if(--_==f)break e;m=r(e[_],d)}while(m>0);e[f]=e[_],e[_]=p,m<0&&(p=e[f],e[f]=e[h],e[h]=p,h++)}}n-_<h-t?(this._quickSort(e,_,n,r),n=h):(this._quickSort(e,t,h,r),t=_)}},e._stringToPath=function(e){var t=[];return e.charCodeAt(0)===nA&&t.push(""),e.replace(nR,function(e,n,r,a){var i=e;r?i=a.replace(nE,"$1"):n&&(i=n.trim()),t.push(i)}),t},e._insertionSort=function(e,t,n,r){for(var a=t+1;a<n;a++){var i=void 0,o=e[a];for(i=a-1;i>=t;i--){var s=e[i];if(r(s,o)>0)e[i+1]=s;else break}e[i+1]=o}},e}(),nA=46,nE=/\\(\\)?/g,nR=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),nM=/*#__PURE__*/function(){function e(){this._updateFlags=[],this._listeners=[]}var t=e.prototype;return t.createFlag=function(e){var t=new e;return this.addFlag(t),t},t.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},t.removeFlag=function(e){nT.removeFromArray(this._updateFlags,e)&&nT.removeFromArray(e._flagManagers,this)},t.addListener=function(e){this._listeners.push(e)},t.removeListener=function(e){nT.removeFromArray(this._listeners,e)},t.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var a=this._listeners,i=a.length-1;i>=0;i--)a[i](e,t)},e}(),nw=((b={})[b.texture=1]="texture",b[b.size=2]="size",b[b.atlasRotate=4]="atlasRotate",b[b.atlasRegion=8]="atlasRegion",b[b.atlasRegionOffset=16]="atlasRegionOffset",b[b.region=32]="region",b[b.pivot=64]="pivot",b[b.border=128]="border",b[b.destroy=256]="destroy",b),nP=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null),void 0===i&&(i=null),void 0===o&&(o=null),(s=e.call(this,t)||this)._automaticWidth=0,s._automaticHeight=0,s._customWidth=void 0,s._customHeight=void 0,s._positions=[new tB,new tB,new tB,new tB],s._uvs=[new tB,new tB,new tB,new tB],s._bounds=new tE,s._texture=null,s._atlasRotated=!1,s._atlasRegion=new tN(0,0,1,1),s._atlasRegionOffset=new tI(0,0,0,0),s._region=new tN(0,0,1,1),s._pivot=new tB(.5,.5),s._border=new tI(0,0,0,0),s._dirtyUpdateFlag=7,s._updateFlagManager=new nM,s._texture=n,s._onRegionChange=s._onRegionChange.bind(s),s._onPivotChange=s._onPivotChange.bind(s),s._onBorderChange=s._onBorderChange.bind(s),s._region._onValueChanged=s._onRegionChange,s._pivot._onValueChanged=s._onPivotChange,s._border._onValueChanged=s._onBorderChange,r&&s._region.copyFrom(r),a&&s._pivot.copyFrom(a),i&&s._border.copyFrom(i),s.name=o,s}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(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},n._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},n._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},n._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},n._addReferCount=function(t){var n;e.prototype._addReferCount.call(this,t),null==(n=this._atlas)||n._addReferCount(t)},n._onDestroy=function(){this._dispatchSpriteChange(nw.destroy),e.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},n._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,a=1/iJ._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-n.x-n.z)*r.width*a,this._automaticHeight=e.height*t.height/(1-n.y-n.w)*r.height*a}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},n._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,n=t.x,r=t.y,a=t.width,i=t.height,o=Math.max(e.x-n,0)/a,s=Math.max(e.w-r,0)/i,l=1-Math.max(e.z-(1-n-a),0)/a,c=1-Math.max(e.y-(1-r-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},n._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,n=this._region,r=n.x,a=n.y,i=n.width,o=n.height,s=1-r-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(r-f,0)*v+u,b=Math.max(l-p,0)*y+d,C=h+u-Math.max(s-m,0)*v,S=_+d-Math.max(a-g,0)*y,T=this._border,A=T.x,E=T.y,R=T.z,M=T.w;e[0].set(x,S),e[1].set((r-f+A*i)*v+u,_+d-(a-g+E*o)*y),e[2].set(h+u-(s-m+R*i)*v,(l-p+M*o)*y+d),e[3].set(C,b),this._dirtyUpdateFlag&=-3},n._dispatchSpriteChange=function(e){switch(e){case nw.texture:this._dirtyUpdateFlag|=4;break;case nw.atlasRegionOffset:case nw.region:this._dirtyUpdateFlag|=7;break;case nw.atlasRegion:this._dirtyUpdateFlag|=6;break;case nw.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},n._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);e.set(t,n,tS.clamp(e.width,0,1-t),tS.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size),e._onValueChanged=this._onRegionChange},n._onPivotChange=function(){this._dispatchSpriteChange(nw.pivot)},n._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);e.set(t,n,tS.clamp(e.z,0,1-t),tS.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.border),e._onValueChanged=this._onBorderChange},tG(t,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(nw.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.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(nw.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(nw.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=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);this._atlasRegion.set(t,n,tS.clamp(e.width,0,1-t),tS.clamp(e.height,0,1-n)),this._dispatchSpriteChange(nw.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=tS.clamp(e.x,0,1),n=tS.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,tS.clamp(e.z,0,1-t),tS.clamp(e.w,0,1-n)),this._dispatchSpriteChange(nw.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(nw.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)}}]),t}(t1),nF=((C={})[C.Zero=0]="Zero",C[C.One=1]="One",C[C.SourceColor=2]="SourceColor",C[C.OneMinusSourceColor=3]="OneMinusSourceColor",C[C.DestinationColor=4]="DestinationColor",C[C.OneMinusDestinationColor=5]="OneMinusDestinationColor",C[C.SourceAlpha=6]="SourceAlpha",C[C.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",C[C.DestinationAlpha=8]="DestinationAlpha",C[C.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",C[C.SourceAlphaSaturate=10]="SourceAlphaSaturate",C[C.BlendColor=11]="BlendColor",C[C.OneMinusBlendColor=12]="OneMinusBlendColor",C),nL=((S={})[S.Add=0]="Add",S[S.Subtract=1]="Subtract",S[S.ReverseSubtract=2]="ReverseSubtract",S[S.Min=3]="Min",S[S.Max=4]="Max",S),nD=((T={})[T.None=0]="None",T[T.Red=1]="Red",T[T.Green=2]="Green",T[T.Blue=4]="Blue",T[T.Alpha=8]="Alpha",T[T.All=15]="All",T),nB=((A={})[A.Never=0]="Never",A[A.Less=1]="Less",A[A.Equal=2]="Equal",A[A.LessEqual=3]="LessEqual",A[A.Greater=4]="Greater",A[A.NotEqual=5]="NotEqual",A[A.GreaterEqual=6]="GreaterEqual",A[A.Always=7]="Always",A),nI=((E={})[E.Off=0]="Off",E[E.Front=1]="Front",E[E.Back=2]="Back",E),nO=((R={})[R.BlendStateEnabled0=0]="BlendStateEnabled0",R[R.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",R[R.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",R[R.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",R[R.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",R[R.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",R[R.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",R[R.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",R[R.BlendStateBlendColor=8]="BlendStateBlendColor",R[R.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",R[R.DepthStateEnabled=10]="DepthStateEnabled",R[R.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",R[R.DepthStateCompareFunction=12]="DepthStateCompareFunction",R[R.StencilStateEnabled=13]="StencilStateEnabled",R[R.StencilStateReferenceValue=14]="StencilStateReferenceValue",R[R.StencilStateMask=15]="StencilStateMask",R[R.StencilStateWriteMask=16]="StencilStateWriteMask",R[R.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",R[R.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",R[R.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",R[R.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",R[R.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",R[R.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",R[R.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",R[R.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",R[R.RasterStateCullMode=25]="RasterStateCullMode",R[R.RasterStateDepthBias=26]="RasterStateDepthBias",R[R.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",R[R.RenderQueueType=28]="RenderQueueType",R),nN=((M={})[M.Opaque=0]="Opaque",M[M.AlphaTest=1]="AlphaTest",M[M.Transparent=2]="Transparent",M),nV=((w={})[w.Float=0]="Float",w[w.Int=1]="Int",w[w.Vector2=2]="Vector2",w[w.Vector3=3]="Vector3",w[w.Vector4=4]="Vector4",w[w.Matrix=5]="Matrix",w[w.Color=6]="Color",w[w.Texture=7]="Texture",w[w.FloatArray=8]="FloatArray",w[w.IntArray=9]="IntArray",w[w.TextureArray=10]="TextureArray",w),nk=((P={})[P.Keep=0]="Keep",P[P.Zero=1]="Zero",P[P.Replace=2]="Replace",P[P.IncrementSaturate=3]="IncrementSaturate",P[P.DecrementSaturate=4]="DecrementSaturate",P[P.Invert=5]="Invert",P[P.IncrementWrap=6]="IncrementWrap",P[P.DecrementWrap=7]="DecrementWrap",P),nz=((F={})[F.GLES100=0]="GLES100",F[F.GLES300=1]="GLES300",F);function nU(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function nG(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return nU(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nU(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var nH=/*#__PURE__*/function(){function e(t,n,r,a){this.name=t,this._maskIndex=r,this._maskValue=a,this.value=n;var i=e._macroNameIdMap,o=i[t];void 0===i[t]&&(i[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,n){var r=n?t+" "+n:t,a=e._macroMap[r];if(!a){var i=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;a=new e(t,n,s,1<<l),e._macroMap[r]=a,s==i.length&&(i.length++,i[s]=Array(32)),i[s][l]=a,e._macroCounter++}return a},e._getMacrosElements=function(t,n){var r=e._macroMaskMap,a=t._mask;n.length=0;for(var i=0,o=t._length;i<o;i++)for(var s=r[i],l=a[i],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&n.push(s[u])},e}();nH._macroMaskMap=[],nH._macroNameIdMap=Object.create(null),nH._macroNameCounter=0,nH._macroCounter=0,nH._macroMap=Object.create(null);var nW=/*#__PURE__*/function(){function e(){this._mask=[],this._length=0}var t=e.prototype;return t.enable=function(e){var t=e._maskIndex,n=t+1,r=this._mask,a=this._length;if(a<n){for(r.length<n&&(r.length=n);a<t;a++)r[a]=0;r[t]=e._maskValue,this._length=n}else r[t]|=e._maskValue},t.disable=function(e){var t=e._maskIndex,n=this._mask,r=this._length-1;if(!(t>r)){var a=n[t]&~e._maskValue;t==r&&0===a?this._length--:n[t]=a}},t.unionCollection=function(e){var t=e._mask,n=e._length,r=this._mask,a=this._length;if(a<n){r.length<n&&(r.length=n);for(var i=0;i<a;i++)r[i]|=t[i];for(;i<n;i++)r[i]=t[i];this._length=n}else for(var o=0;o<n;o++)r[o]|=t[o]},t.complementaryCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1,a=Math.min(e._length-1,r);a>=0;a--){var i=n[a]&~t[a];a==r&&0===i?(r--,this._length--):n[a]=i}},t.intersectionCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1;r>=0;r--){var a=n[r]&t[r];0==a&&r==this._length-1?this._length--:n[r]=a}},t.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},t.clear=function(){this._length=0},e.unionCollection=function(e,t,n){var r,a,i,o,s=n._mask;e._length<t._length?(r=e._length,a=t._length,i=e._mask,o=t._mask):(r=t._length,a=e._length,i=t._mask,o=e._mask);var l=0;for(s.length<a&&(s.length=a);l<r;l++)s[l]=i[l]|o[l];for(;l<a;l++)s[l]=o[l];n._length=a},e}();function nj(){return(nj=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var nX=((L={}).DepthOnly="DepthOnly",L.ShadowCaster="ShadowCaster",L.Forward="Forward",L),nK=/*#__PURE__*/function(){function e(){this._events=Object.create(null),this._eventCount=0}var t=e.prototype;return t.hasEvent=function(e){return null!=this._events[e]},t.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},t.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},t.dispatch=function(t,n){if(!this._events[t])return!1;var r=this._events[t];if(Array.isArray(r)){var a=r.length,i=e._dispatchingListenersPool,o=i.length>0?i.pop():[];o.length=a;for(var s=0;s<a;s++)o[s]=r[s];for(var l=0;l<a;l++){var c=o[l];c.destroyed||(c.once&&this.off(t,c.fn),c.fn(n))}o.length=0,i.push(o)}else r.once&&this.off(t,r.fn),r.fn(n);return!0},t.on=function(e,t){return this._addEventListener(e,t)},t.once=function(e,t){return this._addEventListener(e,t,!0)},t.off=function(e,t){if(!this._events[e])return this;if(!t)return this._clearEvent(e),this;var n=this._events[e],r=Array.isArray(n);if(r||n.fn!==t){if(r){for(var a=n.length-1;a>=0;a--)n[a].fn===t&&(n[a].destroyed=!0,n.splice(a,1));0===n.length?this._clearEvent(e):1===n.length&&(this._events[e]=n[0])}}else this._clearEvent(e);return this},t.removeEventListener=function(e,t){return this.off(e,t)},t.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},t._addEventListener=function(e,t,n){var r={fn:t,once:n},a=this._events,i=a[e];return i?Array.isArray(i)?i.push(r):a[e]=[i,r]:(a[e]=r,this._eventCount++),this},t._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},e}();nK._dispatchingListenersPool=[];var nY=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return e.getByName=function(t){var n=e._propertyNameMap;if(null!=n[t])return n[t];var r=new e(t);return n[t]=r,e._propertyIdMap[r._uniqueId]=r,r},e._getShaderPropertyGroup=function(t){var n=e._propertyNameMap[t];return null==n?void 0:n._group},tG(e,[{key:"type",get:function(){return this._type}}]),e}();nY._propertyIdMap=Object.create(null),nY._propertyNameCounter=0,nY._propertyNameMap=Object.create(null);var nq=/*#__PURE__*/function(){function e(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new tI,this._deltaTimeValue=new tI,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}var t=e.prototype;return t._reset=function(){this._lastSystemTime=performance.now()/1e3},t._update=function(){var e=performance.now()/1e3,t=e-this._lastSystemTime;this._actualDeltaTime=t,this._actualElapsedTime+=t;var n=Math.min(t,this.maximumDeltaTime)*this.timeScale;this._deltaTime=n,this._elapsedTime+=n,this._frameCount++,this._lastSystemTime=e},t._updateSceneShaderData=function(t){var n=this._elapsedTimeValue,r=this._deltaTimeValue,a=this._elapsedTime;n.set(a,Math.sin(a),Math.cos(a),0),t.setVector4(e._elapsedTimeProperty,n),r.set(this._deltaTime,0,0,0),t.setVector4(e._deltaTimeProperty,r)},tG(e,[{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}}]),e}();nq._elapsedTimeProperty=nY.getByName("scene_ElapsedTime"),nq._deltaTimeProperty=nY.getByName("scene_DeltaTime");var nQ=((D={})[D.FLOAT=5126]="FLOAT",D[D.FLOAT_VEC2=35664]="FLOAT_VEC2",D[D.FLOAT_VEC3=35665]="FLOAT_VEC3",D[D.FLOAT_VEC4=35666]="FLOAT_VEC4",D[D.INT=5124]="INT",D[D.INT_VEC2=35667]="INT_VEC2",D[D.INT_VEC3=35668]="INT_VEC3",D[D.INT_VEC4=35669]="INT_VEC4",D[D.BOOL=35670]="BOOL",D[D.BOOL_VEC2=35671]="BOOL_VEC2",D[D.BOOL_VEC3=35672]="BOOL_VEC3",D[D.BOOL_VEC4=35673]="BOOL_VEC4",D[D.FLOAT_MAT2=35674]="FLOAT_MAT2",D[D.FLOAT_MAT3=35675]="FLOAT_MAT3",D[D.FLOAT_MAT4=35676]="FLOAT_MAT4",D[D.FLOAT_ARRAY=35677]="FLOAT_ARRAY",D[D.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",D[D.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",D[D.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",D[D.INT_ARRAY=100003]="INT_ARRAY",D[D.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",D[D.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",D[D.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",D[D.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",D[D.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",D[D.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",D[D.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",D[D.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",D[D.SAMPLER_2D=35678]="SAMPLER_2D",D[D.SAMPLER_CUBE=35680]="SAMPLER_CUBE",D[D.BYTE=5120]="BYTE",D[D.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",D[D.SHORT=5122]="SHORT",D[D.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",D[D.UNSIGNED_INT=5125]="UNSIGNED_INT",D),nJ=((B={}).shaderVertexID="shaderVertexID",B.standardDerivatives="OES_standard_derivatives",B.shaderTextureLod="EXT_shader_texture_lod",B.elementIndexUint="OES_element_index_uint",B.depthTexture="WEBGL_depth_texture",B.drawBuffers="WEBGL_draw_buffers",B.vertexArrayObject="OES_vertex_array_object",B.instancedArrays="ANGLE_instanced_arrays",B.multipleSample="multipleSampleOnlySupportedInWebGL2",B.textureFloat="OES_texture_float",B.textureFloatLinear="OES_texture_float_linear",B.textureHalfFloat="OES_texture_half_float",B.textureHalfFloatLinear="OES_texture_half_float_linear",B.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",B.colorBufferFloat="EXT_color_buffer_float",B.colorBufferHalfFloat="EXT_color_buffer_half_float",B.textureFilterAnisotropic="EXT_texture_filter_anisotropic",B.blendMinMax="EXT_blend_minmax",B.fragDepth="EXT_frag_depth",B.astc="WEBGL_compressed_texture_astc",B.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",B.etc="WEBGL_compressed_texture_etc",B.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",B.etc1="WEBGL_compressed_texture_etc1",B.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",B.pvrtc="WEBGL_compressed_texture_pvrtc",B.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",B.s3tc="WEBGL_compressed_texture_s3tc",B.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",B.bptc="EXT_texture_compression_bptc",B.WEBGL_lose_context="WEBGL_lose_context",B),nZ=nj({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#ifdef RENDERER_TSA_FRAME_RANDOM_CURVES\nuniform vec2 renderer_TSAFrameMinCurve[4];\n#endif\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 tileRow=frame*renderer_TSATillingParams.x;float tileRowIndex=floor(tileRow);uv.x+=tileRow-tileRowIndex;uv.y+=tileRowIndex*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"}),n$=/*#__PURE__*/function(){function e(){}return e.parseCustomMacros=function(e){return e.map(function(e){return"#define "+(e.value?e.name+" "+e.value:e.name)+"\n"}).join("")},e.registerInclude=function(e,t){if(nZ[e])throw'The "'+e+'" shader include already exist';nZ[e]=t},e.unRegisterInclude=function(e){delete nZ[e]},e.parseIncludes=function(t,n){return void 0===n&&(n=/^[ \t]*#include +<([\w\d.]+)>/gm),t.replace(n,function(t,r){var a=nZ[r];return void 0===a?(no.error('Shader slice "'+t.trim()+'" not founded.'),""):e.parseIncludes(a,n)})},e.convertTo300=function(t,n){if(t=(t=(t=t.replace(/\bvarying\b/g,n?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture2DProj\b/g,"textureProj"),n){if(t=(t=(t=(t=(t=t.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"),!e._has300Output(t)){if(/\bgl_FragData\[.+?\]/g.test(t)){var r=(t=t.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);t=this._replaceMRTShader(t,r)}else t=(t=t.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}}else t=t.replace(/\battribute\b/g,"in");return t},e._has300Output=function(t){return e._has300OutInFragReg.test(t)},e._replaceMRTShader=function(e,t){for(var n="",r=new Set,a=0;a<t.length;a++){var i=t[a].match(/\bgl_FragData\[(.+?)\]/);r.add(i[1])}return r.forEach(function(e){n+="layout(location="+e+") out vec4 fragOutColor"+e+";\n"}),n+="void main(",e=(e=e.replace(/\bgl_FragData\[(.+?)\]/g,"fragOutColor$1")).replace(/void\s+?main\s*\(/g,n)},e}();n$._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(""),n$._has300OutInFragReg=/\bout\s+(?:\w+\s+)?(?:vec4)\s+(?:\w+)\s*;/;var n0=/*#__PURE__*/function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var n=e._nameMap;return n[t]||(n[t]=new e(t))},e}();n0._nameCounter=0,n0._nameMap=Object.create(null);var n1=/*#__PURE__*/function(){function e(){this._tagsMap=Object.create(null)}var t=e.prototype;return t.setTag=function(e,t){var n="string"==typeof e?n0.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&no.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},t.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?n0.getByName(e):e)._uniqueId]},t.getTagValue=function(e){return this._tagsMap["string"==typeof e?n0.getByName(e)._uniqueId:e._uniqueId]},tG(e,[{key:"name",get:function(){return this._name}}]),e}(),n2=((I={})[I.Linear=0]="Linear",I[I.Gamma=1]="Gamma",I),n3=/*#__PURE__*/function(){function e(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}var t=e.prototype;return t.upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},t.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},t.upload2f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._colorSpace===n2.Linear?this._gl.uniform2f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g)):this._gl.uniform2f(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2f(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},t.upload3f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._colorSpace===n2.Linear?this._gl.uniform3f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b)):this._gl.uniform3f(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3f(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},t.upload4f=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._colorSpace===n2.Linear?this._gl.uniform4f(e.location,tO.gammaToLinearSpace(t.r),tO.gammaToLinearSpace(t.g),tO.gammaToLinearSpace(t.b),t.a):this._gl.uniform4f(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4f(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},t.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},t.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},t.upload2i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},t.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},t.upload3i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},t.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},t.upload4i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},t.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},t.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},t.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},t.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},t.uploadTextureArray=function(e,t){for(var n=this._rhi,r=e.textureIndex,a=0;a<t.length;a++){var i=t[a];n.activeTexture(r[a]),n.bindTexture(i._platformTexture),i._setUseDepthCompareMode(e.textureUseCompareMode)}},e}(),n4=function(){this.constUniforms=[],this.textureUniforms=[]},n8=((O={})[O.Scene=0]="Scene",O[O.Camera=1]="Camera",O[O.Renderer=2]="Renderer",O[O.Material=3]="Material",O[O.RenderElement=4]="RenderElement",O),n5=/*#__PURE__*/function(){function e(t,n,r){this.sceneUniformBlock=new n4,this.cameraUniformBlock=new n4,this.rendererUniformBlock=new n4,this.materialUniformBlock=new n4,this.renderElementUniformBlock=new n4,this.otherUniformBlock=new n4,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(n,r),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 n=t._propertyValueMap,r=e.constUniforms,a=0,i=r.length;a<i;a++){var o=r[a],s=n[o.propertyId];null!=s&&o.applyFunc(o,s)}},t.uploadTextures=function(e,t){var n=t._propertyValueMap,r=e.textureUniforms;if(r)for(var a=0,i=r.length;a<i;a++){var o=r[a],s=n[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,n=e.length;t<n;t++){var r=e[t];r.applyFunc(r,r.textureDefault)}},t.groupingOtherUniformBlock=function(){var e=this.otherUniformBlock,t=e.constUniforms,n=e.textureUniforms;t.length>0&&this._groupingSubOtherUniforms(t,!1),n.length>0&&this._groupingSubOtherUniforms(n,!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 n=e.length-1;n>=0;n--){var r=e[n],a=nY._getShaderPropertyGroup(r.name);void 0!==a&&(e.splice(e.indexOf(r),1),this._groupingUniform(r,a,t))}},t._groupingUniform=function(e,t,n){switch(t){case n8.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case n8.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case n8.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case n8.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.constUniforms.push(e);break;case n8.RenderElement:n?this.renderElementUniformBlock.textureUniforms.push(e):this.renderElementUniformBlock.constUniforms.push(e);break;default:n?this.otherUniformBlock.textureUniforms.push(e):this.otherUniformBlock.constUniforms.push(e)}},t._createProgram=function(e,t){var n=this._gl,r=this._createShader(n.VERTEX_SHADER,e);if(!r)return null;var a=this._createShader(n.FRAGMENT_SHADER,t);if(!a)return null;var i=n.createProgram();return i?(n.attachShader(i,r),n.attachShader(i,a),n.linkProgram(i),n.validateProgram(i),n.deleteShader(r),n.deleteShader(a),!no.isEnabled||n.getProgramParameter(i,n.LINK_STATUS)||n.isContextLost())?i:(no.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(i,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(i)),n.deleteProgram(i),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,n){var r=this._gl,a=r.createShader(t);return a?(r.shaderSource(a,n),r.compileShader(a),!no.isEnabled||r.getShaderParameter(a,r.COMPILE_STATUS)||r.isContextLost())?a:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==r.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+r.getShaderInfoLog(a)+"\nShader source:\n"+e._addLineNum(n)),r.deleteShader(a),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,n=this._glProgram,r=this._getUniformInfos(),a=this._getAttributeInfos(),i=this._engine._basicResources;r.forEach(function(r){var a,o=r.name,s=r.size,l=r.type,c=new n3(e._engine),u=!1,d=!1;o.indexOf("[0]")>0&&(o=o.substr(0,o.length-3),u=!0);var h=t.getUniformLocation(n,o);switch(c.name=o,c.propertyId=nY.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 tB(0,0));break;case t.FLOAT_VEC3:u?c.applyFunc=c.upload3fv:(c.applyFunc=c.upload3f,c.cacheValue=new tT(0,0,0));break;case t.FLOAT_VEC4:u?c.applyFunc=c.upload4fv:(c.applyFunc=c.upload4f,c.cacheValue=new tI(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 tB(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:u?c.applyFunc=c.upload3iv:(c.applyFunc=c.upload3i,c.cacheValue=new tT(0,0,0));break;case t.BOOL_VEC4:case t.INT_VEC4:u?c.applyFunc=c.upload4iv:(c.applyFunc=c.upload4i,c.cacheValue=new tI(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=nY._getShaderPropertyGroup(o);e._groupingUniform(c,v,d)}),a.forEach(function(r){var a=r.name;e.attributeLocation[a]=t.getAttribLocation(n,a)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=Array(n),a=0;a<n;++a){var i=e.getActiveUniform(t,a);r[a]=i}return r},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,n=[],r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),a=0;a<r;++a){var i=e.getActiveAttrib(t,a);n[a]=i}return n},e._addLineNum=function(e){var t,n=e.split("\n"),r=(n.length+1).toString().length+6;return n.map(function(e,n){if((t="0:"+(n+1)).length>=r)return t.substring(0,r)+e;for(var a=0;a<r-t.length;a++)t+=" ";return t+e}).join("\n")},tG(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();n5._counter=0;var n9=((N={})[N.Canonical=0]="Canonical",N[N.ShaderLab=1]="ShaderLab",N),n6=/*#__PURE__*/function(e){function t(n,r,a,i,o){var s;for(var l in(s=e.call(this)||this)._shaderPassId=0,s._renderStateDataMap={},s._shaderProgramPools=[],s._path="",s._platformMacros=[],s._shaderPassId=t._shaderPassCounter++,s._type=n9.Canonical,"string"==typeof i?(s._name=n,s._shaderLabSource=r,s._vertexEntry=a,s._fragmentEntry=i,o=nj({pipelineStage:nX.Forward},o),s._type=n9.ShaderLab):"string"==typeof a?(s._name=n,s._vertexSource=r,s._fragmentSource=a,o=null!=i?i:{pipelineStage:nX.Forward}):(s._name="Default",s._vertexSource=n,s._fragmentSource=r,o=null!=a?a:{pipelineStage:nX.Forward}),o)s.setTag(l,o[l]);return s}tW(t,e);var n=t.prototype;return n._getShaderProgram=function(e,t){var n=e._getShaderProgramPool(this),r=n.get(t);return r||(r=this._type===n9.Canonical?this._getCanonicalShaderProgram(e,t):this._compileShaderProgram(e,t,this._vertexEntry,this._fragmentEntry),n.cache(r)),r},n._destroy=function(){for(var e=this._shaderProgramPools,t=0,n=e.length;t<n;t++){var r=e[t];r._destroy(),delete r.engine._shaderProgramPools[this._shaderPassId]}e.length=0},n._compileShaderProgram=function(e,n,r,a){var i=this._path,o=this._platformMacros,s=e._hardwareRenderer.isWebGL2,l=[];nH._getMacrosElements(n,l),o.length=0,e._hardwareRenderer.canIUse(nJ.shaderTextureLod)&&o.push("HAS_TEX_LOD"),e._hardwareRenderer.canIUse(nJ.standardDerivatives)&&o.push("HAS_DERIVATIVES"),s?o.push("GRAPHICS_API_WEBGL2"):o.push("GRAPHICS_API_WEBGL1");var c=performance.now(),u=ro._shaderLab._parseShaderPass(this._shaderLabSource,r,a,l,s?nz.GLES300:nz.GLES100,o,new URL(i,t._shaderRootPath).href);return(no.info("[ShaderLab compilation] cost time: "+(performance.now()-c)+"ms"),u)?new n5(e,u.vertex,u.fragment):new n5(e,"","")},n._getCanonicalShaderProgram=function(e,t){var n=e._hardwareRenderer.isWebGL2,r=[];nH._getMacrosElements(t,r);var a=n$.parseCustomMacros(r),i=n?"#version 300 es":"#version 100",o=n?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",s="\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 ";e._hardwareRenderer.canIUse(nJ.shaderTextureLod)&&(s+="#define HAS_TEX_LOD\n"),e._hardwareRenderer.canIUse(nJ.standardDerivatives)&&(s+="#define HAS_DERIVATIVES\n");var l=" "+i+"\n "+o+"\n "+a+"\n "+n$.parseIncludes(this._vertexSource),c=" "+i+"\n "+o+"\n "+(n?"":n$._shaderExtension)+"\n "+s+"\n "+a+"\n "+n$.parseIncludes(this._fragmentSource);return n&&(l=n$.convertTo300(l),c=n$.convertTo300(c,!0)),new n5(e,l,c)},t}(n1);n6._shaderPassCounter=0,n6._shaderRootPath="shaders://root/";var n7=/*#__PURE__*/function(e){function t(t,n,r){var a;if((a=e.call(this)||this)._name=t,n.length<1)throw" count must large than 0.";for(var i in a._passes=n.slice(),r)a.setTag(i,r[i]);return a}return tW(t,e),tG(t,[{key:"passes",get:function(){return this._passes}}]),t}(n1),re=function(){this.enabled=!1,this.colorBlendOperation=nL.Add,this.alphaBlendOperation=nL.Add,this.sourceColorBlendFactor=nF.One,this.sourceAlphaBlendFactor=nF.One,this.destinationColorBlendFactor=nF.Zero,this.destinationAlphaBlendFactor=nF.Zero,this.colorWriteMask=nD.All},rt=/*#__PURE__*/function(){function e(){this.targetBlendState=new re,this.blendColor=new tO(0,0,0,0),this.alphaToCoverage=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c=this.targetBlendState,u=e[nO.BlendStateEnabled0];if(void 0!==u){var d=t.getFloat(u);c.enabled=void 0!==d&&!!d}var h=e[nO.BlendStateColorBlendOperation0];void 0!==h&&(c.colorBlendOperation=null!=(n=t.getFloat(h))?n:nL.Add);var _=e[nO.BlendStateAlphaBlendOperation0];void 0!==_&&(c.alphaBlendOperation=null!=(r=t.getFloat(_))?r:nL.Add);var f=e[nO.BlendStateSourceColorBlendFactor0];void 0!==f&&(c.sourceColorBlendFactor=null!=(a=t.getFloat(f))?a:nF.One);var p=e[nO.BlendStateSourceAlphaBlendFactor0];void 0!==p&&(c.sourceAlphaBlendFactor=null!=(i=t.getFloat(p))?i:nF.One);var m=e[nO.BlendStateDestinationColorBlendFactor0];void 0!==m&&(c.destinationColorBlendFactor=null!=(o=t.getFloat(m))?o:nF.Zero);var g=e[nO.BlendStateDestinationAlphaBlendFactor0];void 0!==g&&(c.destinationAlphaBlendFactor=null!=(s=t.getFloat(g))?s:nF.Zero);var v=e[nO.BlendStateColorWriteMask0];void 0!==v&&(c.colorWriteMask=null!=(l=t.getFloat(v))?l:nD.All);var y=e[nO.BlendStateBlendColor];if(void 0!==y){var x=t.getColor(y);void 0!==x&&this.blendColor.copyFrom(x)}var b=e[nO.BlendStateAlphaToCoverage];if(void 0!==b){var C=t.getFloat(b);this.alphaToCoverage=void 0!==C&&!!C}},t._apply=function(e,t,n){this._platformApply(e,t.blendState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=n.targetBlendState,o=this.targetBlendState,s=o.enabled,l=o.colorBlendOperation,c=o.alphaBlendOperation,u=o.sourceColorBlendFactor,d=o.destinationColorBlendFactor,h=o.sourceAlphaBlendFactor,_=o.destinationAlphaBlendFactor,f=o.colorWriteMask;if(r){var p=r[nO.BlendStateColorWriteMask0];void 0!==p&&(f=p)}if(s!==i.enabled&&(s?a.enable(a.BLEND):a.disable(a.BLEND),i.enabled=s),s){(u!==i.sourceColorBlendFactor||d!==i.destinationColorBlendFactor||h!==i.sourceAlphaBlendFactor||_!==i.destinationAlphaBlendFactor)&&(a.blendFuncSeparate(e._getGLBlendFactor(t,u),e._getGLBlendFactor(t,d),e._getGLBlendFactor(t,h),e._getGLBlendFactor(t,_)),i.sourceColorBlendFactor=u,i.destinationColorBlendFactor=d,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=_),(l!==i.colorBlendOperation||c!==i.alphaBlendOperation)&&(a.blendEquationSeparate(e._getGLBlendOperation(t,l),e._getGLBlendOperation(t,c)),i.colorBlendOperation=l,i.alphaBlendOperation=c);var m=this.blendColor;tO.equals(n.blendColor,m)||(a.blendColor(m.r,m.g,m.b,m.a),n.blendColor.copyFrom(m))}f!==i.colorWriteMask&&(a.colorMask((f&nD.Red)!=0,(f&nD.Green)!=0,(f&nD.Blue)!=0,(f&nD.Alpha)!=0),i.colorWriteMask=f);var g=this.alphaToCoverage;g!==n.alphaToCoverage&&(g?a.enable(a.SAMPLE_ALPHA_TO_COVERAGE):a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=g)},e._getGLBlendFactor=function(e,t){var n=e.gl;switch(t){case nF.Zero:return n.ZERO;case nF.One:return n.ONE;case nF.SourceColor:return n.SRC_COLOR;case nF.OneMinusSourceColor:return n.ONE_MINUS_SRC_COLOR;case nF.DestinationColor:return n.DST_COLOR;case nF.OneMinusDestinationColor:return n.ONE_MINUS_DST_COLOR;case nF.SourceAlpha:return n.SRC_ALPHA;case nF.OneMinusSourceAlpha:return n.ONE_MINUS_SRC_ALPHA;case nF.DestinationAlpha:return n.DST_ALPHA;case nF.OneMinusDestinationAlpha:return n.ONE_MINUS_DST_ALPHA;case nF.SourceAlphaSaturate:return n.SRC_ALPHA_SATURATE;case nF.BlendColor:return n.CONSTANT_COLOR;case nF.OneMinusBlendColor:return n.ONE_MINUS_CONSTANT_COLOR}},e._getGLBlendOperation=function(e,t){var n=e.gl;switch(t){case nL.Add:return n.FUNC_ADD;case nL.Subtract:return n.FUNC_SUBTRACT;case nL.ReverseSubtract:return n.FUNC_REVERSE_SUBTRACT;case nL.Min:if(!e.canIUse(nJ.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return n.MIN;case nL.Max:if(!e.canIUse(nJ.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return n.MAX}},e}();tX([tZ],rt.prototype,"targetBlendState",void 0),tX([tZ],rt.prototype,"blendColor",void 0);var rn=/*#__PURE__*/function(){function e(){this.enabled=!0,this.compareFunction=nB.Less,this.writeEnabled=!0}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r=e[nO.DepthStateEnabled];if(void 0!==r){var a=t.getFloat(r);this.enabled=void 0!==a&&!!a}var i=e[nO.DepthStateWriteEnabled];if(void 0!==i){var o=t.getFloat(i);this.writeEnabled=void 0!==o&&!!o}var s=e[nO.DepthStateCompareFunction];void 0!==s&&(this.compareFunction=null!=(n=t.getFloat(s))?n:nB.Less)},t._apply=function(e,t,n){this._platformApply(e,t.depthState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.compareFunction,s=this.writeEnabled;if(r){var l=r[nO.DepthStateEnabled];void 0!==l&&(i=l)}i!=n.enabled&&(i?a.enable(a.DEPTH_TEST):a.disable(a.DEPTH_TEST),n.enabled=i),i&&o!=n.compareFunction&&(a.depthFunc(e._getGLCompareFunction(t,o)),n.compareFunction=o),s!=n.writeEnabled&&(a.depthMask(s),n.writeEnabled=s)},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e}(),rr=/*#__PURE__*/function(){function e(){this.cullMode=nI.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i=e[nO.RasterStateCullMode];void 0!==i&&(this.cullMode=null!=(n=t.getFloat(i))?n:nI.Back);var o=e[nO.RasterStateDepthBias];void 0!==o&&(this.depthBias=null!=(r=t.getFloat(o))?r:0);var s=e[nO.RasterStateSlopeScaledDepthBias];void 0!==s&&(this.slopeScaledDepthBias=null!=(a=t.getFloat(s))?a:0)},t._apply=function(e,t,n,r){this._platformApply(e,t.rasterState,n,r)},t._platformApply=function(e,t,n,r){var a=e.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias;if(r){var l=r[nO.RasterStateCullMode];void 0!==l&&(i=l)}var c=i!==nI.Off;c!==t._cullFaceEnable&&(c?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),t._cullFaceEnable=c),c&&i!==t.cullMode&&(i==nI.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),t.cullMode=i),n!==t._frontFaceInvert&&(n?a.frontFace(a.CW):a.frontFace(a.CCW),t._frontFaceInvert=n),e._enableGlobalDepthBias||o===t.depthBias&&s===t.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),t.depthBias=o,t.slopeScaledDepthBias=s)},e}(),ra=/*#__PURE__*/function(){function e(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=nB.Always,this.compareFunctionBack=nB.Always,this.passOperationFront=nk.Keep,this.passOperationBack=nk.Keep,this.failOperationFront=nk.Keep,this.failOperationBack=nk.Keep,this.zFailOperationFront=nk.Keep,this.zFailOperationBack=nk.Keep}var t=e.prototype;return t._applyShaderDataValue=function(e,t){var n,r,a,i,o,s,l,c,u,d,h,_=e[nO.StencilStateEnabled];if(void 0!==_){var f=t.getFloat(_);this.enabled=void 0!==f&&!!f}var p=e[nO.StencilStateReferenceValue];void 0!==p&&(this.referenceValue=null!=(n=t.getFloat(p))?n:0);var m=e[nO.StencilStateMask];void 0!==m&&(this.mask=null!=(r=t.getFloat(m))?r:255);var g=e[nO.StencilStateWriteMask];void 0!==g&&(this.writeMask=null!=(a=t.getFloat(g))?a:255);var v=e[nO.StencilStateCompareFunctionFront];void 0!==v&&(this.compareFunctionFront=null!=(i=t.getFloat(v))?i:nB.Always);var y=e[nO.StencilStateCompareFunctionBack];void 0!==y&&(this.compareFunctionBack=null!=(o=t.getFloat(y))?o:nB.Always);var x=e[nO.StencilStatePassOperationFront];void 0!==x&&(this.passOperationFront=null!=(s=t.getFloat(x))?s:nk.Keep);var b=e[nO.StencilStatePassOperationBack];void 0!==b&&(this.passOperationBack=null!=(l=t.getFloat(b))?l:nk.Keep);var C=e[nO.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(c=t.getFloat(C))?c:nk.Keep);var S=e[nO.StencilStateFailOperationBack];void 0!==S&&(this.failOperationBack=null!=(u=t.getFloat(S))?u:nk.Keep);var T=e[nO.StencilStateZFailOperationFront];void 0!==T&&(this.zFailOperationFront=null!=(d=t.getFloat(T))?d:nk.Keep);var A=e[nO.StencilStateZFailOperationBack];void 0!==A&&(this.zFailOperationBack=null!=(h=t.getFloat(A))?h:nk.Keep)},t._apply=function(e,t,n){this._platformApply(e,t.stencilState,n)},t._platformApply=function(t,n,r){var a=t.gl,i=this.enabled,o=this.referenceValue,s=this.mask,l=this.compareFunctionFront,c=this.compareFunctionBack,u=this.failOperationFront,d=this.zFailOperationFront,h=this.passOperationFront,_=this.failOperationBack,f=this.zFailOperationBack,p=this.passOperationBack,m=this.writeMask;if(r){var g=r[nO.StencilStateEnabled];void 0!==g&&(i=g);var v=r[nO.StencilStateWriteMask];void 0!==v&&(m=v);var y=r[nO.StencilStateReferenceValue];void 0!==y&&(o=y);var x=r[nO.StencilStateCompareFunctionFront];void 0!==x&&(l=x);var b=r[nO.StencilStateCompareFunctionBack];void 0!==b&&(c=b);var C=r[nO.StencilStatePassOperationFront];void 0!==C&&(h=C);var S=r[nO.StencilStatePassOperationBack];void 0!==S&&(p=S);var T=r[nO.StencilStateFailOperationFront];void 0!==T&&(u=T);var A=r[nO.StencilStateFailOperationBack];void 0!==A&&(_=A);var E=r[nO.StencilStateZFailOperationFront];void 0!==E&&(d=E);var R=r[nO.StencilStateZFailOperationBack];void 0!==R&&(f=R)}if(i!=n.enabled&&(i?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),n.enabled=i),i){var M=o!==n.referenceValue||s!==n.mask;(M||l!==n.compareFunctionFront)&&(a.stencilFuncSeparate(a.FRONT,e._getGLCompareFunction(t,l),o,s),n.compareFunctionFront=l),(M||c!==n.compareFunctionBack)&&(a.stencilFuncSeparate(a.BACK,e._getGLCompareFunction(t,c),o,s),n.compareFunctionBack=c),M&&(n.referenceValue=o,n.mask=s),(u!==n.failOperationFront||d!==n.zFailOperationFront||h!==n.passOperationFront)&&(a.stencilOpSeparate(a.FRONT,e._getGLStencilOperation(t,u),e._getGLStencilOperation(t,d),e._getGLStencilOperation(t,h)),n.failOperationFront=u,n.zFailOperationFront=d,n.passOperationFront=h),(_!==n.failOperationBack||f!==n.zFailOperationBack||p!==n.passOperationBack)&&(a.stencilOpSeparate(a.BACK,e._getGLStencilOperation(t,_),e._getGLStencilOperation(t,f),e._getGLStencilOperation(t,p)),n.failOperationBack=_,n.zFailOperationBack=f,n.passOperationBack=p),m!==n.writeMask&&(a.stencilMask(m),n.writeMask=m)}},e._getGLCompareFunction=function(e,t){var n=e.gl;switch(t){case nB.Never:return n.NEVER;case nB.Less:return n.LESS;case nB.Equal:return n.EQUAL;case nB.LessEqual:return n.LEQUAL;case nB.Greater:return n.GREATER;case nB.NotEqual:return n.NOTEQUAL;case nB.GreaterEqual:return n.GEQUAL;case nB.Always:return n.ALWAYS}},e._getGLStencilOperation=function(e,t){var n=e.gl;switch(t){case nk.Keep:return n.KEEP;case nk.Zero:return n.ZERO;case nk.Replace:return n.REPLACE;case nk.IncrementSaturate:return n.INCR;case nk.DecrementSaturate:return n.DECR;case nk.Invert:return n.INVERT;case nk.IncrementWrap:return n.INCR_WRAP;case nk.DecrementWrap:return n.DECR_WRAP}},e}(),ri=/*#__PURE__*/function(){function e(){this.blendState=new rt,this.depthState=new rn,this.stencilState=new ra,this.rasterState=new rr,this.renderQueueType=nN.Opaque}var t=e.prototype;return t._applyStates=function(e,t,n,r,a){n&&this._applyStatesByShaderData(n,r);var i=e._hardwareRenderer,o=e._lastRenderState,s=e._renderContext;this.blendState._apply(i,o,a),this.depthState._apply(i,o,a),this.stencilState._apply(i,o,a),this.rasterState._apply(i,o,s.flipProjection?!t:t,a)},t._getRenderQueueByShaderData=function(e,t){var n,r=e[nO.RenderQueueType];return void 0===r?this.renderQueueType:null!=(n=t.getFloat(r))?n:nN.Opaque},t._applyStatesByShaderData=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},e}();tX([tZ],ri.prototype,"blendState",void 0),tX([tZ],ri.prototype,"depthState",void 0),tX([tZ],ri.prototype,"stencilState",void 0),tX([tZ],ri.prototype,"rasterState",void 0);var ro=/*#__PURE__*/function(){function e(e,t){this.name=e,this._refCount=0,this._destroyed=!1,this.name=e,this._subShaders=t}var t=e.prototype;return t._registerPath=function(e){for(var t,n=nG(this._subShaders);!(t=n()).done;)for(var r,a=t.value,i=nG(a.passes);!(r=i()).done;)r.value._path=e},t.compileVariant=function(t,n){var r=e._compileMacros;r.clear();for(var a=0,i=n.length;a<i;a++)r.enable(nH.getByName(n[a]));for(var o=!1,s=this._subShaders,l=0,c=s.length;l<c;l++)for(var u=s[l].passes,d=0,h=u.length;d<h;d++){var _=u[d]._getShaderProgram(t,r);o=0===d?_.isValid:o&&_.isValid}return o},t.destroy=function(t){if(void 0===t&&(t=!1),!t&&0!==this._refCount)return!1;for(var n=this._subShaders,r=0,a=n.length;r<a;r++)for(var i=n[r].passes,o=0,s=i.length;o<s;o++)i[o]._destroy();return delete e._shaderMap[this.name],this._destroyed=!0,!0},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e},e.create=function(t,n,r){var a,i=e._shaderMap;if(n){if(i[t]){console.error('Shader named "'+t+'" already exists.');return}if("string"==typeof n)a=new e(t,[new n7("Default",[new n6(n,r)])]);else if(n.length>0)a=n[0].constructor===n6?new e(t,[new n7("Default",n)]):new e(t,n.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(t);if(i[o.name]){console.error('Shader named "'+o.name+'" already exists.');return}var s=o.subShaders.map(function(t){var n=t.passes.map(function(t){if(t.isUsePass){var n,r,a=t.name.split("/");return null==(r=e.find(a[0]))?void 0:null==(n=r.subShaders.find(function(e){return e.name===a[1]}))?void 0:n.passes.find(function(e){return e.name===a[2]})}var i=new n6(t.name,t.contents,t.vertexEntry,t.fragmentEntry,t.tags),o=t.renderStates,s=o.constantMap,l=o.variableMap;if(Object.keys(s).length>0||Object.keys(l).length>0){var c=new ri;for(var u in i._renderState=c,s)e._applyConstRenderStates(c,parseInt(u),s[u]);var d={};for(var h in l)d[h]=nY.getByName(l[h]);i._renderStateDataMap=d}return i});return new n7(t.name,n,t.tags)});return a=new e(o.name,s),i[o.name]=a,a}return i[t]=a,a},e.find=function(t){return e._shaderMap[t]},e._applyConstRenderStates=function(e,t,n){switch(t){case nO.BlendStateEnabled0:e.blendState.targetBlendState.enabled=n;break;case nO.BlendStateColorBlendOperation0:e.blendState.targetBlendState.colorBlendOperation=n;break;case nO.BlendStateAlphaBlendOperation0:e.blendState.targetBlendState.alphaBlendOperation=n;break;case nO.BlendStateSourceColorBlendFactor0:e.blendState.targetBlendState.sourceColorBlendFactor=n;break;case nO.BlendStateDestinationColorBlendFactor0:e.blendState.targetBlendState.destinationColorBlendFactor=n;break;case nO.BlendStateSourceAlphaBlendFactor0:e.blendState.targetBlendState.sourceAlphaBlendFactor=n;break;case nO.BlendStateDestinationAlphaBlendFactor0:e.blendState.targetBlendState.destinationAlphaBlendFactor=n;break;case nO.BlendStateColorWriteMask0:e.blendState.targetBlendState.colorWriteMask=n;break;case nO.DepthStateEnabled:e.depthState.enabled=n;break;case nO.DepthStateWriteEnabled:e.depthState.writeEnabled=n;break;case nO.DepthStateCompareFunction:e.depthState.compareFunction=n;break;case nO.StencilStateEnabled:e.stencilState.enabled=n;break;case nO.StencilStateReferenceValue:e.stencilState.referenceValue=n;break;case nO.StencilStateMask:e.stencilState.mask=n;break;case nO.StencilStateWriteMask:e.stencilState.writeMask=n;break;case nO.StencilStateCompareFunctionFront:e.stencilState.compareFunctionFront=n;break;case nO.StencilStateCompareFunctionBack:e.stencilState.compareFunctionBack=n;break;case nO.StencilStatePassOperationFront:e.stencilState.passOperationFront=n;break;case nO.StencilStatePassOperationBack:e.stencilState.passOperationBack=n;break;case nO.StencilStateFailOperationFront:e.stencilState.failOperationFront=n;break;case nO.StencilStateFailOperationBack:e.stencilState.failOperationBack=n;break;case nO.StencilStateZFailOperationFront:e.stencilState.zFailOperationFront=n;break;case nO.StencilStateZFailOperationBack:e.stencilState.zFailOperationBack=n;break;case nO.RasterStateCullMode:e.rasterState.cullMode=n;break;case nO.RasterStateDepthBias:e.rasterState.depthBias=n;break;case nO.RasterStateSlopeScaledDepthBias:e.rasterState.slopeScaledDepthBias=n;break;case nO.RenderQueueType:e.renderQueueType=n}},e.getMacroByName=function(e,t){return nH.getByName(e,t)},e.getPropertyByName=function(e){return nY.getByName(e)},tG(e,[{key:"subShaders",get:function(){return this._subShaders}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();ro._compileMacros=new nW,ro._shaderMap=Object.create(null);var rs=/*#__PURE__*/function(){function e(e){this._propertyValueMap=Object.create(null),this._macroCollection=new nW,this._macroMap=Object.create(null),this._refCount=0,this._group=e}var t=e.prototype;return t.getFloat=function(e){return this.getPropertyValue(e)},t.setFloat=function(e,t){this._setPropertyValue(e,nV.Float,t)},t.getInt=function(e){return this.getPropertyValue(e)},t.setInt=function(e,t){this._setPropertyValue(e,nV.Int,t)},t.getFloatArray=function(e){return this.getPropertyValue(e)},t.setFloatArray=function(e,t){this._setPropertyValue(e,nV.FloatArray,t)},t.getIntArray=function(e){return this.getPropertyValue(e)},t.setIntArray=function(e,t){this._setPropertyValue(e,nV.IntArray,t)},t.getVector2=function(e){return this.getPropertyValue(e)},t.setVector2=function(e,t){this._setPropertyValue(e,nV.Vector2,t)},t.getVector3=function(e){return this.getPropertyValue(e)},t.setVector3=function(e,t){this._setPropertyValue(e,nV.Vector3,t)},t.getVector4=function(e){return this.getPropertyValue(e)},t.setVector4=function(e,t){this._setPropertyValue(e,nV.Vector4,t)},t.getMatrix=function(e){return this.getPropertyValue(e)},t.setMatrix=function(e,t){this._setPropertyValue(e,nV.Matrix,t)},t.getColor=function(e){return this.getPropertyValue(e)},t.setColor=function(e,t){this._setPropertyValue(e,nV.Color,t)},t.getTexture=function(e){return this.getPropertyValue(e)},t.setTexture=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);r&&r._addReferCount(-n),t&&t._addReferCount(n)}this._setPropertyValue(e,nV.Texture,t)},t.getTextureArray=function(e){return this.getPropertyValue(e)},t.setTextureArray=function(e,t){var n=this._refCount;if(n>0){var r=this.getPropertyValue(e);if(r)for(var a=0,i=r.length;a<i;a++)r[a]._addReferCount(-n);if(t)for(var o=0,s=t.length;o<s;o++)t[o]._addReferCount(n)}this._setPropertyValue(e,nV.TextureArray,t)},t.getPropertyValue=function(e){return"string"==typeof e&&(e=nY.getByName(e)),this._propertyValueMap[e._uniqueId]},t.enableMacro=function(e,t){"string"==typeof e&&(e=nH.getByName(e,t));var n=e._nameId,r=this._macroMap[n];if(r!==e){var a=this._macroCollection;r&&a.disable(r),a.enable(e),this._macroMap[n]=e}},t.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=nH._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},t.getMacros=function(e){if(!e)return Object.values(this._macroMap);var t=this._macroMap;for(var n in e.length=0,t)e.push(t[n])},t.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=nY._propertyIdMap;for(var a in n)t.push(r[a]);if(!e)return t},t.clone=function(){var t=new e(this._group);return this.cloneTo(t),t},t.cloneTo=function(e){t$.deepCloneObject(this._macroCollection,e._macroCollection,new Map),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,a=Object.keys(n),i=0,o=a.length;i<o;i++){var s=a[i],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(tK(l,ns))r[s]=l,t>0&&l._addReferCount(t);else if(tK(l,Array)||tK(l,Float32Array)||tK(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},t._setPropertyValue=function(e,t,n){if("string"==typeof e&&(e=nY.getByName(e)),e._group!==this._group){if(void 0===e._group)e._group=this._group;else throw"Shader property "+e.name+" has been used as "+n8[e._group]+" group."}if(e._type!==t){if(void 0===e._type)e._type=t;else throw"Shader property "+e.name+" has been used as "+nV[e._type]+" type."}this._propertyValueMap[e._uniqueId]=n},t._getReferCount=function(){return this._refCount},t._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&tK(r,ns)&&r._addReferCount(e)}},e}();tX([tq],rs.prototype,"_group",void 0),tX([tq],rs.prototype,"_propertyValueMap",void 0),tX([tq],rs.prototype,"_macroCollection",void 0),tX([tq],rs.prototype,"_macroMap",void 0),tX([tq],rs.prototype,"_refCount",void 0);var rl=/*#__PURE__*/function(){function e(){}return e.canBatchSprite=function(t,n){if(!0===n.shaderPasses[0].getTagValue(e._disableBatchTag)||t.subChunk.chunk!==n.subChunk.chunk)return!1;var r=t.component,a=n.component,i=r.maskInteraction;return i===a.maskInteraction&&(i===nv.None||r.maskLayer===a.maskLayer)&&t.texture===n.texture&&t.material===n.material},e.canBatchSpriteMask=function(e,t){if(e.subChunk.chunk!==t.subChunk.chunk)return!1;var n=r2._alphaCutoffProperty;return e.texture===t.texture&&e.component.shaderData.getFloat(n)===t.component.shaderData.getFloat(n)},e.batchFor2D=function(e,t){var n=t?t.subChunk:e.subChunk,r=n.chunk,a=n.indices,i=a.length,o=r.updateIndexLength;if(t)e.subChunk.subMesh.count+=i;else{var s=n.subMesh;s.start=o,s.count=i}for(var l=n.vertexArea,c=l.start,u=l.size,d=c/9,h=r.indices,_=0;_<i;++_)h[o++]=d+a[_];r.updateIndexLength+=i,r.updateVertexStart=Math.min(r.updateVertexStart,c),r.updateVertexEnd=Math.max(r.updateVertexEnd,c+u)},e}();rl._disableBatchTag=n0.getByName("spriteDisableBatching");var rc=((V={})[V.None=0]="None",V[V.Scene=1]="Scene",V[V.Hierarchy=2]="Hierarchy",V[V.All=3]="All",V),ru=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t.engine)||this)._awoken=!1,n._phasedActiveInScene=!1,n._phasedActive=!1,n._enabled=!0,n._entity=t,n}tW(t,e);var n=t.prototype;return n._onAwake=function(){},n._onEnable=function(){},n._onDisable=function(){},n._onEnableInScene=function(){},n._onDisableInScene=function(){},n._setActive=function(e,t){var n=this._entity;t&rc.Scene&&(e?!this._phasedActiveInScene&&n._isActiveInScene&&this._enabled&&(this._phasedActiveInScene=!0,this._onEnableInScene()):this._phasedActiveInScene&&!(n._isActiveInScene&&this._enabled)&&(this._phasedActiveInScene=!1,this._onDisableInScene())),t&rc.Hierarchy&&(e?(!this._awoken&&n._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&n._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(n._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable()))},n._addResourceReferCount=function(e,t){this._entity._isTemplate||e._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._entity;t._removeComponent(this),this._enabled&&(t._isActiveInScene&&this._onDisableInScene(),t._isActiveInHierarchy&&this._onDisable())},tG(t,[{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}}]),t}(t0);tX([tq],ru.prototype,"_entity",void 0),tX([tq],ru.prototype,"_awoken",void 0),tX([tq],ru.prototype,"_phasedActiveInScene",void 0),tX([tq],ru.prototype,"_phasedActive",void 0),tX([tQ],ru.prototype,"_enabled",void 0);var rd=/*#__PURE__*/function(){function e(){}return e._addCheck=function(t,n){for(;n!==ru;){var r=e._dependenciesMap.get(n);if(r)for(var a=r.components,i=r.mode,o=0,s=a.length;o<s;o++){var l=a[o];if(!t.getComponent(l)){if(1===i)t.addComponent(l);else throw"Should add "+l.name+" before adding "+n.name}}n=Object.getPrototypeOf(n)}},e._removeCheck=function(t,n){for(var r=t._components,a=r.length;n!==ru;){for(var i=0,o=0;o<a;o++)if(tK(r[o],n)&&++i>1)return;var s=e._invDependenciesMap.get(n);if(s){for(var l=0,c=s.length;l<c;l++)if(t.getComponent(s[l]))throw"Should remove "+s[l].name+" before remove "+n.name}n=Object.getPrototypeOf(n)}},e._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},e}();function rh(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){rd._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return rd._addInvDependency(t,e)})}}rd._invDependenciesMap=new Map,rd._dependenciesMap=new Map;var r_=((k={})[k.CheckOnly=0]="CheckOnly",k[k.AutoAdd=1]="AutoAdd",k),rf=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.flag=!0,t}return tW(t,e),t.prototype.dispatch=function(){this.flag=!0},t}(/*#__PURE__*/function(){function e(){this._flagManagers=[]}var t=e.prototype;return t.clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},t.destroy=function(){this._removeFromManagers(),this._flagManagers=null},t._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)nT.removeFromArray(e[t]._updateFlags,this)},e}()),rp=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._position=new tT,n._rotation=new tT,n._rotationQuaternion=new tF,n._scale=new tT(1,1,1),n._localUniformScaling=!0,n._worldPosition=new tT,n._worldRotation=new tT,n._worldRotationQuaternion=new tF,n._worldUniformScaling=!0,n._lossyWorldScale=new tT(1,1,1),n._localMatrix=new tL,n._worldMatrix=new tL,n._worldForward=null,n._worldRight=null,n._worldUp=null,n._isParentDirty=!0,n._parentTransformCache=null,n._dirtyFlag=188,n._onPositionChanged=n._onPositionChanged.bind(n),n._onWorldPositionChanged=n._onWorldPositionChanged.bind(n),n._onRotationChanged=n._onRotationChanged.bind(n),n._onWorldRotationChanged=n._onWorldRotationChanged.bind(n),n._onRotationQuaternionChanged=n._onRotationQuaternionChanged.bind(n),n._onWorldRotationQuaternionChanged=n._onWorldRotationQuaternionChanged.bind(n),n._onScaleChanged=n._onScaleChanged.bind(n),n._position._onValueChanged=n._onPositionChanged,n._worldPosition._onValueChanged=n._onWorldPositionChanged,n._rotation._onValueChanged=n._onRotationChanged,n._worldRotation._onValueChanged=n._onWorldRotationChanged,n._rotationQuaternion._onValueChanged=n._onRotationQuaternionChanged,n._worldRotationQuaternion._onValueChanged=n._onWorldRotationQuaternionChanged,n._scale._onValueChanged=n._onScaleChanged,n}tW(t,e);var n=t.prototype;return n.setPosition=function(e,t,n){this._position.set(e,t,n)},n.setRotation=function(e,t,n){this._rotation.set(e,t,n)},n.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},n.setScale=function(e,t,n){this._scale.set(e,t,n)},n.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},n.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},n.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},n.translate=function(e,n,r,a){if("number"==typeof e){var i=t._tempVec30;i.set(e,n,r),this._translate(i,a)}else this._translate(e,n)},n.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},n.rotateByAxis=function(e,n,r){void 0===r&&(r=!0);var a=n*tS.degreeToRadFactor;tF.rotationAxisAngle(e,a,t._tempQuat0),this._rotateByQuat(t._tempQuat0,r)},n.lookAt=function(e,n){var r=t._tempVec30;tT.subtract(this.worldPosition,e,r);var a=r.length();if(!(a<=tS.zeroTolerance)){r.scale(1/a);var i=t._tempVec31;if(n?tT.cross(n,r,i):i.set(r.z,0,-r.x),!((a=i.length())<=tS.zeroTolerance)){i.scale(1/a);var o=t._tempVec32;tT.cross(r,i,o);var s=t._tempMat41,l=s.elements;l[0]=i.x,l[1]=i.y,l[2]=i.z,l[4]=o.x,l[5]=o.y,l[6]=o.z,l[8]=r.x,l[9]=r.y,l[10]=r.z,s.getRotation(this._worldRotationQuaternion)}}},n._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag(444)},n._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},n._copyFrom=function(e){this._position.copyFrom(e.position),this._rotation.copyFrom(e.rotation),this._scale.copyFrom(e.scale)},n._onDestroy=function(){e.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},n._updateWorldPositionFlag=function(){if(!this._isContainDirtyFlags(132)){this._worldAssociatedChange(132);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionFlag()}},n._updateWorldRotationFlag=function(){var e=this._getParentTransform(),t=!e||e._getWorldUniformScaling()?152:184;if(!this._isContainDirtyFlags(t)){this._worldAssociatedChange(t),t=this._getWorldUniformScaling()?156:188;for(var n,r=this._entity._children,a=0,i=r.length;a<i;a++)null==(n=r[a].transform)||n._updateWorldPositionAndRotationFlag(t)}},n._updateWorldPositionAndRotationFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e),e=this._getWorldUniformScaling()?156:188;for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndRotationFlag(e)}},n._updateWorldScaleFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e),e|=4;for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndScaleFlag(e)}},n._updateWorldPositionAndScaleFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e);for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateWorldPositionAndScaleFlag(e)}},n._updateAllWorldFlag=function(e){if(!this._isContainDirtyFlags(e)){this._worldAssociatedChange(e);for(var t,n=this._entity._children,r=0,a=n.length;r<a;r++)null==(t=n[r].transform)||t._updateAllWorldFlag(e)}},n._getParentTransform=function(){if(!this._isParentDirty)return this._parentTransformCache;for(var e=null,t=this._entity.parent;t;){var n=t.transform;if(n){e=n;break}t=t.parent}return this._parentTransformCache=e,this._isParentDirty=!1,e},n._getScaleMatrix=function(){var e=t._tempQuat0,n=t._tempMat30,r=t._tempMat31,a=t._tempMat32;return r.copyFromMatrix(this.worldMatrix),tF.invert(this.worldRotationQuaternion,e),tP.rotationQuaternion(e,n),tP.multiply(n,r,a),a},n._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._entity._updateFlagManager.dispatch(e)},n._rotateByQuat=function(e,t){t?tF.multiply(this.rotationQuaternion,e,this._rotationQuaternion):tF.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},n._translate=function(e,n){if(void 0===n&&(n=!0),n){var r=t._tempVec30;tT.transformByQuat(e,this.worldRotationQuaternion,r),this.worldPosition.add(r)}else this.worldPosition.add(e)},n._rotateXYZ=function(e,n,r,a){void 0===a&&(a=!0);var i=tS.degreeToRadFactor,o=t._tempQuat0;tF.rotationEuler(e*i,n*i,r*i,o),this._rotateByQuat(o,a)},n._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},n._onWorldPositionChanged=function(){var e=this._worldPosition,n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat41),tT.transformCoordinate(e,t._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},n._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},n._onWorldRotationChanged=function(){var e=this._worldRotation;tF.rotationEuler(tS.degreeToRadian(e.x),tS.degreeToRadian(e.y),tS.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},n._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},n._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,n=this._getParentTransform();if(n){var r=t._tempQuat0;tF.invert(n.worldRotationQuaternion,r),tF.multiply(r,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},n._onScaleChanged=function(){var e=this._scale,t=e.x,n=e.y,r=e.z;this._setDirtyFlagTrue(64);var a=t==n&&n==r;this._localUniformScaling!==a?(this._localUniformScaling=a,this._updateWorldScaleFlag(416)):this._updateWorldScaleFlag(160)},n._getWorldUniformScaling=function(){if(this._isContainDirtyFlag(256)){var e=this._localUniformScaling;if(e){var t=this._getParentTransform();this._worldUniformScaling=e&&(!t||t._getWorldUniformScaling())}else this._worldUniformScaling=!1;this._setDirtyFlagFalse(256)}return this._worldUniformScaling},n.registerWorldChangeFlag=function(){return this.entity._updateFlagManager.createFlag(rf)},tG(t,[{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(tS.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(tS.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,tF.rotationEuler(tS.degreeToRadian(this._rotation.x),tS.degreeToRadian(this._rotation.y),tS.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):tF.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?tF.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):tF.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)&&(tL.affineTransformation(this._scale,this.rotationQuaternion,this._position,this._localMatrix),this._setDirtyFlagFalse(64)),this._localMatrix},set:function(e){this._localMatrix!==e&&this._localMatrix.copyFrom(e);var t=this._position,n=this._rotationQuaternion,r=this._scale;t._onValueChanged=n._onValueChanged=r._onValueChanged=null,this._localMatrix.decompose(t,n,r),t._onValueChanged=this._onPositionChanged,n._onValueChanged=this._onRotationQuaternionChanged,r._onValueChanged=this._onScaleChanged,this._setDirtyFlagTrue(1),this._setDirtyFlagFalse(66);var a=r.x===r.y&&r.y===r.z;this._localUniformScaling!==a?(this._localUniformScaling=a,this._updateAllWorldFlag(444)):this._updateAllWorldFlag(188)}},{key:"worldMatrix",get:function(){if(this._isContainDirtyFlag(128)){var e=this._getParentTransform();e?tL.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 n=this._getParentTransform();n?(tL.invert(n.worldMatrix,t._tempMat42),tL.multiply(t._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 tT),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 tT),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 tT),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),t}(ru);rp._tempQuat0=new tF,rp._tempVec30=new tT,rp._tempVec31=new tT,rp._tempVec32=new tT,rp._tempMat30=new tP,rp._tempMat31=new tP,rp._tempMat32=new tP,rp._tempMat41=new tL,rp._tempMat42=new tL,tX([tZ],rp.prototype,"_position",void 0),tX([tZ],rp.prototype,"_rotation",void 0),tX([tZ],rp.prototype,"_rotationQuaternion",void 0),tX([tZ],rp.prototype,"_scale",void 0),tX([tQ],rp.prototype,"_localUniformScaling",void 0),tX([tZ],rp.prototype,"_worldPosition",void 0),tX([tZ],rp.prototype,"_worldRotation",void 0),tX([tZ],rp.prototype,"_worldRotationQuaternion",void 0),tX([tQ],rp.prototype,"_worldUniformScaling",void 0),tX([tZ],rp.prototype,"_lossyWorldScale",void 0),tX([tZ],rp.prototype,"_localMatrix",void 0),tX([tZ],rp.prototype,"_worldMatrix",void 0),tX([tq],rp.prototype,"_worldForward",void 0),tX([tq],rp.prototype,"_worldRight",void 0),tX([tq],rp.prototype,"_worldUp",void 0),tX([tq],rp.prototype,"_isParentDirty",void 0),tX([tq],rp.prototype,"_parentTransformCache",void 0),tX([tq],rp.prototype,"_onPositionChanged",null),tX([tq],rp.prototype,"_onWorldPositionChanged",null),tX([tq],rp.prototype,"_onRotationChanged",null),tX([tq],rp.prototype,"_onWorldRotationChanged",null),tX([tq],rp.prototype,"_onRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onWorldRotationQuaternionChanged",null),tX([tq],rp.prototype,"_onScaleChanged",null);var rm=((z={})[z.LocalEuler=1]="LocalEuler",z[z.LocalQuat=2]="LocalQuat",z[z.WorldPosition=4]="WorldPosition",z[z.WorldEuler=8]="WorldEuler",z[z.WorldQuat=16]="WorldQuat",z[z.WorldScale=32]="WorldScale",z[z.LocalMatrix=64]="LocalMatrix",z[z.WorldMatrix=128]="WorldMatrix",z[z.IsWorldUniformScaling=256]="IsWorldUniformScaling",z[z.WmWp=132]="WmWp",z[z.WmWeWq=152]="WmWeWq",z[z.WmWeWqWs=184]="WmWeWqWs",z[z.WmWpWeWq=156]="WmWpWeWq",z[z.WmWs=160]="WmWs",z[z.WmWsWus=416]="WmWsWus",z[z.WmWpWs=164]="WmWpWs",z[z.WmWpWeWqWs=188]="WmWpWeWqWs",z[z.WmWpWeWqWsWus=444]="WmWpWeWqWsWus",z),rg=((U={})[U.Layer0=1]="Layer0",U[U.Layer1=2]="Layer1",U[U.Layer2=4]="Layer2",U[U.Layer3=8]="Layer3",U[U.Layer4=16]="Layer4",U[U.Layer5=32]="Layer5",U[U.Layer6=64]="Layer6",U[U.Layer7=128]="Layer7",U[U.Layer8=256]="Layer8",U[U.Layer9=512]="Layer9",U[U.Layer10=1024]="Layer10",U[U.Layer11=2048]="Layer11",U[U.Layer12=4096]="Layer12",U[U.Layer13=8192]="Layer13",U[U.Layer14=16384]="Layer14",U[U.Layer15=32768]="Layer15",U[U.Layer16=65536]="Layer16",U[U.Layer17=131072]="Layer17",U[U.Layer18=262144]="Layer18",U[U.Layer19=524288]="Layer19",U[U.Layer20=1048576]="Layer20",U[U.Layer21=2097152]="Layer21",U[U.Layer22=4194304]="Layer22",U[U.Layer23=8388608]="Layer23",U[U.Layer24=0x1000000]="Layer24",U[U.Layer25=0x2000000]="Layer25",U[U.Layer26=0x4000000]="Layer26",U[U.Layer27=0x8000000]="Layer27",U[U.Layer28=0x10000000]="Layer28",U[U.Layer29=0x20000000]="Layer29",U[U.Layer30=0x40000000]="Layer30",U[U.Layer31=0x80000000]="Layer31",U[U.Everything=0xffffffff]="Everything",U[U.Nothing=0]="Nothing",U);e.Renderer=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n)||this)._onUpdateIndex=-1,r._rendererIndex=-1,r._globalShaderMacro=new nW,r._bounds=new tE,r._maskInteraction=nv.None,r._maskLayer=rg.Layer0,r._batchedTransformShaderData=!1,r._overrideUpdate=!1,r._materials=[],r._dirtyUpdateFlag=0,r._rendererLayer=new tI,r._shaderData=new rs(n8.Renderer),r._mvMatrix=new tL,r._mvpMatrix=new tL,r._mvInvMatrix=new tL,r._normalMatrix=new tL,r._materialsInstanced=[],r._priority=0,r._receiveShadows=!0,r.castShadows=!0;var r,a=t.prototype,i=r.shaderData;return r._overrideUpdate=r.update!==a.update,r._addResourceReferCount(r.shaderData,1),r._onTransformChanged=r._onTransformChanged.bind(r),r._setTransformEntity(n),i.enableMacro(t._receiveShadowMacro),i.setVector4(t._rendererLayerProperty,r._rendererLayer),r}tW(t,e);var n=t.prototype;return n.getInstanceMaterial=function(e){void 0===e&&(e=0);var t=this._materials;if(t.length>e){var n=t[e];if(n)return this._materialsInstanced[e]?n:this._createInstanceMaterial(n,e)}return null},n.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},n.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},n.getInstanceMaterials=function(){for(var e=this._materials,t=this._materialsInstanced,n=0,r=e.length;n<r;n++)t[n]||this._createInstanceMaterial(this._materials[n],n);return e},n.getMaterials=function(){return this._materials},n.setMaterials=function(e){for(var t=e.length,n=this._materials,r=this._materialsInstanced,a=t,i=n.length;a<i;a++){var o=n[a];o&&this._addResourceReferCount(o,-1)}n.length!==t&&(n.length=t),0!==r.length&&(r.length=0);for(var s=0;s<t;s++){var l=n[s],c=e[s];l!==c&&(n[s]=c,l&&this._addResourceReferCount(l,-1),c&&this._addResourceReferCount(c,1))}},n.update=function(e){},n._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},n._prepareRender=function(e){this._renderFrameCount!==this.engine.time.frameCount&&this._update(e);var n=e.virtualCamera,r=n.position,a=this.bounds.getCenter(t._tempVector0);n.isOrthographic?(tT.subtract(a,r,a),this._distanceForSort=tT.dot(a,n.forward)):this._distanceForSort=tT.distanceSquared(a,r),this._render(e),nW.unionCollection(e.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},n._cloneTo=function(e,t,n){for(var r=this._materials,a=0,i=r.length;a<i;a++)e._setMaterial(a,r[a])},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._setTransformEntity(null),this._addResourceReferCount(this.shaderData,-1);for(var t=this._materials,n=0,r=t.length;n<r;n++){var a=t[n];a&&this._addResourceReferCount(a,-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},n._updateTransformShaderData=function(e,t,n){var r=this._transformEntity.transform.worldMatrix;t?this._updateProjectionRelatedShaderData(e,r,n):this._updateWorldViewRelatedShaderData(e,r,n)},n._canBatch=function(e,t){return!1},n._batch=function(e,t){},n._update=function(e){var t=this.entity.layer;this._rendererLayer.set(65535&t,t>>>16&65535,0,0)},n._updateWorldViewRelatedShaderData=function(e,n,r){var a=this.shaderData,i=this._mvInvMatrix;if(r){var o=tL._identity;tL.invert(e.viewMatrix,i),a.setMatrix(t._localMatrixProperty,o),a.setMatrix(t._worldMatrixProperty,o),a.setMatrix(t._mvMatrixProperty,e.viewMatrix),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,o)}else{var s=this._mvMatrix,l=this._normalMatrix;tL.multiply(e.viewMatrix,n,s),tL.invert(s,i),tL.invert(n,l),l.transpose(),a.setMatrix(t._localMatrixProperty,this._transformEntity.transform.localMatrix),a.setMatrix(t._worldMatrixProperty,n),a.setMatrix(t._mvMatrixProperty,s),a.setMatrix(t._mvInvMatrixProperty,i),a.setMatrix(t._normalMatrixProperty,l)}this._updateProjectionRelatedShaderData(e,n,r)},n._updateProjectionRelatedShaderData=function(e,n,r){if(r)this.shaderData.setMatrix(t._mvpMatrixProperty,e.viewProjectionMatrix);else{var a=this._mvpMatrix;tL.multiply(e.viewProjectionMatrix,n,a),this.shaderData.setMatrix(t._mvpMatrixProperty,a)}},n._setTransformEntity=function(e){var t=this._transformEntity;e!==t&&(null==t||t._updateFlagManager.removeListener(this._onTransformChanged),null==e||e._updateFlagManager.addListener(this._onTransformChanged),this._transformEntity=e)},n._updateBounds=function(e){},n._render=function(e){throw"not implement"},n._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",this._addResourceReferCount(e,-1),this._addResourceReferCount(n,1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},n._setMaterial=function(e,t){var n=this._materials;e>=n.length&&(n.length=e+1);var r=n[e];if(r!==t){var a=this._materialsInstanced;e<a.length&&(a[e]=!1),r&&this._addResourceReferCount(r,-1),t&&this._addResourceReferCount(t,1),n[e]=t}},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},tG(t,[{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(e){this._receiveShadows!==e&&(e?this.shaderData.enableMacro(t._receiveShadowMacro):this.shaderData.disableMacro(t._receiveShadowMacro),this._receiveShadows=e)}},{key:"materialCount",get:function(){return this._materials.length},set:function(e){var t=this._materials,n=this._materialsInstanced;t.length!==e&&(t.length=e),n.length>e&&(n.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}}]),t}(ru),e.Renderer._tempVector0=new tT,e.Renderer._receiveShadowMacro=nH.getByName("RENDERER_IS_RECEIVE_SHADOWS"),e.Renderer._localMatrixProperty=nY.getByName("renderer_LocalMat"),e.Renderer._worldMatrixProperty=nY.getByName("renderer_ModelMat"),e.Renderer._mvMatrixProperty=nY.getByName("renderer_MVMat"),e.Renderer._mvpMatrixProperty=nY.getByName("renderer_MVPMat"),e.Renderer._mvInvMatrixProperty=nY.getByName("renderer_MVInvMat"),e.Renderer._normalMatrixProperty=nY.getByName("renderer_NormalMat"),e.Renderer._rendererLayerProperty=nY.getByName("renderer_Layer"),tX([tq],e.Renderer.prototype,"_distanceForSort",void 0),tX([tq],e.Renderer.prototype,"_onUpdateIndex",void 0),tX([tq],e.Renderer.prototype,"_rendererIndex",void 0),tX([tq],e.Renderer.prototype,"_globalShaderMacro",void 0),tX([tq],e.Renderer.prototype,"_bounds",void 0),tX([tq],e.Renderer.prototype,"_renderFrameCount",void 0),tX([tQ],e.Renderer.prototype,"_maskInteraction",void 0),tX([tQ],e.Renderer.prototype,"_maskLayer",void 0),tX([tq],e.Renderer.prototype,"_batchedTransformShaderData",void 0),tX([tq],e.Renderer.prototype,"_transformEntity",void 0),tX([tq],e.Renderer.prototype,"_overrideUpdate",void 0),tX([tq],e.Renderer.prototype,"_materials",void 0),tX([tq],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),tX([tq],e.Renderer.prototype,"_rendererLayer",void 0),tX([tZ],e.Renderer.prototype,"_shaderData",void 0),tX([tq],e.Renderer.prototype,"_mvMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvpMatrix",void 0),tX([tq],e.Renderer.prototype,"_mvInvMatrix",void 0),tX([tq],e.Renderer.prototype,"_normalMatrix",void 0),tX([tq],e.Renderer.prototype,"_materialsInstanced",void 0),tX([tQ],e.Renderer.prototype,"_priority",void 0),tX([tQ],e.Renderer.prototype,"_receiveShadows",void 0),tX([tq],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=tX([rh(rp,r_.CheckOnly)],e.Renderer);var rv=((G={})[G.WorldVolume=1]="WorldVolume",G);function ry(){return function(e){}}var rx=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(4);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n=t.width,r=t.height,a=t.sprite,i=a.pivot,o=i.x,s=i.y,l=e._worldMatrix,c=l.elements,u=t.entity.transform.worldMatrix.elements,d=t.flipX?-n:n,h=t.flipY?-r:r;c[0]=u[0]*d,c[1]=u[1]*d,c[2]=u[2]*d,c[4]=u[4]*h,c[5]=u[5]*h,c[6]=u[6]*h,c[8]=u[8],c[9]=u[9],c[10]=u[10],c[12]=u[12]-o*c[0]-s*c[4],c[13]=u[13]-o*c[1]-s*c[5],c[14]=u[14]-o*c[2]-s*c[6];for(var _=a._getPositions(),f=t._subChunk,p=f.chunk.vertices,m=0,g=f.vertexArea.start;m<4;++m,g+=9){var v=_[m],y=v.x,x=v.y;p[g]=c[0]*y+c[4]*x+c[12],p[g+1]=c[1]*y+c[5]*x+c[13],p[g+2]=c[2]*y+c[6]*x+c[14]}tE.transform(a._getBounds(),l,t._bounds)},e.updateUVs=function(e){var t=e.sprite._getUVs(),n=t[0],r=n.x,a=n.y,i=t[3],o=i.x,s=i.y,l=e._subChunk,c=l.chunk.vertices,u=l.vertexArea.start+3;c[u]=r,c[u+1]=a,c[u+9]=o,c[u+10]=a,c[u+18]=r,c[u+19]=s,c[u+27]=o,c[u+28]=s},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<4;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rx._rectangleTriangles=[0,1,2,2,1,3],rx._worldMatrix=new tL,rx=tX([ry()],rx);var rb=/*#__PURE__*/function(){function e(){}return e.resetData=function(t){var n=t._getChunkManager(),r=t._subChunk;r&&n.freeSubChunk(r);var a=n.allocateSubChunk(16);a.indices=e._rectangleTriangles,t._subChunk=a},e.updatePositions=function(t){var n,r,a=t.width,i=t.height,o=t.sprite,s=o.border,l=o._getPositions(),c=l[0],u=c.x,d=c.y,h=l[3],_=h.x,f=h.y,p=o.width,m=o.height,g=p*s.x,v=m*s.y,y=p*s.z,x=m*s.w;if(g+y>a){var b=a/(g+y);n=[p*u*b,g*b,g*b,a-p*(1-_)*b]}else n=[p*u,g,a-y,a-p*(1-_)];if(x+v>i){var C=i/(x+v);r=[m*d*C,v*C,v*C,i-m*(1-f)*C]}else r=[m*d,v,i-x,i-m*(1-f)];var S=t.sprite.pivot,T=S.x,A=S.y,E=t.width*T,R=t.height*A,M=e._worldMatrix,w=M.elements,P=t.entity.transform.worldMatrix.elements,F=t.flipX?-1:1,L=t.flipY?-1:1;w[0]=P[0]*F,w[1]=P[1]*F,w[2]=P[2]*F,w[4]=P[4]*L,w[5]=P[5]*L,w[6]=P[6]*L,w[8]=P[8],w[9]=P[9],w[10]=P[10],w[12]=P[12]-E*w[0]-R*w[4],w[13]=P[13]-E*w[1]-R*w[5],w[14]=P[14]-E*w[2]-R*w[6];for(var D=t._subChunk,B=D.chunk.vertices,I=0,O=D.vertexArea.start;I<4;I++)for(var N=n[I],V=0;V<4;V++,O+=9){var k=r[V];B[O]=w[0]*N+w[4]*k+w[12],B[O+1]=w[1]*N+w[5]*k+w[13],B[O+2]=w[2]*N+w[6]*k+w[14]}var z=t._bounds,U=z.min,G=z.max;U.set(n[0],r[0],0),G.set(n[3],r[3],0),t._bounds.transform(M)},e.updateUVs=function(e){for(var t=e._subChunk,n=t.chunk.vertices,r=e.sprite._getUVs(),a=0,i=t.vertexArea.start+3;a<4;a++)for(var o=r[a].x,s=0;s<4;s++,i+=9)n[i]=o,n[i+1]=r[s].y},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.a,s=t.chunk.vertices,l=0,c=t.vertexArea.start+5;l<16;++l,c+=9)s[c]=r,s[c+1]=a,s[c+2]=i,s[c+3]=o},e}();rb._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],rb._worldMatrix=new tL,rb=tX([ry()],rb);var rC=/*#__PURE__*/function(){function e(e){void 0===e&&(e=0),this.length=0,this._loopCounter=0,this._blankCount=0,this._elements=Array(e)}var t=e.prototype;return t.add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},t.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},t.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},t.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},t.deleteByIndex=function(e){var t,n=this._elements;if(this._loopCounter>0)this._elements[e]=null,this._blankCount++;else{var r=this.length-1;e!==r&&(t=n[r],n[e]=t),n[r]=null,this.length--}return t},t.forEach=function(e,t){this._startLoop();for(var n=this._elements,r=0,a=this.length;r<a;r++){var i=n[r];i&&e(i,r)}this._endLoop(t)},t.forEachAndClean=function(e,t){this._startLoop();for(var n=this.length,r=this._elements,a=0;a<n;a++){var i=r[a];i&&e(i,a)}this._endLoopAndClean(n,r,t)},t.sort=function(e){nT._quickSort(this._elements,0,this.length,e)},t.garbageCollection=function(){this._elements.length=this.length},t._startLoop=function(){++this._loopCounter},t._endLoop=function(e){if(0==--this._loopCounter&&this._blankCount){var t=0,n=this.length-1,r=this._elements;e:do{for(;r[t];)if(++t>=n)break e;for(;!r[n];)if(t>=--n)break e;var a=r[n];null==e||e(a,t),r[t++]=a,r[n--]=null}while(t<n);this.length-=this._blankCount,this._blankCount=0}},t._endLoopAndClean=function(e,t,n){if(0==--this._loopCounter){for(var r=0,a=e,i=this.length;a<i;a++){var o=t[a];o&&(t[r]=o,null==n||n(o,r),r++)}this.length=r,this._blankCount=0}},tG(e,[{key:"isLopping",get:function(){return this._loopCounter>0}}]),e}(),rS=/*#__PURE__*/function(){function e(){}return e.resetData=function(e,t){if(t){var n=e._getChunkManager(),r=e._subChunk,a=r&&r.vertexArea.size!==9*t;if(a&&n.freeSubChunk(r),!r||a){var i=n.allocateSubChunk(t);i.indices=[],e._subChunk=i}}},e.updatePositions=function(t){var n,r,a,i,o,s,l=t.width,c=t.height,u=t.sprite,d=t.tileMode,h=t.tiledAdaptiveThreshold,_=e._posRow,f=e._posColumn,p=e._uvRow,m=e._uvColumn,g=t._getChunkManager().maxVertexCount;_.length=f.length=p.length=m.length=0;var v=d===nS.Adaptive?e._calculateAdaptiveDividing(u,l,c,h,_,f,p,m,g):e._calculateContinuousDividing(u,l,c,_,f,p,m,g);e.resetData(t,v);var y=t.sprite.pivot,x=y.x,b=y.y,C=t.width*x,S=t.height*b,T=e._worldMatrix,A=T.elements,E=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,M=t.flipY?-1:1;n=A[0]=E[0]*R,r=A[1]=E[1]*R,a=A[2]=E[2]*R,i=A[4]=E[4]*M,o=A[5]=E[5]*M,s=A[6]=E[6]*M,A[8]=E[8],A[9]=E[9],A[10]=E[10];for(var w=A[12]=E[12]-C*A[0]-S*A[4],P=A[13]=E[13]-C*A[1]-S*A[5],F=A[14]=E[14]-C*A[2]-S*A[6],L=_.length-1,D=f.length-1,B=t._subChunk,I=B.chunk.vertices,O=B.indices,N=0,V=0,k=0,z=B.vertexArea.start;k<D;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[V++]=N,O[V++]=N+1,O[V++]=N+2,O[V++]=N+2,O[V++]=N+1,O[V++]=N+3,N+=4;var X=_.get(G),K=f.get(k),Y=_.get(G+1),q=f.get(k+1);I[z]=n*X+i*K+w,I[z+1]=r*X+o*K+P,I[z+2]=a*X+s*K+F,I[z+9]=n*Y+i*K+w,I[z+10]=r*Y+o*K+P,I[z+11]=a*Y+s*K+F,I[z+18]=n*X+i*q+w,I[z+19]=r*X+o*q+P,I[z+20]=a*X+s*q+F,I[z+27]=n*Y+i*q+w,I[z+28]=r*Y+o*q+P,I[z+29]=a*Y+s*q+F,z+=36}}var Q=t._bounds,J=Q.min,Z=Q.max;J.set(_.get(0),f.get(0),0),Z.set(_.get(L),f.get(D),0),t._bounds.transform(T)},e.updateUVs=function(t){for(var n=e._posRow,r=e._posColumn,a=e._uvRow,i=e._uvColumn,o=n.length-1,s=r.length-1,l=t._subChunk,c=l.chunk.vertices,u=0,d=l.vertexArea.start+3;u<s;u++)for(var h=2*u,_=0;_<o;_++){var f=a.get(2*_),p=i.get(h),m=a.get(2*_+1),g=i.get(h+1);isNaN(f)||isNaN(p)||isNaN(m)||isNaN(g)||(c[d]=f,c[d+1]=p,c[d+9]=m,c[d+10]=p,c[d+18]=f,c[d+19]=g,c[d+27]=m,c[d+28]=g,d+=36)}},e.updateColor=function(e){for(var t=e._subChunk,n=e.color,r=n.r,a=n.g,i=n.b,o=n.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]=r,s[u+1]=a,s[u+2]=i,s[u+3]=o},e._calculateAdaptiveDividing=function(e,t,n,r,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],C=b.x,S=b.y,T=e._getUVs(),A=T[0],E=T[1],R=T[2],M=T[3],w=e.width,P=e.height,F=w*m.x,L=w*m.z,D=F+L,B=w-D,I=P*m.w,O=P*m.y,N=I+O,V=P-N;D>=t?(h=3,u=0):B>tS.zeroTolerance?(h=4+(f=(f=(t-D)/B)%1>=r?Math.ceil(f):Math.floor(f))-1,u=2):(h=4,u=1),N>=n?(_=3,d=0):V>tS.zeroTolerance?(_=4+(p=(p=(n-N)/V)%1>=r?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*C),i.add(n*x),i.add(n*S),o.add(A.x),o.add(M.x),s.add(A.y),s.add(M.y),k+=2,z+=2,no.warn("The number of vertices exceeds the upper limit("+l+")."),k*z;switch(u){case 0:c=t/D,a.add(w*y*c),a.add(F*c),a.add(t-w*(1-C)*c),o.add(A.x),o.add(E.x),o.add(R.x),o.add(M.x),k+=4;break;case 1:a.add(w*y),a.add(F),a.add(t-L),a.add(t-w*(1-C)),o.add(A.x),o.add(E.x),o.add(NaN),o.add(NaN),o.add(R.x),o.add(M.x),k+=4;break;case 2:c=t/(D+f*B),a.add(w*y*c),a.add(F*c),o.add(A.x),o.add(E.x),o.add(E.x),k+=3;for(var U=0,G=f-1;U<G;U++)a.add(F+(U+1)*B*c),o.add(R.x),o.add(E.x),k+=2;a.add(t-L*c),a.add(t-w*(1-C)*c),o.add(R.x),o.add(R.x),o.add(M.x),k+=3}switch(d){case 0:c=n/N,i.add(P*x*c),i.add(O*c),i.add(n-P*(1-S)*c),s.add(A.y),s.add(E.y),s.add(R.y),s.add(M.y),z+=4;break;case 1:i.add(P*x),i.add(O),i.add(n-I),i.add(n-P*(1-S)),s.add(A.y),s.add(E.y),s.add(NaN),s.add(NaN),s.add(R.y),s.add(M.y),z+=4;break;case 2:c=n/(N+p*V),i.add(P*x*c),i.add(O*c),s.add(A.y),s.add(E.y),s.add(E.y),z+=3;for(var H=0,W=p-1;H<W;H++)i.add(O+(H+1)*V*c),s.add(R.y),s.add(E.y),z+=2;i.add(n-I*c),i.add(n-P*(1-S)*c),s.add(R.y),s.add(R.y),s.add(M.y),z+=3}return k*z},e._calculateContinuousDividing=function(e,t,n,r,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,C=e._getUVs(),S=C[0],T=C[1],A=C[2],E=C[3],R=e.width,M=e.height,w=R*f.x,P=R*f.z,F=w+P,L=R-F,D=M*f.w,B=M*f.y,I=D+B,O=M-I;F>=t?(u=3,l=0):L>tS.zeroTolerance?(u=4+(0|(h=(t-F)/L)),l=2):(u=4,l=1),I>=n?(d=3,c=0):O>tS.zeroTolerance?(d=4+(0|(_=(n-I)/O)),c=2):(d=4,c=1);var N=0,V=0;if((u-1)*(d-1)*4>s)return r.add(t*g),r.add(t*x),a.add(n*v),a.add(n*b),i.add(S.x),i.add(E.x),o.add(S.y),o.add(E.y),N+=2,V+=2,no.warn("The number of vertices exceeds the upper limit("+s+")."),N*V;switch(l){case 0:var k=t/F;r.add(R*g*k),r.add(w*k),r.add(t-R*(1-x)*k),i.add(S.x),i.add(T.x),i.add(A.x),i.add(E.x),N+=4;break;case 1:r.add(R*g),r.add(w),r.add(t-P),r.add(t-R*(1-x)),i.add(S.x),i.add(T.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(E.x),N+=4;break;case 2:r.add(R*g),r.add(w),i.add(S.x),i.add(T.x),i.add(T.x),N+=3;for(var z=0|h,U=0;U<z;U++)r.add(w+(U+1)*L),i.add(A.x),i.add(T.x),N+=2;r.add(t-P),r.add(t-R*(1-x)),i.add((A.x-T.x)*(h-z)+T.x),i.add(A.x),i.add(E.x),N+=3}switch(c){case 0:var G=n/I;a.add(M*v*G),a.add(B*G),a.add(n-M*(1-b)*G),o.add(S.y),o.add(T.y),o.add(A.y),o.add(E.y),V+=4;break;case 1:a.add(M*v),a.add(B),a.add(n-D),a.add(n-M*(1-b)),o.add(S.y),o.add(T.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(E.y),V+=4;break;case 2:a.add(M*v),a.add(B),o.add(S.y),o.add(T.y),o.add(T.y),V+=3;for(var H=0|_,W=0;W<H;W++)a.add(B+(W+1)*O),o.add(A.y),o.add(T.y),V+=2;a.add(n-D),a.add(n-M*(1-b)),o.add((A.y-T.y)*(_-H)+T.y),o.add(A.y),o.add(E.y),V+=3}return N*V},e}();rS._worldMatrix=new tL,rS._posRow=new rC,rS._posColumn=new rC,rS._uvRow=new rC,rS._uvColumn=new rC,rS=tX([ry()],rS);var rT=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._tileMode=nS.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new tO(1,1,1,1),n._sprite=null,n._automaticWidth=0,n._automaticHeight=0,n._customWidth=void 0,n._customHeight=void 0,n._flipX=!1,n._flipY=!1,n.drawMode=nC.Simple,n._dirtyUpdateFlag|=4,n.setMaterial(n._engine._basicResources.spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(n),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t._assembler.resetData(t),t.sprite=this._sprite,t.drawMode=this._drawMode},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){this.sprite?this._assembler.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,n=this.getMaterial();if(n){n.destroyed&&(n=this._engine._basicResources.spriteDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3),4&this._dirtyUpdateFlag&&(this._assembler.updateColor(this),this._dirtyUpdateFlag&=-5);var r=e.camera,a=r.engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get(),s=this._subChunk;o.set(this,n,s.chunk.primitive,s.subMesh,this.sprite.texture,s),i.addSubRenderElement(o),r._renderPipeline.pushRenderElement(e,i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.prototype._onDestroy.call(this),this._sprite=null,this._assembler=null,this._subChunk&&(this._getChunkManager().freeSubChunk(this._subChunk),this._subChunk=null)},n._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-9},n._onSpriteChange=function(e){switch(e){case nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:var n=this._drawMode;this._dirtyUpdateFlag|=8,this._drawMode===nC.Sliced?this._dirtyUpdateFlag|=rv.WorldVolume:n===nC.Tiled?this._dirtyUpdateFlag|=rA.WorldVolumeAndUV:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.border:this._drawMode===nC.Sliced&&(this._dirtyUpdateFlag|=rA.WorldVolumeAndUV);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=rA.WorldVolumeAndUV;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},n._onColorChanged=function(){this._dirtyUpdateFlag|=4},tG(t,[{key:"drawMode",get:function(){return this._drawMode},set:function(e){if(this._drawMode!==e){switch(this._drawMode=e,e){case nC.Simple:this._assembler=rx;break;case nC.Sliced:this._assembler=rb;break;case nC.Tiled:this._assembler=rS}this._assembler.resetData(this),this._dirtyUpdateFlag|=rA.VertexData}}},{key:"tileMode",get:function(){return this._tileMode},set:function(e){this._tileMode!==e&&(this._tileMode=e,this.drawMode===nC.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(e){e!==this._tiledAdaptiveThreshold&&(e=tS.clamp(e,0,1),this._tiledAdaptiveThreshold=e,this.drawMode===nC.Tiled&&(this._dirtyUpdateFlag|=rA.VertexData))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=15,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._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(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=this._drawMode===nC.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"height",get:function(){return void 0!==this._customHeight?this._customHeight:(8&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticHeight)},set:function(e){this._customHeight!==e&&(this._customHeight=e,this._dirtyUpdateFlag|=this._drawMode===nC.Tiled?rA.VertexData:rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.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._maskInteraction=e)}}]),t}(e.Renderer);rT._textureProperty=nY.getByName("renderer_SpriteTexture"),tX([tq],rT.prototype,"_subChunk",void 0),tX([tq],rT.prototype,"_drawMode",void 0),tX([tQ],rT.prototype,"_assembler",void 0),tX([tQ],rT.prototype,"_tileMode",void 0),tX([tQ],rT.prototype,"_tiledAdaptiveThreshold",void 0),tX([tZ],rT.prototype,"_color",void 0),tX([tq],rT.prototype,"_sprite",void 0),tX([tq],rT.prototype,"_automaticWidth",void 0),tX([tq],rT.prototype,"_automaticHeight",void 0),tX([tQ],rT.prototype,"_customWidth",void 0),tX([tQ],rT.prototype,"_customHeight",void 0),tX([tQ],rT.prototype,"_flipX",void 0),tX([tQ],rT.prototype,"_flipY",void 0),tX([tq],rT.prototype,"_onSpriteChange",null),tX([tq],rT.prototype,"_onColorChanged",null);var rA=((H=rA||{})[H.UV=2]="UV",H[H.Color=4]="Color",H[H.AutomaticSize=8]="AutomaticSize",H[H.WorldVolumeAndUV=2|rv.WorldVolume]="WorldVolumeAndUV",H[H.VertexData=4|H.WorldVolumeAndUV]="VertexData",H[H.All=15]="All",H),rE=((W={})[W.Layer0=1]="Layer0",W[W.Layer1=2]="Layer1",W[W.Layer2=4]="Layer2",W[W.Layer3=8]="Layer3",W[W.Layer4=16]="Layer4",W[W.Layer5=32]="Layer5",W[W.Layer6=64]="Layer6",W[W.Layer7=128]="Layer7",W[W.Layer8=256]="Layer8",W[W.Layer9=512]="Layer9",W[W.Layer10=1024]="Layer10",W[W.Layer11=2048]="Layer11",W[W.Layer12=4096]="Layer12",W[W.Layer13=8192]="Layer13",W[W.Layer14=16384]="Layer14",W[W.Layer15=32768]="Layer15",W[W.Layer16=65536]="Layer16",W[W.Layer17=131072]="Layer17",W[W.Layer18=262144]="Layer18",W[W.Layer19=524288]="Layer19",W[W.Layer20=1048576]="Layer20",W[W.Layer21=2097152]="Layer21",W[W.Layer22=4194304]="Layer22",W[W.Layer23=8388608]="Layer23",W[W.Layer24=0x1000000]="Layer24",W[W.Layer25=0x2000000]="Layer25",W[W.Layer26=0x4000000]="Layer26",W[W.Layer27=0x8000000]="Layer27",W[W.Layer28=0x10000000]="Layer28",W[W.Layer29=0x20000000]="Layer29",W[W.Layer30=0x40000000]="Layer30",W[W.Layer31=0x80000000]="Layer31",W[W.Everything=0xffffffff]="Everything",W[W.Nothing=0]="Nothing",W),rR=/*#__PURE__*/function(){function e(){}return e.recreateTextureIfNeeded=function(e,t,n,r,a,i,o,s){return t?(t.width!==n||t.height!==r||t.format!==a||t.mipmapCount>1!==i)&&(t.destroy(!0),(t=new nc(e,n,r,a,i)).isGCIgnored=!0):(t=new nc(e,n,r,a,i)).isGCIgnored=!0,t.wrapModeU=t.wrapModeV=o,t.filterMode=s,t},e.recreateRenderTargetIfNeeded=function(t,n,r,a,i,o,s,l,c,u,d){var h=null==n?void 0:n.getColorTexture(0),_=i?e.recreateTextureIfNeeded(t,h,r,a,i,l,u,d):null;if(s){var f=null==n?void 0:n.depthTexture,p=o?e.recreateTextureIfNeeded(t,f,r,a,o,l,u,d):null;(h!==_||f!==p)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,p,c)).isGCIgnored=!0)}else(h!==_||(null==n?void 0:n._depthFormat)!==o||n.antiAliasing!==c)&&(null==n||n.destroy(!0),(n=new nl(t,r,a,_,o,c)).isGCIgnored=!0);return n},e.blitTexture=function(t,n,r,a,i,o,s,l){void 0===a&&(a=0),void 0===i&&(i=e.defaultViewport),void 0===o&&(o=null),void 0===s&&(s=0),void 0===l&&(l=!1);var c=t._basicResources,u=r?c.flipYBlitMesh:c.blitMesh,d=o||c.blitMaterial,h=t._hardwareRenderer,_=t._renderContext;_.flipProjection=!!r,h.activeRenderTarget(r,i,_.flipProjection,0);var f=e._rendererShaderData;f.setTexture(e._blitTextureProperty,n),f.setFloat(e._blitMipLevelProperty,a),e._texelSize.set(1/n.width,1/n.height,n.width,n.height),f.setVector4(e._blitTexelSizeProperty,e._texelSize),l?f.enableMacro(e._flipYTextureMacro):f.disableMacro(e._flipYTextureMacro);var p=d.shader.subShaders[0].passes[s],m=ro._compileMacros;nW.unionCollection(_.camera._globalShaderMacro,f._macroCollection,m),nW.unionCollection(m,d.shaderData._macroCollection,m);var g=p._getShaderProgram(t,m);g.bind(),g.groupingOtherUniformBlock(),g.uploadAll(g.rendererUniformBlock,f),g.uploadAll(g.materialUniformBlock,d.shaderData),g.uploadUnGroupTextures(),(p._renderState||d.renderState)._applyStates(t,!1,p._renderStateDataMap,d.shaderData),h.drawPrimitive(u._primitive,u.subMesh,g)},e}();rR._blitTextureProperty=nY.getByName("renderer_BlitTexture"),rR._blitMipLevelProperty=nY.getByName("renderer_BlitMipLevel"),rR._blitTexelSizeProperty=nY.getByName("renderer_texelSize"),rR._flipYTextureMacro=nH.getByName("renderer_FlipYBlitTexture"),rR._rendererShaderData=new rs(n8.Renderer),rR._texelSize=new tI,rR.defaultViewport=new tI(0,0,1,1);var rM=function(){this.position=new tT,this.isOrthographic=!1,this.viewMatrix=new tL,this.projectionMatrix=new tL,this.viewProjectionMatrix=new tL,this.nearClipPlane=.1,this.farClipPlane=100,this.forward=new tT},rw=((j={})[j.None=0]="None",j[j.Color=1]="Color",j[j.Depth=2]="Depth",j[j.Stencil=4]="Stencil",j[j.ColorDepth=3]="ColorDepth",j[j.ColorStencil=5]="ColorStencil",j[j.DepthStencil=6]="DepthStencil",j[j.All=7]="All",j),rP=((X={})[X.Normal=0]="Normal",X[X.XRCenterCamera=1]="XRCenterCamera",X[X.XRLeftCamera=2]="XRLeftCamera",X[X.XRRightCamera=4]="XRRightCamera",X),rF=((K={})[K.None=0]="None",K[K.PrePass=1]="PrePass",K),rL=((Y={})[Y.None=1]="None",Y[Y.TwoX=2]="TwoX",Y[Y.FourX=4]="FourX",Y),rD=((q={})[q.None=1]="None",q[q.TwoX=2]="TwoX",q[q.FourX=4]="FourX",q[q.EightX=8]="EightX",q),rB=((Q={})[Q.KeepOriginalShader=0]="KeepOriginalShader",Q[Q.DoNotRender=1]="DoNotRender",Q),rI=function(){};rI.tempVec4=new tI,rI.tempVec3=new tT,rI.tempVec2=new tB,e.Camera=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=rw.All,n.cullingMask=rE.Everything,n.depthTextureMode=rF.None,n.opaqueTextureDownsampling=rL.TwoX,n.msaaSamples=rD.None,n._cameraType=rP.Normal,n._globalShaderMacro=new nW,n._frustum=new tw,n._virtualCamera=new rM,n._replacementShader=null,n._replacementSubShaderTag=null,n._replacementFailureStrategy=null,n._cameraIndex=-1,n._priority=0,n._shaderData=new rs(n8.Camera),n._isCustomViewMatrix=!1,n._isCustomProjectionMatrix=!1,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._customAspectRatio=void 0,n._renderTarget=null,n._depthBufferParams=new tI,n._opaqueTextureEnabled=!1,n._enableHDR=!1,n._enablePostProcess=!1,n._viewport=new tI(0,0,1,1),n._pixelViewport=new tN(0,0,0,0),n._inverseProjectionMatrix=new tL,n._invViewProjMat=new tL,n._isViewMatrixDirty=t.registerWorldChangeFlag(),n._isInvViewProjDirty=t.registerWorldChangeFlag(),n._frustumChangeFlag=t.registerWorldChangeFlag(),n._renderPipeline=new rZ(n),n._addResourceReferCount(n.shaderData,1),n._updatePixelViewport(),n._onPixelViewportChanged=n._onPixelViewportChanged.bind(n),n._viewport._onValueChanged=n._onPixelViewportChanged,n.engine.canvas._sizeUpdateFlagManager.addListener(n._onPixelViewportChanged),n}tW(t,e);var n=t.prototype;return n.resetViewMatrix=function(){this._isCustomViewMatrix=!1,this._viewMatrixChange()},n.resetProjectionMatrix=function(){this._isCustomProjectionMatrix=!1,this._projectionMatrixChange()},n.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projectionMatrixChange()},n.worldToViewportPoint=function(e,t){var n=rI.tempVec3,r=rI.tempVec4;tT.transformCoordinate(e,this.viewMatrix,n),tT.transformToVec4(n,this.projectionMatrix,r);var a=r.w;return t.set((r.x/a+1)*.5,(1-r.y/a)*.5,-n.z),t},n.viewportToWorldPoint=function(e,t){var n,r=this.nearClipPlane,a=this.farClipPlane,i=1/(r-a);if(this.isOrthographic)n=-(2*e.z)*i+(a+r)*i;else{var o=e.z;n=(-o*(r+a)*i+2*r*a*i)/o}return this._innerViewportToWorldPoint(e.x,e.y,(n+1)/2,this._getInvViewProjMat(),t),t},n.viewportPointToRay=function(e,t){var n=this._getInvViewProjMat(),r=this._innerViewportToWorldPoint(e.x,e.y,0,n,t.origin),a=this._innerViewportToWorldPoint(e.x,e.y,1-tS.zeroTolerance,n,t.direction);return tT.subtract(a,r,a),a.normalize(),t},n.screenToViewportPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(e.x/n.width-r.x)/r.z,t.y=(e.y/n.height-r.y)/r.w,void 0!==e.z&&(t.z=e.z),t},n.viewportToScreenPoint=function(e,t){var n=this.engine.canvas,r=this.viewport;return t.x=(r.x+e.x*r.z)*n.width,t.y=(r.y+e.y*r.w)*n.height,void 0!==e.z&&(t.z=e.z),t},n.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},n.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},n.screenPointToRay=function(e,t){var n=rI.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},n.render=function(e,t){void 0===t&&(t=0);var n,r=this._engine,a=r._renderContext,i=this._virtualCamera,o=this._entity.transform;tL.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(),nW.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!r._hardwareRenderer.isWebGL2&&(t=0,no.error("mipLevel only take effect in WebGL2.0")),this._cameraType===rP.Normal||this._renderTarget||this.independentCanvasEnabled||(n=r.xrManager._getCameraIgnoreClearFlags(this._cameraType)),this._renderPipeline.render(a,e,t,n),r._renderCount++},n.setReplacementShader=function(e,t,n){void 0===n&&(n=rB.KeepOriginalShader),this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?n0.getByName(t):t,this._replacementFailureStrategy=n},n.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null,this._replacementFailureStrategy=null},n._onEnableInScene=function(){this.scene._componentsManager.addCamera(this)},n._onDisableInScene=function(){this.scene._componentsManager.removeCamera(this)},n._getInternalColorTextureFormat=function(){return this._enableHDR?this.engine._hardwareRenderer.isWebGL2?t9.R11G11B10_UFloat:t9.R16G16B16A16:t9.R8G8B8A8},n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),null==(t=this._renderPipeline)||t.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._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._invViewProjMat=null},n._updatePixelViewport=function(){var e,t,n=this._renderTarget;if(n)e=n.width,t=n.height;else{var r=this.engine.canvas;e=r.width,t=r.height}var a=this._viewport;this._pixelViewport.set(a.x*e,a.y*t,a.z*e,a.w*t)},n._viewMatrixChange=function(){this._isViewMatrixDirty.flag=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._projectionMatrixChange=function(){this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0,this._frustumChangeFlag.flag=!0},n._innerViewportToWorldPoint=function(e,t,n,r,a){var i=rI.tempVec3;return i.set(2*e-1,1-2*t,2*n-1),tT.transformCoordinate(i,r,a),a},n._updateShaderData=function(){var e=this.shaderData,n=this._entity.transform;e.setMatrix(t._inverseViewMatrixProperty,n.worldMatrix),e.setVector3(t._cameraPositionProperty,n.worldPosition),e.setVector3(t._cameraForwardProperty,n.worldForward),e.setVector3(t._cameraUpProperty,n.worldUp);var r=this._depthBufferParams,a=this.farClipPlane/this.nearClipPlane;r.set(1-a,a,0,0),e.setVector4(t._cameraDepthBufferParamsProperty,r)},n._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,tL.multiply(this._entity.transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},n._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,tL.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},n._onPixelViewportChanged=function(){this._updatePixelViewport(),null!=this._customAspectRatio||this._projectionMatrixChange(),this._checkMainCanvasAntialiasWaste()},n._checkMainCanvasAntialiasWaste=function(){this._phasedActiveInScene&&this.independentCanvasEnabled&&tI.equals(this._viewport,rR.defaultViewport)&&no.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.")},tG(t,[{key:"opaqueTextureEnabled",get:function(){return this._opaqueTextureEnabled},set:function(e){this._opaqueTextureEnabled!==e&&(this._opaqueTextureEnabled=e,this._checkMainCanvasAntialiasWaste())}},{key:"independentCanvasEnabled",get:function(){if(this.enablePostProcess&&this.scene._postProcessManager.hasActiveEffect)return!0;if(this.enableHDR||this.opaqueTextureEnabled){var e;return this._getInternalColorTextureFormat()!==(null==(e=this.renderTarget)?void 0:e.getColorTexture(0).format)}return!1}},{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._entity.transform;return tL.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 n=this.aspectRatio;if(e.isOrthographic){var r=this._orthographicSize*n,a=this._orthographicSize;tL.ortho(-r,r,-a,a,this.nearClipPlane,this.farClipPlane,t)}else tL.perspective(tS.degreeToRadian(this._fieldOfView),n,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(e){if(this.enableHDR!==e){var t=this.engine._hardwareRenderer,n=t.isWebGL2||t.canIUse(nJ.textureHalfFloat);if(e&&!n){no.warn("Can't enable HDR in this device.");return}this._enableHDR=e,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())}}]),t}(ru),e.Camera._cameraDepthTextureProperty=nY.getByName("camera_DepthTexture"),e.Camera._cameraOpaqueTextureProperty=nY.getByName("camera_OpaqueTexture"),e.Camera._inverseViewMatrixProperty=nY.getByName("camera_ViewInvMat"),e.Camera._cameraPositionProperty=nY.getByName("camera_Position"),e.Camera._cameraForwardProperty=nY.getByName("camera_Forward"),e.Camera._cameraUpProperty=nY.getByName("camera_Up"),e.Camera._cameraDepthBufferParamsProperty=nY.getByName("camera_DepthBufferParams"),tX([tZ],e.Camera.prototype,"_frustum",void 0),tX([tq],e.Camera.prototype,"_renderPipeline",void 0),tX([tq],e.Camera.prototype,"_virtualCamera",void 0),tX([tq],e.Camera.prototype,"_cameraIndex",void 0),tX([tq],e.Camera.prototype,"_frustumChangeFlag",void 0),tX([tq],e.Camera.prototype,"_isViewMatrixDirty",void 0),tX([tq],e.Camera.prototype,"_isInvViewProjDirty",void 0),tX([tZ],e.Camera.prototype,"_viewport",void 0),tX([tZ],e.Camera.prototype,"_pixelViewport",void 0),tX([tZ],e.Camera.prototype,"_inverseProjectionMatrix",void 0),tX([tZ],e.Camera.prototype,"_invViewProjMat",void 0),tX([tq],e.Camera.prototype,"_onPixelViewportChanged",null),e.Camera=tX([rh(rp,r_.CheckOnly)],e.Camera);var rO=((J={})[J.SolidColor=0]="SolidColor",J[J.Sky=1]="Sky",J[J.Texture=2]="Texture",J),rN=((Z={})[Z.AspectFitWidth=0]="AspectFitWidth",Z[Z.AspectFitHeight=1]="AspectFitHeight",Z[Z.Fill=2]="Fill",Z),rV=function(e){this.engine=e},rk=/*#__PURE__*/function(){function e(){this._projectionParams=new tI,this.flipProjection=!1,this.rendererUpdateFlag=0}var t=e.prototype;return t.applyVirtualCamera=function(t,n){this.virtualCamera=t,this.flipProjection=n;var r=this.camera.shaderData,a=t.viewMatrix,i=t.projectionMatrix,o=t.viewProjectionMatrix;n&&(tL.multiply(e._flipYMatrix,i,e._flipYProjectionMatrix),tL.multiply(e._flipYProjectionMatrix,a,e._flipYViewProjectionMatrix),i=e._flipYProjectionMatrix,o=e._flipYViewProjectionMatrix),this.viewMatrix=a,this.projectionMatrix=i,this.viewProjectionMatrix=o,r.setMatrix(e._viewMatrixProperty,a),r.setMatrix(e._projectionMatrixProperty,i),r.setMatrix(e.vpMatrixProperty,o);var s=this._projectionParams;s.set(n?-1:1,t.nearClipPlane,t.farClipPlane,0),r.setVector4(e._cameraProjectionProperty,s)},t.garbageCollection=function(){this.camera=null},e}();rk.vpMatrixProperty=nY.getByName("camera_VPMat"),rk.pipelineStageKey=n0.getByName("pipelineStage"),rk._flipYMatrix=new tL(1,0,0,0,0,-1),rk._cameraProjectionProperty=nY.getByName("camera_ProjectionParams"),rk._viewMatrixProperty=nY.getByName("camera_ViewMat"),rk._projectionMatrixProperty=nY.getByName("camera_ProjMat"),rk._flipYProjectionMatrix=new tL,rk._flipYViewProjectionMatrix=new tL;var rz=(($={})[$.None=0]="None",$[$.WorldMatrix=1]="WorldMatrix",$[$.viewMatrix=2]="viewMatrix",$[$.ProjectionMatrix=4]="ProjectionMatrix",$[$.WorldViewMatrix=3]="WorldViewMatrix",$[$.viewProjectionMatrix=6]="viewProjectionMatrix",$[$.All=7]="All",$),rU=((ee={})[ee.No=0]="No",ee[ee.Increment=1]="Increment",ee[ee.Decrement=2]="Decrement",ee),rG=/*#__PURE__*/function(){function e(e){this.renderQueueType=e,this.elements=[],this.batchedSubElements=[]}var t=e.prototype;return t.pushRenderElement=function(e){this.elements.push(e)},t.sortBatch=function(e,t){nT._quickSort(this.elements,0,this.elements.length,e),this.batch(t)},t.batch=function(e){e.batch(this)},t.render=function(e,t,n){void 0===n&&(n=rU.No);var r=this.batchedSubElements,a=r.length;if(0!==a)for(var i=e.rendererUpdateFlag,o=e.camera,s=o.engine,l=o.scene,c=o.instanceId,u=o.shaderData,d=l.instanceId,h=l.shaderData,_=l._maskManager,f=s._renderCount,p=s._hardwareRenderer,m=rk.pipelineStageKey,g=this.renderQueueType,v=0;v<a;v++){var y=r[v],x=y.component,b=y.batched,C=y.material;i&rz.WorldViewMatrix||x._batchedTransformShaderData!=b?(x._updateTransformShaderData(e,!1,b),x._batchedTransformShaderData=b):i&rz.ProjectionMatrix&&x._updateTransformShaderData(e,!0,b);var S=x._maskInteraction,T=S!==nv.None,A=n!==rU.No,E=null;A?E=aY.getMaskTypeRenderStates(n):(T?(_.drawMask(e,t,y.component._maskLayer),E=aY.getMaskInteractionRenderStates(S)):_.isReadStencil(C)&&_.clearMask(e,t),_.isStencilWritten(C)&&(_.hasStencilWritten=!0));var R=ro._compileMacros,M=y.primitive,w=y.shaderPasses,P=y.shaderData,F=x.shaderData,L=x.instanceId,D=C.shaderData,B=C.instanceId,I=C.renderStates;nW.unionCollection(x._globalShaderMacro,D._macroCollection,R);for(var O=0,N=w.length;O<N;O++){var V=w[O];if(V.getTagValue(m)===t){var k=V._renderState;if(A)k||(k=I[O]);else if((k?k._getRenderQueueByShaderData(V._renderStateDataMap,D):(k=I[O]).renderQueueType)!==g)continue;var z=V._getShaderProgram(s,R);if(z.isValid){var U=z.bind();f!==z._uploadRenderCount?(z.groupingOtherUniformBlock(),z.uploadAll(z.sceneUniformBlock,h),z.uploadAll(z.cameraUniformBlock,u),z.uploadAll(z.rendererUniformBlock,F),z.uploadAll(z.materialUniformBlock,D),P&&z.uploadAll(z.renderElementUniformBlock,P),z.uploadUnGroupTextures(),z._uploadSceneId=d,z._uploadCameraId=c,z._uploadRendererId=L,z._uploadMaterialId=B,z._uploadRenderCount=f):(z._uploadSceneId!==d?(z.uploadAll(z.sceneUniformBlock,h),z._uploadSceneId=d):U&&z.uploadTextures(z.sceneUniformBlock,h),z._uploadCameraId!==c?(z.uploadAll(z.cameraUniformBlock,u),z._uploadCameraId=c):U&&z.uploadTextures(z.cameraUniformBlock,u),z._uploadRendererId!==L?(z.uploadAll(z.rendererUniformBlock,F),z._uploadRendererId=L):U&&z.uploadTextures(z.rendererUniformBlock,F),z._uploadMaterialId!==B?(z.uploadAll(z.materialUniformBlock,D),z._uploadMaterialId=B):U&&z.uploadTextures(z.materialUniformBlock,D),P&&z.uploadAll(z.renderElementUniformBlock,P),U&&z.uploadUnGroupTextures()),k._applyStates(s,x._transformEntity.transform._isFrontFaceInvert(),V._renderStateDataMap,C.shaderData,E),p.drawPrimitive(M,y.subPrimitive,z)}}}}},t.clear=function(){this.elements.length=0,this.batchedSubElements.length=0},t.destroy=function(){},e.compareForOpaque=function(e,t){return e.priority-t.priority||e.distanceForSort-t.distanceForSort},e.compareForTransparent=function(e,t){return e.priority-t.priority||t.distanceForSort-e.distanceForSort},e}(),rH=function(){this.virtualCamera=new rM,this.cullPlanes=[new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT),new tM(new tT)],this.splitBoundSphere=new tA(new tT,0)},rW=((et={})[et.Low=0]="Low",et[et.Medium=1]="Medium",et[et.High=2]="High",et[et.VeryHigh=3]="VeryHigh",et),rj=((en={})[en.None=0]="None",en[en.Hard=1]="Hard",en[en.SoftLow=2]="SoftLow",en[en.SoftHigh=3]="SoftHigh",en),rX=/*#__PURE__*/function(){function e(){}return e.shadowResolution=function(e){switch(e){case rW.Low:return 512;case rW.Medium:return 1024;case rW.High:return 2048;case rW.VeryHigh:return 4096}},e.shadowDepthFormat=function(e,t){return t?t9.Depth16:t9.R8G8B8A8},e.cullingRenderBounds=function(e,t,n){for(var r=e.min,a=e.max,i=0;i<t;i++){var o=n[i],s=o.normal;if(s.x*(s.x>=0?a.x:r.x)+s.y*(s.y>=0?a.y:r.y)+s.z*(s.z>=0?a.z:r.z)<-o.distance)return!1}return!0},e.shadowCullFrustum=function(t,n,r,a){var i=r._entity.layer;t.camera.cullingMask&i&&n.cullingMask&i&&r.castShadows&&e.cullingRenderBounds(r.bounds,a.cullPlaneCount,a.cullPlanes)&&(r._prepareRender(t),r._renderFrameCount=r.engine.time.frameCount)},e.getBoundSphereByFrustum=function(e,t,n,r,a){var i,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(tS.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,tT.scale(r,i,_),tT.add(n.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},e.getDirectionLightShadowCullPlanes=function(t,n,r,a,i){var o=e._frustumCorners,s=e._backPlaneFaces,l=e._frustumPlaneNeighbors,c=e._frustumTwoPlaneCorners,u=e._edgePlanePoint2,d=i.cullPlanes,h=t.getPlane(tx.Near),_=t.getPlane(tx.Far),f=t.getPlane(tx.Left),p=t.getPlane(tx.Right),m=t.getPlane(tx.Bottom),g=t.getPlane(tx.Top),v=e._adjustNearPlane,y=e._adjustFarPlane;v.normal.copyFrom(h.normal),y.normal.copyFrom(_.normal),v.distance=h.distance-(n-r),y.distance=Math.min(-h.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),tR.intersectionPointThreePlanes(v,m,p,o[7]),tR.intersectionPointThreePlanes(v,g,p,o[6]),tR.intersectionPointThreePlanes(v,g,f,o[5]),tR.intersectionPointThreePlanes(v,m,f,o[4]),tR.intersectionPointThreePlanes(y,m,p,o[3]),tR.intersectionPointThreePlanes(y,g,p,o[2]),tR.intersectionPointThreePlanes(y,g,f,o[1]),tR.intersectionPointThreePlanes(y,m,f,o[0]);for(var x=0,b=0;b<6;b++){var C=void 0;switch(b){case tx.Near:C=v;break;case tx.Far:C=y;break;default:C=t.getPlane(b)}0>tT.dot(C.normal,a)&&(d[x].copyFrom(C),s[x]=b,x++)}for(var S=x,T=0;T<x;T++)for(var A=s[T],E=l[A],R=0;R<4;R++){for(var M=E[R],w=!0,P=0;P<x;P++)if(M==s[P]){w=!1;break}if(w){var F=c[A][M],L=o[F[0]],D=o[F[1]];tT.add(L,a,u),tM.fromPoints(L,D,u,d[S++])}}i.cullPlaneCount=S},e.getDirectionalLightMatrices=function(t,n,r,a,i,o,s,l){var c=s.splitBoundSphere;s.resolution=o;var u=c.center,d=c.radius,h=o/2,_=d*h/(h-e.atlasBorderSize),f=2*_,p=o/f,m=f/o,g=Math.ceil(tT.dot(u,t)*p)*m,v=Math.ceil(tT.dot(u,n)*p)*m,y=tT.dot(u,r);u.x=t.x*g+n.x*v+r.x*y,u.y=t.y*g+n.y*v+r.y*y,u.z=t.z*g+n.z*v+r.z*y;var x=s.virtualCamera,b=x.position,C=x.viewMatrix,S=x.projectionMatrix;tT.scale(r,d+i,b),tT.subtract(u,b,b),tL.lookAt(b,u,t,C),tL.ortho(-_,_,-_,_,0,2*d+i,S);var T=x.viewProjectionMatrix;tL.multiply(S,C,T),nT._floatMatrixMultiply(e._shadowMapCoordMatrix,T.elements,0,l,16*a)},e.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),a=Math.floor(e/r)*Math.floor(t/r);a<n;)a=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},e.getShadowBias=function(e,t,n,r){var a=2/t.elements[0]/n,i=-e.shadowBias*a,o=-e.shadowNormalBias*a;e.shadowType==rj.SoftHigh&&(i*=2.5,o*=2.5),r.set(i,o)},e.applySliceTransform=function(t,n,r,a,i,o){var s=e._tempMatrix0,l=s.elements,c=1/n,u=1/r,d=i.x*c,h=i.y*u;l[0]=t*c,l[1]=0,l[2]=0,l[3]=0,l[4]=0,l[5]=t*u,l[6]=0,l[7]=0,l[8]=0,l[9]=0,l[10]=1,l[11]=0,l[12]=d,l[13]=h,l[14]=0,l[15]=1;var _=16*a;nT._floatMatrixMultiply(s,o,_,o,_)},e.getScaleAndBiasForLinearDistanceFade=function(e,t,n){if(t<1e-4){n.z=1e3,n.w=-(1e3*e);return}t=1-t;var r=(t*=t)*e,a=e-r;n.z=1/a,n.w=-r/a},e}();rX._tempMatrix0=new tL,rX._shadowMapCoordMatrix=new tL(.5,0,0,0,0,-.5,0,0,0,0,.5,0,.5,.5,.5,1),rX._frustumCorners=[new tT,new tT,new tT,new tT,new tT,new tT,new tT,new tT],rX._adjustNearPlane=new tM(new tT),rX._adjustFarPlane=new tM(new tT),rX._backPlaneFaces=[,,,,,],rX._edgePlanePoint2=new tT,rX._frustumPlaneNeighbors=[[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Left,tx.Right,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Top,tx.Bottom],[tx.Near,tx.Far,tx.Left,tx.Right],[tx.Near,tx.Far,tx.Left,tx.Right]],rX._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]]],rX.atlasBorderSize=4;var rK=((er={})[er.NoCascades=1]="NoCascades",er[er.TwoCascades=2]="TwoCascades",er[er.FourCascades=4]="FourCascades",er),rY=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n.engine)||this)._shadowMapSize=new tI,r._shadowBias=new tB,r._shadowSliceData=new rH,r._lightUp=new tT,r._lightSide=new tT,r._splitBoundSpheres=new Float32Array(4*t._maxCascades),r._shadowMatrices=new Float32Array((t._maxCascades+1)*16),r._shadowInfos=new tI,r._viewportOffsets=[new tB,new tB,new tB,new tB],r._camera=n,r._supportDepthTexture=n.engine._hardwareRenderer.canIUse(nJ.depthTexture),r._shadowSliceData.virtualCamera.isOrthographic=!0,r}tW(t,e);var n=t.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(e,n){var r,a,i=this.engine,o=this._camera,s=this._viewportOffsets,l=this._shadowSliceData,c=this._splitBoundSpheres,u=this._shadowMatrices,d=o._renderPipeline._cullingResults,h=d.opaqueQueue,_=d.alphaTestQueue,f=o.scene,p=f._componentsManager,m=i._hardwareRenderer,g=f.shadowCascades,v=t._cascadesSplitDistance,y=l.splitBoundSphere,x=t._tempMatrix0,b=x.elements,C=this._lightUp,S=this._lightSide,T=l.virtualCamera.forward,A=this._shadowMapSize,E=A.z,R=A.w,M=this._shadowMapFormat;a=this._supportDepthTexture?(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,null,M,!0,!1,1,t7.Clamp,t5.Bilinear)).depthTexture:(r=rR.recreateRenderTargetIfNeeded(i,this._renderTarget,E,R,M,null,!1,!1,1,t7.Clamp,t5.Bilinear)).getColorTexture(0),i._hardwareRenderer._isWebGL2&&(a.depthCompareFunction=t8.Less),this._renderTarget=r,this._depthTexture=a,m.activeRenderTarget(r,t._viewport,e.flipProjection,0),this._supportDepthTexture?m.clearRenderTarget(i,rw.Depth,null):m.clearRenderTarget(i,rw.All,t._clearColor),tL.rotationQuaternion(n.entity.transform.worldRotationQuaternion,x),S.set(b[0],b[1],b[2]),C.set(b[4],b[5],b[6]),T.set(-b[8],-b[9],-b[10]);var w=t._tempVector;w.copyFrom(o.entity.transform.worldForward);for(var P=this._shadowTileResolution,F=0;F<g;F++){rX.getBoundSphereByFrustum(v[F],v[F+1],o,w,l),rX.getDirectionLightShadowCullPlanes(o._frustum,v[F],o.nearClipPlane,T,l),rX.getDirectionalLightMatrices(C,S,T,F,n.shadowNearPlaneOffset,P,l,u),g>1&&rX.applySliceTransform(P,E,R,F,this._viewportOffsets[F],u),this._updateSingleShadowCasterShaderData(n,l,e);var L=y.center,D=y.radius,B=4*F;c[B]=L.x,c[B+1]=L.y,c[B+2]=L.z,c[B+3]=D*D,h.clear(),_.clear();for(var I=p._renderers,O=I._elements,N=I.length-1;N>=0;--N)rX.shadowCullFrustum(e,n,O[N],l);if(h.elements.length||_.elements.length){i._renderCount++;var V=i._batcherManager;h.sortBatch(rG.compareForOpaque,V),_.sortBatch(rG.compareForOpaque,V);var k=s[F],z=k.x,U=k.y;m.setGlobalDepthBias(1,1),m.viewport(z,U,P,P),m.scissor(z+1,U+1,P-2,P-2),h.render(e,nX.ShadowCaster),_.render(e,nX.ShadowCaster),m.setGlobalDepthBias(0,0)}}},n._updateReceiversShaderData=function(e){var n=this._camera,r=n.scene,a=this._splitBoundSpheres,i=this._shadowMatrices,o=r.shadowCascades,s=Math.min(r.shadowDistance,n.farClipPlane);if(rX.getScaleAndBiasForLinearDistanceFade(Math.pow(s,2),r.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=r.shaderData;h.setFloatArray(t._shadowMatricesProperty,this._shadowMatrices),h.setVector4(t._shadowInfosProperty,this._shadowInfos),h.setTexture(t._shadowMapsProperty,this._depthTexture),h.setFloatArray(t._shadowSplitSpheresProperty,this._splitBoundSpheres),h.setVector4(t._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(e){var n=t._cascadesSplitDistance,r=this._camera.scene,a=r.shadowTwoCascadeSplits,i=r.shadowFourCascadeSplits,o=r.shadowCascades,s=this._camera,l=s.nearClipPlane,c=s.aspectRatio,u=s.fieldOfView;n[0]=l;var d=e-l,h=Math.tan(.5*tS.degreeToRadian(u)),_=1+h*h*(c*c+1);switch(o){case rK.NoCascades:n[1]=this._getFarWithRadius(e,_);break;case rK.TwoCascades:n[1]=this._getFarWithRadius(l+d*a,_),n[2]=this._getFarWithRadius(e,_);break;case rK.FourCascades:n[1]=this._getFarWithRadius(l+d*i.x,_),n[2]=this._getFarWithRadius(l+d*i.y,_),n[3]=this._getFarWithRadius(l+d*i.z,_),n[4]=this._getFarWithRadius(e,_)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._updateShadowSettings=function(){var e=this._camera,t=e.scene,n=rX.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=rX.shadowResolution(t.shadowResolution),a=t.shadowCascades,i=Math.min(t.shadowDistance,e.farClipPlane);if(this._getCascadesSplitDistance(i),n!==this._shadowMapFormat||r!==this._shadowMapResolution||a!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=a,a==rK.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var o=rX.getMaxTileResolutionInAtlas(r,r,a);this._shadowTileResolution=o;var s=2*o,l=a==rK.TwoCascades?o:2*o;this._shadowMapSize.set(1/s,1/l,s,l)}this._renderTarget=null;var c=this._viewportOffsets,u=this._shadowTileResolution;switch(a){case rK.NoCascades:c[0].set(0,0);break;case rK.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case rK.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var a=n.virtualCamera;rX.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(t._lightShadowBiasProperty,this._shadowBias),i.setVector3(t._lightDirectionProperty,e.direction),r.rendererUpdateFlag|=rz.viewProjectionMatrix,r.applyVirtualCamera(a,!0)},t}(rV);rY._lightShadowBiasProperty=nY.getByName("scene_ShadowBias"),rY._lightDirectionProperty=nY.getByName("scene_LightDirection"),rY._shadowMatricesProperty=nY.getByName("scene_ShadowMatrices"),rY._shadowMapSize=nY.getByName("scene_ShadowMapSize"),rY._shadowInfosProperty=nY.getByName("scene_ShadowInfo"),rY._shadowMapsProperty=nY.getByName("scene_ShadowMap"),rY._shadowSplitSpheresProperty=nY.getByName("scene_ShadowSplitSpheres"),rY._maxCascades=4,rY._cascadesSplitDistance=Array(rY._maxCascades+1),rY._viewport=new tI(0,0,1,1),rY._clearColor=new tO(1,1,1,1),rY._tempVector=new tT,rY._tempMatrix0=new tL;var rq=/*#__PURE__*/function(){function e(){this.opaqueQueue=new rG(nN.Opaque),this.transparentQueue=new rG(nN.Transparent),this.alphaTestQueue=new rG(nN.AlphaTest)}var t=e.prototype;return t.reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},t.sortBatch=function(e){this.opaqueQueue.sortBatch(rG.compareForOpaque,e),this.alphaTestQueue.sortBatch(rG.compareForOpaque,e),this.transparentQueue.sortBatch(rG.compareForTransparent,e)},t.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},e}(),rQ=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._supportDepthTexture=e._hardwareRenderer.canIUse(nJ.depthTexture),n}tW(n,t);var r=n.prototype;return r.onConfig=function(e){var t=this.engine,n=e.pixelViewport,r=n.width,a=n.height,i=rR.recreateRenderTargetIfNeeded(t,this._renderTarget,r,a,null,t9.Depth16,!0,!1,1,t7.Clamp,t5.Point);this._renderTarget=i},r.onRender=function(t,n){var r=this.engine,a=this._renderTarget,i=t.camera,o=r._hardwareRenderer;o.activeRenderTarget(a,rR.defaultViewport,t.flipProjection,0),o.clearRenderTarget(r,rw.Depth,null),r._renderCount++,n.opaqueQueue.render(t,nX.DepthOnly),n.alphaTestQueue.render(t,nX.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},n}(rV),rJ=/*#__PURE__*/function(t){function n(e){return t.call(this,e)||this}tW(n,t);var r=n.prototype;return r.onConfig=function(e,t){this._cameraColorTexture=t;var n=e.opaqueTextureDownsampling,r=n===rL.None,a=e.pixelViewport,i=r?1:n===rL.TwoX?.5:.25,o=rR.recreateRenderTargetIfNeeded(this.engine,this._renderTarget,a.width*i,a.height*i,e._getInternalColorTextureFormat(),null,!1,!1,1,t7.Clamp,r?t5.Point:t5.Bilinear);this._renderTarget=o},r.onRender=function(t){rR.blitTexture(this.engine,this._cameraColorTexture,this._renderTarget),t.camera.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,this._renderTarget.getColorTexture(0))},n}(rV),rZ=/*#__PURE__*/function(){function t(e){this._lastCanvasSize=new tB,this._internalColorTarget=null,this._canUseBlitFrameBuffer=!1,this._shouldGrabColor=!1,this._camera=e;var t=e.engine;this._cullingResults=new rq,this._cascadedShadowCasterPass=new rY(e),this._depthOnlyPass=new rQ(t),this._opaqueTexturePass=new rJ(t)}var n=t.prototype;return n.destroy=function(){this._cullingResults.destroy(),this._camera=null},n.render=function(t,n,r,a){t.rendererUpdateFlag=rz.All;var i=this._camera,o=i.scene,s=i.engine,l=s._hardwareRenderer,c=this._cullingResults,u=o._lightManager._sunlight,d=this._depthOnlyPass,h=i.depthTextureMode===rF.PrePass&&d._supportDepthTexture,_=i.clearFlags&~(null!=a?a:rw.None),f=i.independentCanvasEnabled,p=i.renderTarget?i.renderTarget.antiAliasing:i.msaaSamples;this._shouldGrabColor=f&&!(_&rw.Color),this._canUseBlitFrameBuffer=l.isWebGL2&&1===p&&(!!i.renderTarget||!l.context.antialias),o.castShadows&&u&&u.shadowType!==rj.None&&(this._cascadedShadowCasterPass.onRender(t),t.rendererUpdateFlag=rz.None);var m=s._batcherManager;if(c.reset(),t.rendererUpdateFlag|=rz.viewProjectionMatrix,t.applyVirtualCamera(i._virtualCamera,h),this._prepareRender(t),c.sortBatch(m),m.uploadBuffer(),h?(d.onConfig(i),d.onRender(t,c),t.rendererUpdateFlag=rz.None):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,s._basicResources.whiteTexture2D),f){y=i.renderTarget?i.renderTarget._depthFormat:l.context.depth&&l.context.stencil?t9.Depth24Stencil8:l.context.depth?t9.Depth24:l.context.stencil?t9.Stencil:null;var g=i.pixelViewport,v=rR.recreateRenderTargetIfNeeded(s,this._internalColorTarget,g.width,g.height,i._getInternalColorTextureFormat(),y,!1,!1,p,t7.Clamp,t5.Bilinear);if(!this._canUseBlitFrameBuffer&&this._shouldGrabColor){var y,x,b,C=rR.recreateTextureIfNeeded(s,this._grabTexture,g.width,g.height,null!=(b=null==(x=i.renderTarget)?void 0:x.getColorTexture(0).format)?b:t9.R8G8B8A8,!1,t7.Clamp,t5.Bilinear);this._grabTexture=C}this._internalColorTarget=v}else{var S,T=this._internalColorTarget,A=this._grabTexture;T&&(null==(S=T.getColorTexture(0))||S.destroy(!0),T.destroy(!0),this._internalColorTarget=null),A&&(A.destroy(!0),this._grabTexture=null)}this._drawRenderPass(t,i,_,n,r)},n._drawRenderPass=function(t,n,r,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue,u=n.engine,d=n.scene,h=d.background,_=u._hardwareRenderer,f=this._internalColorTarget,p=f||n.renderTarget,m=f?rR.defaultViewport:n.viewport,g=!!f||n.renderTarget&&void 0==a;t.flipProjection!==g&&(t.rendererUpdateFlag|=rz.ProjectionMatrix,t.applyVirtualCamera(n._virtualCamera,g)),_.activeRenderTarget(p,m,t.flipProjection,i,a);var v=h.solidColor;f&&r!==rw.All?(this._canUseBlitFrameBuffer?(r!==rw.None&&_.clearRenderTarget(u,r,v),_.blitInternalRTByBlitFrameBuffer(n.renderTarget,f,r,n.viewport)):(r&rw.Depth&&r&rw.Stencil||no.warn("We clear all depth/stencil state cause of the internalRT can't copy depth/stencil buffer from back buffer when use copy plan"),this._shouldGrabColor?(_.clearRenderTarget(u,rw.DepthStencil),_.copyRenderTargetToSubTexture(n.renderTarget,this._grabTexture,n.viewport),rR.blitTexture(u,this._grabTexture,f,0,void 0,void 0,void 0,!n.renderTarget)):_.clearRenderTarget(u,rw.All,v)),_.activeRenderTarget(p,m,t.flipProjection,i,a)):r!==rw.None&&_.clearRenderTarget(u,r,v);var y=d._maskManager;if(r&rw.Stencil&&(y.hasStencilWritten=!1),s.render(t,nX.Forward),l.render(t,nX.Forward),r&rw.Color&&(h.mode===rO.Sky?h.sky._render(t):h.mode===rO.Texture&&h.texture&&this._drawBackgroundTexture(n,h)),n.opaqueTextureEnabled){p._blitRenderTarget();var x=this._opaqueTexturePass;x.onConfig(n,p.getColorTexture(0)),x.onRender(t),_.activeRenderTarget(p,m,t.flipProjection,i,a)}else n.shaderData.setTexture(e.Camera._cameraOpaqueTextureProperty,null);c.render(t,nX.Forward),y.clearMask(t,nX.Forward);var b=d._postProcessManager,C=n.renderTarget;n.enablePostProcess&&b.hasActiveEffect?b._render(t,f,C):f&&(f._blitRenderTarget(),rR.blitTexture(u,f.getColorTexture(0),C,0,n.viewport)),null==C||C._blitRenderTarget(),null==C||C.generateMipmaps()},n.pushRenderElement=function(e,t){t.renderQueueFlags=0;for(var n=t.subRenderElements,r=0,a=n.length;r<a;++r){var i=n[r],o=i.material,s=o.renderStates,l=o.shader.subShaders[0],c=e.replacementShader;if(c){var u=c.subShaders,d=e.replacementTag;if(d){for(var h=!1,_=0,f=u.length;_<f;_++){var p=u[_];p.getTagValue(d)===l.getTagValue(d)&&(this.pushRenderElementByType(t,i,p.passes,s),h=!0)}h||e.replacementFailureStrategy!==rB.KeepOriginalShader||this.pushRenderElementByType(t,i,l.passes,s)}else this.pushRenderElementByType(t,i,u[0].passes,s)}else this.pushRenderElementByType(t,i,l.passes,s)}},n.pushRenderElementByType=function(e,t,n,r){for(var a=this._cullingResults,i=0,o=n.length;i<o;i++){var s=void 0,l=n[i],c=l._renderState,u=1<<(s=c?c._getRenderQueueByShaderData(l._renderStateDataMap,t.material.shaderData):r[i].renderQueueType);if(t.shaderPasses=n,t.renderQueueFlags|=u,!(e.renderQueueFlags&u)){switch(s){case nN.Opaque:a.opaqueQueue.pushRenderElement(e);break;case nN.AlphaTest:a.alphaTestQueue.pushRenderElement(e);break;case nN.Transparent:a.transparentQueue.pushRenderElement(e)}e.renderQueueFlags|=u}}},n._drawBackgroundTexture=function(e,t){var n=e.engine,r=n._hardwareRenderer,a=n.canvas,i=t._material,o=t._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&t._textureFillMode!==rN.Fill&&(this._lastCanvasSize.set(a.width,a.height),t._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0],l=s._getShaderProgram(n,ro._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,i.shaderData),l.uploadAll(l.cameraUniformBlock,e.shaderData),l.uploadUnGroupTextures(),(s._renderState||i.renderState)._applyStates(n,!1,s._renderStateDataMap,i.shaderData),r.drawPrimitive(o._primitive,o.subMesh,l)},n._prepareRender=function(e){for(var t=e.camera,n=t.engine,r=t.scene._componentsManager._renderers,a=r._elements,i=r.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=n.time.frameCount)}},t}(),r$=((ea={})[ea.None=0]="None",ea[ea.Opaque=1]="Opaque",ea[ea.AlphaTest=2]="AlphaTest",ea[ea.Transparent=4]="Transparent",ea[ea.All=7]="All",ea),r0=/*#__PURE__*/function(){function e(){this.subRenderElements=[]}var t=e.prototype;return t.set=function(e,t){this.priority=e,this.distanceForSort=t,this.subRenderElements.length=0},t.addSubRenderElement=function(e){this.subRenderElements.push(e)},t.dispose=function(){this.subRenderElements.length=0},e}(),r1=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.set=function(e,t,n,r,a,i){this.component=e,this.material=t,this.primitive=n,this.subPrimitive=r,this.texture=a,this.subChunk=i},t.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)},e}(),r2=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).influenceLayers=rg.Everything,r._maskIndex=-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._alphaCutoff=.5,rx.resetData(r),r.setMaterial(r._engine._basicResources.spriteMaskDefaultMaterial),r.shaderData.setFloat(t._alphaCutoffProperty,r._alphaCutoff),r._renderElement=new r0,r._renderElement.addSubRenderElement(new r1),r._onSpriteChange=r._onSpriteChange.bind(r),r}tW(t,e);var n=t.prototype;return n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.sprite=this._sprite},n._canBatch=function(e,t){return rl.canBatchSpriteMask(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._onEnableInScene=function(){e.prototype._onEnableInScene.call(this),this.scene._maskManager.addSpriteMask(this)},n._onDisableInScene=function(){e.prototype._onDisableInScene.call(this),this.scene._maskManager.removeSpriteMask(this)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManagerMask},n._updateBounds=function(e){this.sprite?rx.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,n=this.getMaterial();if(n){var r=this._engine;n.destroyed&&(n=r._basicResources.spriteMaskDefaultMaterial),this._dirtyUpdateFlag&rv.WorldVolume&&(rx.updatePositions(this),this._dirtyUpdateFlag&=~rv.WorldVolume),2&this._dirtyUpdateFlag&&(rx.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,n,o.chunk.primitive,o.subMesh,this.sprite.texture,o),i.shaderPasses=n.shader.subShaders[0].passes,i.renderQueueFlags=r$.All,a.addSubRenderElement(i)}}},n._onDestroy=function(){var t=this._sprite;t&&(this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onSpriteChange)),e.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 nw.texture:this.shaderData.setTexture(t._textureProperty,this.sprite.texture);break;case nw.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=rv.WorldVolume);break;case nw.region:case nw.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case nw.atlasRegion:this._dirtyUpdateFlag|=2;break;case nw.pivot:this._dirtyUpdateFlag|=rv.WorldVolume;break;case nw.destroy:this.sprite=null}},tG(t,[{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|=rv.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|=rv.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=rv.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var n=this._sprite;n!==e&&(n&&(this._addResourceReferCount(n,-1),n._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(this._addResourceReferCount(e,1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(t._textureProperty,e.texture)):this.shaderData.setTexture(t._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(t._alphaCutoffProperty,e))}}]),t}(e.Renderer);r2._textureProperty=nY.getByName("renderer_MaskTexture"),r2._alphaCutoffProperty=nY.getByName("renderer_MaskAlphaCutoff"),tX([tQ],r2.prototype,"influenceLayers",void 0),tX([tq],r2.prototype,"_renderElement",void 0),tX([tq],r2.prototype,"_subChunk",void 0),tX([tq],r2.prototype,"_maskIndex",void 0),tX([tq],r2.prototype,"_sprite",void 0),tX([tq],r2.prototype,"_automaticWidth",void 0),tX([tq],r2.prototype,"_automaticHeight",void 0),tX([tQ],r2.prototype,"_customWidth",void 0),tX([tQ],r2.prototype,"_customHeight",void 0),tX([tQ],r2.prototype,"_flipX",void 0),tX([tQ],r2.prototype,"_flipY",void 0),tX([tQ],r2.prototype,"_alphaCutoff",void 0),tX([tq],r2.prototype,"_onSpriteChange",null);var r3=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._textChunks=[],n._subFont=null,n._dirtyFlag=15,n._color=new tO(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new tE,n._font=null,n._fontSize=24,n._fontStyle=n_.None,n._lineSpacing=0,n._horizontalAlignment=ny.Center,n._verticalAlignment=nx.Center,n._enableWrapping=!1,n._overflowMode=nf.Overflow;var n,r=n.engine;return n._font=r._textDefaultFont,n._addResourceReferCount(n._font,1),n.setMaterial(r._basicResources.textDefaultMaterial),n._color._onValueChanged=n._onColorChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){this._font&&(this._addResourceReferCount(this._font,-1),this._font=null),e.prototype._onDestroy.call(this),this._freeTextChunks(),this._textChunks=null,this._subFont&&(this._subFont=null)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.font=this._font,t._subFont=this._subFont},n._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},n._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},n._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},n._getSubFont=function(){return this._subFont||this._resetSubFont(),this._subFont},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._canBatch=function(e,t){return rl.canBatchSprite(e,t)},n._batch=function(e,t){rl.batchFor2D(e,t)},n._getChunkManager=function(){return this.engine._batcherManager.primitiveChunkManager2D},n._updateBounds=function(e){tE.transform(this._localBounds,this._entity.transform.worldMatrix,e)},n._render=function(e){if(!this._isTextNoVisible()){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(16)&&(this._updateColor(),this._setDirtyFlagFalse(16));var n=e.camera,r=n.engine,a=r._textSubRenderElementPool,i=this.getMaterial(),o=r._renderElementPool.get();o.set(this.priority,this._distanceForSort);for(var s=this._textChunks,l=0,c=s.length;l<c;++l){var u=s[l],d=u.subChunk,h=u.texture,_=a.get();_.set(this,i,d.chunk.primitive,d.subMesh,h,d),_.shaderData||(_.shaderData=new rs(n8.RenderElement)),_.shaderData.setTexture(t._textureProperty,h),o.addSubRenderElement(_)}n._renderPipeline.pushRenderElement(e,o)}},n._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=np.getNativeFontString(e.name,this.fontSize,this.fontStyle)},n._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,n=e[0],r=e[1],a=e[2],i=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],d=t._tempVec31.set(i,o,s),h=t._tempVec30.set(n,r,a),_=t._worldPositions,f=_[0],p=_[1],m=_[2],g=_[3],v=this._textChunks,y=0,x=v.length;y<x;++y)for(var b=v[y],C=b.subChunk,S=b.charRenderInfos,T=0,A=S.length;T<A;++T){var E=S[T],R=E.localPositions,M=R.x,w=R.y;f.set(M*n+w*i+l,M*r+w*o+c,M*a+w*s+u),tT.scale(h,R.z-M,p),tT.add(f,p,p),tT.scale(d,R.w-w,m),tT.add(f,m,g),tT.add(p,m,m);for(var P=C.chunk.vertices,F=0,L=C.vertexArea.start+36*E.indexInChunk;F<4;++F,L+=9)_[F].copyToArray(P,L)}},n._updateColor=function(){for(var e=this._color,t=e.r,n=e.g,r=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]=n,d[_+2]=r,d[_+3]=a},n._updateLocalData=function(){var e=this._localBounds,n=e.min,r=e.max,a=t._charRenderInfos,i=this._subFont,o=this.enableWrapping?np.measureTextWithWrap(this):np.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=iJ._pixelsPerUnit,m=this.horizontalAlignment,g=1/p,v=.5*(this.width*p),y=this.height*p,x=.5*u,b=0,C=.5*u-d[0].ascent,S=.5*u-d[_-1].descent-1;switch(this.verticalAlignment){case nx.Top:b=.5*y-x+C;break;case nx.Center:b=.5*s-x-(S-C)*.5;break;case nx.Bottom:b=s-.5*y-x-S}for(var T=-1,A=Number.MAX_SAFE_INTEGER,E=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,M=Number.MIN_SAFE_INTEGER,w=0;w<_;++w){var P=c[w];if(P>0){var F=l[w],L=0,D=-1;switch(T<0&&(T=w),m){case ny.Left:L=-v;break;case ny.Center:L=-(.5*P);break;case ny.Right:L=v-P}for(var B=0,I=F.length;B<I;++B){var O=F[B],N=i._getCharInfo(O);if(N.h>0){D<0&&(D=B);var V=a[f++]=h.get(),k=V.localPositions;V.texture=i._getTextureByIndex(N.index),V.uvs=N.uvs;var z=N.w,U=N.ascent,G=N.descent,H=L*g,W=(L+z)*g,j=(b+U)*g,X=(b-G)*g;k.set(H,j,W,X),w===T&&(M=Math.max(M,j)),E=Math.min(E,X),B===D&&(A=Math.min(A,H)),R=Math.max(R,W)}L+=N.xAdvance+N.offsetX}}b-=u}T<0?(n.set(0,0,0),r.set(0,0,0)):(n.set(A,E,0),r.set(R,M,0))}else n.set(0,0,0),r.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 K=this._textChunks,Y=new r4;K.push(Y);var q=this._getChunkManager().maxVertexCount,Q=a[0],J=Q.texture;Y.texture=J;var Z=Y.charRenderInfos;Z.push(Q);for(var $=1;$<f;++$){var ee=a[$],et=ee.texture;(J!==et||4*Z.length+4>q)&&(this._buildChunk(Y,Z.length),Y=new r4,K.push(Y),J=et,Y.texture=et,Z=Y.charRenderInfos),Z.push(ee)}var en=Z.length;en>0&&this._buildChunk(Y,en),a.length=0}},n._onTransformChanged=function(t){e.prototype._onTransformChanged.call(this,t),this._setDirtyFlagTrue(12)},n._isTextNoVisible=function(){return""===this._text||0===this._fontSize||this.enableWrapping&&this.width<=0||this.overflowMode===nf.Truncate&&this.height<=0},n._buildChunk=function(e,t){for(var n=this.color,r=n.r,a=n.g,i=n.b,o=n.a,s=tj.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]=r,u[m+3]=a,u[m+4]=i,u[m+5]=o}return c},n._freeTextChunks=function(){for(var e=this._textChunks,t=this.engine._charRenderInfoPool,n=this._getChunkManager(),r=0,a=e.length;r<a;++r){for(var i=e[r],o=i.charRenderInfos,s=0,l=o.length;s<l;++s)t.return(o[s]);o.length=0,n.freeSubChunk(i.subChunk),i.subChunk=null,i.texture=null}e.length=0},n._onColorChanged=function(){this._setDirtyFlagTrue(16)},tG(t,[{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)}},{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}}]),t}(e.Renderer);r3._textureProperty=nY.getByName("renderElement_TextTexture"),r3._tempVec30=new tT,r3._tempVec31=new tT,r3._worldPositions=[new tT,new tT,new tT,new tT],r3._charRenderInfos=[],tX([tq],r3.prototype,"_textChunks",void 0),tX([tQ],r3.prototype,"_subFont",void 0),tX([tq],r3.prototype,"_dirtyFlag",void 0),tX([tZ],r3.prototype,"_color",void 0),tX([tQ],r3.prototype,"_text",void 0),tX([tQ],r3.prototype,"_width",void 0),tX([tQ],r3.prototype,"_height",void 0),tX([tq],r3.prototype,"_localBounds",void 0),tX([tQ],r3.prototype,"_font",void 0),tX([tQ],r3.prototype,"_fontSize",void 0),tX([tQ],r3.prototype,"_fontStyle",void 0),tX([tQ],r3.prototype,"_lineSpacing",void 0),tX([tQ],r3.prototype,"_horizontalAlignment",void 0),tX([tQ],r3.prototype,"_verticalAlignment",void 0),tX([tQ],r3.prototype,"_enableWrapping",void 0),tX([tQ],r3.prototype,"_overflowMode",void 0),tX([tq],r3.prototype,"_onColorChanged",null);var r4=function(){this.charRenderInfos=[]},r8=((ei={})[ei.Static=0]="Static",ei[ei.Dynamic=1]="Dynamic",ei[ei.Stream=2]="Stream",ei),r5=((eo={})[eo.None=0]="None",eo[eo.Discard=1]="Discard",eo),r9=/*#__PURE__*/function(e){function t(t,n,r,a,i){if(void 0===a&&(a=r8.Static),void 0===i&&(i=!1),(o=e.call(this,t)||this)._dataUpdateManager=new nM,o._engine=t,o._type=n,o._bufferUsage=a,o._readable=i,"number"==typeof r)o._byteLength=r,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,r,a),i&&(o._data=new Uint8Array(r));else{var o,s=r.byteLength;if(o._byteLength=s,o._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,s,a,r),i){var l=r.constructor===ArrayBuffer?r.slice(0):r.buffer.slice(r.byteOffset,r.byteOffset+s);o._data=new Uint8Array(l)}}return o}tW(t,e);var n=t.prototype;return n.bind=function(){this._platformBuffer.bind()},n.setData=function(e,t,n,r,a){if(void 0===t&&(t=0),void 0===n&&(n=0),void 0===a&&(a=r5.None),this._platformBuffer.setData(this._byteLength,e,t,n,r,a),this._readable){var i=e.constructor===ArrayBuffer?e:e.buffer;if(this._data.buffer!==i){var o=e.BYTES_PER_ELEMENT||1,s=r?o*r:e.byteLength,l=new Uint8Array(i,void 0!==e.byteOffset?e.byteOffset+n*o:n,s);this._data.set(l,t)}}this._isContentLost=!1,this._dataUpdateManager.dispatch()},n.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},n.markAsUnreadable=function(){this._data=null,this._readable=!1},n._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformBuffer.destroy()},tG(t,[{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."}}]),t}(ne),r6=((es={})[es.UInt8=0]="UInt8",es[es.UInt16=1]="UInt16",es[es.UInt32=2]="UInt32",es),r7=((el={})[el.Float=0]="Float",el[el.Vector2=1]="Vector2",el[el.Vector3=2]="Vector3",el[el.Vector4=3]="Vector4",el[el.Byte4=4]="Byte4",el[el.UByte4=5]="UByte4",el[el.NormalizedByte4=6]="NormalizedByte4",el[el.NormalizedUByte4=7]="NormalizedUByte4",el[el.Short2=8]="Short2",el[el.UShort2=9]="UShort2",el[el.NormalizedShort2=10]="NormalizedShort2",el[el.NormalizedUShort2=11]="NormalizedUShort2",el[el.Short4=12]="Short4",el[el.UShort4=13]="UShort4",el[el.NormalizedShort4=14]="NormalizedShort4",el[el.NormalizedUShort4=15]="NormalizedUShort4",el),ae=/*#__PURE__*/function(){function e(){}return e._getGLIndexType=function(e){switch(e){case r6.UInt8:return nQ.UNSIGNED_BYTE;case r6.UInt16:return nQ.UNSIGNED_SHORT;case r6.UInt32:return nQ.UNSIGNED_INT}},e._getGLIndexByteCount=function(e){switch(e){case r6.UInt8:return 1;case r6.UInt16:return 2;case r6.UInt32:return 4}},e._getElementInfo=function(e){var t,n,r,a=!1;switch(e){case r7.Float:t=1,n=nQ.FLOAT;break;case r7.Vector2:t=2,n=nQ.FLOAT;break;case r7.Vector3:t=3,n=nQ.FLOAT;break;case r7.Vector4:t=4,n=nQ.FLOAT;break;case r7.Byte4:t=4,n=nQ.BYTE;break;case r7.UByte4:t=4,n=nQ.UNSIGNED_BYTE;break;case r7.NormalizedByte4:t=4,n=nQ.BYTE,a=!0,r=1/127;break;case r7.NormalizedUByte4:t=4,n=nQ.UNSIGNED_BYTE,a=!0,r=1/255;break;case r7.Short2:t=2,n=nQ.SHORT;break;case r7.UShort2:t=2,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort2:t=2,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort2:t=2,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535;break;case r7.Short4:t=4,n=nQ.SHORT;break;case r7.UShort4:t=4,n=nQ.UNSIGNED_SHORT;break;case r7.NormalizedShort4:t=4,n=nQ.SHORT,a=!0,r=1/32767;break;case r7.NormalizedUShort4:t=4,n=nQ.UNSIGNED_SHORT,a=!0,r=1/65535}return{size:t,type:n,normalized:a,normalizedScaleFactor:r}},e}(),at=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=n,this._bindingIndex=r,this._formatMetaInfo=ae._getElementInfo(this.format),this._instanceStepRate=Math.floor(a)}return tG(e,[{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}}]),e}(),an=((ec={})[ec.VertexBuffer=0]="VertexBuffer",ec[ec.IndexBuffer=1]="IndexBuffer",ec),ar=((eu={})[eu.Points=0]="Points",eu[eu.Lines=1]="Lines",eu[eu.LineLoop=2]="LineLoop",eu[eu.LineStrip=3]="LineStrip",eu[eu.Triangles=4]="Triangles",eu[eu.TriangleStrip=5]="TriangleStrip",eu[eu.TriangleFan=6]="TriangleFan",eu),aa=((ed={})[ed.Normal=0]="Normal",ed[ed.Additive=1]="Additive",ed),ai=((eh={})[eh.Front=0]="Front",eh[eh.Back=1]="Back",eh[eh.Double=2]="Double",eh),ao=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this)._renderStates=[],r._shaderData=new rs(n8.Material),r.shader=n,r}tW(t,e);var n=t.prototype;return n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),t$.deepCloneObject(this.renderStates,e.renderStates,new Map)},n._addReferCount=function(t){this._destroyed||(e.prototype._addReferCount.call(this,t),this.shaderData._addReferCount(t),this._shader._addReferCount(t))},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},tG(t,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.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++)r.push(new ri);else r.length=i}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t}(t1),as=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n,r)||this)._renderFace=ai.Front,a._isTransparent=!1,a._blendMode=aa.Normal;var a,i=a.shaderData;return i.setFloat(t._alphaCutoffProp,0),i.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque),a}tW(t,e);var n=t.prototype;return n.setIsTransparent=function(e,n){var r=this.renderStates;if(r.length<e)throw"Pass should less than pass count.";var a=r[e],i=this.shaderData;n?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=nN.Transparent,i.enableMacro(t._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.renderQueueType=i.getFloat(t._alphaCutoffProp)?nN.AlphaTest:nN.Opaque,i.disableMacro(t._transparentMacro))},n.setBlendMode=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";var r=n[e].blendState.targetBlendState;switch(t){case aa.Normal:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add;break;case aa.Additive:r.sourceColorBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=nF.One,r.sourceAlphaBlendFactor=nF.One,r.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=nL.Add}},n.setRenderFace=function(e,t){var n=this.renderStates;if(n.length<e)throw"Pass should less than pass count.";switch(t){case ai.Front:n[e].rasterState.cullMode=nI.Back;break;case ai.Back:n[e].rasterState.cullMode=nI.Front;break;case ai.Double:n[e].rasterState.cullMode=nI.Off}},n.clone=function(){var e=new t(this._engine,this.shader);return this.cloneTo(e),e},n.cloneTo=function(t){e.prototype.cloneTo.call(this,t),t._renderFace=this._renderFace,t._isTransparent=this._isTransparent,t._blendMode=this._blendMode},tG(t,[{key:"shader",get:function(){return this._shader},set:function(e){var t,n=this._getReferCount();n>0&&(null==(t=this._shader)||t._addReferCount(-n),e._addReferCount(n)),this._shader=e;for(var r=this._renderStates,a=r.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++)r.push(new ri),this.setBlendMode(l,aa.Normal);else r.length=i}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){if(e!==this._isTransparent){this.setIsTransparent(0,e);var n=this.shaderData;e?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.getFloat(t._alphaCutoffProp)?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque),this._isTransparent=e}}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(t._alphaCutoffProp)},set:function(e){var n=this.shaderData;if(n.getFloat(t._alphaCutoffProp)!==e){e?(n.enableMacro(t._alphaCutoffMacro),n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest)):(n.disableMacro(t._alphaCutoffMacro),this._isTransparent?n.setFloat(t._shadowCasterRenderQueueProp,nN.AlphaTest):n.setFloat(t._shadowCasterRenderQueueProp,nN.Opaque));for(var r=this.renderStates,a=0,i=r.length;a<i;a++){var o=r[a];e>0?o.renderQueueType=o.blendState.targetBlendState.enabled?nN.Transparent:nN.AlphaTest:o.renderQueueType=o.blendState.targetBlendState.enabled?nN.Transparent:nN.Opaque}n.setFloat(t._alphaCutoffProp,e)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),t}(ao);as._shadowCasterRenderQueueProp=nY.getByName("material_ShadowCasterRenderQueue"),as._baseTextureMacro=nH.getByName("MATERIAL_HAS_BASETEXTURE"),as._normalTextureMacro=nH.getByName("MATERIAL_HAS_NORMALTEXTURE"),as._emissiveTextureMacro=nH.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),as._transparentMacro=nH.getByName("MATERIAL_IS_TRANSPARENT"),as._baseColorProp=nY.getByName("material_BaseColor"),as._baseTextureProp=nY.getByName("material_BaseTexture"),as._tilingOffsetProp=nY.getByName("material_TilingOffset"),as._normalTextureProp=nY.getByName("material_NormalTexture"),as._normalIntensityProp=nY.getByName("material_NormalIntensity"),as._emissiveColorProp=nY.getByName("material_EmissiveColor"),as._emissiveTextureProp=nY.getByName("material_EmissiveTexture"),as._alphaCutoffProp=nY.getByName("material_AlphaCutoff"),as._alphaCutoffMacro=nH.getByName("MATERIAL_IS_ALPHA_CUTOFF");var al=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setColor(t._specularColorProp,new tO(1,1,1,1)),a.setColor(t._emissiveColorProp,new tO(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.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 n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.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 n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.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 n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as);al._specularColorProp=nY.getByName("material_SpecularColor"),al._shininessProp=nY.getByName("material_Shininess"),al._specularTextureProp=nY.getByName("material_SpecularTexture");var ac=((e_={})[e_.UV0=0]="UV0",e_[e_.UV1=1]="UV1",e_[e_.UV2=2]="UV2",e_[e_.UV3=3]="UV3",e_[e_.UV4=4]="UV4",e_[e_.UV5=5]="UV5",e_[e_.UV6=6]="UV6",e_[e_.UV7=7]="UV7",e_),au=/*#__PURE__*/function(e){function t(n,r){var a,i=(a=e.call(this,n,r)||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new tO(1,1,1,1)),i.setColor(t._emissiveColorProp,new tO(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),i.setFloat(t._normalIntensityProp,1),i.setFloat(t._occlusionTextureIntensityProp,1),i.setFloat(t._occlusionTextureCoordProp,ac.UV0),i.setFloat(t._clearCoatProp,0),i.setFloat(t._clearCoatRoughnessProp,0),a}return tW(t,e),tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.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:"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:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(t._normalIntensityProp)},set:function(e){this.shaderData.setFloat(t._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(t._emissiveColorProp)},set:function(e){var n=this.shaderData.getColor(t._emissiveColorProp);e!==n&&n.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:"occlusionTexture",get:function(){return this.shaderData.getTexture(t._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(t._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(t._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(t._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(t._occlusionTextureCoordProp)},set:function(e){e>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(t._occlusionTextureCoordProp,e)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(t._tilingOffsetProp)},set:function(e){var n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(t._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(t._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(t._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(t._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(t._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(t._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(t._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(t._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(t._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(t._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(t._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),t}(as);au._occlusionTextureIntensityProp=nY.getByName("material_OcclusionIntensity"),au._occlusionTextureCoordProp=nY.getByName("material_OcclusionTextureCoord"),au._occlusionTextureProp=nY.getByName("material_OcclusionTexture"),au._clearCoatProp=nY.getByName("material_ClearCoat"),au._clearCoatTextureProp=nY.getByName("material_ClearCoatTexture"),au._clearCoatRoughnessProp=nY.getByName("material_ClearCoatRoughness"),au._clearCoatRoughnessTextureProp=nY.getByName("material_ClearCoatRoughnessTexture"),au._clearCoatNormalTextureProp=nY.getByName("material_ClearCoatNormalTexture");var ad=/*#__PURE__*/function(e){function t(n){(r=e.call(this,n,ro.find("pbr"))||this)._anisotropyRotation=0,r._iridescenceRange=new tB(100,400),r._sheenEnabled=!1;var r,a=r.shaderData;a.setFloat(t._metallicProp,1),a.setFloat(t._roughnessProp,1),a.setFloat(t._iorProp,1.5),a.setVector3(t._anisotropyInfoProp,new tT(1,0,0)),a.setVector4(t._iridescenceInfoProp,new tI(0,1.3,100,400));var i=new tO(0,0,0);return a.setColor(t._sheenColorProp,i),r._iridescenceRange._onValueChanged=r._onIridescenceRangeChanged.bind(r),i._onValueChanged=function(){var e=i.r+i.g+i.b>0;e!==r._sheenEnabled&&(r._sheenEnabled=e,e?r.shaderData.enableMacro("MATERIAL_ENABLE_SHEEN"):r.shaderData.disableMacro("MATERIAL_ENABLE_SHEEN"))},r}tW(t,e);var n=t.prototype;return n._onIridescenceRangeChanged=function(){var e=this.shaderData.getVector4(t._iridescenceInfoProp);e.z=this._iridescenceRange.x,e.w=this._iridescenceRange.y},n.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(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 n=this.shaderData.getVector3(t._anisotropyInfoProp);!!n.z!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_ANISOTROPY"):this.shaderData.enableMacro("MATERIAL_ENABLE_ANISOTROPY")),n.z=e}},{key:"anisotropyRotation",get:function(){return this._anisotropyRotation},set:function(e){if(this._anisotropyRotation!==e){this._anisotropyRotation=e;var n=this.shaderData.getVector3(t._anisotropyInfoProp),r=tS.degreeToRadFactor*e;n.x=Math.cos(r),n.y=Math.sin(r)}}},{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")}},{key:"iridescence",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).x},set:function(e){e=Math.max(0,Math.min(1,e));var n=this.shaderData.getVector4(t._iridescenceInfoProp);!!n.x!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_IRIDESCENCE"):this.shaderData.enableMacro("MATERIAL_ENABLE_IRIDESCENCE")),n.x=e}},{key:"iridescenceTexture",get:function(){return this.shaderData.getTexture(t._iridescenceTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_TEXTURE")}},{key:"iridescenceIOR",get:function(){return this.shaderData.getVector4(t._iridescenceInfoProp).y},set:function(e){this.shaderData.getVector4(t._iridescenceInfoProp).y=Math.max(e,1)}},{key:"iridescenceThicknessRange",get:function(){return this._iridescenceRange},set:function(e){this._iridescenceRange!==e&&this._iridescenceRange.copyFrom(e)}},{key:"iridescenceThicknessTexture",get:function(){return this.shaderData.getTexture(t._iridescenceThicknessTextureProp)},set:function(e){this.shaderData.setTexture(t._iridescenceThicknessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_IRIDESCENCE_THICKNESS_TEXTURE")}},{key:"sheenColor",get:function(){return this.shaderData.getColor(t._sheenColorProp)},set:function(e){var n=this.shaderData.getColor(t._sheenColorProp);e!==n&&n.copyFrom(e)}},{key:"sheenRoughness",get:function(){return this.shaderData.getFloat(t._sheenRoughnessProp)},set:function(e){e=Math.max(0,Math.min(1,e)),this.shaderData.setFloat(t._sheenRoughnessProp,e)}},{key:"sheenColorTexture",get:function(){return this.shaderData.getTexture(t._sheenTextureProp)},set:function(e){this.shaderData.setTexture(t._sheenTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SHEEN_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SHEEN_TEXTURE")}},{key:"sheenRoughnessTexture",get:function(){return this.shaderData.getTexture(t._sheenRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(t._sheenRoughnessTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_SHEEN_ROUGHNESS_TEXTURE")}}]),t}(au);ad._metallicProp=nY.getByName("material_Metal"),ad._roughnessProp=nY.getByName("material_Roughness"),ad._roughnessMetallicTextureProp=nY.getByName("material_RoughnessMetallicTexture"),ad._iorProp=nY.getByName("material_IOR"),ad._anisotropyInfoProp=nY.getByName("material_AnisotropyInfo"),ad._anisotropyTextureProp=nY.getByName("material_AnisotropyTexture"),ad._iridescenceInfoProp=nY.getByName("material_IridescenceInfo"),ad._iridescenceThicknessTextureProp=nY.getByName("material_IridescenceThicknessTexture"),ad._iridescenceTextureProp=nY.getByName("material_IridescenceTexture"),ad._sheenColorProp=nY.getByName("material_SheenColor"),ad._sheenRoughnessProp=nY.getByName("material_SheenRoughness"),ad._sheenTextureProp=nY.getByName("material_SheenTexture"),ad._sheenRoughnessTextureProp=nY.getByName("material_SheenRoughnessTexture");var ah=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new tO(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"specularColor",get:function(){return this.shaderData.getColor(t._specularColorProp)},set:function(e){var n=this.shaderData.getColor(t._specularColorProp);e!==n&&n.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}(au);ah._specularColorProp=nY.getByName("material_PBRSpecularColor"),ah._glossinessProp=nY.getByName("material_Glossiness"),ah._specularGlossinessTextureProp=nY.getByName("material_SpecularGlossinessTexture"),ah._specularGlossinessTextureMacro=nH.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var a_=/*#__PURE__*/function(e){function t(n){var r,a=(r=e.call(this,n,ro.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new tO(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new tI(1,1,0,0)),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(t._baseColorProp)},set:function(e){var n=this.shaderData.getColor(t._baseColorProp);e!==n&&n.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 n=this.shaderData.getVector4(t._tilingOffsetProp);e!==n&&n.copyFrom(e)}}]),t}(as),af=/*#__PURE__*/function(){function e(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new nM,this._dirty=7,n&&n.length!==t.length)throw"deltaNormals length must same with deltaPositions length.";if(r&&r.length!==t.length)throw"deltaTangents length must same with deltaPositions length.";this.weight=e,this._deltaPositions=t,this._deltaNormals=n,this._deltaTangents=r}return e.prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},tG(e,[{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)}}]),e}(),ap=((ef={})[ef.Position=1]="Position",ef[ef.Normal=2]="Normal",ef[ef.Tangent=4]="Tangent",ef[ef.All=7]="All",ef),am=/*#__PURE__*/function(){function e(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new nM,this._dataChangeManager=new nM,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}var t=e.prototype;return t.addFrame=function(e,t,n,r){if("number"==typeof e){var a=new af(e,t,n,r);return this._addFrame(a),a}this._addFrame(e)},t.clearFrames=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._dataChangeManager.removeListener(this._frameDataChangeListener);e.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},t._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},t._addFrame=function(e){var t=this._frames,n=t.length;if(n>0&&e.deltaPositions.length!==t[n-1].deltaPositions.length)throw"Frame's deltaPositions length must same with before frame deltaPositions length.";this._frames.push(e),this._frameDataChangeListener(ap.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},t._updateUseNormalAndTangent=function(e,t){var n=this._useBlendShapeNormal&&e,r=this._useBlendShapeTangent&&t;(this._useBlendShapeNormal!==n||this._useBlendShapeTangent!==r)&&(this._useBlendShapeNormal=n,this._useBlendShapeTangent=r,this._layoutChangeManager.dispatch(0,this))},t._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},tG(e,[{key:"frames",get:function(){return this._frames}}]),e}(),ag=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._format=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),e}(),av=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=ar.Triangles),this.start=e,this.count=t,this.topology=n},ay=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.dispose=function(){},t}(av),ax=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).enableVAO=!0,n.instanceCount=0,n.vertexBufferBindings=[],n._vertexElementMap={},n._bufferStructChanged=!1,n._vertexElements=[],n._platformPrimitive=t._hardwareRenderer.createPlatformPrimitive(n),n}tW(t,e);var n=t.prototype;return n.addVertexElement=function(e){var t=this._vertexElementMap,n=this._vertexElements,r=e.attribute,a=t[r];a&&(console.warn("VertexElement "+r+" already exists."),n.splice(n.indexOf(a),1)),t[r]=e,n.push(e),this._bufferStructChanged=!0},n.removeVertexElement=function(e){var t=this._vertexElements,n=t[e];t.splice(e,1),delete this._vertexElementMap[n.attribute],this._bufferStructChanged=!0},n.clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t];this._bufferStructChanged=!0},n.setVertexElement=function(e,t){var n=this._vertexElementMap,r=this._vertexElements,a=r[e];a&&delete n[a.attribute],n[t.attribute]=t,r[e]=t,this._bufferStructChanged=!0},n.setVertexElementsLength=function(e){for(var t=this._vertexElementMap,n=this._vertexElements,r=e,a=n.length;r<a;r++){var i=n[r];delete t[i.attribute]}n.length=e},n.setVertexBufferBinding=function(e,t){var n,r=this._getReferCount(),a=this.vertexBufferBindings;r>0&&(null==(n=a[e])||n.buffer._addReferCount(-r),null==t||t.buffer._addReferCount(r)),a[e]=t,this._bufferStructChanged=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this.setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e){var t=this.indexBufferBinding,n=this._getReferCount();t!==e&&(this._indexBufferBinding=e,n>0&&(null==t||t.buffer._addReferCount(-n)),e?(n>0&&e.buffer._addReferCount(n),this._glIndexType=ae._getGLIndexType(e.format),this._glIndexByteCount=ae._getGLIndexByteCount(e.format)):this._glIndexType=void 0,this._bufferStructChanged=(null==t?void 0:t.buffer)!==(null==e?void 0:e.buffer))},n.draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t);for(var n,r,a=this.vertexBufferBindings,i=0,o=a.length;i<o;i++)null==(r=a[i])||r.buffer._addReferCount(t);null==(n=this.indexBufferBinding)||n._buffer._addReferCount(t)},n._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this),this._isContentLost=!1},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._platformPrimitive.destroy(),this._vertexElementMap=null},tG(t,[{key:"vertexElements",get:function(){return this._vertexElements}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}}]),t}(ne),ab=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._updateFlagManager=new nM,r._bounds=new tE,r._subMeshes=[],r.name=n,r._primitive=new ax(t),r._onBoundsChanged=r._onBoundsChanged.bind(r);var r,a=r._bounds;return a.min._onValueChanged=r._onBoundsChanged,a.max._onValueChanged=r._onBoundsChanged,r}tW(t,e);var n=t.prototype;return n.addSubMesh=function(e,t,n){return void 0===n&&(n=ar.Triangles),"number"==typeof e&&(e=new ay(e,t,n)),this._subMeshes.push(e),e},n.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},n.clearSubMesh=function(){this._subMeshes.length=0},n._clearVertexElements=function(){this._primitive.clearVertexElements(),this._updateFlagManager.dispatch(2)},n._addVertexElement=function(e){this._primitive.addVertexElement(e),this._updateFlagManager.dispatch(2)},n._removeVertexElement=function(e){this._primitive.removeVertexElement(e),this._updateFlagManager.dispatch(2)},n._setVertexElement=function(e,t){this._primitive.setVertexElement(e,t),this._updateFlagManager.dispatch(2)},n._setVertexElementsLength=function(e){this._primitive.setVertexElementsLength(e)},n._setVertexBufferBinding=function(e,t){this._primitive.setVertexBufferBinding(e,t)},n._addReferCount=function(t){e.prototype._addReferCount.call(this,t),this._primitive._addReferCount(t)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._primitive.destroy()},n._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},n._setIndexBufferBinding=function(e){this._primitive.setIndexBufferBinding(e)},n._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},tG(t,[{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}}]),t}(t1),aC=((ep={})[ep.Bounds=1]="Bounds",ep[ep.VertexElements=2]="VertexElements",ep),aS=/*#__PURE__*/function(){function e(e,t){this._buffer=e,this._stride=t}return tG(e,[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),e}(),aT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}tW(t,e);var n=t.prototype;return n.setVertexElements=function(e){this._setVertexElements(e)},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aS(e,t));var i=this._primitive.vertexBufferBindings;i.length<=n&&(i.length=n+1),this._setVertexBufferBinding(a?t:n,r)},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._primitive.vertexBufferBindings,r=e.length,a=t+r;n.length<a&&(n.length=a);for(var i=0;i<r;i++)this._setVertexBufferBinding(t+i,e[i])},n.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new ag(e,t))),this._setIndexBufferBinding(n)},tG(t,[{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}}]),t}(ab),aA=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._enableVertexColor=!1,n._onMeshChanged=n._onMeshChanged.bind(n),n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1),t._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null),e.prototype._onDestroy.call(this)},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),t.mesh=this._mesh},n._prepareRender=function(t){if(!this._mesh){no.error("mesh is null.");return}if(this._mesh.destroyed){no.error("mesh is destroyed.");return}e.prototype._prepareRender.call(this,t)},n._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds;tE.transform(n,this._transformEntity.transform.worldMatrix,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},n._render=function(e){var n=this._mesh;if(2&this._dirtyUpdateFlag){var r=this.shaderData,a=n._primitive.vertexElements;r.disableMacro(t._uvMacro),r.disableMacro(t._uv1Macro),r.disableMacro(t._normalMacro),r.disableMacro(t._tangentMacro),r.disableMacro(t._enableVertexColorMacro);for(var i=0,o=a.length;i<o;i++)switch(a[i].attribute){case"TEXCOORD_0":r.enableMacro(t._uvMacro);break;case"TEXCOORD_1":r.enableMacro(t._uv1Macro);break;case"NORMAL":r.enableMacro(t._normalMacro);break;case"TANGENT":r.enableMacro(t._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&r.enableMacro(t._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}var s=this._materials,l=this._engine,c=n.subMeshes,u=l._renderElementPool.get();u.set(this.priority,this._distanceForSort);for(var d=l._subRenderElementPool,h=0,_=c.length;h<_;h++){var f=s[h];if(f){(f.destroyed||f.shader.destroyed)&&(f=this.engine._meshMagentaMaterial);var p=d.get();p.set(this,f,n._primitive,c[h]),u.addSubRenderElement(p)}}e.camera._renderPipeline.pushRenderElement(e,u)},n._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},n._onMeshChanged=function(e){e&aC.Bounds&&(this._dirtyUpdateFlag|=rv.WorldVolume),e&aC.VertexElements&&(this._dirtyUpdateFlag|=2)},tG(t,[{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)}}]),t}(e.Renderer);aA._uvMacro=nH.getByName("RENDERER_HAS_UV"),aA._uv1Macro=nH.getByName("RENDERER_HAS_UV1"),aA._normalMacro=nH.getByName("RENDERER_HAS_NORMAL"),aA._tangentMacro=nH.getByName("RENDERER_HAS_TANGENT"),aA._enableVertexColorMacro=nH.getByName("RENDERER_ENABLE_VERTEXCOLOR"),tX([tq],aA.prototype,"_mesh",void 0),tX([tq],aA.prototype,"_onMeshChanged",null);var aE=/*#__PURE__*/function(){function e(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 tI,this._canUseTextureStoreData=!0,this._dataTextureInfo=new tT,this._engine=e,this._modelMesh=t,this._canUseTextureStoreData=this._engine._hardwareRenderer.capability.canUseFloatTextureBlendShape,this._updateLayoutChange=this._updateLayoutChange.bind(this)}var t=e.prototype;return t._addBlendShape=function(e){this._blendShapes.push(e),this._blendShapeCount++,e._layoutChangeManager.addListener(this._updateLayoutChange),this._updateLayoutChange(0,e),this._subDataDirtyFlags.push(e._dataChangeManager.createFlag(rf))},t._clearBlendShapes=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;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 r=this._subDataDirtyFlags,a=0,i=r.length;a<i;a++)r[a].destroy();r.length=0},t._updateShaderData=function(t,n){var r=this._blendShapeCount;if(r>0){if(t.enableMacro(e._blendShapeMacro),this._useTextureMode())t.enableMacro(e._blendShapeTextureMacro),t.setTexture(e._blendShapeTextureProperty,this._vertexTexture),t.setVector3(e._blendShapeTextureInfoProperty,this._dataTextureInfo),t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),t.enableMacro("RENDERER_BLENDSHAPE_COUNT",r.toString()),this._uniformOccupiesCount=r+1;else{var a=this._getVertexBufferModeSupportCount();if(r>a){var i=n._condensedBlendShapeWeights;i||(i=new Float32Array(a),n._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(n.blendShapeWeights,i),t.setFloatArray(e._blendShapeWeightsProperty,i),this._modelMesh._primitive.enableVAO=!1,r=a}else t.setFloatArray(e._blendShapeWeightsProperty,n.blendShapeWeights),this._modelMesh._primitive.enableVAO=!0;t.disableMacro(e._blendShapeTextureMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=r}this._useBlendNormal?t.enableMacro(e._blendShapeNormalMacro):t.disableMacro(e._blendShapeNormalMacro),this._useBlendTangent?t.enableMacro(e._blendShapeTangentMacro):t.disableMacro(e._blendShapeTangentMacro)}else t.disableMacro(e._blendShapeMacro),t.disableMacro("RENDERER_BLENDSHAPE_COUNT")},t._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},t._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},t._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},t._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},t._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,n=e._primitive.vertexBufferBindings,r=0,a=Math.max(n.length,t+1);r<a&&(n[r]||r===t);r++);this._bufferBindingOffset=r}},t._addVertexElements=function(e){this._updateVertexBufferIndex();for(var t=this._vertexElementOffset,n=this._bufferBindingOffset,r=0,a=0,i=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());a<i;a++)e._setVertexElement(t++,new at("POSITION_BS"+a,r,r7.Vector3,n)),r+=12,this._useBlendNormal&&(e._setVertexElement(t++,new at("NORMAL_BS"+a,r,r7.Vector3,n)),r+=12),this._useBlendTangent&&(e._setVertexElement(t++,new at("TANGENT_BS"+a,r,r7.Vector3,n)),r+=12);return t},t._update=function(e){var t=this._modelMesh.vertexCount,n=this._useTextureMode(),r=this._isCreateHost(t);r&&(n?this._createTextureArray(t):this._createVertexBuffers(t,e),this._lastHostCreatedInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent,t)),this._needUpdateData()&&(n?this._updateTextureArray(t,r):this._updateVertexBuffers(t,r))},t._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},t._createVertexBuffers=function(e,t){var n=this._engine,r=this._modelMesh,a=this._blendShapeCount,i=this._vertexBuffers,o=3*this._vertexElementCount,s=4*o,l=Math.floor(255/s),c=Math.ceil(a/l),u=o*e*Math.min(l,a);i.length=c,this._vertices=new Float32Array(u),this._maxCountSingleVertexBuffer=l,this._storeInVertexBufferInfo.length=a;for(var d=this._bufferBindingOffset,h=0;h<c;h++){var _=c-1,f=(h===_?a-_*l:l)*s,p=f*e,m=t?r8.Static:r8.Dynamic,g=new r9(n,an.VertexBuffer,p,m);r._setVertexBufferBinding(d+h,new aS(g,f)),i[h]=g}},t._createTextureArray=function(e){var t=this._engine._hardwareRenderer.capability.maxTextureSize,n=this._vertexElementCount,r=n*e,a=1;r>t&&(a=Math.ceil(r/t),r=t);var i=this._vertexTexture,o=this._blendShapes.length;i&&i.destroy(),(i=new nu(this._engine,r,a,o,t9.R32G32B32A32,!1)).filterMode=t5.Point,this._vertices=new Float32Array(o*r*a*4),this._vertexTexture=i,this._dataTextureInfo.set(n,r,a)},t._updateVertexBuffers=function(e,t){for(var n=this._blendShapes,r=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=n.length;d<h;d++){var _=s[d];if(t||_.flag){var f=n[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/r),v=d%r,y=i[g],x=y.byteLength/(4*e),b=v*l,C=o[d];C||(o[d]=C=new tB),C.set(u+g,v*c);for(var S=m.deltaPositions,T=0;T<e;T++){var A=b+x*T,E=S[T];E&&(a[A]=E.x,a[A+1]=E.y,a[A+2]=E.z)}if(b+=3,this._useBlendNormal){var R=m.deltaNormals;if(R)for(var M=0;M<e;M++){var w=b+x*M,P=R[M];P&&(a[w]=P.x,a[w+1]=P.y,a[w+2]=P.z)}b+=3}if(this._useBlendTangent){var F=m.deltaTangents;if(F)for(var L=0;L<e;L++){var D=b+x*L,B=F[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}b+=3}(v===r-1||d===h-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},t._updateTextureArray=function(e,t){for(var n=this._blendShapes,r=this._vertexTexture,a=this._vertices,i=this._subDataDirtyFlags,o=0,s=n.length;o<s;o++){var l=i[o],c=r.width*r.height*4;if(t||l.flag){var u=n[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}}r.setPixelBuffer(0,a)},t._updateLayoutChange=function(e,t){var n=this._blendShapeCount>1,r=1,a=t._useBlendShapeNormal,i=t._useBlendShapeTangent;n&&(a&&(a=this._useBlendNormal),i&&(i=this._useBlendTangent)),a&&r++,i&&r++,this._useBlendNormal=a,this._useBlendTangent=i,this._vertexElementCount=r},t._attributeModeUpdateVertexElement=function(e,t,n,r){var a=this._vertexElementOffset+this._vertexElementCount*r,i=t[n],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}},t._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},t._filterCondensedBlendShapeWeights=function(e,t){for(var n,r=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<r)this._attributeModeUpdateVertexElement(a,i,s,s),t[s]=c,c<o&&(o=c,n=s);else if(c>o){this._attributeModeUpdateVertexElement(a,i,s,n),t[n]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<r;u++){var d=t[u];d<o&&(o=d,n=u)}}}},e}();aE._blendShapeMacro=nH.getByName("RENDERER_HAS_BLENDSHAPE"),aE._blendShapeTextureMacro=nH.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),aE._blendShapeNormalMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),aE._blendShapeTangentMacro=nH.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),aE._blendShapeWeightsProperty=nY.getByName("renderer_BlendShapeWeights"),aE._blendShapeTextureProperty=nY.getByName("renderer_BlendShapeTexture"),aE._blendShapeTextureInfoProperty=nY.getByName("renderer_BlendShapeTextureInfo");var aR=((em={}).Position="POSITION",em.Normal="NORMAL",em.Color="COLOR_0",em.Tangent="TANGENT",em.BoneWeight="WEIGHTS_0",em.BoneIndex="JOINTS_0",em.UV="TEXCOORD_0",em.UV1="TEXCOORD_1",em.UV2="TEXCOORD_2",em.UV3="TEXCOORD_3",em.UV4="TEXCOORD_4",em.UV5="TEXCOORD_5",em.UV6="TEXCOORD_6",em.UV7="TEXCOORD_7",em),aM=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||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 tT(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=n,r._blendShapeManager=new aE(t,r),r}tW(t,e);var n=t.prototype;return n.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)},n.getPositions=function(){var e=this._getVertexElementData(this._positions,aR.Position,0,this._readVector3VertexData);return this._positions=e,e},n.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},n.getNormals=function(){var e=this._getVertexElementData(this._normals,aR.Normal,1,this._readVector3VertexData);return this._normals=e,e},n.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},n.getColors=function(){var e=this._getVertexElementData(this._colors,aR.Color,2,this._readColorVertexData);return this._colors=e,e},n.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},n.getBoneWeights=function(){var e=this._getVertexElementData(this._boneWeights,aR.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=e,e},n.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},n.getBoneIndices=function(){var e=this._getVertexElementData(this._boneIndices,aR.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=e,e},n.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},n.getTangents=function(){var e=this._getVertexElementData(this._tangents,aR.Tangent,3,this._readVector4VertexData);return this._tangents=e,e},n.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]."}},n.getUVs=function(e){switch(e=null!=e?e:0){case 0:var t=this._getVertexElementData(this._uv,aR.UV,6,this._readVector2VertexData);return this._uv=t,t;case 1:var n=this._getVertexElementData(this._uv1,aR.UV1,7,this._readVector2VertexData);return this._uv1=n,n;case 2:var r=this._getVertexElementData(this._uv2,aR.UV2,8,this._readVector2VertexData);return this._uv2=r,r;case 3:var a=this._getVertexElementData(this._uv3,aR.UV3,9,this._readVector2VertexData);return this._uv3=a,a;case 4:var i=this._getVertexElementData(this._uv4,aR.UV4,10,this._readVector2VertexData);return this._uv4=i,i;case 5:var o=this._getVertexElementData(this._uv5,aR.UV5,11,this._readVector2VertexData);return this._uv5=o,o;case 6:var s=this._getVertexElementData(this._uv6,aR.UV6,12,this._readVector2VertexData);return this._uv6=s,s;case 7:var l=this._getVertexElementData(this._uv7,aR.UV7,13,this._readVector2VertexData);return this._uv7=l,l}throw"The index of channel needs to be in range [0 - 7]."},n.setIndices=function(e){this._indices!==e&&(this._indices=e,tK(e,Uint8Array)?this._indicesFormat=r6.UInt8:tK(e,Uint16Array)?this._indicesFormat=r6.UInt16:tK(e,Uint32Array)&&(this._indicesFormat=r6.UInt32)),this._indicesChangeFlag=!0},n.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},n.setVertexElements=function(e){this._clearVertexElements();for(var t,n=e.length,r=0;r<n;r++)this._addVertexElement(e[r]);var a=this._primitive._vertexElementMap;a[aR.Position]||this.setPositions(null),a[aR.Normal]||this.setNormals(null),a[aR.Color]||this.setColors(null),a[aR.BoneWeight]||this.setBoneWeights(null),a[aR.BoneIndex]||this.setBoneIndices(null),a[aR.Tangent]||this.setTangents(null),a[aR.UV]||this.setUVs(null,0),a[aR.UV1]||this.setUVs(null,1),a[aR.UV2]||this.setUVs(null,2),a[aR.UV3]||this.setUVs(null,3),a[aR.UV4]||this.setUVs(null,4),a[aR.UV5]||this.setUVs(null,5),a[aR.UV6]||this.setUVs(null,6),a[aR.UV7]||this.setUVs(null,7);var i=this._internalVertexBufferCreatedInfo.z;-1!==i&&(null==(t=this._primitive.vertexBufferBindings[i])||t.buffer.destroy(),this._setVertexBufferBinding(i,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},n.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,a=void 0!==r.buffer;a||(r=new aS(e,t));var i=a?t:n,o=this._primitive.vertexBufferBindings,s=this._vertexBufferInfos,l=i+1;o.length<l&&(o.length=l,s.length=l),this._setVertexBufferBinding(i,r),i===this._internalVertexBufferIndex&&(this._internalVertexBufferIndex=-1),i===this._blendShapeManager._bufferBindingOffset&&(this._blendShapeManager._bufferBindingOffset=-1),this._vertexCountDirty=!0},n.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=e.length,r=this._primitive.vertexBufferBindings,a=this._vertexBufferInfos,i=t+n;r.length<i&&(r.length=i,a.length=i);for(var o=0;o<n;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},n.getVertexElement=function(e){return this._updateVertexElements(),this._primitive._vertexElementMap[e]},n.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},n.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},n.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},n.uploadData=function(e){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(e),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var t=this._vertexBufferInfos,n=this._primitive.vertexBufferBindings,r=0,a=n.length;r<a;r++){var i=t[r];if(null==i?void 0:i.uploadAdvancedData){var o,s=null==(o=n[r])?void 0:o.buffer;s.setData(s.data),i.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var l,c=this._indices,u=null==(l=this._primitive.indexBufferBinding)?void 0:l._buffer;if(c){if(u&&c.byteLength==u.byteLength)u.setData(c),this._primitive.indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new ag(u,this._indicesFormat));else{null==u||u.destroy();var d=new r9(this._engine,an.IndexBuffer,c);this._setIndexBufferBinding(new ag(d,this._indicesFormat))}}else u&&(u.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var h=this._blendShapeManager;h._blendShapeCount>0&&h._update(e),e&&(this._accessible=!1,this._releaseCache(!1))},n.calculateTangents=function(){var e=this.getPositions(),n=this.getNormals(),r=this.getUVs();if(!n||!r)throw"Set normal and uv before calculation.";for(var a=this._indices,i=this.vertexCount,o=t._tempVec0,s=t._tempVec1,l=t._tempVec2,c=t._tempVec3,u=t._tempVec4,d=a?a.length/3:e.length/3,h=Array(i),_=Array(i),f=0;f<i;f++)h[f]=new tI,_[f]=new tT;for(var p=0;p<d;p++){var m=3*p,g=3*p+1,v=3*p+2;a&&(m=a[m],g=a[g],v=a[v]);var y=e[m],x=e[g],b=e[v],C=r[m],S=r[g],T=r[v];tT.subtract(x,y,o),tT.subtract(b,y,s);var A=S.x-C.x,E=T.x-C.x,R=S.y-C.y,M=T.y-C.y,w=1/(A*M-E*R);tT.scale(o,M*w,l),tT.scale(s,R*w,u),tT.subtract(l,u,l),tT.scale(s,A*w,c),tT.scale(o,E*w,u),tT.subtract(c,u,c);var P=h[m];P.set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[g]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),(P=h[v]).set(P.x+l.x,P.y+l.y,P.z+l.z,1),_[m].add(c),_[g].add(c),_[v].add(c)}for(var F=0;F<i;F++){var L=n[F],D=_[F],B=h[F];l.set(B.x,B.y,B.z),tT.cross(l,D,u);var I=tT.dot(u,L)>0?1:-1;tT.scale(L,tT.dot(l,L),u),tT.subtract(l,u,l),l.normalize(),B.set(l.x,l.y,l.z,I)}this.setTangents(h)},n._setVertexBufferBinding=function(t,n){var r=this,a=this._primitive.vertexBufferBindings,i=this._vertexBufferInfos,o=function(){r._advancedDataSyncToBuffer||(i[t].dataVersion=r._dataVersionCounter++)},s=a[t];s&&s.buffer._dataUpdateManager.removeListener(o),e.prototype._setVertexBufferBinding.call(this,t,n),n?(n.buffer._dataUpdateManager.addListener(o),(i[t]||(i[t]=new aw)).reset(),o()):t+1==a.length&&a.length--},n._getVertexTypedArray=function(e,t){switch(t){case nQ.BYTE:return new Int8Array(e);case nQ.UNSIGNED_BYTE:return new Uint8Array(e);case nQ.SHORT:return new Int16Array(e);case nQ.UNSIGNED_SHORT:return new Uint16Array(e);case nQ.FLOAT:return new Float32Array(e)}},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._releaseCache(!0)},n._getVertexElementData=function(e,t,n,r){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[n])?a:-1,s=this._primitive._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[n]=l,r.call(this,t))},n._beforeSetAdvancedVertexData=function(e,t,n){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";this._updateAdvancedVertexDataMarks(t,n)},n._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},n._updateInternalVertexBuffer=function(e){var t=this._internalVertexBufferStride,n=this.vertexCount,r=this._internalVertexBufferCreatedInfo,a=t*n;if(r.x*r.y!==a){var i,o=r.z;-1!==o&&(null==(i=this._primitive.vertexBufferBindings[o])||i.buffer.destroy(),this._setVertexBufferBinding(o,null));var s=this._internalVertexBufferIndex,l=t*this.vertexCount>0;if(l){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var c=e?r8.Static:r8.Dynamic,u=new r9(this._engine,an.VertexBuffer,a,c,!0);this._setVertexBufferBinding(s,new aS(u,t))}r.set(t,n,l?s:-1)}},n._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new tB(e[t],e[t+1])})},n._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new tT(e[t],e[t+1],e[t+2])})},n._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new tI(e[t],e[t+1],e[t+2],e[t+3])})},n._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new tO(e[t],e[t+1],e[t+2],e[t+3])})},n._readVertexData=function(e,t){var n=this._primitive,r=n._vertexElementMap[e];if(!r)return null;var a=n.vertexBufferBindings[r.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=r._formatMetaInfo,l=Array(o),c=this._getVertexTypedArray(i.data.buffer,s.type),u=r.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},n._updateAdvancedVertexElement=function(e,t,n){var r=this._primitive._vertexElementMap;if(e){if(!r[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new at(t,i,a,o)),this._internalVertexBufferStride+=this._getAttributeByteLength(t),this._internalVertexElementsFlags|=n,this._blendShapeManager._vertexElementOffset++}}else{var s=r[t];if(s){var l=this._primitive.vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~n):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},n._updateAdvancedVertexElements=function(){var e=this._advancedElementUpdateFlag;1&e&&this._updateAdvancedVertexElement(this._positions,aR.Position,1),2&e&&this._updateAdvancedVertexElement(this._normals,aR.Normal,2),4&e&&this._updateAdvancedVertexElement(this._colors,aR.Color,4),16&e&&this._updateAdvancedVertexElement(this._boneWeights,aR.BoneWeight,16),32&e&&this._updateAdvancedVertexElement(this._boneIndices,aR.BoneIndex,32),8&e&&this._updateAdvancedVertexElement(this._tangents,aR.Tangent,8),64&e&&this._updateAdvancedVertexElement(this._uv,aR.UV,64),128&e&&this._updateAdvancedVertexElement(this._uv1,aR.UV1,128),256&e&&this._updateAdvancedVertexElement(this._uv2,aR.UV2,256),512&e&&this._updateAdvancedVertexElement(this._uv3,aR.UV3,512),1024&e&&this._updateAdvancedVertexElement(this._uv4,aR.UV4,1024),2048&e&&this._updateAdvancedVertexElement(this._uv5,aR.UV5,2048),4096&e&&this._updateAdvancedVertexElement(this._uv6,aR.UV6,4096),8192&e&&this._updateAdvancedVertexElement(this._uv7,aR.UV7,8192)},n._updateVertexElements=function(){var e=this._primitive.vertexElements,t=this._blendShapeManager,n=e.length,r=t._vertexElementOffset;65535&this._advancedElementUpdateFlag&&(this._updateAdvancedVertexElements(),this._advancedElementUpdateFlag=0);var a=!t._useTextureMode()&&t._vertexElementsNeedUpdate();if(r!==t._vertexElementOffset||a&&t._blendShapeCount>0){var i=t._addVertexElements(this);i<n&&this._setVertexElementsLength(i)}},n._writeVector2AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y)})},n._writeVector3AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z)})},n._writeVector4AdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.x,e[t+1]=a.y,e[t+2]=a.z,e[t+3]=a.w)})},n._writeColorAdvancedVertexData=function(e,t,n){this._writeAdvancedVertexData(e,t,function(e,t,r){var a=n[r];a&&(e[t]=a.r,e[t+1]=a.g,e[t+2]=a.b,e[t+3]=a.a)})},n._writeAdvancedVertexData=function(e,t,n){var r,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!=(r=this._advancedVertexDataVersions[t])?r:-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(n(h,b,y),m)for(var C=0;C<g;C++)h[b+C]/=v}u.uploadAdvancedData=!0}}},n._updateAdvancedVertices=function(){var e=this._positions,t=this._normals,n=this._colors,r=this._advancedDataUpdateFlag,a=this._boneWeights,i=this._boneIndices,o=this._tangents,s=this._uv,l=this._uv1,c=this._uv2,u=this._uv3,d=this._uv4,h=this._uv5,_=this._uv6,f=this._uv7;1&r&&this._writeVector3AdvancedVertexData(aR.Position,0,e),t&&2&r&&this._writeVector3AdvancedVertexData(aR.Normal,1,t),n&&4&r&&this._writeColorAdvancedVertexData(aR.Color,2,n),a&&16&r&&this._writeVector4AdvancedVertexData(aR.BoneWeight,4,a),i&&32&r&&this._writeVector4AdvancedVertexData(aR.BoneIndex,5,i),o&&8&r&&this._writeVector4AdvancedVertexData(aR.Tangent,3,o),s&&64&r&&this._writeVector2AdvancedVertexData(aR.UV,6,s),l&&128&r&&this._writeVector2AdvancedVertexData(aR.UV1,7,l),c&&256&r&&this._writeVector2AdvancedVertexData(aR.UV2,8,c),u&&512&r&&this._writeVector2AdvancedVertexData(aR.UV3,9,u),d&&1024&r&&this._writeVector2AdvancedVertexData(aR.UV4,10,d),h&&2048&r&&this._writeVector2AdvancedVertexData(aR.UV5,11,h),_&&4096&r&&this._writeVector2AdvancedVertexData(aR.UV6,12,_),f&&8192&r&&this._writeVector2AdvancedVertexData(aR.UV7,13,f),this._advancedDataUpdateFlag=0},n._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,n=this._primitive.vertexBufferBindings,r=n.length;t<r&&n[t];t++);return this._internalVertexBufferIndex=t,t},n._getAttributeFormat=function(e){switch(e){case aR.Position:case aR.Normal:return r7.Vector3;case aR.Color:case aR.BoneWeight:case aR.Tangent:return r7.Vector4;case aR.BoneIndex:return r7.UByte4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return r7.Vector2}},n._getAttributeByteLength=function(e){switch(e){case aR.Position:case aR.Normal:return 12;case aR.Color:case aR.BoneWeight:case aR.Tangent:return 16;case aR.BoneIndex:return 4;case aR.UV:case aR.UV1:case aR.UV2:case aR.UV3:case aR.UV4:case aR.UV5:case aR.UV6:case aR.UV7:return 8}},n._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,n=this._dataVersionCounter++,r=this._vertexBufferInfos,a=0,i=r.length;a<i;a++){var o=r[a];o&&(o.dataVersion=n)}}},tG(t,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var e=0,t=this._primitive._vertexElementMap[aR.Position];if(t){var n=this._primitive.vertexBufferBindings[t.bindingIndex];n&&(e=n.buffer.byteLength/n.stride)}this._vertexCount=e,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}}]),t}(ab);aM._tempVec0=new tT,aM._tempVec1=new tT,aM._tempVec2=new tT,aM._tempVec3=new tT,aM._tempVec4=new tT;var aw=/*#__PURE__*/function(){function e(){this.dataVersion=-1,this.uploadAdvancedData=!1}return e.prototype.reset=function(){this.uploadAdvancedData=!1},e}(),aP=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).primitiveInfo=n,r}return tW(t,e),t.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:az._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 7:az._setSubdivisionSurfaceSphereData(this.resource,e.radius,e.step,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:az._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:az._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:az._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:az._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:az._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:az._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t}(t2),aF=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},aL=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,0,r,a)||this).radius=t,i.segments=n,i}return tW(t,e),t}(aF),aD=/*#__PURE__*/function(e){function t(t,n,r,a){var i;return(i=e.call(this,7,r,a)||this).radius=t,i.step=n,i}return tW(t,e),t}(aF),aB=/*#__PURE__*/function(e){function t(t,n,r,a,i){var o;return(o=e.call(this,1,a,i)||this).width=t,o.height=n,o.depth=r,o}return tW(t,e),t}(aF),aI=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,2,i,o)||this).width=t,s.height=n,s.horizontalSegments=r,s.verticalSegments=a,s}return tW(t,e),t}(aF),aO=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,3,o,s)||this).radiusTop=t,l.radiusBottom=n,l.height=r,l.radialSegments=a,l.heightSegments=i,l}return tW(t,e),t}(aF),aN=/*#__PURE__*/function(e){function t(t,n,r,a,i,o,s){var l;return(l=e.call(this,4,o,s)||this).radius=t,l.tubeRadius=n,l.radialSegments=r,l.tubularSegments=a,l.arc=i,l}return tW(t,e),t}(aF),aV=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,5,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),ak=/*#__PURE__*/function(e){function t(t,n,r,a,i,o){var s;return(s=e.call(this,6,i,o)||this).radius=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s}return tW(t,e),t}(aF),az=/*#__PURE__*/function(){function e(){}return e.createSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=18),void 0===a&&(a=!0);var i=new aM(t);e._setSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aL(n,r,o,a))),i},e.createSubdivisionSurfaceSphere=function(t,n,r,a){void 0===n&&(n=.5),void 0===r&&(r=3),void 0===a&&(a=!0);var i=new aM(t);e._setSubdivisionSurfaceSphereData(i,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(i,new aD(n,r,o,a))),i},e.createCuboid=function(t,n,r,a,i){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new aM(t);e._setCuboidData(o,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(o,new aB(n,r,a,s,i))),o},e.createPlane=function(t,n,r,a,i,o){void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setPlaneData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aI(n,r,a,i,l,o))),s},e.createCylinder=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1),void 0===s&&(s=!0);var l=new aM(t);e._setCylinderData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aO(n,r,a,i,o,c,s))),l},e.createTorus=function(t,n,r,a,i,o,s){void 0===n&&(n=.5),void 0===r&&(r=.1),void 0===a&&(a=30),void 0===i&&(i=30),void 0===o&&(o=360),void 0===s&&(s=!0);var l=new aM(t);e._setTorusData(l,n,r,a,i,o,s,!1);var c=l.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(l,new aN(n,r,a,i,o,c,s))),l},e.createCone=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=20),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setConeData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new aV(n,r,a,i,l,o))),s},e.createCapsule=function(t,n,r,a,i,o){void 0===n&&(n=.5),void 0===r&&(r=2),void 0===a&&(a=6),void 0===i&&(i=1),void 0===o&&(o=!0);var s=new aM(t);e._setCapsuleData(s,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return t.resourceManager.addContentRestorer(new aP(s,new ak(n,r,a,i,l,o))),s},e._setSubdivisionSurfaceSphereData=function(t,n,r,a,i,o){var s=new Float32Array(3*(6*Math.pow(4,r=tS.clamp(Math.floor(r),1,6))+2)),l=new Float32Array(24*Math.pow(4,r));e._subdiveCatmullClark(r,s,l);for(var c=s.length/3,u=l.length/4,d=c+Math.pow(2,r+1)-1,h=new Float32Array(8*(d+16)),_=e._generateIndices(t.engine,c,6*u),f=0,p={},m=0;m<c;m++){var g=3*m,v=s[g],y=s[g+1],x=s[g+2],b=1/Math.sqrt(v*v+y*y+x*x);if(v*=b,y*=b,x*=b,h[g=8*m]=v*n,h[g+1]=y*n,h[g+2]=x*n,h[g+3]=v,h[g+4]=y,h[g+5]=x,h[g+6]=(Math.PI-Math.atan2(x,v))/(2*Math.PI),h[g+7]=Math.acos(y)/Math.PI,0===h[g+6]){var C=8*(c+f++);h.set(h.subarray(g,g+8),C),h[C+6]=1,p[g/8]=C/8}}var S=0;this._spherePoleIdx=0;for(var T=0;T<u;T++){var A=4*T,E=l[A],R=l[A+1],M=l[A+2],w=l[A+3],P=8*E,F=8*R,L=8*M,D=8*w;h[P+2]+h[F+2]+h[L+2]<0&&(0===h[P+6]&&(E=p[E]),0===h[F+6]&&(R=p[R]),0===h[L+6]&&(M=p[M]),0===h[D+6]&&(w=p[w])),_[S]=E,_[S+1]=R,_[S+2]=M,this._generateAndReplacePoleUV(_,h,S,d),_[S+3]=E,_[S+4]=M,_[S+5]=w,this._generateAndReplacePoleUV(_,h,S+3,d),S+=6}if(!i){var B=t.bounds;B.min.set(-n,-n,-n),B.max.set(n,n,n)}e._initialize(t,h,_,a,i,o)},e._setSphereData=function(t,n,r,a,i,o){for(var s=(r=Math.max(2,Math.floor(r)))+1,l=s*s,c=r*r,u=e._generateIndices(t.engine,l,6*c),d=Math.PI,h=2*d,_=1/s,f=1/r,p=new Float32Array(8*l),m=0;m<l;++m){var g=m%s*f,v=(m*_|0)*f,y=g*h,x=v*d,b=Math.sin(x),C=-n*Math.cos(y)*b,S=n*Math.cos(x),T=n*Math.sin(y)*b,A=8*m;p[A++]=C,p[A++]=S,p[A++]=T,p[A++]=C,p[A++]=S,p[A++]=T,p[A++]=g,p[A++]=v}for(var E=0,R=0;R<c;++R){var M=R%r,w=(R*f|0)*s+M,P=w+1,F=w+s,L=F+1;u[E++]=P,u[E++]=w,u[E++]=L,u[E++]=w,u[E++]=F,u[E++]=L}if(!i){var D=t.bounds;D.min.set(-n,-n,-n),D.max.set(n,n,n)}e._initialize(t,p,u,a,i,o)},e._subdiveCatmullClark=function(t,n,r){var a=new Map,i=[];n.set(e._sphereSeedPositions),r.set(e._sphereSeedCells);for(var o=0;o<t;o++){var s=6*Math.pow(4,o),l=4*s+2;a.clear(),i.length=0;for(var c=0;c<s;c++){for(var u=i[c]={facePoint:new tT,adjacentEdges:[,,,,]},d=0;d<4;d++){var h=3*r[4*c+d];u.facePoint.x+=.25*n[h],u.facePoint.y+=.25*n[h+1],u.facePoint.z+=.25*n[h+2]}for(var _=0;_<4;_++){var f=r[4*c+_],p=r[4*c+(_+1)%4],m=Math.min(f,p)*l+Math.max(f,p);if(!a.has(m)){var g={edgePoint:new tT,edgePointIndex:void 0},v=3*f,y=3*p;g.edgePoint.set(.25*(n[v]+n[y]),.25*(n[v+1]+n[y+1]),.25*(n[v+2]+n[y+2])),a.set(m,g)}var x=a.get(m);u.adjacentEdges[_]=x;var b=x.edgePoint,C=u.facePoint;b.x+=.25*C.x,b.y+=.25*C.y,b.z+=.25*C.z}}var S=s+2,T=S+s,A=0;this._sphereEdgeIdx=0;for(var E=r.slice(0,4*s),R=0;R<s;R++){var M=i[R];M.facePoint.copyToArray(n,3*(S+R));for(var w=S+R,P=void 0,F=void 0,L=void 0,D=0;D<4;D++){var B=E[A++];switch(D){case 0:var I=M.adjacentEdges[D%4],O=M.adjacentEdges[(D+3)%4];F=this._calculateEdgeIndex(n,I,T),L=P=this._calculateEdgeIndex(n,O,T);break;case 1:case 2:var N=M.adjacentEdges[D%4];P=F,F=this._calculateEdgeIndex(n,N,T);break;case 3:P=F,F=L}var V=4*(4*R+D);r[V]=B,r[V+1]=F,r[V+2]=w,r[V+3]=P}}}},e._generateAndReplacePoleUV=function(e,t,n,r){var a=t[8*e[n]+7];if(0===a||1===a){var i=8*e[n],o=8*(r+this._spherePoleIdx);t.set(t.subarray(i,i+8),o),t[o+6]=.5*(t[i+6]+t[8*e[n+1]+6]+t[8*e[n+2]+6]-.5),e[n]=r+this._spherePoleIdx++}},e._calculateEdgeIndex=function(t,n,r){if(void 0!==n.edgePointIndex)return n.edgePointIndex;n.edgePoint.copyToArray(t,3*(r+e._sphereEdgeIdx));var a=r+e._sphereEdgeIdx++;return n.edgePointIndex=a,a},e._setCuboidData=function(t,n,r,a,i,o,s){var l=n/2,c=r/2,u=a/2,d=new Float32Array(192);d[0]=-l,d[1]=c,d[2]=-u,d[6]=0,d[7]=0,d[8]=l,d[9]=c,d[10]=-u,d[14]=1,d[15]=0,d[16]=l,d[17]=c,d[18]=u,d[22]=1,d[23]=1,d[24]=-l,d[25]=c,d[26]=u,d[30]=0,d[31]=1;for(var h=0;h<4;h++){var _=8*h+3;d[_++]=0,d[_++]=1,d[_++]=0}d[32]=-l,d[33]=-c,d[34]=-u,d[38]=0,d[39]=1,d[40]=l,d[41]=-c,d[42]=-u,d[46]=1,d[47]=1,d[48]=l,d[49]=-c,d[50]=u,d[54]=1,d[55]=0,d[56]=-l,d[57]=-c,d[58]=u,d[62]=0,d[63]=0;for(var f=0;f<4;f++){var p=8*f+35;d[p++]=0,d[p++]=-1,d[p++]=0}d[64]=-l,d[65]=c,d[66]=-u,d[70]=0,d[71]=0,d[72]=-l,d[73]=c,d[74]=u,d[78]=1,d[79]=0,d[80]=-l,d[81]=-c,d[82]=u,d[86]=1,d[87]=1,d[88]=-l,d[89]=-c,d[90]=-u,d[94]=0,d[95]=1;for(var m=0;m<4;m++){var g=8*m+67;d[g++]=-1,d[g++]=0,d[g++]=0}d[96]=l,d[97]=c,d[98]=-u,d[102]=1,d[103]=0,d[104]=l,d[105]=c,d[106]=u,d[110]=0,d[111]=0,d[112]=l,d[113]=-c,d[114]=u,d[118]=0,d[119]=1,d[120]=l,d[121]=-c,d[122]=-u,d[126]=1,d[127]=1;for(var v=0;v<4;v++){var y=8*v+99;d[y++]=1,d[y++]=0,d[y++]=0}d[128]=-l,d[129]=c,d[130]=u,d[134]=0,d[135]=0,d[136]=l,d[137]=c,d[138]=u,d[142]=1,d[143]=0,d[144]=l,d[145]=-c,d[146]=u,d[150]=1,d[151]=1,d[152]=-l,d[153]=-c,d[154]=u,d[158]=0,d[159]=1;for(var x=0;x<4;x++){var b=8*x+131;d[b++]=0,d[b++]=0,d[b++]=1}d[160]=-l,d[161]=c,d[162]=-u,d[166]=1,d[167]=0,d[168]=l,d[169]=c,d[170]=-u,d[174]=0,d[175]=0,d[176]=l,d[177]=-c,d[178]=-u,d[182]=0,d[183]=1,d[184]=-l,d[185]=-c,d[186]=-u,d[190]=1,d[191]=1;for(var C=0;C<4;C++){var S=8*C+163;d[S++]=0,d[S++]=0,d[S++]=-1}var T=new Uint16Array(36);if(T[0]=0,T[1]=2,T[2]=1,T[3]=2,T[4]=0,T[5]=3,T[6]=4,T[7]=6,T[8]=7,T[9]=6,T[10]=4,T[11]=5,T[12]=8,T[13]=10,T[14]=9,T[15]=10,T[16]=8,T[17]=11,T[18]=12,T[19]=14,T[20]=15,T[21]=14,T[22]=12,T[23]=13,T[24]=16,T[25]=18,T[26]=17,T[27]=18,T[28]=16,T[29]=19,T[30]=20,T[31]=22,T[32]=23,T[33]=22,T[34]=20,T[35]=21,!o){var A=t.bounds;A.min.set(-l,-c,-u),A.max.set(l,c,u)}e._initialize(t,d,T,i,o,s)},e._setPlaneData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(1,Math.floor(a)))+1,u=(i=Math.max(1,Math.floor(i)))+1,d=n/2,h=r/2,_=n/a,f=r/i,p=c*u,m=i*a,g=e._generateIndices(t.engine,p,6*m),v=1/c,y=1/a,x=1/i,b=new Float32Array(8*p),C=0;C<p;++C){var S=C%c,T=C*v|0,A=8*C;b[A++]=S*_-d,b[A++]=0,b[A++]=T*f-h,b[A++]=0,b[A++]=1,b[A++]=0,b[A++]=S*y,b[A++]=T*x}for(var E=0,R=0;R<m;++R){var M=R%a,w=(R*y|0)*c+M,P=w+1,F=w+c,L=F+1;g[E++]=w,g[E++]=F,g[E++]=P,g[E++]=F,g[E++]=L,g[E++]=P}if(!s){var D=t.bounds;D.min.set(-d,0,-h),D.max.set(d,0,h)}e._initialize(t,b,g,o,s,l)},e._setCylinderData=function(t,n,r,a,i,o,s,l,c){void 0===n&&(n=.5),void 0===r&&(r=.5),void 0===a&&(a=2),void 0===i&&(i=20),void 0===o&&(o=1);for(var u=(i=Math.floor(i))+1,d=(o=Math.floor(o))+1,h=.5*a,_=a/o,f=u*d,p=i*o,m=2*i,g=f+2+m,v=e._generateIndices(t.engine,g,6*p+3*m),y=1/u,x=1/i,b=1/o,C=new Float32Array(8*g),S=0,T=Math.PI,A=2*Math.PI,E=r-n,R=E/a,M=E/o,w=0;w<f;++w){var P=w%u,F=w*y|0,L=P*x,D=F*b,B=T+L*A,I=Math.sin(B),O=Math.cos(B),N=r-F*M,V=N*I,k=F*_-h,z=N*O,U=8*w;C[U++]=V,C[U++]=k,C[U++]=z,C[U++]=I,C[U++]=R,C[U++]=O,C[U++]=L,C[U++]=1-D}for(var G=0;G<p;++G){var H=G%i,W=(G*x|0)*u+H,j=W+1,X=W+u,K=X+1;v[S++]=j,v[S++]=X,v[S++]=W,v[S++]=j,v[S++]=K,v[S++]=X}var Y=8*f;C[Y++]=0,C[Y++]=-h,C[Y++]=0,C[Y++]=0,C[Y++]=-1,C[Y++]=0,C[Y++]=.5,C[Y++]=.5,C[Y++]=0,C[Y++]=h,C[Y++]=0,C[Y++]=0,C[Y++]=1,C[Y++]=0,C[Y++]=.5,C[Y++]=.5,Y=(f+2)*8;for(var q=1/(2*n),Q=1/(2*r),J=u*o,Z=0;Z<i;++Z){var $=8*Z,ee=C[$],et=C[$+2];C[Y++]=ee,C[Y++]=-h,C[Y++]=et,C[Y++]=0,C[Y++]=-1,C[Y++]=0,C[Y++]=ee*Q+.5,C[Y++]=.5-et*Q;var en=(Z+J)*8;ee=C[en],et=C[en+2],C[Y++]=ee,C[Y++]=h,C[Y++]=et,C[Y++]=0,C[Y++]=1,C[Y++]=0,C[Y++]=ee*q+.5,C[Y++]=.5-et*q}for(var er=f+1,ea=f+2,ei=ea+1,eo=0;eo<i;++eo){var es=2*eo,el=eo===i-1?0:es+2;v[S++]=f,v[S++]=ea+el,v[S++]=ea+es,v[S++]=er,v[S++]=ei+es,v[S++]=ei+el}if(!l){var ec=t.bounds,eu=Math.max(n,r);ec.min.set(-eu,-h,-eu),ec.max.set(eu,h,eu)}e._initialize(t,C,v,s,l,c)},e._setTorusData=function(t,n,r,a,i,o,s,l,c){var u=((a=Math.floor(a))+1)*((i=Math.floor(i))+1),d=a*i,h=e._generateIndices(t.engine,u,6*d),_=new Float32Array(8*u);o=o/180*Math.PI;for(var f=0,p=e._tempVec30,m=0;m<=a;m++)for(var g=0;g<=i;g++){var v=g/i*o,y=m/a*Math.PI*2,x=Math.cos(y),b=Math.cos(v),C=Math.sin(v),S=(n+r*x)*b,T=(n+r*x)*C,A=r*Math.sin(y);_[f++]=S,_[f++]=T,_[f++]=A;var E=n*b,R=n*C;p.set(S-E,T-R,A).normalize(),_[f++]=p.x,_[f++]=p.y,_[f++]=p.z,_[f++]=g/i,_[f++]=m/a}f=0;for(var M=1;M<=a;M++)for(var w=1;w<=i;w++){var P=(i+1)*M+w-1,F=(i+1)*(M-1)+w-1,L=(i+1)*(M-1)+w,D=(i+1)*M+w;h[f++]=P,h[f++]=F,h[f++]=D,h[f++]=F,h[f++]=L,h[f++]=D}if(!l){var B=t.bounds,I=n+r;B.min.set(-I,-I,-r),B.max.set(I,I,r)}e._initialize(t,_,h,s,l,c)},e._setConeData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.floor(a))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=_+1+a,m=e._generateIndices(t.engine,p,6*f+3*a),g=1/c,v=1/a,y=1/i,x=new Float32Array(8*p),b=0,C=Math.PI,S=2*Math.PI,T=n/r,A=0;A<_;++A){var E=A%c,R=A*g|0,M=E*v,w=R*y,P=C+M*S,F=Math.sin(P),L=Math.cos(P),D=n-w*n,B=D*F,I=R*h-d,O=D*L,N=8*A;x[N++]=B,x[N++]=I,x[N++]=O,x[N++]=F,x[N++]=T,x[N++]=L,x[N++]=M,x[N++]=1-w}for(var V=0;V<f;++V){var k=V%a,z=(V*v|0)*c+k,U=z+1,G=z+c,H=G+1;m[b++]=U,m[b++]=G,m[b++]=z,m[b++]=U,m[b++]=H,m[b++]=G}var W=8*_;x[W++]=0,x[W++]=-d,x[W++]=0,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=.5,x[W++]=.5,W=(_+1)*8;for(var j=1/(2*n),X=0;X<a;++X){var K=x[8*X],Y=x[8*X+2];x[W++]=K,x[W++]=-d,x[W++]=Y,x[W++]=0,x[W++]=-1,x[W++]=0,x[W++]=K*j+.5,x[W++]=.5-Y*j}for(var q=_+1,Q=0;Q<a;++Q){var J=Q,Z=Q===a-1?0:J+1;m[b++]=_,m[b++]=q+Z,m[b++]=q+J}if(!s){var $=t.bounds;$.min.set(-n,-d,-n),$.max.set(n,d,n)}e._initialize(t,x,m,o,s,l)},e._setCapsuleData=function(t,n,r,a,i,o,s,l){for(var c=(a=Math.max(2,Math.floor(a)))+1,u=(i=Math.floor(i))+1,d=.5*r,h=r/i,_=c*u,f=a*i,p=c*c,m=a*a,g=_+2*p,v=e._generateIndices(t.engine,g,(f+2*m)*6),y=1/c,x=1/a,b=1/i,C=Math.PI,S=2*Math.PI,T=new Float32Array(8*g),A=0,E=0;E<_;++E){var R=E%c,M=E*y|0,w=R*x,P=M*b,F=C+w*S,L=Math.sin(F),D=Math.cos(F),B=8*E;T[B++]=n*L,T[B++]=M*h-d,T[B++]=n*D,T[B++]=L,T[B++]=0,T[B++]=D,T[B++]=w,T[B++]=1-P}for(var I=0;I<f;++I){var O=I%a,N=(I*x|0)*c+O,V=N+1,k=N+c,z=k+1;v[A++]=V,v[A++]=k,v[A++]=N,v[A++]=V,v[A++]=z,v[A++]=k}if(e._createCapsuleCap(n,r,a,C,S,_,1,T,v,A),e._createCapsuleCap(n,r,a,C,-S,_+p,-1,T,v,A+6*m),!s){var U=t.bounds;U.min.set(-n,-n-d,-n),U.max.set(n,n+d,n)}e._initialize(t,T,v,o,s,l)},e._initialize=function(e,t,n,r,a,i){if(a)i.setData(t),e.setIndices(n),e.uploadData(r);else{var o=[new at(aR.Position,0,r7.Vector3,0),new at(aR.Normal,12,r7.Vector3,0),new at(aR.UV,24,r7.Vector2,0)];e.setVertexElements(o);var s=new r9(e.engine,an.VertexBuffer,t,r8.Static,!0);e.setVertexBufferBinding(s,32,0),e.setIndices(n),e.calculateTangents(),e.uploadData(r),e.addSubMesh(0,n.length)}},e._generateIndices=function(e,t,n){var r=null;if(t>65535){if(e._hardwareRenderer.canIUse(nJ.elementIndexUint))r=new Uint32Array(n);else throw Error("The vertex count is over limit.")}else r=new Uint16Array(n);return r},e._createCapsuleCap=function(e,t,n,r,a,i,o,s,l,c){for(var u=n+1,d=.5*t*o,h=u*u,_=n*n,f=1/u,p=1/n,m=0;m<h;++m){var g=m%u*p,v=(m*f|0)*p,y=r+g*a,x=v*Math.PI*.5,b=Math.sin(x),C=e*Math.sin(y)*b,S=e*Math.cos(x)*o+d,T=e*Math.cos(y)*b,A=(m+i)*8;s[A++]=C,s[A++]=S,s[A++]=T,s[A++]=C,s[A++]=S-d,s[A++]=T,s[A++]=g,s[A++]=v}for(var E=0;E<_;++E){var R=E%n,M=(E*p|0)*u+R+i,w=M+1,P=M+u,F=P+1;l[c++]=w,l[c++]=M,l[c++]=F,l[c++]=M,l[c++]=P,l[c++]=F}},e}();function aU(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(aU=function(){return!!e})()}function aG(e,t,n){return(aG=aU()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&tH(a,n.prototype),a}).apply(null,arguments)}az._tempVec30=new tT,az._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]),az._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]),az._sphereEdgeIdx=0,az._spherePoleIdx=0;var aH=/*#__PURE__*/function(){function e(){}return e.cloneComponent=function(e,t,n,r,a){var i=t$.getCloneMode(e.constructor);for(var o in e)t$.cloneProperty(e,t,o,i[o],n,r,a);e._cloneTo&&e._cloneTo(t,n,r)},e}(),aW=/*#__PURE__*/function(e){function t(t,n){for(var r,a=arguments.length,i=Array(a>2?a-2:0),o=2;o<a;o++)i[o-2]=arguments[o];(r=e.call(this,t)||this).layer=rE.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new rC,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._isTemplate=!1,r._updateFlagManager=new nM,r._parent=null,r._invModelMatrix=new tL,r.name=n;for(var s=0,l=i.length;s<l;s++)r.addComponent(i[s]);return r._transform||r.addComponent(rp),r._inverseWorldMatFlag=r.registerWorldChangeFlag(),r}tW(t,e);var n=t.prototype;return n.addComponent=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];rd._addCheck(this,e);var a=aG(e,[].concat([this],n));if(this._components.push(a),tK(a,rp)){var i=this._transform;this._transform=a,null==i||i.destroy()}return a._setActive(!0,rc.All),a},n.getComponent=function(e){for(var t=this._components,n=0,r=t.length;n<r;n++){var a=t[n];if(tK(a,e))return a}return null},n.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];tK(i,e)&&t.push(i)}return t},n.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},n.addChild=function(e,n){var r;if("number"==typeof e?r=e:(r=void 0,n=e),n._isRoot){n._scene._removeFromEntityList(n),n._isRoot=!1,this._addToChildrenList(r,n),n._parent=this;var a=n._scene,i=this._scene,o=rc.None;!this._isActiveInHierarchy&&n._isActiveInHierarchy&&(o|=rc.Hierarchy),n._isActiveInScene&&(this._isActiveInScene?a!==i&&(o|=rc.Scene):o|=rc.Scene),o&&n._processInActive(o),n._scene!==i&&t._traverseSetOwnerScene(n,i);var s=rc.None;n._isActive&&(this._isActiveInHierarchy&&(n._isActiveInHierarchy||(s|=rc.Hierarchy)),this._isActiveInScene&&(n._isActiveInScene&&a===i||(s|=rc.Scene))),s&&n._processActive(s),n._setTransformDirty()}else n._setParent(this,r)},n.removeChild=function(e){e._setParent(null)},n.getChild=function(e){return this._children[e]},n.findByName=function(e){if(e===this.name)return this;for(var t=this._children,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findByPath=function(e){for(var n=e.split("/"),r=this,a=0,i=n.length;a<i;++a){var o=n[a];if(o&&!(r=t._findChildByName(r,o)))return null}return r},n.createChild=function(e){var n=this._transform,r=n?new t(this.engine,e,n.constructor):new t(this.engine,e);return r.layer=this.layer,r.parent=this,r},n.clearChildren=function(){for(var e=this._children,n=e.length-1;n>=0;n--){var r=e[n];r._parent=null;var a=rc.None;r._isActiveInHierarchy&&(a|=rc.Hierarchy),r._isActiveInScene&&(a|=rc.Scene),a&&r._processInActive(a),t._traverseSetOwnerScene(r,null)}e.length=0},n.clone=function(){var e=this._createCloneEntity();return this._parseCloneEntity(this,e,this,e,new Map),e},n.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._markAsTemplate=function(e){this._isTemplate=!0,this._templateResource=e},n._createCloneEntity=function(){var e=this._transform,n=e?new t(this.engine,this.name,e.constructor):new t(this.engine,this.name),r=this._templateResource;r&&(n._templateResource=r,r._addReferCount(1)),n.layer=this.layer,n._isActive=this._isActive,n.transform._copyFrom(this.transform);for(var a=this._children,i=0,o=a.length;i<o;i++)n.addChild(a[i]._createCloneEntity());return n},n._parseCloneEntity=function(e,t,n,r,a){for(var i=e._children,o=t._children,s=0,l=i.length;s<l;s++)this._parseCloneEntity(i[s],o[s],n,r,a);for(var c=e._components,u=0,d=c.length;u<d;u++){var h=c[u];if(!tK(h,rp)){var _=t.addComponent(h.constructor);aH.cloneComponent(h,_,n,r,a)}}},n.destroy=function(){if(!this._destroyed){e.prototype.destroy.call(this),this._templateResource&&(this._isTemplate||this._templateResource._addReferCount(-1),this._templateResource=null);for(var t=this._components,n=t.length-1;n>=0;n--)t[n].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}},n._removeComponent=function(e){rd._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},n._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},n._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},n._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,n=this._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},n._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)},n._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)},n._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},n._addToChildrenList=function(e,t){var n=this._children,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._setParent=function(e,n){var r=this._parent;if(e!==r){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(n,this);var a=this._scene,i=e._scene,o=rc.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(o|=rc.Hierarchy),e._isActiveInScene?this._isActiveInScene&&a!==i&&(o|=rc.Scene):this._isActiveInScene&&(o|=rc.Scene),o&&this._processInActive(o),a!==i&&t._traverseSetOwnerScene(this,i);var s=rc.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(s|=rc.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&a===i||(s|=rc.Scene))),s&&this._processActive(s)}else{var l=rc.None;this._isActiveInHierarchy&&(l|=rc.Hierarchy),this._isActiveInScene&&(l|=rc.Scene),l&&this._processInActive(l),r&&t._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},n._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];tK(r,e)&&t.push(r)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},n._setActiveComponents=function(e,t){for(var n=this._activeChangedComponents,r=0,a=n.length;r<a;++r)n[r]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(n),this._activeChangedComponents=null},n._setActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!0),t&rc.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];(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)}},n._setInActiveInHierarchy=function(e,t){t&rc.Hierarchy&&(this._isActiveInHierarchy=!1),t&rc.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];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)}},n._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 n=this._siblingIndex;if(t<n)for(var r=n;r>=t;r--){var a=r==t?this:e[r-1];e[r]=a,a._siblingIndex=r}else for(var i=n;i<=t;i++){var o=i==t?this:e[i+1];e[i]=o,o._siblingIndex=i}}},n.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(tL.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},t._findChildByName=function(e,t){for(var n=e._children,r=n.length-1;r>=0;r--){var a=n[r];if(a.name===t)return a}return null},t._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=n.length-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},t._getEntityHierarchyPath=function(e,t,n){for(n.length=0;t!==e;){var r=t.parent;if(!r)return!1;n.push(t.siblingIndex),t=r}return!0},t._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},tG(t,[{key:"transform",get:function(){return this._transform}},{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,n=rc.None;this._isRoot&&this._scene._isActiveInEngine?n|=rc.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=rc.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=rc.Scene)),n&&this._processActive(n)}else{var r=rc.None;this._isActiveInHierarchy&&(r|=rc.Hierarchy),this._isActiveInScene&&(r|=rc.Scene),r&&this._processInActive(r)}}}},{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)}}]),t}(t0),aj=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n.inverseBindMatrices=[],n._updatedManager=new nM,n._bones=[],n._updateMark=-1,n.joints=[],n}tW(t,e);var n=t.prototype;return n._updateSkinMatrices=function(e){if(this._updateMark!==e.engine.time.frameCount){for(var t,n=this.bones,r=this.inverseBindMatrices,a=this._skinMatrices,i=(null!=(t=this.rootBone)?t:e.entity).getInvModelMatrix(),o=n.length-1;o>=0;o--){var s=n[o],l=16*o;s?nT._floatMatrixMultiply(s.transform.worldMatrix,r[o].elements,0,a,l):a.set(r[o].elements,l),nT._floatMatrixMultiply(i,a,l,a,l)}this._updateMark=e.engine.time.frameCount}},n._cloneTo=function(e,t,n){var r=[],a=this.rootBone;if(a){var i=aW._getEntityHierarchyPath(t,a,r);e.rootBone=i?aW._getEntityByHierarchyPath(n,r):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=aW._getEntityHierarchyPath(t,u,r);l[c]=d?aW._getEntityByHierarchyPath(n,r):u}e.bones=l}},tG(t,[{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,n=this._bones,r=null!=(t=null==e?void 0:e.length)?t:0,a=n.length;n.length=r;for(var i=0;i<r;i++)n[i]=e[i];a!==r&&(this._skinMatrices=new Float32Array(16*r),this._updatedManager.dispatch(0,r))}},{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)}}]),t}(t0);tX([tZ],aj.prototype,"inverseBindMatrices",void 0),tX([tq],aj.prototype,"_skinMatrices",void 0),tX([tq],aj.prototype,"_updatedManager",void 0),tX([tq],aj.prototype,"_rootBone",void 0),tX([tq],aj.prototype,"_bones",void 0),tX([tq],aj.prototype,"_updateMark",void 0);var aX=((eg={})[eg.BoneCountChanged=0]="BoneCountChanged",eg[eg.RootBoneChanged=1]="RootBoneChanged",eg),aK=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._localBounds=new tE,n._jointDataCreateCache=new tB(-1,-1),n._skin=null;var n,r=n.entity.engine._hardwareRenderer,a=r.renderStates.getParameter(r.gl.MAX_VERTEX_UNIFORM_VECTORS);a=Math.min(a,r._options._maxAllowSkinUniformVectorCount),n._maxVertexUniformVectors=a,n._onLocalBoundsChanged=n._onLocalBoundsChanged.bind(n),n._onSkinUpdated=n._onSkinUpdated.bind(n);var i=n._localBounds;return i.min._onValueChanged=n._onLocalBoundsChanged,i.max._onValueChanged=n._onLocalBoundsChanged,n}tW(t,e);var n=t.prototype;return n._onDestroy=function(){var t;e.prototype._onDestroy.call(this),this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,null==(t=this._jointTexture)||t.destroy(),this._jointTexture=null},n._cloneTo=function(t,n,r){e.prototype._cloneTo.call(this,t,n,r),this.skin&&t._applySkin(null,t.skin),this._blendShapeWeights&&(t._blendShapeWeights=this._blendShapeWeights.slice())},n._update=function(n){var r=this.skin;(null==r?void 0:r.bones.length)>0&&r._updateSkinMatrices(this);var a=this.shaderData,i=this.mesh._blendShapeManager;i._updateShaderData(a,this);var o=null==r?void 0:r.bones;if(o){var s=i._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var d,h=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>h){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new nc(f,4,l,t9.R32G32B32A32,!1),this._jointTexture.filterMode=t5.Point,this._jointTexture.isGCIgnored=!0),a.disableMacro("RENDERER_JOINTS_NUM"),a.enableMacro("RENDERER_USE_JOINT_TEXTURE"),a.setTexture(t._jointSamplerProperty,this._jointTexture)):no.error("component's joints count("+l+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+h+".",this)}else null==(d=this._jointTexture)||d.destroy(),a.disableMacro("RENDERER_USE_JOINT_TEXTURE"),a.enableMacro("RENDERER_JOINTS_NUM",h.toString()),a.setFloatArray(t._jointMatrixProperty,r._skinMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(r._skinMatrices)}e.prototype._update.call(this,n)},n._updateBounds=function(t){var n;(null==(n=this.skin)?void 0:n.rootBone)?tE.transform(this._localBounds,this._transformEntity.transform.worldMatrix,t):e.prototype._updateBounds.call(this,t)},n._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,n=this._blendShapeWeights;if(n){var r=n.length;if(r!==t){var a=new Float32Array(t);if(t>r)a.set(n);else for(var i=0;i<t;i++)a[i]=n[i];this._blendShapeWeights=a}}else this._blendShapeWeights=new Float32Array(t)},n._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onSkinUpdated=function(e,n){switch(e){case aX.BoneCountChanged:var r=this.shaderData;n>0?(r.enableMacro("RENDERER_HAS_SKIN"),r.setInt(t._jointCountProperty,n)):r.disableMacro("RENDERER_HAS_SKIN");break;case aX.RootBoneChanged:this._setTransformEntity(n),this._dirtyUpdateFlag|=rv.WorldVolume}},n._applySkin=function(e,t){var n,r,a,i,o,s,l=null!=(a=null==e?void 0:null==(n=e.bones)?void 0:n.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==(r=t.bones)?void 0:r.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(aX.BoneCountChanged,u),c!==d&&this._onSkinUpdated(aX.RootBoneChanged,d)},tG(t,[{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 n=0,r=t.length;n<r;n++)t[n]=e[n]}},{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}}]),t}(aA);aK._jointCountProperty=nY.getByName("renderer_JointCount"),aK._jointSamplerProperty=nY.getByName("renderer_JointSampler"),aK._jointMatrixProperty=nY.getByName("renderer_JointMatrix"),tX([tq],aK.prototype,"_condensedBlendShapeWeights",void 0),tX([tZ],aK.prototype,"_localBounds",void 0),tX([tq],aK.prototype,"_jointDataCreateCache",void 0),tX([tq],aK.prototype,"_blendShapeWeights",void 0),tX([tq],aK.prototype,"_maxVertexUniformVectors",void 0),tX([tq],aK.prototype,"_jointTexture",void 0),tX([tZ],aK.prototype,"_skin",void 0),tX([tq],aK.prototype,"_onLocalBoundsChanged",null),tX([tq],aK.prototype,"_onSkinUpdated",null);var aY=/*#__PURE__*/function(){function e(e){var t=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]),r=new ao(e,ro.find("blit"));r._addReferCount(1),r.renderState.depthState.enabled=!1,r.renderState.depthState.writeEnabled=!1,this.blitMesh=this._createBlitMesh(e,t),this.flipYBlitMesh=this._createBlitMesh(e,n),this.blitMaterial=r;var a=new Uint8Array([255,255,255,255]);if(this.whiteTexture2D=this._create1x1Texture(e,0,t9.R8G8B8A8,a),this.whiteTextureCube=this._create1x1Texture(e,1,t9.R8G8B8A8,a),e._hardwareRenderer.isWebGL2){this.whiteTexture2DArray=this._create1x1Texture(e,2,t9.R8G8B8A8,a);var i=new Uint32Array([255,255,255,255]);this.uintWhiteTexture2D=this._create1x1Texture(e,0,t9.R32G32B32A32_UInt,i)}this.spriteDefaultMaterial=this._create2DMaterial(e,ro.find("Sprite")),this.textDefaultMaterial=this._create2DMaterial(e,ro.find("Text")),this.spriteMaskDefaultMaterial=this._createSpriteMaskMaterial(e)}var t=e.prototype;return t._createBlitMesh=function(e,t){var n=new aM(e);n._addReferCount(1),n.setVertexElements([new at("POSITION_UV",0,r7.Vector4,0)]);var r=new r9(e,an.VertexBuffer,t,r8.Static,!0);return n.setVertexBufferBinding(r,16),n.addSubMesh(0,3,ar.Triangles),e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){r.setData(r.data)},t}(t2))),n},t._create1x1Texture=function(e,t,n,r){var a;switch(t){case 0:var i=new nc(e,1,1,n,!1);i.setPixelBuffer(r),a=i;break;case 2:var o=new nu(e,1,1,1,n,!1);o.setPixelBuffer(0,r),a=o;break;case 1:for(var s=new nd(e,1,n,!1),l=0;l<6;l++)s.setPixelBuffer(t4.PositiveX+l,r);a=s;break;default:throw"Invalid texture type"}return a.isGCIgnored=!0,e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,a)||this}return tW(n,e),n.prototype.restoreContent=function(){switch(t){case 0:this.resource.setPixelBuffer(r);break;case 2:this.resource.setPixelBuffer(0,r);break;case 1:for(var e=0;e<6;e++)this.resource.setPixelBuffer(t4.PositiveX+e,r)}},n}(t2))),a},t._create2DMaterial=function(e,t){var n=new ao(e,t),r=n.renderState,a=r.blendState.targetBlendState;return a.enabled=!0,a.sourceColorBlendFactor=nF.SourceAlpha,a.destinationColorBlendFactor=nF.OneMinusSourceAlpha,a.sourceAlphaBlendFactor=nF.One,a.destinationAlphaBlendFactor=nF.OneMinusSourceAlpha,a.colorBlendOperation=a.alphaBlendOperation=nL.Add,r.depthState.writeEnabled=!1,r.rasterState.cullMode=nI.Off,r.renderQueueType=nN.Transparent,n.isGCIgnored=!0,n},t._createSpriteMaskMaterial=function(e){var t=new ao(e,ro.find("SpriteMask"));return t.isGCIgnored=!0,t},e.getMaskInteractionRenderStates=function(t){var n,r;if(t===nv.VisibleInsideMask){if(n=e._maskReadInsideRenderStates)return n;e._maskReadInsideRenderStates=n={},r=nB.LessEqual}else{if(n=e._maskReadOutsideRenderStates)return n;e._maskReadOutsideRenderStates=n={},r=nB.Greater}return n[nO.StencilStateEnabled]=!0,n[nO.StencilStateWriteMask]=0,n[nO.StencilStateReferenceValue]=1,n[nO.StencilStateCompareFunctionFront]=r,n[nO.StencilStateCompareFunctionBack]=r,n},e.getMaskTypeRenderStates=function(t){if(t===rU.Increment){if(n=e._maskWriteIncrementRenderStates)return n;e._maskWriteIncrementRenderStates=n={},r=nk.IncrementSaturate}else{if(n=e._maskWriteDecrementRenderStates)return n;e._maskWriteDecrementRenderStates=n={},r=nk.DecrementSaturate}n[nO.StencilStateEnabled]=!0,n[nO.StencilStatePassOperationFront]=r,n[nO.StencilStatePassOperationBack]=r,n[nO.StencilStateCompareFunctionFront]=nB.Always,n[nO.StencilStateCompareFunctionBack]=nB.Always;var n,r,a=nk.Keep;return n[nO.StencilStateFailOperationFront]=a,n[nO.StencilStateFailOperationBack]=a,n[nO.StencilStateZFailOperationFront]=a,n[nO.StencilStateZFailOperationBack]=a,n[nO.BlendStateColorWriteMask0]=nD.None,n[nO.DepthStateEnabled]=!1,n[nO.RasterStateCullMode]=nI.Off,n},e}();aY._maskReadInsideRenderStates=null,aY._maskReadOutsideRenderStates=null,aY._maskWriteIncrementRenderStates=null,aY._maskWriteDecrementRenderStates=null;var aq=/*#__PURE__*/function(){function e(e){this._type=e}return 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},e}(),aQ=/*#__PURE__*/function(e){function t(t,n){void 0===n&&(n=1),(r=e.call(this,t)||this)._lastElementIndex=n-1;for(var r,a=r._elements=Array(n),i=0;i<n;++i)a[i]=new t;return r}tW(t,e);var n=t.prototype;return n.get=function(){return this._lastElementIndex<0?new this._type:this._elements[this._lastElementIndex--]},n.return=function(e){this._elements[++this._lastElementIndex]=e},t}(aq),aJ=/*#__PURE__*/function(){function e(){}return e.prototype.dispose=function(){this.chunk=null,this.vertexArea=null,this.subMesh=null,this.indices=null},e}(),aZ=/*#__PURE__*/function(){function e(e,t){this.start=e,this.size=t}return e.prototype.dispose=function(){},e}(),a$=/*#__PURE__*/function(){function e(e,t){this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER,this.updateIndexLength=0;var n=new ax(e);n.addVertexElement(new at("POSITION",0,r7.Vector3,0)),n.addVertexElement(new at("TEXCOORD_0",12,r7.Vector2,0)),n.addVertexElement(new at("COLOR_0",20,r7.Vector4,0)),n._addReferCount(1);var r=new r9(e,an.VertexBuffer,36*t,r8.Dynamic,!0);n.setVertexBufferBinding(0,new aS(r,36));var a=new r9(e,an.IndexBuffer,8*t,r8.Dynamic,!0);n.setIndexBufferBinding(new ag(a,r6.UInt16)),this.primitive=n,this.vertices=new Float32Array(r.data.buffer),this.indices=new Uint16Array(a.data.buffer),this.vertexFreeAreas=[new aZ(0,9*t)]}var t=e.prototype;return t.allocateSubChunk=function(t){var n=this._allocateArea(9*t);if(n){var r=e.subChunkPool.get();r.chunk=this,r.vertexArea=n;var a=e.subMeshPool.get();return a.topology=ar.Triangles,r.subMesh=a,r}return null},t.freeSubChunk=function(t){this._freeArea(t.vertexArea),e.subMeshPool.return(t.subMesh),e.subChunkPool.return(t)},t.uploadBuffer=function(){var e=this.primitive,t=this.updateVertexStart,n=this.updateVertexEnd;t!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER&&(e.vertexBufferBindings[0].buffer.setData(this.vertices,4*t,t,n-t,r5.Discard),this.updateVertexStart=Number.MAX_SAFE_INTEGER,this.updateVertexEnd=Number.MIN_SAFE_INTEGER),e.indexBufferBinding.buffer.setData(this.indices,0,0,this.updateIndexLength,r5.Discard),this.updateIndexLength=0},t.destroy=function(){this.primitive._addReferCount(-1),this.primitive.destroy(),this.primitive=null,this.vertices=null,this.indices=null},t._allocateArea=function(t){for(var n=this.vertexFreeAreas,r=e.areaPool,a=0,i=n.length;a<i;++a){var o=n[a],s=o.size;if(s>t){var l=r.get();return l.start=o.start,l.size=t,o.start+=t,o.size-=t,l}if(s===t)return n.splice(a,1),o}return null},t._freeArea=function(t){for(var n=t.start,r=t.size,a=this.vertexFreeAreas,i=n+r,o=e.areaPool,s=0,l=a.length;s<l;++s){var c=a[s],u=c.start,d=u+c.size;if(i<u){a.splice(s,0,t);return}if(i===u){c.start=n,c.size+=r,o.return(t);return}if(n===d){c.size+=r,o.return(t);var h=s+1;if(h<l){var _=a[h];i===_.start&&(c.size+=_.size,a.splice(h,1),o.return(_))}return}}a.push(t)},e}();a$.areaPool=new aQ(aZ,10),a$.subChunkPool=new aQ(aJ,10),a$.subMeshPool=new aQ(ay,10);var a0=/*#__PURE__*/function(){function e(e,t){void 0===t&&(t=4096),this.engine=e,this.maxVertexCount=t,this.primitiveChunks=[]}var t=e.prototype;return t.allocateSubChunk=function(e){for(var t=this.primitiveChunks,n=t.length,r=null,a=0;a<n;++a)if(r=t[a].allocateSubChunk(e))return r;return(t[n]||(t[n]=new a$(this.engine,this.maxVertexCount))).allocateSubChunk(e)},t.freeSubChunk=function(e){e.chunk.freeSubChunk(e)},t.uploadBuffer=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].uploadBuffer()},t.destroy=function(){for(var e=this.primitiveChunks,t=0,n=e.length;t<n;++t)e[t].destroy();e.length=0,this.primitiveChunks=null,this.engine=null},e}(),a1=/*#__PURE__*/function(){function e(e){this.primitiveChunkManager2D=new a0(e),this.primitiveChunkManagerMask=new a0(e,128)}var t=e.prototype;return t.destroy=function(){this.primitiveChunkManager2D.destroy(),this.primitiveChunkManagerMask.destroy(),this.primitiveChunkManager2D=null,this.primitiveChunkManagerMask=null},t.batch=function(e){for(var t,n,r,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?r===f&&n._canBatch(t,h)?(n._batch(t,h),t.batched=!0):(i.push(t),t=h,n=_,r=f,_._batch(h),h.batched=!1):(t=h,n=_,r=f,_._batch(h),h.batched=!1)}}t&&i.push(t)},t.uploadBuffer=function(){this.primitiveChunkManager2D.uploadBuffer(),this.primitiveChunkManagerMask.uploadBuffer()},e}(),a2=((ev={}).Text="Text",ev.JSON="JSON",ev.Buffer="Buffer",ev.Texture2D="Texture2D",ev.TextureCube="TextureCube",ev.Material="Material",ev.Shader="Shader",ev.Mesh="Mesh",ev.AnimationClip="AnimationClip",ev.AnimatorController="AnimatorController",ev.Prefab="Prefab",ev.GLTF="GLTF",ev.KTX="KTX",ev.KTXCube="KTXCube",ev.KTX2="KTX2",ev.Sprite="Sprite",ev.PrimitiveMesh="PrimitiveMesh",ev.SpriteAtlas="SpriteAtlas",ev.Env="Environment",ev.Scene="Scene",ev.HDR="HDR",ev.Font="Font",ev.SourceFont="SourceFont",ev.Audio="Audio",ev.Project="project",ev),a3=/*#__PURE__*/function(){function e(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}var t=e.prototype;return t.push=function(e){this._array.push(e),this._loopArrayDirty=!0},t.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},t.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},t.findAndRemove=function(e){for(var t=this._array,n=t.length-1;n>=0;n--)e(t[n])&&this.removeByIndex(n)},t.indexOf=function(e){return this._array.indexOf(e)},t.getArray=function(){return this._array},t.getLoopArray=function(){var e=this._loopArray;if(this._loopArrayDirty){var t=this._array,n=t.length;e.length=n;for(var r=0;r<n;r++)e[r]=t[r];this._loopArrayDirty=!1}return e},tG(e,[{key:"length",get:function(){return this._array.length}}]),e}(),a4=/*#__PURE__*/function(){function e(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new a3}var t=e.prototype;return t.addScene=function(e,t){var n,r=this._scenes;if("number"==typeof e){if(e<0||e>r.length)throw"The index is out of range.";n=e}else n=r.length,t=e;if(t.engine!==this.engine)throw"The scene is not belong to this engine.";if(t._sceneManager){var a=r.indexOf(t);a!==n&&(r.removeByIndex(a),r.add(n,t))}else t._sceneManager=this,r.add(n,t),t.isActive&&t._processActive(!0)},t.removeScene=function(e){var t=this._scenes,n=t.indexOf(e);if(-1!==n){var r=t.getArray()[n];t.removeByIndex(n),e._sceneManager=null,r.isActive&&r._processActive(!1)}},t.loadScene=function(e,t){var n=this;void 0===t&&(t=!0);var r=this.engine.resourceManager.load({url:e,type:a2.Scene});return r.then(function(e){if(t)for(var r=n._scenes.getArray(),a=0,i=r.length;a<i;a++)r[a].destroy();n.addScene(e)}),r},t.mergeScenes=function(e,t){for(var n=e.rootEntities;n.length>0;)t.addRootEntity(n[0])},t._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},tG(e,[{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)}}]),e}(),a8=/*#__PURE__*/function(){function e(e){var t=this;this._state="pending",this._onTaskCompleteCallbacks=[],this._onTaskDetailCallbacks=[],this._promise=new Promise(function(n,r){t._reject=r,e(function(e){"pending"===t._state&&(n(e),t._state="fulfilled",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e){"pending"===t._state&&(r(e),t._state="rejected",t._onTaskCompleteCallbacks=void 0,t._onTaskDetailCallbacks=void 0)},function(e,n){if("pending"===t._state){var r=t._taskCompleteProgress||(t._taskCompleteProgress={loaded:e,total:n});r.loaded=e,r.total=n,t._onTaskCompleteCallbacks.forEach(function(t){return t(e,n)})}},function(e,n,r){if("pending"===t._state){t._taskDetailProgress||(t._taskDetailProgress={});var a,i=(a=t._taskDetailProgress)[e]||(a[e]={loaded:n,total:r});i.loaded=n,i.total=r,t._onTaskDetailCallbacks.forEach(function(t){return t(e,n,r)})}},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}var t=e.prototype;return t.onProgress=function(e,t){var n=this._taskCompleteProgress,r=this._taskDetailProgress;if(n&&e(n.loaded,n.total),r)for(var a in r){var i=r[a];t(a,i.loaded,i.total)}return"pending"===this._state&&(e&&this._onTaskCompleteCallbacks.push(e),t&&this._onTaskDetailCallbacks.push(t)),this},t.then=function(t,n){var r=this;return new e(function(e,a){r._promise.then(t,n).then(e).catch(a)})},t.catch=function(t){var n=this;return new e(function(e,r){n._promise.catch(t).then(e).catch(r)})},t.finally=function(e){return this._promise.finally(e)},t.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},e.all=function(t){return new e(function(n,r,a){var i=function(e,t){c++,l[e]=t,a(c,s),c===s&&n(l)},o=function(t,n){tK(t,Promise)||tK(t,e)?t.then(function(e){i(n,e)},r):Promise.resolve().then(function(){i(n,t)})},s=t.length,l=Array(s),c=0;if(0===s)return n(l);for(var u=0;u<s;u++)o(t[u],u)})},tG(e,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),e}(),a5={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},a9=1/0;function a6(e,t){return void 0===t&&(t={}),new a8(function(n,r,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:a9,t.type=null!=(c=t.type)?c:a5[e.substring(e.lastIndexOf(".")+1)],new a7(function(){var n;return(n=t,new a8(function(t,r,a,i){var o,s=new XMLHttpRequest,l="image"===n.type;s.timeout=n.timeout,n.method=null!=(o=n.method)?o:"get",s.onload=function(){if(s.status<200||s.status>=300){r(Error("request failed from: "+e));return}var n,i=null!=(n=s.response)?n: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(){r(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(){r(Error("request failed from: "+e))},s.ontimeout=function(){r(Error("request timeout from: "+e))},s.onprogress=function(t){t.lengthComputable&&i(e,t.loaded,t.total)},s.open(n.method,e,!0),s.withCredentials="include"===n.credentials,s.responseType=l?"blob":n.type;var c=n.headers;c&&Object.keys(c).forEach(function(e){s.setRequestHeader(e,c[e])}),s.send(n.body)})).onProgress(a,i)},u,d).start().onError(r).onComplete(n)})}var a7=/*#__PURE__*/function(){function e(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}var t=e.prototype;return t.start=function(){return this.exec(),this},t.onComplete=function(e){return this._onComplete=e,this},t.onError=function(e){return this._onError=e,this},t.cancel=function(){window.clearTimeout(this._timeoutId)},t.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)})},e}(),ie=/*#__PURE__*/function(){function e(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)}var t=e.prototype;return t.load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var n=e.map(function(e){return t._loadSingleItem(e)});return a8.all(n)},t.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},t.findResourcesByType=function(e){var t=[],n=this._referResourcePool;for(var r in n){var a=n[r];tK(a,e)&&t.push(a)}return t},t.getAssetPath=function(e){return this._assetPool[e]},t.cancelNotLoaded=function(e){var t,n=this;e?"string"==typeof e?null==(t=this._loadingPromises[e])||t.cancel():e.forEach(function(e){var t;null==(t=n._loadingPromises[e])||t.cancel()}):nT.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},t.gc=function(){this._gc(!1),this.engine._pendingGC()},t.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},t._getRemoteUrl=function(e){var t;return null!=(t=this._virtualPathMap[e])?t:e},t._requestByRemoteUrl=function(e,t){return a6(e,t)},t._request=function(e,t){var n=this._getRemoteUrl(e);return this._requestByRemoteUrl(n,t)},t._onSubAssetSuccess=function(e,t,n){var r,a,i,o=null!=(a=this._virtualPathMap[e])?a:e,s=null==(r=this._subAssetPromiseCallbacks[o])?void 0:r[t];s?s.resolve(n):((i=this._subAssetPromiseCallbacks)[o]||(i[o]={}))[t]={resolvedValue:n}},t._onSubAssetFail=function(e,t,n){var r,a,i=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[t];i?i.reject(n):((a=this._subAssetPromiseCallbacks)[e]||(a[e]={}))[t]={rejectedValue:n}},t._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},t._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},t._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},t._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},t._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},t._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},t._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},t._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},t._lostGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._isContentLost=!0},t._restoreResourcesContent=function(){var e=this._contentRestorerPool,t=[];for(var n in e){var r=e[n].restoreContent();r&&t.push(r)}return Promise.all(t)},t._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},t._assignDefaultOptions=function(t){var n,r,a,i,o;if(t.type=null!=(n=t.type)?n:e._getTypeByUrl(t.url),void 0===t.type)throw"asset type should be specified: "+t.url;return t.retryCount=null!=(r=t.retryCount)?r:this.retryCount,t.timeout=null!=(a=t.timeout)?a:this.timeout,t.retryInterval=null!=(i=t.retryInterval)?i:this.retryInterval,t.url=null!=(o=t.url)?o:t.urls.join(","),t},t._loadSingleItem=function(t){var n,r,a=this,i=this._assignDefaultOptions("string"==typeof t?{url:t}:t),o=i.url;!nT.isAbsoluteUrl(o)&&this.baseUrl&&(o=nT.resolveAbsoluteUrl(this.baseUrl,o));var s=this._parseURL(o),l=s.assetBaseURL,c=s.queryPath,u=c?this._parseQueryPath(c):[],d=null!=(n=this._virtualPathMap[l])?n:l,h=this._assetUrlPool[d];if(h)return new a8(function(e){e(a._getResolveResource(h,u))});var _=d;if(c)for(_+="?q="+u.shift();r=u.shift();)_+="["+r+"]";var f=this._loadingPromises,p=f[_];if(p)return new a8(function(e,t,n,r){p.onProgress(n,r).then(function(t){e(t)}).catch(function(e){t(e)})});var m=e._loaders[i.type];if(!m)throw"loader not found: "+i.type;return c?((f[d]||this._loadMainAsset(m,i,d,l)).catch(function(e){a._onSubAssetFail(d,c,e)}),this._createSubAssetPromiseCallback(d,_,c)):this._loadMainAsset(m,i,d,l)},t._loadMainAsset=function(e,t,n,r){var a=this;t.url=r;var i=this._loadingPromises,o=e.load(t,this);return i[n]=o,o.then(function(t){e.useCache&&a._addAsset(n,t),delete i[n],a._releaseSubAssetPromiseCallback(n)},function(){delete i[n],a._releaseSubAssetPromiseCallback(n)}),o},t._createSubAssetPromiseCallback=function(e,t,n){var r,a=this,i=this._loadingPromises,o=null==(r=this._subAssetPromiseCallbacks[e])?void 0:r[n],s=null==o?void 0:o.resolvedValue,l=null==o?void 0:o.rejectedValue;if(s||l)return new a8(function(e,t){s?e(s):l&&t(l)});var c=new a8(function(t,r){var i;((i=a._subAssetPromiseCallbacks)[e]||(i[e]={}))[n]={resolve:t,reject:r}});return i[t]=c,c.then(function(){delete i[t]},function(){return delete i[t]}),c},t._gc=function(e){for(var t=nT.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++){var a=t[n];(!a.isGCIgnored||e)&&a.destroy(e,!0)}},t._getResolveResource=function(e,t){var n=e;if(t)for(var r=0,a=t.length;r<a;r++)n=n[t[r]];return n},t._parseURL=function(e){var t=e.split("?"),n=t[0],r=t[1],a=void 0,i=n;if(r){for(var o=r.split("&"),s=o.length-1;s>=0;s--){var l=o[s];if(l.startsWith("q=")){a=decodeURIComponent(l.split("=")[1]),o.splice(s,1);break}}i=o.length>0?n+"?"+o.join("&"):n}return{assetBaseURL:i,queryPath:a}},t._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===ir&&t.push(""),e.replace(ii,function(e,n,r,a){var i=e;r?i=a.replace(ia,"$1"):n&&(i=n.trim()),t.push(i)}),t},t._releaseSubAssetPromiseCallback=function(e){delete this._subAssetPromiseCallbacks[e]},t.getResourceByRef=function(e){var t,n=e.refId,r=e.key,a=e.isClone,i=this._objectPool[n];if(i)t=Promise.resolve(i);else{var o=this._editorResourceConfig[n];if(!o)return no.warn("refId:"+n+" is not find in this._editorResourceConfig."),Promise.resolve(null);var s=o.virtualPath;r&&(s+="?q="+r),t=this.load({url:s,type:o.type})}return t.then(function(e){return a?e.clone():e})},t.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},e._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,a=n.length;r<a;r++)this._extTypeMapping[n[r].toLowerCase()]=e},e._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1).toLowerCase()]},e}();function it(e,t,n){return void 0===n&&(n=!0),function(r){var a=new r(n);ie._addLoader(e,a,t)}}ie._loaders={},ie._extTypeMapping={};var ir=46,ia=/\\(\\)?/g,ii=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),io=((ey={})[ey.Down=0]="Down",ey[ey.Move=1]="Move",ey[ey.Stationary=2]="Stationary",ey[ey.Up=3]="Up",ey[ey.Leave=4]="Leave",ey),is=/*#__PURE__*/function(){function e(e){this.phase=io.Leave,this.position=new tB,this.deltaPosition=new tB,this._events=[],this._upMap=[],this._downMap=[],this._upList=new rC,this._downList=new rC,this.id=e}var t=e.prototype;return t._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)},t._firePointerDown=function(e){var t=this;e&&e._scripts.forEach(function(e){e.onPointerDown(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=e},t._firePointerDrag=function(){var e=this;this._currentPressedEntity&&this._currentPressedEntity._scripts.forEach(function(t){t.onPointerDrag(e)},function(e,t){e._entityScriptsIndex=t})},t._firePointerUpAndClick=function(e){var t=this,n=this._currentPressedEntity;if(n){var r=n===e;n._scripts.forEach(function(e){r&&e.onPointerClick(t),e.onPointerUp(t)},function(e,t){e._entityScriptsIndex=t}),this._currentPressedEntity=null}},e}(),il=((ex={})[ex.None=0]="None",ex[ex.Primary=1]="Primary",ex[ex.Secondary=2]="Secondary",ex[ex.Auxiliary=4]="Auxiliary",ex[ex.XButton1=8]="XButton1",ex[ex.XButton2=16]="XButton2",ex[ex.XButton3=32]="XButton3",ex[ex.XButton4=64]="XButton4",ex[ex.XButton5=128]="XButton5",ex[ex.XButton6=256]="XButton6",ex[ex.XButton7=512]="XButton7",ex[ex.XButton8=1024]="XButton8",ex),ic=[1,4,2,8,16,32,64,128,256,512,1024],iu={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},id=/*#__PURE__*/function(){function e(){}return e._initialize=function(){if("undefined"==typeof navigator){e._isBrowser=!1;return}var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?e.platform=tz.IPhone:/iPad/i.test(n)?e.platform=tz.IPad:/Android/i.test(n)?e.platform=tz.Android:/Macintosh/i.test(n)&&(e.platform=tz.Mac),e.platform){case tz.IPhone:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPhone OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPhone OS";break;case tz.IPad:t=n.match(/OS (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"iPad OS "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"iPad OS";break;case tz.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case tz.Mac:t=n.match(/Mac OS X (\d+)_?(\d+)?_?(\d+)?/),this.operatingSystem=t?"Mac OS X "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Mac OS X"}},e._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},tG(e,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),e}();id.platform=tz.Unknown,id.operatingSystem="",id._isBrowser=!0,id._simdSupported=null,id._initialize();var ih=((eb={})[eb.Backquote=0]="Backquote",eb[eb.Backslash=1]="Backslash",eb[eb.Backspace=2]="Backspace",eb[eb.BracketLeft=3]="BracketLeft",eb[eb.BracketRight=4]="BracketRight",eb[eb.Comma=5]="Comma",eb[eb.Digit0=6]="Digit0",eb[eb.Digit1=7]="Digit1",eb[eb.Digit2=8]="Digit2",eb[eb.Digit3=9]="Digit3",eb[eb.Digit4=10]="Digit4",eb[eb.Digit5=11]="Digit5",eb[eb.Digit6=12]="Digit6",eb[eb.Digit7=13]="Digit7",eb[eb.Digit8=14]="Digit8",eb[eb.Digit9=15]="Digit9",eb[eb.Equal=16]="Equal",eb[eb.IntlBackslash=17]="IntlBackslash",eb[eb.IntlRo=18]="IntlRo",eb[eb.IntlYen=19]="IntlYen",eb[eb.KeyA=20]="KeyA",eb[eb.KeyB=21]="KeyB",eb[eb.KeyC=22]="KeyC",eb[eb.KeyD=23]="KeyD",eb[eb.KeyE=24]="KeyE",eb[eb.KeyF=25]="KeyF",eb[eb.KeyG=26]="KeyG",eb[eb.KeyH=27]="KeyH",eb[eb.KeyI=28]="KeyI",eb[eb.KeyJ=29]="KeyJ",eb[eb.KeyK=30]="KeyK",eb[eb.KeyL=31]="KeyL",eb[eb.KeyM=32]="KeyM",eb[eb.KeyN=33]="KeyN",eb[eb.KeyO=34]="KeyO",eb[eb.KeyP=35]="KeyP",eb[eb.KeyQ=36]="KeyQ",eb[eb.KeyR=37]="KeyR",eb[eb.KeyS=38]="KeyS",eb[eb.KeyT=39]="KeyT",eb[eb.KeyU=40]="KeyU",eb[eb.KeyV=41]="KeyV",eb[eb.KeyW=42]="KeyW",eb[eb.KeyX=43]="KeyX",eb[eb.KeyY=44]="KeyY",eb[eb.KeyZ=45]="KeyZ",eb[eb.Minus=46]="Minus",eb[eb.Period=47]="Period",eb[eb.Quote=48]="Quote",eb[eb.Semicolon=49]="Semicolon",eb[eb.Slash=50]="Slash",eb[eb.AltLeft=51]="AltLeft",eb[eb.AltRight=52]="AltRight",eb[eb.CapsLock=53]="CapsLock",eb[eb.ContextMenu=54]="ContextMenu",eb[eb.ControlLeft=55]="ControlLeft",eb[eb.ControlRight=56]="ControlRight",eb[eb.Enter=57]="Enter",eb[eb.MetaLeft=58]="MetaLeft",eb[eb.MetaRight=59]="MetaRight",eb[eb.ShiftLeft=60]="ShiftLeft",eb[eb.ShiftRight=61]="ShiftRight",eb[eb.Space=62]="Space",eb[eb.Tab=63]="Tab",eb[eb.Convert=64]="Convert",eb[eb.KanaMode=65]="KanaMode",eb[eb.Lang1=66]="Lang1",eb[eb.Lang2=67]="Lang2",eb[eb.Lang3=68]="Lang3",eb[eb.Lang4=69]="Lang4",eb[eb.Lang5=70]="Lang5",eb[eb.NonConvert=71]="NonConvert",eb[eb.Delete=72]="Delete",eb[eb.End=73]="End",eb[eb.Help=74]="Help",eb[eb.Home=75]="Home",eb[eb.Insert=76]="Insert",eb[eb.PageDown=77]="PageDown",eb[eb.PageUp=78]="PageUp",eb[eb.ArrowDown=79]="ArrowDown",eb[eb.ArrowLeft=80]="ArrowLeft",eb[eb.ArrowRight=81]="ArrowRight",eb[eb.ArrowUp=82]="ArrowUp",eb[eb.NumLock=83]="NumLock",eb[eb.Numpad0=84]="Numpad0",eb[eb.Numpad1=85]="Numpad1",eb[eb.Numpad2=86]="Numpad2",eb[eb.Numpad3=87]="Numpad3",eb[eb.Numpad4=88]="Numpad4",eb[eb.Numpad5=89]="Numpad5",eb[eb.Numpad6=90]="Numpad6",eb[eb.Numpad7=91]="Numpad7",eb[eb.Numpad8=92]="Numpad8",eb[eb.Numpad9=93]="Numpad9",eb[eb.NumpadAdd=94]="NumpadAdd",eb[eb.NumpadBackspace=95]="NumpadBackspace",eb[eb.NumpadClear=96]="NumpadClear",eb[eb.NumpadClearEntry=97]="NumpadClearEntry",eb[eb.NumpadComma=98]="NumpadComma",eb[eb.NumpadDecimal=99]="NumpadDecimal",eb[eb.NumpadDivide=100]="NumpadDivide",eb[eb.NumpadEnter=101]="NumpadEnter",eb[eb.NumpadEqual=102]="NumpadEqual",eb[eb.NumpadHash=103]="NumpadHash",eb[eb.NumpadMemoryAdd=104]="NumpadMemoryAdd",eb[eb.NumpadMemoryClear=105]="NumpadMemoryClear",eb[eb.NumpadMemoryRecall=106]="NumpadMemoryRecall",eb[eb.NumpadMemoryStore=107]="NumpadMemoryStore",eb[eb.NumpadMemorySubtract=108]="NumpadMemorySubtract",eb[eb.NumpadMultiply=109]="NumpadMultiply",eb[eb.NumpadParenLeft=110]="NumpadParenLeft",eb[eb.NumpadParenRight=111]="NumpadParenRight",eb[eb.NumpadStar=112]="NumpadStar",eb[eb.NumpadSubtract=113]="NumpadSubtract",eb[eb.Escape=114]="Escape",eb[eb.F1=115]="F1",eb[eb.F2=116]="F2",eb[eb.F3=117]="F3",eb[eb.F4=118]="F4",eb[eb.F5=119]="F5",eb[eb.F6=120]="F6",eb[eb.F7=121]="F7",eb[eb.F8=122]="F8",eb[eb.F9=123]="F9",eb[eb.F10=124]="F10",eb[eb.F11=125]="F11",eb[eb.F12=126]="F12",eb[eb.F13=127]="F13",eb[eb.F14=128]="F14",eb[eb.F15=129]="F15",eb[eb.Fn=130]="Fn",eb[eb.FnLock=131]="FnLock",eb[eb.PrintScreen=132]="PrintScreen",eb[eb.ScrollLock=133]="ScrollLock",eb[eb.Pause=134]="Pause",eb[eb.BrowserBack=135]="BrowserBack",eb[eb.BrowserFavorites=136]="BrowserFavorites",eb[eb.BrowserForward=137]="BrowserForward",eb[eb.BrowserHome=138]="BrowserHome",eb[eb.BrowserRefresh=139]="BrowserRefresh",eb[eb.BrowserSearch=140]="BrowserSearch",eb[eb.BrowserStop=141]="BrowserStop",eb[eb.Eject=142]="Eject",eb[eb.LaunchApp1=143]="LaunchApp1",eb[eb.LaunchApp2=144]="LaunchApp2",eb[eb.LaunchMail=145]="LaunchMail",eb[eb.MediaPlayPause=146]="MediaPlayPause",eb[eb.MediaSelect=147]="MediaSelect",eb[eb.MediaStop=148]="MediaStop",eb[eb.MediaTrackNext=149]="MediaTrackNext",eb[eb.MediaTrackPrevious=150]="MediaTrackPrevious",eb[eb.Power=151]="Power",eb[eb.Sleep=152]="Sleep",eb[eb.AudioVolumeDown=153]="AudioVolumeDown",eb[eb.AudioVolumeMute=154]="AudioVolumeMute",eb[eb.AudioVolumeUp=155]="AudioVolumeUp",eb[eb.WakeUp=156]="WakeUp",eb[eb.Hyper=157]="Hyper",eb[eb.Super=158]="Super",eb[eb.Turbo=159]="Turbo",eb[eb.Abort=160]="Abort",eb[eb.Resume=161]="Resume",eb[eb.Suspend=162]="Suspend",eb[eb.Again=163]="Again",eb[eb.Copy=164]="Copy",eb[eb.Cut=165]="Cut",eb[eb.Find=166]="Find",eb[eb.Open=167]="Open",eb[eb.Paste=168]="Paste",eb[eb.Props=169]="Props",eb[eb.Select=170]="Select",eb[eb.Undo=171]="Undo",eb[eb.Hiragana=172]="Hiragana",eb[eb.Katakana=173]="Katakana",eb[eb.Unidentified=174]="Unidentified",eb),i_=/*#__PURE__*/function(){function e(e,t){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new rC,this._curFrameDownList=new rC,this._curFrameUpList=new rC,this._nativeEvents=[],this._engine=e,this._onBlur=this._onBlur.bind(this),this._onKeyEvent=this._onKeyEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._nativeEvents,t=this._curFrameDownList,n=this._curFrameUpList;if(t.length=0,n.length=0,e.length>0){for(var r=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,i=this._curFrameHeldDownList,o=this._downKeyToFrameCountMap,s=this._upKeyToFrameCountMap,l=0,c=e.length;l<c;l++){var u=e[l],d=ih[u.code];switch(u.type){case"keydown":null==a[d]&&(t.add(d),i.add(d),a[d]=i.length-1,o[d]=r);break;case"keyup":var h=a[d];if(null!=h){a[d]=null;var _=i.deleteByIndex(h);_&&(a[_]=h)}if(n.add(d),s[d]=r,id.platform===tz.Mac&&(d===ih.MetaLeft||d===ih.MetaRight)){for(var f=0,p=i.length;f<p;f++)a[i.get(f)]=null;i.length=0}}}e.length=0}},t._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},t._onBlur=function(){this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0},t._onKeyEvent=function(e){this._nativeEvents.push(e)},t._addEventListener=function(){var e=this._target;e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),e.addEventListener("blur",this._onBlur)},t._removeEventListener=function(){var e=this._target;e.removeEventListener("keydown",this._onKeyEvent),e.removeEventListener("keyup",this._onKeyEvent),e.removeEventListener("blur",this._onBlur)},e}();e.Collider=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._index=-1,n._shapes=[],n._updateFlag=t.registerWorldChangeFlag(),n}tW(t,e);var n=t.prototype;return n.addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this._addNativeShape(e),this._handleShapesChanged())},n.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this._removeNativeShape(e),this._handleShapesChanged())},n.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++)this._removeNativeShape(e[t]);e.length=0,this._handleShapesChanged()},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform;this._nativeCollider.setWorldTransform(e.worldPosition,e.worldRotationQuaternion);for(var t=e.lossyWorldScale,n=0,r=this.shapes.length;n<r;n++)this.shapes[n]._nativeShape.setWorldScale(t);this._updateFlag.flag=!1}},n._onLateUpdate=function(){},n._onEnableInScene=function(){this.scene.physics._addCollider(this)},n._onDisableInScene=function(){this.scene.physics._removeCollider(this)},n._cloneTo=function(e){e._syncNative()},n._handleShapesChanged=function(){},n._syncNative=function(){for(var e=0,t=this.shapes.length;e<t;e++)this._addNativeShape(this.shapes[e])},n._onDestroy=function(){e.prototype._onDestroy.call(this);for(var t=this._shapes,n=0,r=t.length;n<r;n++){var a=t[n];this._removeNativeShape(a),a._destroy()}t.length=0,this._nativeCollider.destroy()},n._addNativeShape=function(e){e._collider=this,this._nativeCollider.addShape(e._nativeShape)},n._removeNativeShape=function(e){e._collider=null,this._nativeCollider.removeShape(e._nativeShape)},tG(t,[{key:"shapes",get:function(){return this._shapes}}]),t}(ru),tX([tq],e.Collider.prototype,"_index",void 0),tX([tq],e.Collider.prototype,"_nativeCollider",void 0),tX([tq],e.Collider.prototype,"_updateFlag",void 0),tX([tZ],e.Collider.prototype,"_shapes",void 0),e.Collider=tX([rh(rp,r_.CheckOnly)],e.Collider);var ip=/*#__PURE__*/function(){function e(t){this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new rC,this._gravity=new tT(0,-9.81,0),this._onContactEnter=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionEnter(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactExit=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionExit(n)},function(e,t){e._entityScriptsIndex=t})},this._onContactStay=function(t,n){var r=iJ._physicalObjectsMap,a=r[t],i=r[n];a.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=i,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t}),i.collider.entity._scripts.forEach(function(t){var n=e._collision;n.shape=a,t.onCollisionStay(n)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerEnter=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerEnter(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerExit=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerExit(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerExit(r)},function(e,t){e._entityScriptsIndex=t})},this._onTriggerStay=function(e,t){var n=iJ._physicalObjectsMap,r=n[e],a=n[t];r.collider.entity._scripts.forEach(function(e){e.onTriggerStay(a)},function(e,t){e._entityScriptsIndex=t}),a.collider.entity._scripts.forEach(function(e){e.onTriggerStay(r)},function(e,t){e._entityScriptsIndex=t})},this._scene=t,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var n=t.engine;n._physicsInitialized&&(this._nativePhysicsScene=e._nativePhysics.createPhysicsScene(n._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var t=e.prototype;return t.raycast=function(e,t,n,r){var a,i=Number.MAX_VALUE;"number"==typeof t?i=t:void 0!=t&&(a=t);var o=rE.Everything;"number"==typeof n?o=n:void 0!=n&&(a=n),r&&(a=r);var s=function(e){var t=iJ._physicalObjectsMap[e];return!!t&&t.collider.entity.layer&o&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(e,i,s):!!this._nativePhysicsScene.raycast(e,i,s,function(e,t,n,r){var i=iJ._physicalObjectsMap[e];a.entity=i._collider.entity,a.shape=i,a.distance=t,a.normal.copyFrom(r),a.point.copyFrom(n)})||(a.entity=null,a.shape=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},t._update=function(e){var t=this._fixedTimeStep,n=this._nativePhysicsScene,r=this._scene._componentsManager,a=this._restTime+e,i=Math.floor(a/t);this._restTime=a-i*t;for(var o=0;o<i;o++)r.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),n.update(t),this._callColliderOnLateUpdate()},t._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},t._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},t._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},t._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},t._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},t._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},t._gc=function(){this._colliders.garbageCollection()},t._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},tG(e,[{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,tS.zeroTolerance)}}]),e}();ip._collision=new function(){};var im=((eC={})[eC.PreventClimbing=0]="PreventClimbing",eC[eC.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding",eC),ig=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=im.PreventClimbing,n._upDirection=new tT(0,1,0),n._slopeLimit=.707,n._nativeCollider=ip._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(n),n._upDirection._onValueChanged=n._setUpDirection,n._onUpdate(),n}tW(t,e);var n=t.prototype;return n.move=function(e,t,n){var r=this._nativeCollider.move(e,t,n);return this._syncWorldPositionFromPhysicalSpace(),r},n.addShape=function(t){if(this._shapes.length>0)throw"only allow single shape on controller!";e.prototype.addShape.call(this,t),this._updateFlag.flag=!0},n._onUpdate=function(){if(this._updateFlag.flag){var e=this.entity.transform,t=this.shapes;this._nativeCollider.setWorldPosition(e.worldPosition);for(var n=e.lossyWorldScale,r=0,a=t.length;r<a;r++)t[r]._nativeShape.setWorldScale(n);this._updateFlag.flag=!1}},n._onLateUpdate=function(){this._syncWorldPositionFromPhysicalSpace(),this._updateFlag.flag=!1},n._onEnableInScene=function(){this.scene.physics._addCharacterController(this)},n._onDisableInScene=function(){this.scene.physics._removeCharacterController(this)},n._syncNative=function(){e.prototype._syncNative.call(this),this._nativeCollider.setStepOffset(this._stepOffset),this._nativeCollider.setNonWalkableMode(this._nonWalkableMode),this._nativeCollider.setUpDirection(this._upDirection),this._nativeCollider.setSlopeLimit(this._slopeLimit)},n._syncWorldPositionFromPhysicalSpace=function(){this._nativeCollider.getWorldPosition(this.entity.transform.worldPosition)},n._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},tG(t,[{key:"stepOffset",get:function(){return this._stepOffset},set:function(e){e=Math.max(0,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))}}]),t}(e.Collider);tX([tZ],ig.prototype,"_upDirection",void 0);var iv=/*#__PURE__*/function(e){function t(t){(n=e.call(this,t)||this)._linearDamping=0,n._angularDamping=.05,n._linearVelocity=new tT,n._angularVelocity=new tT,n._mass=1,n._centerOfMass=new tT,n._inertiaTensor=new tT(1,1,1),n._maxAngularVelocity=100,n._maxDepenetrationVelocity=10000000331813535e16,n._solverIterations=4,n._isKinematic=!1,n._constraints=0,n._collisionDetectionMode=0,n._sleepThreshold=.005,n._automaticCenterOfMass=!0,n._automaticInertiaTensor=!0;var n,r=n.entity.transform;return n._nativeCollider=ip._nativePhysics.createDynamicCollider(r.worldPosition,r.worldRotationQuaternion),n._setLinearVelocity=n._setLinearVelocity.bind(n),n._setAngularVelocity=n._setAngularVelocity.bind(n),n._handleCenterOfMassChanged=n._handleCenterOfMassChanged.bind(n),n._handleInertiaTensorChanged=n._handleInertiaTensorChanged.bind(n),n._linearVelocity._onValueChanged=n._setLinearVelocity,n._angularVelocity._onValueChanged=n._setAngularVelocity,n._centerOfMass._onValueChanged=n._handleCenterOfMassChanged,n._inertiaTensor._onValueChanged=n._handleInertiaTensorChanged,n}tW(t,e);var n=t.prototype;return n.applyForce=function(e){this._phasedActiveInScene&&this._nativeCollider.addForce(e)},n.applyTorque=function(e){this._phasedActiveInScene&&this._nativeCollider.addTorque(e)},n.move=function(e,t){this._phasedActiveInScene&&this._nativeCollider.move(e,t)},n.sleep=function(){this._nativeCollider.sleep()},n.isSleeping=function(){return this._nativeCollider.isSleeping()},n.wakeUp=function(){this._nativeCollider.wakeUp()},n._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},n._cloneTo=function(t){t._linearVelocity.copyFrom(this.linearVelocity),t._angularVelocity.copyFrom(this.angularVelocity),t._centerOfMass.copyFrom(this.centerOfMass),t._inertiaTensor.copyFrom(this.inertiaTensor),e.prototype._cloneTo.call(this,t)},n._handleShapesChanged=function(){(this._automaticCenterOfMass||this._automaticInertiaTensor)&&this._setMassAndUpdateInertia()},n._syncNative=function(){e.prototype._syncNative.call(this),this._nativeCollider.setLinearDamping(this._linearDamping),this._nativeCollider.setAngularDamping(this._angularDamping),this._nativeCollider.setLinearVelocity(this._linearVelocity),this._nativeCollider.setAngularVelocity(this._angularVelocity),this._automaticCenterOfMass||this._automaticInertiaTensor?this._setMassAndUpdateInertia():(this._nativeCollider.setMass(this._mass),this._nativeCollider.setCenterOfMass(this._centerOfMass),this._nativeCollider.setInertiaTensor(this._inertiaTensor)),this._nativeCollider.setMaxAngularVelocity(this._maxAngularVelocity),this._nativeCollider.setMaxDepenetrationVelocity(this._maxDepenetrationVelocity),this._nativeCollider.setSleepThreshold(this._sleepThreshold),this._nativeCollider.setSolverIterations(this._solverIterations),this._nativeCollider.setIsKinematic(this._isKinematic),this._nativeCollider.setConstraints(this._constraints),this._nativeCollider.setCollisionDetectionMode(this._collisionDetectionMode)},n._setMassAndUpdateInertia=function(){this._nativeCollider.setMassAndUpdateInertia(this._mass),this._automaticCenterOfMass||this._nativeCollider.setCenterOfMass(this._centerOfMass),this._automaticInertiaTensor||this._nativeCollider.setInertiaTensor(this._inertiaTensor)},n._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},n._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},n._handleCenterOfMassChanged=function(){this._automaticCenterOfMass?console.warn("The center of mass is automatically calculated, please set automaticCenterOfMass to false if you want to set it manually."):this._nativeCollider.setCenterOfMass(this._centerOfMass)},n._handleInertiaTensorChanged=function(){this._automaticInertiaTensor?console.warn("The inertia tensor is automatically calculated, please set automaticInertiaTensor to false if you want to set it manually."):this._nativeCollider.setInertiaTensor(this._inertiaTensor)},tG(t,[{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._onValueChanged=null,this._nativeCollider.getLinearVelocity(this._linearVelocity),this._linearVelocity._onValueChanged=this._setLinearVelocity,this._linearVelocity},set:function(e){this._linearVelocity!==e&&this._linearVelocity.copyFrom(e)}},{key:"angularVelocity",get:function(){return this._angularVelocity._onValueChanged=null,this._nativeCollider.getAngularVelocity(this._angularVelocity),this._angularVelocity._onValueChanged=this._setAngularVelocity,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._automaticInertiaTensor||this._automaticCenterOfMass?this._setMassAndUpdateInertia():this._nativeCollider.setMass(e))}},{key:"automaticCenterOfMass",get:function(){return this._automaticCenterOfMass},set:function(e){this._automaticCenterOfMass!==e&&(this._automaticCenterOfMass=e,e&&this._setMassAndUpdateInertia())}},{key:"centerOfMass",get:function(){return this._centerOfMass._onValueChanged=null,this._nativeCollider.getCenterOfMass(this._centerOfMass),this._centerOfMass._onValueChanged=this._handleCenterOfMassChanged,this._centerOfMass},set:function(e){this._centerOfMass!==e&&this._centerOfMass.copyFrom(e)}},{key:"automaticInertiaTensor",get:function(){return this._automaticInertiaTensor},set:function(e){this._automaticInertiaTensor!==e&&(this._automaticInertiaTensor=e,e&&this._setMassAndUpdateInertia())}},{key:"inertiaTensor",get:function(){return this._inertiaTensor._onValueChanged=null,this._nativeCollider.getInertiaTensor(this._inertiaTensor),this._inertiaTensor._onValueChanged=this._handleInertiaTensorChanged,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))}}]),t}(e.Collider);tX([tq],iv.prototype,"_linearVelocity",void 0),tX([tq],iv.prototype,"_angularVelocity",void 0),tX([tq],iv.prototype,"_centerOfMass",void 0),tX([tq],iv.prototype,"_inertiaTensor",void 0),tX([tq],iv.prototype,"_setLinearVelocity",null),tX([tq],iv.prototype,"_setAngularVelocity",null),tX([tq],iv.prototype,"_handleCenterOfMassChanged",null),tX([tq],iv.prototype,"_handleInertiaTensorChanged",null);var iy=((eS={})[eS.Discrete=0]="Discrete",eS[eS.Continuous=1]="Continuous",eS[eS.ContinuousDynamic=2]="ContinuousDynamic",eS[eS.ContinuousSpeculative=3]="ContinuousSpeculative",eS),ix=((eT={})[eT.None=0]="None",eT[eT.FreezePositionX=1]="FreezePositionX",eT[eT.FreezePositionY=2]="FreezePositionY",eT[eT.FreezePositionZ=4]="FreezePositionZ",eT[eT.FreezeRotationX=8]="FreezeRotationX",eT[eT.FreezeRotationY=16]="FreezeRotationY",eT[eT.FreezeRotationZ=32]="FreezeRotationZ",eT),ib=function(){this.entity=null,this.distance=0,this.point=new tT,this.normal=new tT,this.shape=null},iC=((eA={})[eA.Average=0]="Average",eA[eA.Minimum=1]="Minimum",eA[eA.Multiply=2]="Multiply",eA[eA.Maximum=3]="Maximum",eA),iS=/*#__PURE__*/function(){function e(){this._bounciness=0,this._dynamicFriction=.6,this._staticFriction=.6,this._bounceCombine=iC.Average,this._frictionCombine=iC.Average,this._nativeMaterial=ip._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}return e.prototype._destroy=function(){this._destroyed||this._nativeMaterial.destroy(),this._destroyed=!0},tG(e,[{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))}}]),e}(),iT=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t)||this).entity.transform;return n._nativeCollider=ip._nativePhysics.createStaticCollider(r.worldPosition,r.worldRotationQuaternion),n}return tW(t,e),t}(e.Collider),iA=((eE={})[eE.X=0]="X",eE[eE.Y=1]="Y",eE[eE.Z=2]="Z",eE),iE=((eR={})[eR.Sides=1]="Sides",eR[eR.Up=2]="Up",eR[eR.Down=4]="Down",eR);e.Joint=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._colliderInfo=new iR,n._connectedColliderInfo=new iR,n._force=1/0,n._torque=1/0,n._automaticConnectedAnchor=!0,n._colliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,1),n._connectedColliderInfo.anchor._onValueChanged=n._updateActualAnchor.bind(n,2),n._onSelfTransformChanged=n._onSelfTransformChanged.bind(n),n._onConnectedTransformChanged=n._onConnectedTransformChanged.bind(n),t._updateFlagManager.addListener(n._onSelfTransformChanged),n}tW(t,e);var n=t.prototype;return n._onEnableInScene=function(){this._createJoint(),this._syncNative()},n._onDisableInScene=function(){this._nativeJoint.destroy(),this._nativeJoint=null},n._syncNative=function(){if(this._nativeJoint){var e;this._nativeJoint.setConnectedCollider((null==(e=this._connectedColliderInfo.collider)?void 0:e._nativeCollider)||null),this._updateActualAnchor(1),this._automaticConnectedAnchor?this._calculateConnectedAnchor():this._updateActualAnchor(2),this._nativeJoint.setConnectedMassScale(this._connectedColliderInfo.massScale),this._nativeJoint.setConnectedInertiaScale(this._connectedColliderInfo.inertiaScale),this._nativeJoint.setMassScale(this._colliderInfo.massScale),this._nativeJoint.setInertiaScale(this._colliderInfo.inertiaScale),this._nativeJoint.setBreakForce(this._force),this._nativeJoint.setBreakTorque(this._torque)}},n._calculateConnectedAnchor=function(){var e=this._colliderInfo,n=this._connectedColliderInfo,r=this.entity.transform.worldPosition,a=e.actualAnchor,i=n.anchor,o=n.actualAnchor,s=n.collider;if(s){var l=s.entity.transform,c=l.worldPosition,u=l.lossyWorldScale;tT.subtract(r,c,t._tempVector3),tT.add(t._tempVector3,a,o),tT.divide(o,u,i)}else tT.add(r,a,o),i.copyFrom(o)},n._onSelfTransformChanged=function(e){e&rm.WorldScale&&this._updateActualAnchor(1)},n._onConnectedTransformChanged=function(e){e&rm.WorldScale&&this._updateActualAnchor(2)},n._updateActualAnchor=function(e){if(1&e){var t,n=this.entity.transform.lossyWorldScale,r=this._colliderInfo;tT.multiply(r.anchor,n,r.actualAnchor),null==(t=this._nativeJoint)||t.setAnchor(r.actualAnchor)}if(2&e){var a,i=this._connectedColliderInfo,o=i.collider;if(o){var s=o.entity.transform.lossyWorldScale;tT.multiply(i.anchor,s,i.actualAnchor)}else i.actualAnchor.copyFrom(i.anchor);null==(a=this._nativeJoint)||a.setConnectedAnchor(i.actualAnchor)}},tG(t,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){if(this._connectedColliderInfo.collider!==e){var t,n;null==(t=this._connectedColliderInfo.collider)||t.entity._updateFlagManager.removeListener(this._onConnectedTransformChanged),null==e||e.entity._updateFlagManager.addListener(this._onConnectedTransformChanged),this._connectedColliderInfo.collider=e,null==(n=this._nativeJoint)||n.setConnectedCollider(e._nativeCollider),this._automaticConnectedAnchor?this._calculateConnectedAnchor():this._updateActualAnchor(2)}}},{key:"anchor",get:function(){return this._colliderInfo.anchor},set:function(e){var t=this._colliderInfo.anchor;e!==t&&(t.copyFrom(e),this._updateActualAnchor(1),this._automaticConnectedAnchor&&this._calculateConnectedAnchor())}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.anchor},set:function(e){if(this.automaticConnectedAnchor){console.warn("Cannot set connectedAnchor when automaticConnectedAnchor is true.");return}var t=this._connectedColliderInfo.anchor;e!==t&&(t.copyFrom(e),this._updateActualAnchor(2))}},{key:"automaticConnectedAnchor",get:function(){return this._automaticConnectedAnchor},set:function(e){this._automaticConnectedAnchor=e,e&&this._calculateConnectedAnchor()}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){if(e!==this._connectedColliderInfo.massScale){var t;this._connectedColliderInfo.massScale=e,null==(t=this._nativeJoint)||t.setConnectedMassScale(e)}}},{key:"massScale",get:function(){return this._colliderInfo.massScale},set:function(e){if(e!==this._colliderInfo.massScale){var t;this._colliderInfo.massScale=e,null==(t=this._nativeJoint)||t.setMassScale(e)}}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){if(e!==this._connectedColliderInfo.inertiaScale){var t;this._connectedColliderInfo.inertiaScale=e,null==(t=this._nativeJoint)||t.setConnectedInertiaScale(e)}}},{key:"inertiaScale",get:function(){return this._colliderInfo.inertiaScale},set:function(e){if(e!==this._colliderInfo.inertiaScale){var t;this._colliderInfo.inertiaScale=e,null==(t=this._nativeJoint)||t.setInertiaScale(e)}}},{key:"breakForce",get:function(){return this._force},set:function(e){if(e!==this._force){var t;this._force=e,null==(t=this._nativeJoint)||t.setBreakForce(e)}}},{key:"breakTorque",get:function(){return this._torque},set:function(e){if(e!==this._torque){var t;this._torque=e,null==(t=this._nativeJoint)||t.setBreakTorque(e)}}}]),t}(ru),e.Joint._tempVector3=new tT,tX([tZ],e.Joint.prototype,"_colliderInfo",void 0),tX([tZ],e.Joint.prototype,"_connectedColliderInfo",void 0),tX([tq],e.Joint.prototype,"_nativeJoint",void 0),tX([tq],e.Joint.prototype,"_onSelfTransformChanged",null),tX([tq],e.Joint.prototype,"_onConnectedTransformChanged",null),tX([tq],e.Joint.prototype,"_updateActualAnchor",null),e.Joint=tX([rh(e.Collider,r_.CheckOnly)],e.Joint);var iR=function(){this.collider=null,this.anchor=new tT,this.actualAnchor=new tT,this.massScale=1,this.inertiaScale=1};tX([tZ],iR.prototype,"anchor",void 0),tX([tZ],iR.prototype,"actualAnchor",void 0);var iM=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return tW(n,t),n.prototype._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n}(e.Joint),iw=((eM={})[eM.None=0]="None",eM[eM.LimitEnabled=1]="LimitEnabled",eM[eM.DriveEnabled=2]="DriveEnabled",eM[eM.DriveFreeSpin=4]="DriveFreeSpin",eM),iP=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this)._axis=new tT(1,0,0),n._hingeFlags=iw.None,n._useSpring=!1,n._angle=0,n._velocity=0,n._onMotorChanged=n._onMotorChanged.bind(n),n._onLimitsChanged=n._onLimitsChanged.bind(n),n}tW(n,t);var r=n.prototype;return r._onDisableInScene=function(){var e=this._nativeJoint;this._angle=e.getAngle(),this._velocity=e.getVelocity(),t.prototype._onDisableInScene.call(this)},r._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createHingeJoint(t.collider._nativeCollider)},r._syncNative=function(){t.prototype._syncNative.call(this);var e=this._jointMotor;this._nativeJoint.setAxis(this._axis),this._nativeJoint.setHingeJointFlag(iw.LimitEnabled,this.useLimits),this._nativeJoint.setHingeJointFlag(iw.DriveEnabled,this.useMotor),e&&(this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRatio),this._nativeJoint.setHingeJointFlag(iw.DriveFreeSpin,e.freeSpin))},r._onMotorChanged=function(){var e=this._jointMotor;this._nativeJoint&&(this._nativeJoint.setDriveVelocity(e.targetVelocity),this._nativeJoint.setDriveForceLimit(e.forceLimit),this._nativeJoint.setDriveGearRatio(e.gearRatio),this._nativeJoint.setHingeJointFlag(iw.DriveFreeSpin,e.freeSpin))},r._onLimitsChanged=function(){var e=this._limits;e&&this._nativeJoint&&(this.useSpring?this._nativeJoint.setSoftLimit(e.min,e.max,e.stiffness,e.damping):this._nativeJoint.setHardLimit(e.min,e.max,e.contactDistance))},tG(n,[{key:"axis",get:function(){return this._axis},set:function(e){var t,n=this._axis;e!==n&&(n.copyFrom(e),null==(t=this._nativeJoint)||t.setAxis(n))}},{key:"angle",get:function(){var e=this._nativeJoint;return e&&(this._angle=e.getAngle()),this._angle}},{key:"velocity",get:function(){var e=this._nativeJoint;return e&&(this._velocity=e.getVelocity()),this._velocity}},{key:"useLimits",get:function(){return(this._hingeFlags&iw.LimitEnabled)==iw.LimitEnabled},set:function(e){if(e!==this.useLimits){var t;e?this._hingeFlags|=iw.LimitEnabled:this._hingeFlags&=~iw.LimitEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iw.LimitEnabled,e)}}},{key:"useMotor",get:function(){return(this._hingeFlags&iw.DriveEnabled)==iw.DriveEnabled},set:function(e){if(e!==this.useMotor){var t;e?this._hingeFlags|=iw.DriveEnabled:this._hingeFlags&=~iw.DriveEnabled,null==(t=this._nativeJoint)||t.setHingeJointFlag(iw.DriveEnabled,e)}}},{key:"useSpring",get:function(){return this._useSpring},set:function(e){this._useSpring!==e&&(this._useSpring=e,this._onLimitsChanged())}},{key:"motor",get:function(){return this._jointMotor},set:function(e){if(this._jointMotor!==e){var t;null==(t=this._jointMotor)||t._updateFlagManager.removeListener(this._onMotorChanged),this._jointMotor=e,null==e||e._updateFlagManager.addListener(this._onMotorChanged),this._onMotorChanged()}}},{key:"limits",get:function(){return this._limits},set:function(e){if(this._limits!==e){var t;null==(t=this._limits)||t._updateFlagManager.removeListener(this._onLimitsChanged),this._limits=e,null==e||e._updateFlagManager.addListener(this._onLimitsChanged),this._onLimitsChanged()}}}]),n}(e.Joint);tX([tZ],iP.prototype,"_axis",void 0),tX([tZ],iP.prototype,"_jointMotor",void 0),tX([tZ],iP.prototype,"_limits",void 0),tX([tq],iP.prototype,"_onMotorChanged",null),tX([tq],iP.prototype,"_onLimitsChanged",null);var iF=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e}tW(n,t);var r=n.prototype;return r._createJoint=function(){var t=this._colliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=ip._nativePhysics.createSpringJoint(t.collider._nativeCollider)},r._syncNative=function(){t.prototype._syncNative.call(this),this._nativeJoint.setMinDistance(this._minDistance),this._nativeJoint.setMaxDistance(this._maxDistance),this._nativeJoint.setTolerance(this._tolerance),this._nativeJoint.setStiffness(this._stiffness),this._nativeJoint.setDamping(this._damping)},tG(n,[{key:"minDistance",get:function(){return this._minDistance},set:function(e){if(this._minDistance!==e){var t;this._minDistance=e,null==(t=this._nativeJoint)||t.setMinDistance(e)}}},{key:"maxDistance",get:function(){return this._maxDistance},set:function(e){if(this._maxDistance!==e){var t;this._maxDistance=e,null==(t=this._nativeJoint)||t.setMaxDistance(e)}}},{key:"tolerance",get:function(){return this._tolerance},set:function(e){if(this._tolerance!==e){var t;this._tolerance=e,null==(t=this._nativeJoint)||t.setTolerance(e)}}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){if(this._stiffness!==e){var t;this._stiffness=e,null==(t=this._nativeJoint)||t.setStiffness(e)}}},{key:"damping",get:function(){return this._damping},set:function(e){if(this._damping!==e){var t;this._damping=e,null==(t=this._nativeJoint)||t.setDamping(e)}}}]),n}(e.Joint),iL=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nM,this._max=0,this._min=0,this._contactDistance=-1,this._stiffness=0,this._damping=0}return tG(e,[{key:"max",get:function(){return this._max},set:function(e){if(e<this._min)throw Error("Max limit must be greater than min limit");this._max!==e&&(this._max=e,this._updateFlagManager.dispatch())}},{key:"min",get:function(){return this._min},set:function(e){if(e>this._max)throw Error("Min limit must be less than max limit");this._min!==e&&(this._min=e,this._updateFlagManager.dispatch())}},{key:"contactDistance",get:function(){return -1===this._contactDistance?Math.min(.1,.49*(this._max-this._min)):this._contactDistance},set:function(e){this._contactDistance!==e&&(this._contactDistance=e,this._updateFlagManager.dispatch())}},{key:"stiffness",get:function(){return this._stiffness},set:function(e){this._stiffness!==e&&(this._stiffness=e,this._updateFlagManager.dispatch())}},{key:"damping",get:function(){return this._damping},set:function(e){this._damping!==e&&(this._damping=e,this._updateFlagManager.dispatch())}}]),e}();tX([tZ],iL.prototype,"_updateFlagManager",void 0);var iD=/*#__PURE__*/function(){function e(){this._updateFlagManager=new nM,this._targetVelocity=0,this._forceLimit=Number.MAX_VALUE,this._gearRatio=1,this._freeSpin=!1}return tG(e,[{key:"targetVelocity",get:function(){return this._targetVelocity},set:function(e){this._targetVelocity=e,this._updateFlagManager.dispatch()}},{key:"forceLimit",get:function(){return this._forceLimit},set:function(e){this._forceLimit=e,this._updateFlagManager.dispatch()}},{key:"gearRatio",get:function(){return this._gearRatio},set:function(e){this._gearRatio=e,this._updateFlagManager.dispatch()}},{key:"freeSpin",get:function(){return this._freeSpin},set:function(e){this._freeSpin=e,this._updateFlagManager.dispatch()}}]),e}();tX([tZ],iD.prototype,"_updateFlagManager",void 0);var iB=/*#__PURE__*/function(){function e(){this._isTrigger=!1,this._rotation=new tT,this._position=new tT,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new iS,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,iJ._physicalObjectsMap[this._id]=this}var t=e.prototype;return t._cloneTo=function(e){e._syncNative()},t._destroy=function(){this._nativeShape.destroy(),this._nativeShape=null,delete iJ._physicalObjectsMap[this._id]},t._syncNative=function(){var e;this._nativeShape.setPosition(this._position),this._nativeShape.setRotation(this._rotation),this._nativeShape.setContactOffset(this._contactOffset),this._nativeShape.setIsTrigger(this._isTrigger),this._nativeShape.setMaterial(this._material._nativeMaterial),null==(e=this._collider)||e._handleShapesChanged()},t._setPosition=function(){var e;this._nativeShape.setPosition(this._position),null==(e=this._collider)||e._handleShapesChanged()},t._setRotation=function(){var e;this._nativeShape.setRotation(this._rotation),null==(e=this._collider)||e._handleShapesChanged()},tG(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){e=Math.max(0,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}();iB._idGenerator=0,tX([tq],iB.prototype,"_collider",void 0),tX([tq],iB.prototype,"_nativeShape",void 0),tX([tq],iB.prototype,"_id",void 0),tX([tZ],iB.prototype,"_rotation",void 0),tX([tZ],iB.prototype,"_position",void 0),tX([tq],iB.prototype,"_setPosition",null),tX([tq],iB.prototype,"_setRotation",null);var iI=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._size=new tT(1,1,1),t._nativeShape=ip._nativePhysics.createBoxColliderShape(t._id,t._size,t._material._nativeMaterial),t._size._onValueChanged=t._setSize.bind(t),t}tW(t,e);var n=t.prototype;return n._syncNative=function(){e.prototype._syncNative.call(this),this._setSize()},n._setSize=function(){this._nativeShape.setSize(this._size)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),t}(iB);tX([tZ],iI.prototype,"_size",void 0),tX([tq],iI.prototype,"_setSize",null);var iO=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._nativeShape=ip._nativePhysics.createSphereColliderShape(t._id,t._radius,t._material._nativeMaterial),t}return tW(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),t}(iB),iN=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._nativeShape=ip._nativePhysics.createPlaneColliderShape(t._id,t._material._nativeMaterial),t}return tW(t,e),t}(iB),iV=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._radius=1,t._height=2,t._upAxis=iA.Y,t._nativeShape=ip._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t}return tW(t,e),t.prototype._syncNative=function(){e.prototype._syncNative.call(this),this._nativeShape.setRadius(this._radius),this._nativeShape.setHeight(this._height),this._nativeShape.setUpAxis(this._upAxis)},tG(t,[{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))}}]),t}(iB),ik=/*#__PURE__*/function(){function e(e,t){if(this._pointers=[],this._multiPointerEnabled=!0,this._buttons=il.None,this._upMap=[],this._downMap=[],this._upList=new rC,this._downList=new rC,this._nativeEvents=[],"undefined"!=typeof Window&&tK(t,Window))throw"Do not set window as target because window cannot listen to pointer leave event.";this._engine=e,this._target=t,this._canvas=e.canvas,this._htmlCanvas=e._canvas._webCanvas,this._pointerPool=Array(11),this._onPointerEvent=this._onPointerEvent.bind(this),this._addEventListener()}var t=e.prototype;return t._update=function(){for(var e=this._pointers,t=this._nativeEvents,n=this._htmlCanvas,r=this._canvas,a=r.width,i=r.height,o=n.clientWidth,s=n.clientHeight,l=n.getBoundingClientRect(),c=l.left,u=l.top,d=a/o,h=i/s,_=e.length-1;_>=0;_--)e[_].phase===io.Leave&&e.splice(_,1);for(var f=0,p=t.length;f<p;f++){var m=t[f],g=m.pointerId,v=this._getPointerByID(g);if(v)v._events.push(m);else{var y=e.length;if(0===y||this._multiPointerEnabled){for(var x,b=this._pointerPool,C=0;C<y&&!(e[C].id>C);C++);(v=b[x=C]||(b[x]=new is(C)))._uniqueID=g,v._events.push(m),v.position.set((m.clientX-c)*d,(m.clientY-u)*h),e.splice(C,0,v)}}}t.length=0,this._upList.length=this._downList.length=0,this._buttons=il.None;for(var S=this._engine.time.frameCount,T=0,A=e.length;T<A;T++){var E=e[T];E._upList.length=E._downList.length=0,this._updatePointerInfo(S,E,c,u,d,h),this._buttons|=E.pressedButtons}},t._firePointerScript=function(e){for(var t=this._pointers,n=this._canvas,r=0,a=t.length;r<a;r++){var i=t[r],o=i._events,s=i.position;i._firePointerDrag();var l=this._pointerRayCast(e,s.x/n.width,s.y/n.height);i._firePointerExitAndEnter(l);var c=o.length;if(c>0){for(var u=0;u<c;u++)switch(o[u].type){case"pointerdown":i.phase=io.Down,i._firePointerDown(l);break;case"pointerup":i.phase=io.Up,i._firePointerUpAndClick(l);break;case"pointerleave":case"pointercancel":i.phase=io.Leave,i._firePointerExitAndEnter(null)}o.length=0}}},t._destroy=function(){this._removeEventListener(),this._pointerPool.length=0,this._nativeEvents.length=0,this._downMap.length=0,this._upMap.length=0},t._onPointerEvent=function(e){this._nativeEvents.push(e)},t._getPointerByID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return t[n];return null},t._updatePointerInfo=function(e,t,n,r,a,i){var o=t._events,s=t.position,l=o.length;if(l>0){var c=this._upList,u=this._upMap,d=this._downList,h=this._downMap,_=o[l-1],f=(_.clientX-n)*a,p=(_.clientY-r)*i;t.deltaPosition.set(f-s.x,p-s.y),s.set(f,p);for(var m=0;m<l;m++){var g=o[m],v=g.button;switch(t.button=ic[v]||il.None,t.pressedButtons=g.buttons,g.type){case"pointerdown":d.add(v),h[v]=e,t._downList.add(v),t._downMap[v]=e,t.phase=io.Down;break;case"pointerup":c.add(v),u[v]=e,t._upList.add(v),t._upMap[v]=e,t.phase=io.Up;break;case"pointermove":t.phase=io.Move;break;case"pointerleave":case"pointercancel":t.phase=io.Leave}}this._engine._physicsInitialized||(o.length=0)}else t.deltaPosition.set(0,0),t.phase=io.Stationary},t._pointerRayCast=function(t,n,r){for(var a=e._tempPoint,i=e._tempRay,o=e._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(n>=f&&r>=p&&n-f<=m&&r-p<=g){if(a.set((n-f)/m,(r-p)/g),l.physics.raycast(h.viewportPointToRay(a,i),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&rw.Color)return null}}}}return null},t._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)},t._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},e}();ik._tempRay=new tD,ik._tempPoint=new tB,ik._tempHitResult=new ib;var iz=/*#__PURE__*/function(){function e(e,t){this._delta=new tT,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),this._target=t,this._addEventListener()}var t=e.prototype;return t._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var n=t.length-1;n>=0;n--){var r=t[n];e.x+=r.deltaX,e.y+=r.deltaY,e.z+=r.deltaZ}t.length=0}},t._addEventListener=function(){this._target.addEventListener("wheel",this._onWheelEvent)},t._removeEventListener=function(){this._target.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0)},t._destroy=function(){this._removeEventListener(),this._nativeEvents=null,this._delta=null},t._onWheelEvent=function(e){this._nativeEvents.push(e)},e}(),iU=/*#__PURE__*/function(){function e(e,t){this._initialized=!1,this._engine=e;var n,r,a,i=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&tK(i,OffscreenCanvas)||(this._wheelManager=new iz(e,null!=(n=null==t?void 0:t.wheelTarget)?n:i),this._pointerManager=new ik(e,null!=(r=null==t?void 0:t.pointerTarget)?r:i),this._keyboardManager=new i_(e,null!=(a=null==t?void 0:t.keyboardTarget)?a:window),this._initialized=!0)}var t=e.prototype;return t.isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},t.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},t.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},t.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[iu[e]]===this._engine.time.frameCount)},t.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[iu[e]]===this._engine.time.frameCount)},t._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},t._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},t._destroy=function(){this._initialized&&(this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},tG(e,[{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}}]),e}(),iG=((ew={}).cornerTextureCoordinate="a_CornerTextureCoordinate",ew),iH=((eP={}).ShapePositionStartLifeTime="a_ShapePositionStartLifeTime",eP.DirectionTime="a_DirectionTime",eP.StartColor="a_StartColor",eP.StartSize="a_StartSize",eP.StartRotation0="a_StartRotation0",eP.StartSpeed="a_StartSpeed",eP.Random0="a_Random0",eP.Random1="a_Random1",eP.SimulationWorldPosition="a_SimulationWorldPosition",eP.SimulationWorldRotation="a_SimulationWorldRotation",eP.SimulationUV="a_SimulationUV",eP),iW=function e(t){this.billboardVertexElement=new at(iG.cornerTextureCoordinate,0,r7.Vector4,0),this.instanceVertexElements=[new at(iH.ShapePositionStartLifeTime,0,r7.Vector4,1,1),new at(iH.DirectionTime,16,r7.Vector4,1,1),new at(iH.StartColor,32,r7.Vector4,1,1),new at(iH.StartSize,48,r7.Vector3,1,1),new at(iH.StartRotation0,60,r7.Vector3,1,1),new at(iH.StartSpeed,72,r7.Float,1,1),new at(iH.Random0,76,r7.Vector4,1,1),new at(iH.Random1,92,r7.Vector4,1,1),new at(iH.SimulationWorldPosition,108,r7.Vector3,1,1),new at(iH.SimulationWorldRotation,120,r7.Vector4,1,1),new at(iH.SimulationUV,136,r7.Vector4,1,1)];var n=new r9(t,an.VertexBuffer,64,r8.Static,!1);n.isGCIgnored=!0,this.billboardVertexBufferBinding=new aS(n,16);var r=new r9(t,an.IndexBuffer,e.billboardIndexCount,r8.Static,!1);r.isGCIgnored=!0,this.billboardIndexBufferBinding=new ag(r,r6.UInt8);var a=new Float32Array([-.5,-.5,0,1,.5,-.5,1,1,.5,.5,1,0,-.5,.5,0,0]),i=new Uint8Array([0,2,3,0,1,2]);n.setData(a),r.setData(i),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,n)||this}return tW(t,e),t.prototype.restoreContent=function(){n.setData(a)},t}(t2))),t.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function t(){return e.call(this,r)||this}return tW(t,e),t.prototype.restoreContent=function(){},t}(t2)))};iW.instanceVertexStride=152,iW.instanceVertexFloatStride=iW.instanceVertexStride/4,iW.startLifeTimeOffset=3,iW.timeOffset=7,iW.simulationUVOffset=34,iW.billboardIndexCount=6,iW.boundsFloatStride=8,iW.boundsTimeOffset=6,iW.boundsMaxLifetimeOffset=7;var ij="#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;}",iX="#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}",iK=/*#__PURE__*/function(){function e(){}return e.init=function(){var e=new n6("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:nX.ShadowCaster});e._renderState=new ri,e._renderStateDataMap[nO.RenderQueueType]=as._shadowCasterRenderQueueProp;var t=[e,new n6("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:nX.DepthOnly})],n={pipelineStage:nX.Forward};ro.create("blinn-phong",[].concat([new n6("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}",n)],t)),ro.create("pbr",[].concat([new n6("Forward",iX,"#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}",n)],t)),ro.create("pbr-specular",[].concat([new n6("Forward",iX,"#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}",n)],t)),ro.create("unlit",[].concat([new n6("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}",n)],t)),ro.create("blit",[new n6("Forward",ij,"#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(){vec2 uv=v_uv;\n#ifdef renderer_FlipYBlitTexture\nuv.y=1.0-uv.y;\n#endif\n#ifdef HAS_TEX_LOD\ngl_FragColor=texture2DLodEXT(renderer_BlitTexture,uv,renderer_BlitMipLevel);\n#else\ngl_FragColor=texture2D(renderer_BlitTexture,uv);\n#endif\n}",n)]),ro.create("skybox",[new n6("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}",n)]),ro.create("SkyProcedural",[new n6("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}",n)]),ro.create("particle-shader",[new n6("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*a_Random0.x*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}",n)]),ro.create("SpriteMask",[new n6("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;}",n)]),ro.create("Sprite",[new n6("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;}",n)]),ro.create("Text",[new n6("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;}",n)]),ro.create("background-texture",[new n6("Forward","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform vec4 camera_ProjectionParams;void main(){gl_Position=vec4(POSITION,1.0);gl_Position.y*=camera_ProjectionParams.x;v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",n)])},e}(),iY=/*#__PURE__*/function(){function e(e){this.engine=e,this._cacheHierarchyDepth=1,this._cacheMap=Object.create(null)}var t=e.prototype;return t.get=function(e){var t=this._cacheMap,n=e._length,r=this._cacheHierarchyDepth;n>r&&(this._resizeCacheMapHierarchy(t,0,r,n-r),this._cacheHierarchyDepth=n);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},t.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},t._destroy=function(){this._recursiveDestroy(0,this._cacheMap),this._cacheMap=Object.create(null)},t._recursiveDestroy=function(e,t){if(e===this._cacheHierarchyDepth-1){for(var n in t)t[n].destroy();return}for(var r in++e,t)this._recursiveDestroy(e,t[r])},t._resizeCacheMapHierarchy=function(e,t,n,r){if(t==n-1)for(var a in e){for(var i=e[a],o=e,s=0;s<r;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,n,r)},e}(),iq=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._usedElementCount=0,n._elements=[],n}tW(t,e);var n=t.prototype;return n.get=function(){var e=this._usedElementCount,t=this._elements;if(this._usedElementCount++,t.length!==e)return t[e];var n=new this._type;return t.push(n),n},n.clear=function(){this._usedElementCount=0},t}(aq),iQ=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t._initialize=function(e,t){},t._update=function(){},t._destroy=function(){},t._getRequestAnimationFrame=function(){return null},t._getCancelAnimationFrame=function(){return null},t._getCameraIgnoreClearFlags=function(e){return rw.None},e}();iK.init();var iJ=/*#__PURE__*/function(e){function t(n,r,a){(i=e.call(this)||this)._physicsInitialized=!1,i._lastRenderState=new ri,i._renderElementPool=new iq(r0),i._subRenderElementPool=new iq(r1),i._textSubRenderElementPool=new iq(r1),i._charRenderInfoPool=new aQ(tj,50),i._renderContext=new rk,i._renderCount=0,i._shaderProgramPools=[],i._fontMap={},i._macroCollection=new nW,i._settings={},i._resourceManager=new ie(i),i._sceneManager=new a4(i),i._vSyncCount=1,i._targetFrameRate=60,i._time=new nq,i._isPaused=!0,i._vSyncCounter=1,i._targetFrameInterval=1e3/60,i._destroyed=!1,i._frameInProcess=!1,i._waitingDestroy=!1,i._isDeviceLost=!1,i._waitingGC=!1,i._animate=function(){if(i._vSyncCount){var e,t=(null==(e=i.xrManager)?void 0:e._getRequestAnimationFrame())||requestAnimationFrame;i._requestId=t(i._animate),i._vSyncCounter++%i._vSyncCount==0&&(i.update(),i._vSyncCounter=1)}else i._timeoutId=window.setTimeout(i._animate,i._targetFrameInterval),i.update()},i._hardwareRenderer=r,i._hardwareRenderer.init(n,i._onDeviceLost.bind(i),i._onDeviceRestored.bind(i)),i._canvas=n,i._textDefaultFont=ng.createFromOS(i,"Arial"),i._textDefaultFont.isGCIgnored=!0,i._batcherManager=new a1(i),i.inputManager=new iU(i,a.input);var i,o=a.xrDevice;if(o&&(i.xrManager=new iQ,i.xrManager._initialize(i,o)),r.canIUse(nJ.depthTexture)){var s=new nc(i,1,1,t9.Depth16,!1);s.isGCIgnored=!0,i._depthTexture2D=s}else i._macroCollection.enable(t._noDepthTextureMacro);var l=new ao(i,ro.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._meshMagentaMaterial=l;var c=new ao(i,ro.find("particle-shader"));c.isGCIgnored=!0,c.shaderData.setColor("material_BaseColor",new tO(1,0,1.01,1)),i._particleMagentaMaterial=c;var u=i._settings,d=a.colorSpace||n2.Linear;return d===n2.Gamma&&i._macroCollection.enable(t._gammaMacro),u.colorSpace=d,i._basicResources=new aY(i),i._particleBufferUtils=new iW(i),i}tW(t,e);var n=t.prototype;return n.createEntity=function(e){return new aW(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 n=t.deltaTime;this._frameInProcess=!0,this._subRenderElementPool.clear(),this._textSubRenderElementPool.clear(),this._renderElementPool.clear(),null==(e=this.xrManager)||e._update();var r=this.inputManager,a=this._physicsInitialized;r._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(n)}a&&r._firePointerScript(i);for(var h=0;h<o;h++){var _=i[h];_.isActive&&!_.destroyed&&_._componentsManager.callScriptOnUpdate(n)}for(var f=0;f<o;f++){var p=i[f];p.isActive&&!p.destroyed&&p._componentsManager.callAnimationUpdate(n)}for(var m=0;m<o;m++){var g=i[m];g.isActive&&!g.destroyed&&g._componentsManager.callScriptOnLateUpdate(n)}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,n=this._shaderProgramPools,r=n[t];if(!r){var a=t+1;a>n.length&&(n.length=a),n[t]=r=new iY(this),e._shaderProgramPools.push(r)}return r},n._render=function(e){for(var t=this,n=this.time.deltaTime,r=0,a=e.length;r<a;r++){var i=e[r];i.isActive&&!i.destroyed&&(i._componentsManager.callRendererOnUpdate(n),i._updateShaderData())}for(var o=0,s=e.length;o<s;o++)!function(n,r){var a=e[n];if(a.isActive&&!a.destroyed){var i=a._componentsManager._activeCameras;if(0===i.length)return no.debug("No active camera in scene.");i.forEach(function(e){var n=a._componentsManager;n.callCameraOnBeginRender(e),e.render(),n.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,n=e.shaderLab,r=e.physics;n&&!ro._shaderLab&&(ro._shaderLab=n);var a=[];r&&a.push(r.initialize().then(function(){return ip._nativePhysics=r,t._nativePhysicsManager=r.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=ie._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._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 ri,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()},tG(t,[{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}}]),t}(nK);iJ._gammaMacro=nH.getByName("ENGINE_IS_COLORSPACE_GAMMA"),iJ._noDepthTextureMacro=nH.getByName("ENGINE_NO_DEPTH_TEXTURE"),iJ._pixelsPerUnit=100,iJ._physicalObjectsMap={};var iZ=/*#__PURE__*/function(){function e(){this._sizeUpdateFlagManager=new nM}return tG(e,[{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())}}]),e}(),i$=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.destroy=function(){this.mesh=null,this.material=null},t._render=function(t){var n=this.material,r=this.mesh;if(!n){no.warn("The material of sky is not defined.");return}if(n.destroyed){no.warn("The material of sky is destroyed.");return}if(!r){no.warn("The mesh of sky is not defined.");return}if(r.destroyed){no.warn("The mesh of sky is destroyed.");return}var a=t.camera,i=a.engine,o=a.scene,s=a.aspectRatio,l=a.fieldOfView,c=a.viewMatrix,u=a.shaderData,d=o.shaderData,h=e._viewProjMatrix,_=e._projectionMatrix,f=i._hardwareRenderer,p=n.shaderData,m=n.shader,g=n.renderState;h.copyFrom(c);var v=h.elements;v[12]=v[13]=v[14]=0;var y=1/Math.tan(tS.degreeToRadian(l)/2);_.elements[0]=y/s,_.elements[5]=y,tL.multiply(_,h,h);var x=u.getMatrix(rk.vpMatrixProperty);t.flipProjection&&tL.multiply(rk._flipYMatrix,h,h),u.setMatrix(rk.vpMatrixProperty,h);var b=ro._compileMacros;nW.unionCollection(t.camera._globalShaderMacro,p._macroCollection,b);var C=m.subShaders[0].passes[0],S=C._getShaderProgram(i,b);S.bind(),S.groupingOtherUniformBlock(),S.uploadAll(S.sceneUniformBlock,d),S.uploadAll(S.cameraUniformBlock,u),S.uploadAll(S.materialUniformBlock,p),S.uploadUnGroupTextures(),g._applyStates(i,!1,C._renderStateDataMap,p),f.drawPrimitive(r._primitive,r.subMesh,S),u.setMatrix(rk.vpMatrixProperty,x)},tG(e,[{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}}}]),e}();i$._epsilon=1e-6,i$._viewProjMatrix=new tL,i$._projectionMatrix=new tL(1,0,0,0,0,1,0,0,0,0,i$._epsilon-1,-1,0,0,0,0);var i0=/*#__PURE__*/function(){function e(e){this._engine=e,this.mode=rO.SolidColor,this.solidColor=new tO(.25,.25,.25,1),this.sky=new i$,this._textureFillMode=rN.AspectFitHeight,this._texture=null,this._initMesh(e),this._initMaterial(e)}var t=e.prototype;return t.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()},t._resizeBackgroundTexture=function(){var e=this._texture,t=this._mesh;if(this._texture){var n=this._engine.canvas,r=n.width,a=n.height,i=t.getPositions();switch(this._textureFillMode){case rN.Fill:i[0].set(-1,-1,1),i[1].set(1,-1,1),i[2].set(-1,1,1),i[3].set(1,1,1);break;case rN.AspectFitWidth:var o=e.height*r/e.width/a;i[0].set(-1,-o,1),i[1].set(1,-o,1),i[2].set(-1,o,1),i[3].set(1,o,1);break;case rN.AspectFitHeight:var s=e.width*a/e.height/r;i[0].set(-s,-1,1),i[1].set(s,-1,1),i[2].set(-s,1,1),i[3].set(s,1,1)}t.setPositions(i),t.uploadData(!1)}},t._initMesh=function(e){var t=this._mesh=this._createPlane(e);e.resourceManager.addContentRestorer(new/*#__PURE__*/(function(e){function n(){return e.call(this,t)||this}return tW(n,e),n.prototype.restoreContent=function(){t.setPositions(t.getPositions()),t.setUVs(t.getUVs()),t.setIndices(t.getIndices()),t.uploadData(!1)},n}(t2))),this._mesh._addReferCount(1)},t._initMaterial=function(e){var t=this._material=new ao(e,ro.find("background-texture"));t.renderState.depthState.compareFunction=nB.LessEqual,t._addReferCount(1)},t._createPlane=function(e){for(var t=new aM(e),n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],a=[,,,,],i=0;i<4;++i)r[i]=new tT,a[i]=new tB(i%2,1-(.5*i|0));return t.setPositions(r),t.setUVs(a),t.setIndices(n),t.uploadData(!1),t.addSubMesh(0,n.length),t},tG(e,[{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())}}]),e}(),i1=/*#__PURE__*/function(){function e(){this._cameraNeedSorting=!1,this._activeCameras=new rC,this._renderers=new rC,this._onStartScripts=new rC,this._onUpdateScripts=new rC,this._onLateUpdateScripts=new rC,this._onPhysicsUpdateScripts=new rC,this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new rC,this._onUpdateRenderers=new rC,this._componentsContainerPool=[]}var t=e.prototype;return t.addCamera=function(e){e._cameraIndex=this._activeCameras.length,this._activeCameras.add(e),this._cameraNeedSorting=!0},t.removeCamera=function(e){var t=this._activeCameras.deleteByIndex(e._cameraIndex);t&&(t._cameraIndex=e._cameraIndex),e._cameraIndex=-1,this._cameraNeedSorting=!0},t.sortCameras=function(){if(this._cameraNeedSorting){var e=this._activeCameras;e.sort(function(e,t){return e.priority-t.priority});for(var t=0,n=e.length;t<n;t++)e.get(t)._cameraIndex=t;this._cameraNeedSorting=!1}},t.addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},t.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},t.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},t.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},t.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},t.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},t.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},t.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},t.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},t.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},t.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},t.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},t.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},t.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})},t.callScriptOnUpdate=function(e){this._onUpdateScripts.forEach(function(t){t._started&&t.onUpdate(e)},function(e,t){e._onUpdateIndex=t})},t.callScriptOnLateUpdate=function(e){this._onLateUpdateScripts.forEach(function(t){t._started&&t.onLateUpdate(e)},function(e,t){e._onLateUpdateIndex=t})},t.callScriptOnPhysicsUpdate=function(){this._onPhysicsUpdateScripts.forEach(function(e){e._started&&e.onPhysicsUpdate()},function(e,t){e._onPhysicsUpdateIndex=t})},t.callAnimationUpdate=function(e){this._onUpdateAnimations.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.callRendererOnUpdate=function(e){this._onUpdateRenderers.forEach(function(t){t.update(e)},function(e,t){e._onUpdateIndex=t})},t.handlingInvalidScripts=function(){var e=this._disposeDestroyScripts,t=this._pendingDestroyScripts;this._disposeDestroyScripts=t,this._pendingDestroyScripts=e;var n=t.length;if(n>0){for(var r=n-1;r>=0;r--)t[r].onDestroy();t.length=0}},t.callCameraOnBeginRender=function(e){e.entity._scripts.forEach(function(t){t.onBeginRender(e)},function(e,t){e._entityScriptsIndex=t})},t.callCameraOnEndRender=function(e){e.entity._scripts.forEach(function(t){t.onEndRender(e)},function(e,t){e._entityScriptsIndex=t})},t.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},t.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},t._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()},e}(),i2=/*#__PURE__*/function(){function e(){this.hasStencilWritten=!1,this._preMaskLayer=rg.Nothing,this._allSpriteMasks=new rC}var t=e.prototype;return t.addSpriteMask=function(e){e._maskIndex=this._allSpriteMasks.length,this._allSpriteMasks.add(e)},t.removeSpriteMask=function(e){var t=this._allSpriteMasks.deleteByIndex(e._maskIndex);t&&(t._maskIndex=e._maskIndex),e._maskIndex=-1},t.drawMask=function(t,n,r){var a=e.getMaskIncrementRenderQueue();a.clear();var i=e.getMaskDecrementRenderQueue();i.clear(),this._buildMaskRenderElement(r,a,i);var o=t.camera.engine._batcherManager;a.batch(o),o.uploadBuffer(),a.render(t,n,rU.Increment),i.batch(o),o.uploadBuffer(),i.render(t,n,rU.Decrement)},t.clearMask=function(t,n){var r=this._preMaskLayer;if(r!==rg.Nothing){if(this.hasStencilWritten){var a=e.getMaskDecrementRenderQueue();a.clear();for(var i=this._allSpriteMasks,o=0,s=i.length;o<s;o++){var l=i.get(o);l.influenceLayers&r&&a.pushRenderElement(l._renderElement)}var c=t.camera.engine._batcherManager;a.batch(c),c.uploadBuffer(),a.render(t,n,rU.Decrement)}else{var u=t.camera.engine;u._hardwareRenderer.clearRenderTarget(u,rw.Stencil,null)}this._preMaskLayer=rg.Nothing}},t.isStencilWritten=function(e){var t=e.renderState.stencilState,n=nk.Keep;return!!t.enabled&&0!==t.writeMask&&(t.passOperationFront!==n||t.passOperationBack!==n||t.failOperationFront!==n||t.failOperationBack!==n||t.zFailOperationFront!==n||t.zFailOperationBack!==n)},t.isReadStencil=function(e){var t=e.renderState.stencilState,n=t.enabled,r=t.mask,a=t.compareFunctionFront,i=t.compareFunctionBack;return!!n&&0!==r&&(a!==nB.Always&&a!==nB.Never||i!==nB.Always&&i!==nB.Never)},t.destroy=function(){var e=this._allSpriteMasks;e.length=0,e.garbageCollection()},t._buildMaskRenderElement=function(e,t,n){var r=this._preMaskLayer;if(r!==e){for(var a=this._allSpriteMasks,i=r&e,o=r&~e,s=a._elements,l=0,c=a.length;l<c;l++){var u=s[l],d=u.influenceLayers;!(d&i)&&(d&e?t.pushRenderElement(u._renderElement):d&o&&n.pushRenderElement(u._renderElement))}this._preMaskLayer=e}},e.getMaskIncrementRenderQueue=function(){return e._maskIncrementRenderQueue||(e._maskIncrementRenderQueue=new rG(nN.Transparent))},e.getMaskDecrementRenderQueue=function(){return e._maskDecrementRenderQueue||(e._maskDecrementRenderQueue=new rG(nN.Transparent))},e}(),i3=((eF={})[eF.None=0]="None",eF[eF.Linear=1]="Linear",eF[eF.Exponential=2]="Exponential",eF[eF.ExponentialSquared=3]="ExponentialSquared",eF),i4=((eL={})[eL.SolidColor=0]="SolidColor",eL[eL.SphericalHarmonics=1]="SphericalHarmonics",eL),i8=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._diffuseSolidColor=new tO(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=i4.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n}tW(t,e);var n=t.prototype;return n._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var n=e.shaderData;n.setColor(t._diffuseColorProperty,this._diffuseSolidColor),n.setFloat(t._diffuseIntensityProperty,this._diffuseIntensity),n.setFloat(t._specularIntensityProperty,this._specularIntensity),n.setFloatArray(t._diffuseSHProperty,this._shArray),this._setDiffuseMode(n),this._setSpecularTextureDecodeRGBM(n),this._setSpecularTexture(n)},n._removeFromScene=function(e){this._addReferCount(-1);var n=this._scenes,r=n.indexOf(e);n.splice(r,1);var a=e.shaderData;a.setTexture(t._specularTextureProperty,null),a.disableMacro(t._specularMacro)},n._setDiffuseMode=function(e){this._diffuseMode===i4.SphericalHarmonics?e.enableMacro(t._shMacro):e.disableMacro(t._shMacro)},n._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(t._specularTextureProperty,this._specularTexture),e.setFloat(t._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(t._specularMacro)):e.disableMacro(t._specularMacro)},n._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(t._decodeRGBMMacro):e.disableMacro(t._decodeRGBMMacro)},n._preComputeSH=function(e,t){var n=e.coefficients;t[0]=.886227*n[0],t[1]=.886227*n[1],t[2]=.886227*n[2],t[3]=-1.023327*n[3],t[4]=-1.023327*n[4],t[5]=-1.023327*n[5],t[6]=1.023327*n[6],t[7]=1.023327*n[7],t[8]=1.023327*n[8],t[9]=-1.023327*n[9],t[10]=-1.023327*n[10],t[11]=-1.023327*n[11],t[12]=.858086*n[12],t[13]=.858086*n[13],t[14]=.858086*n[14],t[15]=-.858086*n[15],t[16]=-.858086*n[16],t[17]=-.858086*n[17],t[18]=.247708*n[18],t[19]=.247708*n[19],t[20]=.247708*n[20],t[21]=-.858086*n[21],t[22]=-.858086*n[22],t[23]=-.858086*n[23],t[24]=.429042*n[24],t[25]=.429042*n[25],t[26]=.429042*n[26]},tG(t,[{key:"specularTextureDecodeRGBM",get:function(){return this._specularTextureDecodeRGBM},set:function(e){this._specularTextureDecodeRGBM=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTextureDecodeRGBM(t[n].shaderData)}},{key:"diffuseMode",get:function(){return this._diffuseMode},set:function(e){this._diffuseMode=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setDiffuseMode(t[n].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 n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloatArray(t._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var n=this._scenes,r=0,a=n.length;r<a;r++)n[r].shaderData.setFloat(t._diffuseIntensityProperty,e)}},{key:"specularTexture",get:function(){return this._specularTexture},set:function(e){this._specularTexture=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)this._setSpecularTexture(t[n].shaderData)}},{key:"specularIntensity",get:function(){return this._specularIntensity},set:function(e){this._specularIntensity=e;for(var n=0,r=this._scenes.length;n<r;n++)this._scenes[n].shaderData.setFloat(t._specularIntensityProperty,e)}}]),t}(t1);i8._shMacro=nH.getByName("SCENE_USE_SH"),i8._specularMacro=nH.getByName("SCENE_USE_SPECULAR_ENV"),i8._decodeRGBMMacro=nH.getByName("SCENE_IS_DECODE_ENV_RGBM"),i8._diffuseColorProperty=nY.getByName("scene_EnvMapLight.diffuse"),i8._diffuseSHProperty=nY.getByName("scene_EnvSH"),i8._diffuseIntensityProperty=nY.getByName("scene_EnvMapLight.diffuseIntensity"),i8._specularTextureProperty=nY.getByName("scene_EnvSpecularSampler"),i8._specularIntensityProperty=nY.getByName("scene_EnvMapLight.specularIntensity"),i8._mipLevelProperty=nY.getByName("scene_EnvMapLight.mipMapLevel");var i5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.intensity=1,t.cullingMask=rE.Everything,t.shadowType=rj.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t._lightIndex=-1,t._lightColor=new tO,t._shadowStrength=1,t._color=new tO(1,1,1,1),t}return tW(t,e),t.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},tG(t,[{key:"shadowStrength",get:function(){return this._shadowStrength},set:function(e){this._shadowStrength=tS.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 tL),tL.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new tL),tL.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),t}(ru);tX([tq],i5.prototype,"_lightIndex",void 0);var i9=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shadowNearPlaneOffset=.1,t._reverseDirection=new tT,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.direction,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.direction[a]=o.x,t.direction[a+1]=o.y,t.direction[a+2]=o.z},n._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._directionProperty,n.direction)},tG(t,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}}]),t}(i5);i9._cullingMaskProperty=nY.getByName("scene_DirectLightCullingMask"),i9._colorProperty=nY.getByName("scene_DirectLightColor"),i9._directionProperty=nY.getByName("scene_DirectLightDirection");var i6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=this._getLightIntensityColor(),o=this.position,s=this.cullingMask;t.cullingMask[n]=65535&s,t.cullingMask[n+1]=s>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(i.r),t.color[r+1]=tO.gammaToLinearSpace(i.g),t.color[r+2]=tO.gammaToLinearSpace(i.b)):(t.color[r]=i.r,t.color[r+1]=i.g,t.color[r+2]=i.b),t.position[a]=o.x,t.position[a+1]=o.y,t.position[a+2]=o.z,t.distance[e]=this.distance},n._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._distanceProperty,n.distance)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}}]),t}(i5);i6._cullingMaskProperty=nY.getByName("scene_PointLightCullingMask"),i6._colorProperty=nY.getByName("scene_PointLightColor"),i6._positionProperty=nY.getByName("scene_PointLightPosition"),i6._distanceProperty=nY.getByName("scene_PointLightDistance");var i7=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.distance=100,t.angle=Math.PI/6,t.penumbra=Math.PI/12,t._inverseDirection=new tT,t._projectMatrix=new tL,t}tW(t,e);var n=t.prototype;return n._appendData=function(e,t){var n=2*e,r=3*e,a=3*e,i=3*e,o=this._getLightIntensityColor(),s=this.position,l=this.direction,c=this.cullingMask;t.cullingMask[n]=65535&c,t.cullingMask[n+1]=c>>>16&65535,this.engine.settings.colorSpace===n2.Linear?(t.color[r]=tO.gammaToLinearSpace(o.r),t.color[r+1]=tO.gammaToLinearSpace(o.g),t.color[r+2]=tO.gammaToLinearSpace(o.b)):(t.color[r]=o.r,t.color[r+1]=o.g,t.color[r+2]=o.b),t.position[a]=s.x,t.position[a+1]=s.y,t.position[a+2]=s.z,t.direction[i]=l.x,t.direction[i+1]=l.y,t.direction[i+2]=l.z,t.distance[e]=this.distance,t.angleCos[e]=Math.cos(this.angle),t.penumbraCos[e]=Math.cos(this.angle+this.penumbra)},n._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},n._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},t._updateShaderData=function(e,n){e.setIntArray(t._cullingMaskProperty,n.cullingMask),e.setFloatArray(t._colorProperty,n.color),e.setFloatArray(t._positionProperty,n.position),e.setFloatArray(t._directionProperty,n.direction),e.setFloatArray(t._distanceProperty,n.distance),e.setFloatArray(t._angleCosProperty,n.angleCos),e.setFloatArray(t._penumbraCosProperty,n.penumbraCos)},tG(t,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return tT.scale(this.direction,-1,this._inverseDirection),this._inverseDirection}}]),t}(i5);i7._cullingMaskProperty=nY.getByName("scene_SpotLightCullingMask"),i7._colorProperty=nY.getByName("scene_SpotLightColor"),i7._positionProperty=nY.getByName("scene_SpotLightPosition"),i7._directionProperty=nY.getByName("scene_SpotLightDirection"),i7._distanceProperty=nY.getByName("scene_SpotLightDistance"),i7._angleCosProperty=nY.getByName("scene_SpotLightAngleCos"),i7._penumbraCosProperty=nY.getByName("scene_SpotLightPenumbraCos");var oe=/*#__PURE__*/function(){function e(){this._spotLights=new rC,this._pointLights=new rC,this._directLights=new rC,this._directData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight)},this._pointData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight)},this._spotData={cullingMask:new Int32Array(2*e._maxLight),color:new Float32Array(3*e._maxLight),position:new Float32Array(3*e._maxLight),direction:new Float32Array(3*e._maxLight),distance:new Float32Array(e._maxLight),angleCos:new Float32Array(e._maxLight),penumbraCos:new Float32Array(e._maxLight)}}var t=e.prototype;return t._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},t._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},t._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},t._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},t._updateShaderData=function(t){for(var n=this._spotLights,r=this._pointLights,a=this._directLights,i=this._spotData,o=this._pointData,s=this._directData,l=e._maxLight,c=Math.min(n.length,l),u=Math.min(r.length,l),d=Math.min(a.length,l),h=0;h<c;h++)n.get(h)._appendData(h,i);for(var _=0;_<u;_++)r.get(_)._appendData(_,o);for(var f=0;f<d;f++)a.get(f)._appendData(f,s);d?(i9._updateShaderData(t,s),t.enableMacro("SCENE_DIRECT_LIGHT_COUNT",d.toString())):t.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),u?(i6._updateShaderData(t,o),t.enableMacro("SCENE_POINT_LIGHT_COUNT",u.toString())):t.disableMacro("SCENE_POINT_LIGHT_COUNT"),c?(i7._updateShaderData(t,i),t.enableMacro("SCENE_SPOT_LIGHT_COUNT",c.toString())):t.disableMacro("SCENE_SPOT_LIGHT_COUNT")},t._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},t._updateSunlightIndex=function(e){var t=this._directLights,n=e._lightIndex;if(n>0){var r=t.get(0),a=t.get(n);t.set(0,a),t.set(n,r),a._lightIndex=0,r._lightIndex=n}},t._getMaxBrightestSunlight=function(){for(var e=this._directLights,t=null,n=Number.NEGATIVE_INFINITY,r=!1,a=0,i=e.length;a<i;a++){var o=e.get(a);o.shadowType===rj.None||r||(n=Number.NEGATIVE_INFINITY,r=!0);var s=o.intensity*o.color.getBrightness();r?o.shadowType!==rj.None&&n<s&&(n=s,t=o):n<s&&(n=s,t=o)}return t},e}();oe._sunlightColorProperty=nY.getByName("scene_SunlightColor"),oe._sunlightDirectionProperty=nY.getByName("scene_SunlightDirection"),oe._maxLight=10;var ot=((eD={})[eD.Half=0]="Half",eD[eD.Quarter=1]="Quarter",eD),on=/*#__PURE__*/function(){function e(t){this._uberMaterial=t,this._highQualityFiltering=!1,this._mipDownRT=[],this._mipUpRT=[],this._maxIterations=6,this._enabled=!1,this.downScale=0;var n=new ao(t.engine,ro.find(e.SHADER_NAME)),r=n.renderState.depthState;r.enabled=!1,r.writeEnabled=!1;var a=n.shaderData,i=t.shaderData;a.setVector4(e._bloomParams,new tI),a.setVector4(e._lowMipTexelSizeProp,new tI),i.setVector4(e._bloomIntensityParams,new tI(1,1,0,0)),i.setVector4(e._dirtTilingOffsetProp,new tI),i.setColor(e._tintProp,new tO(1,1,1,1)),this._bloomMaterial=n,this.threshold=.9,this.scatter=.7,this.intensity=1,this.dirtIntensity=1}var t=e.prototype;return t.onRender=function(e,t){var n=e.camera,r=0===this.downScale?1:2,a=n.pixelViewport,i=a.width>>r,o=a.height>>r,s=this._calculateMipCount(i,o);this._prefilter(n,t,i,o,s),this._downsample(s),this._upsample(s),this._setupUber(n)},t._calculateMipCount=function(e,t){return Math.min(Math.max(Math.floor(Math.log2(Math.max(e,t))-1),1),this._maxIterations)},t._prefilter=function(e,t,n,r,a){for(var i=this._uberMaterial.engine,o=e._getInternalColorTextureFormat(),s=n,l=r,c=0;c<a;c++)this._mipUpRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipUpRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),this._mipDownRT[c]=rR.recreateRenderTargetIfNeeded(i,this._mipDownRT[c],s,l,o,null,!1,!1,1,t7.Clamp,t5.Bilinear),s=Math.max(1,Math.floor(s/2)),l=Math.max(1,Math.floor(l/2));rR.blitTexture(i,t,this._mipDownRT[0],void 0,void 0,this._bloomMaterial,0)},t._downsample=function(e){for(var t=this._bloomMaterial,n=t.engine,r=this._mipDownRT[0],a=1;a<e;a++)rR.blitTexture(n,r.getColorTexture(0),this._mipUpRT[a],void 0,void 0,t,1),rR.blitTexture(n,this._mipUpRT[a].getColorTexture(0),this._mipDownRT[a],void 0,void 0,t,2),r=this._mipDownRT[a]},t._upsample=function(t){for(var n=this._bloomMaterial,r=n.engine,a=n.shaderData,i=t-2;i>=0;i--){var o=i==t-2?this._mipDownRT[i+1]:this._mipUpRT[i+1],s=this._mipDownRT[i],l=this._mipUpRT[i];a.setTexture(e._lowMipTextureProp,o.getColorTexture(0)),this.highQualityFiltering&&a.getVector4(e._lowMipTexelSizeProp).set(1/o.width,1/o.height,o.width,o.height),rR.blitTexture(r,s.getColorTexture(0),l,void 0,void 0,n,3)}},t._setupUber=function(t){var n=this._uberMaterial.shaderData,r=this.dirtTexture;if(r){var a=n.getVector4(e._dirtTilingOffsetProp),i=r.width/r.height,o=t.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)}n.setTexture(e._bloomTextureProp,this._mipUpRT[0].getColorTexture(0))},t._releaseRenderTargets=function(){for(var e=this._mipDownRT.length,t=0;t<e;t++){var n=this._mipDownRT[t],r=this._mipUpRT[t];n&&(n.getColorTexture(0).destroy(!0),n.destroy(!0)),r&&(r.getColorTexture(0).destroy(!0),r.destroy(!0))}this._mipDownRT.length=0,this._mipUpRT.length=0},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):(this._uberMaterial.shaderData.disableMacro(e._enableMacro),this._releaseRenderTargets()))}},{key:"threshold",get:function(){return this._threshold},set:function(t){if((t=Math.max(0,t))!==this._threshold){this._threshold=t;var n=tO.gammaToLinearSpace(t),r=.5*n,a=this._bloomMaterial.shaderData.getVector4(e._bloomParams);a.x=n,a.y=r}}},{key:"scatter",get:function(){return this._scatter},set:function(t){if((t=tS.clamp(t,0,1))!==this._scatter){this._scatter=t;var n=this._bloomMaterial.shaderData.getVector4(e._bloomParams),r=tS.lerp(.05,.95,t);n.z=r}}},{key:"intensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).x=t}},{key:"tint",get:function(){return this._uberMaterial.shaderData.getColor(e._tintProp)},set:function(t){var n=this._uberMaterial.shaderData.getColor(e._tintProp);t!==n&&n.copyFrom(t)}},{key:"highQualityFiltering",get:function(){return this._highQualityFiltering},set:function(t){t!==this._highQualityFiltering&&(this._highQualityFiltering=t,t?(this._bloomMaterial.shaderData.enableMacro(e._hqMacro),this._uberMaterial.shaderData.enableMacro(e._hqMacro)):(this._bloomMaterial.shaderData.disableMacro(e._hqMacro),this._uberMaterial.shaderData.disableMacro(e._hqMacro)))}},{key:"dirtTexture",get:function(){return this._uberMaterial.shaderData.getTexture(e._dirtTextureProp)},set:function(t){this._uberMaterial.shaderData.setTexture(e._dirtTextureProp,t),t?this._uberMaterial.shaderData.enableMacro(e._dirtMacro):this._uberMaterial.shaderData.disableMacro(e._dirtMacro)}},{key:"dirtIntensity",get:function(){return this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y},set:function(t){t=Math.max(0,t),this._uberMaterial.shaderData.getVector4(e._bloomIntensityParams).y=t}}]),e}();on.SHADER_NAME="PostProcessEffect Bloom",on._hqMacro=nH.getByName("BLOOM_HQ"),on._dirtMacro=nH.getByName("BLOOM_DIRT"),on._bloomParams=nY.getByName("material_BloomParams"),on._lowMipTextureProp=nY.getByName("material_lowMipTexture"),on._lowMipTexelSizeProp=nY.getByName("material_lowMipTexelSize"),on._enableMacro=nH.getByName("ENABLE_EFFECT_BLOOM"),on._bloomTextureProp=nY.getByName("material_BloomTexture"),on._dirtTextureProp=nY.getByName("material_BloomDirtTexture"),on._tintProp=nY.getByName("material_BloomTint"),on._bloomIntensityParams=nY.getByName("material_BloomIntensityParams"),on._dirtTilingOffsetProp=nY.getByName("material_BloomDirtTilingOffset"),ro.create(on.SHADER_NAME,[new n6("Bloom Prefilter",ij,"#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 n6("Bloom Blur Horizontal",ij,"#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 n6("Bloom Blur Vertical",ij,"#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 n6("Bloom Upsample",ij,"#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}")]);var or=((eB={})[eB.Neutral=0]="Neutral",eB[eB.ACES=1]="ACES",eB),oa=/*#__PURE__*/function(){function e(e){this._uberMaterial=e,this._enabled=!1,this.mode=0}return tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(t){t!==this._enabled&&(this._enabled=t,t?this._uberMaterial.shaderData.enableMacro(e._enableMacro):this._uberMaterial.shaderData.disableMacro(e._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()))}}]),e}();oa._enableMacro=nH.getByName("ENABLE_EFFECT_TONEMAPPING");var oi=/*#__PURE__*/function(){function e(t){this.scene=t,this.isActive=!0;var n=ro.find(e.UBER_SHADER_NAME),r=new ao(t.engine,n),a=r.renderState.depthState;a.enabled=!1,a.writeEnabled=!1;var i=new on(r),o=new oa(r);this._uberMaterial=r,this._bloomEffect=i,this._tonemappingEffect=o}return e.prototype._render=function(e,t,n){var r=e.camera,a=r.engine;t._blitRenderTarget();var i=t.getColorTexture(),o=this._bloomEffect;o.enabled&&o.onRender(e,i),rR.blitTexture(a,i,n,0,r.viewport,this._uberMaterial)},tG(e,[{key:"hasActiveEffect",get:function(){return this.isActive&&(this._bloomEffect.enabled||this._tonemappingEffect.enabled)}}]),e}();oi.UBER_SHADER_NAME="UberPost",Object.assign(nZ,{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;}"}),ro.create(oi.UBER_SHADER_NAME,ij,"#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 oo=/*#__PURE__*/function(e){function t(n,r){(a=e.call(this,n)||this).physics=new ip(a),a.castShadows=!0,a.shadowResolution=rW.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new tT(1/15,.2,7/15),a.shadowDistance=50,a.shadowFadeBorder=.1,a._lightManager=new oe,a._componentsManager=new i1,a._maskManager=new i2,a._isActiveInEngine=!1,a._globalShaderMacro=new nW,a._rootEntities=[],a._postProcessManager=new oi(a),a._background=new i0(a._engine),a._shaderData=new rs(n8.Scene),a._shadowCascades=rK.NoCascades,a._fogMode=i3.None,a._fogColor=new tO(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new tI,a._isActive=!0,a._enableTransparentShadow=!1,a.name=r||"";var a,i=a.shaderData;return i._addReferCount(1),a.ambientLight=new i8(n),n.sceneManager._allCreatedScenes.push(a),i.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),i.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),i.setColor(t._fogColorProperty,a._fogColor),i.setVector4(t._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}tW(t,e);var n=t.prototype;return n.createRootEntity=function(e){var t=new aW(this._engine,e);return this.addRootEntity(t),t},n.addRootEntity=function(e,t){"number"==typeof e?n=e:(n=void 0,t=e);var n,r=t._isRoot;r||(t._isRoot=!0,t._removeFromParent(),t._setTransformDirty());var a=t._scene;a!==this?(a&&r&&a._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var i=rc.None;t._isActiveInHierarchy&&(this._isActiveInEngine||(i|=rc.Hierarchy)),t._isActiveInScene&&a!==this&&(i|=rc.Scene),i&&t._processInActive(i),a!==this&&aW._traverseSetOwnerScene(t,this);var o=rc.None;t._isActive&&(this._isActiveInEngine&&(t._isActiveInHierarchy||(o|=rc.Hierarchy)),t._isActiveInScene&&a===this||(o|=rc.Scene)),o&&t._processActive(o)},n.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=rc.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=rc.Hierarchy),e._isActiveInScene&&(t|=rc.Scene),t&&e._processInActive(t),aW._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,n=0,r=t.length;n<r;n++){var a=t[n].findByName(e);if(a)return a}return null},n.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),n=0,r=this.rootEntitiesCount;n<r;n++){var a=this.getRootEntity(n);if(a.name==t[0]){for(var i=1,o=t.length;i<o&&(a=aW._findChildByName(a,t[i]));++i);return a}}return null},n._processActive=function(e){this._isActiveInEngine=e;for(var t=this._rootEntities,n=t.length-1;n>=0;n--){var r=t[n];r._isActive&&(e?r._processActive(rc.Hierarchy):r._processInActive(rc.Hierarchy))}},n._updateShaderData=function(){var e=this.shaderData,t=this._engine,n=this._lightManager;t.time._updateSceneShaderData(e),n._updateShaderData(this.shaderData);var r=this._lightManager._sunlight=this._getSunlight();r?(n._updateSunlightIndex(r),e.setColor(oe._sunlightColorProperty,r._lightColor),e.setVector3(oe._sunlightDirectionProperty,r.direction)):e.setVector3(oe._sunlightDirectionProperty,tT._zero),this.castShadows&&r&&r.shadowType!==rj.None?e.enableMacro("SCENE_SHADOW_TYPE",r.shadowType.toString()):e.disableMacro("SCENE_SHADOW_TYPE"),nW.unionCollection(this.engine._macroCollection,e._macroCollection,this._globalShaderMacro)},n._removeFromEntityList=function(e){var t=this._rootEntities,n=e._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;e._siblingIndex=-1},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this._engine.sceneManager;for(t.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 n=t._allCreatedScenes;n.splice(n.indexOf(this),1)},n._addToRootEntityList=function(e,t){var n=this._rootEntities,r=n.length;if(void 0===e)t._siblingIndex=r,n.push(t);else{if(e<0||e>r)throw"The index "+e+" is out of child list bounds "+r;t._siblingIndex=e,n.splice(e,0,t);for(var a=e+1,i=r+1;a<i;a++)n[a]._siblingIndex++}},n._computeLinearFogParams=function(e,t){var n=t-e,r=this._fogParams;r.x=-1/n,r.y=t/n},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()},tG(t,[{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){no.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"))}}]),t}(t0);oo._fogColorProperty=nY.getByName("scene_FogColor"),oo._fogParamsProperty=nY.getByName("scene_FogParams");var os=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._started=!1,t._onStartIndex=-1,t._onUpdateIndex=-1,t._onLateUpdateIndex=-1,t._onPhysicsUpdateIndex=-1,t._onPreRenderIndex=-1,t._onPostRenderIndex=-1,t._entityScriptsIndex=-1,t}tW(t,e);var n=t.prototype;return n.onAwake=function(){},n.onEnable=function(){},n.onStart=function(){},n.onUpdate=function(e){},n.onLateUpdate=function(e){},n.onBeginRender=function(e){},n.onEndRender=function(e){},n.onPhysicsUpdate=function(){},n.onTriggerEnter=function(e){},n.onTriggerExit=function(e){},n.onTriggerStay=function(e){},n.onCollisionEnter=function(e){},n.onCollisionExit=function(e){},n.onCollisionStay=function(e){},n.onPointerDown=function(e){},n.onPointerUp=function(e){},n.onPointerClick=function(e){},n.onPointerEnter=function(e){},n.onPointerExit=function(e){},n.onPointerDrag=function(e){},n.onDisable=function(){},n.onDestroy=function(){},n._onAwake=function(){this.onAwake()},n._onEnable=function(){this.onEnable()},n._onDisable=function(){this.onDisable()},n._onEnableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.addOnStartScript(this),this.onUpdate!==n.onUpdate&&e.addOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.addOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.addOnPhysicsUpdateScript(this),this._entity._addScript(this)},n._onDisableInScene=function(){var e=this.scene._componentsManager,n=t.prototype;this._started||e.removeOnStartScript(this),this.onUpdate!==n.onUpdate&&e.removeOnUpdateScript(this),this.onLateUpdate!==n.onLateUpdate&&e.removeOnLateUpdateScript(this),this.onPhysicsUpdate!==n.onPhysicsUpdate&&e.removeOnPhysicsUpdateScript(this),this._entity._removeScript(this)},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.scene?this.scene._componentsManager.addPendingDestroyScript(this):this.onDestroy()},t}(ru);tX([tq],os.prototype,"_started",void 0),tX([tq],os.prototype,"_onStartIndex",void 0),tX([tq],os.prototype,"_onUpdateIndex",void 0),tX([tq],os.prototype,"_onLateUpdateIndex",void 0),tX([tq],os.prototype,"_onPhysicsUpdateIndex",void 0),tX([tq],os.prototype,"_onPreRenderIndex",void 0),tX([tq],os.prototype,"_onPostRenderIndex",void 0),tX([tq],os.prototype,"_entityScriptsIndex",void 0);var ol=/*#__PURE__*/function(){function e(e){this.useCache=e}return e.registerClass=function(e,t){this._engineObjects[e]=t,this._classNameMap.set(t,e)},e.getClass=function(e){return this._engineObjects[e]},e.getClassName=function(e){return this._classNameMap.get(e)},e}();ol._engineObjects={},ol._classNameMap=new Map;var oc=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){var t=e.component,n=e.property.split(".");if(e.getProperty){var r=e.getProperty.split(".");this._initializeMounted(t,r,1),this._initializeMounted(t,n,2)}else this._initializeMounted(t,n,3)},t.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]}},t.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}},t._initializeMounted=function(e,t,n){for(var r,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("[");r=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}),r=1,2&n){var p=o.indexOf("$value");this._replaceValueIndex=p>-1?p:o.length}}else r=0;2&n&&(this._setMounted=e,this._setType=r,this._setArrayIndex=a,this._setValueName=_,i&&(this._setValueName=i),this._setArgs=o),1&n&&(this._getMounted=e,this._getType=r,this._getArrayIndex=a,this._getValueName=_,i&&(this._getValueName=i),this._getArgs=o)},e}(),ou=/*#__PURE__*/function(){function e(t,n,r,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=r,this.cureType=o;var s=e.getAssemblerType(n,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,n){return n?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,n,r,a,i){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(t,r,!1);var o=e&&e.keys.length?i?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):i?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?i?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):i?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,a)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){if(!this.cureType._supportInterpolationMode)return this.evaluateValue(e,t,!1);var a=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,i=e&&e.keys.length?r?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):r?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(a,i,n)},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,n){var r=this.cureType;if(n){var a=this._assembler;if(r._isCopyMode)r._additiveValue(e,t,this.referenceTargetValue);else{var i=a.getTargetValue(),o=r._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)r._isCopyMode?r._setValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(r._isCopyMode){var s=this.referenceTargetValue;r._lerpValue(s,e,t,s)}else{var l=this._assembler.getTargetValue(),c=r._lerpValue(l,e,t);this._assembler.setTargetValue(c)}},t._lerpValue=function(e,t,n){return this.cureType._isCopyMode?this.cureType._lerpValue(e,t,n,this.baseEvaluateData.value):(this.baseEvaluateData.value=this.cureType._lerpValue(e,t,n),this.baseEvaluateData.value)},e.registerAssembler=function(t,n,r){var a=e._assemblerMap.get(t);a||(a={},e._assemblerMap.set(t,a)),a[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),a=r?r[n]:void 0;return null!=a?a:oc},e}();ou._components=[],ou._assemblerMap=new Map;var od=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.position},t.setTargetValue=function(e){this._transform.position=e},e}();ou.registerAssembler(rp,"position",od);var oh=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.rotationQuaternion},t.setTargetValue=function(e){this._transform.rotationQuaternion=e},e}();ou.registerAssembler(rp,"rotationQuaternion",oh);var o_=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._transform=e.target.transform},t.getTargetValue=function(){return this._transform.scale},t.setTargetValue=function(e){this._transform.scale=e},e}();ou.registerAssembler(rp,"scale",o_);var of=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.initialize=function(e){this._skinnedMeshRenderer=e.component},t.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},t.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},e}();ou.registerAssembler(aK,"blendShapeWeights",of);var op=/*#__PURE__*/function(){function e(){this.crossCurveMark=0,this.isActive=!0}var t=e.prototype;return t.initFinalValue=function(){var e=this.curveOwner,t=e.cureType,n=e.defaultValue;t._isCopyMode?t._setValue(n,this.finalValue):this.finalValue=n},t.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},e}(),om=/*#__PURE__*/function(){function e(){this.typeIndex=0,this._tempCurveOwner={}}var t=e.prototype;return t._createCurveOwner=function(e,t){var n=this.curve.constructor,r=new ou(e,this.type,t,this.property,this.getProperty,n);return n._initializeOwner(r),r.saveDefaultValue(),r},t._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new op;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},t._getTempCurveOwner=function(e,t){var n=e.instanceId;return this._tempCurveOwner[n]||(this._tempCurveOwner[n]=this._createCurveOwner(e,t)),this._tempCurveOwner[n]},e}(),og=function(){},ov=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,null)||this).name=t,n._curveBindings=[],n._updateFlagManager=new nM,n._length=0,n._events=[],n}tW(t,e);var n=t.prototype;return n.addEvent=function(e,t,n){if("string"==typeof e){var r,a=new og;a.functionName=e,a.time=t,a.parameter=n,r=a}else r=e;var i=this._events,o=i.length,s=r.time;if(s>=(o?i[o-1].time:0))i.push(r);else{for(var l=o;--l>=0&&s<i[l].time;);i.splice(l+1,0,r)}this._updateFlagManager.dispatch()},n.clearEvents=function(){this._events.length=0,this._updateFlagManager.dispatch()},n.addCurveBinding=function(e,t,n,r,a,i){var o=new om;o.relativePath=e,o.type=t,"number"==typeof n?(o.typeIndex=n,o.property=r,"string"==typeof a?(o.getProperty=a,o.curve=i):o.curve=a):(o.property=n,"string"==typeof r?(o.getProperty=r,o.curve=a):o.curve=r),this._length=Math.max(this._length,o.curve.length),this._curveBindings.push(o)},n.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},n._sampleAnimation=function(e,t){for(var n=this._curveBindings,r=n.length-1;r>=0;r--){var a=n[r],i=e.findByPath(a.relativePath);if(i){var o=a.typeIndex>0?i.getComponents(a.type,ou._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)}}}},tG(t,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),t}(t0),oy=((eI={})[eI.Linear=0]="Linear",eI[eI.CubicSpine=1]="CubicSpine",eI[eI.Step=2]="Step",eI[eI.Hermite=3]="Hermite",eI),ox=/*#__PURE__*/function(){function e(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var e=this.constructor;this._interpolation=e._supportInterpolationMode?oy.Linear:oy.Step,this._type=e}var t=e.prototype;return t.addKey=function(e){var t=e.time,n=this.keys;if(t>=this._length)n.push(e),this._length=t;else{for(var r=n.length;--r>=0&&t<n[r].time;);n.splice(r+1,0,e)}},t.evaluate=function(e){return this._evaluate(e,this._evaluateData)},t.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,n=0,r=t.length-1;r>=0;r--){var a=t[r];a.time>this._length&&(n=a.time)}this._length=n},t._evaluate=function(e,t){var n,r=this.keys.length;if(!r){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,i=this.interpolation,o=t.curKeyframeIndex;-1!==o&&(o>=r||e<a[o].time)&&(o=-1);for(var s=o+1;s<r&&!(e<a[s].time);)o++,s++;if(t.curKeyframeIndex=o,-1===o)n=this._type._setValue(a[0].value,t.value);else if(s===r)n=this._type._setValue(a[o].value,t.value);else{var l=a[o],c=a[s],u=l.time,d=c.time-u,h=(e-u)/d;switch(i){case oy.Linear:n=this._type._lerpValue(l.value,c.value,h,t.value);break;case oy.Step:n=this._type._setValue(l.value,t.value);break;case oy.CubicSpine:case oy.Hermite:n=this._type._hermiteInterpolationValue(l,c,h,d,t.value)}}return t.value=n,n},t._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},tG(e,[{key:"interpolation",get:function(){return this._interpolation},set:function(e){this._type._supportInterpolationMode||e===oy.Step?this._interpolation=e:(this._interpolation=oy.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),e}();e.AnimationArrayCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=[],t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},t._initializeLayerOwner=function(e){e.finalValue=[]},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationArrayCurve._isCopyMode=!0,e.AnimationArrayCurve._supportInterpolationMode=!0,e.AnimationArrayCurve=tX([ry()],e.AnimationArrayCurve),e.AnimationBoolCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=!1,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},t._initializeLayerOwner=function(e){e.finalValue=!1},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return!1},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationBoolCurve._isCopyMode=!1,e.AnimationBoolCurve._supportInterpolationMode=!1,e.AnimationBoolCurve=tX([ry()],e.AnimationBoolCurve),e.AnimationColorCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tO,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tO,e.fixedPoseValue=new tO,e.baseEvaluateData.value=new tO,e.crossEvaluateData.value=new tO},t._initializeLayerOwner=function(e){e.finalValue=new tO},t._lerpValue=function(e,t,n,r){return tO.lerp(e,t,n,r),r},t._subtractValue=function(e,t,n){return tO.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._additiveValue=function(e,t,n){return tO.scale(e,t,e),tO.add(n,e,n),n},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+f*s.a:a.a=i.a,a},t}(ox),e.AnimationColorCurve._isCopyMode=!0,e.AnimationColorCurve._supportInterpolationMode=!0,e.AnimationColorCurve=tX([ry()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return tW(t,e),t.prototype.addKey=function(t){e.prototype.addKey.call(this,t);var n=this._evaluateData;if(!n.value||n.value.length!==t.value.length){var r=t.value.length;n.value=new Float32Array(r)}},t._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)},t._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},t._lerpValue=function(e,t,n,r){for(var a=0,i=r.length;a<i;++a){var o=e[a];r[a]=o+(t[a]-o)*n}return r},t._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},t._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},t._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},t._setValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},t._hermiteInterpolationValue=function(e,t,n,r,a){for(var i=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},t}(ox),e.AnimationFloatArrayCurve._isCopyMode=!0,e.AnimationFloatArrayCurve._supportInterpolationMode=!0,e.AnimationFloatArrayCurve=tX([ry()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=0,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},t._initializeLayerOwner=function(e){e.finalValue=0},t._lerpValue=function(e,t,n){return e+(t-e)*n},t._additiveValue=function(e,t,n){return n+e*t},t._subtractValue=function(e,t){return e-t},t._getZeroValue=function(){return 0},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e,t,n,r){var a=e.outTangent,i=t.inTangent;if(!(Number.isFinite(a)&&Number.isFinite(i)))return e.value;var o=n*n,s=o*n;return(2*s-3*o+1)*e.value+(s-2*o+n)*a*r+(s-o)*i*r+(-2*s+3*o)*t.value},t}(ox),e.AnimationFloatCurve._isCopyMode=!1,e.AnimationFloatCurve._supportInterpolationMode=!0,e.AnimationFloatCurve=tX([ry()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tF,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tF,e.fixedPoseValue=new tF,e.baseEvaluateData.value=new tF,e.crossEvaluateData.value=new tF},t._initializeLayerOwner=function(e){e.finalValue=new tF},t._lerpValue=function(e,t,n,r){return tF.slerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return e.x=e.x*t,e.y=e.y*t,e.z=e.z*t,e.normalize(),n.multiply(e),n},t._subtractValue=function(e,n,r){var a=t._tempConjugateQuat;return tF.conjugate(n,a),tF.multiply(a,e,r),r},t._getZeroValue=function(e){return e.set(0,0,0,1),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationQuaternionCurve._supportInterpolationMode=!0,e.AnimationQuaternionCurve._isCopyMode=!0,e.AnimationQuaternionCurve._tempConjugateQuat=new tF,e.AnimationQuaternionCurve=tX([ry()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tB,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tB,e.fixedPoseValue=new tB,e.baseEvaluateData.value=new tB,e.crossEvaluateData.value=new tB},t._initializeLayerOwner=function(e){e.finalValue=new tB},t._lerpValue=function(e,t,n,r){return tB.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tB.scale(e,t,e),tB.add(n,e,n),n},t._subtractValue=function(e,t,n){return tB.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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*r+_*m*r+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*r+_*m*r+f*s.y:a.y=i.y,a},t}(ox),e.AnimationVector2Curve._isCopyMode=!0,e.AnimationVector2Curve._supportInterpolationMode=!0,e.AnimationVector2Curve=tX([ry()],e.AnimationVector2Curve),e.AnimationVector3Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tT,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tT,e.fixedPoseValue=new tT,e.baseEvaluateData.value=new tT,e.crossEvaluateData.value=new tT},t._initializeLayerOwner=function(e){e.finalValue=new tT},t._lerpValue=function(e,t,n,r){return tT.lerp(e,t,n,r),r},t._relativeBaseValue=function(e,t){return tT.subtract(t,e,t),t},t._additiveValue=function(e,t,n){return tT.scale(e,t,e),tT.add(n,e,n),n},t._subtractValue=function(e,t,n){return tT.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+f*s.z:a.z=i.z,a},t}(ox),e.AnimationVector3Curve._isCopyMode=!0,e.AnimationVector3Curve._supportInterpolationMode=!0,e.AnimationVector3Curve=tX([ry()],e.AnimationVector3Curve),e.AnimationVector4Curve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tI,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tI,e.fixedPoseValue=new tI,e.baseEvaluateData.value=new tI,e.crossEvaluateData.value=new tI},t._initializeLayerOwner=function(e){e.finalValue=new tI},t._lerpValue=function(e,t,n,r){return tI.lerp(e,t,n,r),r},t._additiveValue=function(e,t,n){return tI.scale(e,t,e),tI.add(n,e,n),n},t._subtractValue=function(e,t,n){return tI.subtract(e,t,n),n},t._getZeroValue=function(e){return e.set(0,0,0,0),e},t._setValue=function(e,t){return t.copyFrom(e),t},t._hermiteInterpolationValue=function(e,t,n,r,a){var i=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,d=2*u-3*c+1,h=u-2*c+n,_=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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+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*r+_*m*r+f*s.w:a.w=i.w,a},t}(ox),e.AnimationVector4Curve._isCopyMode=!0,e.AnimationVector4Curve._supportInterpolationMode=!0,e.AnimationVector4Curve=tX([ry()],e.AnimationVector4Curve),e.AnimationRefCurve=/*#__PURE__*/function(e){function t(){return e.call(this)||this}return tW(t,e),t._initializeOwner=function(e){},t._initializeLayerOwner=function(e){},t._setValue=function(e){return e},t}(ox),e.AnimationRefCurve._isCopyMode=!1,e.AnimationRefCurve._supportInterpolationMode=!1,e.AnimationRefCurve=tX([ry()],e.AnimationRefCurve),e.AnimationRectCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value=new tN,t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue=new tN,e.fixedPoseValue=new tN,e.baseEvaluateData.value=new tN,e.crossEvaluateData.value=new tN},t._initializeLayerOwner=function(e){e.finalValue=new tN},t._setValue=function(e,t){return t.copyFrom(e),t},t}(ox),e.AnimationRectCurve._isCopyMode=!0,e.AnimationRectCurve._supportInterpolationMode=!1,e.AnimationRectCurve=tX([ry()],e.AnimationRectCurve),e.AnimationStringCurve=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this)._evaluateData.value="",t}return tW(t,e),t._initializeOwner=function(e){e.defaultValue="",e.fixedPoseValue="",e.baseEvaluateData.value="",e.crossEvaluateData.value=""},t._initializeLayerOwner=function(e){e.finalValue=""},t._lerpValue=function(e,t){return e},t._subtractValue=function(e,t,n){return e},t._getZeroValue=function(){return""},t._additiveValue=function(e,t,n){return e},t._setValue=function(e){return e},t._hermiteInterpolationValue=function(e){return e.value},t}(ox),e.AnimationStringCurve._isCopyMode=!1,e.AnimationStringCurve._supportInterpolationMode=!1,e.AnimationStringCurve=tX([ry()],e.AnimationStringCurve);var ob=((eO={})[eO.If=0]="If",eO[eO.IfNot=1]="IfNot",eO[eO.Greater=2]="Greater",eO[eO.Less=3]="Less",eO[eO.Equals=4]="Equals",eO[eO.NotEquals=5]="NotEquals",eO),oC=((eN={})[eN.None=0]="None",eN[eN.Complete=1]="Complete",eN),oS=((eV={})[eV.Override=0]="Override",eV[eV.Additive=1]="Additive",eV),oT=((ek={})[ek.UnStarted=0]="UnStarted",ek[ek.Playing=1]="Playing",ek[ek.Finished=2]="Finished",ek),oA=((ez={})[ez.Standby=0]="Standby",ez[ez.Playing=1]="Playing",ez[ez.CrossFading=2]="CrossFading",ez[ez.FixedCrossFading=3]="FixedCrossFading",ez[ez.Finished=4]="Finished",ez),oE=/*#__PURE__*/function(){function e(){this.handlers=[]}return e.prototype.dispose=function(){},e}(),oR=function(){},oM=/*#__PURE__*/function(){function e(){this.duration=0,this.offset=0,this.exitTime=1,this.mute=!1,this.isFixedDuration=!1,this._isExit=!1,this._conditions=[],this._solo=!1,this._hasExitTime=!0}var t=e.prototype;return t.addCondition=function(e,t,n){if((void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object")return this._conditions.push(e),e;var r=new oR;return r.parameterName=e,r.mode=null!=t?t:ob.If,r.threshold=n,this._conditions.push(r),r},t.removeCondition=function(e){var t=this._conditions.indexOf(e);-1!==t&&this._conditions.splice(t,1)},t._getFixedDuration=function(){return this.isFixedDuration?this.duration:this.duration*this.destinationState._getDuration()},tG(e,[{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._collection)||t.updateTransitionSolo(e))}},{key:"conditions",get:function(){return this._conditions}},{key:"hasExitTime",get:function(){return this._hasExitTime},set:function(e){var t;this._hasExitTime!==e&&(this._hasExitTime=e,null==(t=this._collection)||t.updateTransitionsIndex(this,e))}}]),e}(),ow=((eU={})[eU.Once=0]="Once",eU[eU.Loop=1]="Loop",eU),oP=/*#__PURE__*/function(){function e(){this.isForward=!0,this._changedOrientation=!1}var t=e.prototype;return t.reset=function(e,t,n){this.state=e,this.playedTime=0,this.offsetFrameTime=n,this.stateData=t,this.playState=oT.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.isForward=!0,this.state._transitionCollection.needResetCurrentCheckIndex=!0},t.updateOrientation=function(e){if(0!==e){var t=this.isForward;this.isForward=e>0,this.isForward!==t&&(this._changedOrientation=!0,this.isForward||this._correctTime())}},t.update=function(e){this.playedTime+=e;var t=this.state,n=this.playedTime+this.offsetFrameTime,r=t._getDuration();this.playState=oT.Playing,t.wrapMode===ow.Loop?n=r?n%r:0:Math.abs(n)>=r&&(n=n<0?-r:r,this.playState=oT.Finished),n<0&&(n+=r),this.clipTime=n+t.clipStartTime*t.clip.length,this._changedOrientation&&(this.isForward||this._correctTime(),this._changedOrientation=!1)},t._correctTime=function(){var e=this.state;0===this.clipTime&&(this.clipTime=e.clipEndTime*e.clip.length)},e}(),oF=/*#__PURE__*/function(){function e(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new oP,this.destPlayData=new oP,this.layerState=oA.Standby,this.crossCurveMark=0,this.manuallyTransition=new oM,this.crossLayerOwnerCollection=[]}var t=e.prototype;return t.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},t.resetCurrentCheckIndex=function(){this.layer.stateMachine._entryTransitionCollection.needResetCurrentCheckIndex=!0,this.layer.stateMachine._anyStateTransitionCollection.needResetCurrentCheckIndex=!0},e}(),oL=function(){this.curveLayerOwner=[],this.eventHandlers=[]},oD=/*#__PURE__*/function(t){function n(e){var n;return(n=t.call(this,e)||this).cullingMode=oC.None,n.speed=1,n._playFrameCount=-1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new iq(oE),n._parametersValueMap=Object.create(null),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n}tW(n,t);var r=n.prototype;return r.play=function(e,t,n){void 0===t&&(t=-1),void 0===n&&(n=0),(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset();var r,a=this._getAnimatorStateInfo(e,t),i=a.state;i&&this._preparePlay(i,a.layerIndex,n)&&(this._playFrameCount=this.engine.time.frameCount)},r.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!1)},r.crossFadeInFixedDuration=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),this._crossFade(e,t,n,r,!0)},r.update=function(e){if(this._playFrameCount===this.engine.time.frameCount&&(e=0),this.cullingMode===oC.Complete){n=!1;for(var t,n,r=this._controlledRenderers,a=0,i=r.length;a<i;a++)if(!r[a].isCulled){n=!0;break}}else n=!0;var o=this._animatorController;if(o){(null==(t=this._controllerUpdateFlag)?void 0:t.flag)&&this._reset(),this._updateMark++;for(var s=o.layers,l=0,c=s.length;l<c;l++){var u=this._getAnimatorLayerData(l);this._updateState(u,e,n)}}},r.getCurrentAnimatorState=function(e){var t,n;return null==(n=this._animatorLayersData[e])?void 0:null==(t=n.srcPlayData)?void 0:t.state},r.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},r.findLayerByName=function(e){var t;return null==(t=this._animatorController)?void 0:t._layersMap[e]},r.getParameter=function(e){var t,n;return null!=(n=null==(t=this._animatorController)?void 0:t._parametersMap[e])?n:null},r.getParameterValue=function(e){var t,n,r=null==(t=this._animatorController)?void 0:t._parametersMap[e];if(r)return null!=(n=this._parametersValueMap[e])?n:r.defaultValue},r.setParameterValue=function(e,t){var n;(null==(n=this._animatorController)?void 0:n._parametersMap[e])&&(this._parametersValueMap[e]=t)},r.activateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!0)},r.deactivateTriggerParameter=function(e){var t,n=null==(t=this._animatorController)?void 0:t._parametersMap[e];(null==n?void 0:n._isTrigger)&&(this._parametersValueMap[e]=!1)},r._onEnable=function(){this._reset(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},r._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},r._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},r._reset=function(){var e=this._curveOwnerPool;for(var t in e){var n=e[t];for(var r in n)n[r].revertDefaultValue()}this._animatorLayersData.length=0,this._curveOwnerPool=Object.create(null),this._parametersValueMap=Object.create(null),this._animationEventHandlerPool.clear(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},r._crossFade=function(e,t,n,r,a){(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset();var i,o=this._getAnimatorStateInfo(e,n),s=o.state,l=o.layerIndex,c=this._getAnimatorLayerData(l).manuallyTransition;c.duration=t,c.offset=r,c.isFixedDuration=a,c.destinationState=s,this._prepareCrossFadeByTransition(c,l)&&(this._playFrameCount=this.engine.time.frameCount)},r._getAnimatorStateInfo=function(e,t){var n=this._animatorController,r=this._tempAnimatorStateInfo,a=null;if(n){var i=n.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 r.layerIndex=t,r.state=a,r},r._getAnimatorStateData=function(e,t,n,r){var a=n.animatorStateDataMap,i=a[e];return i||(i=new oL,a[e]=i,this._saveAnimatorStateData(t,i,n,r),this._saveAnimatorEventHandlers(t,i)),i},r._saveAnimatorStateData=function(e,t,n,r){for(var a=this.entity,i=this._curveOwnerPool,o=this._animatorController.layers[r].mask,s=t.curveLayerOwner,l=e.clip._curveBindings,c=n.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,ou._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)),C=b[g]||(b[g]=d._createCurveLayerOwner(x));o&&o.pathMasks.length&&(C.isActive=null==(p=null==(f=o.getPathMask(h))?void 0:f.active)||p),s[u]=C}else s[u]=null,no.warn("The entity don't have the child entity which path is "+d.relativePath+".")}},r._saveAnimatorEventHandlers=function(e,t){var n=this,r=this._animationEventHandlerPool,a=[],i=t.eventHandlers,o=function(){n._entity.getComponents(os,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=r.get(),d=c.functionName,h=u.handlers;u.event=c,h.length=0;for(var _=t-1;_>=0;_--){var f,p=a[_],m=null==(f=p[d])?void 0:f.bind(p);m&&h.push(m)}i.push(u)}};o(),e._updateFlagManager.addListener(o)},r._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},r._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},r._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},r._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},r._prepareFixedPoseCrossFading=function(e){for(var t=e.crossLayerOwnerCollection,n=t.length-1;n>=0;n--){var r=t[n];r&&(r.curveOwner.saveFixedPoseValue(),r.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},r._prepareSrcCrossData=function(e,t){for(var n=e.srcPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];a&&(a.crossCurveMark=e.crossCurveMark,t&&a.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,a,r,-1))}},r._prepareDestCrossData=function(e,t){for(var n=e.destPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var a=n[r];if(a){if(a.crossCurveMark===e.crossCurveMark)a.crossDestCurveIndex=r;else{var i=a.curveOwner;t&&i.saveFixedPoseValue(),a.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,a,-1,r)}}}},r._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||((t=new oF).layerIndex=e,t.layer=this._animatorController.layers[e],this._animatorLayersData[e]=t),t},r._updateState=function(e,t,n){var r=e.layer,a=r.weight,i=r.blendingMode===oS.Additive;switch(0===e.layerIndex&&(a=1),e.layerState){case oA.Standby:this._checkAnyAndEntryState(e,t,n);break;case oA.Playing:this._updatePlayingState(e,a,i,t,n);break;case oA.Finished:this._updateFinishedState(e,a,i,t,n);break;case oA.CrossFading:this._updateCrossFadeState(e,a,i,t,n);break;case oA.FixedCrossFading:this._updateCrossFadeFromPoseState(e,a,i,t,n)}},r._updatePlayingState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=o.state,l=s.speed*this.speed,c=l*r;o.updateOrientation(c);var u=o.clipTime,d=o.playState;o.update(c);var h=o.clipTime,_=o.isForward,f=s._transitionCollection,p=e.layer.stateMachine._anyStateTransitionCollection,m=p.count&&this._applyStateTransitions(e,_,o,p,u,h,c,a)||f.count&&this._applyStateTransitions(e,_,o,f,u,h,c,a);if(m){var g=s._getClipActualEndTime();if(m.hasExitTime){var v=m.exitTime*s._getDuration()+s._getClipActualStartTime();if(_)i=v<u?v+g-u:v-u;else{var y=s._getClipActualStartTime();i=-(i=u<v?g-v+u-y:u-v)}}else i=0;o.update(i-c)}else i=c,o.playState===oT.Finished&&(e.layerState=oA.Finished);if(this._evaluatePlayingState(o,t,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,u,d,i),m){var x=r-i/l;x>0&&this._updateState(e,x,a)}},r._evaluatePlayingState=function(e,t,n,r){var a=e.state.clip._curveBindings,i=e.playState===oT.Finished;if(r||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,n);var d=c.evaluateValue(u,e.clipTime,n);r&&c.applyValue(d,t,n),i&&l.saveFinalValue()}}}},r._updateCrossFadeState=function(e,t,n,r,a){var i,o=e.srcPlayData,s=e.destPlayData,l=e.layerIndex,c=this.speed,u=o.state,d=s.state,h=e.crossFadeTransition._getFixedDuration(),_=u.speed*c,f=d.speed*c,p=f*r;o&&o.updateOrientation(_*r),s&&s.updateOrientation(p);var m=o.clipTime,g=o.playState,v=s.clipTime,y=s.playState;if(s.isForward){var x=s.playedTime;i=x+p>h?h-x:p}else{var b=s.playedTime;i=b-p>h?b-h:p}var C=0===f?r:i/f,S=C*_;o.update(S),s.update(i);var T=Math.abs(s.playedTime)/h;(T>=1-tS.zeroTolerance||0===h)&&(T=1);var A=1===T;if(A?(o.playState=oT.Finished,this._preparePlayOwner(e,d),this._evaluatePlayingState(s,t,n,a)):this._evaluateCrossFadeState(e,o,s,t,T,n,a),this._fireAnimationEventsAndCallScripts(l,o,u,m,g,S),this._fireAnimationEventsAndCallScripts(l,s,d,v,y,i),A){this._updateCrossFadeData(e);var E=r-C;E>0&&this._updateState(e,E,a)}},r._evaluateCrossFadeState=function(e,t,n,r,a,i,o){var s=e.crossLayerOwnerCollection,l=t.state.clip._curveBindings,c=n.state.clip._curveBindings,u=n.playState===oT.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,n.clipTime,a,i);o&&_.applyValue(m,r,i),u&&h.saveFinalValue()}}},r._updateCrossFadeFromPoseState=function(e,t,n,r,a){var i,o=e.destPlayData,s=o.state,l=e.crossFadeTransition._getFixedDuration(),c=s.speed*this.speed,u=c*r;o.updateOrientation(u);var d=o.clipTime,h=o.playState;if(o.isForward){var _=o.playedTime;i=_+u>l?l-_:u}else{var f=o.playedTime;i=f-u>l?f-l:u}var p=0===c?r:i/c;o.update(i);var m=Math.abs(o.playedTime)/l;(m>=1-tS.zeroTolerance||0===l)&&(m=1);var g=1===m;if(g?(this._preparePlayOwner(e,s),this._evaluatePlayingState(o,t,n,a)):this._evaluateCrossFadeFromPoseState(e,o,t,m,n,a),this._fireAnimationEventsAndCallScripts(e.layerIndex,o,s,d,h,i),g){this._updateCrossFadeData(e);var v=r-p;v>0&&this._updateState(e,v,a)}},r._evaluateCrossFadeFromPoseState=function(e,t,n,r,a,i){var o=e.crossLayerOwnerCollection,s=t.state.clip._curveBindings,l=t.clipTime,c=t.playState===oT.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,r,a);i&&h.applyValue(f,n,a),c&&d.saveFinalValue()}}},r._updateFinishedState=function(e,t,n,r,a){var i=e.srcPlayData,o=i.state,s=o.speed*this.speed*r;i.updateOrientation(s);var l=i.clipTime,c=i.isForward,u=o._transitionCollection,d=e.layer.stateMachine._anyStateTransitionCollection;d.count&&this._applyTransitionsByCondition(e,d,a)||u.count&&this._applyStateTransitions(e,c,i,u,l,l,s,a)?this._updateState(e,r,a):this._evaluateFinishedState(i,t,n,a)},r._evaluateFinishedState=function(e,t,n,r){if(r)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,n),l.applyValue(s.finalValue,t,n))}},r._updateCrossFadeData=function(e){e.destPlayData.playState===oT.Finished?e.layerState=oA.Finished:e.layerState=oA.Playing,e.switchPlayData(),e.crossFadeTransition=null},r._preparePlayOwner=function(e,t){if(e.layerState===oA.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,a=n.stateData.curveLayerOwner,i=a.length-1;i>=0;i--)null==(r=a[i])||r.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},r._applyStateTransitions=function(e,t,n,r,a,i,o,s){var l=n.state,c=l.clip.length,u=null,d=l.clipStartTime*c,h=l.clipEndTime*c;return r.noExitTimeCount&&(u=this._checkNoExitTimeTransition(e,r,s))||(t?a+o>=h?(u=this._checkSubTransition(e,l,r,a,h,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkSubTransition(e,l,r,d,i,s)):u=this._checkSubTransition(e,l,r,a,i,s):a+o<=d?(u=this._checkBackwardsSubTransition(e,l,r,a,d,s))||(r.needResetCurrentCheckIndex=!0,u=this._checkBackwardsSubTransition(e,l,r,i,h,s)):u=this._checkBackwardsSubTransition(e,l,r,a,i,s)),u},r._checkNoExitTimeTransition=function(e,t,n){for(var r=0,a=t.count;r<a;++r){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i))return this._applyTransition(e,i,n)}return null},r._checkSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!0);for(var o=n.transitions,s=n.noExitTimeCount+n.currentCheckIndex,l=o.length;s<l;s++){var c=o[s],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u>a)break;if(!(u<r)){if(n.updateCurrentCheckIndex(!0),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._checkBackwardsSubTransition=function(e,t,n,r,a,i){n.needResetCurrentCheckIndex&&n.resetCurrentCheckIndex(!1);for(var o=n.transitions,s=n.noExitTimeCount,l=n.currentCheckIndex+s;l>=s;l--){var c=o[l],u=c.exitTime*t._getDuration()+t._getClipActualStartTime();if(u<a)break;if(!(u>r)){if(n.updateCurrentCheckIndex(!1),c.mute||n.isSoloMode&&!c.solo||!this._checkConditions(c))continue;return this._applyTransition(e,c,i)}}return null},r._applyTransitionsByCondition=function(e,t,n){for(var r=0,a=t.count;r<a;r++){var i=t.get(r);if(!i.mute&&(!t.isSoloMode||i.solo)&&this._checkConditions(i)){if(this._applyTransition(e,i,n))return i;return null}}},r._preparePlay=function(e,t,n){void 0===n&&(n=0);var r=e.name;if(!e.clip)return no.warn("The state named "+r+" has no AnimationClip data."),!1;var a=this._getAnimatorLayerData(t),i=this._getAnimatorStateData(r,e,a,t);return this._preparePlayOwner(a,e),a.layerState=oA.Playing,a.srcPlayData.reset(e,i,e._getClipActualEndTime()*n),a.resetCurrentCheckIndex(),!0},r._applyTransition=function(e,t,n){var r=this._prepareCrossFadeByTransition(t,e.layerIndex);return t.isExit?(this._checkAnyAndEntryState(e,0,n),t):r?t:null},r._checkConditions=function(e){for(var t=e.conditions,r=!0,a=0,i=t.length;a<i;++a){var o=!1,s=t[a],l=s.mode,c=s.parameterName,u=s.threshold,d=this.getParameterValue(c);if(void 0===d)return!1;if(!0===d){var h=this.getParameter(c);(null==h?void 0:h._isTrigger)&&(n._passedTriggerParameterNames.push(c),o=!0)}if(!o)switch(l){case ob.Equals:d===u&&(o=!0);break;case ob.Greater:d>u&&(o=!0);break;case ob.Less:d<u&&(o=!0);break;case ob.NotEquals:d!==u&&(o=!0);break;case ob.If:!0===d&&(o=!0);break;case ob.IfNot:!1===d&&(o=!0)}if(!o){r=!1;break}}return r&&this._deactivateTriggeredParameters(),n._passedTriggerParameterNames.length=0,r},r._prepareCrossFadeByTransition=function(e,t){var n=e.destinationState;if(!n)return!1;if(!n.clip)return no.warn("The state named "+n.name+" has no AnimationClip data."),!1;var r=this._getAnimatorLayerData(t),a=this._getAnimatorStateData(n.name,n,r,t);switch(r.destPlayData.reset(n,a,e.offset*n._getClipActualEndTime()),r.resetCurrentCheckIndex(),r.layerState){case oA.Standby:case oA.Finished:r.layerState=oA.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case oA.Playing:r.layerState=oA.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case oA.CrossFading:r.layerState=oA.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case oA.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},r._fireAnimationEvents=function(e,t,n,r){var a=e.state,i=e.isForward,o=e.clipTime,s=a._getClipActualStartTime(),l=a._getClipActualEndTime();i?n+r>=l?(this._fireSubAnimationEvents(e,t,n,l),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,s,o)):this._fireSubAnimationEvents(e,t,n,o):n+r<=s?(this._fireBackwardSubAnimationEvents(e,t,n,s),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,l,o)):this._fireBackwardSubAnimationEvents(e,t,n,o)},r._fireSubAnimationEvents=function(e,t,n,r){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>r)break;var u=o.handlers;if(l>=n){for(var d=u.length-1;d>=0;d--)u[d](c);e.currentEventIndex=Math.min(a+1,i-1)}}},r._fireBackwardSubAnimationEvents=function(e,t,n,r){for(var a=e.currentEventIndex;a>=0;a--){var i=t[a],o=i.event,s=o.time,l=o.parameter;if(s<r)break;if(s<=n){for(var c=i.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(a-1,0)}}},r._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,a=n.length;r<a;r++)n[r].onStateEnter(this,e,t)},r._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,a=n.length;r<a;r++)n[r].onStateUpdate(this,e,t)},r._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,a=n.length;r<a;r++)n[r].onStateExit(this,e,t)},r._checkAnyAndEntryState=function(e,t,n){var r,a=e.layer.stateMachine,i=a._anyStateTransitionCollection,o=a._entryTransitionCollection;if((r=i.count&&this._applyTransitionsByCondition(e,i,n))||(r=o.count&&this._applyTransitionsByCondition(e,o,n)),r)this._updateState(e,t,n);else{var s=a.defaultState;s&&(this._preparePlay(s,e.layerIndex),this._updateState(e,t,n))}},r._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},r._fireAnimationEventsAndCallScripts=function(e,t,n,r,a,i){var o=t.stateData.eventHandlers;o.length&&this._fireAnimationEvents(t,o,r,i),a===oT.UnStarted&&this._callAnimatorScriptOnEnter(n,e),a!==oT.Finished&&t.playState===oT.Finished?this._callAnimatorScriptOnExit(n,e):this._callAnimatorScriptOnUpdate(n,e)},r._deactivateTriggeredParameters=function(){for(var e=n._passedTriggerParameterNames,t=0,r=e.length;t<r;t++)this._parametersValueMap[e[t]]=!1},tG(n,[{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}}]),n}(ru);oD._passedTriggerParameterNames=[],tX([tQ],oD.prototype,"speed",void 0),tX([tq],oD.prototype,"_controllerUpdateFlag",void 0),tX([tq],oD.prototype,"_updateMark",void 0),tX([tq],oD.prototype,"_animatorLayersData",void 0),tX([tq],oD.prototype,"_curveOwnerPool",void 0),tX([tq],oD.prototype,"_animationEventHandlerPool",void 0),tX([tq],oD.prototype,"_parametersValueMap",void 0),tX([tq],oD.prototype,"_tempAnimatorStateInfo",void 0),tX([tq],oD.prototype,"_controlledRenderers",void 0);var oB=/*#__PURE__*/function(){function e(){this._onNameChanged=null,this._isTrigger=!1}return tG(e,[{key:"name",get:function(){return this._name},set:function(e){if(this._name!==e){var t=this._name;this._name=e,null==this._onNameChanged||this._onNameChanged.call(this,t,e)}}}]),e}(),oI=/*#__PURE__*/function(e){function t(t){var n;return t&&((n=e.call(this,t)||this)._parameters=[],n._parametersMap={},n._layers=[],n._layersMap={},n._updateFlagManager=new nM),function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(n)}tW(t,e);var n=t.prototype;return n.addParameter=function(e,t){return this._addParameter(e,t,!1)},n.addTriggerParameter=function(e){return this._addParameter(e,!1,!0)},n.removeParameter=function(e){var t=this._parametersMap[e],n=this._parameters.indexOf(t);-1!==n&&(this._parameters.splice(n,1),delete this._parametersMap[t.name])},n.clearParameters=function(){for(var e in this._parameters.length=0,this._parametersMap)delete this._parametersMap[e]},n.getParameter=function(e){return this._parametersMap[e]||null},n.findLayerByName=function(e){return this._layersMap[e]},n.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},n.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},n.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},n._registerChangeFlag=function(){return this._updateFlagManager.createFlag(rf)},n._addParameter=function(e,t,n){var r=this;if(void 0===n&&(n=!1),this._parametersMap[e])return console.warn("Parameter "+e+" already exists."),null;var a=new oB;return a.name=e,a.defaultValue=t,a._isTrigger=n,a._onNameChanged=function(e,t){delete r._parametersMap[e],r._parametersMap[t]=a},this._parametersMap[e]=a,this._parameters.push(a),a},tG(t,[{key:"layers",get:function(){return this._layers}},{key:"parameters",get:function(){return this._parameters}}]),t}(t1),oO=/*#__PURE__*/function(){function e(){this.transitions=[],this.noExitTimeCount=0,this.needResetCurrentCheckIndex=!0,this._soloCount=0}var t=e.prototype;return t.get=function(e){return this.transitions[e]},t.add=function(e){var t;return tK(e,oV)?((t=new oM).hasExitTime=!1,t.destinationState=e):t=e,this._addTransition(t),t._collection=this,t.solo&&this._soloCount++,t},t.remove=function(e){var t=this.transitions,n=t.indexOf(e);-1!==n&&(t.splice(n,1),!e.hasExitTime&&this.noExitTimeCount--),e._collection=null,e.solo&&this._soloCount--},t.clear=function(){for(var e=this.transitions,t=0,n=e.length;t<n;t++)e[t]._collection=null;e.length=0,this._soloCount=0,this.noExitTimeCount=0},t.updateTransitionSolo=function(e){this._soloCount+=e?1:-1},t.updateTransitionsIndex=function(e,t){var n=this.transitions;n.splice(n.indexOf(e),1),this._addTransition(e)},t.updateCurrentCheckIndex=function(e){this.currentCheckIndex=e?Math.min(this.currentCheckIndex+1,this.count-this.noExitTimeCount-1):Math.max(this.currentCheckIndex-1,0)},t.resetCurrentCheckIndex=function(e){this.currentCheckIndex=e?0:this.count-this.noExitTimeCount-1,this.needResetCurrentCheckIndex=!1},t._addTransition=function(e){var t=this.transitions;if(!e.hasExitTime){t.unshift(e),this.noExitTimeCount++;return}var n=e.exitTime,r=t.length;if(n>=(r?t[r-1].exitTime:0))t.push(e);else{for(var a=r;--a>=0&&n<t[a].exitTime;);t.splice(a+1,0,e)}},tG(e,[{key:"isSoloMode",get:function(){return this._soloCount>0}},{key:"count",get:function(){return this.transitions.length}}]),e}(),oN=/*#__PURE__*/function(){function e(){this._destroyed=!1}var t=e.prototype;return t.onStateEnter=function(e,t,n){},t.onStateUpdate=function(e,t,n){},t.onStateExit=function(e,t,n){},t.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},e}(),oV=/*#__PURE__*/function(){function e(e){this.name=e,this.speed=1,this.wrapMode=ow.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._updateFlagManager=new nM,this._transitionCollection=new oO,this._clipStartTime=0,this._clipEndTime=1,this._onClipChanged=this._onClipChanged.bind(this)}var t=e.prototype;return t.addTransition=function(e){return this._transitionCollection.add(e)},t.addExitTransition=function(e){void 0===e&&(e=1);var t=new oM;return t._isExit=!0,t.exitTime=e,this._transitionCollection.add(t)},t.removeTransition=function(e){this._transitionCollection.remove(e),e._isExit&&(e._isExit=!1)},t.addStateMachineScript=function(e){var t=new e;t._state=this;var n=oN.prototype;return t.onStateEnter!==n.onStateEnter&&this._onStateEnterScripts.push(t),t.onStateUpdate!==n.onStateUpdate&&this._onStateUpdateScripts.push(t),t.onStateExit!==n.onStateExit&&this._onStateExitScripts.push(t),t},t.clearTransitions=function(){this._transitionCollection.clear()},t._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},t._removeStateMachineScript=function(e){var t=oN.prototype;if(e.onStateEnter!==t.onStateEnter){var n=this._onStateEnterScripts.indexOf(e);-1!==n&&this._onStateEnterScripts.splice(n,1)}if(e.onStateUpdate!==t.onStateUpdate){var r=this._onStateUpdateScripts.indexOf(e);-1!==r&&this._onStateUpdateScripts.splice(r,1)}if(e.onStateExit!==t.onStateExit){var a=this._onStateExitScripts.indexOf(e);-1!==a&&this._onStateExitScripts.splice(a,1)}},t._onClipChanged=function(){this._updateFlagManager.dispatch()},t._getClipActualStartTime=function(){return this._clipStartTime*this.clip.length},t._getClipActualEndTime=function(){return this._clipEndTime*this.clip.length},tG(e,[{key:"transitions",get:function(){return this._transitionCollection.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)}}]),e}(),ok=/*#__PURE__*/function(){function e(){this.states=[],this._entryTransitionCollection=new oO,this._anyStateTransitionCollection=new oO,this._statesMap={}}var t=e.prototype;return t.addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new oV(e),this.states.push(t),this._statesMap[e]=t),t},t.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},t.findStateByName=function(e){return this._statesMap[e]},t.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},t.addEntryStateTransition=function(e){return this._entryTransitionCollection.add(e)},t.removeEntryStateTransition=function(e){this._entryTransitionCollection.remove(e)},t.addAnyStateTransition=function(e){return this._anyStateTransitionCollection.add(e)},t.removeAnyStateTransition=function(e){this._anyStateTransitionCollection.remove(e)},t.clearEntryStateTransitions=function(){this._entryTransitionCollection.clear()},t.clearAnyStateTransitions=function(){this._anyStateTransitionCollection.clear()},tG(e,[{key:"entryTransitions",get:function(){return this._entryTransitionCollection.transitions}},{key:"anyStateTransitions",get:function(){return this._anyStateTransitionCollection.transitions}}]),e}(),oz=function(e){this.name=e,this.weight=1,this.blendingMode=oS.Override,this.stateMachine=new ok},oU=function(){},oG=function(){},oH=/*#__PURE__*/function(){function e(){this._pathMasks=[],this._pathMaskMap={}}var t=e.prototype;return t.addPathMask=function(e){var t=this._pathMaskMap[e];if(t)return t;var n=new oG;return n.path=e,n.active=!0,this._pathMasks.push(n),this._pathMaskMap[e]=n,n},t.removePathMask=function(e){for(var t=this._pathMasks,n=0,r=this._pathMasks.length;n<r;++n)if(t[n].path===e){t.splice(n,1),delete this._pathMaskMap[e];break}},t.getPathMask=function(e){return this._pathMaskMap[e]},t.setPathMaskActive=function(e,t,n){void 0===n&&(n=!1);var r=this._pathMaskMap[e];if(r&&(r.active=t),n)for(var a in this._pathMaskMap)a.startsWith(e)&&(this._pathMaskMap[a].active=t)},e.createByEntity=function(t){var n=new e;return n.addPathMask(""),e._addPathMaskWithChildren(n,t,""),n},e._addPathMaskWithChildren=function(t,n,r){for(var a=n.children,i=0,o=a.length;i<o;++i){var s=a[i],l=r?r+"/"+s.name:s.name;t.addPathMask(l),e._addPathMaskWithChildren(t,s,l)}},tG(e,[{key:"pathMasks",get:function(){return this._pathMasks}}]),e}(),oW=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n,ro.find("skybox"))||this)._textureDecodeRGBM=!1,r._tintColor=new tO(1,1,1,1),r.renderState.rasterState.cullMode=nI.Off,r.renderState.depthState.compareFunction=nB.LessEqual,r.shaderData.setFloat(t._rotationProp,0),r.shaderData.setFloat(t._exposureProp,1),r.shaderData.setColor(t._tintColorProp,r._tintColor),r}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(t._decodeSkyRGBMMacro):this.shaderData.disableMacro(t._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(t._textureCubeProp)},set:function(e){this.shaderData.setTexture(t._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(t._rotationProp)},set:function(e){this.shaderData.setFloat(t._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),t}(ao);oW._tintColorProp=nY.getByName("material_TintColor"),oW._textureCubeProp=nY.getByName("material_CubeTexture"),oW._rotationProp=nY.getByName("material_Rotation"),oW._exposureProp=nY.getByName("material_Exposure"),oW._decodeSkyRGBMMacro=nH.getByName("MATERIAL_IS_DECODE_SKY_RGBM");var oj=((eG={})[eG.None=0]="None",eG[eG.Simple=1]="Simple",eG[eG.HighQuality=2]="HighQuality",eG),oX=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new tO(.5,.5,.5,1),n.groundTint=new tO(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=nI.Off,n.renderState.depthState.compareFunction=nB.LessEqual,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var n=this.shaderData;switch(e){case 2:n.disableMacro(t._sunSimpleMacro),n.enableMacro(t._sunHighQualityMacro);break;case 1:n.disableMacro(t._sunHighQualityMacro),n.enableMacro(t._sunSimpleMacro);break;case 0:n.disableMacro(t._sunHighQualityMacro),n.disableMacro(t._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(t._sunSizeProp)},set:function(e){this.shaderData.setFloat(t._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(t._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(t._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(t._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(t._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(t._skyTintProp)},set:function(e){this.shaderData.setColor(t._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(t._groundTintProp)},set:function(e){this.shaderData.setColor(t._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(t._exposureProp)},set:function(e){this.shaderData.setFloat(t._exposureProp,Math.min(Math.max(0,e),8))}}]),t}(ao);oX._sunSizeProp=nY.getByName("material_SunSize"),oX._sunSizeConvergenceProp=nY.getByName("material_SunSizeConvergence"),oX._atmosphereThicknessProp=nY.getByName("material_AtmosphereThickness"),oX._skyTintProp=nY.getByName("material_SkyTint"),oX._groundTintProp=nY.getByName("material_GroundTint"),oX._exposureProp=nY.getByName("material_Exposure"),oX._sunHighQualityMacro=nH.getByName("MATERIAL_SUN_HIGH_QUALITY"),oX._sunSimpleMacro=nH.getByName("MATERIAL_SUN_SIMPLE");var oK=((eH={})[eH.Billboard=0]="Billboard",eH[eH.StretchBillboard=1]="StretchBillboard",eH[eH.HorizontalBillboard=2]="HorizontalBillboard",eH[eH.VerticalBillboard=3]="VerticalBillboard",eH[eH.Mesh=4]="Mesh",eH[eH.None=5]="None",eH),oY=((eW={})[eW.Local=0]="Local",eW[eW.World=1]="World",eW),oq=((ej={})[ej.StopEmittingAndClear=0]="StopEmittingAndClear",ej[ej.StopEmitting=1]="StopEmitting",ej),oQ=/*#__PURE__*/function(e){function t(n){var r;return(r=e.call(this,n)||this).velocityScale=0,r.lengthScale=2,r.pivot=new tT,r._generatorBounds=new tE,r._transformedBounds=new tE,r._onGeneratorParamsChanged=r._onGeneratorParamsChanged.bind(r),r.generator=new ss(r),r._currentRenderModeMacro=t._billboardModeMacro,r.shaderData.enableMacro(t._billboardModeMacro),r._supportInstancedArrays=r.engine._hardwareRenderer.canIUse(nJ.instancedArrays),r._onGeneratorParamsChanged(),r}tW(t,e);var n=t.prototype;return n._onEnable=function(){this.generator.main.playOnEnabled&&this.generator.play(!1)},n._onDisable=function(){this.generator.stop(!1,oq.StopEmittingAndClear)},n._prepareRender=function(t){this._supportInstancedArrays&&e.prototype._prepareRender.call(this,t)},n._updateTransformShaderData=function(t,n,r){e.prototype._updateTransformShaderData.call(this,t,n,!0)},n._updateBounds=function(e){var t=this.generator;if(!t.isAlive){var n=this.entity.transform.worldPosition;e.min.copyFrom(n),e.max.copyFrom(n);return}t.main.simulationSpace===oY.Local?t._updateBoundsSimulationLocal(e):(this._isContainDirtyFlag(2)&&(t._generateTransformedBounds(),this._setDirtyFlagFalse(2)),t._updateBoundsSimulationWorld(e))},n._update=function(e){var n=this.generator;if(n._update(this.engine.time.deltaTime),n._firstActiveElement!==n._firstFreeElement){var r=this.shaderData;r.setFloat(t._lengthScale,this.lengthScale),r.setFloat(t._speedScale,this.velocityScale),r.setFloat(t._currentTime,this.generator._playTime),r.setVector3(t._pivotOffsetProperty,this.pivot),this.generator._updateShaderData(r)}},n._render=function(e){var t=this.generator,n=t._getAliveParticleCount();if(n){t._primitive.instanceCount=n;var r=this.getMaterial();if(r){(r.destroyed||r.shader.destroyed)&&(r=this.engine._particleMagentaMaterial);var a=this._engine,i=a._renderElementPool.get();i.set(this.priority,this._distanceForSort);var o=a._subRenderElementPool.get();o.set(this,r,t._primitive,t._subPrimitive),i.addSubRenderElement(o),e.camera._renderPipeline.pushRenderElement(e,i)}}},n._onDestroy=function(){var t=this._mesh;t&&(t.destroyed||this._addResourceReferCount(t,-1)),e.prototype._onDestroy.call(this),this.generator._destroy()},n._isContainDirtyFlag=function(e){return(this._dirtyUpdateFlag&e)!=0},n._setDirtyFlagFalse=function(e){this._dirtyUpdateFlag&=~e},n._onWorldVolumeChanged=function(){this._dirtyUpdateFlag|=rv.WorldVolume},n._onGeneratorParamsChanged=function(){this._dirtyUpdateFlag|=6|rv.WorldVolume},n._onTransformChanged=function(e){this._dirtyUpdateFlag|=2|rv.WorldVolume},tG(t,[{key:"renderMode",get:function(){return this._renderMode},set:function(e){if(this._renderMode!==e){var n=this._renderMode;this._renderMode=e;var r=null,a=this.shaderData;switch(e){case oK.Billboard:r=t._billboardModeMacro;break;case oK.StretchBillboard:r=t._stretchedBillboardModeMacro;break;case oK.HorizontalBillboard:case oK.VerticalBillboard:case oK.Mesh:throw"Not implemented"}this._currentRenderModeMacro!==r&&(this._currentRenderModeMacro&&a.disableMacro(this._currentRenderModeMacro),r&&a.enableMacro(r),this._currentRenderModeMacro=r),n!==oK.Mesh!=(e===oK.Mesh)&&this.generator._reorganizeGeometryBuffers()}}},{key:"mesh",get:function(){return this._mesh},set:function(e){var t=this._mesh;t!==e&&(this._mesh=e,t&&this._addResourceReferCount(t,-1),e&&this._addResourceReferCount(e,1),this.renderMode===oK.Mesh&&this.generator._reorganizeGeometryBuffers())}}]),t}(e.Renderer);oQ._billboardModeMacro=nH.getByName("RENDERER_MODE_SPHERE_BILLBOARD"),oQ._stretchedBillboardModeMacro=nH.getByName("RENDERER_MODE_STRETCHED_BILLBOARD"),oQ._horizontalBillboardModeMacro=nH.getByName("RENDERER_MODE_HORIZONTAL_BILLBOARD"),oQ._verticalBillboardModeMacro=nH.getByName("RENDERER_MODE_VERTICAL_BILLBOARD"),oQ._renderModeMeshMacro=nH.getByName("RENDERER_MODE_MESH"),oQ._pivotOffsetProperty=nY.getByName("renderer_PivotOffset"),oQ._lengthScale=nY.getByName("renderer_StretchedBillboardLengthScale"),oQ._speedScale=nY.getByName("renderer_StretchedBillboardSpeedScale"),oQ._currentTime=nY.getByName("renderer_CurrentTime"),tX([tZ],oQ.prototype,"generator",void 0),tX([tJ],oQ.prototype,"pivot",void 0),tX([tq],oQ.prototype,"_generatorBounds",void 0),tX([tq],oQ.prototype,"_transformedBounds",void 0),tX([tq],oQ.prototype,"_onGeneratorParamsChanged",null);var oJ=((eX={})[eX.TransformVolume=2]="TransformVolume",eX[eX.GeneratorVolume=4]="GeneratorVolume",eX),oZ=((eK={})[eK.Constant=0]="Constant",eK[eK.TwoConstants=1]="TwoConstants",eK[eK.Curve=2]="Curve",eK[eK.TwoCurves=3]="TwoCurves",eK),o$=((eY={})[eY.Constant=0]="Constant",eY[eY.TwoConstants=1]="TwoConstants",eY[eY.Gradient=2]="Gradient",eY[eY.TwoGradients=3]="TwoGradients",eY),o0=((eq={})[eq.Burst=0x23571a3e]="Burst",eq[eq.StartDelay=0x13371337]="StartDelay",eq[eq.StartColor=0x12460f3b]="StartColor",eq[eq.StartSize=0x6aed452e]="StartSize",eq[eq.StartRotation=0xdec4aea1]="StartRotation",eq[eq.randomizeRotationDirection=0x96aa4de3]="randomizeRotationDirection",eq[eq.StartLifetime=0x8d2c8431]="StartLifetime",eq[eq.StartSpeed=0xf3857f6f]="StartSpeed",eq[eq.VelocityOverLifetime=0xe0fbd834]="VelocityOverLifetime",eq[eq.ColorOverLifetime=0x13740583]="ColorOverLifetime",eq[eq.SizeOverLifetime=0x591bc05c]="SizeOverLifetime",eq[eq.RotationOverLifetime=0x40eb95e4]="RotationOverLifetime",eq[eq.TextureSheetAnimation=0xbc524e5]="TextureSheetAnimation",eq[eq.Shape=0xaf502044]="Shape",eq[eq.GravityModifier=0xa47b8c4d]="GravityModifier",eq),o1=/*#__PURE__*/function(){function e(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 n=0,r=e.length;n<r;n++){var a=e[n];this.addColorKey(a)}if(t)for(var i=0,o=t.length;i<o;i++){var s=t[i];this.addAlphaKey(s)}}var t=e.prototype;return t.addColorKey=function(e,t){var n=this._colorKeys;if(4===n.length)throw Error("Gradient can only have 4 color keys");var r="number"==typeof e?new o2(e,t):e;r._onValueChanged=this._setColorTypeArrayDirty.bind(this),this._addKey(n,r),this._colorTypeArrayDirty=!0},t.addAlphaKey=function(e,t){var n=this._alphaKeys;if(4===n.length)throw Error("Gradient can only have 4 alpha keys");var r="number"==typeof e?new o3(e,t):e;r._onValueChanged=this._setAlphaTypeArrayDirty.bind(this),this._addKey(n,r),this._alphaTypeArrayDirty=!0},t.removeColorKey=function(e){this._colorKeys[e]._onValueChanged=null,this._removeKey(this._colorKeys,e),this._colorTypeArrayDirty=!0},t.removeAlphaKey=function(e){this._alphaKeys[e]._onValueChanged=null,this._removeKey(this._alphaKeys,e),this._alphaTypeArrayDirty=!0},t.setKeys=function(e,t){for(var n=this._colorKeys,r=this._alphaKeys,a=0,i=n.length;a<i;a++)n[a]._onValueChanged=null;for(var o=0,s=r.length;o<s;o++)r[o]._onValueChanged=null;n.length=0,r.length=0;for(var l=0,c=e.length;l<c;l++)this._addKey(n,e[l]);for(var u=0,d=t.length;u<d;u++)this._addKey(r,t[u]);this._alphaTypeArrayDirty=!0,this._colorTypeArrayDirty=!0},t._getColorTypeArray=function(e){var t=this._colorTypeArray||(this._colorTypeArray=new Float32Array(16));if(this._colorTypeArrayDirty){for(var n=this._colorKeys,r=0,a=Math.min(n.length,4);r<a;r++){var i=4*r,o=n[r];t[i]=o.time;var s=o.color;e===n2.Linear?(t[i+1]=tO.gammaToLinearSpace(s.r),t[i+2]=tO.gammaToLinearSpace(s.g),t[i+3]=tO.gammaToLinearSpace(s.b)):(t[i+1]=s.r,t[i+2]=s.g,t[i+3]=s.b)}this._colorTypeArrayDirty=!1}return t},t._getAlphaTypeArray=function(){var e=this._alphaTypeArray||(this._alphaTypeArray=new Float32Array(8));if(this._alphaTypeArrayDirty){for(var t=this._alphaKeys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.alpha}this._alphaTypeArrayDirty=!1}return e},t._addKey=function(e,t){var n=t.time,r=e.length;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)}},t._removeKey=function(e,t){e.splice(t,1)},t._setColorTypeArrayDirty=function(){this._colorTypeArrayDirty=!0},t._setAlphaTypeArrayDirty=function(){this._alphaTypeArrayDirty=!0},tG(e,[{key:"colorKeys",get:function(){return this._colorKeys}},{key:"alphaKeys",get:function(){return this._alphaKeys}}]),e}();tX([tZ],o1.prototype,"_colorKeys",void 0),tX([tZ],o1.prototype,"_alphaKeys",void 0),tX([tq],o1.prototype,"_colorTypeArray",void 0),tX([tq],o1.prototype,"_alphaTypeArray",void 0),tX([tq],o1.prototype,"_setColorTypeArrayDirty",null),tX([tq],o1.prototype,"_setAlphaTypeArrayDirty",null);var o2=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._color=new tO,this._time=e,t&&this._color.copyFrom(t),this._color._onValueChanged=this._onValueChanged}return tG(e,[{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)}}]),e}(),o3=/*#__PURE__*/function(){function e(e,t){this._onValueChanged=null,this._time=e,this._alpha=t}return tG(e,[{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()}}]),e}(),o4=/*#__PURE__*/function(){function e(e,t){this.mode=o$.Constant,this.constantMin=new tO,this.constantMax=new tO,this.gradientMin=new o1,this.gradientMax=new o1,e.constructor===tO?t?(this.constantMin.copyFrom(e),this.constantMax.copyFrom(t),this.mode=o$.TwoConstants):(this.constant.copyFrom(e),this.mode=o$.Constant):t?(this.gradientMin=e,this.gradientMax=t,this.mode=o$.TwoGradients):(this.gradient=e,this.mode=o$.Gradient)}return e.prototype.evaluate=function(e,t,n){switch(this.mode){case o$.Constant:n.copyFrom(this.constant);break;case o$.TwoConstants:tO.lerp(this.constantMin,this.constantMax,t,n)}},tG(e,[{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}}]),e}();tX([tZ],o4.prototype,"constantMin",void 0),tX([tZ],o4.prototype,"constantMax",void 0),tX([tZ],o4.prototype,"gradientMin",void 0),tX([tZ],o4.prototype,"gradientMax",void 0);var o8=/*#__PURE__*/function(){function e(e){this._enabled=!1,this._generator=e}return e.prototype._enableMacro=function(e,t,n){return t!==n&&(t&&e.disableMacro(t),n&&e.enableMacro(n)),n},tG(e,[{key:"enabled",get:function(){return this._enabled},set:function(e){this._enabled=e}}]),e}();tX([tq],o8.prototype,"_generator",void 0);var o5=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.color=new o4(new o1([new o2(0,new tO(1,1,1)),new o2(1,new tO(1,1,1))],[new o3(0,1),new o3(1,1)])),t._colorGradientRand=new tk(0,o0.ColorOverLifetime),t._gradientKeysCount=new tI(0,0,0,0),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.color.mode;if(r!==o$.Gradient&&r!==o$.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;e.setFloatArray(t._maxGradientColor,a.gradientMax._getColorTypeArray(i)),e.setFloatArray(t._maxGradientAlpha,a.gradientMax._getAlphaTypeArray()),r===o$.Gradient?n=t._gradientMacro:(e.setFloatArray(t._minGradientColor,a.gradientMin._getColorTypeArray(i)),e.setFloatArray(t._minGradientAlpha,a.gradientMin._getAlphaTypeArray()),n=t._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),e.setVector4(t._gradientKeysCount,this._gradientKeysCount)}this._colorMacro=this._enableMacro(e,this._colorMacro,n)},n._resetRandomSeed=function(e){this._colorGradientRand.reset(e,o0.ColorOverLifetime)},t}(o8);o5._gradientMacro=nH.getByName("RENDERER_COL_GRADIENT"),o5._randomGradientsMacro=nH.getByName("RENDERER_COL_RANDOM_GRADIENTS"),o5._minGradientColor=nY.getByName("renderer_COLMinGradientColor"),o5._minGradientAlpha=nY.getByName("renderer_COLMinGradientAlpha"),o5._maxGradientColor=nY.getByName("renderer_COLMaxGradientColor"),o5._maxGradientAlpha=nY.getByName("renderer_COLMaxGradientAlpha"),o5._gradientKeysCount=nY.getByName("renderer_COLGradientKeysMaxTime"),tX([tZ],o5.prototype,"color",void 0),tX([tq],o5.prototype,"_colorGradientRand",void 0),tX([tq],o5.prototype,"_gradientKeysCount",void 0),tX([tq],o5.prototype,"_colorMacro",void 0);var o9=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._mode=oZ.Constant,this._constantMin=0,this._constantMax=0,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager),"number"==typeof e?t?(this.constantMin=e,this.constantMax=t,this.mode=oZ.TwoConstants):(this.constant=e,this.mode=oZ.Constant):t?(this.curveMin=e,this.curveMax=t,this.mode=oZ.TwoCurves):(this.curve=e,this.mode=oZ.Curve)}var t=e.prototype;return t.evaluate=function(e,t){switch(this.mode){case oZ.Constant:return this.constant;case oZ.TwoConstants:return this.constantMin+(this.constantMax-this.constantMin)*t}},t._getMax=function(){switch(this.mode){case oZ.Constant:return this.constantMax;case oZ.TwoConstants:return Math.max(this.constantMin,this.constantMax);case oZ.Curve:var e;return this._getMaxKeyValue(null==(e=this.curveMax)?void 0:e.keys);case oZ.TwoCurves:var t,n,r=this._getMaxKeyValue(null==(t=this.curveMin)?void 0:t.keys),a=this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys);return r>a?r:a}},t._getMinMax=function(e){switch(this.mode){case oZ.Constant:e.x=e.y=this.constantMax;break;case oZ.TwoConstants:e.set(Math.min(this.constantMin,this.constantMax),Math.max(this.constantMin,this.constantMax));break;case oZ.Curve:var t,n;e.set(this._getMinKeyValue(null==(t=this.curveMax)?void 0:t.keys),this._getMaxKeyValue(null==(n=this.curveMax)?void 0:n.keys));break;case oZ.TwoCurves:var r,a,i,o,s=this._getMinKeyValue(null==(r=this.curveMax)?void 0:r.keys),l=this._getMinKeyValue(null==(a=this.curveMin)?void 0:a.keys),c=this._getMaxKeyValue(null==(i=this.curveMax)?void 0:i.keys),u=this._getMaxKeyValue(null==(o=this.curveMin)?void 0:o.keys);e.set(s<l?s:l,c>u?c:u)}},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._getMaxKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.max(n,e[a].value)}return n},t._getMinKeyValue=function(e){var t,n=void 0,r=null!=(t=null==e?void 0:e.length)?t:0;if(r>0){n=e[0].value;for(var a=1;a<r;a++)n=Math.min(n,e[a].value)}return n},t._onCurveChange=function(e,t){var n=this._updateDispatch;null==e||e._unRegisterOnValueChanged(n),null==t||t._registerOnValueChanged(n),n()},tG(e,[{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}}]),e}();tX([tq],o9.prototype,"_updateManager",void 0),tX([tZ],o9.prototype,"_curveMin",void 0),tX([tZ],o9.prototype,"_curveMax",void 0),tX([tq],o9.prototype,"_updateDispatch",void 0);var o6=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.rateOverTime=new o9(10),t.rateOverDistance=new o9(0),t._shapeRand=new tk(0,o0.Shape),t._frameRateTime=0,t._bursts=[],t._currentBurstIndex=0,t._burstRand=new tk(0,o0.Burst),t}tW(t,e);var n=t.prototype;return n.addBurst=function(e){for(var t=this._bursts,n=t.length;--n>=0&&e.time<t[n].time;);t.splice(n+1,0,e)},n.removeBurst=function(e){var t=this._bursts.indexOf(e);-1!==t&&this._bursts.splice(t,1)},n.removeBurstByIndex=function(e){this._bursts.splice(e,1)},n.clearBurst=function(){this._bursts.length=0},n._emit=function(e,t){this._emitByRateOverTime(t),this._emitByBurst(e,t)},n._resetRandomSeed=function(e){this._burstRand.reset(e,o0.Burst),this._shapeRand.reset(e,o0.Shape)},n._reset=function(){this._frameRateTime=0,this._currentBurstIndex=0},n._destroy=function(){var e;null==(e=this._shape)||e._unRegisterOnValueChanged(this._generator._renderer._onGeneratorParamsChanged)},n._emitByRateOverTime=function(e){var t=this.rateOverTime.evaluate(void 0,void 0);if(t>0)for(var n=this._generator,r=1/t,a=e-this._frameRateTime;a>=r;)a-=r,this._frameRateTime+=r,n._emit(this._frameRateTime,1)},n._emitByBurst=function(e,t){var n=this._generator.main,r=n.duration,a=Math.floor((t-e)/r);if(n.isLoop&&(a>0||t%r<e%r)){var i=Math.ceil(e/r)*r;this._emitBySubBurst(e,i,r),this._currentBurstIndex=0;for(var o=0;o<a;o++){var s=i;i+=r,this._emitBySubBurst(s,i,r),this._currentBurstIndex=0}this._emitBySubBurst(i,t,r)}else this._emitBySubBurst(e,t,r)},n._emitBySubBurst=function(e,t,n){for(var r=this._generator,a=this._burstRand,i=this.bursts,o=Math.floor(e/n)*n,s=e%n,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());r._emit(o+h,_)}}this._currentBurstIndex=c},tG(t,[{key:"shape",get:function(){return this._shape},set:function(e){var t=this._shape;if(e!==t){this._shape=e;var n=this._generator._renderer;null==t||t._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==e||e._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()}}},{key:"bursts",get:function(){return this._bursts}}]),t}(o8);tX([tZ],o6.prototype,"rateOverTime",void 0),tX([tZ],o6.prototype,"rateOverDistance",void 0),tX([tZ],o6.prototype,"_shape",void 0),tX([tq],o6.prototype,"_shapeRand",void 0),tX([tZ],o6.prototype,"_bursts",void 0),tX([tq],o6.prototype,"_burstRand",void 0);var o7=((eQ={})[eQ.Hierarchy=0]="Hierarchy",eQ[eQ.Local=1]="Local",eQ[eQ.World=2]="World",eQ),se=/*#__PURE__*/function(){function e(e){this._tempVector40=new tI,this.duration=5,this.isLoop=!0,this.startDelay=new o9(0),this.startRotation3D=!1,this.startRotationX=new o9(0),this.startRotationY=new o9(0),this.startRotationZ=new o9(0),this.flipRotation=0,this.startColor=new o4(new tO(1,1,1,1)),this.simulationSpeed=1,this.scalingMode=o7.Local,this.playOnEnabled=!0,this._maxParticleBuffer=1e3,this._startDelayRand=new tk(0,o0.StartDelay),this._startSpeedRand=new tk(0,o0.StartSpeed),this._startLifeTimeRand=new tk(0,o0.StartLifetime),this._startColorRand=new tk(0,o0.StartColor),this._startSizeRand=new tk(0,o0.StartSize),this._startRotationRand=new tk(0,o0.StartRotation),this._gravityModifierRand=new tk(0,o0.GravityModifier),this._startSize3D=!1,this._simulationSpace=oY.Local,this._generator=e,this.startLifetime=new o9(5),this.startSpeed=new o9(5),this.startSizeX=new o9(1),this.startSizeY=new o9(1),this.startSizeZ=new o9(1),this.gravityModifier=new o9(0)}var t=e.prototype;return t._resetRandomSeed=function(e){this._startSpeedRand.reset(e,o0.StartSpeed),this._startLifeTimeRand.reset(e,o0.StartLifetime),this._startColorRand.reset(e,o0.StartColor),this._startSizeRand.reset(e,o0.StartSize),this._startRotationRand.reset(e,o0.StartRotation)},t._getPositionScale=function(){var e=this._generator._renderer.entity.transform;switch(this.scalingMode){case o7.Hierarchy:case o7.World:return e.lossyWorldScale;case o7.Local:return e.scale}},t._updateShaderData=function(t){var n=this._generator._renderer,r=n.entity.transform;switch(this.simulationSpace){case oY.Local:t.setVector3(e._worldPosition,r.worldPosition);var a=r.worldRotationQuaternion,i=this._tempVector40.copyFrom(a);t.setVector4(e._worldRotation,i);break;case oY.World:break;default:throw Error("ParticleRenderer: SimulationSpace value is invalid.")}switch(this.scalingMode){case o7.Hierarchy:var o=r.lossyWorldScale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.Local:var o=r.scale;t.setVector3(e._positionScale,o),t.setVector3(e._sizeScale,o);break;case o7.World:t.setVector3(e._positionScale,r.lossyWorldScale),t.setVector3(e._sizeScale,e._vector3One)}t.setVector3(e._gravity,n.scene.physics.gravity),t.setInt(e._simulationSpace,this.simulationSpace),t.setFloat(e._startRotation3D,+this.startRotation3D),t.setInt(e._scaleMode,this.scalingMode)},t._cloneTo=function(e){e.maxParticles=this.maxParticles,e._simulationSpace===oY.World&&e._generator._generateTransformedBounds()},t._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(e,[{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(e){if(e!==this._simulationSpace){this._simulationSpace=e;var t=this._generator;t._renderer._onTransformChanged(rm.WorldMatrix),e===oY.Local&&t._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}}]),e}();se._vector3One=new tT(1,1,1),se._positionScale=nY.getByName("renderer_PositionScale"),se._sizeScale=nY.getByName("renderer_SizeScale"),se._worldPosition=nY.getByName("renderer_WorldPosition"),se._worldRotation=nY.getByName("renderer_WorldRotation"),se._gravity=nY.getByName("renderer_Gravity"),se._simulationSpace=nY.getByName("renderer_SimulationSpace"),se._startRotation3D=nY.getByName("renderer_ThreeDStartRotation"),se._scaleMode=nY.getByName("renderer_ScalingMode"),tX([tZ],se.prototype,"startDelay",void 0),tX([tZ],se.prototype,"startRotationX",void 0),tX([tZ],se.prototype,"startRotationY",void 0),tX([tZ],se.prototype,"startRotationZ",void 0),tX([tZ],se.prototype,"startColor",void 0),tX([tq],se.prototype,"_maxParticleBuffer",void 0),tX([tq],se.prototype,"_startDelayRand",void 0),tX([tq],se.prototype,"_startSpeedRand",void 0),tX([tq],se.prototype,"_startLifeTimeRand",void 0),tX([tq],se.prototype,"_startColorRand",void 0),tX([tq],se.prototype,"_startSizeRand",void 0),tX([tq],se.prototype,"_startRotationRand",void 0),tX([tq],se.prototype,"_gravityModifierRand",void 0),tX([tZ],se.prototype,"_startLifetime",void 0),tX([tZ],se.prototype,"_startSpeed",void 0),tX([tZ],se.prototype,"_startSizeX",void 0),tX([tZ],se.prototype,"_startSizeY",void 0),tX([tZ],se.prototype,"_startSizeZ",void 0),tX([tZ],se.prototype,"_gravityModifier",void 0),tX([tq],se.prototype,"_generator",void 0);var st=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.separateAxes=!1,t.rotationX=new o9(0),t.rotationY=new o9(0),t.rotationZ=new o9(45),t._rotationRand=new tk(0,o0.RotationOverLifetime),t._rotationMinConstant=new tT,t._rotationMaxConstant=new tT,t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.rotationX,o=this.rotationY,s=this.rotationZ,l=this.separateAxes,c=l?i.mode===oZ.TwoCurves&&o.mode===oZ.TwoCurves&&s.mode===oZ.TwoCurves:s.mode===oZ.TwoCurves;if(c||l?i.mode===oZ.Curve&&o.mode===oZ.Curve&&s.mode===oZ.Curve:s.mode===oZ.Curve)e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro;else{var u=this._rotationMaxConstant;if(u.set(tS.degreeToRadian(i.constantMax),tS.degreeToRadian(o.constantMax),tS.degreeToRadian(s.constantMax)),e.setVector3(t._maxConstantProperty,u),l?i.mode===oZ.TwoConstants&&o.mode===oZ.TwoConstants&&s.mode===oZ.TwoConstants:s.mode===oZ.TwoConstants){var d=this._rotationMinConstant;d.set(tS.degreeToRadian(i.constantMin),tS.degreeToRadian(o.constantMin),tS.degreeToRadian(s.constantMin)),e.setVector3(t._minConstantProperty,d),a=t._isRandomTwoMacro}r=t._constantModeMacro}l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._resetRandomSeed=function(e){this._rotationRand.reset(e,o0.RotationOverLifetime)},t}(o8);st._constantModeMacro=nH.getByName("RENDERER_ROL_CONSTANT_MODE"),st._curveModeMacro=nH.getByName("RENDERER_ROL_CURVE_MODE"),st._isSeparateMacro=nH.getByName("RENDERER_ROL_IS_SEPARATE"),st._isRandomTwoMacro=nH.getByName("RENDERER_ROL_IS_RANDOM_TWO"),st._minConstantProperty=nY.getByName("renderer_ROLMinConst"),st._minCurveXProperty=nY.getByName("renderer_ROLMinCurveX"),st._minCurveYProperty=nY.getByName("renderer_ROLMinCurveY"),st._minCurveZProperty=nY.getByName("renderer_ROLMinCurveZ"),st._maxConstantProperty=nY.getByName("renderer_ROLMaxConst"),st._maxCurveXProperty=nY.getByName("renderer_ROLMaxCurveX"),st._maxCurveYProperty=nY.getByName("renderer_ROLMaxCurveY"),st._maxCurveZProperty=nY.getByName("renderer_ROLMaxCurveZ"),tX([tZ],st.prototype,"rotationX",void 0),tX([tZ],st.prototype,"rotationY",void 0),tX([tZ],st.prototype,"rotationZ",void 0),tX([tq],st.prototype,"_rotationRand",void 0),tX([tq],st.prototype,"_rotationMinConstant",void 0),tX([tq],st.prototype,"_rotationMaxConstant",void 0),tX([tq],st.prototype,"_enableSeparateMacro",void 0),tX([tq],st.prototype,"_isCurveMacro",void 0),tX([tq],st.prototype,"_isRandomTwoMacro",void 0);var sn=/*#__PURE__*/function(){function e(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._updateManager=new nM,this._keys=[],this._typeArrayDirty=!1,this._updateDispatch=this._updateManager.dispatch.bind(this._updateManager);for(var r=0,a=t.length;r<a;r++){var i=t[r];this.addKey(i)}}var t=e.prototype;return t.addKey=function(e,t){var n=this._keys;if(4===n.length)throw Error("Curve can only have 4 keys");var r="number"==typeof e?new sr(e,t):e;this._addKey(n,r),r._registerOnValueChanged(this._updateDispatch),this._updateDispatch(),this._typeArrayDirty=!0},t.removeKey=function(e){this._keys.splice(e,1),this._typeArrayDirty=!0,this._keys[e]._unRegisterOnValueChanged(this._updateDispatch),this._updateDispatch()},t.setKeys=function(e){this._keys.length=0;for(var t=0,n=e.length;t<n;t++)this.addKey(e[t]);this._typeArrayDirty=!0},t._getTypeArray=function(){var e=this._typeArray||(this._typeArray=new Float32Array(8));if(this._typeArrayDirty){for(var t=this._keys,n=0,r=Math.min(t.length,4);n<r;n++){var a=2*n,i=t[n];e[a]=i.time,e[a+1]=i.value}this._typeArrayDirty=!1}return e},t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},t._addKey=function(e,t){var n=e.length,r=t.time;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)}},tG(e,[{key:"keys",get:function(){return this._keys}}]),e}();tX([tq],sn.prototype,"_updateManager",void 0),tX([tZ],sn.prototype,"_keys",void 0),tX([tq],sn.prototype,"_typeArray",void 0),tX([tq],sn.prototype,"_updateDispatch",void 0);var sr=/*#__PURE__*/function(){function e(e,t){this._updateManager=new nM,this._time=e,this._value=t}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{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())}}]),e}();tX([tq],sr.prototype,"_updateManager",void 0);var sa=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._separateAxes=!1,n.sizeX=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeY=new o9(new sn(new sr(0,0),new sr(1,1))),n.sizeZ=new o9(new sn(new sr(0,0),new sr(1,1))),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null,r=null,a=null;if(this.enabled){var i=this.sizeX,o=this.sizeY,s=this.sizeZ,l=this.separateAxes,c=l?i.mode===oZ.TwoCurves&&o.mode===oZ.TwoCurves&&s.mode===oZ.TwoCurves:i.mode===oZ.TwoCurves;(c||l?i.mode===oZ.Curve&&o.mode===oZ.Curve&&s.mode===oZ.Curve:i.mode===oZ.Curve)&&(e.setFloatArray(t._maxCurveXProperty,i.curveMax._getTypeArray()),l&&(e.setFloatArray(t._maxCurveYProperty,o.curveMax._getTypeArray()),e.setFloatArray(t._maxCurveZProperty,s.curveMax._getTypeArray())),c&&(e.setFloatArray(t._minCurveXProperty,i.curveMin._getTypeArray()),l&&(e.setFloatArray(t._minCurveYProperty,o.curveMin._getTypeArray()),e.setFloatArray(t._minCurveZProperty,s.curveMin._getTypeArray())),a=t._isRandomTwoMacro),r=t._curveModeMacro),l&&(n=t._isSeparateMacro)}this._enableSeparateMacro=this._enableMacro(e,this._enableSeparateMacro,n),this._isCurveMacro=this._enableMacro(e,this._isCurveMacro,r),this._isRandomTwoMacro=this._enableMacro(e,this._isRandomTwoMacro,a)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{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}}]),t}(o8);sa._curveModeMacro=nH.getByName("RENDERER_SOL_CURVE_MODE"),sa._isSeparateMacro=nH.getByName("RENDERER_SOL_IS_SEPARATE"),sa._isRandomTwoMacro=nH.getByName("RENDERER_SOL_IS_RANDOM_TWO"),sa._minCurveXProperty=nY.getByName("renderer_SOLMinCurveX"),sa._minCurveYProperty=nY.getByName("renderer_SOLMinCurveY"),sa._minCurveZProperty=nY.getByName("renderer_SOLMinCurveZ"),sa._maxCurveXProperty=nY.getByName("renderer_SOLMaxCurveX"),sa._maxCurveYProperty=nY.getByName("renderer_SOLMaxCurveY"),sa._maxCurveZProperty=nY.getByName("renderer_SOLMaxCurveZ"),tX([tZ],sa.prototype,"_sizeX",void 0),tX([tZ],sa.prototype,"_sizeY",void 0),tX([tZ],sa.prototype,"_sizeZ",void 0),tX([tq],sa.prototype,"_enableSeparateMacro",void 0),tX([tq],sa.prototype,"_isCurveMacro",void 0),tX([tq],sa.prototype,"_isRandomTwoMacro",void 0);var si=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.frameOverTime=new o9(new sn(new sr(0,0),new sr(1,1))),t.type=0,t.cycleCount=1,t._tillingInfo=new tT(1,1,1),t._frameOverTimeRand=new tk(0,o0.TextureSheetAnimation),t._tiling=new tB(1,1),t}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.frameOverTime.mode;if(r===oZ.Curve||r===oZ.TwoCurves){var a=this.frameOverTime;e.setFloatArray(t._frameMaxCurveProperty,a.curveMax._getTypeArray()),r===oZ.Curve?n=t._frameCurveMacro:(e.setFloatArray(t._frameMinCurveProperty,a.curveMin._getTypeArray()),n=t._frameRandomCurvesMacro),e.setFloat(t._cycleCountProperty,this.cycleCount),e.setVector3(t._tillingParamsProperty,this._tillingInfo)}}this._frameCurveMacro=this._enableMacro(e,this._frameCurveMacro,n)},n._resetRandomSeed=function(e){this._frameOverTimeRand.reset(e,o0.TextureSheetAnimation)},tG(t,[{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)}}]),t}(o8);si._frameCurveMacro=nH.getByName("RENDERER_TSA_FRAME_CURVE"),si._frameRandomCurvesMacro=nH.getByName("RENDERER_TSA_FRAME_RANDOM_CURVES"),si._frameMinCurveProperty=nY.getByName("renderer_TSAFrameMinCurve"),si._frameMaxCurveProperty=nY.getByName("renderer_TSAFrameMaxCurve"),si._cycleCountProperty=nY.getByName("renderer_TSACycles"),si._tillingParamsProperty=nY.getByName("renderer_TSATillingParams"),tX([tZ],si.prototype,"frameOverTime",void 0),tX([tJ],si.prototype,"_tillingInfo",void 0),tX([tq],si.prototype,"_frameOverTimeRand",void 0),tX([tZ],si.prototype,"_tiling",void 0),tX([tq],si.prototype,"_frameCurveMacro",void 0);var so=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this)._velocityRand=new tk(0,o0.VelocityOverLifetime),n._velocityMinConstant=new tT,n._velocityMaxConstant=new tT,n._space=oY.Local,n.velocityX=new o9(0),n.velocityY=new o9(0),n.velocityZ=new o9(0),n}tW(t,e);var n=t.prototype;return n._updateShaderData=function(e){var n=null;if(this.enabled){var r=this.velocityX,a=this.velocityY,i=this.velocityZ,o=r.mode===oZ.TwoCurves&&a.mode===oZ.TwoCurves&&i.mode===oZ.TwoCurves;if(o||r.mode===oZ.Curve&&a.mode===oZ.Curve&&i.mode===oZ.Curve)e.setFloatArray(t._maxGradientXProperty,r.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientYProperty,a.curveMax._getTypeArray()),e.setFloatArray(t._maxGradientZProperty,i.curveMax._getTypeArray()),o?(e.setFloatArray(t._minGradientXProperty,r.curveMin._getTypeArray()),e.setFloatArray(t._minGradientYProperty,a.curveMin._getTypeArray()),e.setFloatArray(t._minGradientZProperty,i.curveMin._getTypeArray()),n=t._randomCurveMacro):n=t._curveMacro;else{var s=this._velocityMaxConstant;if(s.set(r.constantMax,a.constantMax,i.constantMax),e.setVector3(t._maxConstantProperty,s),r.mode===oZ.TwoConstants&&a.mode===oZ.TwoConstants&&i.mode===oZ.TwoConstants){var l=this._velocityMinConstant;l.set(r.constantMin,a.constantMin,i.constantMin),e.setVector3(t._minConstantProperty,l),n=t._randomConstantMacro}else n=t._constantMacro}e.setInt(t._spaceProperty,this.space)}this._velocityMacro=this._enableMacro(e,this._velocityMacro,n)},n._resetRandomSeed=function(e){this._velocityRand.reset(e,o0.VelocityOverLifetime)},n._onCompositeCurveChange=function(e,t){var n=this._generator._renderer;null==e||e._unRegisterOnValueChanged(n._onGeneratorParamsChanged),null==t||t._registerOnValueChanged(n._onGeneratorParamsChanged),n._onGeneratorParamsChanged()},tG(t,[{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())}}]),t}(o8);so._constantMacro=nH.getByName("RENDERER_VOL_CONSTANT"),so._curveMacro=nH.getByName("RENDERER_VOL_CURVE"),so._randomConstantMacro=nH.getByName("RENDERER_VOL_RANDOM_CONSTANT"),so._randomCurveMacro=nH.getByName("RENDERER_VOL_RANDOM_CURVE"),so._minConstantProperty=nY.getByName("renderer_VOLMinConst"),so._maxConstantProperty=nY.getByName("renderer_VOLMaxConst"),so._minGradientXProperty=nY.getByName("renderer_VOLMinGradientX"),so._minGradientYProperty=nY.getByName("renderer_VOLMinGradientY"),so._minGradientZProperty=nY.getByName("renderer_VOLMinGradientZ"),so._maxGradientXProperty=nY.getByName("renderer_VOLMaxGradientX"),so._maxGradientYProperty=nY.getByName("renderer_VOLMaxGradientY"),so._maxGradientZProperty=nY.getByName("renderer_VOLMaxGradientZ"),so._spaceProperty=nY.getByName("renderer_VOLSpace"),tX([tq],so.prototype,"_velocityRand",void 0),tX([tq],so.prototype,"_velocityMinConstant",void 0),tX([tq],so.prototype,"_velocityMaxConstant",void 0),tX([tq],so.prototype,"_velocityMacro",void 0),tX([tZ],so.prototype,"_velocityX",void 0),tX([tZ],so.prototype,"_velocityY",void 0),tX([tZ],so.prototype,"_velocityZ",void 0);var ss=/*#__PURE__*/function(){function e(t){this.useAutoRandomSeed=!0,this.emission=new o6(this),this.rotationOverLifetime=new st(this),this.colorOverLifetime=new o5(this),this.textureSheetAnimation=new si(this),this._currentParticleCount=0,this._playTime=0,this._firstNewElement=0,this._firstActiveElement=0,this._firstFreeElement=0,this._firstRetiredElement=0,this._vertexBufferBindings=[],this._subPrimitive=new ay(0,0,ar.Triangles),this._isPlaying=!1,this._instanceBufferResized=!1,this._waitProcessRetiredElementCount=0,this._randomSeed=0,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0,this._playStartDelay=0,this._renderer=t,new av().start=0,this._primitive=new ax(t.engine),this._reorganizeGeometryBuffers(),this._resizeInstanceBuffer(!0,e._particleIncreaseCount),this.main=new se(this),this.velocityOverLifetime=new so(this),this.sizeOverLifetime=new sa(this),this.emission.enabled=!0}var t=e.prototype;return t.play=function(t){if(void 0===t&&(t=!0),t)for(var n=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),r=0,a=n.length;r<a;r++)n[r].generator.play(!1);else this._isPlaying=!0,this.useAutoRandomSeed&&this._resetGlobalRandSeed(Math.floor(0xffffffff*Math.random())),this._playStartDelay=this.main.startDelay.evaluate(void 0,this.main._startDelayRand.random())},t.stop=function(t,n){if(void 0===t&&(t=!0),void 0===n&&(n=oq.StopEmitting),t)for(var r=this._renderer.entity.getComponentsIncludeChildren(oQ,e._tempParticleRenderers),a=0,i=r.length;a<i;a++)r[a].generator.stop(!1,n);else if(this._isPlaying=!1,n===oq.StopEmittingAndClear){var o=this._firstFreeElement;this._firstRetiredElement=o,this._firstActiveElement=o,this._firstNewElement=o,this._playTime=0,this._firstActiveTransformedBoundingBox=this._firstFreeTransformedBoundingBox,this.emission._reset()}},t.emit=function(e){this._emit(this._playTime,e)},t._emit=function(t,n){if(this.emission.enabled&&!(this._getNotRetiredParticleCount()>=this.main.maxParticles))for(var r=e._tempVector30,a=e._tempVector31,i=this._renderer.entity.transform,o=this.emission.shape,s=0;s<n;s++){if(null==o?void 0:o.enabled){o._generatePositionAndDirection(this.emission._shapeRand,t,r,a);var l=this.main._getPositionScale();r.multiply(l),a.normalize().multiply(l)}else r.set(0,0,0),a.set(0,0,-1);this._addNewParticle(r,a,i,t)}},t._update=function(e){var t=this.isAlive,n=this.main,r=this.emission,a=n.duration,i=this._playTime,o=e*n.simulationSpeed;if(this._playStartDelay>0){var s=this._playStartDelay-=o;if(!(s<0))return;this._playTime-=s,this._playStartDelay=0}if(this._playTime+=o,this._retireActiveParticles(),this._freeRetiredParticles(),n.simulationSpace===oY.World&&this._retireTransformedBounds(),r.enabled&&this._isPlaying&&(this._currentParticleCount>n._maxParticleBuffer&&this._getNotRetiredParticleCount()<n._maxParticleBuffer&&this._resizeInstanceBuffer(!1),r._emit(i,this._playTime),!n.isLoop&&this._playTime>a&&(this._isPlaying=!1)),this.isAlive)n.simulationSpace===oY.World&&this._generateTransformedBounds();else{var l=Math.min(r._frameRateTime,Math.floor(this._playTime/a)*a);this._playTime-=l,r._frameRateTime-=l}this.isAlive!==t&&this._renderer._onWorldVolumeChanged(),(this._firstNewElement!=this._firstFreeElement||this._waitProcessRetiredElementCount>0||this._instanceBufferResized||this._instanceVertexBufferBinding._buffer.isContentLost)&&this._addActiveParticlesToVertexBuffer()},t._reorganizeGeometryBuffers=function(){var e=this._renderer,t=e.engine._particleBufferUtils,n=this._primitive,r=this._vertexBufferBindings;if(n.clearVertexElements(),r.length=0,e.renderMode===oK.Mesh){var a=e.mesh;if(!a)return;var i=a.getVertexElement(aR.Position),o=a.getVertexElement(aR.Color),s=a.getVertexElement(aR.UV),l=i?a.vertexBufferBindings[i.bindingIndex]:null,c=o?a.vertexBufferBindings[o.bindingIndex]:null,u=s?a.vertexBufferBindings[s.bindingIndex]:null;if(l){var d=this._addVertexBufferBindingsFilterDuplicate(l,r);n.addVertexElement(new at(aR.Position,i.offset,i.format,d))}if(c){var h=this._addVertexBufferBindingsFilterDuplicate(c,r);n.addVertexElement(new at(aR.Color,o.offset,o.format,h))}if(u){var _=this._addVertexBufferBindingsFilterDuplicate(u,r);n.addVertexElement(new at(aR.UV,s.offset,s.format,_))}var f=a._primitive.indexBufferBinding;n.setIndexBufferBinding(f),this._subPrimitive.count=f.buffer.byteLength/n._glIndexByteCount}else n.addVertexElement(t.billboardVertexElement),r.push(t.billboardVertexBufferBinding),n.setIndexBufferBinding(t.billboardIndexBufferBinding),this._subPrimitive.count=iW.billboardIndexCount;n.setVertexBufferBindings(r);for(var p=t.instanceVertexElements,m=r.length,g=0,v=p.length;g<v;g++){var y=p[g];n.addVertexElement(new at(y.attribute,y.offset,y.format,m,y.instanceStepRate))}},t._resizeInstanceBuffer=function(e,t){null==(u=this._instanceVertexBufferBinding)||u.buffer.destroy();var n=iW.instanceVertexStride,r=e?this._currentParticleCount+t:this.main._maxParticleBuffer,a=n*r,i=new r9(this._renderer.engine,an.VertexBuffer,a,r8.Dynamic,!1);i.isGCIgnored=!0;var o=this._primitive.vertexBufferBindings,s=new aS(i,n),l=new Float32Array(a/4),c=this._instanceVertices;if(c){var u,d,h,_=iW.instanceVertexFloatStride,f=this._firstFreeElement,p=this._firstRetiredElement;if(e){l.set(new Float32Array(c.buffer,0,f*_));var m=f+1;l.set(new Float32Array(c.buffer,m*_*4),(m+t)*_),this._firstNewElement>f&&(this._firstNewElement+=t),this._firstActiveElement>f&&(this._firstActiveElement+=t),p>f&&(this._firstRetiredElement+=t)}else p<=f?(d=f-p,h=0,this._firstFreeElement-=p,this._firstNewElement-=p,this._firstActiveElement-=p,this._firstRetiredElement=0):(d=this._currentParticleCount-p,h=f,this._firstNewElement>f&&(this._firstNewElement-=f),this._firstActiveElement>f&&(this._firstActiveElement-=f),p>f&&(this._firstRetiredElement-=f)),l.set(new Float32Array(c.buffer,p*_*4,d*_),h*_);this._instanceBufferResized=!0}this._primitive.setVertexBufferBinding(c?o.length-1:o.length,s),this._instanceVertices=l,this._instanceVertexBufferBinding=s,this._currentParticleCount=r},t._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)},t._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)},t._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},t._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},t._destroy=function(){this._instanceVertexBufferBinding.buffer.destroy(),this._primitive.destroy(),this.emission._destroy()},t._updateBoundsSimulationLocal=function(e){var t=this._renderer,n=this.main.startLifetime._getMax(),r=t._generatorBounds,a=t._transformedBounds;t._isContainDirtyFlag(oJ.GeneratorVolume)&&(this._calculateGeneratorBounds(n,r),t._setDirtyFlagFalse(oJ.GeneratorVolume)),t._isContainDirtyFlag(oJ.TransformVolume)&&(this._calculateTransformedBounds(n,r,a),t._setDirtyFlagFalse(oJ.TransformVolume)),this._addGravityToBounds(n,a,e)},t._updateBoundsSimulationWorld=function(e){var t=this._transformedBoundsArray,n=this._firstActiveTransformedBoundingBox,r=this._firstFreeTransformedBoundingBox,a=n*iW.boundsFloatStride;if(e.min.copyFromArray(t,a),e.max.copyFromArray(t,a+3),n<r)for(var i=n+1;i<r;i++)this._mergeTransformedBounds(i,e);else{for(var o=n+1,s=this._transformedBoundsCount;o<s;o++)this._mergeTransformedBounds(o,e);if(r>0)for(var l=0;l<r;l++)this._mergeTransformedBounds(l,e)}var c=this.main.startLifetime._getMax();this._addGravityToBounds(c,e,e)},t._freeBoundsArray=function(){this._transformedBoundsArray=null,this._transformedBoundsCount=0,this._firstActiveTransformedBoundingBox=0,this._firstFreeTransformedBoundingBox=0},t._generateTransformedBounds=function(){var e=this._renderer,t=this.main.startLifetime._getMax(),n=e._generatorBounds;e._isContainDirtyFlag(oJ.GeneratorVolume)&&(this._calculateGeneratorBounds(t,n),e._setDirtyFlagFalse(oJ.GeneratorVolume));var r=iW.boundsFloatStride,a=iW.boundsTimeOffset,i=iW.boundsMaxLifetimeOffset,o=this._firstFreeTransformedBoundingBox;if(e._isContainDirtyFlag(oJ.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,n,l);var c=o*r,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(oJ.TransformVolume)}else{var d=this._firstFreeTransformedBoundingBox-1;d<0&&(d=this._transformedBoundsCount),this._transformedBoundsArray[d*iW.boundsFloatStride+a]=this._playTime}},t._addNewParticle=function(t,n,r,a){var i,o,s=this._firstFreeElement,l=s+1;l>=this._currentParticleCount&&(l=0);var c=this.main;if(l===this._firstRetiredElement){var u=Math.min(e._particleIncreaseCount,c._maxParticleBuffer-this._currentParticleCount);if(0===u)return;this._resizeInstanceBuffer(!0,u),l=s+1}c.simulationSpace===oY.World&&(i=r.worldPosition,o=r.worldRotationQuaternion);var d=c.startSpeed.evaluate(void 0,c._startSpeedRand.random()),h=this._instanceVertices,_=s*iW.instanceVertexFloatStride;h[_]=t.x,h[_+1]=t.y,h[_+2]=t.z,h[_+iW.startLifeTimeOffset]=c.startLifetime.evaluate(void 0,c._startLifeTimeRand.random()),h[_+4]=n.x,h[_+5]=n.y,h[_+6]=n.z,h[_+iW.timeOffset]=a;var f=e._tempColor0;c.startColor.evaluate(void 0,c._startColorRand.random(),f),this._renderer.engine.settings.colorSpace===n2.Linear&&f.toLinear(f),h[_+8]=f.r,h[_+9]=f.g,h[_+10]=f.b,h[_+11]=f.a;var p=c._startSizeRand;if(c.startSize3D)h[_+12]=c.startSizeX.evaluate(void 0,p.random()),h[_+13]=c.startSizeY.evaluate(void 0,p.random()),h[_+14]=c.startSizeZ.evaluate(void 0,p.random());else{var m=c.startSize.evaluate(void 0,p.random());h[_+12]=m,h[_+13]=m,h[_+14]=m}var g=c._startRotationRand;switch(c.startRotation3D?(h[_+15]=tS.degreeToRadian(c.startRotationX.evaluate(void 0,g.random())),h[_+16]=tS.degreeToRadian(c.startRotationY.evaluate(void 0,g.random())),h[_+17]=tS.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random()))):h[_+15]=tS.degreeToRadian(c.startRotationZ.evaluate(void 0,g.random())),h[_+18]=d,c.gravityModifier.mode){case oZ.Constant:h[_+19]=c.gravityModifier.constant;break;case oZ.TwoConstants:h[_+19]=c.gravityModifier.evaluate(void 0,c._gravityModifierRand.random())}var v=this.colorOverLifetime;v.enabled&&v.color.mode===o$.TwoGradients&&(h[_+20]=v._colorGradientRand.random());var y=this.rotationOverLifetime;y.enabled&&y.rotationZ.mode===oZ.TwoConstants&&(h[_+22]=y._rotationRand.random());var x=this.textureSheetAnimation;x.enabled&&x.frameOverTime.mode===oZ.TwoCurves&&(h[_+23]=x._frameOverTimeRand.random());var b=this.velocityOverLifetime;if(b.enabled&&b.velocityX.mode===oZ.TwoConstants&&b.velocityY.mode===oZ.TwoConstants&&b.velocityZ.mode===oZ.TwoConstants){var C=b._velocityRand;h[_+24]=C.random(),h[_+25]=C.random(),h[_+26]=C.random()}if(this.main.simulationSpace===oY.World&&(h[_+27]=i.x,h[_+28]=i.y,h[_+29]=i.z,h[_+30]=o.x,h[_+31]=o.y,h[_+32]=o.z,h[_+33]=o.w),x.enabled){var S=x.frameOverTime,T=x._tillingInfo,A=T.x,E=T.y,R=T.z,M=0;(S.mode===oZ.Constant||S.mode===oZ.TwoConstants)&&(M=Math.floor(S.evaluate(void 0,x._frameOverTimeRand.random())*R)*A);var w=Math.floor(M);h[_+iW.simulationUVOffset]=A,h[_+35]=E,h[_+36]=M-w,h[_+37]=w*E}else h[_+iW.simulationUVOffset]=1,h[_+35]=1,h[_+36]=0,h[_+37]=0;this._firstFreeElement=l},t._retireActiveParticles=function(){for(var e=this._renderer.engine.time.frameCount,t=this._instanceVertices;this._firstActiveElement!==this._firstNewElement;){var n=this._firstActiveElement*iW.instanceVertexFloatStride,r=n+iW.timeOffset;if(Math.fround(this._playTime-t[r])<t[n+iW.startLifeTimeOffset])break;t[r]=e,++this._firstActiveElement>=this._currentParticleCount&&(this._firstActiveElement=0),this._waitProcessRetiredElementCount++}},t._freeRetiredParticles=function(){for(var e=this._renderer.engine.time.frameCount;this._firstRetiredElement!==this._firstActiveElement;){var t=this._firstRetiredElement*iW.instanceVertexFloatStride+iW.startLifeTimeOffset;if(e-this._instanceVertices[t]<0)break;++this._firstRetiredElement>=this._currentParticleCount&&(this._firstRetiredElement=0)}},t._addActiveParticlesToVertexBuffer=function(){var e=this._firstActiveElement,t=this._firstFreeElement;if(e!==t){var n=iW.instanceVertexStride,r=e*n,a=this._instanceVertexBufferBinding.buffer,i=this._instanceVertices.buffer;if(e<t)a.setData(i,0,r,(t-e)*n,r5.Discard);else{var o=(this._currentParticleCount-e)*n;a.setData(i,0,r,o,r5.Discard),t>0&&a.setData(i,o,0,t*n)}this._firstNewElement=t,this._waitProcessRetiredElementCount=0,this._instanceBufferResized=!1}},t._addVertexBufferBindingsFilterDuplicate=function(e,t){for(var n=0,r=t.length;n<r;n++)if(t[n]===e)return n;return t.push(e),n},t._resizeTransformedBoundsArray=function(){var t=iW.boundsFloatStride,n=e._transformedBoundsIncreaseCount;this._transformedBoundsCount+=n;var r=this._transformedBoundsArray,a=new Float32Array(this._transformedBoundsCount*t);if(r){var i=this._firstFreeTransformedBoundingBox;a.set(new Float32Array(r.buffer,0,i*t));var o=i+1;a.set(new Float32Array(r.buffer,o*t*4),(o+n)*t),this._firstActiveTransformedBoundingBox>i&&(this._firstActiveTransformedBoundingBox+=n)}this._transformedBoundsArray=a},t._retireTransformedBounds=function(){for(var e=iW.boundsFloatStride,t=iW.boundsTimeOffset,n=iW.boundsMaxLifetimeOffset,r=this._transformedBoundsArray,a=this._firstFreeTransformedBoundingBox,i=this._transformedBoundsCount;this._firstActiveTransformedBoundingBox!==a;){var o=this._firstActiveTransformedBoundingBox*e;if(this._playTime-r[o+t]<=r[o+n])break;++this._firstActiveTransformedBoundingBox>=i&&(this._firstActiveTransformedBoundingBox=0),this._renderer._onWorldVolumeChanged()}},t._calculateGeneratorBounds=function(t,n){var r=e._tempVector30,a=e._tempVector31,i=e._tempVector20,o=n.min,s=n.max,l=this.main,c=this.emission.shape;(null==c?void 0:c.enabled)?(c._getPositionRange(o,s),c._getDirectionRange(a,r)):(o.set(0,0,0),s.set(0,0,0),a.set(0,0,-1),r.set(0,0,0)),this._getExtremeValueFromZero(l.startSpeed,i);var u=i.x,d=i.y,h=a.x,_=a.y,f=a.z,p=r.x,m=r.y,g=r.z;o.set(o.x+Math.min(h*d,p*u)*t,o.y+Math.min(_*d,m*u)*t,o.z+Math.min(f*d,g*u)*t),s.set(s.x+Math.max(h*u,p*d)*t,s.y+Math.max(_*u,m*d)*t,s.z+Math.max(f*u,g*d)*t);var v=l.startSize._getMax();if(l.startSize3D){var y=l.startSizeY._getMax();v=this._renderer.renderMode===oK.Billboard||oK.StretchBillboard||oK.HorizontalBillboard?Math.max(v,y):Math.max(v,y,l.startSizeZ._getMax())}v*=1.414;var x=this.sizeOverLifetime;if(x.enabled){var b=x.size._getMax();x.separateAxes&&(b=Math.max(b,x.sizeY._getMax(),x.sizeZ._getMax())),v*=b}o.set(o.x-v,o.y-v,o.z-v),s.set(s.x+v,s.y+v,s.z+v)},t._mergeTransformedBounds=function(e,t){var n=t.min,r=t.max,a=this._transformedBoundsArray,i=e*iW.boundsFloatStride;n.set(Math.min(n.x,a[i]),Math.min(n.y,a[i+1]),Math.min(n.z,a[i+2])),r.set(Math.max(r.x,a[i+3]),Math.max(r.y,a[i+4]),Math.max(r.z,a[i+5]))},t._calculateTransformedBounds=function(t,n,r){var a=e._tempVector20,i=e._tempVector21,o=e._tempVector22,s=e._tempMat,l=this._renderer.entity.transform,c=l.worldPosition;tL.rotationQuaternion(l.worldRotationQuaternion,s);var u=n.min,d=n.max,h=r.min,_=r.max,f=this.velocityOverLifetime;f.enabled?(this._getExtremeValueFromZero(f.velocityX,a),this._getExtremeValueFromZero(f.velocityY,i),this._getExtremeValueFromZero(f.velocityZ,o),f.space===oY.Local?(h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t),r.transform(s)):(r.transform(s),h.set(u.x+a.x*t,u.y+i.x*t,u.z+o.x*t),_.set(d.x+a.y*t,d.y+i.y*t,d.z+o.y*t))):tE.transform(n,s,r),h.add(c),_.add(c)},t._addGravityToBounds=function(t,n,r){var a=n.min,i=n.max,o=e._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*t*t,h=o.x*d,_=o.y*d,f=l*h,p=l*_,m=c*h,g=c*_,v=u*h,y=u*_;r.min.set(Math.min(f,p)+a.x,Math.min(m,g)+a.y,Math.min(v,y)+a.z),r.max.set(Math.max(f,p)+i.x,Math.max(m,g)+i.y,Math.max(v,y)+i.z)},t._getExtremeValueFromZero=function(e,t){e._getMinMax(t),t.x=Math.min(0,t.x),t.y=Math.max(0,t.y)},tG(e,[{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}}]),e}();ss._tempVector20=new tB,ss._tempVector21=new tB,ss._tempVector22=new tB,ss._tempVector30=new tT,ss._tempVector31=new tT,ss._tempMat=new tL,ss._tempColor0=new tO,ss._tempParticleRenderers=[],ss._particleIncreaseCount=128,ss._transformedBoundsIncreaseCount=16,tX([tZ],ss.prototype,"main",void 0),tX([tZ],ss.prototype,"emission",void 0),tX([tZ],ss.prototype,"velocityOverLifetime",void 0),tX([tZ],ss.prototype,"sizeOverLifetime",void 0),tX([tZ],ss.prototype,"rotationOverLifetime",void 0),tX([tZ],ss.prototype,"colorOverLifetime",void 0),tX([tZ],ss.prototype,"textureSheetAnimation",void 0),tX([tq],ss.prototype,"_playTime",void 0),tX([tq],ss.prototype,"_firstNewElement",void 0),tX([tq],ss.prototype,"_firstActiveElement",void 0),tX([tq],ss.prototype,"_firstFreeElement",void 0),tX([tq],ss.prototype,"_firstRetiredElement",void 0),tX([tq],ss.prototype,"_primitive",void 0),tX([tq],ss.prototype,"_vertexBufferBindings",void 0),tX([tq],ss.prototype,"_subPrimitive",void 0),tX([tq],ss.prototype,"_renderer",void 0),tX([tq],ss.prototype,"_isPlaying",void 0),tX([tq],ss.prototype,"_instanceBufferResized",void 0),tX([tq],ss.prototype,"_waitProcessRetiredElementCount",void 0),tX([tq],ss.prototype,"_instanceVertexBufferBinding",void 0),tX([tq],ss.prototype,"_instanceVertices",void 0),tX([tq],ss.prototype,"_transformedBoundsArray",void 0),tX([tq],ss.prototype,"_transformedBoundsCount",void 0),tX([tq],ss.prototype,"_firstActiveTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_firstFreeTransformedBoundingBox",void 0),tX([tq],ss.prototype,"_playStartDelay",void 0);var sl=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t,ro.find("particle-shader"))||this).shaderData.setColor(as._baseColorProp,new tO(1,1,1,1)),n.isTransparent=!0,n}return tW(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},tG(t,[{key:"baseColor",get:function(){return this.shaderData.getColor(as._baseColorProp)},set:function(e){var t=this.shaderData.getColor(as._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(as._baseTextureProp)},set:function(e){this.shaderData.setTexture(as._baseTextureProp,e),e?this.shaderData.enableMacro(as._baseTextureMacro):this.shaderData.disableMacro(as._baseTextureMacro)}}]),t}(as),sc=function(e,t){this.time=e,this.count=t};tX([tZ],sc.prototype,"count",void 0);var su=/*#__PURE__*/function(){function e(){this._updateManager=new nM,this._enabled=!0,this._randomDirectionAmount=0}var t=e.prototype;return t._registerOnValueChanged=function(e){this._updateManager.addListener(e)},t._unRegisterOnValueChanged=function(e){this._updateManager.removeListener(e)},tG(e,[{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())}}]),e}();tX([tq],su.prototype,"_updateManager",void 0);var sd=/*#__PURE__*/function(){function e(){}return e.randomPointUnitArcCircle=function(e,t,n){var r=n.random()*e;t.x=Math.cos(r),t.y=Math.sin(r)},e.randomPointInsideUnitArcCircle=function(t,n,r){e.randomPointUnitArcCircle(t,n,r);var a=Math.sqrt(r.random());n.x=n.x*a,n.y=n.y*a},e.randomPointUnitCircle=function(e,t){var n=t.random()*Math.PI*2;e.x=Math.cos(n),e.y=Math.sin(n)},e.randomPointInsideUnitCircle=function(t,n){e.randomPointUnitCircle(t,n);var r=Math.sqrt(n.random());t.x=t.x*r,t.y=t.y*r},e._randomPointUnitSphere=function(e,t){var n=2*t.random()-1,r=t.random()*Math.PI*2,a=Math.sqrt(1-n*n);e.x=a*Math.cos(r),e.y=a*Math.sin(r),e.z=n},e._randomPointInsideUnitSphere=function(t,n){e._randomPointUnitSphere(t,n);var r=Math.pow(n.random(),1/3);t.x=t.x*r,t.y=t.y*r,t.z=t.z*r},e._randomPointInsideHalfUnitBox=function(e,t){void 0===t&&(t=null),e.x=t.random()-.5,e.y=t.random()-.5,e.z=t.random()-.5},e}(),sh=((eJ={})[eJ.Box=0]="Box",eJ[eJ.Circle=1]="Circle",eJ[eJ.Cone=2]="Cone",eJ[eJ.Hemisphere=3]="Hemisphere",eJ[eJ.Sphere=4]="Sphere",eJ),s_=/*#__PURE__*/function(e){function t(){var t;return(t=e.call(this)||this).shapeType=sh.Box,t._size=new tT(1,1,1),t._size._onValueChanged=t._updateManager.dispatch.bind(t._updateManager),t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){sd._randomPointInsideHalfUnitBox(r,e),r.multiply(this.size);var i=t._tempVector30;i.set(0,0,-1),sd._randomPointUnitSphere(a,e),tT.lerp(i,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=Math.PI*this.randomDirectionAmount;if(this.randomDirectionAmount<.5){var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)}else{var a=Math.cos(n);e.set(-1,-1,-1),t.set(1,1,-a)}},n._getPositionRange=function(e,t){var n=this._size,r=n.x,a=n.y,i=n.z;e.set(-(.5*r),-(.5*a),-(.5*i)),t.set(.5*r,.5*a,.5*i)},tG(t,[{key:"size",get:function(){return this._size},set:function(e){e!==this._size&&this._size.copyFrom(e)}}]),t}(su);s_._tempVector30=new tT,tX([tZ],s_.prototype,"_size",void 0);var sf=((eZ={})[eZ.Random=0]="Random",eZ[eZ.Loop=1]="Loop",eZ),sp=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Circle,t._radius=1,t._arc=360,t._arcMode=sf.Random,t._arcSpeed=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempPositionPoint;switch(this.arcMode){case sf.Loop:var o=n*this.arcSpeed*(360/this.arc)%1,s=tS.degreeToRadian(this.arc*o);i.set(Math.cos(s),Math.sin(s)),i.scale(e.random());break;case sf.Random:sd.randomPointInsideUnitArcCircle(tS.degreeToRadian(this.arc),i,e)}r.set(i.x,i.y,0),r.scale(this.radius),sd._randomPointUnitSphere(a,e),tT.lerp(r,a,this.randomDirectionAmount,a)},n._getDirectionRange=function(e,t){var n=this.randomDirectionAmount>.5?1:Math.sin(this.randomDirectionAmount*Math.PI),r=.5*(360-this._arc)*this.randomDirectionAmount,a=r>90?-1:-Math.sin(r);this._getUnitArcRange(this._arc+r,e,t,a,n)},n._getPositionRange=function(e,t){this._getUnitArcRange(this._arc,e,t,0,0),e.scale(this._radius),t.scale(this._radius)},n._getUnitArcRange=function(e,t,n,r,a){var i=tS.degreeToRadian(e),o=Math.sin(i),s=Math.cos(i);e<90?(t.set(0,r,-a),n.set(1,o,a)):(e<180?t.set(s,r,-a):e<270?t.set(-1,Math.min(o,r),-a):t.set(-1,-1,-a),n.set(1,1,a))},tG(t,[{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())}}]),t}(su);sp._tempPositionPoint=new tB;var sm=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Cone,t._angle=25,t._radius=1,t._length=5,t._emitType=0,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,n,r,a){var i=t._tempVector20,o=tS.degreeToRadian(this.angle),s=Math.sin(o),l=Math.cos(o);switch(this.emitType){case 0:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0);var c=t._tempVector21;sd.randomPointInsideUnitCircle(c,e),tB.lerp(i,c,this.randomDirectionAmount,c),a.set(c.x*s,c.y*s,-l);break;case 1:sd.randomPointInsideUnitCircle(i,e),r.set(i.x*this.radius,i.y*this.radius,0),a.set(i.x*s,i.y*s,-l),a.normalize();var u=t._tempVector30;tT.scale(a,this.length*e.random(),u),r.add(u);var d=t._tempVector31;sd._randomPointUnitSphere(d,e),tT.lerp(a,d,this.randomDirectionAmount,a)}},n._getDirectionRange=function(e,t){var n=0;switch(this.emitType){case 0:n=tS.degreeToRadian(this._angle);break;case 1:n=Math.sin(tS.degreeToRadian((180-this._angle)*this.randomDirectionAmount+this._angle))}var r=Math.sin(n);e.set(-r,-r,-1),t.set(r,r,0)},n._getPositionRange=function(e,t){var n=this.radius;switch(this.emitType){case 0:e.set(-n,-n,0),t.set(n,n,0);break;case 1:var r=this.length,a=Math.sin(tS.degreeToRadian(this._angle));e.set(-n-a*r,-n-a*r,-r),t.set(n+a*r,n+a*r,0)}},tG(t,[{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())}}]),t}(su);sm._tempVector20=new tB,sm._tempVector21=new tB,sm._tempVector30=new tT,sm._tempVector31=new tT;var sg=((e$={})[e$.Base=0]="Base",e$[e$.Volume=1]="Volume",e$),sv=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Hemisphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius);var a=n.z;a>0&&(n.z=-a),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){var n=Math.sin(.5*this.randomDirectionAmount*Math.PI);e.set(-1,-1,-1),t.set(1,1,n)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,0)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su),sy=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.shapeType=sh.Sphere,t._radius=1,t}tW(t,e);var n=t.prototype;return n._generatePositionAndDirection=function(e,t,n,r){sd._randomPointInsideUnitSphere(n,e),n.scale(this.radius),sd._randomPointUnitSphere(r,e),tT.lerp(n,r,this.randomDirectionAmount,r)},n._getDirectionRange=function(e,t){e.set(-1,-1,-1),t.set(1,1,1)},n._getPositionRange=function(e,t){var n=this._radius;e.set(-n,-n,-n),t.set(n,n,n)},tG(t,[{key:"radius",get:function(){return this._radius},set:function(e){e!==this._radius&&(this._radius=e,this._updateManager.dispatch())}}]),t}(su);ro.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 sx=/*#__PURE__*/function(e){function t(t){var n,r=(n=e.call(this,t,ro.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=nF.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=nF.One,n.renderState.depthState.writeEnabled=!1,n}return tW(t,e),t}(ao),sb=new tT,sC=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t)||this)._stroke=n.stroke||.2,r._minSeg=n.minSeg||.02,r._lifetime=n.lifetime||1e3,r._maxPointNum=r._lifetime/1e3*t.engine.targetFrameRate,r._points=[],r._pointStates=[],r._strapPoints=[];for(var r,a=0;a<r._maxPointNum;a++)r._points.push(new tT),r._pointStates.push(r._lifetime),r._strapPoints.push(new tT),r._strapPoints.push(new tT);r._curPointNum=0;var i=n.material||new sx(r.engine);return r.setMaterial(i),r.setTexture(n.texture),r._initGeometry(),r}tW(t,e);var n=t.prototype;return n.update=function(e){for(var t=0,n=0,r=0;r<this._curPointNum;r++)this._pointStates[r]-=e,this._pointStates[r]<0?t++:t>0&&(n=r-t,this._pointStates[n]=this._pointStates[r],this._points[n].copyFrom(this._points[r]));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];tT.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++)},n.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},n._render=function(t){this._updateStrapVertices(t.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),e.prototype._render.call(this,t)},n._initGeometry=function(){var e=new aT(this._entity.engine),t=2*this._maxPointNum,n=20*t,r=new Float32Array(n),a=[new at("POSITION",0,r7.Vector3,0),new at("TEXCOORD_0",12,r7.Vector2,0)],i=new r9(this.engine,4*n,r8.Dynamic);e.setVertexBufferBinding(i,20),e.setVertexElements(a),e.addSubMesh(0,t,ar.TriangleStrip),this._vertexBuffer=i,this._vertexStride=20,this._vertices=r,this.mesh=e},n._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new tT(n[0],n[4],n[8]),a=new tT(n[1],n[5],n[9]),i=new tT(n[2],n[6],n[10]),o=this._stroke;a.scale(o);var s=new tT,l=new tT,c=new tF;tT.transformByQuat(r,c,r),tT.transformByQuat(a,c,a);var u=new tT,d=new tT,h=new tT;r.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?tT.subtract(p,t[f-1],h):tT.subtract(t[f+1],p,h),this._projectOnPlane(h,i,h),h.normalize();var m=Math.acos(tT.dot(r,h));tT.cross(r,h,d),0>=tT.dot(d,i)&&(m=2*Math.PI-m),tF.rotationAxisAngle(i,m,c),tT.transformByQuat(a,c,u),tT.add(p,u,s),tT.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}},n._updateStrapCoords=function(){if(this._prePointsNum!==this._curPointNum){this._prePointsNum=this._curPointNum;for(var e=this._curPointNum,t=1/e,n=this._vertices,r=0;r<e;r++){var a=1-r*t,i=2*r*this._vertexStride/4,o=(2*r+1)*this._vertexStride/4;n[i]=0,n[i+1]=a,n[o]=1,n[o+1]=a}}},n._projectOnVector=function(e,t,n){var r=t.clone();tT.normalize(r,r);var a=tT.dot(e,r);n.x=r.x*a,n.y=r.y*a,n.z=r.z*a},n._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,sb),tT.subtract(e,sb,n)},t}(aA),sS=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.probeLayer=rE.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t}tW(t,e);var n=t.prototype;return n.onTextureChange=function(e){},n.onBeginRender=function(e){this.enabled&&(this._camera=e,this._oriCameraCullingMask=e.cullingMask,e.cullingMask=this.probeLayer,this._activeRenderTarget&&this._activeRenderTarget.width===this.width&&this._activeRenderTarget.height===this.height&&this._activeRenderTarget.antiAliasing===this.antiAliasing||(this._renderTarget=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._renderTargetSwap=new nl(this.engine,this.width,this.height,this._isCube?new nd(this.engine,this.width):new nc(this.engine,this.width,this.height),t3.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=e.renderTarget,e.renderTarget=this._activeRenderTarget)},n.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},n._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},tG(t,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),t}(os),sT=new tT,sA=new tT,sE=new tT,sR=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t.position=new tT(0,0,0),t._isCube=!0,t.oriViewMatrix=new tL,t}tW(t,e);var n=t.prototype;return n.onBeginRender=function(t){if(this.enabled){e.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var n=0;n<6;n++)this._setCamera(n,t),t.render(t4.PositiveX+n);this._restoreCamera(t),e.prototype._reset.call(this)}},n._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},n._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},n._setCamera=function(e,t){switch(e){case 0:sA.set(0,-1,0),sE.set(1,0,0);break;case 1:sA.set(0,-1,0),sE.set(-1,0,0);break;case 2:sA.set(0,0,1),sE.set(0,1,0);break;case 3:sA.set(0,0,-1),sE.set(0,-1,0);break;case 4:sA.set(0,-1,0),sE.set(0,0,1);break;case 5:sA.set(0,-1,0),sE.set(0,0,-1)}tT.add(this.position,sE,sT),tL.lookAt(this.position,sT,sA,t.viewMatrix),t.fieldOfView=90},t}(sS),sM=/*#__PURE__*/function(e){function t(t,n){var r;return void 0===n&&(n=""),(r=e.call(this,t)||this)._audioBuffer=null,r.name=n,r}tW(t,e);var n=t.prototype;return n._getAudioSource=function(){return this._audioBuffer},n._setAudioSource=function(e){this._audioBuffer=e},n._onDestroy=function(){e.prototype._onDestroy.call(this),this._audioBuffer=null,this.name=null},tG(t,[{key:"channels",get:function(){return this._audioBuffer.numberOfChannels}},{key:"sampleRate",get:function(){return this._audioBuffer.sampleRate}},{key:"duration",get:function(){return this._audioBuffer.duration}}]),t}(t1),sw=/*#__PURE__*/function(){function e(){}return e.getContext=function(){var t=e._context;return t||(e._context=t=new window.AudioContext,document.addEventListener("pointerdown",e._tryResume,!0),document.addEventListener("touchend",e._tryResume,!0),document.addEventListener("touchstart",e._tryResume,!0)),t},e.getGainNode=function(){var t=e._gainNode;return e._gainNode||(e._gainNode=t=e.getContext().createGain(),t.connect(e.getContext().destination)),t},e.isAudioContextRunning=function(){return"running"===e.getContext().state||(console.warn("The AudioContext is not running and requires user interaction, such as a click or touch."),!1)},e._tryResume=function(){"running"===e._context.state||e._isResuming||(e._isResuming=!0,e._context.resume().then(function(){e._isResuming=!1}))},e}();sw._isResuming=!1;var sP=/*#__PURE__*/function(e){function t(t){var n;return(n=e.call(this,t)||this).playOnEnabled=!0,n._isPlaying=!1,n._sourceNode=null,n._pausedTime=-1,n._playTime=-1,n._volume=1,n._lastVolume=1,n._playbackRate=1,n._loop=!1,n._onPlayEnd=n._onPlayEnd.bind(n),n._gainNode=sw.getContext().createGain(),n._gainNode.connect(sw.getGainNode()),n}tW(t,e);var n=t.prototype;return n.play=function(){if(this._canPlay()&&!this._isPlaying){var e=this._pausedTime>0?this._pausedTime-this._playTime:0;this._initSourceNode(e),this._playTime=sw.getContext().currentTime-e,this._pausedTime=-1,this._isPlaying=!0}},n.stop=function(){this._isPlaying&&(this._clearSourceNode(),this._isPlaying=!1,this._pausedTime=-1,this._playTime=-1)},n.pause=function(){this._isPlaying&&(this._clearSourceNode(),this._pausedTime=sw.getContext().currentTime,this._isPlaying=!1)},n._onEnable=function(){this.playOnEnabled&&this.play()},n._onDisable=function(){this.pause()},n._onDestroy=function(){e.prototype._onDestroy.call(this),this.stop(),this.clip=null},n._onPlayEnd=function(){this.stop()},n._initSourceNode=function(e){var t=sw.getContext().createBufferSource();t.buffer=this._clip._getAudioSource(),t.playbackRate.value=this._playbackRate,t.loop=this._loop,t.onended=this._onPlayEnd,this._sourceNode=t,t.connect(this._gainNode),this._sourceNode.start(0,e)},n._clearSourceNode=function(){this._sourceNode.stop(),this._sourceNode.disconnect(),this._sourceNode.onended=null,this._sourceNode=null},n._canPlay=function(){var e;return null!=(e=this._clip)&&!!e._getAudioSource()&&sw.isAudioContextRunning()},tG(t,[{key:"clip",get:function(){return this._clip},set:function(e){var t=this._clip;t!==e&&(t&&t._addReferCount(-1),e&&e._addReferCount(1),this._clip=e,this.stop())}},{key:"isPlaying",get:function(){return this._isPlaying}},{key:"volume",get:function(){return this._volume},set:function(e){e=Math.min(Math.max(0,e),1),this._volume=e,this._gainNode.gain.setValueAtTime(e,sw.getContext().currentTime)}},{key:"playbackRate",get:function(){return this._playbackRate},set:function(e){this._playbackRate=e,this._isPlaying&&(this._sourceNode.playbackRate.value=this._playbackRate)}},{key:"mute",get:function(){return 0===this.volume},set:function(e){e?(this._lastVolume=this.volume,this.volume=0):this.volume=this._lastVolume}},{key:"loop",get:function(){return this._loop},set:function(e){e!==this._loop&&(this._loop=e,this._isPlaying&&(this._sourceNode.loop=this._loop))}},{key:"time",get:function(){return this._isPlaying?sw.getContext().currentTime-this._playTime:this._pausedTime>0?this._pausedTime-this._playTime:0}}]),t}(ru);tX([tq],sP.prototype,"_isPlaying",void 0),tX([tq],sP.prototype,"_clip",void 0),tX([tZ],sP.prototype,"_gainNode",void 0),tX([tq],sP.prototype,"_sourceNode",void 0),tX([tZ],sP.prototype,"_pausedTime",void 0),tX([tq],sP.prototype,"_playTime",void 0),tX([tZ],sP.prototype,"_volume",void 0),tX([tZ],sP.prototype,"_lastVolume",void 0),tX([tZ],sP.prototype,"_playbackRate",void 0),tX([tZ],sP.prototype,"_loop",void 0),/*#__PURE__*/(function(){function e(){}return e.registerPolyfill=function(){e._registerMatchAll()},e._registerMatchAll=function(){String.prototype.matchAll||(no.info("polyfill String.prototype.matchAll"),String.prototype.matchAll=function(e){var t=e.flags;if(-1===t.indexOf("g"))throw TypeError("String.prototype.matchAll called with a non-global RegExp argument");var n=this;return function(){var r,a,i,o,s,l;return function(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,function(c){switch(c.label){case 0:if(null==(r=n.match(e)))return[2,null];for(s in a=t.split("g").join(""),i=new RegExp(e.source,a),o=[],r)o.push(s);l=0,c.label=1;case 1:if(!(l<o.length))return[3,4];return[4,r[o[l]].match(i)];case 2:c.sent(),c.label=3;case 3:return l++,[3,1];case 4:return[2]}})}()})},e})().registerPolyfill();var sF=/*#__PURE__*/Object.freeze({__proto__:null,AmbientLight:i8,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:ov,AnimationClipCurveBinding:om,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:ox,AnimationEvent:og,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:oD,AnimatorCondition:oR,AnimatorConditionMode:ob,AnimatorController:oI,AnimatorControllerLayer:oz,AnimatorControllerParameter:oB,AnimatorCullingMode:oC,AnimatorLayerBlendingMode:oS,AnimatorLayerMask:oH,AnimatorState:oV,AnimatorStateMachine:ok,AnimatorStateTransition:oM,AssetPromise:a8,AssetType:a2,AudioClip:sM,AudioManager:sw,AudioSource:sP,Background:i0,BackgroundMode:rO,BackgroundTextureFillMode:rN,BaseMaterial:as,BasicRenderPipeline:rZ,BlendFactor:nF,BlendMode:aa,BlendOperation:nL,BlendShape:am,BlendShapeFrame:af,BlendState:rt,BlinnPhongMaterial:al,BloomDownScaleMode:ot,BloomEffect:on,BoolUpdateFlag:rf,BoxColliderShape:iI,BoxShape:s_,Buffer:r9,BufferBindFlag:an,BufferMesh:aT,BufferUsage:r8,BufferUtil:ae,Burst:sc,get Camera(){return e.Camera},CameraClearFlags:rw,CameraType:rP,Canvas:iZ,CapsuleColliderShape:iV,CharacterController:ig,CircleShape:sp,ClearableObjectPool:iq,CloneManager:t$,get Collider(){return e.Collider},ColliderShape:iB,ColliderShapeUpAxis:iA,CollisionDetectionMode:iy,ColorOverLifetimeModule:o5,ColorSpace:n2,ColorWriteMask:nD,CompareFunction:nB,Component:ru,ConeEmitType:sg,ConeShape:sm,ContentRestorer:t2,ControllerCollisionFlag:iE,ControllerNonWalkableMode:im,CubeProbe:sR,CullMode:nI,CurveKey:sr,DataType:nQ,DependentMode:r_,DepthState:rn,DepthTextureMode:rF,DiffuseMode:i4,DirectLight:i9,DisorderedArray:rC,Downsampling:rL,DynamicCollider:iv,DynamicColliderConstraints:ix,EmissionModule:o6,Engine:iJ,EngineObject:t0,Entity:aW,EventDispatcher:nK,FixedJoint:iM,FogMode:i3,Font:ng,FontStyle:n_,GLCapabilityType:nJ,GradientAlphaKey:o3,GradientColorKey:o2,HemisphereShape:sv,HingeJoint:iP,HitResult:ib,IndexBufferBinding:ag,IndexFormat:r6,InputManager:iU,InterpolationType:oy,get Joint(){return e.Joint},JointLimits:iL,JointMotor:iD,Keyframe:oU,Keys:ih,Layer:rE,LayerPathMask:oG,Light:i5,Loader:ol,Logger:no,MSAASamples:rD,MainModule:se,Material:ao,Mesh:ab,MeshRenderer:aA,MeshTopology:ar,ModelMesh:aM,OverflowMode:nf,PBRBaseMaterial:au,PBRMaterial:ad,PBRSpecularMaterial:ah,ParticleCompositeCurve:o9,ParticleCompositeGradient:o4,ParticleCurve:sn,ParticleCurveMode:oZ,ParticleGenerator:ss,ParticleGradient:o1,ParticleGradientMode:o$,ParticleMaterial:sl,ParticleRenderMode:oK,ParticleRenderer:oQ,ParticleScaleMode:o7,ParticleShapeArcMode:sf,ParticleShapeType:sh,ParticleSimulationSpace:oY,ParticleStopMode:oq,PhysicsMaterial:iS,PhysicsMaterialCombineMode:iC,PhysicsScene:ip,PipelineStage:nX,PlaneColliderShape:iN,Platform:tz,PointLight:i6,Pointer:is,PointerButton:il,PointerPhase:io,Primitive:ax,PrimitiveMesh:az,Probe:sS,RasterState:rr,ReferResource:t1,RenderBufferDepthFormat:t3,RenderFace:ai,RenderQueue:rG,RenderQueueType:nN,RenderState:ri,RenderStateDataKey:nO,RenderTarget:nl,RenderTargetBlendState:re,get Renderer(){return e.Renderer},ReplacementFailureStrategy:rB,ResourceManager:ie,ReturnableObjectPool:aQ,RotationOverLifetimeModule:st,SafeLoopArray:a3,Scene:oo,SceneManager:a4,Script:os,SetDataOptions:r5,Shader:ro,ShaderData:rs,ShaderFactory:n$,ShaderLib:nZ,ShaderMacro:nH,ShaderMacroCollection:nW,ShaderPass:n6,ShaderPlatformTarget:nz,ShaderProperty:nY,ShaderPropertyType:nV,ShaderTagKey:n0,ShadowCascadesMode:rK,ShadowResolution:rW,ShadowType:rj,SizeOverLifetimeModule:sa,Skin:aj,SkinnedMeshRenderer:aK,Sky:i$,SkyBoxMaterial:oW,SkyProceduralMaterial:oX,SphereColliderShape:iO,SphereShape:sy,SpotLight:i7,SpringJoint:iF,Sprite:nP,SpriteAtlas:nb,SpriteDrawMode:nC,SpriteMask:r2,SpriteMaskInteraction:nv,SpriteMaskLayer:rg,SpriteRenderer:rT,SpriteTileMode:nS,StateMachineScript:oN,StaticCollider:iT,StencilOperation:nk,StencilState:ra,SubMesh:ay,SubPrimitive:av,SubShader:n7,SunMode:oj,SystemInfo:id,TextHorizontalAlignment:ny,TextRenderer:r3,TextUtils:np,TextVerticalAlignment:nx,Texture:ns,Texture2D:nc,Texture2DArray:nu,TextureCoordinate:ac,TextureCube:nd,TextureCubeFace:t4,TextureDepthCompareFunction:t8,TextureFilterMode:t5,TextureFormat:t9,TextureSheetAnimationModule:si,TextureUsage:t6,TextureWrapMode:t7,Time:nq,TonemappingEffect:oa,TonemappingMode:or,TrailMaterial:sx,TrailRenderer:sC,Transform:rp,UnlitMaterial:a_,Utils:nT,VelocityOverLifetimeModule:so,VertexAttribute:aR,VertexBufferBinding:aS,VertexElement:at,VertexElementFormat:r7,WrapMode:ow,XRManager:iQ,_PostProcessManager:oi,assignmentClone:tQ,deepClone:tZ,dependentComponents:rh,ignoreClone:tq,request:a6,resourceLoader:it,shallowClone:tJ}),sL=((e0={})[e0.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",e0[e0.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",e0[e0.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",e0[e0.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",e0[e0.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",e0[e0.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",e0[e0.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",e0[e0.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",e0[e0.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",e0[e0.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",e0[e0.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",e0[e0.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",e0[e0.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",e0[e0.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",e0[e0.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",e0[e0.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",e0[e0.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",e0[e0.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",e0[e0.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",e0[e0.R11_EAC=37488]="R11_EAC",e0[e0.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",e0[e0.RG11_EAC=37490]="RG11_EAC",e0[e0.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",e0[e0.RGB8_ETC2=37492]="RGB8_ETC2",e0[e0.SRGB8_ETC2=37493]="SRGB8_ETC2",e0[e0.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e0[e0.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",e0[e0.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",e0[e0.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",e0[e0.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",e0[e0.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",e0[e0.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",e0[e0.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",e0[e0.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",e0[e0.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",e0[e0.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",e0[e0.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",e0[e0.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",e0[e0.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT",e0);function sD(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function sB(e,t,n){return t&&sD(e.prototype,t),n&&sD(e,n),e}function sI(e,t){return(sI=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sO(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&&sI(e,t)}function sN(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var sV=/*#__PURE__*/function(e){function t(t){(n=e.call(this)||this)._scale=new tB;var n,r=t.width,a=t.height;return n._webCanvas=t,n.width=r,n.height=a,n}sO(t,e);var n=t.prototype;return n.resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;if("undefined"==typeof OffscreenCanvas||!sN(t,OffscreenCanvas)){var n=t.clientWidth*e,r=t.clientHeight*e;this.width=n,this.height=r}},n.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},n._onWidthChanged=function(e){this._webCanvas.width=e},n._onHeightChange=function(e){this._webCanvas.height=e},sB(t,[{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&sN(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&&sN(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),t}(iZ),sk=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return sO(t,e),t.create=function(e){var n=e.canvas,r=new t(new sV("string"==typeof n?document.getElementById(n):n),new sZ(e.graphicDeviceOptions),e);return r._initialize(e).then(function(){return r.sceneManager.addScene(new oo(r,"DefaultScene")),r})},sB(t,[{key:"canvas",get:function(){return this._canvas}}]),t}(iJ);function sz(){return(sz=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var sU=/*#__PURE__*/function(){function e(e,t,n,r,a){void 0===r&&(r=r8.Static);var i=e.gl,o=i.createBuffer(),s=this._getGLBufferUsage(i,r),l=t===an.VertexBuffer?i.ARRAY_BUFFER:i.ELEMENT_ARRAY_BUFFER;this._gl=i,this._glBuffer=o,this._glBufferUsage=s,this._glBindTarget=l,this._isWebGL2=e.isWebGL2,this.bind(),a?i.bufferData(l,a,s):i.bufferData(l,n,s),i.bindBuffer(l,null)}var t=e.prototype;return t.bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},t.setData=function(e,t,n,r,a,i){var o=this._gl,s=this._glBindTarget;this.bind(),i===r5.Discard&&o.bufferData(s,e,this._glBufferUsage);var l=t.BYTES_PER_ELEMENT||1,c=a?l*a:t.byteLength;if(0!==r||c<t.byteLength){var u=void 0!==t.byteOffset;if(this._isWebGL2&&u)o.bufferSubData(s,n,t,r,c/l);else{var d=new Uint8Array(u?t.buffer:t,r*l,c);o.bufferSubData(s,n,d)}}else o.bufferSubData(s,n,t);o.bindBuffer(s,null)},t.getData=function(e,t,n,r){if(this._isWebGL2){var a=this._gl;this.bind(),a.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},t.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},t._getGLBufferUsage=function(e,t){switch(t){case r8.Static:return e.STATIC_DRAW;case r8.Dynamic:return e.DYNAMIC_DRAW;case r8.Stream:return e.STREAM_DRAW}},e}(),sG=/*#__PURE__*/function(){function e(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}var t=e.prototype;return t.canIUse=function(e){return this.capabilityList.get(e)},t.canIUseCompressedTextureInternalFormat=function(e){var t=sL.RGBA_ASTC_4X4_KHR,n=sL.RGBA_ASTC_12X12_KHR,r=sL.SRGB8_ALPHA8_ASTC_4X4_KHR,a=sL.SRGB8_ALPHA8_ASTC_12X12_KHR,i=sL.RGB_ETC1_WEBGL,o=sL.R11_EAC,s=sL.SRGB8_ALPHA8_ETC2_EAC,l=sL.RGB_PVRTC_4BPPV1_IMG,c=sL.RGBA_PVRTC_2BPPV1_IMG,u=sL.RGB_S3TC_DXT1_EXT,d=sL.RGBA_S3TC_DXT5_EXT,h=sL.RGBA_BPTC_UNORM_EXT,_=sL.RGB_BPTC_UNSIGNED_FLOAT_EXT;return e>=t&&n<=n||e>=r&&e<=a?this.canIUse(nJ.astc):e===i?this.canIUse(nJ.etc1):e>=o&&e<=s?this.canIUse(nJ.etc):e>=l&&e<=c?this.canIUse(nJ.pvrtc):e>=u&&e<=d?this.canIUse(nJ.s3tc):!!(e>=h)&&!!(e<=_)&&this.canIUse(nJ.bptc)},t._init=function(){var e=this.capabilityList,t=this.rhi.isWebGL2,n=this.rhi.requireExtension.bind(this.rhi),r=nJ.shaderVertexID,a=nJ.standardDerivatives,i=nJ.shaderTextureLod,o=nJ.elementIndexUint,s=nJ.depthTexture,l=nJ.vertexArrayObject,c=nJ.instancedArrays,u=nJ.multipleSample,d=nJ.drawBuffers,h=nJ.blendMinMax,_=nJ.astc,f=nJ.astc_webkit,p=nJ.etc,m=nJ.etc_webkit,g=nJ.etc1,v=nJ.etc1_webkit,y=nJ.pvrtc,x=nJ.pvrtc_webkit,b=nJ.s3tc,C=nJ.s3tc_webkit,S=nJ.bptc,T=nJ.textureFloat,A=nJ.textureHalfFloat,E=nJ.textureFloatLinear,R=nJ.textureHalfFloatLinear,M=nJ.WEBGL_colorBufferFloat,w=nJ.colorBufferFloat,P=nJ.colorBufferHalfFloat,F=nJ.textureFilterAnisotropic,L=nJ.fragDepth;e.set(r,t),e.set(a,t||!!n(a)),e.set(i,t||!!n(i)),e.set(o,t||!!n(o)),e.set(s,t||!!n(s)),e.set(l,t||!!n(l)),e.set(c,t||!!n(c)),e.set(u,t),e.set(d,t||!!n(d)),e.set(h,t||!!n(h)),e.set(T,t||!!n(T)),e.set(A,t||!!n(A)),e.set(E,!!n(E)),e.set(R,t||!!n(R)),e.set(w,t&&!!n(w)||!!n(M)),e.set(P,t&&!!n(w)||!!n(P)),e.set(F,!!n(F)),e.set(L,t||!!n(L)),e.set(_,!!(n(_)||n(f))),e.set(p,!!(n(p)||n(m))),e.set(g,!!(n(g)||n(v))),e.set(y,!!(n(y)||n(x))),e.set(b,!!(n(b)||n(C))),e.set(S,!!n(S))},t._compatibleInterface=function(e,t){var n=this.rhi,r=n.gl,a=null;if(a=n.requireExtension(e))for(var i in t){var o=a[t[i]];(null==o?void 0:o.bind)?r[i]=o.bind(a):r[i]=o}},t._compatibleAllInterface=function(){var e=nJ.depthTexture,t=nJ.vertexArrayObject,n=nJ.instancedArrays,r=nJ.drawBuffers,a=nJ.textureFilterAnisotropic,i=nJ.textureHalfFloat,o=nJ.colorBufferHalfFloat,s=nJ.WEBGL_colorBufferFloat,l=nJ.blendMinMax;if(!this.rhi.isWebGL2){this._compatibleInterface(l,{MIN:"MIN_EXT",MAX:"MAX_EXT"}),this._compatibleInterface(e,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(t,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(n,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(r,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var c={};if(this.canIUse(nJ.drawBuffers)){for(var u=this.maxDrawBuffers,d=0;d<u;d++)0!=d&&(c["COLOR_ATTACHMENT"+d]="COLOR_ATTACHMENT"+d+"_WEBGL"),c["DRAW_BUFFER"+d]="DRAW_BUFFER"+d+"_WEBGL";this._compatibleInterface(r,sz({drawBuffers:"drawBuffersWEBGL"},c))}this._compatibleInterface(i,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(o,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(s,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},sB(e,[{key:"maxTextureSize",get:function(){return this.rhi.renderStates.getParameter(this.rhi.gl.MAX_TEXTURE_SIZE)}},{key:"canUseFloatTextureBlendShape",get:function(){return this.canIUse(nJ.shaderVertexID)&&this.canIUse(nJ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"canIUseMoreJoints",get:function(){return this.canIUse(nJ.textureFloat)&&this.rhi.renderStates.getParameter(this.rhi.gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}},{key:"maxDrawBuffers",get:function(){return this._maxDrawBuffers||(this.canIUse(nJ.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 e=this._rhi.requireExtension(nJ.textureFilterAnisotropic);this._maxAnisoLevel=e?this._rhi.gl.getParameter(e.MAX_TEXTURE_MAX_ANISOTROPY_EXT):1}return this._maxAnisoLevel}},{key:"maxAntiAliasing",get:function(){if(!this._maxAntiAliasing){var e=this._rhi.gl,t=this.canIUse(nJ.multipleSample);this._maxAntiAliasing=t?e.getParameter(e.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),e}(),sH=/*#__PURE__*/function(){function e(e){this.rhi=e,this._requireResult={}}return e.prototype.requireExtension=function(e){return void 0!==this._requireResult[e]||(this._requireResult[e]=this.rhi.gl.getExtension(e)),this._requireResult[e]},e}(),sW=/*#__PURE__*/function(){function e(e,t){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=t,this._canUseInstancedArrays=e.canIUse(nJ.instancedArrays),this._isSupportVAO=e.canIUse(nJ.vertexArrayObject),this._gl=e.gl}var t=e.prototype;return t.draw=function(e,t){var n=this._gl,r=this._primitive,a=this._isSupportVAO&&r.enableVAO;if(a){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var i=this._vaoMap.get(e.id);n.bindVertexArray(i)}else this._bindBufferAndAttrib(e);var o=r.indexBufferBinding,s=r.instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,d=t.start,h=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)n.drawElementsInstanced(u,h,l,d*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,h,l,d*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,d,h,s)}else no.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)n.drawElements(u,h,l,d*c);else{var f=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(u,h,l,d*c),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(u,d,h);a?n.bindVertexArray(null):this._disableAttrib()},t.destroy=function(){this._isSupportVAO&&this._clearVAO()},t._bindBufferAndAttrib=function(e){var t,n,r=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;n!==(t=h._platformBuffer._glBuffer)&&(n=t,r.bindBuffer(r.ARRAY_BUFFER,t)),r.enableVertexAttribArray(c);var f=u._formatMetaInfo;r.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&r.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else no.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},t._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},t._registerVAO=function(e){var t=this._gl,n=t.createVertexArray();t.bindVertexArray(n);var r=this._primitive.indexBufferBinding;r&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.buffer._platformBuffer._glBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,n)},t._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},e}(),sj=/*#__PURE__*/function(){function e(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)}return e.prototype.getParameter=function(e){return this._parameters[e]},e}(),sX=/*#__PURE__*/function(){function e(e,t,n){this._texture=t,this._rhi=e,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=n,this._glTexture=this._gl.createTexture()}var t=e.prototype;return t.destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},t.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},t.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},t._bind=function(){this._rhi.bindTexture(this)},t._init=function(e){var t=this._gl,n=this._isWebGL2,r=this._formatDetail,a=r.internalFormat,i=r.baseFormat,o=r.dataType,s=this._texture,l=s.mipmapCount,c=s.width,u=s.height,d=s.usage,h=s._isDepthTexture;if(this._bind(),n&&!(i===t.LUMINANCE_ALPHA||i===t.ALPHA)&&d!==t6.Dynamic)t.texStorage2D(this._target,l,a,c,u);else if(e)for(var _=0;_<l;_++)for(var f=Math.max(1,c>>_),p=0;p<6;p++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+p,_,a,f,f,0,i,o,null);else if(h)t.texImage2D(this._target,0,a,c,u,0,i,o,null);else for(var m=0;m<l;m++){var g=Math.max(1,c>>m),v=Math.max(1,u>>m);t.texImage2D(this._target,m,a,g,v,0,i,o,null)}},t._getPixelBuffer=function(e,t,n,r,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,no.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,n,r,a,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t._setWrapMode=function(t,n){var r=this._gl,a=this._isWebGL2,i=this._target,o=this._texture,s=o.width,l=o.height;switch(a||t===t7.Clamp||e._isPowerOf2(s)&&e._isPowerOf2(l)||(no.warn("non-power-2 texture is not supported for REPEAT or MIRRORED_REPEAT in WebGL1,and has automatically downgraded to CLAMP_TO_EDGE"),t=t7.Clamp),t){case t7.Clamp:r.texParameteri(i,n,r.CLAMP_TO_EDGE);break;case t7.Repeat:r.texParameteri(i,n,r.REPEAT);break;case t7.Mirror:r.texParameteri(i,n,r.MIRRORED_REPEAT)}},t._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},e._isPowerOf2=function(e){return(e&e-1)==0},e._getFormatDetail=function(e,t,n){switch(e){case t9.R8G8B8:return{internalFormat:n?t.RGB8:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R8G8B8A8:return{internalFormat:n?t.RGBA8:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R4G4B4A4:return{internalFormat:n?t.RGBA4:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case t9.R5G5B5A1:return{internalFormat:n?t.RGB5_A1:t.RGBA,baseFormat:t.RGBA,dataType:t.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case t9.R5G6B5:return{internalFormat:n?t.RGB565:t.RGB,baseFormat:t.RGB,dataType:t.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case t9.Alpha8:return{internalFormat:t.ALPHA,baseFormat:t.ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.LuminanceAlpha:return{internalFormat:t.LUMINANCE_ALPHA,baseFormat:t.LUMINANCE_ALPHA,dataType:t.UNSIGNED_BYTE,isCompressed:!1};case t9.R11G11B10_UFloat:return{internalFormat:n?t.R11F_G11F_B10F:t.NONE,baseFormat:t.RGB,dataType:t.FLOAT,isCompressed:!1};case t9.R16G16B16A16:return{internalFormat:n?t.RGBA16F:t.RGBA,baseFormat:t.RGBA,dataType:t.HALF_FLOAT,isCompressed:!1};case t9.R32G32B32A32:return{internalFormat:n?t.RGBA32F:t.RGBA,baseFormat:t.RGBA,dataType:t.FLOAT,isCompressed:!1};case t9.R32G32B32A32_UInt:return{internalFormat:n?t.RGBA32UI:t.NONE,baseFormat:t.RGBA_INTEGER,dataType:t.UNSIGNED_INT,isCompressed:!1};case t9.BC1:return{internalFormat:sL.RGB_S3TC_DXT1_EXT,isCompressed:!0};case t9.BC3:return{internalFormat:sL.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case t9.BC7:return{internalFormat:sL.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case t9.ETC1_RGB:return{internalFormat:sL.RGB_ETC1_WEBGL,isCompressed:!0};case t9.ETC2_RGB:return{internalFormat:sL.RGB8_ETC2,isCompressed:!0};case t9.ETC2_RGBA5:return{internalFormat:sL.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case t9.ETC2_RGBA8:return{internalFormat:sL.RGBA8_ETC2_EAC,isCompressed:!0};case t9.PVRTC_RGB2:return{internalFormat:sL.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA2:return{internalFormat:sL.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGB4:return{internalFormat:sL.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.PVRTC_RGBA4:return{internalFormat:sL.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case t9.ASTC_4x4:return{internalFormat:sL.RGBA_ASTC_4X4_KHR,isCompressed:!0};case t9.ASTC_5x5:return{internalFormat:sL.RGBA_ASTC_5X5_KHR,isCompressed:!0};case t9.ASTC_6x6:return{internalFormat:sL.RGBA_ASTC_6X6_KHR,isCompressed:!0};case t9.ASTC_8x8:return{internalFormat:sL.RGBA_ASTC_8X8_KHR,isCompressed:!0};case t9.ASTC_10x10:return{internalFormat:sL.RGBA_ASTC_10X10_KHR,isCompressed:!0};case t9.ASTC_12x12:return{internalFormat:sL.RGBA_ASTC_12X12_KHR,isCompressed:!0};case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:n?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._getRenderBufferDepthFormatDetail=function(e,t,n){switch(e){case t9.Depth:return{internalFormat:n?t.DEPTH_COMPONENT32F:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:n?t.FLOAT:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.DepthStencil:return{internalFormat:n?t.DEPTH32F_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:n?t.FLOAT_32_UNSIGNED_INT_24_8_REV:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Stencil:return{internalFormat:t.STENCIL_INDEX8,baseFormat:t.STENCIL_ATTACHMENT,dataType:t.UNSIGNED_BYTE,isCompressed:!1,attachment:t.STENCIL_ATTACHMENT};case t9.Depth16:return{internalFormat:t.DEPTH_COMPONENT16,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_SHORT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth24Stencil8:return{internalFormat:n?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,baseFormat:t.DEPTH_STENCIL,dataType:t.UNSIGNED_INT_24_8,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};case t9.Depth24:return{internalFormat:t.DEPTH_COMPONENT24,baseFormat:t.DEPTH_COMPONENT,dataType:t.UNSIGNED_INT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32:return{internalFormat:t.DEPTH_COMPONENT32F,baseFormat:t.DEPTH_COMPONENT,dataType:t.FLOAT,isCompressed:!1,attachment:t.DEPTH_ATTACHMENT};case t9.Depth32Stencil8:return{internalFormat:t.DEPTH32F_STENCIL8,baseFormat:t.DEPTH_STENCIL,dataType:t.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:t.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+e)}},e._supportTextureFormat=function(e,t){switch(e){case t9.R16G16B16A16:if(!t.canIUse(nJ.textureHalfFloat))return!1;break;case t9.R32G32B32A32:if(!t.canIUse(nJ.textureFloat))return!1;break;case t9.Depth16:case t9.Depth24Stencil8:case t9.Depth:case t9.DepthStencil:if(!t.canIUse(nJ.depthTexture))return!1;break;case t9.R11G11B10_UFloat:case t9.R32G32B32A32_UInt:case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return t.isWebGL2}return!0},e._supportRenderBufferColorFormat=function(e,t){var n=!0;switch(e){case t9.R16G16B16A16:t.canIUse(nJ.colorBufferHalfFloat)&&t.canIUse(nJ.textureHalfFloat)||(n=!1);break;case t9.R32G32B32A32:t.canIUse(nJ.colorBufferFloat)&&t.canIUse(nJ.textureFloat)||(n=!1);break;case t9.R11G11B10_UFloat:n=t.isWebGL2}return n},e._supportRenderBufferDepthFormat=function(e,t){if(!t.isWebGL2)switch(e){case t9.Depth24:case t9.Depth32:case t9.Depth32Stencil8:return!1}return!0},sB(e,[{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(e){var t=this._gl,n=this._target,r=this._texture._mipmap;switch(this._bind(),e){case t5.Point:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.NEAREST_MIPMAP_NEAREST:t.NEAREST);break;case t5.Bilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_NEAREST:t.LINEAR);break;case t5.Trilinear:t.texParameteri(n,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(n,t.TEXTURE_MIN_FILTER,r?t.LINEAR_MIPMAP_LINEAR:t.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(e){this._bind();var t=this._gl;switch(e){case t8.Never:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NEVER);break;case t8.Less:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LESS);break;case t8.Equal:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.EQUAL);break;case t8.LessEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.LEQUAL);break;case t8.Greater:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GREATER);break;case t8.NotEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.NOTEQUAL);break;case t8.GreaterEqual:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.GEQUAL);break;case t8.Always:t.texParameteri(this._target,t.TEXTURE_COMPARE_FUNC,t.ALWAYS)}}}]),e}(),sK=/*#__PURE__*/function(){function e(e,t){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._curFaceIndex=void 0,this._gl=e.gl,this._isWebGL2=e.isWebGL2,this._target=t;for(var n=t._colorTextures,r=t._depth,a=t.width,i=t.height,o=sN(r,ns),s=0,l=n.length;s<l;s++){var c=n[s]._format;if(!sX._supportRenderBufferColorFormat(c,e))throw Error("TextureFormat is not supported:"+t9[c]+" in RenderTarget")}if(!o&&!sX._supportRenderBufferDepthFormat(r,e))throw Error("TextureFormat is not supported:"+t9[r]+" in RenderTarget");if(n.length>1&&!e.canIUse(nJ.drawBuffers))throw Error("MRT is not supported");if(n.some(function(e){return e.width!==a||e.height!==i}))throw Error("ColorTexture's size must as same as RenderTarget");if(o&&(r.width!==a||r.height!==i))throw Error("DepthTexture's size must as same as RenderTarget");if(n.length>1&&n.some(function(e){return sN(e,nd)}))throw Error("MRT+Cube+[,MSAA] is not supported");var u=e.capability.maxAntiAliasing;t.antiAliasing>u&&(no.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+u),t._antiAliasing=u),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),t.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}var t=e.prototype;return t.activeRenderTarget=function(e,t){var n=this._gl,r=this._target;n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer);var a=e!==this._curMipLevel,i=t!==this._curFaceIndex,o=r.getColorTexture(0);if(o){var s=sN(o,nd);(a||s&&i)&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,s?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,o._platformTexture._glTexture,e)}var l=r.depthTexture;if(l){var c=sN(l,nd);if(a||c){var u=l._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,u._formatDetail.attachment,c?n.TEXTURE_CUBE_MAP_POSITIVE_X+t:n.TEXTURE_2D,u._glTexture,e)}}else if(a){var d=sX._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,d,r.width>>e,r.height>>e)}this._curMipLevel=e,this._curFaceIndex=t,this._MSAAFrameBuffer&&n.bindFramebuffer(n.FRAMEBUFFER,this._MSAAFrameBuffer)},t.blitRenderTarget=function(){if(this._MSAAFrameBuffer){var e=this._gl,t=e.COLOR_BUFFER_BIT|(this._target.depthTexture?e.DEPTH_BUFFER_BIT:0),n=this._target,r=n.colorTextureCount,a=n.width,i=n.height;e.bindFramebuffer(e.READ_FRAMEBUFFER,this._MSAAFrameBuffer),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,this._frameBuffer);for(var o=0;o<r;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)}},t.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},t._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,a=n.colorTextureCount,i=n.width,o=n.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,sN(c,nd)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(sN(r,ns)&&!sN(r,nd)){var d=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,d._formatDetail.attachment,e.TEXTURE_2D,d._glTexture,0)}else if(this._target.antiAliasing<=1){var h=sX._getRenderBufferDepthFormatDetail(r,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)},t._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,a=r._depth,i=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(i),this._MSAADepthRenderBuffer=n,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=sN(a,ns)?a._platformTexture._formatDetail:sX._getRenderBufferDepthFormatDetail(a,e,t),h=d.internalFormat,_=d.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,h,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},t._checkFrameBuffer=function(){var e=this._gl,t=this._isWebGL2,n=e.checkFramebufferStatus(e.FRAMEBUFFER);switch(n){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&&n===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.")},e}(),sY=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var r,a=n.format,i=n._mipmap,o=n.width,s=n.height,l=r._isWebGL2;if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||l||sX._isPowerOf2(o)&&sX._isPowerOf2(s)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sX._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,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||_-n,i=i||f-r,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,n,r,a,i,c,e):(o.compressedTexImage2D(this._target,t,c,a,i,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,a,i,u,d,e)},n.setImageSource=function(e,t,n,r,a,i){var o=this._gl,s=this._formatDetail,l=s.internalFormat,c=s.baseFormat,u=s.dataType;this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,+n),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+r),this._texture.usage===t6.Dynamic?o.texImage2D(this._target,t,l,c,u,e):o.texSubImage2D(this._target,t,a||0,i||0,c,u,e)},n.getPixelBuffer=function(t,n,r,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,null,t,n,r,a,i,o)},t}(sX),sq=/*#__PURE__*/function(e){function t(t,n){r=e.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this;var r,a=n.format,i=n.width,o=n.height,s=n.length,l=n.mipmapCount;if(!r._isWebGL2)throw Error("Texture2D Array is not supported in WebGL1.0");if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return r._bind(),r._formatDetail=sX._getFormatDetail(a,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,i,o,s),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,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>>n)-r,o=o||Math.max(1,this._texture.height>>n)-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,n,r,a,e,i,o,s,d,t):c.texSubImage3D(l,n,r,a,e,i,o,s,h,_,t)},n.setImageSource=function(e,t,n,r,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,+r),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),c.texSubImage3D(this._target,n,i,o,e,null!=(s=t.width)?s:t.codedWidth,null!=(l=t.height)?l:t.codedHeight,1,d,h,t)},n.getPixelBuffer=function(e,t,n,r,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,n,r,a,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},t}(sX),sQ=/*#__PURE__*/function(e){function t(t,n){(r=e.call(this,t,n,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var r,a=n.format,i=n._mipmap,o=n.width,s=r._isWebGL2;if(!sX._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+t9[a]);return!i||s||sX._isPowerOf2(o)||(no.warn("non-power-2 texture is not supported for mipmap in WebGL1,and has automatically downgraded to non-mipmap"),n._mipmap=!1,n._mipmapCount=n._getMipmapCount()),r._formatDetail=sX._getFormatDetail(a,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r}sO(t,e);var n=t.prototype;return n.setPixelBuffer=function(e,t,n,r,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>>n);if(i=i||f-r,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<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,i,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,a,i,o,d,h,t)},n.setImageSource=function(e,t,n,r,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,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,i||0,o||0,c,u,t)},n.getPixelBuffer=function(t,n,r,a,i,o,s){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");e.prototype._getPixelBuffer.call(this,t,n,r,a,i,o,s)},t}(sX),sJ=((e1={})[e1.Auto=0]="Auto",e1[e1.WebGL2=1]="WebGL2",e1[e1.WebGL1=2]="WebGL1",e1),sZ=/*#__PURE__*/function(){function e(e){void 0===e&&(e={}),this._readFrameBuffer=null,this._mainFrameBuffer=null,this._mainFrameWidth=0,this._mainFrameHeight=0,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new tI(null,null,null,null),this._lastScissor=new tI(null,null,null,null),this._lastClearColor=new tO(null,null,null,null),this._scissorEnable=!1;var t=sz({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},e);if(id.platform===tz.IPhone||id.platform===tz.IPad){var n=id.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(n){var r=parseInt(n[1]),a=parseInt(n[2]);15===r&&a>=0&&a<=4&&(t._forceFlush=!0)}}this._options=t,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}var t=e.prototype;return t.init=function(e,t,n){var r,a=this._options,i=e._webCanvas,o=a.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=n,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)&&((r=i.getContext("webgl2",a))||"undefined"!=typeof OffscreenCanvas&&sN(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl2",a)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=o&&2!=o||((r=i.getContext("webgl",a))||"undefined"!=typeof OffscreenCanvas&&sN(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},t.createPlatformPrimitive=function(e){return new sW(this,e)},t.createPlatformTexture2D=function(e){return new sY(this,e)},t.createPlatformTexture2DArray=function(e){return new sq(this,e)},t.createPlatformTextureCube=function(e){return new sQ(this,e)},t.createPlatformRenderTarget=function(e){return new sK(this,e)},t.createPlatformBuffer=function(e,t,n,r){return void 0===n&&(n=r8.Static),new sU(this,e,t,n,r)},t.requireExtension=function(e){return this._extensions.requireExtension(e)},t.canIUse=function(e){return this.capability.canIUse(e)},t.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},t.viewport=function(e,t,n,r){var a=this._gl,i=this._lastViewport;(e!==i.x||t!==i.y||n!==i.z||r!==i.w)&&(a.viewport(e,t,n,r),i.set(e,t,n,r))},t.scissor=function(e,t,n,r){var a=this._gl,i=this._lastScissor;if(e!==i.x||t!==i.y||n!==i.z||r!==i.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===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,n,r)),i.set(e,t,n,r)}},t.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},t.clearRenderTarget=function(e,t,n){var r=this._gl,a=e._lastRenderState,i=a.blendState.targetBlendState,o=a.depthState,s=a.stencilState,l=0;if(t&rw.Color&&n){l|=r.COLOR_BUFFER_BIT;var c=this._lastClearColor,u=n.r,d=n.g,h=n.b,_=n.a;n&&(u!==c.r||d!==c.g||h!==c.b||_!==c.a)&&(r.clearColor(u,d,h,_),c.set(u,d,h,_)),i.colorWriteMask!==nD.All&&(r.colorMask(!0,!0,!0,!0),i.colorWriteMask=nD.All)}t&rw.Depth&&(l|=r.DEPTH_BUFFER_BIT,!0!==o.writeEnabled&&(r.depthMask(!0),o.writeEnabled=!0)),t&rw.Stencil&&(l|=r.STENCIL_BUFFER_BIT,255!==s.writeMask&&(r.stencilMask(255),s.writeMask=255)),r.clear(l)},t.drawPrimitive=function(e,t,n){e?e.draw(n,t):no.error("draw primitive failed.")},t.getMainFrameBufferWidth=function(){return this._mainFrameWidth||this._gl.drawingBufferWidth},t.getMainFrameBufferHeight=function(){return this._mainFrameHeight||this._gl.drawingBufferHeight},t.activeRenderTarget=function(e,t,n,r,a){if(e){var i,o;e._isContentLost=!1,e._platformRenderTarget.activeRenderTarget(r,a),i=e.width>>r,o=e.height>>r}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=n?t.y*o:o-t.y*o-c;this.viewport(u,d,l,c),this.scissor(u,d,l,c)},t.blitInternalRTByBlitFrameBuffer=function(e,t,n,r){if(!this._isWebGL2){no.warn("WebGL1.0 not support blit frame buffer.");return}var a=this._gl,i=e?e._platformRenderTarget._frameBuffer:null,o=t?t._platformRenderTarget._frameBuffer:null,s=this.getMainFrameBufferWidth(),l=this.getMainFrameBufferHeight(),c=e?e.width:s,u=e?e.height:l,d=t.width,h=t.height,_=!e,f=(n&rw.Color)==0,p=(n&rw.Depth)==0,m=(n&rw.Stencil)==0;a.bindFramebuffer(a.READ_FRAMEBUFFER,i),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,o);var g=f?a.COLOR_BUFFER_BIT:0;if(p||m){var v=t._depthFormat;p&&(v===t9.Depth||v>=t9.DepthStencil&&v<=t9.Depth32Stencil8?g|=a.DEPTH_BUFFER_BIT:no.warn("Do not clear depth, or set depth format of target which is "+t9[v]+" now.")),m&&(v===t9.Stencil||v===t9.DepthStencil||v>=t9.Depth24Stencil8||v>=t9.Depth32Stencil8?g|=a.STENCIL_BUFFER_BIT:no.warn("Do not clear stencil, or set stencil format of target which is "+t9[v]+" now."))}var y=r.x*c,x=_?u-r.y*u:u-r.y*u-h;a.blitFramebuffer(y,x,y+d,_?x-h:x+h,0,0,d,h,g,a.NEAREST)},t.copyRenderTargetToSubTexture=function(e,t,n){var r,a=this._gl,i=this.getMainFrameBufferWidth(),o=this.getMainFrameBufferHeight(),s=e?e.width:i,l=e?e.height:o,c=t.width,u=t.height,d=!e,h=n.x*s,_=d?l-n.y*l-u:n.y*l,f=null!=(r=null==e?void 0:e._platformRenderTarget._frameBuffer)?r:null;a.bindFramebuffer(a.FRAMEBUFFER,f);var p=t._platformTexture;p._bind(),a.copyTexSubImage2D(p._target,0,0,0,h,_,c,u)},t.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},t.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)},t.setGlobalDepthBias=function(e,t){var n=this._gl,r=0!==e||0!==t;r?(n.enable(n.POLYGON_OFFSET_FILL),n.polygonOffset(t,e)):n.disable(n.POLYGON_OFFSET_FILL),this._enableGlobalDepthBias=r},t.flush=function(){this._gl.flush()},t.forceLoseDevice=function(){this.requireExtension(nJ.WEBGL_lose_context).loseContext()},t.forceRestoreDevice=function(){this.requireExtension(nJ.WEBGL_lose_context).restoreContext()},t.resetState=function(){this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._currentBindShaderProgram=null;for(var e=this._activeTextures,t=0,n=e.length;t<n;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)},t._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new sj(e),this._extensions=new sH(this),this._capability=new sG(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL)),this._contextAttributes=e.getContextAttributes()},t.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},t._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},t._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},t._onWebGLContextRestored=function(e){this._onDeviceRestored()},sB(e,[{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}},{key:"context",get:function(){return this._contextAttributes}}]),e}();function s$(){return(s$=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s0(e,t){return(s0=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s1(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&&s0(e,t)}function s2(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function s3(e,t,r,a){var i,o=arguments.length,s=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if(("undefined"==typeof Reflect?"undefined":n(Reflect))==="object"&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,a);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s}function s4(e,t){var n,r,a,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(n)throw TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(a=2&s[0]?r.return:s[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,s[1])).done)return a;switch(r=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(a=(a=i.trys).length>0&&a[a.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]<a[3])){i.label=s[1];break}if(6===s[0]&&i.label<a[1]){i.label=a[1],a=s;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(s);break}a[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=a=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s5(e,t,n){return t&&s8(e.prototype,t),n&&s8(e,n),e}"function"==typeof SuppressedError&&SuppressedError;var s9=/*#__PURE__*/function(){function e(e,t,n,r){void 0===t&&(t=0),void 0===r&&(r=!0),this.data=e,this._dataView=new DataView(e.buffer,e.byteOffset+t,null!=n?n:e.byteLength-t),this._littleEndian=r,this._position=0,this._baseOffset=t}var t=e.prototype;return t.nextUint8=function(){var e=this._dataView.getUint8(this._position);return this._position+=1,e},t.nextUint16=function(){var e=this._dataView.getUint16(this._position,this._littleEndian);return this._position+=2,e},t.nextUint32=function(){var e=this._dataView.getUint32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32=function(){var e=this._dataView.getInt32(this._position,this._littleEndian);return this._position+=4,e},t.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextFloat32=function(){var e=this._dataView.getFloat32(this._position,this._littleEndian);return this._position+=4,e},t.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=4*e,t},t.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,t},t.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+0x100000000*t},t.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._position+this._dataView.byteOffset,e);return this._position+=e,nT.decodeText(t)},t.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._position)},t.nextImagesData=function(e){for(var t=Array(e),n=0;n<e;n++){var r=this._dataView.getUint32(this._position,this._littleEndian);t[n]=r,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},t.skip=function(e){return this._position+=e,this},t.scan=function(e,t){void 0===t&&(t=0);for(var n=this._position,r=0;this._dataView.getUint8(this._position)!==t&&r<e;)r++,this._position++;return r<e&&this._position++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)},s5(e,[{key:"position",get:function(){return this._position}},{key:"offset",get:function(){return this._position+this._baseOffset}}]),e}(),s6={};function s7(e){return function(t){s6[e]=t}}var le=/*#__PURE__*/function(){function e(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}return e.decode=function(t){var n=new DataView(t),r=n.getUint32(0,!0),a=n.getUint8(4),i=n.getUint16(5,!0),o=new Uint8Array(t,7,i),s=n.getUint16(7+i,!0),l=new Uint8Array(t,9+i,s),c=nT.decodeText(l),u=nT.decodeText(o),d=new e;return d.totalLength=r,d.name=c,d.type=u,d.version=a,d.headerLength=l.byteLength+o.byteLength+9,d},s5(e,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),e}();function lt(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tI(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function ln(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tT(e[3*r],e[3*r+1],e[3*r+2]);return n}function lr(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tB(e[2*r],e[2*r+1]);return n}function la(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(la=function(){return!!e})()}function li(e,t,n){return(li=la()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&s0(a,n.prototype),a}).apply(null,arguments)}e.MeshDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n){var r=new aM(e),a=JSON.parse(t.nextStr());a.bounds&&r.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=ln(s,l);if(r.setPositions(c),a.normals){var u=ln(new Float32Array(o,a.normals.start+i,(a.normals.end-a.normals.start)/4),l);r.setNormals(u)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i,(a.uvs.end-a.uvs.start)/4);r.setUVs(lr(d,l))}if(a.uv1){var h=new Float32Array(o,a.uv1.start+i,(a.uv1.end-a.uv1.start)/4);r.setUVs(lr(h,l),1)}if(a.uv2){var _=new Float32Array(o,a.uv2.start+i,(a.uv2.end-a.uv2.start)/4);r.setUVs(lr(_,l),2)}if(a.uv3){var f=new Float32Array(o,a.uv3.start+i,(a.uv3.end-a.uv3.start)/4);r.setUVs(lr(f,l),3)}if(a.uv4){var p=new Float32Array(o,a.uv4.start+i,(a.uv4.end-a.uv4.start)/4);r.setUVs(lr(p,l),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i,(a.uv5.end-a.uv5.start)/4);r.setUVs(lr(m,l),5)}if(a.uv6){var g=new Float32Array(o,a.uv6.start+i,(a.uv6.end-a.uv6.start)/4);r.setUVs(lr(g,l),6)}if(a.uv7){var v=new Float32Array(o,a.uv7.start+i,(a.uv7.end-a.uv7.start)/4);r.setUVs(lr(v,l),7)}if(a.colors){var y=new Float32Array(o,a.colors.start+i,(a.colors.end-a.colors.start)/4);r.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new tO(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(y,l))}if(a.boneWeights){var x=new Float32Array(o,a.boneWeights.start+i,(a.boneWeights.end-a.boneWeights.start)/4);r.setBoneWeights(lt(x,l))}if(a.boneIndices){var b=new Float32Array(o,a.boneIndices.start+i,(a.boneIndices.end-a.boneIndices.start)/4);r.setBoneIndices(lt(b,l))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new am(e.name);e.frames.forEach(function(e){var n=new Float32Array(o,e.deltaPosition.start+i,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,a=ln(n,r);e.deltaNormals&&ln(new Float32Array(o,e.deltaNormals.start+i,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&<(new Float32Array(o,e.deltaTangents.start+i,(e.deltaTangents.end-e.deltaTangents.start)/4),r),t.addFrame(e.weight,a)}),r.addBlendShape(t)}),a.indices){var C=null;C=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),r.setIndices(C)}a.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},e}(),e.MeshDecoder=s3([s7("Mesh")],e.MeshDecoder),e.Texture2DDecoder=/*#__PURE__*/function(){function e(){}return e.decode=function(e,t){return new Promise(function(n,r){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 nc(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,n(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&&n(m)};if(t(),i){var r=function(e){var n=new window.Blob([p[e]]),r=new Image;r.onload=function(){m.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};m.generateMipmaps();for(var a=1;a<f;a++)r(a)}},b.src=URL.createObjectURL(x)}})},e}(),e.Texture2DDecoder=s3([s7("Texture2D")],e.Texture2DDecoder);var lo=((e2={})[e2.Prefab=0]="Prefab",e2[e2.Scene=1]="Scene",e2),ls=/*#__PURE__*/function(){function e(e,t,n){void 0===t&&(t=1),this.engine=e,this.type=t,this.resource=n,this.entityMap=new Map,this.entityConfigMap=new Map,this.components=new Map,this.rootIds=[],this.strippedIds=[],this.resourceManager=e.resourceManager}return e.prototype.clear=function(){this.entityMap.clear(),this.components.clear(),this.entityConfigMap.clear(),this.rootIds.length=0,this.strippedIds.length=0},e}(),ll=/*#__PURE__*/function(){function e(e){this._context=e}var t=e.prototype;return t.parseEntity=function(e){var t=this;return this._getEntityByConfig(e).then(function(n){n.isActive=null==(r=e.isActive)||r;var r,a,i=e.position,o=e.rotation,s=e.scale;return i&&n.transform.position.copyFrom(i),o&&n.transform.rotation.copyFrom(o),s&&n.transform.scale.copyFrom(s),n.layer=null!=(a=e.layer)?a:n.layer,t._context.type===lo.Prefab&&n._markAsTemplate(t._context.resource),n})},t.parseClassObject=function(e){var t,n=this,r=ol.getClass(e.class);return Promise.all((null!=(t=e.constructParams)?t:[]).map(function(e){return n.parseBasicType(e)})).then(function(e){return li(r,[].concat(e))}).then(function(t){return n.parsePropsAndMethods(t,e)})},t.parsePropsAndMethods=function(t,n){var r=[];if(n.methods)for(var a in n.methods)for(var i=n.methods[a],o=0,s=i.length;o<s;o++)r.push(this.parseMethod(t,a,i[o]));if(n.props){var l,c=function(e){var a=n.props[e],i=l.parseBasicType(a,t[e]).then(function(n){return t[e]=n});r.push(i)};for(var u in n.props)l=this,c(u)}return Promise.all(r).then(function(){var r=e.customParseComponentHandles[t.constructor.name];return r?r(t,n):t})},t.parseMethod=function(e,t,n){var r=this;return Promise.all(n.map(function(e){return r.parseBasicType(e)})).then(function(n){return e[t].apply(e,[].concat(n))})},t.parseBasicType=function(t,n){var r=this;if(Array.isArray(t))return Promise.all(t.map(function(e){return r.parseBasicType(e)}));if((void 0===t?"undefined":s2(t))==="object"&&null!=t){if(e._isClass(t))return this.parseClassObject(t);if(e._isAssetRef(t)){var a=this._context;return a.resourceManager.getResourceByRef(t).then(function(e){return a.type===lo.Prefab&&a.resource._addDependenceAsset(e),e})}if(e._isEntityRef(t))return Promise.resolve(this._context.entityMap.get(t.entityId));if(n){var i,o=function(e){if("methods"===e){var r=t[e];for(var a in r)for(var o=r[a],l=0,c=o.length;l<c;l++){var u=o[l];s.push(i.parseMethod(n,a,u))}}else s.push(i.parseBasicType(t[e],n[e]).then(function(t){return n[e]=t}))},s=[];for(var l in t)i=this,o(l);return Promise.all(s).then(function(){return n})}}return Promise.resolve(t)},t._getEntityByConfig=function(e){var t=this,n=e.assetRefId,r=this._context.engine;return n?r.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(a){var i=r.resourceManager._objectPool[n];return t._context.type===lo.Prefab&&t._context.resource._addDependenceAsset(i),a.name=e.name,a}):Promise.resolve(new aW(r,e.name))},e.registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},e._isClass=function(e){return void 0!=e.class},e._isAssetRef=function(e){return void 0!=e.refId},e._isEntityRef=function(e){return void 0!=e.entityId},e}();ll.customParseComponentHandles=new Map;var lc=((e3={})[e3.Float=0]="Float",e3[e3.FloatArray=1]="FloatArray",e3[e3.Vector2=2]="Vector2",e3[e3.Vector3=3]="Vector3",e3[e3.Vector4=4]="Vector4",e3[e3.Quaternion=5]="Quaternion",e3[e3.Color=6]="Color",e3[e3.Array=7]="Array",e3[e3.Boolean=8]="Boolean",e3[e3.Rect=9]="Rect",e3[e3.ReferResource=10]="ReferResource",e3);e.AnimationClipDecoder=/*#__PURE__*/function(){function t(){}return t.decode=function(t,n){return new Promise(function(t){for(var r=new ov(n.nextStr()),a=n.nextUint16(),i=0;i<a;++i){var o=new og;o.time=n.nextFloat32(),o.functionName=n.nextStr(),o.parameter=JSON.parse(n.nextStr()).val,r.addEvent(o)}for(var s=n.nextUint16(),l=0;l<s;++l){var c=n.nextStr(),u=n.nextStr(),d=ol.getClass(u),h=n.nextStr(),_=n.nextStr(),f=void 0,p=n.nextUint8(),m=n.nextUint16();switch(n.nextStr()){case"AnimationFloatCurve":(f=new e.AnimationFloatCurve).interpolation=p;for(var g=0;g<m;++g){var v=new oU;v.time=n.nextFloat32(),v.value=n.nextFloat32(),v.inTangent=n.nextFloat32(),v.outTangent=n.nextFloat32(),f.addKey(v)}break;case"AnimationArrayCurve":(f=new e.AnimationArrayCurve).interpolation=p;for(var y=0;y<m;++y){var x=new oU;x.time=n.nextFloat32();var b=n.nextUint16();x.value=Array.from(n.nextFloat32Array(b)),x.inTangent=Array.from(n.nextFloat32Array(b)),x.outTangent=Array.from(n.nextFloat32Array(b)),f.addKey(x)}break;case"AnimationFloatArrayCurve":(f=new e.AnimationFloatArrayCurve).interpolation=p;for(var C=0;C<m;++C){var S=new oU;S.time=n.nextFloat32();var T=n.nextUint16();S.value=n.nextFloat32Array(T),S.inTangent=Array.from(n.nextFloat32Array(T)),S.outTangent=Array.from(n.nextFloat32Array(T)),f.addKey(S)}break;case"AnimationVector2Curve":(f=new e.AnimationVector2Curve).interpolation=p;for(var A=0;A<m;++A){var E=new oU;E.time=n.nextFloat32(),E.value=new tB(n.nextFloat32(),n.nextFloat32()),E.inTangent=new tB(n.nextFloat32(),n.nextFloat32()),E.outTangent=new tB(n.nextFloat32(),n.nextFloat32()),f.addKey(E)}break;case"AnimationVector3Curve":(f=new e.AnimationVector3Curve).interpolation=p;for(var R=0;R<m;++R){var M=new oU;M.time=n.nextFloat32(),M.value=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new tT(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(M)}break;case"AnimationVector4Curve":(f=new e.AnimationVector4Curve).interpolation=p;var w=new oU;w.time=n.nextFloat32(),w.value=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),w.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(w);break;case"AnimationColorCurve":(f=new e.AnimationColorCurve).interpolation=p;for(var P=0;P<m;++P){var F=new oU;F.time=n.nextFloat32(),F.value=new tO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(F)}break;case"AnimationQuaternionCurve":(f=new e.AnimationQuaternionCurve).interpolation=p;for(var L=0;L<m;++L){var D=new oU;D.time=n.nextFloat32(),D.value=new tF(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.inTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),D.outTangent=new tI(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),f.addKey(D)}break;case"AnimationRefCurve":(f=new e.AnimationRefCurve).interpolation=p;for(var B=0;B<m;++B){var I=new oU;I.time=n.nextFloat32();var O=n.nextStr();O?I.value=JSON.parse(O):I.value=null,f.addKey(I)}break;case"AnimationBoolCurve":(f=new e.AnimationBoolCurve).interpolation=p;for(var N=0;N<m;++N){var V=new oU;V.time=n.nextFloat32(),V.value=1===n.nextUint8(),f.addKey(V)}break;case"AnimationStringCurve":(f=new e.AnimationStringCurve).interpolation=p;for(var k=0;k<m;++k){var z=new oU;z.time=n.nextFloat32(),z.value=n.nextStr(),f.addKey(z)}}r.addCurveBinding(c,d,h,_,f)}t(r)})},t}(),e.AnimationClipDecoder=s3([s7("AnimationClip")],e.AnimationClipDecoder);var lu=((e4={}).Vector2="Vector2",e4.Vector3="Vector3",e4.Vector4="Vector4",e4.Color="Color",e4.Float="Float",e4.Texture="Texture",e4.Boolean="Boolean",e4.Integer="Integer",e4),ld=((e8={}).Sky="Sky",e8.Custom="Custom",e8);function lh(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function l_(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function lf(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l_(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return l_(e,void 0)}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var lp=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r._dependenceAssets=new Set,r}s1(t,e);var n=t.prototype;return n.instantiate=function(){var e;return null==(e=this._root)?void 0:e.clone()},n._addDependenceAsset=function(e){this._dependenceAssets.add(e),e._associationSuperResource(this)},n._onDestroy=function(){var t=this;e.prototype._onDestroy.call(this),this._root.destroy(),this._dependenceAssets.forEach(function(e){e._disassociationSuperResource(t)})},t}(t1),lm=/*#__PURE__*/function(){function e(e,t){var n=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){n._reject=t,n._resolve=e}),this._reflectionParser=new ll(t)}var t=e.prototype;return t.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)},t._parseEntities=function(){var e=this,t=this.data.entities,n=this.context.entityConfigMap,r=this.context.entityMap,a=this._engine;return Promise.all(t.map(function(t){var r,i=null!=(r=t.strippedId)?r:t.id;return t.id=i,n.set(i,t),e._getEntityByConfig(t,a)})).then(function(e){for(var n=0,a=e.length;n<a;n++)r.set(t[n].id,e[n]);return e})},t._parseComponents=function(){for(var e=this.data.entities,t=this.context.entityMap,n=this.context.components,r=[],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(ol.getClass(u));n.set(c.id,d);var h=this._reflectionParser.parsePropsAndMethods(d,c);r.push(h)}return Promise.all(r)},t._parsePrefabModification=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],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=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.target,r=t.props,a=t.methods,i=n.entityId,o=n.componentId,s=e._prefabContextMap.get(c),l=s.entityMap.get(i),u=s.components.get(o);return u?e._reflectionParser.parsePropsAndMethods(u,{props:r,methods:a}):l?Promise.resolve(e._applyEntityData(l,r)):void 0})))}}(a);return Promise.all(r)},t._parsePrefabRemovedEntities=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],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=n.get(s);r.push.apply(r,[].concat(l.map(function(t){var n=t.entityId,r=e._prefabContextMap.get(c).entityMap.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._parsePrefabRemovedComponents=function(){for(var e=this,t=this.data.entities,n=this.context.entityMap,r=[],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=n.get(s);r.concat.apply(r,[].concat(l.map(function(t){var n=t.componentId,r=e._prefabContextMap.get(c).components.get(n);r&&r.destroy()})))}}(a);return Promise.all(r)},t._organizeEntities=function(){for(var e,t=this.context,n=t.rootIds,r=t.strippedIds,a=n.concat(r),i=lf(a);!(e=i()).done;){var o=e.value;this._parseChildren(o)}for(var s=0;s<n.length;s++)this._handleRootEntity(n[s])},t._getEntityByConfig=function(e,t){var n=this;return(e.assetRefId?this._parsePrefab(e,t):e.strippedId?this._parseStrippedEntity(e):this._parseEntity(e,t)).then(function(t){return n._applyEntityData(t,e)})},t._parseEntity=function(e,t){var n=new aW(t,e.name);return e.parent||this.context.rootIds.push(e.id),Promise.resolve(n)},t._parsePrefab=function(e,t){var n=this,r=e.assetRefId;return t.resourceManager.getResourceByRef({refId:r}).then(function(r){var a=lh(r,lp)?r.instantiate():r.instantiateSceneRoot(),i=new ls(t,lo.Prefab,null);e.parent||n.context.rootIds.push(e.id),n._generateInstanceContext(a,i,""),n._prefabContextMap.set(a,i);var o=n._prefabPromiseMap.get(e.id);if(o)for(var s=0,l=o.length;s<l;s++)o[s].resolve(i);return a})},t._parseStrippedEntity=function(e){var t=this;return this.context.strippedIds.push(e.id),new Promise(function(n,r){var a,i=null!=(a=t._prefabPromiseMap.get(e.prefabInstanceId))?a:[];i.push({resolve:n,reject:r}),t._prefabPromiseMap.set(e.prefabInstanceId,i)}).then(function(t){var n=e.prefabSource.entityId;return t.entityMap.get(n)})},t._parseChildren=function(e){var t=this.context,n=t.entityConfigMap,r=t.entityMap,a=n.get(e).children;if(a&&a.length>0)for(var i=r.get(e),o=0;o<a.length;o++){var s=a[o],l=r.get(s);i.addChild(l),this._parseChildren(s)}},t._applyEntityData=function(e,t){void 0===t&&(t={}),e.isActive=null!=(n=t.isActive)?n:e.isActive,e.name=null!=(r=t.name)?r:e.name;var n,r,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},t._generateInstanceContext=function(e,t,n){var r=t.entityMap,a=t.components,i={},o={};r.set(n,e),e._components.forEach(function(t){var r=ol.getClassName(t.constructor);i[r]||(i[r]=e.getComponents(t.constructor,[]),o[r]=0),a.set(n+":"+r+"/"+o[r]++,t)});for(var s=0,l=e.children.length;s<l;s++){var c=e.children[s],u=n?n+"/"+s:""+s;this._generateInstanceContext(c,t,u)}},e}(),lg=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).scene=r,a}s1(t,e);var n=t.prototype;return n._handleRootEntity=function(e){var t=this.context.entityMap;this.scene.addRootEntity(t.get(e))},n._clearAndResolve=function(){return this.context.clear(),this.scene},t.parse=function(e,n){var r=new oo(e),a=new t(n,new ls(e,lo.Scene,r),r);return a.start(),a.promise.then(function(){return r})},t}(lm);function lv(e,t){var n=le.decode(e),r=new s9(new Uint8Array(e),n.headerLength,n.dataLength);return s6[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.EditorTextureLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){lv(e,t.engine).then(function(e){n(e)})}).catch(r)})},t}(ol),e.EditorTextureLoader=s3([it("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var ly=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){return lv(e,t.engine).then(function(e){return Promise.all(e.curveBindings.map(function(e){return Promise.all(e.curve.keys.map(function(e){return n._parseKeyframeValue(e,t).then(function(t){e.value=t})}))})).then(function(){r(e)})}).catch(a)}).catch(a)})},n._parseKeyframeValue=function(e,t){var n=e.value;return(void 0===n?"undefined":s2(n))==="object"&&(null==n?void 0:n.refId)?new Promise(function(r){t.getResourceByRef(n).then(function(t){e.value=t,r(e.value)})}):Promise.resolve(e.value)},t}(ol);ly=s3([it(a2.AnimationClip,["ani"])],ly);var lx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var a=new oI(t.engine),i=e.layers,o=e.parameters,s=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,l=e.weight,c=e.stateMachine,u=new oz(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,n){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(ol.getClass(e))}),m[a]=_,d&&s.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),h.forEach(function(e){var t=n._createTransition(e,m[e.destinationStateId]);g[e.id]=t}),d.forEach(function(e){var t=e.id;e.transitions.forEach(function(e){var n=g[e];n&&m[t].addTransition(n)})}),_.forEach(function(e){p.addEntryStateTransition(n._createTransition(e,m[e.destinationStateId]))}),f.forEach(function(e){p.addAnyStateTransition(n._createTransition(e,m[e.destinationStateId]))})}a.addLayer(u)}),o.forEach(function(e){e.isTrigger?a.addTriggerParameter(e.name):a.addParameter(e.name,e.defaultValue)}),Promise.all(s).then(function(e){e.forEach(function(e){var t=e.layerIndex,n=e.stateIndex,r=e.clip;a.layers[t].stateMachine.states[n].clip=r}),r(a)})}).catch(a)})},n._createTransition=function(e,t){var n=new oM;return n.hasExitTime=e.hasExitTime,n.isFixedDuration=e.isFixedDuration,n.duration=e.duration,n.offset=e.offset,n.exitTime=e.exitTime,n.solo=e.solo,n.mute=e.mute,n._isExit=e.isExit,n.destinationState=t,e.conditions.forEach(function(e){n.addCondition(e.parameterName,e.mode,e.threshold)}),n},t}(ol);lx=s3([it(a2.AnimatorController,["json"],!1)],lx);var lb=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=e.url;return/^data:(.+?);base64,/.test(n)?new a8(function(e){var t=n.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(t),function(e){return e.charCodeAt(0)}).buffer)}):t._request(n,s$({},e,{type:"arraybuffer"}))},t}(ol);lb=s3([it(a2.Buffer,["bin","r3bin"],!1)],lb);var lC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){return new a8(function(r,a){var i=s$({},e,{type:"arraybuffer"}),o=n.engine;n._request(e.url,i).then(function(n){var a=t._setTextureByBuffer(o,n);o.resourceManager.addContentRestorer(new lS(a,e.url,i));var s=new i8(o),l=new tV;s.diffuseMode=i4.SphericalHarmonics,l.copyFromArray(new Float32Array(n,0,27)),s.diffuseSphericalHarmonics=l,s.specularTexture=a,s.specularTextureDecodeRGBM=!0,r(s)}).catch(function(e){a(e)})})},t._setTextureByBuffer=function(e,t,n){var r=new Uint16Array(t,108,1)[0];n||(n=new nd(e,r)),n.filterMode=t5.Trilinear;for(var a=n.mipmapCount,i=110,o=0;o<a;o++)for(var s=r>>o,l=0;l<6;l++){var c=s*s*4,u=new Uint8Array(t,i,c);i+=c,n.setPixelBuffer(t4.PositiveX+l,u,o)}return n},t}(ol);lC=s3([it(a2.Env,["env"])],lC);var lS=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){a6(e.url,e.requestConfig).then(function(n){lC._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t2);function lT(e,t,n,r,a,i,o){try{var s=e[i](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,a)}function lA(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){lT(i,r,a,o,s,"next",e)}function s(e){lT(i,r,a,o,s,"throw",e)}o(void 0)})}}var lE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var i=e.fontName,o=e.fontUrl;o?n._registerFont(i,o).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):r(new ng(t.engine,i))}).catch(function(e){a(e)})})},n._registerFont=function(e,t){return lA(function(){var n;return s4(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);lE=s3([it(a2.Font,["font"],!1)],lE);var lR=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).url=n,r}s1(t,e);var n=t.prototype;return n.instantiateSceneRoot=function(e){return(void 0===e?this._defaultSceneRoot:this._sceneRoots[e]).clone()},n._onDestroy=function(){e.prototype._onDestroy.call(this);var t=this.textures,n=this.materials,r=this.meshes;if(t&&this._disassociationSuperResource(t),n&&this._disassociationSuperResource(n),r)for(var a=0,i=r.length;a<i;a++)this._disassociationSuperResource(r[a])},n._disassociationSuperResource=function(e){for(var t=0,n=e.length;t<n;t++)e[t]._disassociationSuperResource(this)},s5(t,[{key:"extensionsData",get:function(){return this._extensionsData}},{key:"sceneRoots",get:function(){return this._sceneRoots}},{key:"defaultSceneRoot",get:function(){return this._defaultSceneRoot}}]),t}(t1),lM=((e5={})[e5.BYTE=5120]="BYTE",e5[e5.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e5[e5.SHORT=5122]="SHORT",e5[e5.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e5[e5.UNSIGNED_INT=5125]="UNSIGNED_INT",e5[e5.FLOAT=5126]="FLOAT",e5),lw=((e9={}).SCALAR="SCALAR",e9.VEC2="VEC2",e9.VEC3="VEC3",e9.VEC4="VEC4",e9.MAT2="MAT2",e9.MAT3="MAT3",e9.MAT4="MAT4",e9),lP=((e6={}).TRANSLATION="translation",e6.ROTATION="rotation",e6.SCALE="scale",e6.WEIGHTS="weights",e6),lF=((e7={}).Linear="LINEAR",e7.Step="STEP",e7.CubicSpine="CUBICSPLINE",e7),lL=((te={}).PERSPECTIVE="perspective",te.ORTHOGRAPHIC="orthographic",te),lD=((tt={}).OPAQUE="OPAQUE",tt.MASK="MASK",tt.BLEND="BLEND",tt),lB=((tn={})[tn.NEAREST=9728]="NEAREST",tn[tn.LINEAR=9729]="LINEAR",tn),lI=((tr={})[tr.NEAREST=9728]="NEAREST",tr[tr.LINEAR=9729]="LINEAR",tr[tr.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",tr[tr.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",tr[tr.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",tr[tr.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",tr),lO=((ta={})[ta.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ta[ta.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ta[ta.REPEAT=10497]="REPEAT",ta),lN=/*#__PURE__*/function(){function e(e,t,n){var r=this;this.glTFResource=e,this.resourceManager=t,this.params=n,this.accessorBufferCache={},this.needAnimatorController=!1,this._resourceCache=new Map,this._progress={taskDetail:{},taskComplete:{loaded:0,total:0}},this._onTaskDetail=function(e,t,n){var a,i=(a=r._progress.taskDetail)[e]||(a[e]={});i.loaded=t,i.total=n,r._setTaskDetailProgress(e,t,n)},this.contentRestorer=new l2(e)}var t=e.prototype;return t.get=function(t,n){var r=this,a=e._parsers[t];if(!a)return Promise.resolve(null);var i=this._resourceCache,o=void 0===n?""+t:t+":"+n,s=i.get(o);if(s)return s;var l=lz[t],c=!!lU[t];if(l){var u=this.glTF[l];u&&(void 0===n||u[n])?void 0===n?s=8===t?u.map(function(e,n){return r.get(t,n)}):Promise.all(u.map(function(e,n){return r.get(t,n)})):(s=a.parse(this,n),c&&this._handleSubAsset(s,t,n)):s=Promise.resolve(null)}else s=a.parse(this,n),c&&this._handleSubAsset(s,t,n);return i.set(o,s),s},t.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,n=t.animatorController;return n&&(t._defaultSceneRoot.addComponent(oD).animatorController=n),e.resourceManager.addContentRestorer(e.contentRestorer),t})});return this._addTaskCompletePromise(t),t},t._addTaskCompletePromise=function(e){var t=this,n=this._progress.taskComplete;n.total+=1,e.then(function(){t._setTaskCompleteProgress(++n.loaded,n.total)},function(){})},t._handleSubAsset=function(e,t,n){var r,a=this,i=lU[t];if(8===t)((r=this.glTFResource)[i]||(r[i]=[]))[n]=e;else{var o=this.glTFResource.url;e.then(function(e){if(void 0==n?a.glTFResource[i]=e:((r=a.glTFResource)[i]||(r[i]=[]))[n]=e,7===t)for(var r,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o,i+"["+n+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o,""+i+(void 0===n?"":"["+n+"]"),e),2===t&&(null!=(s=a.glTF.scene)?s:0)===n&&a.resourceManager._onSubAssetSuccess(o,"defaultSceneRoot",e)})}},e.addParser=function(e,t){this._parsers[e]=t},e}();lN._parsers={};var lV=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},lk=((ti={})[ti.Schema=0]="Schema",ti[ti.Validator=1]="Validator",ti[ti.Scene=2]="Scene",ti[ti.Buffer=3]="Buffer",ti[ti.BufferView=4]="BufferView",ti[ti.Texture=5]="Texture",ti[ti.Material=6]="Material",ti[ti.Mesh=7]="Mesh",ti[ti.Entity=8]="Entity",ti[ti.Skin=9]="Skin",ti[ti.Animation=10]="Animation",ti[ti.AnimatorController=11]="AnimatorController",ti),lz=((th={})[2]="scenes",th[3]="buffers",th[5]="textures",th[6]="materials",th[7]="meshes",th[8]="nodes",th[9]="skins",th[10]="animations",th[4]="bufferViews",th),lU=((t_={})[2]="_sceneRoots",t_[5]="textures",t_[6]="materials",t_[7]="meshes",t_[8]="entities",t_[9]="skins",t_[10]="animations",t_[11]="animatorController",t_);function lG(e){return function(t){var n=new t;lN.addParser(e,n)}}var lH=/*#__PURE__*/function(){function t(){}return t.floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new tB(e[r],e[r+1]);return n},t.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new tT(e[r],e[r+1],e[r+2]);return n},t.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new tI(e[r],e[r+1],e[r+2],e[r+3]);return n},t.floatBufferToColorArray=function(e,t){var n=e.length,r=Array(n/(t?3:4));if(t)for(var a=0;a<n;a+=3)r[a/3]=new tO(e[a],e[a+1],e[a+2],1);else for(var i=0;i<n;i+=4)r[i/4]=new tO(e[i],e[i+1],e[i+2],e[i+3]);return r},t.getAccessorTypeSize=function(e){switch(e){case lw.SCALAR:return 1;case lw.VEC2:return 2;case lw.VEC3:return 3;case lw.VEC4:case lw.MAT2:return 4;case lw.MAT3:return 9;case lw.MAT4:return 16}},t.getComponentType=function(e){switch(e){case lM.BYTE:return Int8Array;case lM.UNSIGNED_BYTE:return Uint8Array;case lM.SHORT:return Int16Array;case lM.UNSIGNED_SHORT:return Uint16Array;case lM.UNSIGNED_INT:return Uint32Array;case lM.FLOAT:return Float32Array}},t.getNormalizedComponentScale=function(e){switch(e){case lM.BYTE:return 1/127;case lM.UNSIGNED_BYTE:return 1/255;case lM.SHORT:return 1/32767;case lM.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},t.getAccessorBuffer=function(e,n,r){var a,i=r.componentType,o=t.getComponentType(i),s=t.getAccessorTypeSize(r.type),l=o.BYTES_PER_ELEMENT,c=s*l,u=r.count;if(void 0!==r.bufferView){var d=r.bufferView,h=n[d];a=e.get(lk.BufferView,r.bufferView).then(function(t){var n,a,_,f=h.buffer,p=null!=(n=t.byteOffset)?n:0,m=null!=(a=r.byteOffset)?a:0,g=h.byteStride;if(void 0!==g&&g!==c){var v=Math.floor(m/g),y=d+":"+i+":"+v+":"+u,x=e.accessorBufferCache;if(!(_=x[y])){var b=p+v*g,C=g/l*u,S=new o(t.buffer,b,C);x[y]=_=new lV(S,!0,g),_.restoreInfo=new l9(new l6(f,o,b,C))}}else{var T=p+m,A=u*s;(_=new lV(new o(t.buffer,T,A),!1,c)).restoreInfo=new l9(new l6(f,o,T,A))}return _})}else{var _=u*s,f=new lV(new o(_),!1,c);f.restoreInfo=new l9(new l6(void 0,o,void 0,_)),a=Promise.resolve(f)}return r.sparse?a.then(function(n){return t.processingSparseData(e,r,n).then(function(){return n})}):a},t.bufferToVector3Array=function(e,n,r,a,i){for(var o=n/e.BYTES_PER_ELEMENT,s=e.length/r,l=Array(r),c=a?t.getNormalizedComponentScale(i):1,u=0;u<r;u++){var d=o+u*s;l[u]=new tT(e[d]*c,e[d+1]*c,e[d+2]*c)}return l},t.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},t.processingSparseData=function(e,n,r){var a=r.restoreInfo,i=e.glTF.bufferViews,o=t.getAccessorTypeSize(n.type),s=t.getComponentType(n.componentType),l=r.data.slice(),c=n.sparse,u=c.count,d=c.indices,h=c.values,_=i[d.bufferView],f=i[h.bufferView];return Promise.all([e.get(lk.BufferView,d.bufferView),e.get(lk.BufferView,h.bufferView)]).then(function(e){var n,i,c,p,m=e[0],g=e[1],v=(null!=(n=d.byteOffset)?n:0)+(null!=(i=m.byteOffset)?i:0),y=m.byteLength,x=(null!=(c=h.byteOffset)?c:0)+(null!=(p=g.byteOffset)?p:0),b=g.byteLength;a.typeSize=o,a.sparseCount=u;var C=t.getComponentType(d.componentType),S=y/C.BYTES_PER_ELEMENT,T=new C(m.buffer,v,S);a.sparseIndices=new l6(_.buffer,C,v,S);var A=b/s.BYTES_PER_ELEMENT,E=new s(g.buffer,x,A);a.sparseValues=new l6(f.buffer,s,x,A);for(var R=0;R<u;R++)for(var M=T[R],w=0;w<o;w++)l[M*o+w]=E[R*o+w];r.data=l})},t.getIndexFormat=function(e){switch(e){case lM.UNSIGNED_BYTE:return r6.UInt8;case lM.UNSIGNED_SHORT:return r6.UInt16;case lM.UNSIGNED_INT:return r6.UInt32}},t.getElementFormat=function(e,t,n){if(void 0===n&&(n=!1),e==lM.FLOAT)switch(t){case 1:return r7.Float;case 2:return r7.Vector2;case 3:return r7.Vector3;case 4:return r7.Vector4}if(e==lM.SHORT)switch(t){case 2:return n?r7.NormalizedShort2:r7.Short2;case 3:case 4:return n?r7.NormalizedShort4:r7.Short4}if(e==lM.UNSIGNED_SHORT)switch(t){case 2:return n?r7.NormalizedUShort2:r7.UShort2;case 3:case 4:return n?r7.NormalizedUShort4:r7.UShort4}if(e==lM.BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedByte4:r7.Byte4}if(e==lM.UNSIGNED_BYTE)switch(t){case 2:case 3:case 4:return n?r7.NormalizedUByte4:r7.UByte4}},t.loadImageBuffer=function(e,t){return new Promise(function(n,r){var a=new window.Blob([e],{type:t}),i=new Image;i.onerror=function(){r(Error("Failed to load image buffer"))},i.onload=function(){requestAnimationFrame(function(){n(i),i.onload=null,i.onerror=null,i.onabort=null})},i.crossOrigin="anonymous",i.src=URL.createObjectURL(a)})},t.parseGLB=function(e,t){var n={JSON:0x4e4f534a,BIN:5130562},r=new DataView(t),a={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(0x46546c67!==a.magic)return{originBuffer:t};var i=r.getUint32(12,!0),o=r.getUint32(16,!0);if(o!==n.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(nT.decodeText(s)),c=[],u=20+i,d=e.contentRestorer.glbBufferSlices;u<a.length;){if(i=r.getUint32(u,!0),(o=r.getUint32(u+4,!0))!==n.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 tB(h,i)),u+=i+8}return{glTF:l,buffers:c}},t.parseSampler=function(e,t){var n=t.filterMode,r=t.wrapModeU,a=t.wrapModeV;void 0!==n&&(e.filterMode=n),void 0!==r&&(e.wrapModeU=r),void 0!==a&&(e.wrapModeV=a)},t.getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=lI.NEAREST_MIPMAP_NEAREST,r===lB.NEAREST?o.filterMode=t5.Point:n<=lI.LINEAR_MIPMAP_NEAREST?o.filterMode=t5.Bilinear:o.filterMode=t5.Trilinear),a&&(o.wrapModeU=e.GLTFTextureParser._wrapMap[a]),i&&(o.wrapModeV=e.GLTFTextureParser._wrapMap[i]),o},t}(),lW=((to={})[to.None=0]="None",to[to.BasisLZ=1]="BasisLZ",to[to.Zstd=2]="Zstd",to[to.ZLib=3]="ZLib",to),lj=/*#__PURE__*/function(){function e(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)}return e.prototype.parse=function(e){var t=e.buffer,n=e.byteOffset,r=new s9(e,12);this.vkFormat=r.nextUint32(),this.typeSize=r.nextUint32(),this.pixelWidth=r.nextUint32(),this.pixelHeight=r.nextUint32(),this.pixelDepth=r.nextUint32(),this.layerCount=r.nextUint32(),this.faceCount=r.nextUint32();var a=Math.max(1,r.nextUint32());this.supercompressionScheme=r.nextUint32();var i=r.nextUint32(),o=r.nextUint32(),s=r.nextUint32(),l=r.nextUint32(),c=r.nextUint64(),u=r.nextUint64(),d=Array(a),h=24*a,_=new s9(e,r.offset,h);this.levels=d;for(var f=0;f<a;f++)d[f]={levelData:new Uint8Array(t,n+_.nextUint64(),_.nextUint64()),uncompressedByteLength:_.nextUint64()};var p=new s9(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 s9(e,s,l,!0);x.position<l;){var b=x.nextUint32(),C=x.scan(b),S=nT.decodeText(C),T=x.nextUint8Array(b-C.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?nT.decodeText(T).replace(/^(.*)\x00$/,"$1"):T;var A=b%4?4-b%4:0;x.skip(A)}if(u<=0)return this;for(var E=new s9(e,c,u,!0),R=E.nextUint16(),M=E.nextUint16(),w=E.nextUint32(),P=E.nextUint32(),F=E.nextUint32(),L=E.nextUint32(),D=Array(a),B=0;B<a;B++)D[B]={imageFlags:E.nextUint32(),rgbSliceByteOffset:E.nextUint32(),rgbSliceByteLength:E.nextUint32(),alphaSliceByteOffset:E.nextUint32(),alphaSliceByteLength:E.nextUint32()};var I=c+E.position,O=I+w,N=O+P,V=N+F,k=new Uint8Array(t,n+I,w),z=new Uint8Array(t,n+O,P),U=new Uint8Array(t,n+N,F),G=new Uint8Array(t,n+V,L);this.globalData={endpointCount:R,selectorCount:M,imageDescs:D,endpointsData:k,selectorsData:z,tablesData:U,extendedData:G}},s5(e,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),e}(),lX=((ts={})[ts.ASTC=0]="ASTC",ts[ts.BC7=1]="BC7",ts[ts.BC1_BC3=2]="BC1_BC3",ts[ts.PVRTC=3]="PVRTC",ts[ts.ETC=4]="ETC",ts[ts.R8=5]="R8",ts[ts.R8G8=6]="R8G8",ts[ts.R8G8B8A8=7]="R8G8B8A8",ts),lK=/*#__PURE__*/function(){function e(e,t){void 0===e&&(e=4),this.limitedCount=e,this._workerCreator=t,this._taskQueue=[],this._workerStatus=0,this._workerItems=Array(e)}var t=e.prototype;return t.prepareWorker=function(){for(var e=this.limitedCount,t=Array(e),n=0;n<e;n++)t.push(this._initWorker(n));return Promise.all(t)},t.postMessage=function(e){var t=this;return new Promise(function(n,r){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=n,t.reject=r,t.worker.postMessage(e)}).catch(r)}else t._taskQueue.push({resolve:n,reject:r,message:e})})},t.destroy=function(){for(var e=this._workerItems,t=0,n=e.length;t<n;t++){var r=e[t];r.worker.terminate(),r.reject=null,r.resolve=null}e.length=0,this._taskQueue.length=0,this._workerStatus=0},t._initWorker=function(e){var t=this;return Promise.resolve(this._workerCreator()).then(function(n){return n.addEventListener("message",t._onMessage.bind(t,e)),t._workerItems[e]={worker:n,resolve:null,reject:null},n})},t._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},t._onMessage=function(e,t){var n=t.data.error;n?this._workerItems[e].reject(n):this._workerItems[e].resolve(t.data),this._nextTask(e)},t._nextTask=function(e){if(this._taskQueue.length){var t=this._taskQueue.shift(),n=this._workerItems[e];n.resolve=t.resolve,n.reject=t.reject,n.worker.postMessage(t.message)}else this._workerStatus^=1<<e},e}(),lY=/*#__PURE__*/function(){function e(e){this.workerLimitCount=e}var t=e.prototype;return t.init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},t.destroy=function(){this._transcodeWorkerPool.destroy()},t._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new lK(this.workerLimitCount,function(){return new Promise(function(n,r){var a=new Worker(e);a.addEventListener("message",function(e){e.data.error?r(e.data.error):n(a)}),a.postMessage({type:"init",transcoderWasm:t})})}),this._transcodeWorkerPool.prepareWorker()},e}();function lq(){var e,t=function(t){return e||(e=new Promise(function(e,n){var r={wasmBinary:t,onRuntimeInitialized:function(){return e(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),e};self.onmessage=function(e){var n=e.data;switch(n.type){case"init":t(n.transcoderWasm).then(function(){self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":t().then(function(e){var t=lJ(n.buffer,n.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var lQ=function(e){return tl||(tl=new Promise(function(t,n){var r={wasmBinary:e,onRuntimeInitialized:function(){return t(r)},onAbort:n};self.BASIS(r)}).then(function(e){return e.initializeBasis(),e.KTX2File})),tl};function lJ(e,t,n){var r=new n(new Uint8Array(e));function a(){r.close(),r.delete()}if(!r.isValid())throw a(),Error("Invalid or unsupported .ktx2 file");if(!r.startTranscoding())throw a(),Error("KTX2 startTranscoding failed");for(var i=r.getWidth(),o=r.getHeight(),s=r.getLayers()||1,l=r.getLevels(),c=r.getHasAlpha(),u=r.getFaces(),d=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,c),h=Array(u),_=2===d||3===d||7===d,f=0;f<u;f++){for(var p=Array(l),m=0;m<l;m++){for(var g=Array(s),v=void 0,y=void 0,x=0;x<s;x++){var b=r.getImageLevelInfo(m,x,f);_&&0===m&&(i!==b.width||o!==b.height)?console.warn("KTX2 transcode to BC will resize to width: "+(i=v=b.width)+", height: "+(o=y=b.height)+". You'd better use an image whose size if multiple of 4."):(v=b.origWidth,y=b.origHeight);var C=new Uint8Array(r.getImageTranscodedSizeInBytes(m,x,0,d));if(!r.transcodeImage(C,m,x,f,d,0,-1,-1))throw a(),Error("transcodeImage failed.");g[x]=C}p[m]={data:function(e){if(1===e.length)return e[0];for(var t=0,n=0;n<e.length;n++)t+=e[n].byteLength;for(var r=new Uint8Array(t),a=0,i=0;i<e.length;i++)r.set(e[i],a),a+=e[i].byteLength;return r}(g),width:v,height:y}}h[f]=p}return a(),{faces:h,width:i,height:o,hasAlpha:c,faceCount:u,format:d}}var lZ=/*#__PURE__*/function(e){function t(t){return e.call(this,t)||this}s1(t,e);var n=t.prototype;return n._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 n=t[0],r=t[1];if(0===e.workerLimitCount)return new Promise(function(e,t){var a=document.createElement("script");a.src=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),document.body.appendChild(a),a.onload=function(){lQ(r).then(function(){e(null)})},a.onerror=function(){t()}});var a=lq.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o="\n "+n+"\n "+lJ.toString()+"\n "+i+"\n ",s=URL.createObjectURL(new Blob([o],{type:"application/javascript"}));return e._createTranscodePool(s,r)})},n.transcode=function(e,t){return 0===this.workerLimitCount?lQ().then(function(n){return lJ(e,t,n)}):this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},t}(lY);function l$(){var e,t=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.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,n){if(void 0===n&&(n=0),!e.instance)throw Error("ZSTDDecoder: Await .init() before decoding.");var r=e.instance.exports,a=t.byteLength,i=r.malloc(a);e.heap.set(t,i),n=n||Number(r.ZSTD_findDecompressedSize(i,a));var o=r.malloc(n),s=r.ZSTD_decompress(o,n,i,a),l=e.heap.slice(o,o+s);return r.free(i),r.free(o),l},e}();t.IMPORT_OBJECT={env:{emscripten_notify_memory_growth:function(){t.heap=new Uint8Array(t.instance.exports.memory.buffer)}}},t.WasmModuleURL="https://mdn.alipayobjects.com/rms/afts/file/A*awNJR7KqIAEAAAAAAAAAAAAAARQnAQ/zstddec.wasm";var n=new t;self.onmessage=function(t){var r,a=t.data;switch(a.type){case"init":(r=a.transcoderWasm,e=WebAssembly.instantiate(r,{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":e.then(function(e){var t,r,i,o,s;(t=a.data,r=a.needZstd,o=Array(i=t.length),s=Promise.resolve(),r&&(n.init(),s=n._initPromise),s.then(function(){for(var a=0;a<i;a++){for(var s=t[a].length,l=Array(s),c=0;c<s;c++){var u=t[a][c],d=u.buffer,h=u.levelHeight,_=u.levelWidth,f=u.uncompressedByteLength;r&&(d=n.decode(d.slice(),f));var p=d.byteLength/i,m=d.byteOffset,g=function(e,t,n,r){var a=(n+3>>2)*(r+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}(e,new Uint8Array(d.buffer,m+a*p,p),_,h);if(g)l[c]={data:g.slice(),width:_,height:h};else throw"buffer decoded error"}o[a]=l}return o})).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var l0=/*#__PURE__*/function(e){function t(t,n){var r;return(r=e.call(this,t)||this).type=n,r}s1(t,e);var n=t.prototype;return n._initTranscodeWorkerPool=function(){var e=this;return fetch(t.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var n=l$.toString(),r=URL.createObjectURL(new Blob([n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(r,t)})},n.transcode=function(e){for(var t=e.supercompressionScheme===lW.Zstd,n=e.levels.length,r=e.faceCount,a={width:e.pixelWidth,height:e.pixelHeight,mipmaps:null},i={type:"transcode",format:0,needZstd:t,data:Array(r)},o=i.data,s=0;s<r;s++){for(var l=Array(n),c=0;c<n;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})},t}(lY);l0.transcoderMap=((tf={})[lX.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",tf),e.KTX2Loader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.initialize=function(e,n){if(n.ktx2Loader){var r=n.ktx2Loader;return(r.priorityFormats&&(t._priorityFormats.etc1s=r.priorityFormats,t._priorityFormats.uastc=r.priorityFormats),1===r.transcoder)?t._getKhronosTranscoder(r.workerCount).init():t._getBinomialLLCTranscoder(r.workerCount).init()}},n.load=function(e,n){return new a8(function(r,a,i,o){n._request(e.url,{type:"arraybuffer"}).onProgress(i,o).then(function(r){return t._parseBuffer(new Uint8Array(r),n.engine,e.params).then(function(e){var n=e.engine,r=e.result,a=e.targetFormat,i=e.params;return t._createTextureByBuffer(n,r,a,i)})}).then(r).catch(a)})},t.release=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},t._parseBuffer=function(e,n,r){var a,i,o=new lj(e),s=null!=(a=null==r?void 0:r.priorityFormats)?a:t._priorityFormats[o.isUASTC?"uastc":"etc1s"],l=t._decideTargetFormat(n,o,s);if(!t._isBinomialInit&&l0.transcoderMap[l]&&o.isUASTC){var c=t._getKhronosTranscoder();i=c.init().then(function(){return c.transcode(o)})}else{var u=t._getBinomialLLCTranscoder();i=u.init().then(function(){return u.transcode(e,l)})}return i.then(function(e){return{engine:n,result:e,targetFormat:l,params:o.keyValue.GalaceanTextureParams}})},t._createTextureByBuffer=function(e,t,n,r){var a,i=t.width,o=t.height,s=t.faces,l=s.length,c=s[0],u=c.length>1,d=this._getEngineTextureFormat(n,t);if(6!==l){a=new nc(e,i,o,d,u);for(var h=0;h<c.length;h++){var _=c[h].data;a.setPixelBuffer(_,h)}}else{a=new nd(e,o,d,u);for(var f=0;f<s.length;f++)for(var p=s[f],m=0;m<c.length;m++)a.setPixelBuffer(t4.PositiveX+f,p[m].data,m)}return r&&(a.wrapModeU=r[0],a.wrapModeV=r[1],a.filterMode=r[2],a.anisoLevel=r[3]),a},t._decideTargetFormat=function(e,t,n){var r=e._hardwareRenderer,a=this._detectSupportedFormat(r,n);return a!==lX.PVRTC||tS.isPowerOf2(t.pixelWidth)&&tS.isPowerOf2(t.pixelHeight)&&t.pixelWidth===t.pixelHeight?null===a?(no.warn("Can't support any compressed texture, downgrade to RGBA8"),lX.R8G8B8A8):a:(no.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),lX.R8G8B8A8)},t._detectSupportedFormat=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],a=this._supportedMap[r];if(a){for(var i=0;i<a.length;i++)if(e.canIUse(a[i]))return r}else switch(t[n]){case lX.R8G8B8A8:return r;case lX.R8:case lX.R8G8:if(e.isWebGL2)return r}}return null},t._getBinomialLLCTranscoder=function(e){var n;return void 0===e&&(e=4),t._isBinomialInit=!0,null!=(n=this._binomialLLCTranscoder)?n:this._binomialLLCTranscoder=new lZ(e)},t._getKhronosTranscoder=function(e){var t;return void 0===e&&(e=4),null!=(t=this._khronosTranscoder)?t:this._khronosTranscoder=new l0(e,lX.ASTC)},t._getEngineTextureFormat=function(e,t){var n=t.hasAlpha;switch(e){case lX.ASTC:return t9.ASTC_4x4;case lX.ETC:return n?t9.ETC2_RGBA8:t9.ETC2_RGB;case lX.BC7:return t9.BC7;case lX.BC1_BC3:return n?t9.BC3:t9.BC1;case lX.PVRTC:return n?t9.PVRTC_RGBA4:t9.PVRTC_RGB4;case lX.R8G8B8A8:return t9.R8G8B8A8}},t}(ol),e.KTX2Loader._isBinomialInit=!1,e.KTX2Loader._priorityFormats={etc1s:[lX.ETC,lX.BC7,lX.ASTC,lX.BC1_BC3,lX.PVRTC],uastc:[lX.ASTC,lX.BC7,lX.ETC,lX.BC1_BC3,lX.PVRTC]},e.KTX2Loader._supportedMap=((tp={})[lX.ASTC]=[nJ.astc],tp[lX.ETC]=[nJ.etc],tp[lX.BC7]=[nJ.bptc],tp[lX.BC1_BC3]=[nJ.s3tc],tp[lX.PVRTC]=[nJ.pvrtc,nJ.pvrtc_webkit],tp),e.KTX2Loader=s3([it(a2.KTX2,["ktx2"])],e.KTX2Loader);var l1=((tc={})[tc.BinomialLLC=0]="BinomialLLC",tc[tc.Khronos=1]="Khronos",tc),l2=/*#__PURE__*/function(t){function n(){var e;return e=t.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e}s1(n,t);var r=n.prototype;return r.restoreContent=function(){var t=this;return new a8(function(n,r){Promise.all(t.bufferRequests.map(function(e){return a6(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)}}a8.all(t.bufferTextures.map(function(t){var n,r=t.bufferView,i=new Uint8Array(a[r.buffer],null!=(n=r.byteOffset)?n:0,r.byteLength),o=t.texture;return"image/ktx2"===t.mimeType?e.KTX2Loader._parseBuffer(i,o.engine).then(function(e){for(var t=e.result.faces[0],n=0;n<t.length;n++)o.setPixelBuffer(t[n].data,n)}):lH.loadImageBuffer(i,t.mimeType).then(function(e){o.setImageSource(e),o.generateMipmaps()})})).then(function(){for(var e,r=lf(t.meshes);!(e=r()).done;){for(var i,o=e.value,s=o.mesh,l=lf(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,_=lf(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=lH.bufferToVector3Array(g,m.byteOffset,m.count,m.normalized,m.componentType),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=lH.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=lH.bufferToVector3Array(b,x.byteOffset,x.count,x.normalized,x.componentType)}}s.uploadData(!0)}n(t.resource)}).catch(r)}).catch(r)})},r._getBufferData=function(e,t){var n,r=t.main;if(r){var a=e[r.bufferIndex];n=new r.TypedArray(a,r.byteOffset,r.length)}else n=new r.TypedArray(r.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++)n[f*h+p]=d[_*h+p];return n},n}(t2),l3=function(e,t){this.url=e,this.config=t},l4=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},l8=function(){this.vertexBuffers=[],this.blendShapes=[]},l5=function(e,t){this.buffer=e,this.data=t},l9=function(e,t,n,r,a){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=a},l6=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},l7=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},ce=function(e,t,n,r,a){this.buffer=e,this.byteOffset=t,this.count=n,this.normalized=r,this.componentType=a},ct=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.createAndParse=function(e,t,n){for(var r=arguments.length,a=Array(r>3?r-3:0),i=3;i<r;i++)a[i-3]=arguments[i];throw"Not implemented."},t.additiveParse=function(e,t,n,r){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."},e}(),cn=((tu={})[tu.CreateAndParse=0]="CreateAndParse",tu[tu.AdditiveParse=1]="AdditiveParse",tu),cr=/*#__PURE__*/function(){function e(){}return e.executeExtensionsCreateAndParse=function(t,n,r){void 0===t&&(t={});for(var a=arguments.length,i=Array(a>3?a-3:0),o=3;o<a;o++)i[o-3]=arguments[o];for(var s=null,l=Object.keys(t),c=l.length-1;c>=0;--c){var u=l[c],d=t[u];if(s=e._createAndParse.apply(e,[].concat([u,n,d,r],i)))return s}},e.executeExtensionsAdditiveAndParse=function(t,n,r,a){for(var i=arguments.length,o=Array(i>4?i-4:0),s=4;s<i;s++)o[s-4]=arguments[s];for(var l in t){var c=t[l];e._additiveParse.apply(e,[].concat([l,n,r,c,a],o))}},e.hasExtensionParser=function(t){var n;return!!(null==(n=e._extensionParsers[t])?void 0:n.length)},e.getExtensionParser=function(t,n){var r=e._extensionParsers[t],a=null==r?void 0:r.length;if(a)for(var i=a-1;i>=0;--i){var o=r[i];if(o._mode===n)return o}},e._addExtensionParser=function(t,n){e._extensionParsers[t]||(e._extensionParsers[t]=[]),e._extensionParsers[t].push(n)},e._createAndParse=function(t,n,r,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=e.getExtensionParser(t,cn.CreateAndParse);if(l)return l.createAndParse.apply(l,[].concat([n,r,a],o))},e._additiveParse=function(t,n,r,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=e.getExtensionParser(t,cn.AdditiveParse);c&&c.additiveParse.apply(c,[].concat([n,r,a,i],s))},e}();function ca(e,t){return function(n){var r=new n;r._mode=t,cr._addExtensionParser(e,r)}}function ci(){if(tg)return tg;var e,t=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]),n=id._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";function r(e){for(var n=new Uint8Array(e.length),r=0;r<e.length;++r){var a=e.charCodeAt(r);n[r]=a>96?a-97:a>64?a-39:a+4}for(var i=0,o=0;o<e.length;++o)n[i++]=n[o]<60?t[n[o]]:(n[o]-60)*64+n[++o];return n.buffer.slice(0,i)}tg=WebAssembly.instantiate(r(n)).then(function(t){(e=t.instance).exports.__wasm_call_ctors()}).then(function(){return{workerCount:4,ready:tg,useWorkers:function(e){this.workerCount=null!=e?e:this.workerCount,function(e){for(var t=new Blob(["var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(r(n))+']), {}).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 }'],{type:"text/javascript"}),a=URL.createObjectURL(t),i=0;i<e;++i)o[i]=function(e){var t={object:new Worker(e),pending:0,requests:{}};return t.object.onmessage=function(e){var n=e.data;t.pending-=n.count,t.requests[n.id][n.action](n.value),delete t.requests[n.id]},t}(a);URL.revokeObjectURL(a)}(this.workerCount)},decodeGltfBuffer:function(t,n,r,l,c){return(this.workerCount>0&&0===o.length&&this.useWorkers(),o.length>0)?function(e,t,n,r,a){for(var i=o[0],l=1;l<o.length;++l)o[l].pending<i.pending&&(i=o[l]);return new Promise(function(o,l){var c=new Uint8Array(n),u=s++;i.pending+=e,i.requests[u]={resolve:o,reject:l},i.object.postMessage({id:u,count:e,size:t,source:c,mode:r,filter:a},[c.buffer])})}(t,n,r,i[l],a[c]):tg.then(function(){var o=new Uint8Array(t*n);return function(t,n,r,a,i,o){var s=e.exports.sbrk,l=r+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,r,a,u,i.length);if(0==h&&o&&o(c,l,a),n.set(d.subarray(c,c+r*a)),s(c-s(0)),0!=h)throw Error("Malformed buffer data: "+h)}(e.exports[i[l]],o,t,n,r,e.exports[a[c]]),o})},release:function(){for(var e=0;e<o.length;e++)o[e].object.terminate()}}});var a={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},i={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},o=[],s=0;return tg}cr._extensionParsers={},e.GLTFSchemaParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=e.resourceManager,a=t.url,i=n.bufferRequests,o={type:"arraybuffer"},s=r._getRemoteUrl(a);return r._requestByRemoteUrl(s,o).onProgress(void 0,e._onTaskDetail).then(function(t){var n=lH.parseGLB(e,t);return(null==n?void 0:n.glTF)&&i.push(new l3(s,o)),n}).then(function(t){return(null==t?void 0:t.glTF)?(n.isGLB=!0,e.buffers=t.buffers,t.glTF):(n.isGLB=!1,JSON.parse(nT.decodeText(new Uint8Array(t.originBuffer))))})},t}(cr),e.GLTFSchemaParser=s3([lG(lk.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.parse=function(e,t){var r=e.glTF.animations[t],a=r.name;return Promise.resolve(cr.executeExtensionsCreateAndParse(r.extensions,e,r)||n._parseStandardProperty(e,new ov(void 0===a?"AnimationClip"+t:a),r)).then(function(t){return cr.executeExtensionsAdditiveAndParse(r.extensions,e,t,r),t})},n._parseStandardProperty=function(e,t,n){for(var r=function(t,n){var r=c[t],a=o[r.input],i=o[r.output];_.push(Promise.all([lH.getAccessorBuffer(e,s,a),lH.getAccessorBuffer(e,s,i)]).then(function(e){var n,a,o=e[0].data,s=e[1].data;if(i.normalized){for(var l=lH.getNormalizedComponentScale(i.componentType),c=new Float32Array(s.length),u=0,h=s.length;u<h;u++)c[u]=s[u]*l;s=c}var _=s.length/o.length;switch(null!=(n=r.interpolation)?n:lF.Linear){case lF.CubicSpine:a=oy.CubicSpine;break;case lF.Step:a=oy.Step;break;case lF.Linear:a=oy.Linear}o[o.length-1],d[t]={type:i.type,interpolation:a,input:o,output:s,outputSize:_}}))},a=this,i=e.glTF,o=i.accessors,s=i.bufferViews,l=n.channels,c=n.samplers,u=c.length,d=Array(u),h=e.get(lk.Entity),_=[],f=0;f<u;f++)r(f);return _.push(e.get(lk.Scene)),Promise.all(_).then(function(){for(var n=0,r=l.length;n<r;n++){for(var o=l[n],s=o.target,c=h[s.node],u="",_=c;_.parent;)u=""===u?""+_.name:_.name+"/"+u,_=_.parent;if(-1!==e.glTFResource.sceneRoots.indexOf(_)){var f=void 0,p=void 0;switch(s.path){case lP.TRANSLATION:f=rp,p="position";break;case lP.ROTATION:f=rp,p="rotationQuaternion";break;case lP.SCALE:f=rp,p="scale";break;case lP.WEIGHTS:f=aK,p="blendShapeWeights"}var m=a._addCurve(s.path,o,d);if(s.path===lP.WEIGHTS)for(var g=i.nodes[s.node].mesh,v=0,y=i.meshes[g].primitives.length;v<y;v++)t.addCurveBinding(u,f,v,p,m);else t.addCurveBinding(u,f,p,m)}}return t})},n._addCurve=function(t,n,r){var a=r[n.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case lP.TRANSLATION:case lP.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,d=0,h=i.length;d<h;d++){var _=new oU;_.time=i[d],c===oy.CubicSpine?(_.inTangent=new tT(o[u++],o[u++],o[u++]),_.value=new tT(o[u++],o[u++],o[u++]),_.outTangent=new tT(o[u++],o[u++],o[u++])):_.value=new tT(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lP.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 oU;y.time=i[g],p===oy.CubicSpine?(y.inTangent=new tI(o[m++],o[m++],o[m++],o[m++]),y.value=new tF(o[m++],o[m++],o[m++],o[m++]),y.outTangent=new tI(o[m++],o[m++],o[m++],o[m++])):y.value=new tF(o[m++],o[m++],o[m++],o[m++]),f.addKey(y)}return f;case lP.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var b=0,C=0,S=i.length;C<S;C++){var T=new oU;T.time=i[C],x.interpolation===oy.CubicSpine?(T.inTangent=Array.from(o.subarray(b,b+s)),b+=s,T.value=o.slice(b,b+s),b+=s,T.outTangent=Array.from(o.subarray(b,b+s))):T.value=o.slice(b,b+s),b+=s,x.addKey(T)}return x}},n}(cr),e.GLTFAnimationParser=s3([lG(lk.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e,t){var n=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,n[t])},n._parseSingleBuffer=function(e,t){var n=e.glTFResource,r=e.contentRestorer,a=e.resourceManager,i=n.url,o=a._getRemoteUrl(i),s=r.bufferRequests,l={type:"arraybuffer"},c=nT.resolveAbsoluteUrl(o,t.uri);s.push(new l3(c,l));var u=a._requestByRemoteUrl(c,l).onProgress(void 0,e._onTaskDetail);return e._addTaskCompletePromise(u),u},t}(cr),e.GLTFBufferParser=s3([lG(lk.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,t){var n=e.glTFResource,r=e.glTF.nodes[t],a=n.engine,i=r.matrix,o=r.translation,s=r.rotation,l=r.scale,c=r.extensions,u=new aW(a,r.name||"_GLTF_ENTITY_"+t);u._markAsTemplate(n);var d=u.transform;if(i){var h=d.localMatrix;h.copyFromArray(i),d.localMatrix=h}else o&&d.setPosition(o[0],o[1],o[2]),s&&d.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&d.setScale(l[0],l[1],l[2]);var _=r.children;if(_)for(var f=0;f<_.length;f++){var p=_[f],m=e.get(lk.Entity,p);u.addChild(m)}return cr.executeExtensionsAdditiveAndParse(c,e,u,r),u},t}(cr),e.GLTFEntityParser=s3([lG(lk.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){var r=e.glTF.materials[n],a=e.glTFResource,i=a.engine,o=cr.executeExtensionsCreateAndParse(r.extensions,e,r);return o||((o=new ad(i)).name=r.name,t._parseStandardProperty(e,o,r)),Promise.resolve(o).then(function(n){return n||(n=t._getDefaultMaterial(i)),cr.executeExtensionsAdditiveAndParse(r.extensions,e,n,r),n._associationSuperResource(a),n})},t._getDefaultMaterial=function(e){return t._defaultMaterial||(t._defaultMaterial=new al(e))},t._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&no.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},t._parseStandardProperty=function(e,n,r){var a=r.pbrMetallicRoughness,i=r.normalTexture,o=r.occlusionTexture,s=r.emissiveTexture,l=r.emissiveFactor,c=r.alphaMode,u=r.alphaCutoff,d=r.doubleSided;if(a){var h=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,m=a.metallicRoughnessTexture;h&&(n.baseColor=new tO(tO.linearToGammaSpace(h[0]),tO.linearToGammaSpace(h[1]),tO.linearToGammaSpace(h[2]),h[3])),_&&e.get(lk.Texture,_.index).then(function(t){n.baseTexture=t,cr.executeExtensionsAdditiveAndParse(_.extensions,e,n,_)}),n.constructor===ad&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,m&&(t._checkOtherTextureTransform(m,"Roughness metallic"),e.get(lk.Texture,m.index).then(function(e){n.roughnessMetallicTexture=e})))}if(n.constructor===ad||n.constructor===ah){if(s&&(t._checkOtherTextureTransform(s,"Emissive"),e.get(lk.Texture,s.index).then(function(e){n.emissiveTexture=e})),l&&(n.emissiveColor=new tO(tO.linearToGammaSpace(l[0]),tO.linearToGammaSpace(l[1]),tO.linearToGammaSpace(l[2]))),i){var g=i.index,v=i.scale;t._checkOtherTextureTransform(i,"Normal"),e.get(lk.Texture,g).then(function(e){n.normalTexture=e}),void 0!==v&&(n.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,b=o.texCoord;t._checkOtherTextureTransform(o,"Occlusion"),e.get(lk.Texture,y).then(function(e){n.occlusionTexture=e}),void 0!==x&&(n.occlusionTextureIntensity=x),b===ac.UV1?n.occlusionTextureCoord=ac.UV1:b>ac.UV1&&no.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=ai.Double:n.renderFace=ai.Front,c){case lD.OPAQUE:n.isTransparent=!1;break;case lD.BLEND:n.isTransparent=!0;break;case lD.MASK:n.alphaCutoff=null!=u?u:.5}},t}(cr),e.GLTFMaterialParser=s3([lG(lk.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){for(var r=function(n,r){var c=a.primitives[n];l[n]=new Promise(function(r){var l=cr.executeExtensionsCreateAndParse(c.extensions,e,c,a);if(l)lh(l,aM)?(l._associationSuperResource(o),r(l)):l.then(function(e){e._associationSuperResource(o),r(e)});else{var u=new aM(s,a.name||n+"");u._associationSuperResource(o);var d=new l8;d.mesh=u,e.contentRestorer.meshes.push(d),t._parseMeshFromGLTFPrimitive(e,u,d,a,c,i,e.params.keepMeshData).then(r)}})},a=e.glTF.meshes[n],i=e.glTF,o=e.glTFResource,s=o.engine,l=[],c=0,u=a.primitives.length;c<u;c++)r(c);return Promise.all(l)},t._parseMeshFromGLTFPrimitive=function(e,n,r,a,i,o,s){var l,c=function(a){var i=u[d[a]],c=lH.getAccessorBuffer(e,o.bufferViews,i).then(function(e){var o,c,u,d=lH.getAccessorTypeSize(i.type),h=i.count,_=e.data,f=n.instanceId,v=e.vertexBindingInfos,y=i.normalized,x=lH.getElementFormat(i.componentType,d,y);if(y&&(c=lH.getNormalizedComponentScale(i.componentType)),e.interleaved){var b=i.byteOffset||0,C=e.stride;if(u=b%C,void 0===v[f]){o=new at(a,u,x,g);var S=e.vertexBuffer;S||(S=new r9(p,an.VertexBuffer,_,r8.Static,s),e.vertexBuffer=S,r.vertexBuffers.push(new l5(S,e.restoreInfo))),n.setVertexBufferBinding(S,C,g),v[f]=g++}else o=new at(a,u,x,v[f])}else{o=new at(a,u=0,x,g);var T=e.vertexBuffer;T||(T=new r9(p,an.VertexBuffer,_,r8.Static,s),r.vertexBuffers.push(new l5(T,e.restoreInfo))),n.setVertexBufferBinding(T,e.stride,g),v[f]=g++}if(m.push(o),"POSITION"===a){l=h;var A=n.bounds,E=A.min,R=A.max;if(i.min&&i.max)E.copyFromArray(i.min),R.copyFromArray(i.max);else{var M=t._tempVector3;E.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;M.copyFromArray(_,L),tT.min(E,M,E),tT.max(R,M,R)}}y&&(E.scale(c),R.scale(c))}});v.push(c)},u=o.accessors,d=i.attributes,h=i.targets,_=i.indices,f=i.mode,p=n.engine,m=[],g=0,v=[];for(var y in d)c(y);return Promise.all(v).then(function(){if(n.setVertexElements(m),void 0!==_){var c=o.accessors[_],u=lH.getAccessorBuffer(e,o.bufferViews,c).then(function(e){n.setIndices(e.data),n.addSubMesh(0,c.count,f),r.indexBuffer=e.restoreInfo});v.push(u)}else n.addSubMesh(0,l,f);return h&&v.push(t._createBlendShape(e,n,r,a,i,h)),Promise.all(v).then(function(){return n.uploadData(!s),n})})},t._getBlendShapeData=function(e,t,n){return lH.getAccessorBuffer(e,t.bufferViews,n).then(function(e){var t,r=e.data,a=e.interleaved?(null!=(t=n.byteOffset)?t:0)%e.stride:0,i=n.count,o=n.normalized,s=n.componentType;return{vertices:lH.bufferToVector3Array(r,a,i,o,s),restoreInfo:new ce(e.restoreInfo,a,i,o,s)}})},t._createBlendShape=function(e,t,n,r,a,i){for(var o,s=e.glTF,l=s.accessors,c=r.extras?r.extras.targetNames:null,u=[],d=i.length,h=Array(d),_=0;_<d;_++)o=this,function(t){var n={};h[t]=n;var r=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 am(r);o.addFrame(1,t.vertices,f?a.vertices:null,p?i.vertices:null),n.blendShape=o,n.restoreInfo=new l7(o,t.restoreInfo,f?a.restoreInfo:null,p?null==i?void 0:i.restoreInfo:null)}))}(_);return Promise.all(u).then(function(){for(var e,r=lf(h);!(e=r()).done;){var a=e.value;t.addBlendShape(a.blendShape),n.blendShapes.push(a.restoreInfo)}})},t}(cr),e.GLTFMeshParser._tempVector3=new tT,e.GLTFMeshParser=s3([lG(lk.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}s1(n,t);var r=n.prototype;return r.parse=function(e,t){var n,r=e.glTF,a=r.scenes,i=r.scene,o=e.glTFResource,s=a[t],l=s.extensions,c=o.engine,u=s.nodes||[];if(1===u.length)n=e.get(lk.Entity,u[0]);else{(n=new aW(c,"GLTF_ROOT"))._markAsTemplate(o);for(var d=0;d<u.length;d++){var h=e.get(lk.Entity,u[d]);n.addChild(h)}}(void 0===i?0:i)===t&&(o._defaultSceneRoot=n);for(var _=[],f=0;f<u.length;f++)_.push(this._parseEntityComponent(e,u[f]));return Promise.all(_).then(function(){return cr.executeExtensionsAdditiveAndParse(l,e,n,s),n})},r._parseEntityComponent=function(e,t){var n,r=this,a=e.glTF,i=e.glTFResource,o=a.nodes[t],s=o.camera,l=o.mesh,c=e.get(lk.Entity,t);return void 0!==s&&this._createCamera(i,a.cameras[s],c),void 0!==l&&(n=this._createRenderer(e,o,c)),Promise.resolve(n).then(function(){var t=[],n=o.children;if(n)for(var a=0;a<n.length;a++)t.push(r._parseEntityComponent(e,n[a]));return Promise.all(t)})},r._createCamera=function(t,n,r){var a=n.orthographic,i=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===lL.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===lL.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},r._createRenderer=function(t,n,r){for(var a,i=this,o=n.mesh,s=n.skin,l=t.glTF.meshes[o],c=l.primitives,u=c.length,d=n.weights||l.weights,h=Array(u),_=0;_<u;_++)h[_]=t.get(lk.Material,null!=(a=c[_].material)?a:-1);return Promise.all([t.get(lk.Mesh,o),void 0!==s&&t.get(lk.Skin,s),Promise.all(h)]).then(function(n){for(var a=n[0],o=n[1],s=n[2],l=0;l<u;l++)!function(n){var l=s[n]||e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine),u=c[n],h=a[n],_=void 0;if(o||d){var f=r.addComponent(aK);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(_=r.addComponent(aA)).mesh=h;_.setMaterial(l),h.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(_.enableVertexColor=!0)}),cr.executeExtensionsAdditiveAndParse(u.extensions,t,_,u)}(l)})},r._computeLocalBounds=function(e,t,n,r,a){var i=n.indexOf(r);if(-1!==i)tE.transform(t.bounds,a[i],e.localBounds);else{var o=new tL(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),s=this._computeApproximateBindMatrix(n,a,r,o);0!==s?(tL.multiplyScalar(o,1/s,o),tE.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},r._computeApproximateBindMatrix=function(e,t,n,r){for(var a=0,i=n.children,o=0,s=i.length;o<s;o++){var l=i[o],c=e.indexOf(l);-1!==c?(tL.add(r,t[c],r),a++):a+=this._computeApproximateBindMatrix(e,t,l,r)}return a},n}(cr),e.GLTFSceneParser=s3([lG(lk.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e,t){var n=this,r=e.glTF,a=r.skins[t],i=a.inverseBindMatrices,o=a.skeleton,s=a.joints,l=a.name,c=s.length,u=new aj(void 0===l?"SKIN_"+t:l);u.inverseBindMatrices.length=c;var d=Array(c),h=r.accessors[i];return Promise.resolve(lH.getAccessorBuffer(e,r.bufferViews,h).then(function(t){for(var r=e.get(lk.Entity),a=t.data,i=0;i<c;i++){var l=new tL;l.copyFromArray(a,16*i),u.inverseBindMatrices[i]=l;var h=r[s[i]];d[i]=h,u.joints[i]=h.name}if(u.bones=d,void 0!==o){var _=r[o];u.rootBone=_}else{var f=n._findSkeletonRootBone(s,r);if(f)u.rootBone=f;else throw"Failed to find skeleton root bone."}return u}))},n._findSkeletonRootBone=function(e,t){for(var n,r={},a=lf(e);!(n=a()).done;){for(var i=n.value,o=[],s=t[i];s;)o.unshift(s),s=s.parent;r[i]=o}for(var l=null,c=0;;c++){var u=r[e[0]];if(c>=u.length)return l;for(var d=u[c],h=1,_=e.length;h<_;h++)if(c>=(u=r[e[h]]).length||d!==u[c])return l;l=d}},t}(cr),e.GLTFSkinParser=s3([lG(lk.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,n){var r=e.glTF.textures[n],a=e.glTFResource,i=r.sampler,o=r.source,s=r.name,l=r.extensions,c=cr.executeExtensionsCreateAndParse(l,e,r,n);return c||(c=t._parseTexture(e,void 0===o?0:o,n,i,s)),Promise.resolve(c).then(function(t){return cr.executeExtensionsAdditiveAndParse(l,e,t,r),t._associationSuperResource(a),t})},t._parseTexture=function(e,t,n,r,a){var i,o=e.glTFResource,s=e.glTF,l=o.engine,c=o.url,u=s.images[t],d=u.uri,h=u.bufferView,_=u.mimeType,f=u.name,p=void 0!==r,m=p&&lH.getSamplerInfo(s.samplers[r]);if(d){var g=d.lastIndexOf("."),v=d.substring(g+1).startsWith("ktx")?a2.KTX:a2.Texture2D;i=l.resourceManager.load({url:nT.resolveAbsoluteUrl(c,d),type:v,params:{mipmap:null==m?void 0:m.mipmap}}).onProgress(void 0,e._onTaskDetail).then(function(e){return e.name=a||f||e.name||"texture_"+n,p&&lH.parseSampler(e,m),e}),e._addTaskCompletePromise(i)}else{var y=s.bufferViews[h];i=e.get(lk.Buffer).then(function(t){var r=new Uint8Array(t[y.buffer],y.byteOffset,y.byteLength);return lH.loadImageBuffer(r,_).then(function(t){var r=new nc(l,t.width,t.height,void 0,null==m?void 0:m.mipmap);r.setImageSource(t),r.generateMipmaps(),r.name=a||f||"texture_"+n,p&&lH.parseSampler(r,m);var i=new l4(r,y,_);return e.contentRestorer.bufferTextures.push(i),r})})}return i},t}(cr),e.GLTFTextureParser._wrapMap=((tm={})[lO.CLAMP_TO_EDGE]=t7.Clamp,tm[lO.MIRRORED_REPEAT]=t7.Mirror,tm[lO.REPEAT]=t7.Repeat,tm),e.GLTFTextureParser=s3([lG(lk.Texture)],e.GLTFTextureParser),e.GLTFValidator=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e){var t=e.glTF,n=t.asset.version,r=t.extensionsUsed,a=t.extensionsRequired,i=Number(n);if(!(i>=2&&i<3))throw"Only support glTF 2.x.";if(r){no.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];cr.hasExtensionParser(s)||no.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){no.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];cr.hasExtensionParser(c)||no.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},t}(cr),e.GLTFValidator=s3([lG(lk.Validator)],e.GLTFValidator),e.GLTFBufferViewParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.parse=function(e,t){var n=e.glTF.bufferViews[t],r=n.extensions,a=n.byteOffset,i=void 0===a?0:a,o=n.byteLength,s=n.buffer;return r?cr.executeExtensionsCreateAndParse(r,e,n):e.get(lk.Buffer,s).then(function(e){return new Uint8Array(e,i,o)})},t}(cr),e.GLTFBufferViewParser=s3([lG(lk.BufferView)],e.GLTFBufferViewParser),e.GLTFAnimatorControllerParser=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.parse=function(e){var t=this;return e.needAnimatorController?e.get(lk.Animation).then(function(n){return Promise.resolve(t._createAnimatorController(e,n))}):Promise.resolve(null)},n._createAnimatorController=function(e,t){var n=new oI(e.glTFResource.engine),r=new oz("layer"),a=new ok;if(n.addLayer(r),r.stateMachine=a,t)for(var i=0;i<t.length;i++){var o=t[i],s=o.name,l=a.makeUniqueStateName(s);l!==s&&console.warn("AnimatorState name is existed, name: "+s+" reset to "+l),a.addState(l).clip=o}return n},t}(cr),e.GLTFAnimatorControllerParser=s3([lG(lk.AnimatorController)],e.GLTFAnimatorControllerParser),e.GLTFLoader=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.initialize=function(e,t){var n,r,a,i=null!=(a=null==(n=t.glTFLoader)?void 0:n.meshOpt)?a:null==(r=t.glTF)?void 0:r.meshOpt;return i?ci().then(function(e){e.useWorkers(i.workerCount)}):Promise.resolve()},n.load=function(e,t){var n=e.params,r=new lN(new lR(t.engine,e.url),t,s$({keepMeshData:!1},n));return new a8(function(e,t,n,a){r._setTaskCompleteProgress=n,r._setTaskDetailProgress=a,r.parse().then(e).catch(t)})},t.release=function(){tg&&ci().then(function(e){e.release()})},t}(ol),e.GLTFLoader=s3([it(a2.GLTF,["gltf","glb"])],e.GLTFLoader);var co=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t,n)||this).prefabResource=r,a}s1(t,e);var n=t.prototype;return n._handleRootEntity=function(e){this.prefabResource._root=this.context.entityMap.get(e)},n._clearAndResolve=function(){return this.context.clear(),this.prefabResource},t.parse=function(e,n,r){var a=new lp(e,n),i=new t(r,new ls(e,lo.Prefab,a),a);return i.start(),i.promise.then(function(){return a})},t}(lm),cs=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(t){co.parse(n,e.url,t).then(r).catch(a)})})},t}(ol);cs=s3([it(a2.Prefab,["prefab"])],cs);var cl=Math.PI,cc=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){return new a8(function(r,a){var i=n.engine,o=s$({},e,{type:"arraybuffer"});n._request(e.url,o).then(function(n){var a=t._setTextureByBuffer(i,n);i.resourceManager.addContentRestorer(new cu(a,e.url,o)),r(a)}).catch(a)})},t._setTextureByBuffer=function(e,n,r){var a=new Uint8Array(n),i=t._parseHeader(a),o=i.width,s=i.height,l=i.dataPosition,c=s>>1;r||(r=new nd(e,c));for(var u=t._readPixels(a.subarray(l),o,s),d=t._convertToCubemap(u,o,s,c),h=0;h<6;h++)r.setPixelBuffer(t4.PositiveX+h,d[h],0);return r.generateMipmaps(),r},t._convertToCubemap=function(e,t,n,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*n*4)throw"ConvertPanoramaToCubemap: input size is wrong";return[this._createCubemapData(r,this._faceRight,e,t,n),this._createCubemapData(r,this._faceLeft,e,t,n),this._createCubemapData(r,this._faceUp,e,t,n),this._createCubemapData(r,this._faceBottom,e,t,n),this._createCubemapData(r,this._faceFront,e,t,n),this._createCubemapData(r,this._faceBack,e,t,n)]},t._createCubemapData=function(e,t,n,r,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,n,r,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},t._calcProjectionSpherical=function(e,t,n,r){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-cl;)a+=2*cl;for(;a>cl;)a-=2*cl;var o=a/cl,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(i/cl*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s;return new tO(t[c],t[c+1],t[c+2],t[c+3])},t._readStringLine=function(e,t){for(var n="",r="",a=t;a<e.length-t&&"\n"!=(r=String.fromCharCode(e[a]));a++)n+=r;return n},t._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var a=!1,i=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?i=!0:0==r.length&&(a=!0);while(!a);if(!i)throw"HDR Bad header format, unsupported FORMAT";o+=r.length+1,r=this._readStringLine(e,o);var s=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!s||s.length<3)throw"HDR Bad header format, no size";if(n=parseInt(s[2]),t=parseInt(s[1]),n<8||n>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:o+=r.length+1}},t._readPixels=function(e,t,n){for(var r=e.byteLength,a=new Uint8Array(4*t*n),i=0,o=0,s=4*t,l=new Uint8Array(s),c=n;c>0&&o<r;){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<r;){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},t._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},t._linearToRGBM=function(e,t){var n=Math.min(Math.max(e.r,Math.max(e.g,e.b))/t,1),r=65025/((n=Math.ceil(255*n))*t);e.r*=r,e.g*=r,e.b*=r,e.a*=n},t}(ol);cc._rightBottomBack=new tT(1,-1,-1),cc._rightBottomFront=new tT(1,-1,1),cc._rightUpBack=new tT(1,1,-1),cc._rightUpFront=new tT(1,1,1),cc._leftBottomBack=new tT(-1,-1,-1),cc._leftBottomFront=new tT(-1,-1,1),cc._leftUpBack=new tT(-1,1,-1),cc._leftUpFront=new tT(-1,1,1),cc._faceRight=[cc._rightBottomBack,cc._rightBottomFront,cc._rightUpBack,cc._rightUpFront],cc._faceLeft=[cc._leftBottomFront,cc._leftBottomBack,cc._leftUpFront,cc._leftUpBack],cc._faceUp=[cc._leftBottomFront,cc._rightBottomFront,cc._leftBottomBack,cc._rightBottomBack],cc._faceBottom=[cc._leftUpBack,cc._rightUpBack,cc._leftUpFront,cc._rightUpFront],cc._faceFront=[cc._leftBottomBack,cc._rightBottomBack,cc._leftUpBack,cc._rightUpBack],cc._faceBack=[cc._rightBottomFront,cc._leftBottomFront,cc._rightUpFront,cc._leftUpFront],cc._tempVector3=new tT,cc._temp2Vector3=new tT,cc._temp3Vector3=new tT,cc._temp4Vector3=new tT,cc._temp5Vector3=new tT,cc=s3([it(a2.HDR,["hdr"])],cc);var cu=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){a6(e.url,e.requestConfig).then(function(n){cc._setTextureByBuffer(e.resource.engine,n,e.resource),t(e.resource)}).catch(n)})},t}(t2),cd=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return t._request(e.url,s$({},e,{type:"json"}))},t}(ol);cd=s3([it(a2.JSON,["json"],!1)],cd);var ch={parse:function(e,t,n,r){if(void 0===r&&(r=!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}(e))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var a=Uint32Array.BYTES_PER_ELEMENT,i=new DataView(e,12,13*a),o=0x4030201===i.getUint32(0,!0),s={buffer:e,glType:i.getUint32(1*a,o),glTypeSize:i.getUint32(2*a,o),glFormat:i.getUint32(3*a,o),glInternalFormat:i.getUint32(4*a,o),glBaseInternalFormat:i.getUint32(5*a,o),pixelWidth:i.getUint32(6*a,o),pixelHeight:i.getUint32(7*a,o),pixelDepth:i.getUint32(8*a,o),numberOfArrayElements:i.getUint32(9*a,o),numberOfFaces:i.getUint32(10*a,o),numberOfMipmapLevels:i.getUint32(11*a,o),bytesOfKeyValueData:i.getUint32(12*a,o),loadType:0};if(0!==s.glType)throw Error("only compressed formats currently supported");if(s.numberOfMipmapLevels=Math.max(1,s.numberOfMipmapLevels),0===s.pixelHeight||0!==s.pixelDepth)throw Error("only 2D textures currently supported");if(0!==s.numberOfArrayElements)throw Error("texture arrays not currently supported");if(s.numberOfFaces!==t)throw Error("number of faces expected"+t+", but found "+s.numberOfFaces);return n&&(s.mipmaps=function(e,t){for(var n=[],r=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,r,1)[0];r+=4;for(var c=0;c<e.numberOfFaces;c++){var u=new Uint8Array(e.buffer,r,l);n.push({data:u,width:a,height:i}),r+=l,r+=3-(l+3)%4}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return n}(s,!0)),r&&(s.engineFormat=function(e){switch(e){case sL.RGB_S3TC_DXT1_EXT:return t9.BC1;case sL.RGBA_S3TC_DXT5_EXT:return t9.BC3;case sL.RGBA_BPTC_UNORM_EXT:return t9.BC7;case sL.RGB_ETC1_WEBGL:return t9.ETC1_RGB;case sL.RGB8_ETC2:return t9.ETC2_RGB;case sL.RGB8_PUNCHTHROUGH_ALPHA1_ETC2:return t9.ETC2_RGBA5;case sL.RGBA8_ETC2_EAC:return t9.ETC2_RGBA8;case sL.RGB_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGB2;case sL.RGBA_PVRTC_2BPPV1_IMG:return t9.PVRTC_RGBA2;case sL.RGB_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGB4;case sL.RGBA_PVRTC_4BPPV1_IMG:return t9.PVRTC_RGBA4;case sL.RGBA_ASTC_4X4_KHR:return t9.ASTC_4x4;case sL.RGBA_ASTC_5X5_KHR:return t9.ASTC_5x5;case sL.RGBA_ASTC_6X6_KHR:return t9.ASTC_6x6;case sL.RGBA_ASTC_8X8_KHR:return t9.ASTC_8x8;case sL.RGBA_ASTC_10X10_KHR:return t9.ASTC_10x10;case sL.RGBA_ASTC_12X12_KHR:return t9.ASTC_12x12;default:throw Error("this format is not supported in Galacean Engine: "+sL[e])}}(s.glInternalFormat)),s}};function c_(e){var t=ch.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var cf=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){Promise.all(e.urls.map(function(n){return t._request(n,s$({},e,{type:"arraybuffer"}))})).then(function(e){for(var r=function(e){for(var t,n,r,a,i=[],o=0;o<e.length;o++){var s=ch.parse(e[o],1,!0,!0);i.push(s.mipmaps),0===o&&(r=s.pixelWidth,a=s.pixelHeight,t=s.glInternalFormat,n=s.engineFormat)}return{mipmapsFaces:i,engineFormat:n,internalFormat:t,width:r,height:a}}(e),a=r.width,i=r.mipmapsFaces,o=r.engineFormat,s=i[0].length>1,l=new nd(t.engine,a,o,s),c=0;c<6;c++)for(var u=i[c].length,d=0;d<u;d++){var h=i[c][d],_=h.data,f=h.width,p=h.height;l.setPixelBuffer(t4.PositiveX+c,_,d,0,0,f,p)}n(l)}).catch(function(e){r(e)})})},t}(ol);cf=s3([it(a2.KTXCube,[])],cf);var cp=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){for(var r=c_(e),a=r.width,i=r.height,o=r.mipmaps,s=r.engineFormat,l=o.length>1,c=new nc(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){r(e)})})},t}(ol);cp=s3([it(a2.KTX,["ktx"])],cp);var cm=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){var a=t.engine,i=e.shaderRef,o=e.shader,s=ro.find(o);s?r(n._getMaterialByShader(e,s,a)):i&&r(t.getResourceByRef(i).then(function(t){return n._getMaterialByShader(e,t,a)}))}).catch(a)})},n._getMaterialByShader=function(e,t,n){var r=function(e){var t=i[e],r=t.type,a=t.value;switch(r){case lu.Vector2:u.setVector2(e,new tB(a.x,a.y));break;case lu.Vector3:u.setVector3(e,new tT(a.x,a.y,a.z));break;case lu.Vector4:u.setVector4(e,new tI(a.x,a.y,a.z,a.w));break;case lu.Color:u.setColor(e,new tO(a.r,a.g,a.b,a.a));break;case lu.Float:u.setFloat(e,a);break;case lu.Texture:c.push(n.resourceManager.getResourceByRef(a).then(function(t){u.setTexture(e,t)}));break;case lu.Boolean:u.setInt(e,a?1:0);break;case lu.Integer:u.setInt(e,Number(a))}},a=e.name,i=e.shaderData,o=e.macros,s=e.renderState,l=new ao(n,t);l.name=a;var c=[],u=l.shaderData;for(var d in i)r(d);for(var h=0,_=o.length;h<_;h++){var f=o[h],p=f.name,m=f.value;void 0==m?u.enableMacro(p):u.enableMacro(p,m)}return function e(t,n,r){if((void 0===r?"undefined":s2(r))==="object")for(var a in r)e(t[n],a,r[a]);else t[n]=r}(l,"renderState",s),Promise.all(c).then(function(){return l})},t}(ol);cm=s3([it(a2.Material,["json"])],cm);var cg=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){t._request(e.url,s$({},e,{type:"arraybuffer"})).then(function(e){return lv(e,t.engine)}).then(function(e){n(e)}).catch(r)})},t}(ol);cg=s3([it(a2.Mesh,["mesh"])],cg);var cv=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return t._request(e.url,s$({},e,{type:"json"})).then(function(e){switch(e.type){case"sphere":return az.createSubdivisionSurfaceSphere(n,e.sphereRadius,e.sphereStep);case"capsule":return az.createCapsule(n,e.capsuleRadius,e.capsuleHeight,e.capsuleRadialSegments,e.capsuleHeightSegments);case"cone":return az.createCone(n,e.coneRadius,e.coneHeight,e.coneRadialSegment,e.coneHeightSegment);case"cuboid":return az.createCuboid(n,e.cuboidWidth,e.cuboidHeight,e.cuboidDepth);case"cylinder":return az.createCylinder(n,e.cylinderRadiusTop,e.cylinderRadiusBottom,e.cylinderHeight,e.cylinderRadialSegment,e.cylinderHeightSegment);case"plane":return az.createPlane(n,e.planeWidth,e.planeHeight,e.planeHorizontalSegments,e.planeVerticalSegments);case"torus":return az.createTorus(n,e.torusRadius,e.torusTubeRadius,e.torusRadialSegments,e.torusTubularSegments,e.torusArc)}})},t}(ol);cv=s3([it(a2.PrimitiveMesh,["mesh"],!1)],cv);var cy=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){return n.resourceManager.initVirtualResources(e.files),t.load({type:a2.Scene,url:e.scene}).then(function(e){n.sceneManager.activeScene=e,r()})}).catch(a)})},t}(ol);cy=s3([it(a2.Project,["proj"],!1)],cy);var cx=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a){var i=t._getRemoteUrl(e.url);n._registerFont(i,i).then(function(){r(new ng(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},n._registerFont=function(e,t){return lA(function(){var n;return s4(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},t}(ol);cx=s3([it(a2.SourceFont,["ttf","otf","woff"],!1)],cx);var cb=/*#__PURE__*/function(e){function t(){var t;return t=e.apply(this,arguments)||this,t._tempRect=new tN,t._tempVec2=new tB,t._tempVec4=new tI,t}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return new a8(function(r,a,i,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=t._request(e.url,s$({},e,{type:"json"}));l.push(c),c.then(function(i){var o=i.atlasItems,s=i.mipmap,c=i.anisoLevel,u=i.filterMode,d=i.wrapModeU,h=i.wrapModeV,_=i.format,f=o?o.length:0,p=t.engine,m=new nb(p);if(f<=0){r(m);return}l.length=0;for(var g=0;g<f;g++)!function(r){var i,f=o[r];if(f.img)l.push(t.load({url:nT.resolveAbsoluteUrl(e.url,f.img),type:null!=(i=f.type)?i:a2.Texture2D,params:{format:_,mipmap:s}}).then(function(e){c&&(e.anisoLevel=c),void 0!==u&&(e.filterMode=u),void 0!==d&&(e.wrapModeU=d),void 0!==h&&(e.wrapModeV=h);for(var t=0;t<f.sprites.length;t++)m._addSprite(n._makeSprite(p,f.sprites[t],e))}).catch(a));else for(var g=0;g<f.sprites.length;g++)m._addSprite(n._makeSprite(p,f.sprites[g]))}(g);a8.all(l).then(function(){r(m)}).catch(a)}).catch(a)})},n._makeSprite=function(e,t,n){var r=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=t.width,c=t.height,u=new nP(e,n,r?this._tempRect.set(r.x,r.y,r.w,r.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(n){var d=1/n.width,h=1/n.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},t}(ol);cb=s3([it(a2.SpriteAtlas,["atlas"],!1)],cb);var cC=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this;return t._request(e.url,s$({},e,{type:"json"})).then(function(e){return e.belongToAtlas?n._loadFromAtlas(t,e):n._loadFromTexture(t,e)})},n._loadFromAtlas=function(e,t){var n=this;return e.getResourceByRef(t.belongToAtlas).then(function(r){return r.getSprite(t.fullPath)||n._loadFromTexture(e,t)})},n._loadFromTexture=function(e,t){return t.texture?e.getResourceByRef(t.texture).then(function(n){var r=new nP(e.engine,n,t.region,t.pivot,t.border),a=t.width,i=t.height;return isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),r}):new a8(function(n){var r=new nP(e.engine,null,t.region,t.pivot,t.border),a=t.width,i=t.height;isNaN(a)||(r.width=a),isNaN(i)||(r.height=i),n(r)})},t}(ol);cC=s3([it(a2.Sprite,["sprite"],!1)],cC);var cS=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).url=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return a6(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},t}(t2),cT=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r,a,i){var o=e.url,s=s$({},e,{type:"image"});t._request(o,s).onProgress(a,i).then(function(r){var a,i=null!=(a=e.params)?a:{},l=i.format,c=i.mipmap,u=i.anisoLevel,d=i.wrapModeU,h=i.wrapModeV,_=i.filterMode,f=new nc(t.engine,r.width,r.height,l,c);if(f.anisoLevel=null!=u?u:f.anisoLevel,f.filterMode=null!=_?_:f.filterMode,f.wrapModeU=null!=d?d:f.wrapModeU,f.wrapModeV=null!=h?h:f.wrapModeV,f.setImageSource(r),f.generateMipmaps(),0!==o.indexOf("data:")){var p=o.lastIndexOf("/");f.name=o.substring(p+1)}t.addContentRestorer(new cS(f,o,s)),n(f)}).catch(function(e){r(e)})})},t}(ol);cT=s3([it(a2.Texture2D,["png","jpg","webp","jpeg"])],cT);var cA=/*#__PURE__*/function(e){function t(t,n,r){var a;return(a=e.call(this,t)||this).urls=n,a.requestConfig=r,a}return s1(t,e),t.prototype.restoreContent=function(){var e=this;return new a8(function(t,n){Promise.all(e.urls.map(function(t){return a6(t,e.requestConfig)})).then(function(n){for(var r=e.resource,a=0;a<6;a++)r.setImageSource(t4.PositiveX+a,n[a],0);r.generateMipmaps(),t(r)}).catch(function(e){n(e)})})},t}(t2),cE=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){var a=e.urls,i=s$({},e,{type:"image"});Promise.all(a.map(function(e){return t._request(e,i)})).then(function(e){var r=e[0],o=r.width;if(o!==r.height){console.error("The cube texture must have the same width and height");return}for(var s=new nd(t.engine,o),l=0;l<6;l++)s.setImageSource(t4.PositiveX+l,e[l],0);s.generateMipmaps(),t.addContentRestorer(new cA(s,a,i)),n(s)}).catch(function(e){r(e)})})},t}(ol);cE=s3([it(a2.TextureCube,[""])],cE);var cR=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){return new a8(function(n,r){var a=e.url,i=s$({},e,{type:"arraybuffer"});t._request(a,i).then(function(e){var i=new sM(t.engine);sw.getContext().decodeAudioData(e).then(function(e){if(i._setAudioSource(e),0!==a.indexOf("data:")){var t=a.lastIndexOf("/");i.name=a.substring(t+1)}n(i)}).catch(function(e){r(e)})})})},t}(ol);cR=s3([it(a2.Audio,["mp3","ogg","wav"])],cR);var cM=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,n){var r=e.url;return n._request(r,s$({},e,{type:"text"})).then(function(e){return n$.registerInclude(r.substring(1),e),t._loadChunksInCode(e,r,n)})},t._loadChunksInCode=function(e,n,r){for(var a,i=[],o=e.matchAll(t._shaderIncludeRegex),s=lf(o);!(a=s()).done;){var l=a.value,c=nT.resolveAbsoluteUrl(n,l[1]);nZ[c.substring(1)]||i.push(c)}return Promise.all(i.map(function(e){return r.load({type:"ShaderChunk",url:e})}))},t}(ol);cM._shaderIncludeRegex=/#include\s+"([./][^\\"]+)"/gm,cM=s3([it("ShaderChunk",["glsl"])],cM);var cw=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}s1(t,e);var n=t.prototype;return n.load=function(e,t){var n=this,r=e.url;return t._request(r,s$({},e,{type:"text"})).then(function(e){var a=n._getBuiltinShader(e);return a?ro.find(a):cM._loadChunksInCode(e,r,t).then(function(){var t=ro.create(e);return t._registerPath(r),t})})},n._getBuiltinShader=function(e){var n=e.match(t._builtinRegex);if(n&&n[1])return n[1]},t}(ol);cw._builtinRegex=/^\s*\/\/\s*@builtin\s+(\w+)/,cw=s3([it(a2.Shader,["gs","gsl"])],cw);var cP=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.load=function(e,t){var n=t.engine;return new a8(function(r,a){t._request(e.url,s$({},e,{type:"json"})).then(function(e){return lg.parse(n,e).then(function(n){var a,i,o=[],s=e.scene.ambient;if(s){var l=s.specularMode===ld.Custom,c=s.diffuseMode===i4.SphericalHarmonics;n.ambientLight.diffuseIntensity=s.diffuseIntensity,n.ambientLight.specularIntensity=s.specularIntensity,n.ambientLight.diffuseMode=s.diffuseMode,n.ambientLight.diffuseSolidColor.copyFrom(s.diffuseSolidColor),n.ambientLight.specularTextureDecodeRGBM=!0,l&&s.customAmbientLight&&o.push(t.getResourceByRef(s.customAmbientLight).then(function(e){n.ambientLight.specularTexture=null==e?void 0:e.specularTexture})),s.ambientLight&&(!l||c)&&o.push(t.getResourceByRef(s.ambientLight).then(function(e){l||(n.ambientLight.specularTexture=null==e?void 0:e.specularTexture),c&&(n.ambientLight.diffuseSphericalHarmonics=null==e?void 0:e.diffuseSphericalHarmonics)}))}var u=e.scene.background;switch(n.background.mode=u.mode,n.background.mode){case rO.SolidColor:n.background.solidColor.copyFrom(u.color);break;case rO.Sky:if(u.skyMesh&&u.skyMaterial){var d=t.getResourceByRef(u.skyMesh).then(function(e){n.background.sky.mesh=e}),h=t.getResourceByRef(u.skyMaterial).then(function(e){n.background.sky.material=e});o.push(d,h)}else no.warn("Sky background mode requires skyMesh and skyMaterial");break;case rO.Texture:if(u.texture){var _,f=t.getResourceByRef(u.texture).then(function(e){n.background.texture=e});o.push(f),n.background.textureFillMode=null!=(_=u.textureFillMode)?_:n.background.textureFillMode}}var p=e.scene.shadow;p&&(void 0!=p.castShadows&&(n.castShadows=p.castShadows),void 0!=p.shadowResolution&&(n.shadowResolution=p.shadowResolution),void 0!=p.shadowDistance&&(n.shadowDistance=p.shadowDistance),void 0!=p.shadowCascades&&(n.shadowCascades=p.shadowCascades),void 0!=p.enableTransparentShadow&&(n.enableTransparentShadow=p.enableTransparentShadow),n.shadowTwoCascadeSplits=null!=(a=p.shadowTwoCascadeSplits)?a:n.shadowTwoCascadeSplits,p.shadowFourCascadeSplits&&n.shadowFourCascadeSplits.copyFrom(p.shadowFourCascadeSplits),n.shadowFadeBorder=null!=(i=p.shadowFadeBorder)?i:n.shadowFadeBorder);var m=e.scene.fog;m&&(void 0!=m.fogMode&&(n.fogMode=m.fogMode),void 0!=m.fogStart&&(n.fogStart=m.fogStart),void 0!=m.fogEnd&&(n.fogEnd=m.fogEnd),void 0!=m.fogDensity&&(n.fogDensity=m.fogDensity),void 0!=m.fogColor&&n.fogColor.copyFrom(m.fogColor));var g=e.scene.postProcess;if(g){var v=n._postProcessManager,y=v._bloomEffect,x=v._tonemappingEffect;if(v.isActive=g.isActive,y.enabled=g.bloom.enabled,y.downScale=g.bloom.downScale,y.threshold=g.bloom.threshold,y.scatter=g.bloom.scatter,y.intensity=g.bloom.intensity,y.tint.copyFrom(g.bloom.tint),y.dirtIntensity=g.bloom.dirtIntensity,x.enabled=g.tonemapping.enabled,x.mode=g.tonemapping.mode,g.bloom.dirtTexture){var b=t.getResourceByRef(g.bloom.dirtTexture).then(function(e){y.dirtTexture=e});o.push(b)}}return Promise.all(o).then(function(){r(n)})})}).catch(a)})},t}(ol);cP=s3([it(a2.Scene,["scene"],!0)],cP),ll.registerCustomParseComponent("TextRenderer",/*#__PURE__*/lA(function(e,t){var n;return s4(this,function(r){return(n=t.props).font||(e.font=ng.createFromOS(e.engine,n.fontFamily||"Arial")),[2,e]})}));var cF=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r,a=e.glTF.extensions.KHR_lights_punctual.lights[n.light],i=a.color,o=a.intensity,s=a.type,l=a.range,c=a.spot,u=e.glTFResource;if("directional"===s?r=t.addComponent(i9):"point"===s?r=t.addComponent(i6):"spot"===s&&(r=t.addComponent(i7)),i&&r.color.set(i[0],i[1],i[2],1),r.intensity=void 0===o?1:o,l&&!lh(r,i9)&&(r.distance=l),c&&lh(r,i7)){var d=c.innerConeAngle,h=void 0===d?0:d,_=c.outerConeAngle,f=void 0===_?Math.PI/4:_;r.angle=h,r.penumbra=f-h}u.lights||(u.lights=[]),u.lights.push(r)},t}(ct);cF=s3([ca("KHR_lights_punctual",cn.AdditiveParse)],cF);var cL=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.clearcoatFactor,i=r.clearcoatTexture,o=r.clearcoatRoughnessFactor,s=r.clearcoatRoughnessTexture,l=r.clearcoatNormalTexture;n.clearCoat=void 0===a?0:a,n.clearCoatRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Clear coat"),t.get(lk.Texture,i.index).then(function(e){n.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(lk.Texture,s.index).then(function(e){n.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(lk.Texture,l.index).then(function(e){n.clearCoatNormalTexture=e}))},n}(ct);cL=s3([ca("KHR_materials_clearcoat",cn.AdditiveParse)],cL);var cD=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},t}(ct);cD=s3([ca("KHR_materials_ior",cn.AdditiveParse)],cD);var cB=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){var a=new ah(t.glTFResource.engine),i=n.diffuseFactor,o=n.diffuseTexture,s=n.specularFactor,l=n.glossinessFactor,c=n.specularGlossinessTexture;return i&&(a.baseColor=new tO(tO.linearToGammaSpace(i[0]),tO.linearToGammaSpace(i[1]),tO.linearToGammaSpace(i[2]),i[3])),o&&t.get(lk.Texture,o.index).then(function(e){a.baseTexture=e,cr.executeExtensionsAdditiveAndParse(o.extensions,t,a,o)}),s&&(a.specularColor=new tO(tO.linearToGammaSpace(s[0]),tO.linearToGammaSpace(s[1]),tO.linearToGammaSpace(s[2]))),void 0!==l&&(a.glossiness=l),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"Specular glossiness"),t.get(lk.Texture,c.index).then(function(e){a.specularGlossinessTexture=e})),a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(ct);cB=s3([ca("KHR_materials_pbrSpecularGlossiness",cn.CreateAndParse)],cB);var cI=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.sheenColorFactor,i=r.sheenColorTexture,o=r.sheenRoughnessFactor,s=r.sheenRoughnessTexture;a&&n.sheenColor.set(tO.linearToGammaSpace(a[0]),tO.linearToGammaSpace(a[1]),tO.linearToGammaSpace(a[2]),void 0),n.sheenRoughness=void 0===o?0:o,i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Sheen texture"),t.get(lk.Texture,i.index).then(function(e){n.sheenColorTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"SheenRoughness texture"),t.get(lk.Texture,s.index).then(function(e){n.sheenRoughnessTexture=e}))},n}(ct);cI=s3([ca("KHR_materials_sheen",cn.AdditiveParse)],cI);var cO=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){var a=new a_(t.glTFResource.engine);return a.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,a,r),a},n}(ct);cO=s3([ca("KHR_materials_unlit",cn.CreateAndParse)],cO);var cN=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=e.glTF.extensions.KHR_materials_variants.variants,a=e.glTFResource,i=n.mappings;a._extensionsData||(a._extensionsData={});var o=[];a.extensionsData.variants=o;for(var s=0;s<i.length;s++)!function(n){var a=i[n],s=a.material,l=a.variants;e.get(lk.Material,s).then(function(e){o.push({renderer:t,material:e,variants:l.map(function(e){return r[e].name})})})}(s)},t}(ct);cN=s3([ca("KHR_materials_variants",cn.AdditiveParse)],cN);var cV=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t}(ct);cV=s3([ca("KHR_mesh_quantization",cn.AdditiveParse)],cV);var ck=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.createAndParse=function(t,n,r){return lA(function(){var a,i,o,s,l,c,u,d,h,_,f,p,m,g,v,y;return s4(this,function(x){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=r.sampler,c=r.name,u=n.source,h=(d=a.images[u]).uri,_=d.bufferView,f=d.mimeType,p=d.name,m=void 0!==l&&lH.getSamplerInfo(a.samplers[l]),h)?(g=h.lastIndexOf("."),v=o.resourceManager.load({url:nT.resolveAbsoluteUrl(s,h),type:a2.KTX2}).onProgress(void 0,t._onTaskDetail).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&lH.parseSampler(e,m),e}),t._addTaskCompletePromise(v),[2,v]):(y=a.bufferViews[_],[2,t.get(lk.Buffer,y.buffer).then(function(n){var r=new Uint8Array(n,y.byteOffset,y.byteLength);return e.KTX2Loader._parseBuffer(r,o).then(function(t){var n=t.engine,r=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(n,r,a,i)}).then(function(e){e.name=c||p||"texture_"+_,void 0!==l&&lH.parseSampler(e,m);var n=new l4(e,y,f);return t.contentRestorer.bufferTextures.push(n),e})})])})})()},n}(ct);ck=s3([ca("KHR_texture_basisu",cn.CreateAndParse)],ck);var cz=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){var r=n.offset,a=n.rotation,i=n.scale,o=n.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),i&&(t.tilingOffset.x=i[0],t.tilingOffset.y=i[1]),a&&no.warn("rotation in KHR_texture_transform is not supported now"),o&&no.warn("texCoord in KHR_texture_transform is not supported now")},t}(ct);cz=s3([ca("KHR_texture_transform",cn.AdditiveParse)],cz);var cU=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.createAndParse=function(e,t){var n=e.glTFResource.engine.resourceManager.getResourceByRef(t);return e._addTaskCompletePromise(n),n},t}(ct);cU=s3([ca("GALACEAN_materials_remap",cn.CreateAndParse)],cU);var cG=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new og;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},t}(ct);cG=s3([ca("GALACEAN_animation_event",cn.AdditiveParse)],cG);var cH=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}return s1(t,e),t.prototype.createAndParse=function(e,t){return e.get(lk.Buffer,t.buffer).then(function(e){return ci().then(function(n){return n.decodeGltfBuffer(t.count,t.byteStride,new Uint8Array(e,t.byteOffset,t.byteLength),t.mode,t.filter)})})},t}(ct);cH=s3([ca("EXT_meshopt_compression",cn.CreateAndParse)],cH);var cW=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.anisotropyStrength,i=r.anisotropyRotation,o=r.anisotropyTexture;n.anisotropy=void 0===a?0:a,n.anisotropyRotation=void 0===i?0:i,o&&(e.GLTFMaterialParser._checkOtherTextureTransform(o,"Anisotropy texture"),t.get(lk.Texture,o.index).then(function(e){n.anisotropyTexture=e}))},n}(ct);cW=s3([ca("KHR_materials_anisotropy",cn.AdditiveParse)],cW);var cj=/*#__PURE__*/function(t){function n(){return t.apply(this,arguments)||this}return s1(n,t),n.prototype.additiveParse=function(t,n,r){var a=r.iridescenceFactor,i=r.iridescenceTexture,o=r.iridescenceIor,s=r.iridescenceThicknessMinimum,l=r.iridescenceThicknessMaximum,c=r.iridescenceThicknessTexture;n.iridescence=void 0===a?0:a,n.iridescenceIOR=void 0===o?1.3:o,n.iridescenceThicknessRange.set(void 0===s?100:s,void 0===l?400:l),i&&(e.GLTFMaterialParser._checkOtherTextureTransform(i,"Iridescence texture"),t.get(lk.Texture,i.index).then(function(e){n.iridescenceTexture=e})),c&&(e.GLTFMaterialParser._checkOtherTextureTransform(c,"IridescenceThickness texture"),t.get(lk.Texture,c.index).then(function(e){n.iridescenceThicknessTexture=e}))},n}(ct);cj=s3([ca("KHR_materials_iridescence",cn.AdditiveParse)],cj);var cX=/*#__PURE__*/function(t){function n(){var e;if((e=t.call(this)||this)._supportWebP=!1,id._isBrowser){var n=document.createElement("canvas");n.width=n.height=1,e._supportWebP=0==n.toDataURL("image/webp").indexOf("data:image/webp")}else e._supportWebP=!1;return e}return s1(n,t),n.prototype.createAndParse=function(t,n,r,a){var i=this;return lA(function(){var o,s,l,c,u;return s4(this,function(d){return o=n.source,s=r.sampler,c=void 0===(l=r.source)?0:l,u=r.name,[2,e.GLTFTextureParser._parseTexture(t,i._supportWebP?o:c,a,s,u)]})})()},n}(ct);cX=s3([ca("EXT_texture_webp",cn.CreateAndParse)],cX);var cK="1.4.0-alpha.1";for(var cY in console.log("Galacean engine version: "+cK),sF)ol.registerClass(cY,sF[cY]);e.AccessorType=lw,e.AmbientLight=i8,e.AnimationClip=ov,e.AnimationClipCurveBinding=om,e.AnimationCurve=ox,e.AnimationEvent=og,e.Animator=oD,e.AnimatorCondition=oR,e.AnimatorConditionMode=ob,e.AnimatorController=oI,e.AnimatorControllerLayer=oz,e.AnimatorControllerParameter=oB,e.AnimatorCullingMode=oC,e.AnimatorLayerBlendingMode=oS,e.AnimatorLayerMask=oH,e.AnimatorState=oV,e.AnimatorStateMachine=ok,e.AnimatorStateTransition=oM,e.AssetPromise=a8,e.AssetType=a2,e.AudioClip=sM,e.AudioManager=sw,e.AudioSource=sP,e.Background=i0,e.BackgroundMode=rO,e.BackgroundTextureFillMode=rN,e.BaseMaterial=as,e.BasicRenderPipeline=rZ,e.BlendFactor=nF,e.BlendMode=aa,e.BlendOperation=nL,e.BlendShape=am,e.BlendShapeFrame=af,e.BlendState=rt,e.BlinnPhongMaterial=al,e.BloomDownScaleMode=ot,e.BloomEffect=on,e.BoolUpdateFlag=rf,e.BoundingBox=tE,e.BoundingFrustum=tw,e.BoundingSphere=tA,e.BoxColliderShape=iI,e.BoxShape=s_,e.Buffer=r9,e.BufferBindFlag=an,e.BufferInfo=lV,e.BufferMesh=aT,e.BufferReader=s9,e.BufferUsage=r8,e.BufferUtil=ae,e.Burst=sc,e.CameraClearFlags=rw,e.CameraType=rP,e.Canvas=iZ,e.CapsuleColliderShape=iV,e.CharacterController=ig,e.CircleShape=sp,e.ClearableObjectPool=iq,e.CloneManager=t$,e.ColliderShape=iB,e.ColliderShapeUpAxis=iA,e.CollisionDetectionMode=iy,e.CollisionUtil=tR,e.Color=tO,e.ColorOverLifetimeModule=o5,e.ColorSpace=n2,e.ColorWriteMask=nD,e.CompareFunction=nB,e.Component=ru,e.ConeEmitType=sg,e.ConeShape=sm,e.ContainmentType=tv,e.ContentRestorer=t2,e.ControllerCollisionFlag=iE,e.ControllerNonWalkableMode=im,e.CubeProbe=sR,e.CullMode=nI,e.CurveKey=sr,e.DataType=nQ,e.DependentMode=r_,e.DepthState=rn,e.DepthTextureMode=rF,e.DiffuseMode=i4,e.DirectLight=i9,e.DisorderedArray=rC,e.Downsampling=rL,e.DynamicCollider=iv,e.DynamicColliderConstraints=ix,e.EmissionModule=o6,e.Engine=iJ,e.EngineObject=t0,e.Entity=aW,e.EventDispatcher=nK,e.FileHeader=le,e.FixedJoint=iM,e.FogMode=i3,e.Font=ng,e.FontStyle=n_,e.FrustumFace=tx,e.GLCapabilityType=nJ,e.GLCompressedTextureInternalFormat=sL,e.GLTFExtensionMode=cn,e.GLTFExtensionParser=ct,e.GLTFParser=cr,e.GLTFParserContext=lN,e.GLTFParserType=lk,e.GLTFResource=lR,e.GLTFUtils=lH,e.GradientAlphaKey=o3,e.GradientColorKey=o2,e.HemisphereShape=sv,e.HingeJoint=iP,e.HitResult=ib,e.IndexBufferBinding=ag,e.IndexFormat=r6,e.InputManager=iU,e.InterpolableValueType=lc,e.InterpolationType=oy,e.JointLimits=iL,e.JointMotor=iD,e.KTX2TargetFormat=lX,e.KTX2Transcoder=l1,e.Keyframe=oU,e.Keys=ih,e.Layer=rE,e.LayerPathMask=oG,e.Light=i5,e.Loader=ol,e.Logger=no,e.MSAASamples=rD,e.MainModule=se,e.Material=ao,e.MaterialLoaderType=lu,e.MathUtil=tS,e.Matrix=tL,e.Matrix3x3=tP,e.Mesh=ab,e.MeshRenderer=aA,e.MeshTopology=ar,e.ModelMesh=aM,e.OverflowMode=nf,e.PBRBaseMaterial=au,e.PBRMaterial=ad,e.PBRSpecularMaterial=ah,e.ParserContext=ls,e.ParserType=lo,e.ParticleCompositeCurve=o9,e.ParticleCompositeGradient=o4,e.ParticleCurve=sn,e.ParticleCurveMode=oZ,e.ParticleGenerator=ss,e.ParticleGradient=o1,e.ParticleGradientMode=o$,e.ParticleMaterial=sl,e.ParticleRenderMode=oK,e.ParticleRenderer=oQ,e.ParticleScaleMode=o7,e.ParticleShapeArcMode=sf,e.ParticleShapeType=sh,e.ParticleSimulationSpace=oY,e.ParticleStopMode=oq,e.PhysicsMaterial=iS,e.PhysicsMaterialCombineMode=iC,e.PhysicsScene=ip,e.PipelineStage=nX,e.Plane=tM,e.PlaneColliderShape=iN,e.PlaneIntersectionType=ty,e.Platform=tz,e.PointLight=i6,e.Pointer=is,e.PointerButton=il,e.PointerPhase=io,e.PrefabResource=lp,e.Primitive=ax,e.PrimitiveMesh=az,e.Probe=sS,e.Quaternion=tF,e.Rand=tk,e.RasterState=rr,e.Ray=tD,e.Rect=tN,e.ReferResource=t1,e.ReflectionParser=ll,e.RenderBufferDepthFormat=t3,e.RenderFace=ai,e.RenderQueue=rG,e.RenderQueueType=nN,e.RenderState=ri,e.RenderStateDataKey=nO,e.RenderTarget=nl,e.RenderTargetBlendState=re,e.ReplacementFailureStrategy=rB,e.ResourceManager=ie,e.ReturnableObjectPool=aQ,e.RotationOverLifetimeModule=st,e.SafeLoopArray=a3,e.Scene=oo,e.SceneManager=a4,e.SceneParser=lg,e.Script=os,e.SetDataOptions=r5,e.Shader=ro,e.ShaderData=rs,e.ShaderFactory=n$,e.ShaderLib=nZ,e.ShaderMacro=nH,e.ShaderMacroCollection=nW,e.ShaderPass=n6,e.ShaderPlatformTarget=nz,e.ShaderProperty=nY,e.ShaderPropertyType=nV,e.ShaderTagKey=n0,e.ShadowCascadesMode=rK,e.ShadowResolution=rW,e.ShadowType=rj,e.SizeOverLifetimeModule=sa,e.Skin=aj,e.SkinnedMeshRenderer=aK,e.Sky=i$,e.SkyBoxMaterial=oW,e.SkyProceduralMaterial=oX,e.SpecularMode=ld,e.SphereColliderShape=iO,e.SphereShape=sy,e.SphericalHarmonics3=tV,e.SpotLight=i7,e.SpringJoint=iF,e.Sprite=nP,e.SpriteAtlas=nb,e.SpriteDrawMode=nC,e.SpriteMask=r2,e.SpriteMaskInteraction=nv,e.SpriteMaskLayer=rg,e.SpriteRenderer=rT,e.SpriteTileMode=nS,e.StateMachineScript=oN,e.StaticCollider=iT,e.StencilOperation=nk,e.StencilState=ra,e.SubMesh=ay,e.SubPrimitive=av,e.SubShader=n7,e.SunMode=oj,e.SystemInfo=id,e.TextHorizontalAlignment=ny,e.TextRenderer=r3,e.TextUtils=np,e.TextVerticalAlignment=nx,e.Texture=ns,e.Texture2D=nc,e.Texture2DArray=nu,e.TextureCoordinate=ac,e.TextureCube=nd,e.TextureCubeFace=t4,e.TextureDepthCompareFunction=t8,e.TextureFilterMode=t5,e.TextureFormat=t9,e.TextureSheetAnimationModule=si,e.TextureUsage=t6,e.TextureWrapMode=t7,e.Time=nq,e.TonemappingEffect=oa,e.TonemappingMode=or,e.TrailMaterial=sx,e.TrailRenderer=sC,e.Transform=rp,e.UnlitMaterial=a_,e.Utils=nT,e.Vector2=tB,e.Vector3=tT,e.Vector4=tI,e.VelocityOverLifetimeModule=so,e.VertexAttribute=aR,e.VertexBufferBinding=aS,e.VertexElement=at,e.VertexElementFormat=r7,e.WebCanvas=sV,e.WebGLEngine=sk,e.WebGLGraphicDevice=sZ,e.WebGLMode=sJ,e.WrapMode=ow,e.XRManager=iQ,e._PostProcessManager=oi,e.assignmentClone=tQ,e.decode=lv,e.decoder=s7,e.decoderMap=s6,e.deepClone=tZ,e.dependentComponents=rh,e.ignoreClone=tq,e.parseSingleKTX=c_,e.registerGLTFExtension=ca,e.registerGLTFParser=lG,e.request=a6,e.resourceLoader=it,e.shallowClone=tJ,e.version=cK,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|