@galacean/engine 1.1.0-alpha.0 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +12594 -10078
- package/dist/browser.min.js +1 -1
- package/dist/main.js +1 -1
- package/dist/miniprogram.js +1 -1
- package/dist/module.js +1 -1
- package/package.json +5 -5
package/dist/browser.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Galacean={})}(this,function(e){"use strict";function t(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](e):e instanceof t}function n(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 r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}e.ContainmentType=void 0,(oQ=e.ContainmentType||(e.ContainmentType={}))[oQ.Disjoint=0]="Disjoint",oQ[oQ.Contains=1]="Contains",oQ[oQ.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(oJ=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[oJ.Back=0]="Back",oJ[oJ.Front=1]="Front",oJ[oJ.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(oZ=e.FrustumFace||(e.FrustumFace={}))[oZ.Near=0]="Near",oZ[oZ.Far=1]="Far",oZ[oZ.Left=2]="Left",oZ[oZ.Right=3]="Right",oZ[oZ.Bottom=4]="Bottom",oZ[oZ.Top=5]="Top";var i,a,o,s,l,c,u,h,d,_,f,p,g,m,v,y,x,T,C,S,A,w,E,M,b,F,R,P,L,D,I,B,N,V,O,U,z,k,G,H,W,X,K,j,q,Y,Q,J,Z,$,ee,et,en,er,ei,ea,eo,es,el,ec,eu,eh,ed,e_,ef,ep,eg,em,ev,ey,ex,eT,eC,eS,eA,ew,eE,eM,eb,eF,eR,eP,eL,eD,eI,eB,eN,eV,eO,eU,ez,ek,eG,eH,eW,eX,eK,ej,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e5,e8,e6,e7,e9,te,tt,tn,tr,ti,ta,to,ts,tl,tc,tu,th,td,t_,tf,tp,tg,tm,tv,ty,tx,tT,tC,tS,tA,tw,tE,tM,tb,tF,tR,tP,tL,tD,tI,tB,tN,tV,tO,tU,tz,tk,tG,tH,tW,tX,tK,tj,tq,tY,tQ,tJ,tZ,t$,t0,t1,t2,t3,t4,t5,t8,t6,t7,t9,ne,nt,nn,nr,ni,na,no,ns,nl,nc,nu,nh,nd,n_,nf,np,ng,nm,nv,ny,nx,nT,nC,nS,nA,nw,nE,nM,nb,nF,nR,nP,nL,nD,nI,nB,nN,nV,nO,nU,nz,nk,nG,nH,nW,nX,nK,nj,nq,nY,nQ,nJ,nZ,n$,n0,n1,n2,n3,n4,n5,n8,n6,n7,n9,re,rt,rn,rr,ri,ra,ro,rs,rl,rc,ru,rh,rd,r_,rf,rp,rg,rm,rv,ry,rx,rT,rC,rS,rA,rw,rE,rM,rb,rF,rR,rP,rL,rD,rI,rB,rN,rV,rO,rU,rz,rk,rG,rH,rW,rX,rK,rj,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ie,it,ir,ii,ia,io,is,il,ic,iu,ih,id,i_,ip,ig,im,iv,iy,ix,iT,iC,iS,iA,iw,iE,iM,ib,iF,iR,iP,iL,iD,iI,iB,iN,iV,iO,iU,iz,ik,iG,iH,iW,iX,iK,ij,iq,iY,iQ,iJ,iZ,i$,i0,i1,i2,i3,i4,i5,i8,i6,i7,i9,ae,at,an,ar,ai,aa,ao,as,al,ac,au,ah,ad,a_,af,ap,ag,am,av,ay,ax,aT,aC,aS,aA,aw,aE,aM,ab,aF,aR,aP,aL,aD,aI,aB,aN,aV,aO,aU,az,ak,aG,aH,aW,aX,aK,aj,aq,aY,aQ,aJ,aZ,a$,a0,a1,a2,a3,a4,a5,a8,a6,a7,a9,oe,ot,on,or,oi,oa,oo,os,ol,oc,ou,oh,od,o_,of,op,og,om,ov,oy,ox,oT,oC,oS,oA,ow,oE,oM,ob,oF,oR,oP,oL,oD,oI,oB,oN,oV,oO,oU,oz,ok,oG,oH,oW,oX,oK,oj,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st,sn,sr,si,sa,so,ss,sl,sc,su,sh,sd,s_,sf,sp,sg,sm,sv,sy,sx,sT,sC,sS,sA,sw,sE,sM,sb,sF,sR,sP,sL,sD,sI,sB,sN,sV=((o$=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},o$.equals=function(e,t){return Math.abs(e-t)<=o$.zeroTolerance},o$.isPowerOf2=function(e){return(e&e-1)==0},o$.radianToDegree=function(e){return e*o$.radToDegreeFactor},o$.degreeToRadian=function(e){return e*o$.degreeToRadFactor},o$);sV.zeroTolerance=1e-6,sV.radToDegreeFactor=180/Math.PI,sV.degreeToRadFactor=Math.PI/180;var sO=((a=(i=function(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}).prototype).set=function(e,t,n){return this._x=e,this._y=t,this._z=n,this._onValueChanged&&this._onValueChanged(),this},a.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._onValueChanged&&this._onValueChanged(),this},a.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._onValueChanged&&this._onValueChanged(),this},a.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._onValueChanged&&this._onValueChanged(),this},a.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._onValueChanged&&this._onValueChanged(),this},a.length=function(){var e=this._x,t=this._y,n=this._z;return Math.sqrt(e*e+t*t+n*n)},a.lengthSquared=function(){var e=this._x,t=this._y,n=this._z;return e*e+t*t+n*n},a.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},a.normalize=function(){return i.normalize(this,this),this},a.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},a.transformNormal=function(e){return i.transformNormal(this,e,this),this},a.transformToVec3=function(e){return i.transformToVec3(this,e,this),this},a.transformCoordinate=function(e){return i.transformCoordinate(this,e,this),this},a.transformByQuat=function(e){return i.transformByQuat(this,e,this),this},a.clone=function(){return new i(this._x,this._y,this._z)},a.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},a.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},a.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},a.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},i.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._onValueChanged&&n._onValueChanged()},i.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()},i.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()},i.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()},i.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},i.cross=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z;n.set(i*l-a*s,a*o-r*l,r*s-i*o)},i.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z;return Math.sqrt(n*n+r*r+i*i)},i.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z;return n*n+r*r+i*i},i.equals=function(e,t){return sV.equals(e._x,t._x)&&sV.equals(e._y,t._y)&&sV.equals(e._z,t._z)},i.lerp=function(e,t,n,r){var i=e._x,a=e._y,o=e._z;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._z=o+(t._z-o)*n,r._onValueChanged&&r._onValueChanged()},i.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()},i.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()},i.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._onValueChanged&&t._onValueChanged()},i.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=Math.sqrt(n*n+r*r+i*i);a>sV.zeroTolerance&&(a=1/a,t.set(n*a,r*a,i*a))},i.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._onValueChanged&&n._onValueChanged()},i.transformNormal=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8],n._y=r*o[1]+i*o[5]+a*o[9],n._z=r*o[2]+i*o[6]+a*o[10],n._onValueChanged&&n._onValueChanged()},i.transformToVec3=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8]+o[12],n._y=r*o[1]+i*o[5]+a*o[9]+o[13],n._z=r*o[2]+i*o[6]+a*o[10]+o[14],n._onValueChanged&&n._onValueChanged()},i.transformToVec4=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements;n._x=r*o[0]+i*o[4]+a*o[8]+o[12],n._y=r*o[1]+i*o[5]+a*o[9]+o[13],n._z=r*o[2]+i*o[6]+a*o[10]+o[14],n._w=r*o[3]+i*o[7]+a*o[11]+o[15],n._onValueChanged&&n._onValueChanged()},i.transformCoordinate=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t.elements,s=r*o[3]+i*o[7]+a*o[11]+o[15];s=1/s,n._x=(r*o[0]+i*o[4]+a*o[8]+o[12])*s,n._y=(r*o[1]+i*o[5]+a*o[9]+o[13])*s,n._z=(r*o[2]+i*o[6]+a*o[10]+o[14])*s,n._onValueChanged&&n._onValueChanged()},i.transformByQuat=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=t._x,s=t._y,l=t._z,c=t._w,u=c*r+s*a-l*i,h=c*i+l*r-o*a,d=c*a+o*i-s*r,_=-o*r-s*i-l*a;n._x=u*c-_*o-h*l+d*s,n._y=h*c-_*s-d*o+u*l,n._z=d*c-_*l-u*s+h*o,n._onValueChanged&&n._onValueChanged()},r(i,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}}]),i);sO._zero=new sO(0,0,0),sO._one=new sO(1,1,1);var sU=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sO,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 n=e.length,r=o._tempVec30;r.x=r.y=r.z=0;for(var i=0;i<n;++i)sO.add(e[i],r,r);sO.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sO.distanceSquared(r,e[s]);l>a&&(a=l)}t.radius=Math.sqrt(a)},o.fromBox=function(e,t){var n=t.center,r=e.min,i=e.max;n.x=(r.x+i.x)*.5,n.y=(r.y+i.y)*.5,n.z=(r.z+i.z)*.5,t.radius=sO.distance(n,i)},o);sU._tempVec30=new sO;var sz=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sO,this.max=new sO,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sO.add(this.min,this.max,e),sO.scale(e,.5,e),e},c.getExtent=function(e){return sO.subtract(this.max,this.min,e),sO.scale(e,.5,e),e},c.getCorners=function(e){void 0===e&&(e=[]);var t=this.min,n=this.max,r=t.x,i=t.y,a=t.z,o=n.x,s=n.y,l=n.z,c=e.length;if(c<8)for(var u=0,h=8-c;u<h;++u)e[c+u]=new sO;return e[0].set(r,s,l),e[1].set(o,s,l),e[2].set(o,i,l),e[3].set(r,i,l),e[4].set(r,s,a),e[5].set(o,s,a),e[6].set(o,i,a),e[7].set(r,i,a),e},c.transform=function(e){return l.transform(this,e,this),this},c.clone=function(){return new l(this.min,this.max)},c.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,n){sO.subtract(e,t,n.min),sO.add(e,t,n.max)},l.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 i=0,a=e.length;i<a;++i){var o=e[i];sO.min(n,o,n),sO.max(r,o,r)}},l.fromSphere=function(e,t){var n=e.center,r=e.radius,i=t.min,a=t.max;i.x=n.x-r,i.y=n.y-r,i.z=n.z-r,a.x=n.x+r,a.y=n.y+r,a.z=n.z+r},l.transform=function(e,t,n){var r=l._tempVec30,i=l._tempVec31;e.getCenter(r),e.getExtent(i),sO.transformCoordinate(r,t,r);var a=i.x,o=i.y,s=i.z,c=t.elements;i.x=Math.abs(a*c[0])+Math.abs(o*c[4])+Math.abs(s*c[8]),i.y=Math.abs(a*c[1])+Math.abs(o*c[5])+Math.abs(s*c[9]),i.z=Math.abs(a*c[2])+Math.abs(o*c[6])+Math.abs(s*c[10]),sO.subtract(r,i,n.min),sO.add(r,i,n.max)},l.merge=function(e,t,n){return sO.min(e.min,t.min,n.min),sO.max(e.max,t.max,n.max),n},l);sz._tempVec30=new sO,sz._tempVec31=new sO;var sk=((u=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sO.cross(a,o,u._tempVec30),sO.cross(o,i,u._tempVec31),sO.cross(i,a,u._tempVec32);var s=-sO.dot(i,u._tempVec30),l=-sO.dot(a,u._tempVec31),c=-sO.dot(o,u._tempVec32);sO.scale(u._tempVec30,e.distance/s,u._tempVec30),sO.scale(u._tempVec31,t.distance/l,u._tempVec31),sO.scale(u._tempVec32,n.distance/c,u._tempVec32),sO.add(u._tempVec30,u._tempVec31,r),sO.add(r,u._tempVec32,r)},u.distancePlaneAndPoint=function(e,t){return sO.dot(e.normal,t)+e.distance},u.intersectsPlaneAndPoint=function(t,n){var r=u.distancePlaneAndPoint(t,n);return r>0?e.PlaneIntersectionType.Front:r<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndBox=function(t,n){var r=n.min,i=n.max,a=t.normal,o=u._tempVec30,s=u._tempVec31;return(a.x>=0?(o.x=i.x,s.x=r.x):(o.x=r.x,s.x=i.x),a.y>=0?(o.y=i.y,s.y=r.y):(o.y=r.y,s.y=i.y),a.z>=0?(o.z=i.z,s.z=r.z):(o.z=r.z,s.z=i.z),0>u.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:u.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndSphere=function(t,n){var r=n.center,i=n.radius,a=u.distancePlaneAndPoint(t,r);return a>i?e.PlaneIntersectionType.Front:a<-i?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var n=t.normal,r=sV.zeroTolerance,i=sO.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sO.dot(n,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-r)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var n=sV.zeroTolerance,r=e.origin,i=e.direction,a=t.min,o=t.max,s=i.x,l=i.y,c=i.z,u=r.x,h=r.y,d=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){if(u<a.x||u>o.x)return -1}else{var p=1/s,g=(a.x-u)*p,m=(o.x-u)*p;if(g>m){var v=g;g=m,m=v}if((_=Math.max(g,_))>(f=Math.min(m,f)))return -1}if(Math.abs(l)<n){if(h<a.y||h>o.y)return -1}else{var y=1/l,x=(a.y-h)*y,T=(o.y-h)*y;if(x>T){var C=x;x=T,T=C}if((_=Math.max(x,_))>(f=Math.min(T,f)))return -1}if(Math.abs(c)<n){if(d<a.z||d>o.z)return -1}else{var S=1/c,A=(a.z-d)*S,w=(o.z-d)*S;if(A>w){var E=A;A=w,w=E}if((_=Math.max(A,_))>(f=Math.min(w,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var n=e.origin,r=e.direction,i=t.center,a=t.radius,o=u._tempVec30;sO.subtract(n,i,o);var s=sO.dot(o,r),l=sO.dot(o,o)-a*a;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var h=-s-Math.sqrt(c);return h<0&&(h=0),h},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 n=e.radius+t.radius;return sO.distanceSquared(e.center,t.center)<n*n},u.intersectsSphereAndBox=function(e,t){var n=e.center,r=t.max,i=t.min,a=u._tempVec30;return a.set(Math.max(i.x,Math.min(n.x,r.x)),Math.max(i.y,Math.min(n.y,r.y)),Math.max(i.z,Math.min(n.z,r.z))),sO.distanceSquared(n,a)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var n=t.min,r=t.max,i=u._tempVec30,a=0;a<6;++a){var o=e.getPlane(a),s=o.normal;if(i.set(s.x>=0?r.x:n.x,s.y>=0?r.y:n.y,s.z>=0?r.z:n.z),sO.dot(s,i)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,n){var r=u.distancePlaneAndPoint(t.near,n);return Math.abs(r)<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.far,n))<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.left,n))<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.right,n))<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.top,n))<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.bottom,n))<sV.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,n){for(var r=n.min,i=n.max,a=u._tempVec30,o=u._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),h=c.normal;if(h.x>=0?(a.x=i.x,o.x=r.x):(a.x=r.x,o.x=i.x),h.y>=0?(a.y=i.y,o.y=r.y):(a.y=r.y,o.y=i.y),h.z>=0?(a.z=i.z,o.z=r.z):(a.z=r.z,o.z=i.z),u.intersectsPlaneAndPoint(c,a)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;u.intersectsPlaneAndPoint(c,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},u.frustumContainsSphere=function(t,n){for(var r=e.ContainmentType.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=u.intersectsPlaneAndSphere(a,n);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){r=e.ContainmentType.Intersects;break}}return r},u);sk._tempVec30=new sO,sk._tempVec31=new sO,sk._tempVec32=new sO;var sG=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sO,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return h.normalize(this,this),this},d.clone=function(){var e=new h;return e.copyFrom(this),e},d.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},h.normalize=function(e,t){var n=e.normal,r=1/n.length();sO.scale(n,r,t.normal),t.distance=e.distance*r},h.fromPoints=function(e,t,n,r){var i=e.x,a=e.y,o=e.z,s=t.x-i,l=t.y-a,c=t.z-o,u=n.x-i,h=n.y-a,d=n.z-o,_=l*d-c*h,f=c*u-s*d,p=s*h-l*u,g=1/Math.sqrt(_*_+f*f+p*p),m=_*g,v=f*g,y=p*g,x=r.normal;x.x=m,x.y=v,x.z=y,r.distance=-(m*i+v*a+y*o)},h),sH=((f=(_=function(e){void 0===e&&(e=null),this.near=new sG,this.far=new sG,this.left=new sG,this.right=new sG,this.top=new sG,this.bottom=new sG,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,n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],_=t[11],f=t[12],p=t[13],g=t[14],m=t[15];this.near.normal.set(a+i,c+l,_+d),this.near.distance=m+g,this.near.normalize(),this.far.normal.set(a-i,c-l,_-d),this.far.distance=m-g,this.far.normalize(),this.left.normal.set(a+n,c+o,_+u),this.left.distance=m+f,this.left.normalize(),this.right.normal.set(a-n,c-o,_-u),this.right.distance=m-f,this.right.normalize(),this.bottom.normal.set(a+r,c+s,_+h),this.bottom.distance=m+p,this.bottom.normalize(),this.top.normal.set(a-r,c-s,_-h),this.top.distance=m-p,this.top.normalize()},f.intersectsBox=function(e){return sk.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return sk.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},_),sW=((g=(p=function(e,t,n,r,i,a,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===i&&(i=1),void 0===a&&(a=0),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=1),this.elements=new Float32Array(9);var c=this.elements;c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l}).prototype).set=function(e,t,n,r,i,a,o,s,l){var c=this.elements;return c[0]=e,c[1]=t,c[2]=n,c[3]=r,c[4]=i,c[5]=a,c[6]=o,c[7]=s,c[8]=l,this},g.add=function(e){return p.add(this,e,this),this},g.subtract=function(e){return p.subtract(this,e,this),this},g.multiply=function(e){return p.multiply(this,e,this),this},g.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8];return t*(c*a-o*l)+n*(-c*i+o*s)+r*(l*i-a*s)},g.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},g.invert=function(){return p.invert(this,this),this},g.rotate=function(e){return p.rotate(this,e,this),this},g.scale=function(e){return p.scale(this,e,this),this},g.translate=function(e){return p.translate(this,e,this),this},g.transpose=function(){return p.transpose(this,this),this},g.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])},g.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},g.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},g.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]},g.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},p.add=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements;a[0]=r[0]+i[0],a[1]=r[1]+i[1],a[2]=r[2]+i[2],a[3]=r[3]+i[3],a[4]=r[4]+i[4],a[5]=r[5]+i[5],a[6]=r[6]+i[6],a[7]=r[7]+i[7],a[8]=r[8]+i[8]},p.subtract=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements;a[0]=r[0]-i[0],a[1]=r[1]-i[1],a[2]=r[2]-i[2],a[3]=r[3]-i[3],a[4]=r[4]-i[4],a[5]=r[5]-i[5],a[6]=r[6]-i[6],a[7]=r[7]-i[7],a[8]=r[8]-i[8]},p.multiply=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],h=r[5],d=r[6],_=r[7],f=r[8],p=i[0],g=i[1],m=i[2],v=i[3],y=i[4],x=i[5],T=i[6],C=i[7],S=i[8];a[0]=o*p+c*g+d*m,a[1]=s*p+u*g+_*m,a[2]=l*p+h*g+f*m,a[3]=o*v+c*y+d*x,a[4]=s*v+u*y+_*x,a[5]=l*v+h*y+f*x,a[6]=o*T+c*C+d*S,a[7]=s*T+u*C+_*S,a[8]=l*T+h*C+f*S},p.equals=function(e,t){var n=e.elements,r=t.elements;return sV.equals(n[0],r[0])&&sV.equals(n[1],r[1])&&sV.equals(n[2],r[2])&&sV.equals(n[3],r[3])&&sV.equals(n[4],r[4])&&sV.equals(n[5],r[5])&&sV.equals(n[6],r[6])&&sV.equals(n[7],r[7])&&sV.equals(n[8],r[8])},p.lerp=function(e,t,n,r){var i=e.elements,a=t.elements,o=r.elements,s=1-n;o[0]=i[0]*s+a[0]*n,o[1]=i[1]*s+a[1]*n,o[2]=i[2]*s+a[2]*n,o[3]=i[3]*s+a[3]*n,o[4]=i[4]*s+a[4]*n,o[5]=i[5]*s+a[5]*n,o[6]=i[6]*s+a[6]*n,o[7]=i[7]*s+a[7]*n,o[8]=i[8]*s+a[8]*n},p.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,i=e._y,a=e._z,o=e._w,s=r+r,l=i+i,c=a+a,u=r*s,h=i*s,d=i*l,_=a*s,f=a*l,p=a*c,g=o*s,m=o*l,v=o*c;n[0]=1-d-p,n[3]=h-v,n[6]=_+m,n[1]=h+v,n[4]=1-u-p,n[7]=f-g,n[2]=_-m,n[5]=f+g,n[8]=1-u-d},p.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},p.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},p.invert=function(e,t){var n=e.elements,r=t.elements,i=n[0],a=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],h=n[7],d=n[8],_=d*l-c*h,f=-d*s+c*u,p=h*s-l*u,g=i*_+a*f+o*p;g&&(g=1/g,r[0]=_*g,r[1]=(-d*a+o*h)*g,r[2]=(c*a-o*l)*g,r[3]=f*g,r[4]=(d*i-o*u)*g,r[5]=(-c*i+o*s)*g,r[6]=p*g,r[7]=(-h*i+a*u)*g,r[8]=(l*i-a*s)*g)},p.normalMatrix=function(e,t){var n=e.elements,r=t.elements,i=n[0],a=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],h=n[7],d=n[8],_=n[9],f=n[10],p=n[11],g=n[12],m=n[13],v=n[14],y=n[15],x=i*c-a*l,T=i*u-o*l,C=i*h-s*l,S=a*u-o*c,A=a*h-s*c,w=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,F=_*v-f*m,R=_*y-p*m,P=f*y-p*v,L=x*P-T*R+C*F+S*b-A*M+w*E;if(!L)return null;L=1/L,r[0]=(c*P-u*R+h*F)*L,r[1]=(u*b-l*P-h*M)*L,r[2]=(l*R-c*b+h*E)*L,r[3]=(o*R-a*P-s*F)*L,r[4]=(i*P-o*b+s*M)*L,r[5]=(a*b-i*R-s*E)*L,r[6]=(m*w-v*A+y*S)*L,r[7]=(v*C-g*w-y*T)*L,r[8]=(g*A-m*C+y*x)*L},p.rotate=function(e,t,n){var r=e.elements,i=n.elements,a=Math.sin(t),o=Math.cos(t),s=r[0],l=r[1],c=r[2],u=r[3],h=r[4],d=r[5],_=r[6],f=r[7],p=r[8];i[0]=o*s+a*u,i[1]=o*l+a*h,i[2]=o*c+a*d,i[3]=o*u-a*s,i[4]=o*h-a*l,i[5]=o*d-a*c,i[6]=_,i[7]=f,i[8]=p},p.scale=function(e,t,n){var r=t._x,i=t._y,a=e.elements,o=n.elements;o[0]=r*a[0],o[1]=r*a[1],o[2]=r*a[2],o[3]=i*a[3],o[4]=i*a[4],o[5]=i*a[5],o[6]=a[6],o[7]=a[7],o[8]=a[8]},p.translate=function(e,t,n){var r=t._x,i=t._y,a=e.elements,o=n.elements,s=a[0],l=a[1],c=a[2],u=a[3],h=a[4],d=a[5],_=a[6],f=a[7],p=a[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=h,o[5]=d,o[6]=r*s+i*u+_,o[7]=r*l+i*h+f,o[8]=r*c+i*d+p},p.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var i=n[1],a=n[2],o=n[5];r[1]=n[3],r[2]=n[6],r[3]=i,r[5]=n[7],r[6]=a,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]},p),sX=((v=(m=function(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}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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,n=this._y,r=this._z,i=t*t+n*n+r*r;if(i<sV.zeroTolerance)return e._x=1,e._y=0,e._z=0,0;var a=1/i;return e._x=this._x*a,e._y=this._y*a,e._z=this._z*a,2*Math.acos(this._w)},v.identity=function(){return this._x=0,this._y=0,this._z=0,this._w=1,this._onValueChanged&&this._onValueChanged(),this},v.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},v.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},v.normalize=function(){return m.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 m.rotateX(this,e,this),this},v.rotateY=function(e){return m.rotateY(this,e,this),this},v.rotateZ=function(e){return m.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return m.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return m.multiply(this,e,this),this},v.invert=function(){return m.invert(this,this),this},v.dot=function(e){return m.dot(this,e)},v.lerp=function(e,t){return m.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return m._tempQuat1.rotationAxisAngle(e,t),this.multiply(m._tempQuat1),this},v.clone=function(){return new m(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,n=this._y,r=this._z,i=this._w,a=t*t,o=2*(t*i-n*r);e._y=Math.abs(o)>=1?Math.sign(o)*(Math.PI/2):Math.asin(o),e._x=Math.atan2(2*(r*t+n*i),1-2*(n*n+a)),e._z=Math.atan2(2*(t*n+r*i),1-2*(r*r+a))},m.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()},m.multiply=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w;n._x=r*u+o*s+i*c-a*l,n._y=i*u+o*l+a*s-r*c,n._z=a*u+o*c+r*l-i*s,n._w=o*u-r*s-i*l-a*c,n._onValueChanged&&n._onValueChanged()},m.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},m.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},m.equals=function(e,t){return sV.equals(e._x,t._x)&&sV.equals(e._y,t._y)&&sV.equals(e._z,t._z)&&sV.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sO.normalize(e,r);var i=Math.sin(t*=.5);n._x=r._x*i,n._y=r._y*i,n._z=r._z*i,n._w=Math.cos(t),n._onValueChanged&&n._onValueChanged()},m.rotationEuler=function(e,t,n,r){m.rotationYawPitchRoll(t,e,n,r)},m.rotationYawPitchRoll=function(e,t,n,r){var i=.5*n,a=.5*t,o=.5*e,s=Math.sin(i),l=Math.cos(i),c=Math.sin(a),u=Math.cos(a),h=Math.sin(o),d=Math.cos(o),_=d*u,f=h*c;r._x=d*c*l+h*u*s,r._y=h*u*l-d*c*s,r._z=_*s-f*l,r._w=_*l+f*s,r._onValueChanged&&r._onValueChanged()},m.rotationMatrix3x3=function(e,t){var n,r,i=e.elements,a=i[0],o=i[1],s=i[2],l=i[3],c=i[4],u=i[5],h=i[6],d=i[7],_=i[8],f=a+c+_;f>0?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(u-d)*n,t._y=(h-s)*n,t._z=(o-l)*n):a>=c&&a>=_?(r=.5/(n=Math.sqrt(1+a-c-_)),t._x=.5*n,t._y=(o+l)*r,t._z=(s+h)*r,t._w=(u-d)*r):c>_?(r=.5/(n=Math.sqrt(1+c-a-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(d+u)*r,t._w=(h-s)*r):(r=.5/(n=Math.sqrt(1+_-a-c)),t._x=(s+h)*r,t._y=(u+d)*r,t._z=.5*n,t._w=(o-l)*r),t._onValueChanged&&t._onValueChanged()},m.invert=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=n*n+r*r+i*i+a*a;if(o>sV.zeroTolerance){var s=1/o;t._x=-n*s,t._y=-r*s,t._z=-i*s,t._w=a*s,t._onValueChanged&&t._onValueChanged()}},m.lerp=function(e,t,n,r){var i=1-n;m.dot(e,t)>=0?(r._x=e._x*i+t._x*n,r._y=e._y*i+t._y*n,r._z=e._z*i+t._z*n,r._w=e._w*i+t._w*n):(r._x=e._x*i-t._x*n,r._y=e._y*i-t._y*n,r._z=e._z*i-t._z*n,r._w=e._w*i-t._w*n),r.normalize()},m.slerp=function(e,t,n,r){var i,a,o=m.dot(e,t);if(Math.abs(o)>1-sV.zeroTolerance)a=1-n,i=n*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);a=Math.sin((1-n)*s)*l,i=Math.sin(n*s)*l*Math.sign(o)}r.x=a*e.x+i*t.x,r.y=a*e.y+i*t.y,r.z=a*e.z+i*t.z,r.w=a*e.w+i*t.w,r._onValueChanged&&r._onValueChanged()},m.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>sV.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},m.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()},m.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()},m.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()},m.rotateX=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+o*s,n._y=i*l+a*s,n._z=a*l-i*s,n._w=o*l-r*s,n._onValueChanged&&n._onValueChanged()},m.rotateY=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l-a*s,n._y=i*l+o*s,n._z=a*l+r*s,n._w=o*l-i*s,n._onValueChanged&&n._onValueChanged()},m.rotateZ=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=Math.sin(t*=.5),l=Math.cos(t);n._x=r*l+i*s,n._y=i*l-r*s,n._z=a*l+o*s,n._w=o*l-a*s,n._onValueChanged&&n._onValueChanged()},m.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()},r(m,[{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)<sV.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);sX._tempVector3=new sO,sX._tempQuat1=new sX;var sK=((x=(y=function(e,t,n,r,i,a,o,s,l,c,u,h,d,_,f,p){void 0===e&&(e=1),void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===a&&(a=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===l&&(l=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===h&&(h=0),void 0===d&&(d=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var g=this.elements;g[0]=e,g[1]=t,g[2]=n,g[3]=r,g[4]=i,g[5]=a,g[6]=o,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=_,g[14]=f,g[15]=p}).prototype).set=function(e,t,n,r,i,a,o,s,l,c,u,h,d,_,f,p){var g=this.elements;return g[0]=e,g[1]=t,g[2]=n,g[3]=r,g[4]=i,g[5]=a,g[6]=o,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=_,g[14]=f,g[15]=p,this},x.multiply=function(e){return y.multiply(this,e,this),this},x.determinant=function(){var e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],_=e[12],f=e[13],p=e[14],g=e[15];return(t*o-n*a)*(h*g-d*p)-(t*s-r*a)*(u*g-d*f)+(t*l-i*a)*(u*p-h*f)+(n*s-r*o)*(c*g-d*_)-(n*l-i*o)*(c*p-h*_)+(r*l-i*s)*(c*f-u*_)},x.decompose=function(e,t,n){var r=y._tempMat30,i=this.elements,a=r.elements,o=i[0],s=i[1],l=i[2],c=i[3],u=i[4],h=i[5],d=i[6],_=i[7],f=i[8],p=i[9],g=i[10],m=i[11];e.set(i[12],i[13],i[14]);var v=(0>Math.sign(o*s*l*c)?-1:1)*Math.sqrt(o*o+s*s+l*l),x=(0>Math.sign(u*h*d*_)?-1:1)*Math.sqrt(u*u+h*h+d*d),T=(0>Math.sign(f*p*g*m)?-1:1)*Math.sqrt(f*f+p*p+g*g);if(n.set(v,x,T),Math.abs(v)<sV.zeroTolerance||Math.abs(x)<sV.zeroTolerance||Math.abs(T)<sV.zeroTolerance)return t.identity(),!1;var C=1/v,S=1/x,A=1/T;return a[0]=o*C,a[1]=s*C,a[2]=l*C,a[3]=u*S,a[4]=h*S,a[5]=d*S,a[6]=f*A,a[7]=p*A,a[8]=g*A,sX.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>sV.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 i=2*Math.sqrt(1+t[0]-t[5]-t[10]);e._w=(t[6]-t[9])/i,e._x=.25*i,e._y=(t[1]+t[4])/i,e._z=(t[8]+t[2])/i}else if(t[5]>t[10]){var a=2*Math.sqrt(1+t[5]-t[0]-t[10]);e._w=(t[8]-t[2])/a,e._x=(t[1]+t[4])/a,e._y=.25*a,e._z=(t[6]+t[9])/a}else{var o=2*Math.sqrt(1+t[10]-t[0]-t[5]);e._w=(t[1]-t[4])/o,e._x=(t[8]+t[2])/o,e._y=(t[6]+t[9])/o,e._z=.25*o}return e._onValueChanged&&e._onValueChanged(),e},x.getScaling=function(e){var t=this.elements,n=t[0],r=t[1],i=t[2],a=t[4],o=t[5],s=t[6],l=t[8],c=t[9],u=t[10];return e.set(Math.sqrt(n*n+r*r+i*i),Math.sqrt(a*a+o*o+s*s),Math.sqrt(l*l+c*c+u*u)),e},x.getTranslation=function(e){var t=this.elements;return e.set(t[12],t[13],t[14]),e},x.identity=function(){var e=this.elements;return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},x.invert=function(){return y.invert(this,this),this},x.rotateAxisAngle=function(e,t){return y.rotateAxisAngle(this,e,t,this),this},x.scale=function(e){return y.scale(this,e,this),this},x.translate=function(e){return y.translate(this,e,this),this},x.transpose=function(){return y.transpose(this,this),this},x.clone=function(){var e=this.elements;return new y(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15])},x.copyFrom=function(e){var t=this.elements,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},x.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},x.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]},y.multiply=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements,o=r[0],s=r[1],l=r[2],c=r[3],u=r[4],h=r[5],d=r[6],_=r[7],f=r[8],p=r[9],g=r[10],m=r[11],v=r[12],y=r[13],x=r[14],T=r[15],C=i[0],S=i[1],A=i[2],w=i[3],E=i[4],M=i[5],b=i[6],F=i[7],R=i[8],P=i[9],L=i[10],D=i[11],I=i[12],B=i[13],N=i[14],V=i[15];a[0]=o*C+u*S+f*A+v*w,a[1]=s*C+h*S+p*A+y*w,a[2]=l*C+d*S+g*A+x*w,a[3]=c*C+_*S+m*A+T*w,a[4]=o*E+u*M+f*b+v*F,a[5]=s*E+h*M+p*b+y*F,a[6]=l*E+d*M+g*b+x*F,a[7]=c*E+_*M+m*b+T*F,a[8]=o*R+u*P+f*L+v*D,a[9]=s*R+h*P+p*L+y*D,a[10]=l*R+d*P+g*L+x*D,a[11]=c*R+_*P+m*L+T*D,a[12]=o*I+u*B+f*N+v*V,a[13]=s*I+h*B+p*N+y*V,a[14]=l*I+d*B+g*N+x*V,a[15]=c*I+_*B+m*N+T*V},y.equals=function(e,t){var n=e.elements,r=t.elements;return sV.equals(n[0],r[0])&&sV.equals(n[1],r[1])&&sV.equals(n[2],r[2])&&sV.equals(n[3],r[3])&&sV.equals(n[4],r[4])&&sV.equals(n[5],r[5])&&sV.equals(n[6],r[6])&&sV.equals(n[7],r[7])&&sV.equals(n[8],r[8])&&sV.equals(n[9],r[9])&&sV.equals(n[10],r[10])&&sV.equals(n[11],r[11])&&sV.equals(n[12],r[12])&&sV.equals(n[13],r[13])&&sV.equals(n[14],r[14])&&sV.equals(n[15],r[15])},y.lerp=function(e,t,n,r){var i=e.elements,a=t.elements,o=r.elements,s=1-n;o[0]=i[0]*s+a[0]*n,o[1]=i[1]*s+a[1]*n,o[2]=i[2]*s+a[2]*n,o[3]=i[3]*s+a[3]*n,o[4]=i[4]*s+a[4]*n,o[5]=i[5]*s+a[5]*n,o[6]=i[6]*s+a[6]*n,o[7]=i[7]*s+a[7]*n,o[8]=i[8]*s+a[8]*n,o[9]=i[9]*s+a[9]*n,o[10]=i[10]*s+a[10]*n,o[11]=i[11]*s+a[11]*n,o[12]=i[12]*s+a[12]*n,o[13]=i[13]*s+a[13]*n,o[14]=i[14]*s+a[14]*n,o[15]=i[15]*s+a[15]*n},y.add=function(e,t,n){var r=e.elements,i=t.elements,a=n.elements;a[0]=r[0]+i[0],a[1]=r[1]+i[1],a[2]=r[2]+i[2],a[3]=r[3]+i[3],a[4]=r[4]+i[4],a[5]=r[5]+i[5],a[6]=r[6]+i[6],a[7]=r[7]+i[7],a[8]=r[8]+i[8],a[9]=r[9]+i[9],a[10]=r[10]+i[10],a[11]=r[11]+i[11],a[12]=r[12]+i[12],a[13]=r[13]+i[13],a[14]=r[14]+i[14],a[15]=r[15]+i[15]},y.multiplyScalar=function(e,t,n){var r=e.elements,i=n.elements;i[0]=r[0]*t,i[1]=r[1]*t,i[2]=r[2]*t,i[3]=r[3]*t,i[4]=r[4]*t,i[5]=r[5]*t,i[6]=r[6]*t,i[7]=r[7]*t,i[8]=r[8]*t,i[9]=r[9]*t,i[10]=r[10]*t,i[11]=r[11]*t,i[12]=r[12]*t,i[13]=r[13]*t,i[14]=r[14]*t,i[15]=r[15]*t},y.rotationQuaternion=function(e,t){var n=t.elements,r=e._x,i=e._y,a=e._z,o=e._w,s=r+r,l=i+i,c=a+a,u=r*s,h=i*s,d=i*l,_=a*s,f=a*l,p=a*c,g=o*s,m=o*l,v=o*c;n[0]=1-d-p,n[1]=h+v,n[2]=_-m,n[3]=0,n[4]=h-v,n[5]=1-u-p,n[6]=f+g,n[7]=0,n[8]=_+m,n[9]=f-g,n[10]=1-u-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},y.rotationAxisAngle=function(e,t,n){var r,i,a,o=n.elements,s=e._x,l=e._y,c=e._z,u=Math.sqrt(s*s+l*l+c*c);Math.abs(u)<sV.zeroTolerance||(s*=u=1/u,l*=u,c*=u,r=Math.sin(t),a=1-(i=Math.cos(t)),o[0]=s*s*a+i,o[1]=l*s*a+c*r,o[2]=c*s*a-l*r,o[3]=0,o[4]=s*l*a-c*r,o[5]=l*l*a+i,o[6]=c*l*a+s*r,o[7]=0,o[8]=s*c*a+l*r,o[9]=l*c*a-s*r,o[10]=c*c*a+i,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1)},y.rotationTranslation=function(e,t,n){y.rotationQuaternion(e,n);var r=n.elements;r[12]=t._x,r[13]=t._y,r[14]=t._z},y.affineTransformation=function(e,t,n,r){var i=r.elements,a=t._x,o=t._y,s=t._z,l=t._w,c=a+a,u=o+o,h=s+s,d=a*c,_=a*u,f=a*h,p=o*u,g=o*h,m=s*h,v=l*c,y=l*u,x=l*h,T=e._x,C=e._y,S=e._z;i[0]=(1-(p+m))*T,i[1]=(_+x)*T,i[2]=(f-y)*T,i[3]=0,i[4]=(_-x)*C,i[5]=(1-(d+m))*C,i[6]=(g+v)*C,i[7]=0,i[8]=(f+y)*S,i[9]=(g-v)*S,i[10]=(1-(d+p))*S,i[11]=0,i[12]=n._x,i[13]=n._y,i[14]=n._z,i[15]=1},y.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},y.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},y.invert=function(e,t){var n=e.elements,r=t.elements,i=n[0],a=n[1],o=n[2],s=n[3],l=n[4],c=n[5],u=n[6],h=n[7],d=n[8],_=n[9],f=n[10],p=n[11],g=n[12],m=n[13],v=n[14],y=n[15],x=i*c-a*l,T=i*u-o*l,C=i*h-s*l,S=a*u-o*c,A=a*h-s*c,w=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,F=_*v-f*m,R=_*y-p*m,P=f*y-p*v,L=x*P-T*R+C*F+S*b-A*M+w*E;if(!L)return null;L=1/L,r[0]=(c*P-u*R+h*F)*L,r[1]=(o*R-a*P-s*F)*L,r[2]=(m*w-v*A+y*S)*L,r[3]=(f*A-_*w-p*S)*L,r[4]=(u*b-l*P-h*M)*L,r[5]=(i*P-o*b+s*M)*L,r[6]=(v*C-g*w-y*T)*L,r[7]=(d*w-f*C+p*T)*L,r[8]=(l*R-c*b+h*E)*L,r[9]=(a*b-i*R-s*E)*L,r[10]=(g*A-m*C+y*x)*L,r[11]=(_*C-d*A-p*x)*L,r[12]=(c*M-l*F-u*E)*L,r[13]=(i*F-a*M+o*E)*L,r[14]=(m*T-g*S-v*x)*L,r[15]=(d*S-_*T+f*x)*L},y.lookAt=function(e,t,n,r){var i=r.elements,a=y._tempVec30,o=y._tempVec31,s=y._tempVec32;sO.subtract(e,t,s),s.normalize(),sO.cross(n,s,a),a.normalize(),sO.cross(s,a,o),i[0]=a._x,i[1]=o._x,i[2]=s._x,i[3]=0,i[4]=a._y,i[5]=o._y,i[6]=s._y,i[7]=0,i[8]=a._z,i[9]=o._z,i[10]=s._z,i[11]=0,i[12]=-sO.dot(a,e),i[13]=-sO.dot(o,e),i[14]=-sO.dot(s,e),i[15]=1},y.ortho=function(e,t,n,r,i,a,o){var s=o.elements,l=1/(e-t),c=1/(n-r),u=1/(i-a);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*u,s[11]=0,s[12]=(e+t)*l,s[13]=(r+n)*c,s[14]=(a+i)*u,s[15]=1},y.perspective=function(e,t,n,r,i){var a=i.elements,o=1/Math.tan(e/2),s=1/(n-r);a[0]=o/t,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(r+n)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*r*n*s,a[15]=0},y.rotateAxisAngle=function(e,t,n,r){var i,a,o,s=t._x,l=t._y,c=t._z,u=Math.sqrt(s*s+l*l+c*c);if(!(Math.abs(u)<sV.zeroTolerance)){var h=e.elements,d=r.elements;s*=u=1/u,l*=u,c*=u,i=Math.sin(n),o=1-(a=Math.cos(n));var _=h[0],f=h[1],p=h[2],g=h[3],m=h[4],v=h[5],y=h[6],x=h[7],T=h[8],C=h[9],S=h[10],A=h[11],w=s*s*o+a,E=l*s*o+c*i,M=c*s*o-l*i,b=s*l*o-c*i,F=l*l*o+a,R=c*l*o+s*i,P=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;d[0]=_*w+m*E+T*M,d[1]=f*w+v*E+C*M,d[2]=p*w+y*E+S*M,d[3]=g*w+x*E+A*M,d[4]=_*b+m*F+T*R,d[5]=f*b+v*F+C*R,d[6]=p*b+y*F+S*R,d[7]=g*b+x*F+A*R,d[8]=_*P+m*L+T*D,d[9]=f*P+v*L+C*D,d[10]=p*P+y*L+S*D,d[11]=g*P+x*L+A*D,e!==r&&(d[12]=h[12],d[13]=h[13],d[14]=h[14],d[15]=h[15])}},y.scale=function(e,t,n){var r=e.elements,i=n.elements,a=t._x,o=t._y,s=t._z;i[0]=r[0]*a,i[1]=r[1]*a,i[2]=r[2]*a,i[3]=r[3]*a,i[4]=r[4]*o,i[5]=r[5]*o,i[6]=r[6]*o,i[7]=r[7]*o,i[8]=r[8]*s,i[9]=r[9]*s,i[10]=r[10]*s,i[11]=r[11]*s,i[12]=r[12],i[13]=r[13],i[14]=r[14],i[15]=r[15]},y.translate=function(e,t,n){var r=e.elements,i=n.elements,a=t._x,o=t._y,s=t._z;if(e===n)i[12]=r[0]*a+r[4]*o+r[8]*s+r[12],i[13]=r[1]*a+r[5]*o+r[9]*s+r[13],i[14]=r[2]*a+r[6]*o+r[10]*s+r[14],i[15]=r[3]*a+r[7]*o+r[11]*s+r[15];else{var l=r[0],c=r[1],u=r[2],h=r[3],d=r[4],_=r[5],f=r[6],p=r[7],g=r[8],m=r[9],v=r[10],y=r[11];i[0]=l,i[1]=c,i[2]=u,i[3]=h,i[4]=d,i[5]=_,i[6]=f,i[7]=p,i[8]=g,i[9]=m,i[10]=v,i[11]=y,i[12]=l*a+d*o+g*s+r[12],i[13]=c*a+_*o+m*s+r[13],i[14]=u*a+f*o+v*s+r[14],i[15]=h*a+p*o+y*s+r[15]}},y.transpose=function(e,t){var n=e.elements,r=t.elements;if(t===e){var i=n[1],a=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]=i,r[6]=n[9],r[7]=n[13],r[8]=a,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]},y);sK._tempVec30=new sO,sK._tempVec31=new sO,sK._tempVec32=new sO,sK._tempMat30=new sW,sK._identity=new sK(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var sj=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sO,this.direction=new sO,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return sk.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return sk.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return sk.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return sO.scale(this.direction,e,t),t.add(this.origin)},T),sq=((A=(S=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this._onValueChanged=null,this._x=e,this._y=t}).prototype).set=function(e,t){return this._x=e,this._y=t,this._onValueChanged&&this._onValueChanged(),this},A.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},A.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},A.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},A.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},A.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},A.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},A.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},A.normalize=function(){return S.normalize(this,this),this},A.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},A.clone=function(){return new S(this._x,this._y)},A.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},A.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},A.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},A.toJSON=function(){return{x:this._x,y:this._y}},S.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._onValueChanged&&n._onValueChanged()},S.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._onValueChanged&&n._onValueChanged()},S.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._onValueChanged&&n._onValueChanged()},S.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._onValueChanged&&n._onValueChanged()},S.dot=function(e,t){return e._x*t._x+e._y*t._y},S.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y;return Math.sqrt(n*n+r*r)},S.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y;return n*n+r*r},S.equals=function(e,t){return sV.equals(e._x,t._x)&&sV.equals(e._y,t._y)},S.lerp=function(e,t,n,r){var i=e._x,a=e._y;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._onValueChanged&&r._onValueChanged()},S.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()},S.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()},S.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},S.normalize=function(e,t){var n=e._x,r=e._y,i=Math.sqrt(n*n+r*r);i>sV.zeroTolerance&&(i=1/i,t._x=n*i,t._y=r*i,t._onValueChanged&&t._onValueChanged())},S.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},r(S,[{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()}}]),S);sq._zero=new sq(0,0),sq._one=new sq(1,1);var sY=((E=(w=function(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}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},E.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},E.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},E.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},E.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},E.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},E.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},E.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},E.normalize=function(){return w.normalize(this,this),this},E.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new w(this._x,this._y,this._z,this._w)},E.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},E.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},E.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},E.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},w.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()},w.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()},w.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()},w.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()},w.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},w.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return Math.sqrt(n*n+r*r+i*i+a*a)},w.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y,i=t._z-e._z,a=t._w-e._w;return n*n+r*r+i*i+a*a},w.equals=function(e,t){return sV.equals(e._x,t._x)&&sV.equals(e._y,t._y)&&sV.equals(e._z,t._z)&&sV.equals(e._w,t._w)},w.lerp=function(e,t,n,r){var i=e._x,a=e._y,o=e._z,s=e._w;r._x=i+(t._x-i)*n,r._y=a+(t._y-a)*n,r._z=o+(t._z-o)*n,r._w=s+(t._w-s)*n,r._onValueChanged&&r._onValueChanged()},w.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()},w.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()},w.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},w.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>sV.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},w.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()},w.transform=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=t.elements;n._x=r*s[0]+i*s[4]+a*s[8]+o*s[12],n._y=r*s[1]+i*s[5]+a*s[9]+o*s[13],n._z=r*s[2]+i*s[6]+a*s[10]+o*s[14],n._w=r*s[3]+i*s[7]+a*s[11]+o*s[15],n._onValueChanged&&n._onValueChanged()},w.transformByQuat=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,c=t._z,u=t._w,h=u*r+l*a-c*i,d=u*i+c*r-s*a,_=u*a+s*i-l*r,f=-s*r-l*i-c*a;n._x=h*u-f*s-d*c+_*l,n._y=d*u-f*l-_*s+h*c,n._z=_*u-f*c-h*l+d*s,n._w=o,n._onValueChanged&&n._onValueChanged()},r(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:"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()}}]),w);sY._zero=new sY(0,0,0,0),sY._one=new sY(1,1,1,1);var sQ=((b=(M=function(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}).prototype).set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},b.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},b.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},b.clone=function(){return new M(this._r,this._g,this._b,this._a)},b.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},b.toLinear=function(e){return e._r=M.gammaToLinearSpace(this._r),e._g=M.gammaToLinearSpace(this._g),e._b=M.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},b.toGamma=function(e){return e._r=M.linearToGammaSpace(this._r),e._g=M.linearToGammaSpace(this._g),e._b=M.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},b.getBrightness=function(){var e=this.r,t=this.g,n=this.b,r=e,i=e;return t>r&&(r=t),n>r&&(r=n),t<i&&(i=t),n<i&&(i=n),(r+i)/2},b.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},M.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},M.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},M.equals=function(e,t){return sV.equals(e._r,t._r)&&sV.equals(e._g,t._g)&&sV.equals(e._b,t._b)&&sV.equals(e._a,t._a)},M.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},M.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()},M.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},M.lerp=function(e,t,n,r){var i=e._r,a=e._g,o=e._b,s=e._a;return r._r=i+(t._r-i)*n,r._g=a+(t._g-a)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},r(M,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),M),sJ=((R=(F=function(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.x=e,this.y=t,this.width=n,this.height=r}).prototype).set=function(e,t,n,r){return this.x=e,this.y=t,this.width=n,this.height=r,this},R.clone=function(){return new F(this.x,this.y,this.width,this.height)},R.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this},F),sZ=((L=(P=function(){this.coefficients=new Float32Array(27)}).prototype).addLight=function(e,t,n){t.scale(n);var r=this.coefficients,i=e._x,a=e._y,o=e._z,s=t.r,l=t.g,c=t.b,u=-.488603*a,h=.488603*o,d=-.488603*i,_=1.092548*(i*a),f=-1.092548*(a*o),p=.315392*(3*o*o-1),g=-1.092548*(i*o),m=.546274*(i*i-a*a);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*h,r[7]+=l*h,r[8]+=c*h,r[9]+=s*d,r[10]+=l*d,r[11]+=c*d,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*g,r[22]+=l*g,r[23]+=c*g,r[24]+=s*m,r[25]+=l*m,r[26]+=c*m},L.evaluate=function(e,t){var n=this.coefficients,r=e._x,i=e._y,a=e._z,o=-1.023327*i,s=1.023327*a,l=-1.023327*r,c=.858086*i*r,u=-.858086*i*a,h=.247708*(3*a*a-1),d=-.858086*a*r,_=.429042*(r*r-i*i),f=.886227*n[0],p=.886227*n[1],g=.886227*n[2];return f+=n[3]*o+n[6]*s+n[9]*l,p+=n[4]*o+n[7]*s+n[10]*l,g+=n[5]*o+n[8]*s+n[11]*l,f+=n[12]*c+n[15]*u+n[18]*h+n[21]*d+n[24]*_,p+=n[13]*c+n[16]*u+n[19]*h+n[22]*d+n[25]*_,g+=n[14]*c+n[17]*u+n[20]*h+n[23]*d+n[26]*_,t.set(f,p,g,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 P;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 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]},L.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]},P);function s$(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s0(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 s1(e,t,n){return t&&s0(e.prototype,t),n&&s0(e,n),e}function s2(e,t){return(s2=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s3(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&&s2(e,t)}e.Platform=void 0,(D=e.Platform||(e.Platform={}))[D.Android=0]="Android",D[D.IPhone=1]="IPhone",D[D.IPad=2]="IPad",D[D.Mac=3]="Mac",D[D.Unknown=4]="Unknown";var s4=((I=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},I.equals=function(e,t){return Math.abs(e-t)<=I.zeroTolerance},I.isPowerOf2=function(e){return(e&e-1)==0},I.radianToDegree=function(e){return e*I.radToDegreeFactor},I.degreeToRadian=function(e){return e*I.degreeToRadFactor},I);s4.zeroTolerance=1e-6,s4.radToDegreeFactor=180/Math.PI,s4.degreeToRadFactor=Math.PI/180;var s5=((N=(B=function(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}).prototype).set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},N.add=function(e){return this._r+=e._r,this._g+=e._g,this._b+=e._b,this._a+=e._a,this._onValueChanged&&this._onValueChanged(),this},N.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},N.clone=function(){return new B(this._r,this._g,this._b,this._a)},N.copyFrom=function(e){return this._r=e.r,this._g=e.g,this._b=e.b,this._a=e.a,this._onValueChanged&&this._onValueChanged(),this},N.toLinear=function(e){return e._r=B.gammaToLinearSpace(this._r),e._g=B.gammaToLinearSpace(this._g),e._b=B.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.toGamma=function(e){return e._r=B.linearToGammaSpace(this._r),e._g=B.linearToGammaSpace(this._g),e._b=B.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},N.getBrightness=function(){var e=this.r,t=this.g,n=this.b,r=e,i=e;return t>r&&(r=t),n>r&&(r=n),t<i&&(i=t),n<i&&(i=n),(r+i)/2},N.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},B.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)},B.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)},B.equals=function(e,t){return s4.equals(e._r,t._r)&&s4.equals(e._g,t._g)&&s4.equals(e._b,t._b)&&s4.equals(e._a,t._a)},B.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},B.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()},B.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},B.lerp=function(e,t,n,r){var i=e._r,a=e._g,o=e._b,s=e._a;return r._r=i+(t._r-i)*n,r._g=a+(t._g-a)*n,r._b=o+(t._b-o)*n,r._a=s+(t._a-s)*n,r._onValueChanged&&r._onValueChanged(),r},s1(B,[{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()}}]),B);function s8(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function s6(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function s7(e,t){ln.registerCloneMode(e,t,o0.Ignore)}function s9(e,t){ln.registerCloneMode(e,t,o0.Assignment)}function le(e,t){ln.registerCloneMode(e,t,o0.Shallow)}function lt(e,t){ln.registerCloneMode(e,t,o0.Deep)}(V=o0||(o0={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var ln=((O=function(){}).registerCloneMode=function(e,t,n){var r=O._subCloneModeMap.get(e.constructor);r||(r=Object.create(null),O._subCloneModeMap.set(e.constructor,r)),r[t]=n},O.getCloneMode=function(e){var t=O._cloneModeMap.get(e);if(!t){t=Object.create(null),O._cloneModeMap.set(e,t);for(var n=O._objectType,r=O._subCloneModeMap;e!==n;){var i=r.get(e);i&&Object.assign(t,i),e=Object.getPrototypeOf(e)}}return t},O.deepCloneObject=function(e,t){switch(e.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:t.set(e);break;case Array:for(var n=0,r=e.length;n<r;n++)O._deepCloneObjectItem(e,t,n);break;default:if(e.clone&&e.cloneTo)e.cloneTo(t);else for(var i=Object.keys(e),a=0,o=i.length;a<o;a++)O._deepCloneObjectItem(e,t,i[a])}},O._deepCloneObjectItem=function(e,t,n){var r=e[n];if(s6(r,Object))switch(r.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var i=t[n];null==i?t[n]=r.slice():i.set(r);break;case Array:var a=t[n];null==a?t[n]=Array(r.length):a.length=r.length,O.deepCloneObject(r,a);break;default:if(r.clone&&r.cloneTo){var o=t[n];o?r.cloneTo(o):t[n]=r.clone()}else{var s=t[n];null==s&&(t[n]=s=new r.constructor),O.deepCloneObject(r,s)}}else t[n]=r},O);ln._subCloneModeMap=new Map,ln._cloneModeMap=new Map,ln._objectType=Object.getPrototypeOf(Object);var lr=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)},s1(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();lr._instanceIdCounter=0,s8([s7],lr.prototype,"instanceId",void 0),s8([s7],lr.prototype,"_engine",void 0);var li=(s3(U=function(e){var t;return(t=lr.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(s$(t)),t},lr),(z=U.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(lr.prototype.destroy.call(this),!0)},z._getReferCount=function(){return this._refCount},z._addReferCount=function(e){this._refCount+=e},z._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},z._onDestroy=function(){lr.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},s1(U,[{key:"refCount",get:function(){return this._refCount}}]),U),la=function(e){this.resource=e};e.RenderBufferDepthFormat=void 0,(k=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[k.Depth=0]="Depth",k[k.DepthStencil=1]="DepthStencil",k[k.Stencil=2]="Stencil",k[k.Depth16=3]="Depth16",k[k.Depth24=4]="Depth24",k[k.Depth32=5]="Depth32",k[k.Depth24Stencil8=6]="Depth24Stencil8",k[k.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(G=e.TextureCubeFace||(e.TextureCubeFace={}))[G.PositiveX=0]="PositiveX",G[G.NegativeX=1]="NegativeX",G[G.PositiveY=2]="PositiveY",G[G.NegativeY=3]="NegativeY",G[G.PositiveZ=4]="PositiveZ",G[G.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(H=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[H.Never=0]="Never",H[H.Less=1]="Less",H[H.Equal=2]="Equal",H[H.LessEqual=3]="LessEqual",H[H.Greater=4]="Greater",H[H.NotEqual=5]="NotEqual",H[H.GreaterEqual=6]="GreaterEqual",H[H.Always=7]="Always",e.TextureFilterMode=void 0,(W=e.TextureFilterMode||(e.TextureFilterMode={}))[W.Point=0]="Point",W[W.Bilinear=1]="Bilinear",W[W.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(X=e.TextureFormat||(e.TextureFormat={}))[X.R8G8B8=0]="R8G8B8",X[X.R8G8B8A8=1]="R8G8B8A8",X[X.R4G4B4A4=2]="R4G4B4A4",X[X.R5G5B5A1=3]="R5G5B5A1",X[X.R5G6B5=4]="R5G6B5",X[X.Alpha8=5]="Alpha8",X[X.LuminanceAlpha=6]="LuminanceAlpha",X[X.R16G16B16A16=7]="R16G16B16A16",X[X.R32G32B32A32=8]="R32G32B32A32",X[X.DXT1=9]="DXT1",X[X.DXT5=10]="DXT5",X[X.ETC1_RGB=11]="ETC1_RGB",X[X.ETC2_RGB=12]="ETC2_RGB",X[X.ETC2_RGBA5=13]="ETC2_RGBA5",X[X.ETC2_RGBA8=14]="ETC2_RGBA8",X[X.PVRTC_RGB2=15]="PVRTC_RGB2",X[X.PVRTC_RGBA2=16]="PVRTC_RGBA2",X[X.PVRTC_RGB4=17]="PVRTC_RGB4",X[X.PVRTC_RGBA4=18]="PVRTC_RGBA4",X[X.ASTC_4x4=19]="ASTC_4x4",X[X.ASTC_5x5=20]="ASTC_5x5",X[X.ASTC_6x6=21]="ASTC_6x6",X[X.ASTC_8x8=22]="ASTC_8x8",X[X.ASTC_10x10=23]="ASTC_10x10",X[X.ASTC_12x12=24]="ASTC_12x12",X[X.Depth=25]="Depth",X[X.DepthStencil=26]="DepthStencil",X[X.Depth16=27]="Depth16",X[X.Depth24=28]="Depth24",X[X.Depth32=29]="Depth32",X[X.Depth24Stencil8=30]="Depth24Stencil8",X[X.Depth32Stencil8=31]="Depth32Stencil8",e.TextureWrapMode=void 0,(K=e.TextureWrapMode||(e.TextureWrapMode={}))[K.Clamp=0]="Clamp",K[K.Repeat=1]="Repeat",K[K.Mirror=2]="Mirror";var lo=(s3(j=function(e){var t;return t=li.call(this,e)||this,e.resourceManager._addGraphicResource(s$(t)),t},li),j.prototype._onDestroy=function(){li.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},j),ls=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},ll=console.log.bind(console),lc=console.info.bind(console),lu=console.warn.bind(console),lh=console.error.bind(console),ld={debug:ls,info:ls,warn:ls,error:ls,isEnabled:!1,enable:function(){this.debug=ll,this.info=lc,this.warn=lu,this.error=lh,this.isEnabled=!0},disable:function(){this.debug=ls,this.info=ls,this.warn=ls,this.error=ls,this.isEnabled=!1}},l_=(s3(q=function(){var e;return e=lo.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},lo),(Y=q.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},Y._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},Y._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode)},Y._onDestroy=function(){lo.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},Y._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},Y._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},s1(q,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){e!==this._filterMode&&(this._filterMode=e,this._platformTexture.filterMode=e)}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(ld.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(ld.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)}}]),q),lf=(s3(Q=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=lo.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=s6(i,Array)?i.slice():[i],c=0,u=l.length;c<u;c++)if(l[c]._isDepthTexture)throw"Render texture can't use depth format.";s._colorTextures=l}else s._colorTextures=[];if(s6(a,l_)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s$(s)),s},lo),(J=Q.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},J.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()}},J._onDestroy=function(){lo.prototype._onDestroy.call(this),this._platformRenderTarget.destroy(),this._colorTextures.length=0,this._depthTexture=null,this._depth=null},J._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t)},J._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},J._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},s1(Q,[{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}}]),Q),lp=(s3(Z=function(t,n,r,i,a){var o;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(o=l_.call(this,t)||this)._mipmap=a,o._width=n,o._height=r,o._format=i,o._mipmapCount=o._getMipmapCount(),o._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,o._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s$(o)),o.filterMode=e.TextureFilterMode.Bilinear,o.wrapModeU=o.wrapModeV=e.TextureWrapMode.Repeat,o},l_),($=Z.prototype).setPixelBuffer=function(e,t,n,r,i,a){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a)},$.setImageSource=function(e,t,n,r,i,a){void 0===t&&(t=0),void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===i&&(i=0),void 0===a&&(a=0),this._platformTexture.setImageSource(e,t,n,r,i,a)},$.getPixelBuffer=function(e,t,n,r,i,a){var o=arguments.length;1===o?this._platformTexture.getPixelBuffer(0,0,this._width,this._height,0,e):2===o?this._platformTexture.getPixelBuffer(0,0,this._width>>e,this._height>>e,e,t):5===o?this._platformTexture.getPixelBuffer(e,t,n,r,0,i):6===o&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a)},$._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),l_.prototype._rebuild.call(this)},Z),lg=(s3(ee=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=l_.call(this,t)||this)._mipmap=o,s._width=n,s._height=r,s._length=i,s._format=a,s._mipmapCount=s._getMipmapCount(),s._platformTexture=t._hardwareRenderer.createPlatformTexture2DArray(s$(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},l_),(et=ee.prototype).setPixelBuffer=function(e,t,n,r,i,a,o,s){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a,o,s)},et.setImageSource=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,i,a,o)},et.getPixelBuffer=function(e,t,n,r,i,a,o){var s=arguments.length;1===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):5===s?this._platformTexture.getPixelBuffer(e,t,n,r,i,0,a):6===s&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a,o)},et._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),l_.prototype._rebuild.call(this)},s1(ee,[{key:"length",get:function(){return this._length}}]),ee),lm=(s3(en=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=l_.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(s$(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},l_),(er=en.prototype).setPixelBuffer=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=0),this._platformTexture.setPixelBuffer(e,t,n,r,i,a,o)},er.setImageSource=function(e,t,n,r,i,a,o){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===i&&(i=!1),void 0===a&&(a=0),void 0===o&&(o=0),this._platformTexture.setImageSource(e,t,n,r,i,a,o)},er.getPixelBuffer=function(e,t,n,r,i,a,o){var s=arguments.length;2===s?this._platformTexture.getPixelBuffer(e,0,0,this._width,this._height,0,t):3===s?this._platformTexture.getPixelBuffer(e,0,0,this._width>>t,this._height>>t,t,n):6===s?this._platformTexture.getPixelBuffer(e,t,n,r,i,0,a):7===s&&this._platformTexture.getPixelBuffer(e,t,n,r,i,a,o)},er._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),l_.prototype._rebuild.call(this)},en),lv=(s3(ei=function(e){var t;return(t=li.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},li),(ea=ei.prototype).uploadCharTexture=function(e){var t=e.w,n=e.h,r=e.data,i=this._space,a=this.texture,o=a.width,s=t+i,l=n+i;if(1+s>=o||1+l>=o)throw Error("The char fontSize is too large.");this._curX+s>=o&&(this._curX=i,this._curY=this._nextY+i);var c=this._curY+l;if(c>this._nextY&&(this._nextY=c),c>=o)return!1;t>0&&n>0&&r&&(e.bufferOffset=new sq(this._curX,this._curY),a.setPixelBuffer(r,0,this._curX,this._curY,t,n),a.generateMipmaps());var u=1/o,h=this._curX,d=this._curY,_=h*u,f=(h+t)*u,p=d*u,g=(d+n)*u;e.x=h,e.y=d;var m=e.uvs;return m[0].set(_,p),m[1].set(f,p),m[2].set(f,g),m[3].set(_,g),this._curX+=s+i,!0},ea.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},ea.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},ea._onDestroy=function(){li.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},ei);e.FontStyle=void 0,(eo=e.FontStyle||(e.FontStyle={}))[eo.None=0]="None",eo[eo.Bold=1]="Bold",eo[eo.Italic=2]="Italic",e.OverflowMode=void 0,(es=e.OverflowMode||(e.OverflowMode={}))[es.Overflow=0]="Overflow",es[es.Truncate=1]="Truncate";var ly=((el=function(){}).textContext=function(){var e=el._textContext;if(!e){try{t=new OffscreenCanvas(0,0)}catch(e){t=document.createElement("canvas")}var t,n=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,context:n},el._textContext=e}return e},el.measureFont=function(e){var t=el._fontSizeInfoCache,n=t[e];return n||(n=el._measureFontOrChar(e),t[e]=n),n},el.getNativeFontString=function(t,n,r){var i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=el._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},el.measureChar=function(e,t){return el._measureFontOrChar(t,e)},el.measureTextWithWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=el.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=us._pixelsPerUnit,u=i.size+t.lineSpacing*c,h=t.width*c,d=0;n.nativeFontString=r;for(var _=0,f=a.length;_<f;_++){for(var p=a[_],g="",m=0,v=0,y=0,x="",T=0,C=0,S=0,A=!1,w=0,E=p.length;w<E;++w){var M=p[w],b=el._getCharInfo(M,r,n),F=M.charCodeAt(0),R=32===F;if(!R||!A||0!==x.length||0!==g.length){var P=R||F>=19968&&F<=40959,L=b.w,D=b.offsetY,I=.5*b.h,B=I+D,N=I-D;P?(g.length>0&&(T+m>h?(this._pushLine(o,s,l,x,T,C,S),d=Math.max(d,T),A=!0,x=g,T=m,C=v,S=y):(x+=g,T+=m,C=Math.max(C,v),S=Math.max(S,y)),g="",m=v=y=0),T+L>h&&T>0?(this._pushLine(o,s,l,x,T,C,S),d=Math.max(d,T),A=!0,R?(x="",T=C=S=0):(x=M,T=b.xAdvance,C=B,S=N)):(x+=M,T+=b.xAdvance,C=Math.max(C,B),S=Math.max(S,N))):m+b.w>h?(T>0&&(this._pushLine(o,s,l,x,T,C,S),d=Math.max(d,T),x="",T=C=S=0),this._pushLine(o,s,l,g,m,v,y),d=Math.max(d,m),A=!0,g=M,m=b.xAdvance,v=B,y=N):(g+=M,m+=b.xAdvance,v=C=Math.max(v,B),y=S=Math.max(y,N))}}m>0&&(T+m>h?(this._pushLine(o,s,l,x,T,C,S),d=Math.max(d,T),T=0,this._pushLine(o,s,l,g,m,v,y),d=Math.max(d,m)):(x+=g,T+=m,C=Math.max(C,v),S=Math.max(S,y))),T>0&&(this._pushLine(o,s,l,x,T,C,S),d=Math.max(d,T))}var V=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(V=u*o.length),{width:d,height:V,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},el.measureTextWithoutWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=el.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=us._pixelsPerUnit,u=i.size+t.lineSpacing*c,h=0,d=t.height*c;t.overflowMode===e.OverflowMode.Overflow&&(d=u*o),n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=a[_],p=0,g=-1,m=-1,v=0,y=f.length;v<y;++v){var x=el._getCharInfo(f[v],r,n);p+=x.xAdvance;var T=x.offsetY,C=.5*x.h,S=C+T,A=C-T;g<S&&(g=S),m<A&&(m=A)}s[_]=p,l[_]={ascent:g,descent:m,size:g+m},p>h&&(h=p)}return{width:h,height:d,lines:a,lineWidths:s,lineHeight:u,lineMaxSizes:l}},el.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=el._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},el._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=el.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||el._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(el._measureBaseline).width),c=l*el._heightMultiplier;l=el._baselineMultiplier*l|0,i.width=s,i.height=c,a.font=e,a.fillStyle="#000",a.clearRect(0,0,s,c),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var u=a.getImageData(0,0,s,c).data,h=u.length,d=-1,_=-1,f=0,p=0,g=0,m=i.width,v=1/m,y=0;y<h;y+=4)0!==u[y+3]?(n=~~(.25*y*v),-1===d&&(d=n),n>_&&(_=n)):u[y]=u[y+1]=u[y+2]=255;-1!==d&&-1!==_&&(g=(f=l-d)+(p=_-l+1));var x={ascent:f,descent:p,size:g};if(!t)return x;var T=null;if(g>0){var C=4*m;T=new Uint8Array(u.buffer,d*C,g*C)}return{char:t,x:0,y:0,w:s,h:g,offsetX:0,offsetY:(f-p)*.5,xAdvance:s,uvs:[new sq,new sq,new sq,new sq],ascent:f,descent:p,index:0,data:T}},el._getCharInfo=function(e,t,n){var r=n._getCharInfo(e);return r||(r=el.measureChar(e,t),n._uploadCharTexture(r),n._addCharInfo(e,r)),r},el._pushLine=function(e,t,n,r,i,a,o){e.push(r),t.push(i),n.push({ascent:a,descent:o,size:a+o})},el);ly._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],ly._measureString="|\xc9q\xc5",ly._measureBaseline="M",ly._heightMultiplier=2,ly._baselineMultiplier=1.4,ly._fontSizeInfoCache={},ly._textContext=null;var lx=((eu=(ec=function(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}).prototype).destroy=function(){for(var e=this._fontAtlases,t=0,n=e.length;t<n;++t)e[t].destroy(!0);e.length=0},eu._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},eu._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},eu._getCharInfo=function(e){for(var t=this._fontAtlases,n=0,r=t.length;n<r;++n){var i=t[n].getCharInfo(e);if(i)return i}return null},eu._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},eu._getLastIndex=function(){return this._lastIndex},eu._createFontAtlas=function(){var e,t=this._engine,n=new lv(t),r=new lp(t,256,256);n.texture=r,this._fontAtlases.push(n);var i=this.nativeFontString;return t.resourceManager.addContentRestorer(new(s3(e=function(){return la.call(this,n)},la),e.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var r in t){var a=t[r],o=ly.measureChar(a.char,i).data;if(a.w>0&&a.h>0&&o){var s=a.bufferOffset;n.setPixelBuffer(o,0,s.x,s.y,a.w,a.h)}}n.generateMipmaps()},e)),n},ec),lT=(s3(eh=function(e,t){var n;return void 0===t&&(t=""),(n=li.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},li),(ed=eh.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new lx(this.engine),r[n]=i),i},ed._onDestroy=function(){li.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]},eh.createFromOS=function(e,t){if(t){var n=e._fontMap,r=n[t];return r||(r=new eh(e,t),n[t]=r),r}return null},s1(eh,[{key:"name",get:function(){return this._name}}]),eh),lC=((ef=(e_=function(){this._events=Object.create(null),this._eventCount=0,this._dispatchingListeners=[]}).prototype).hasEvent=function(e){return null!=this._events[e]},ef.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ef.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ef.dispatch=function(e,t){if(!this._events[e])return!1;var n=this._events[e];if(Array.isArray(n)){var r=n.length,i=this._dispatchingListeners;i.length=r;for(var a=0;a<r;a++)i[a]=n[a];for(var o=0;o<r;o++){var s=i[o];s.destroyed||(s.once&&this.off(e,s.fn),s.fn(t))}i.length=0}else n.once&&this.off(e,n.fn),n.fn(t);return!0},ef.on=function(e,t){return this._addEventListener(e,t)},ef.once=function(e,t){return this._addEventListener(e,t,!0)},ef.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 i=n.length-1;i>=0;i--)n[i].fn===t&&(n[i].destroyed=!0,n.splice(i,1));0===n.length?this._clearEvent(e):1===n.length&&(this._events[e]=n[0])}}else this._clearEvent(e);return this},ef.removeEventListener=function(e,t){return this.off(e,t)},ef.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ef._addEventListener=function(e,t,n){var r={fn:t,once:n},i=this._events,a=i[e];return a?Array.isArray(a)?a.push(r):i[e]=[a,r]:(i[e]=r,this._eventCount++),this},ef._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},e_),lS=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},s1(e,[{key:"type",get:function(){return this._type}}]),e}();lS._propertyIdMap=Object.create(null),lS._propertyNameCounter=0,lS._propertyNameMap=Object.create(null);var lA=((eg=(ep=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new sY,this._deltaTimeValue=new sY,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},eg._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},eg._updateSceneShaderData=function(e){var t=this._elapsedTimeValue,n=this._deltaTimeValue,r=this._elapsedTime;t.set(r,Math.sin(r),Math.cos(r),0),e.setVector4(ep._elapsedTimeProperty,t),n.set(this._deltaTime,0,0,0),e.setVector4(ep._deltaTimeProperty,n)},s1(ep,[{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}}]),ep);lA._elapsedTimeProperty=lS.getByName("scene_ElapsedTime"),lA._deltaTimeProperty=lS.getByName("scene_DeltaTime"),e.DataType=void 0,(em=e.DataType||(e.DataType={}))[em.FLOAT=5126]="FLOAT",em[em.FLOAT_VEC2=35664]="FLOAT_VEC2",em[em.FLOAT_VEC3=35665]="FLOAT_VEC3",em[em.FLOAT_VEC4=35666]="FLOAT_VEC4",em[em.INT=5124]="INT",em[em.INT_VEC2=35667]="INT_VEC2",em[em.INT_VEC3=35668]="INT_VEC3",em[em.INT_VEC4=35669]="INT_VEC4",em[em.BOOL=35670]="BOOL",em[em.BOOL_VEC2=35671]="BOOL_VEC2",em[em.BOOL_VEC3=35672]="BOOL_VEC3",em[em.BOOL_VEC4=35673]="BOOL_VEC4",em[em.FLOAT_MAT2=35674]="FLOAT_MAT2",em[em.FLOAT_MAT3=35675]="FLOAT_MAT3",em[em.FLOAT_MAT4=35676]="FLOAT_MAT4",em[em.FLOAT_ARRAY=35677]="FLOAT_ARRAY",em[em.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",em[em.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",em[em.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",em[em.INT_ARRAY=100003]="INT_ARRAY",em[em.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",em[em.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",em[em.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",em[em.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",em[em.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",em[em.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",em[em.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",em[em.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",em[em.SAMPLER_2D=35678]="SAMPLER_2D",em[em.SAMPLER_CUBE=35680]="SAMPLER_CUBE",em[em.BYTE=5120]="BYTE",em[em.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",em[em.SHORT=5122]="SHORT",em[em.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",em[em.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(ev=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",ev.standardDerivatives="OES_standard_derivatives",ev.shaderTextureLod="EXT_shader_texture_lod",ev.elementIndexUint="OES_element_index_uint",ev.depthTexture="WEBGL_depth_texture",ev.drawBuffers="WEBGL_draw_buffers",ev.vertexArrayObject="OES_vertex_array_object",ev.instancedArrays="ANGLE_instanced_arrays",ev.multipleSample="multipleSampleOnlySupportedInWebGL2",ev.textureFloat="OES_texture_float",ev.textureFloatLinear="OES_texture_float_linear",ev.textureHalfFloat="OES_texture_half_float",ev.textureHalfFloatLinear="OES_texture_half_float_linear",ev.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",ev.colorBufferFloat="EXT_color_buffer_float",ev.colorBufferHalfFloat="EXT_color_buffer_half_float",ev.textureFilterAnisotropic="EXT_texture_filter_anisotropic",ev.blendMinMax="EXT_blend_minmax",ev.astc="WEBGL_compressed_texture_astc",ev.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",ev.etc="WEBGL_compressed_texture_etc",ev.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",ev.etc1="WEBGL_compressed_texture_etc1",ev.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",ev.pvrtc="WEBGL_compressed_texture_pvrtc",ev.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",ev.s3tc="WEBGL_compressed_texture_s3tc",ev.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",ev.WEBGL_lose_context="WEBGL_lose_context",(ey=o1||(o1={}))[ey.None=0]="None",ey[ey.Scene=1]="Scene",ey[ey.Hierarchy=2]="Hierarchy",ey[ey.All=3]="All";var lw=(s3(ex=function(e){var t;return(t=lr.call(this,e.engine)||this)._awoken=!1,t._phasedActive=!1,t._phasedActiveInScene=!1,t._enabled=!0,t._entity=e,t},lr),(eT=ex.prototype)._onAwake=function(){},eT._onEnable=function(){},eT._onDisable=function(){},eT._onEnableInScene=function(){},eT._onDisableInScene=function(){},eT._setActive=function(e,t){var n=this._entity;t&o1.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&o1.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()))},eT._onDestroy=function(){lr.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},s1(ex,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?(this._phasedActiveInScene=!0,this._onEnableInScene()):(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?(this._phasedActive=!0,this._onEnable()):(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),ex);s8([s7],lw.prototype,"_entity",void 0),s8([s7],lw.prototype,"_awoken",void 0),s8([s7],lw.prototype,"_phasedActive",void 0),s8([s7],lw.prototype,"_phasedActiveInScene",void 0),s8([s9],lw.prototype,"_enabled",void 0);var lE=((eC=function(){})._addCheck=function(e,t){for(;t!==lw;){var n=eC._dependenciesMap.get(t);if(n)for(var r=n.components,i=n.mode,a=0,o=r.length;a<o;a++){var s=r[a];if(!e.getComponent(s)){if(1===i)e.addComponent(s);else throw"Should add "+s.name+" before adding "+t.name}}t=Object.getPrototypeOf(t)}},eC._removeCheck=function(e,t){for(;t!==lw;){var n=eC._invDependenciesMap.get(t);if(n){for(var r=0,i=n.length;r<i;r++)if(e.getComponent(n[r]))throw"Should remove "+n[r].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eC._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eC._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eC);function lM(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){lE._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return lE._addInvDependency(t,e)})}}lE._invDependenciesMap=new Map,lE._dependenciesMap=new Map,e.DependentMode=void 0,(eS=e.DependentMode||(e.DependentMode={}))[eS.CheckOnly=0]="CheckOnly",eS[eS.AutoAdd=1]="AutoAdd";var lb=((ew=(eA=function(e){void 0===e&&(e=0),this.length=0,this._elements=Array(e)}).prototype).add=function(e){this.length===this._elements.length?this._elements.push(e):this._elements[this.length]=e,this.length++},ew.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ew.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ew.deleteByIndex=function(e){var t=this._elements,n=null,r=this.length-1;return e!==r&&(n=t[r],t[e]=n),this.length--,n},ew.garbageCollection=function(){this._elements.length=this.length},eA);e.Layer=void 0,(eE=e.Layer||(e.Layer={}))[eE.Layer0=1]="Layer0",eE[eE.Layer1=2]="Layer1",eE[eE.Layer2=4]="Layer2",eE[eE.Layer3=8]="Layer3",eE[eE.Layer4=16]="Layer4",eE[eE.Layer5=32]="Layer5",eE[eE.Layer6=64]="Layer6",eE[eE.Layer7=128]="Layer7",eE[eE.Layer8=256]="Layer8",eE[eE.Layer9=512]="Layer9",eE[eE.Layer10=1024]="Layer10",eE[eE.Layer11=2048]="Layer11",eE[eE.Layer12=4096]="Layer12",eE[eE.Layer13=8192]="Layer13",eE[eE.Layer14=16384]="Layer14",eE[eE.Layer15=32768]="Layer15",eE[eE.Layer16=65536]="Layer16",eE[eE.Layer17=131072]="Layer17",eE[eE.Layer18=262144]="Layer18",eE[eE.Layer19=524288]="Layer19",eE[eE.Layer20=1048576]="Layer20",eE[eE.Layer21=2097152]="Layer21",eE[eE.Layer22=4194304]="Layer22",eE[eE.Layer23=8388608]="Layer23",eE[eE.Layer24=16777216]="Layer24",eE[eE.Layer25=33554432]="Layer25",eE[eE.Layer26=67108864]="Layer26",eE[eE.Layer27=134217728]="Layer27",eE[eE.Layer28=268435456]="Layer28",eE[eE.Layer29=536870912]="Layer29",eE[eE.Layer30=1073741824]="Layer30",eE[eE.Layer31=2147483648]="Layer31",eE[eE.Everything=4294967295]="Everything",eE[eE.Nothing=0]="Nothing";var lF=((eM=function(){})._floatMatrixMultiply=function(e,t,n,r,i){var a=e.elements,o=a[0],s=a[1],l=a[2],c=a[3],u=a[4],h=a[5],d=a[6],_=a[7],f=a[8],p=a[9],g=a[10],m=a[11],v=a[12],y=a[13],x=a[14],T=a[15],C=t[n],S=t[n+1],A=t[n+2],w=t[n+3],E=t[n+4],M=t[n+5],b=t[n+6],F=t[n+7],R=t[n+8],P=t[n+9],L=t[n+10],D=t[n+11],I=t[n+12],B=t[n+13],N=t[n+14],V=t[n+15];r[i]=o*C+u*S+f*A+v*w,r[i+1]=s*C+h*S+p*A+y*w,r[i+2]=l*C+d*S+g*A+x*w,r[i+3]=c*C+_*S+m*A+T*w,r[i+4]=o*E+u*M+f*b+v*F,r[i+5]=s*E+h*M+p*b+y*F,r[i+6]=l*E+d*M+g*b+x*F,r[i+7]=c*E+_*M+m*b+T*F,r[i+8]=o*R+u*P+f*L+v*D,r[i+9]=s*R+h*P+p*L+y*D,r[i+10]=l*R+d*P+g*L+x*D,r[i+11]=c*R+_*P+m*L+T*D,r[i+12]=o*I+u*B+f*N+v*V,r[i+13]=s*I+h*B+p*N+y*V,r[i+14]=l*I+d*B+g*N+x*V,r[i+15]=c*I+_*B+m*N+T*V},eM._reflectGet=function(e,t){for(var n=this._stringToPath(t),r=e,i=0,a=n.length;null!=r&&i<a;)r=r[n[i++]];return i&&i==a?r:void 0},eM.removeFromArray=function(e,t){var n=e.indexOf(t);if(n<0)return!1;var r=e.length-1;if(n!==r){var i=e[r];e[n]=i}return e.length--,!0},eM.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))},eM.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eM.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eM.resolveAbsoluteUrl=function(e,t){return eM.isAbsoluteUrl(t)?t:"."===t.charAt(0)?eM._formatRelativePath(t+t):e.substring(0,e.lastIndexOf("/")+1)+t},eM._stringToPath=function(e){var t=[];return e.charCodeAt(0)===lR&&t.push(""),e.replace(lL,function(e,n,r,i){var a=e;r?a=i.replace(lP,"$1"):n&&(a=n.trim()),t.push(a)}),t},eM._formatRelativePath=function(e){for(var t=e.split("/"),n=0,r=t.length;n<r;n++)".."==t[n]&&(t.splice(n-1,2),n-=2);return t.join("/")},eM),lR=46,lP=/\\(\\)?/g,lL=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lD=((eF=(eb=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eF.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eF._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)lF.removeFromArray(e[t]._updateFlags,this)},s3(eR=function(){var e;return e=eb.apply(this,arguments)||this,e.flag=!0,e},eb),eR.prototype.dispatch=function(){this.flag=!0},eR),lI=((eL=(eP=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eL.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eL.removeFlag=function(e){lF.removeFromArray(this._updateFlags,e)&&lF.removeFromArray(e._flagManagers,this)},eL.addListener=function(e){this._listeners.push(e)},eL.removeListener=function(e){lF.removeFromArray(this._listeners,e)},eL.dispatch=function(e,t){for(var n=this._updateFlags,r=n.length-1;r>=0;r--)n[r].dispatch(e,t);for(var i=this._listeners,a=i.length-1;a>=0;a--)i[a](e,t)},eP),lB=(s3(eD=function(e){var t;return(t=lw.call(this,e)||this)._position=new sO,t._rotation=new sO,t._rotationQuaternion=new sX,t._scale=new sO(1,1,1),t._worldPosition=new sO,t._worldRotation=new sO,t._worldRotationQuaternion=new sX,t._lossyWorldScale=new sO(1,1,1),t._localMatrix=new sK,t._worldMatrix=new sK,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new lI,t._onPositionChanged=t._onPositionChanged.bind(s$(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(s$(t)),t._onRotationChanged=t._onRotationChanged.bind(s$(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(s$(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(s$(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(s$(t)),t._onScaleChanged=t._onScaleChanged.bind(s$(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},lw),(eI=eD.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eI.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eI.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eI.setScale=function(e,t,n){this._scale.set(e,t,n)},eI.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eI.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eI.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eI.translate=function(e,t,n,r){if("number"==typeof e){var i=eD._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},eI.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eI.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*sV.degreeToRadFactor;sX.rotationAxisAngle(e,r,eD._tempQuat0),this._rotateByQuat(eD._tempQuat0,n)},eI.lookAt=function(e,t){var n=eD._tempVec30;sO.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=sV.zeroTolerance)){n.scale(1/r);var i=eD._tempVec31;if(t?sO.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=sV.zeroTolerance)){i.scale(1/r);var a=eD._tempVec32;sO.cross(n,i,a);var o=eD._tempMat41,s=o.elements;s[0]=i.x,s[1]=i.y,s[2]=i.z,s[4]=a.x,s[5]=a.y,s[6]=a.z,s[8]=n.x,s[9]=n.y,s[10]=n.z,o.getRotation(this._worldRotationQuaternion)}}},eI.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(lD)},eI._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eI._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eI._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()}},eI._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)){this._worldAssociatedChange(152);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndRotationFlag()}},eI._updateWorldPositionAndRotationFlag=function(){if(!this._isContainDirtyFlags(156)){this._worldAssociatedChange(156);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndRotationFlag()}},eI._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)){this._worldAssociatedChange(160);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndScaleFlag()}},eI._updateWorldPositionAndScaleFlag=function(){if(!this._isContainDirtyFlags(164)){this._worldAssociatedChange(164);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndScaleFlag()}},eI._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)){this._worldAssociatedChange(188);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateAllWorldFlag()}},eI._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},eI._getScaleMatrix=function(){var e=eD._tempQuat0,t=eD._tempMat30,n=eD._tempMat31,r=eD._tempMat32;return n.copyFromMatrix(this.worldMatrix),sX.invert(this.worldRotationQuaternion,e),sW.rotationQuaternion(e,t),sW.multiply(t,n,r),r},eI._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eI._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eI._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eI._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eI._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eI._rotateByQuat=function(e,t){t?sX.multiply(this.rotationQuaternion,e,this._rotationQuaternion):sX.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eI._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eD._tempVec30;sO.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eI._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=sV.degreeToRadFactor,a=eD._tempQuat0;sX.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},eI._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eI._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(sK.invert(t.worldMatrix,eD._tempMat41),sO.transformCoordinate(e,eD._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eI._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eI._onWorldRotationChanged=function(){var e=this._worldRotation;sX.rotationEuler(sV.degreeToRadian(e.x),sV.degreeToRadian(e.y),sV.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eI._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eI._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eD._tempQuat0;sX.invert(t.worldRotationQuaternion,n),sX.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eI._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},s1(eD,[{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(sV.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(sV.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,sX.rotationEuler(sV.degreeToRadian(this._rotation.x),sV.degreeToRadian(this._rotation.y),sV.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):sX.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?sX.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):sX.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)&&(sK.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?sK.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?(sK.invert(t.worldMatrix,eD._tempMat42),sK.multiply(eD._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 sO),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 sO),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 sO),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eD);lB._tempQuat0=new sX,lB._tempVec30=new sO,lB._tempVec31=new sO,lB._tempVec32=new sO,lB._tempMat30=new sW,lB._tempMat31=new sW,lB._tempMat32=new sW,lB._tempMat41=new sK,lB._tempMat42=new sK,s8([lt],lB.prototype,"_position",void 0),s8([lt],lB.prototype,"_rotation",void 0),s8([lt],lB.prototype,"_rotationQuaternion",void 0),s8([lt],lB.prototype,"_scale",void 0),s8([lt],lB.prototype,"_worldPosition",void 0),s8([lt],lB.prototype,"_worldRotation",void 0),s8([lt],lB.prototype,"_worldRotationQuaternion",void 0),s8([lt],lB.prototype,"_lossyWorldScale",void 0),s8([lt],lB.prototype,"_localMatrix",void 0),s8([lt],lB.prototype,"_worldMatrix",void 0),s8([s7],lB.prototype,"_worldForward",void 0),s8([s7],lB.prototype,"_worldRight",void 0),s8([s7],lB.prototype,"_worldUp",void 0),s8([s7],lB.prototype,"_isParentDirty",void 0),s8([s7],lB.prototype,"_parentTransformCache",void 0),s8([s7],lB.prototype,"_updateFlagManager",void 0),s8([s7],lB.prototype,"_onPositionChanged",null),s8([s7],lB.prototype,"_onWorldPositionChanged",null),s8([s7],lB.prototype,"_onRotationChanged",null),s8([s7],lB.prototype,"_onWorldRotationChanged",null),s8([s7],lB.prototype,"_onRotationQuaternionChanged",null),s8([s7],lB.prototype,"_onWorldRotationQuaternionChanged",null),s8([s7],lB.prototype,"_onScaleChanged",null),(eB=o2||(o2={}))[eB.LocalEuler=1]="LocalEuler",eB[eB.LocalQuat=2]="LocalQuat",eB[eB.WorldPosition=4]="WorldPosition",eB[eB.WorldEuler=8]="WorldEuler",eB[eB.WorldQuat=16]="WorldQuat",eB[eB.WorldScale=32]="WorldScale",eB[eB.LocalMatrix=64]="LocalMatrix",eB[eB.WorldMatrix=128]="WorldMatrix",eB[eB.WmWp=132]="WmWp",eB[eB.WmWeWq=152]="WmWeWq",eB[eB.WmWpWeWq=156]="WmWpWeWq",eB[eB.WmWs=160]="WmWs",eB[eB.WmWpWs=164]="WmWpWs",eB[eB.WmWpWeWqWs=188]="WmWpWeWqWs";var lN=((eN=function(){}).cloneComponent=function(e,t){for(var n=ln.getCloneMode(e.constructor),r=Object.keys(e),i=0,a=r.length;i<a;i++){var o=r[i];switch(n[o]){case void 0:case o0.Assignment:t[o]=e[o];break;case o0.Shallow:var s=e[o];if(s6(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case o0.Deep:var c=e[o];if(s6(c,Object)){var u=t[o];null==u&&(u=t[o]=c.constructor()),ln.deepCloneObject(c,u)}else t[o]=c}}e._cloneTo&&e._cloneTo(t)},eN),lV=(s3(eV=function(t,n){var r;return(r=lr.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new lb,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new sK,r.name=n,r.transform=r.addComponent(lB),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},lr),(eO=eV.prototype).addComponent=function(e){lE._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0,o1.All),t},eO.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(s6(r,e))return r}},eO.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];s6(a,e)&&t.push(a)}return t},eO.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eO.addChild=function(e,t){var n;if("number"==typeof e?n=e:(n=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(n,t),t._parent=this;var r=t._scene,i=this._scene,a=o1.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(a|=o1.Hierarchy),this._isActiveInScene?t._isActiveInScene&&r!==i&&(a|=o1.Scene):t._isActiveInScene&&(a|=o1.Scene),a&&t._processInActive(a),t._scene!==i&&eV._traverseSetOwnerScene(t,i);var o=o1.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=o1.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&r===i||(o|=o1.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,n)},eO.removeChild=function(e){e._setParent(null)},eO.getChild=function(e){return this._children[e]},eO.findByName=function(e){if(e===this.name)return this;for(var t=this._children,n=0,r=t.length;n<r;n++){var i=t[n].findByName(e);if(i)return i}return null},eO.findByPath=function(e){for(var t=e.split("/"),n=this,r=0,i=t.length;r<i;++r){var a=t[r];if(a&&!(n=eV._findChildByName(n,a)))return null}return n},eO.createChild=function(e){var t=new eV(this.engine,e);return t.layer=this.layer,t.parent=this,t},eO.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n._parent=null;var r=o1.None;n._isActiveInHierarchy&&(r|=o1.Hierarchy),n._isActiveInScene&&(r|=o1.Scene),r&&n._processInActive(r),eV._traverseSetOwnerScene(n,null)}e.length=0},eO.clone=function(){var e=new eV(this._engine,this.name);e._isActive=this._isActive,e.transform.localMatrix=this.transform.localMatrix;for(var t=this._children,n=0,r=this._children.length;n<r;n++){var i=t[n];e.addChild(i.clone())}for(var a=this._components,o=0,s=a.length;o<s;o++){var l=a[o];if(!s6(l,lB)){var c=e.addComponent(l.constructor);lN.cloneComponent(l,c)}}return e},eO.destroy=function(){if(!this._destroyed){lr.prototype.destroy.call(this);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var n=this._children;n.length>0;)n[0].destroy();this._isRoot?(this._scene._removeFromEntityList(this),this._isRoot=!1):this._removeFromParent()}},eO._removeComponent=function(e){lE._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eO._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eO._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eO._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}},eO._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)},eO._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)},eO._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 i=e+1,a=r+1;i<a;i++)n[i]._siblingIndex++}},eO._setParent=function(e,t){var n=this._parent;if(e!==n){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var r=this._scene,i=e._scene,a=o1.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(a|=o1.Hierarchy),e._isActiveInScene?this._isActiveInScene&&r!==i&&(a|=o1.Scene):this._isActiveInScene&&(a|=o1.Scene),a&&this._processInActive(a),r!==i&&eV._traverseSetOwnerScene(this,i);var o=o1.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=o1.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&r===i||(o|=o1.Scene))),o&&this._processActive(o)}else{var s=o1.None;this._isActiveInHierarchy&&(s|=o1.Hierarchy),this._isActiveInScene&&(s|=o1.Scene),s&&this._processInActive(s),n&&eV._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},eO._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];s6(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},eO._setActiveComponents=function(e,t){for(var n=this._activeChangedComponents,r=0,i=n.length;r<i;++r)n[r]._setActive(e,t);this._scene._componentsManager.putActiveChangedTempList(n),this._activeChangedComponents=null},eO._setActiveInHierarchy=function(e,t){t&o1.Hierarchy&&(this._isActiveInHierarchy=!0),t&o1.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=n.length-1;r>=0;r--){var i=n[r];(i.enabled||!i._awoken)&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setActiveInHierarchy(e,t)}},eO._setInActiveInHierarchy=function(e,t){t&o1.Hierarchy&&(this._isActiveInHierarchy=!1),t&o1.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=n.length-1;r>=0;r--){var i=n[r];i.enabled&&e.push(i)}for(var a=this._children,o=a.length-1;o>=0;o--){var s=a[o];s.isActive&&s._setInActiveInHierarchy(e,t)}},eO._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eO._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 i=r==t?this:e[r-1];e[r]=i,i._siblingIndex=r}else for(var a=n;a<=t;a++){var o=a==t?this:e[a+1];e[a]=o,o._siblingIndex=a}}},eO.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(sK.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eV._findChildByName=function(e,t){for(var n=e._children,r=n.length-1;r>=0;r--){var i=n[r];if(i.name===t)return i}return null},eV._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=n.length-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},s1(eV,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,n=o1.None;this._isRoot&&this._scene._isActiveInEngine?n|=o1.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=o1.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=o1.Scene)),n&&this._processActive(n)}else{var r=o1.None;this._isActiveInHierarchy&&(r|=o1.Hierarchy),this._isActiveInScene&&(r|=o1.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)}}]),eV),lO=((ez=(eU=function(e){this._elementPoolIndex=0,this._elementPool=[],this._type=e}).prototype).getFromPool=function(){var e=this._elementPoolIndex,t=this._elementPool;if(this._elementPoolIndex++,t.length!==e)return t[e];var n=new this._type;return t.push(n),n},ez.resetPool=function(){this._elementPoolIndex=0},eU),lU=function(){},lz=(s3(ek=function(){return lU.apply(this,arguments)},lU),ek.prototype.set=function(e,t,n,r){this.component=e,this.material=t,this.mesh=n,this.subMesh=r},ek);e.BlendFactor=void 0,(eG=e.BlendFactor||(e.BlendFactor={}))[eG.Zero=0]="Zero",eG[eG.One=1]="One",eG[eG.SourceColor=2]="SourceColor",eG[eG.OneMinusSourceColor=3]="OneMinusSourceColor",eG[eG.DestinationColor=4]="DestinationColor",eG[eG.OneMinusDestinationColor=5]="OneMinusDestinationColor",eG[eG.SourceAlpha=6]="SourceAlpha",eG[eG.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eG[eG.DestinationAlpha=8]="DestinationAlpha",eG[eG.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eG[eG.SourceAlphaSaturate=10]="SourceAlphaSaturate",eG[eG.BlendColor=11]="BlendColor",eG[eG.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eH=e.BlendOperation||(e.BlendOperation={}))[eH.Add=0]="Add",eH[eH.Subtract=1]="Subtract",eH[eH.ReverseSubtract=2]="ReverseSubtract",eH[eH.Min=3]="Min",eH[eH.Max=4]="Max",e.ColorWriteMask=void 0,(eW=e.ColorWriteMask||(e.ColorWriteMask={}))[eW.None=0]="None",eW[eW.Red=1]="Red",eW[eW.Green=2]="Green",eW[eW.Blue=4]="Blue",eW[eW.Alpha=8]="Alpha",eW[eW.All=15]="All",e.CompareFunction=void 0,(eX=e.CompareFunction||(e.CompareFunction={}))[eX.Never=0]="Never",eX[eX.Less=1]="Less",eX[eX.Equal=2]="Equal",eX[eX.LessEqual=3]="LessEqual",eX[eX.Greater=4]="Greater",eX[eX.NotEqual=5]="NotEqual",eX[eX.GreaterEqual=6]="GreaterEqual",eX[eX.Always=7]="Always",e.CullMode=void 0,(eK=e.CullMode||(e.CullMode={}))[eK.Off=0]="Off",eK[eK.Front=1]="Front",eK[eK.Back=2]="Back",e.RenderQueueType=void 0,(ej=e.RenderQueueType||(e.RenderQueueType={}))[ej.Opaque=0]="Opaque",ej[ej.AlphaTest=1]="AlphaTest",ej[ej.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eq=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eq.Float=0]="Float",eq[eq.Int=1]="Int",eq[eq.Vector2=2]="Vector2",eq[eq.Vector3=3]="Vector3",eq[eq.Vector4=4]="Vector4",eq[eq.Matrix=5]="Matrix",eq[eq.Color=6]="Color",eq[eq.Texture=7]="Texture",eq[eq.FloatArray=8]="FloatArray",eq[eq.IntArray=9]="IntArray",eq[eq.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eY=e.StencilOperation||(e.StencilOperation={}))[eY.Keep=0]="Keep",eY[eY.Zero=1]="Zero",eY[eY.Replace=2]="Replace",eY[eY.IncrementSaturate=3]="IncrementSaturate",eY[eY.DecrementSaturate=4]="DecrementSaturate",eY[eY.Invert=5]="Invert",eY[eY.IncrementWrap=6]="IncrementWrap",eY[eY.DecrementWrap=7]="DecrementWrap";var lk=function(){function e(t,n,r,i){this.name=t,this._maskIndex=r,this._maskValue=i,this.value=n;var a=e._macroNameIdMap,o=a[t];void 0===a[t]&&(a[t]=o=e._macroNameCounter++),this._nameId=o}return e.getByName=function(t,n){var r=n?t+" "+n:t,i=e._macroMap[r];if(!i){var a=e._macroMaskMap,o=e._macroCounter,s=Math.floor(o/32),l=o%32;i=new e(t,n,s,1<<l),e._macroMap[r]=i,s==a.length&&(a.length++,a[s]=Array(32)),a[s][l]=r,e._macroCounter++}return i},e._getNamesByMacros=function(t,n){var r=e._macroMaskMap,i=t._mask;n.length=0;for(var a=0,o=t._length;a<o;a++)for(var s=r[a],l=i[a],c=l<0?32:Math.floor(Math.log2(l))+1,u=0;u<c;u++)l&1<<u&&n.push(s[u])},e}();lk._macroMaskMap=[],lk._macroNameIdMap=Object.create(null),lk._macroNameCounter=0,lk._macroCounter=0,lk._macroMap=Object.create(null);var lG=((eJ=(eQ=function(){this._mask=[],this._length=0}).prototype).enable=function(e){var t=e._maskIndex,n=t+1,r=this._mask,i=this._length;if(i<n){for(r.length<n&&(r.length=n);i<t;i++)r[i]=0;r[t]=e._maskValue,this._length=n}else r[t]|=e._maskValue},eJ.disable=function(e){var t=e._maskIndex,n=this._mask,r=this._length-1;if(!(t>r)){var i=n[t]&~e._maskValue;t==r&&0===i?this._length--:n[t]=i}},eJ.unionCollection=function(e){var t=e._mask,n=e._length,r=this._mask,i=this._length;if(i<n){r.length<n&&(r.length=n);for(var a=0;a<i;a++)r[a]|=t[a];for(;a<n;a++)r[a]=t[a];this._length=n}else for(var o=0;o<n;o++)r[o]|=t[o]},eJ.complementaryCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1,i=Math.min(e._length-1,r);i>=0;i--){var a=n[i]&~t[i];i==r&&0===a?(r--,this._length--):n[i]=a}},eJ.intersectionCollection=function(e){for(var t=e._mask,n=this._mask,r=this._length-1;r>=0;r--){var i=n[r]&t[r];0==i&&r==this._length-1?this._length--:n[r]=i}},eJ.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},eJ.clear=function(){this._length=0},eQ.unionCollection=function(e,t,n){var r,i,a,o,s=n._mask;e._length<t._length?(r=e._length,i=t._length,a=e._mask,o=t._mask):(r=t._length,i=e._length,a=t._mask,o=e._mask);var l=0;for(s.length<i&&(s.length=i);l<r;l++)s[l]=a[l]|o[l];for(;l<i;l++)s[l]=o[l];n._length=i},eQ);function lH(){return(lH=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)}e.PipelineStage=void 0,(eZ=e.PipelineStage||(e.PipelineStage={})).ShadowCaster="ShadowCaster",eZ.Forward="Forward";var lW=lH({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvec3 normalW=normalize(mat3(renderer_NormalMat)*normal.xyz);vec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){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]))continue;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]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec3 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(scene_ShadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==sunIndex){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]))continue;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]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"}),lX=((e$=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},e$.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=lW[t];return void 0===n?(ld.error('Shader slice "'+e.trim()+'" not founded.'),""):e$.parseIncludes(n)})},e$.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},e$.convertTo300=function(e,t){if(e=(e=(e=(e=e.replace(/\battribute\b/g,"in")).replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),t){if(/\bgl_FragData\[.+?\]/g.test(e)){var n=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,n)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}return e},e$._replaceMRTShader=function(e,t){for(var n="",r=new Set,i=0;i<t.length;i++){var a=t[i].match(/\bgl_FragData\[(.+?)\]/);r.add(a[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$),lK=function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var n;return(n=e._nameMap)[t]||(n[t]=new e(t))},e}();lK._nameCounter=0,lK._nameMap=Object.create(null);var lj=((e1=(e0=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var n="string"==typeof e?lK.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&ld.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},e1.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?lK.getByName(e):e)._uniqueId]},e1.getTagValue=function(e){return this._tagsMap["string"==typeof e?lK.getByName(e)._uniqueId:e._uniqueId]},e0);(e2=o3||(o3={}))[e2.Scene=0]="Scene",e2[e2.Camera=1]="Camera",e2[e2.Renderer=2]="Renderer",e2[e2.Material=3]="Material",e.ColorSpace=void 0,(e3=e.ColorSpace||(e.ColorSpace={}))[e3.Linear=0]="Linear",e3[e3.Gamma=1]="Gamma";var lq=((e5=(e4=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)},e5.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},e5.upload2f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform2f(t.location,sQ.gammaToLinearSpace(n.r),sQ.gammaToLinearSpace(n.g)):this._gl.uniform2f(t.location,n.r,n.g),r.x=n.r,r.y=n.g):(r.x!==n.x||r.y!==n.y)&&(this._gl.uniform2f(t.location,n.x,n.y),r.x=n.x,r.y=n.y)},e5.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},e5.upload3f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform3f(t.location,sQ.gammaToLinearSpace(n.r),sQ.gammaToLinearSpace(n.g),sQ.gammaToLinearSpace(n.b)):this._gl.uniform3f(t.location,n.r,n.g,n.b),r.x=n.r,r.y=n.g,r.z=n.b):(r.x!==n.x||r.y!==n.y||r.z!==n.z)&&(this._gl.uniform3f(t.location,n.x,n.y,n.z),r.x=n.x,r.y=n.y,r.z=n.z)},e5.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},e5.upload4f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b||r.w!==n.a)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform4f(t.location,sQ.gammaToLinearSpace(n.r),sQ.gammaToLinearSpace(n.g),sQ.gammaToLinearSpace(n.b),n.a):this._gl.uniform4f(t.location,n.r,n.g,n.b,n.a),r.x=n.r,r.y=n.g,r.z=n.b,r.w=n.a):(r.x!==n.x||r.y!==n.y||r.z!==n.z||r.w!==n.w)&&(this._gl.uniform4f(t.location,n.x,n.y,n.z,n.w),r.x=n.x,r.y=n.y,r.z=n.z,r.w=n.w)},e5.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},e5.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},e5.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},e5.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)},e5.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},e5.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)},e5.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},e5.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)},e5.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},e5.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},e5.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},e5.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},e5.uploadTextureArray=function(e,t){for(var n=this._rhi,r=e.textureIndex,i=0;i<t.length;i++){var a=t[i];n.activeTexture(r[i]),n.bindTexture(a._platformTexture),a._setUseDepthCompareMode(e.textureUseCompareMode)}},e4),lY=function(){this.constUniforms=[],this.textureUniforms=[]},lQ=function(){function e(t,n,r){this.sceneUniformBlock=new lY,this.cameraUniformBlock=new lY,this.rendererUniformBlock=new lY,this.materialUniformBlock=new lY,this.otherUniformBlock=new lY,this._uploadRenderCount=-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,i=0,a=r.length;i<a;i++){var o=r[i],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 i=0,a=r.length;i<a;i++){var o=r[i],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],i=lS._getShaderPropertyGroup(r.name);void 0!==i&&(e.splice(e.indexOf(r),1),this._groupingUniform(r,i,t))}},t._groupingUniform=function(e,t,n){switch(t){case o3.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case o3.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case o3.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case o3.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.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 i=this._createShader(n.FRAGMENT_SHADER,t);if(!i)return null;var a=n.createProgram();return a?(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),n.validateProgram(a),n.deleteShader(r),n.deleteShader(i),!ld.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(ld.error("Could not link WebGL program\n\nShader error: "+n.getError()+"\n\nValidate status: "+n.getProgramParameter(a,n.VALIDATE_STATUS)+"\n\nProgram information log: "+n.getProgramInfoLog(a)),n.deleteProgram(a),null):(console.warn("Context lost while create program."),null)},t._createShader=function(t,n){var r=this._gl,i=r.createShader(t);return i?(r.shaderSource(i,n),r.compileShader(i),!ld.isEnabled||r.getShaderParameter(i,r.COMPILE_STATUS)||r.isContextLost())?i:(console.warn("Could not compile WebGL shader\n\nShader type: "+(t==r.VERTEX_SHADER?"vertex":"fragment")+"\n\nShader information log:\n"+r.getShaderInfoLog(i)+"\nShader source:\n"+e._addLineNum(n)),r.deleteShader(i),null):(console.warn("Context lost while create shader."),null)},t._recordLocation=function(){var e=this,t=this._gl,n=this._glProgram,r=this._getUniformInfos(),i=this._getAttributeInfos();r.forEach(function(r){var i,a=r.name,o=r.size,s=r.type,l=new lq(e._engine),c=!1,u=!1;a.indexOf("[0]")>0&&(a=a.substr(0,a.length-3),c=!0);var h=t.getUniformLocation(n,a);switch(l.name=a,l.propertyId=lS.getByName(a)._uniqueId,l.location=h,s){case t.FLOAT:c?l.applyFunc=l.upload1fv:(l.applyFunc=l.upload1f,l.cacheValue=0);break;case t.FLOAT_VEC2:c?l.applyFunc=l.upload2fv:(l.applyFunc=l.upload2f,l.cacheValue=new sq(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sO(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new sY(0,0,0,0));break;case t.BOOL:case t.INT:c?l.applyFunc=l.upload1iv:(l.applyFunc=l.upload1i,l.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:c?l.applyFunc=l.upload2iv:(l.applyFunc=l.upload2i,l.cacheValue=new sq(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=c?l.upload3iv:l.upload3i,l.cacheValue=new sO(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new sY(0,0,0));break;case t.FLOAT_MAT4:l.applyFunc=c?l.uploadMat4v:l.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(s){case t.SAMPLER_2D:i=e._engine._magentaTexture2D;break;case t.SAMPLER_CUBE:i=e._engine._magentaTextureCube;break;case t.SAMPLER_2D_ARRAY:i=e._engine._magentaTexture2DArray;break;case t.SAMPLER_2D_SHADOW:i=e._engine._depthTexture2D,l.textureUseCompareMode=!0}if(u=!0,c){for(var d=Array(o),_=new Int32Array(o),f=Array(o),p=0;p<o;p++)d[p]=i,_[p]=e._activeTextureUint,f[p]=t.TEXTURE0+e._activeTextureUint++;l.textureDefault=d,l.textureIndex=f,l.applyFunc=l.uploadTextureArray,e.bind(),t.uniform1iv(h,_)}else{var g=t.TEXTURE0+e._activeTextureUint;l.textureDefault=i,l.textureIndex=g,l.applyFunc=l.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var m=lS._getShaderPropertyGroup(a);e._groupingUniform(l,m,u)}),i.forEach(function(r){var i=r.name;e.attributeLocation[i]=t.getAttribLocation(n,i)})},t._getUniformInfos=function(){for(var e=this._gl,t=this._glProgram,n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS),r=Array(n),i=0;i<n;++i){var a=e.getActiveUniform(t,i);r[i]=a}return r},t._getAttributeInfos=function(){for(var e=this._gl,t=this._glProgram,n=[],r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),i=0;i<r;++i){var a=e.getActiveAttrib(t,i);n[i]=a}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 i=0;i<r-t.length;i++)t+=" ";return t+e}).join("\n")},s1(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();lQ._counter=0;var lJ=function(t){function n(r,i,a){var o;for(var s in void 0===a&&(a={pipelineStage:e.PipelineStage.Forward}),(o=t.call(this)||this)._shaderPassId=0,o._shaderPassId=n._shaderPassCounter++,o._vertexSource=r,o._fragmentSource=i,a)o.setTag(s,a[s]);return o}return s3(n,t),n.prototype._getShaderProgram=function(t,n){var r=t._getShaderProgramPool(this),i=r.get(n);if(i)return i;var a=t._hardwareRenderer.isWebGL2,o=[];lk._getNamesByMacros(n,o);var s=lX.parseCustomMacros(o),l=a?"#version 300 es":"#version 100",c=a?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",u="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&(u+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(u+="#define HAS_DERIVATIVES\n");var h=" "+l+"\n "+c+"\n "+s+"\n "+lX.parseIncludes(this._vertexSource),d=" "+l+"\n "+c+"\n "+(a?"":lX.parseExtension(l$._shaderExtension))+"\n "+u+"\n "+s+"\n "+lX.parseIncludes(this._fragmentSource);return a&&(h=lX.convertTo300(h),d=lX.convertTo300(d,!0)),i=new lQ(t,h,d),r.cache(i),i},n}(lj);lJ._shaderPassCounter=0;var lZ=(s3(e8=function(e,t,n){var r;if((r=lj.call(this)||this).name=e,t.length<1)throw" count must large than 0.";for(var i in r._passes=t.slice(),n)r.setTag(i,n[i]);return r},lj),s1(e8,[{key:"passes",get:function(){return this._passes}}]),e8),l$=((e6=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var n=e6._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(lk.getByName(t[r]));for(var a=this._subShaders,o=0,s=a.length;o<s;o++){for(var l=void 0,c=a[o].passes,u=0,h=c.length;u<h;u++)void 0===l?l=c[u]._getShaderProgram(e,n).isValid:l&&(l=c[u]._getShaderProgram(e,n).isValid);if(l)return!0}return!1},e6.create=function(e,t,n){var r,i=e6._shaderMap;if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new lJ(t,n);r=new e6(e,[new lZ("Default",[a])])}else if(t.length>0)r=t[0].constructor===lJ?new e6(e,[new lZ("Default",t)]):new e6(e,t.slice());else throw"SubShader or ShaderPass count must large than 0.";return i[e]=r,r},e6.find=function(e){return e6._shaderMap[e]},e6.getMacroByName=function(e,t){return lk.getByName(e,t)},e6.getPropertyByName=function(e){return lS.getByName(e)},s1(e6,[{key:"subShaders",get:function(){return this._subShaders}}]),e6);l$._compileMacros=new lG,l$._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],l$._shaderMap=Object.create(null);var l0=((e9=(e7=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new lG,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},e9.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},e9.getInt=function(e){return this.getPropertyValue(e)},e9.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},e9.getFloatArray=function(e){return this.getPropertyValue(e)},e9.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},e9.getIntArray=function(e){return this.getPropertyValue(e)},e9.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},e9.getVector2=function(e){return this.getPropertyValue(e)},e9.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},e9.getVector3=function(e){return this.getPropertyValue(e)},e9.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},e9.getVector4=function(e){return this.getPropertyValue(e)},e9.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},e9.getMatrix=function(e){return this.getPropertyValue(e)},e9.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},e9.getColor=function(e){return this.getPropertyValue(e)},e9.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},e9.getTexture=function(e){return this.getPropertyValue(e)},e9.setTexture=function(t,n){if(this._getReferCount()>0){var r=this.getPropertyValue(t);r&&r._addReferCount(-1),n&&n._addReferCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,n)},e9.getTextureArray=function(e){return this.getPropertyValue(e)},e9.setTextureArray=function(t,n){if(this._getReferCount()>0){var r=this.getPropertyValue(t);if(r)for(var i=0,a=r.length;i<a;i++)r[i]._addReferCount(-1);if(n)for(var o=0,s=n.length;o<s;o++)n[o]._addReferCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,n)},e9.getPropertyValue=function(e){return"string"==typeof e&&(e=lS.getByName(e)),this._propertyValueMap[e._uniqueId]},e9.enableMacro=function(e,t){"string"==typeof e&&(e=lk.getByName(e,t));var n=e._nameId,r=this._macroMap[n];if(r!==e){var i=this._macroCollection;r&&i.disable(r),i.enable(e),this._macroMap[n]=e}},e9.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=lk._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},e9.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])},e9.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=lS._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},e9.clone=function(){var e=new e7(this._group);return this.cloneTo(e),e},e9.cloneTo=function(e){ln.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=this._propertyValueMap,n=e._propertyValueMap,r=Object.keys(t),i=0,a=r.length;i<a;i++){var o=r[i],s=t[o];if(null!=s){if("number"==typeof s)n[o]=s;else if(s6(s,l_))n[o]=s;else if(s6(s,Array)||s6(s,Float32Array)||s6(s,Int32Array))n[o]=s.slice();else{var l=n[o];l?l.copyFrom(s):n[o]=s.clone()}}else n[o]=s}},e9._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lS.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 "+o3[t._group]+" group."}if(t._type!==n){if(void 0===t._type)t._type=n;else throw"Shader property "+t.name+" has been used as "+e.ShaderPropertyType[t._type]+" type."}this._propertyValueMap[t._uniqueId]=r},e9._getReferCount=function(){return this._refCount},e9._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&s6(r,l_)&&r._addReferCount(e)}},e7),l1=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},l2=((tt=(te=function(){this.targetBlendState=new l1,this.blendColor=new sQ(0,0,0,0),this.alphaToCoverage=!1}).prototype)._apply=function(e,t){this._platformApply(e,t.blendState)},tt._platformApply=function(t,n){var r=t.gl,i=n.targetBlendState,a=this.targetBlendState,o=a.enabled,s=a.colorBlendOperation,l=a.alphaBlendOperation,c=a.sourceColorBlendFactor,u=a.destinationColorBlendFactor,h=a.sourceAlphaBlendFactor,d=a.destinationAlphaBlendFactor,_=a.colorWriteMask;if(o!==i.enabled&&(o?r.enable(r.BLEND):r.disable(r.BLEND),i.enabled=o),o){(c!==i.sourceColorBlendFactor||u!==i.destinationColorBlendFactor||h!==i.sourceAlphaBlendFactor||d!==i.destinationAlphaBlendFactor)&&(r.blendFuncSeparate(te._getGLBlendFactor(t,c),te._getGLBlendFactor(t,u),te._getGLBlendFactor(t,h),te._getGLBlendFactor(t,d)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=d),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(r.blendEquationSeparate(te._getGLBlendOperation(t,s),te._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;sQ.equals(n.blendColor,f)||(r.blendColor(f.r,f.g,f.b,f.a),n.blendColor.copyFrom(f))}_!==i.colorWriteMask&&(r.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),i.colorWriteMask=_);var p=this.alphaToCoverage;p!==n.alphaToCoverage&&(p?r.enable(r.SAMPLE_ALPHA_TO_COVERAGE):r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=p)},te._getGLBlendFactor=function(t,n){var r=t.gl;switch(n){case e.BlendFactor.Zero:return r.ZERO;case e.BlendFactor.One:return r.ONE;case e.BlendFactor.SourceColor:return r.SRC_COLOR;case e.BlendFactor.OneMinusSourceColor:return r.ONE_MINUS_SRC_COLOR;case e.BlendFactor.DestinationColor:return r.DST_COLOR;case e.BlendFactor.OneMinusDestinationColor:return r.ONE_MINUS_DST_COLOR;case e.BlendFactor.SourceAlpha:return r.SRC_ALPHA;case e.BlendFactor.OneMinusSourceAlpha:return r.ONE_MINUS_SRC_ALPHA;case e.BlendFactor.DestinationAlpha:return r.DST_ALPHA;case e.BlendFactor.OneMinusDestinationAlpha:return r.ONE_MINUS_DST_ALPHA;case e.BlendFactor.SourceAlphaSaturate:return r.SRC_ALPHA_SATURATE;case e.BlendFactor.BlendColor:return r.CONSTANT_COLOR;case e.BlendFactor.OneMinusBlendColor:return r.ONE_MINUS_CONSTANT_COLOR}},te._getGLBlendOperation=function(t,n){var r=t.gl;switch(n){case e.BlendOperation.Add:return r.FUNC_ADD;case e.BlendOperation.Subtract:return r.FUNC_SUBTRACT;case e.BlendOperation.ReverseSubtract:return r.FUNC_REVERSE_SUBTRACT;case e.BlendOperation.Min:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return r.MIN;case e.BlendOperation.Max:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return r.MAX}},te),l3=((tr=(tn=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._apply=function(e,t){this._platformApply(e,t.depthState)},tr._platformApply=function(e,t){var n=e.gl,r=this.enabled,i=this.compareFunction,a=this.writeEnabled;r!=t.enabled&&(r?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),t.enabled=r),r&&(i!=t.compareFunction&&(n.depthFunc(tn._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(n.depthMask(a),t.writeEnabled=a))},tn._getGLCompareFunction=function(t,n){var r=t.gl;switch(n){case e.CompareFunction.Never:return r.NEVER;case e.CompareFunction.Less:return r.LESS;case e.CompareFunction.Equal:return r.EQUAL;case e.CompareFunction.LessEqual:return r.LEQUAL;case e.CompareFunction.Greater:return r.GREATER;case e.CompareFunction.NotEqual:return r.NOTEQUAL;case e.CompareFunction.GreaterEqual:return r.GEQUAL;case e.CompareFunction.Always:return r.ALWAYS}},tn),l4=((ta=(ti=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._apply=function(e,t,n){this._platformApply(e,t.rasterState,n)},ta._platformApply=function(t,n,r){var i=t.gl,a=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=a!==e.CullMode.Off;l!==n._cullFaceEnable&&(l?i.enable(i.CULL_FACE):i.disable(i.CULL_FACE),n._cullFaceEnable=l),l&&a!==n.cullMode&&(a==e.CullMode.Back?i.cullFace(i.BACK):i.cullFace(i.FRONT),n.cullMode=a),r!==n._frontFaceInvert&&(r?i.frontFace(i.CW):i.frontFace(i.CCW),n._frontFaceInvert=r),t._enableGlobalDepthBias||o===n.depthBias&&s===n.slopeScaledDepthBias||(0!==o||0!==s?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset(s,o)):i.disable(i.POLYGON_OFFSET_FILL),n.depthBias=o,n.slopeScaledDepthBias=s)},ti),l5=((ts=(to=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._apply=function(e,t){this._platformApply(e,t.stencilState)},ts._platformApply=function(e,t){var n=e.gl,r=this.enabled,i=this.referenceValue,a=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,u=this.passOperationFront,h=this.failOperationBack,d=this.zFailOperationBack,_=this.passOperationBack,f=this.writeMask;if(r!=t.enabled&&(r?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),t.enabled=r),r){var p=i!==t.referenceValue||a!==t.mask;(p||o!==t.compareFunctionFront)&&(n.stencilFuncSeparate(n.FRONT,to._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(n.stencilFuncSeparate(n.BACK,to._getGLCompareFunction(e,s),i,a),t.compareFunctionBack=this.compareFunctionBack),p&&(t.referenceValue=this.referenceValue,t.mask=this.mask),(l!==t.failOperationFront||c!==t.zFailOperationFront||u!==t.passOperationFront)&&(n.stencilOpSeparate(n.FRONT,to._getGLStencilOperation(e,l),to._getGLStencilOperation(e,c),to._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(h!==t.failOperationBack||d!==t.zFailOperationBack||_!==t.passOperationBack)&&(n.stencilOpSeparate(n.BACK,to._getGLStencilOperation(e,h),to._getGLStencilOperation(e,d),to._getGLStencilOperation(e,_)),t.failOperationBack=h,t.zFailOperationBack=d,t.passOperationBack=_),f!==t.writeMask&&(n.stencilMask(f),t.writeMask=f)}},to._getGLCompareFunction=function(t,n){var r=t.gl;switch(n){case e.CompareFunction.Never:return r.NEVER;case e.CompareFunction.Less:return r.LESS;case e.CompareFunction.Equal:return r.EQUAL;case e.CompareFunction.LessEqual:return r.LEQUAL;case e.CompareFunction.Greater:return r.GREATER;case e.CompareFunction.NotEqual:return r.NOTEQUAL;case e.CompareFunction.GreaterEqual:return r.GEQUAL;case e.CompareFunction.Always:return r.ALWAYS}},to._getGLStencilOperation=function(t,n){var r=t.gl;switch(n){case e.StencilOperation.Keep:return r.KEEP;case e.StencilOperation.Zero:return r.ZERO;case e.StencilOperation.Replace:return r.REPLACE;case e.StencilOperation.IncrementSaturate:return r.INCR;case e.StencilOperation.DecrementSaturate:return r.DECR;case e.StencilOperation.Invert:return r.INVERT;case e.StencilOperation.IncrementWrap:return r.INCR_WRAP;case e.StencilOperation.DecrementWrap:return r.DECR_WRAP}},to),l8=((tl=function(){this.blendState=new l2,this.depthState=new l3,this.stencilState=new l5,this.rasterState=new l4,this.renderQueueType=e.RenderQueueType.Opaque}).prototype._apply=function(e,t){var n=e._hardwareRenderer,r=e._lastRenderState;this.blendState._apply(n,r),this.depthState._apply(n,r),this.stencilState._apply(n,r),this.rasterState._apply(n,r,t)},tl),l6=((tc=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(tc._viewMatrixProperty,e.viewMatrix),t.setMatrix(tc._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(tc.vpMatrixProperty,e.viewProjectionMatrix)},tc);l6.vpMatrixProperty=lS.getByName("camera_VPMat"),l6.pipelineStageKey=lK.getByName("pipelineStage"),l6._viewMatrixProperty=lS.getByName("camera_ViewMat"),l6._projectionMatrixProperty=lS.getByName("camera_ProjMat");var l7=((tu=function(){}).prototype.set=function(e,t,n){this.data=e,this.shaderPass=t,this.renderState=n},tu);function l9(){return function(e){}}e.SpriteMaskInteraction=void 0,(th=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[th.None=0]="None",th[th.VisibleInsideMask=1]="VisibleInsideMask",th[th.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(s3(td=function(t){(n=lw.call(this,t)||this).shaderData=new l0(o3.Renderer),n._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new lG,n._bounds=new sz,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._mvMatrix=new sK,n._mvpMatrix=new sK,n._mvInvMatrix=new sK,n._normalMatrix=new sK,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new sY,n.castShadows=!0;var n,r=e.Renderer.prototype,i=n.shaderData;return n._overrideUpdate=n.update!==r.update,i._addReferCount(1),n._onTransformChanged=n._onTransformChanged.bind(s$(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lw),(t_=td.prototype).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},t_.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},t_.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},t_.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},t_.getMaterials=function(){return this._materials},t_.setMaterials=function(e){for(var t=e.length,n=this._materials,r=this._materialsInstanced,i=t,a=n.length;i<a;i++){var o=n[i];o&&o._addReferCount(-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&&l._addReferCount(-1),c&&c._addReferCount(1))}},t_.update=function(e){},t_._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},t_._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},t_._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sO.subtract(i,r,i),this._distanceForSort=sO.dot(i,n.forward)):this._distanceForSort=sO.distanceSquared(i,r),this._updateShaderData(t),this._render(t),lG.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},t_._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},t_._onDestroy=function(){lw.prototype._onDestroy.call(this),this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged),this.shaderData._addReferCount(-1);for(var e,t=this._materials,n=0,r=t.length;n<r;n++)null==(e=t[n])||e._addReferCount(-1)},t_._updateShaderData=function(e){var t=this.entity,n=t.transform.worldMatrix;this._updateTransformShaderData(e,n);var r=t.layer;this._rendererLayer.set(65535&r,r>>>16&65535,0,0)},t_._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;sK.multiply(i.viewMatrix,n,a),sK.multiply(i.viewProjectionMatrix,n,o),sK.invert(a,s),sK.invert(n,l),l.transpose(),r.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),r.setMatrix(e.Renderer._worldMatrixProperty,n),r.setMatrix(e.Renderer._mvMatrixProperty,a),r.setMatrix(e.Renderer._mvpMatrixProperty,o),r.setMatrix(e.Renderer._mvInvMatrixProperty,s),r.setMatrix(e.Renderer._normalMatrixProperty,l)},t_._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},t_._updateBounds=function(e){},t_._render=function(e){throw"not implement"},t_._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",e._addReferCount(-1),n._addReferCount(1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},t_._setMaterial=function(e,t){var n=this._materials;e>=n.length&&(n.length=e+1);var r=n[e];if(r!==t){var i=this._materialsInstanced;e<i.length&&(i[e]=!1),r&&r._addReferCount(-1),t&&t._addReferCount(1),n[e]=t}},t_._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},s1(td,[{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,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}}]),(o4=td)._tempVector0=new sO,o4._receiveShadowMacro=lk.getByName("RENDERER_IS_RECEIVE_SHADOWS"),o4._localMatrixProperty=lS.getByName("renderer_LocalMat"),o4._worldMatrixProperty=lS.getByName("renderer_ModelMat"),o4._mvMatrixProperty=lS.getByName("renderer_MVMat"),o4._mvpMatrixProperty=lS.getByName("renderer_MVPMat"),o4._mvInvMatrixProperty=lS.getByName("renderer_MVInvMat"),o4._normalMatrixProperty=lS.getByName("renderer_NormalMat"),o4._rendererLayerProperty=lS.getByName("renderer_Layer"),o4),s8([lt],e.Renderer.prototype,"shaderData",void 0),s8([s7],e.Renderer.prototype,"_distanceForSort",void 0),s8([s7],e.Renderer.prototype,"_onUpdateIndex",void 0),s8([s7],e.Renderer.prototype,"_rendererIndex",void 0),s8([s7],e.Renderer.prototype,"_globalShaderMacro",void 0),s8([lt],e.Renderer.prototype,"_bounds",void 0),s8([s7],e.Renderer.prototype,"_renderFrameCount",void 0),s8([s7],e.Renderer.prototype,"_overrideUpdate",void 0),s8([s7],e.Renderer.prototype,"_materials",void 0),s8([s7],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),s8([s7],e.Renderer.prototype,"_mvMatrix",void 0),s8([s7],e.Renderer.prototype,"_mvpMatrix",void 0),s8([s7],e.Renderer.prototype,"_mvInvMatrix",void 0),s8([s7],e.Renderer.prototype,"_normalMatrix",void 0),s8([s7],e.Renderer.prototype,"_materialsInstanced",void 0),s8([s7],e.Renderer.prototype,"_priority",void 0),s8([s9],e.Renderer.prototype,"_receiveShadows",void 0),s8([s7],e.Renderer.prototype,"_rendererLayer",void 0),s8([s7],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=s8([lM(lB,e.DependentMode.CheckOnly)],e.Renderer),(tf=o5||(o5={}))[tf.WorldVolume=1]="WorldVolume";var ce=((tp=function(){}).resetData=function(e){var t=e._verticesData,n=t.vertexCount=4,r=t.positions,i=t.uvs;if(r.length<n)for(var a=r.length;a<n;a++)r.push(new sO),i.push(new sq);t.triangles=ce._rectangleTriangles},tp.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=ce._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,u=e.flipX?-t:t,h=e.flipY?-n:n;l[0]=c[0]*u,l[1]=c[1]*u,l[2]=c[2]*u,l[4]=c[4]*h,l[5]=c[5]*h,l[6]=c[6]*h,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-a*l[0]-o*l[4],l[13]=c[13]-a*l[1]-o*l[5],l[14]=c[14]-a*l[2]-o*l[6];for(var d=r._getPositions(),_=e._verticesData.positions,f=0;f<4;f++){var p=d[f],g=p.x,m=p.y;_[f].set(l[0]*g+l[4]*m+l[12],l[1]*g+l[5]*m+l[13],l[2]*g+l[6]*m+l[14])}sz.transform(r._getBounds(),s,e._bounds)},tp.updateUVs=function(e){var t=e.sprite._getUVs(),n=e._verticesData.uvs,r=t[0],i=r.x,a=r.y,o=t[3],s=o.x,l=o.y;n[0].set(i,a),n[1].set(s,a),n[2].set(i,l),n[3].set(s,l)},(o8=tp)._rectangleTriangles=[0,1,2,2,1,3],o8._worldMatrix=new sK,o8);ce=s8([l9()],ce);var ct=function(e,t,n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),this.vertexCount=e,this.positions=t,this.uvs=n,this.triangles=r,this.color=i};e.SpriteMaskLayer=void 0,(tg=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[tg.Layer0=1]="Layer0",tg[tg.Layer1=2]="Layer1",tg[tg.Layer2=4]="Layer2",tg[tg.Layer3=8]="Layer3",tg[tg.Layer4=16]="Layer4",tg[tg.Layer5=32]="Layer5",tg[tg.Layer6=64]="Layer6",tg[tg.Layer7=128]="Layer7",tg[tg.Layer8=256]="Layer8",tg[tg.Layer9=512]="Layer9",tg[tg.Layer10=1024]="Layer10",tg[tg.Layer11=2048]="Layer11",tg[tg.Layer12=4096]="Layer12",tg[tg.Layer13=8192]="Layer13",tg[tg.Layer14=16384]="Layer14",tg[tg.Layer15=32768]="Layer15",tg[tg.Layer16=65536]="Layer16",tg[tg.Layer17=131072]="Layer17",tg[tg.Layer18=262144]="Layer18",tg[tg.Layer19=524288]="Layer19",tg[tg.Layer20=1048576]="Layer20",tg[tg.Layer21=2097152]="Layer21",tg[tg.Layer22=4194304]="Layer22",tg[tg.Layer23=8388608]="Layer23",tg[tg.Layer24=16777216]="Layer24",tg[tg.Layer25=33554432]="Layer25",tg[tg.Layer26=67108864]="Layer26",tg[tg.Layer27=134217728]="Layer27",tg[tg.Layer28=268435456]="Layer28",tg[tg.Layer29=536870912]="Layer29",tg[tg.Layer30=1073741824]="Layer30",tg[tg.Layer31=2147483648]="Layer31",tg[tg.Everything=4294967295]="Everything",(tm=o6||(o6={}))[tm.texture=1]="texture",tm[tm.size=2]="size",tm[tm.atlasRotate=4]="atlasRotate",tm[tm.atlasRegion=8]="atlasRegion",tm[tm.atlasRegionOffset=16]="atlasRegionOffset",tm[tm.region=32]="region",tm[tm.pivot=64]="pivot",tm[tm.border=128]="border";var cn=function(t){function n(r){var i;return(i=t.call(this,r)||this).influenceLayers=e.SpriteMaskLayer.Everything,i._sprite=null,i._automaticWidth=0,i._automaticHeight=0,i._customWidth=void 0,i._customHeight=void 0,i._flipX=!1,i._flipY=!1,i._alphaCutoff=.5,i._verticesData=new ct(4,[],[]),ce.resetData(s$(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(s$(i)),i}s3(n,t);var r=n.prototype;return r._cloneTo=function(e){t.prototype._cloneTo.call(this,e),e.sprite=this._sprite},r._updateBounds=function(e){this.sprite?ce.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},r._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&o5.WorldVolume&&(ce.updatePositions(this),this._dirtyUpdateFlag&=~o5.WorldVolume),2&this._dirtyUpdateFlag&&(ce.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var t,n=this._engine._spriteMaskRenderDataPool.getFromPool(),r=this.getMaterial();n.set(this,r,this._verticesData);var i=this._engine._renderElementPool.getFromPool();i.set(n,r.shader.subShaders[0].passes[0],r.renderStates[0]),this._maskElement=i}},r._onDestroy=function(){var e;t.prototype._onDestroy.call(this),null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._sprite=null,this._verticesData=null},r._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},r._onSpriteChange=function(e){switch(e){case o6.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case o6.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=o5.WorldVolume);break;case o6.region:case o6.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case o6.atlasRegion:this._dirtyUpdateFlag|=2;break;case o6.pivot:this._dirtyUpdateFlag|=o5.WorldVolume}},s1(n,[{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|=o5.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|=o5.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=o5.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=o5.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&t._updateFlagManager.removeListener(this._onSpriteChange),this._dirtyUpdateFlag|=7,e?(e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(n._textureProperty,e.texture)):this.shaderData.setTexture(n._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(n._alphaCutoffProperty,e))}}]),n}(e.Renderer);cn._textureProperty=lS.getByName("renderer_MaskTexture"),cn._alphaCutoffProperty=lS.getByName("renderer_MaskAlphaCutoff"),s8([s9],cn.prototype,"influenceLayers",void 0),s8([s7],cn.prototype,"_sprite",void 0),s8([s7],cn.prototype,"_automaticWidth",void 0),s8([s7],cn.prototype,"_automaticHeight",void 0),s8([s9],cn.prototype,"_customWidth",void 0),s8([s9],cn.prototype,"_customHeight",void 0),s8([s9],cn.prototype,"_flipX",void 0),s8([s9],cn.prototype,"_flipY",void 0),s8([s9],cn.prototype,"_alphaCutoff",void 0),s8([s7],cn.prototype,"_onSpriteChange",null),(tv=o7||(o7={}))[tv.UV=2]="UV",tv[tv.RenderData=3]="RenderData",tv[tv.AutomaticSize=4]="AutomaticSize",tv[tv.All=7]="All",e.VertexElementFormat=void 0,(ty=e.VertexElementFormat||(e.VertexElementFormat={}))[ty.Float=0]="Float",ty[ty.Vector2=1]="Vector2",ty[ty.Vector3=2]="Vector3",ty[ty.Vector4=3]="Vector4",ty[ty.Byte4=4]="Byte4",ty[ty.UByte4=5]="UByte4",ty[ty.NormalizedByte4=6]="NormalizedByte4",ty[ty.NormalizedUByte4=7]="NormalizedUByte4",ty[ty.Short2=8]="Short2",ty[ty.UShort2=9]="UShort2",ty[ty.NormalizedShort2=10]="NormalizedShort2",ty[ty.NormalizedUShort2=11]="NormalizedUShort2",ty[ty.Short4=12]="Short4",ty[ty.UShort4=13]="UShort4",ty[ty.NormalizedShort4=14]="NormalizedShort4",ty[ty.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(tx=e.IndexFormat||(e.IndexFormat={}))[tx.UInt8=0]="UInt8",tx[tx.UInt16=1]="UInt16",tx[tx.UInt32=2]="UInt32";var cr=((tT=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}},tT._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tT._getElementInfo=function(t){var n,r,i=!1;switch(t){case e.VertexElementFormat.Float:n=1,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:n=2,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:n=3,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:n=4,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:n=4,r=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:n=4,r=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:n=4,r=e.DataType.BYTE,i=!0;break;case e.VertexElementFormat.NormalizedUByte4:n=4,r=e.DataType.UNSIGNED_BYTE,i=!0;break;case e.VertexElementFormat.Short2:n=2,r=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:n=2,r=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:n=2,r=e.DataType.SHORT,i=!0;break;case e.VertexElementFormat.NormalizedUShort2:n=2,r=e.DataType.UNSIGNED_SHORT,i=!0;break;case e.VertexElementFormat.Short4:n=4,r=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:n=4,r=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:n=4,r=e.DataType.SHORT,i=!0;break;case e.VertexElementFormat.NormalizedUShort4:n=4,r=e.DataType.UNSIGNED_SHORT,i=!0}return{size:n,type:r,normalized:i}},tT),ci=(s1(tC=function(e,t,n,r,i){void 0===i&&(i=0),this._semantic=e,this._offset=t,this._format=n,this._bindingIndex=r,this._glElementInfo=cr._getElementInfo(this.format),this._instanceStepRate=Math.floor(i)},[{key:"semantic",get:function(){return this._semantic}},{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}}]),tC);e.BufferUsage=void 0,(tS=e.BufferUsage||(e.BufferUsage={}))[tS.Static=0]="Static",tS[tS.Dynamic=1]="Dynamic",tS[tS.Stream=2]="Stream",e.SetDataOptions=void 0,(tA=e.SetDataOptions||(e.SetDataOptions={}))[tA.None=0]="None",tA[tA.Discard=1]="Discard";var ca=(s3(tw=function(t,n,r,i){if(void 0===i&&(i=e.BufferUsage.Static),(a=lo.call(this,t)||this)._engine=t,a._type=n,a._bufferUsage=i,"number"==typeof r)a._byteLength=r,a._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,r,i);else{var a,o=r.byteLength;a._byteLength=o,a._platformBuffer=t._hardwareRenderer.createPlatformBuffer(n,o,i,r)}return a},lo),(tE=tw.prototype).bind=function(){this._platformBuffer.bind()},tE.setData=function(t,n,r,i,a){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,n,r,i,a)},tE.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},tE._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},tE._onDestroy=function(){lo.prototype._onDestroy.call(this),this._platformBuffer.destroy()},tE.resize=function(e){this._platformBuffer.resize(e),this._byteLength=e},s1(tw,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),tw);e.BufferBindFlag=void 0,(tM=e.BufferBindFlag||(e.BufferBindFlag={}))[tM.VertexBuffer=0]="VertexBuffer",tM[tM.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(tb=e.MeshTopology||(e.MeshTopology={}))[tb.Points=0]="Points",tb[tb.Lines=1]="Lines",tb[tb.LineLoop=2]="LineLoop",tb[tb.LineStrip=3]="LineStrip",tb[tb.Triangles=4]="Triangles",tb[tb.TriangleStrip=5]="TriangleStrip",tb[tb.TriangleFan=6]="TriangleFan";var co=(s1(tF=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tF),cs=function(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=e.MeshTopology.Triangles),this.start=t,this.count=n,this.topology=r},cl=(s3(tR=function(e,t){(n=lo.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new lI,n._bounds=new sz,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(s$(n)),n._onBoundsChanged=n._onBoundsChanged.bind(s$(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},lo),(tP=tR.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new cs(t,n,r)),this._subMeshes.push(t),t},tP.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},tP.clearSubMesh=function(){this._subMeshes.length=0},tP._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},tP._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tP._insertVertexElement=function(e,t){var n=t.semantic;this._vertexElementMap[n]=t,this._vertexElements.splice(e,0,t),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tP._setVertexBufferBinding=function(e,t){if(this._getReferCount()>0){var n=this._vertexBufferBindings[e];n&&n._buffer._addReferCount(-1),t._buffer._addReferCount(1)}this._vertexBufferBindings[e]=t,this._bufferStructChanged=!0},tP._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tP._addReferCount=function(e){lo.prototype._addReferCount.call(this,e);for(var t=this._vertexBufferBindings,n=0,r=t.length;n<r;n++)t[n]._buffer._addReferCount(e)},tP._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this)},tP._onDestroy=function(){lo.prototype._onDestroy.call(this),this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},tP._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},tP._setIndexBufferBinding=function(e){var t=this._indexBufferBinding;e?(this._indexBufferBinding=e,this._glIndexType=cr._getGLIndexType(e.format),this._glIndexByteCount=cr._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},tP._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},s1(tR,[{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}}]),tR);(tL=o9||(o9={}))[tL.Bounds=1]="Bounds",tL[tL.VertexElements=2]="VertexElements";var cc=(s1(tD=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tD),cu=((tB=(tI=function(e,t){this._blendShapeCount=0,this._blendShapes=[],this._subDataDirtyFlags=[],this._vertexBuffers=[],this._uniformOccupiesCount=0,this._useBlendNormal=!1,this._useBlendTangent=!1,this._vertexElementCount=0,this._storeInVertexBufferInfo=[],this._maxCountSingleVertexBuffer=0,this._lastCreateHostInfo=new sO(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sO,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(lD))},tB._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,i=0,a=r.length;i<a;i++)r[i].destroy();r.length=0},tB._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(tI._blendShapeMacro),this._useTextureMode())e.enableMacro(tI._blendShapeTextureMacro),e.setTexture(tI._blendShapeTextureProperty,this._vertexTexture),e.setVector3(tI._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(tI._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",n.toString()),this._uniformOccupiesCount=n+1;else{var r=this._getVertexBufferModeSupportCount();if(n>r){var i=t._condensedBlendShapeWeights;i||(i=new Float32Array(r),t._condensedBlendShapeWeights=i),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,i),e.setFloatArray(tI._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(tI._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(tI._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(tI._blendShapeNormalMacro):e.disableMacro(tI._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(tI._blendShapeTangentMacro):e.disableMacro(tI._blendShapeTangentMacro)}else e.disableMacro(tI._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},tB._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},tB._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},tB._vertexElementsNeedUpdate=function(){var e=this._getVertexBufferModeSupportCount(),t=this._lastCreateHostInfo;return Math.min(t.x,e)!==Math.min(this._blendShapeCount,e)||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent},tB._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},tB._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},tB._addVertexElements=function(t){for(var n=this._bufferBindingOffset,r=0,i=0,a=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<a;i++)t._addVertexElement(new ci("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new ci("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new ci("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},tB._update=function(e,t){var n=this._modelMesh.vertexCount,r=this._useTextureMode(),i=this._layoutOrCountChange()||e;i&&(r?this._createTextureArray(n):this._createVertexBuffers(n,t),this._lastCreateHostInfo.set(this._blendShapeCount,+this._useBlendNormal,+this._useBlendTangent)),this._needUpdateData()&&(r?this._updateTextureArray(n,i):this._updateVertexBuffers(n,i))},tB._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},tB._createVertexBuffers=function(t,n){var r=this._engine,i=this._modelMesh,a=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,c=Math.floor(255/l),u=Math.ceil(a/c);o.length=u,this._vertices=new Float32Array(s*t*Math.min(c,a)),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=a;for(var h=this._bufferBindingOffset,d=0;d<u;d++){var _=u-1,f=(d===_?a-_*c:c)*l,p=f*t,g=n?e.BufferUsage.Static:e.BufferUsage.Dynamic,m=new ca(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new cc(m,f)),o[d]=m}},tB._createTextureArray=function(t){var n=this._engine._hardwareRenderer.capability.maxTextureSize,r=this._vertexElementCount,i=r*t,a=1;i>n&&(a=Math.ceil(i/n),i=n);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new lg(this._engine,i,a,s,e.TextureFormat.R32G32B32A32,!1)).filterMode=e.TextureFilterMode.Point,this._vertices=new Float32Array(s*i*a*4),this._vertexTexture=o,this._dataTextureInfo.set(r,i,a)},tB._updateVertexBuffers=function(e,t){for(var n=this._blendShapes,r=this._maxCountSingleVertexBuffer,i=this._vertices,a=this._vertexBuffers,o=this._storeInVertexBufferInfo,s=this._subDataDirtyFlags,l=3*this._vertexElementCount,c=4*l,u=this._bufferBindingOffset,h=0,d=n.length;h<d;h++){var _=s[h];if(t||_.flag){var f=n[h].frames,p=f.length,g=f[p-1];if(p>0&&g.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var m=Math.floor(h/r),v=h%r,y=a[m],x=y.byteLength/(4*e),T=v*l,C=o[h];C||(o[h]=C=new sq),C.set(u+m,v*c);for(var S=g.deltaPositions,A=0;A<e;A++){var w=T+x*A,E=S[A];E&&(i[w]=E.x,i[w+1]=E.y,i[w+2]=E.z)}if(T+=3,this._useBlendNormal){var M=g.deltaNormals;if(M)for(var b=0;b<e;b++){var F=T+x*b,R=M[b];R&&(i[F]=R.x,i[F+1]=R.y,i[F+2]=R.z)}T+=3}if(this._useBlendTangent){var P=g.deltaTangents;if(P)for(var L=0;L<e;L++){var D=T+x*L,I=P[L];I&&(i[D]=I.x,i[D+1]=I.y,i[D+2]=I.z)}T+=3}(v===r-1||h===d-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},tB._updateTextureArray=function(e,t){for(var n=this._blendShapes,r=this._vertexTexture,i=this._vertices,a=this._subDataDirtyFlags,o=0,s=n.length;o<s;o++){var l=a[o],c=r.width*r.height*4;if(t||l.flag){var u=n[o].frames,h=u.length,d=u[h-1];if(h>0&&d.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=d.deltaPositions,f=d.deltaNormals,p=d.deltaTangents,g=o*c,m=0;m<e;m++){var v=_[m];if(i[g]=v.x,i[g+1]=v.y,i[g+2]=v.z,g+=4,f){var y=f[m];i[g]=y.x,i[g+1]=y.y,i[g+2]=y.z,g+=4}if(p){var x=p[m];i[g]=x.x,i[g+1]=x.y,i[g+2]=x.z,g+=4}}l.flag=!1}}r.setPixelBuffer(0,i)},tB._updateLayoutChange=function(e,t){var n=this._blendShapeCount>1,r=1,i=t._useBlendShapeNormal,a=t._useBlendShapeTangent;n&&(i&&(i=this._useBlendNormal),a&&(a=this._useBlendTangent)),i&&r++,a&&r++,this._useBlendNormal=i,this._useBlendTangent=a,this._vertexElementCount=r},tB._attributeModeUpdateVertexElement=function(e,t,n,r){var i=this._vertexElementOffset+this._vertexElementCount*r,a=t[n],o=a.x,s=a.y,l=e[i];if(l.bindingIndex=o,l.offset=s,this._useBlendNormal){var c=e[++i];s+=12,c.bindingIndex=o,c.offset=s}if(this._useBlendTangent){var u=e[++i];s+=12,u.bindingIndex=o,u.offset=s}},tB._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},tB._filterCondensedBlendShapeWeights=function(e,t){for(var n,r=t.length,i=this._modelMesh._vertexElements,a=this._storeInVertexBufferInfo,o=Number.POSITIVE_INFINITY,s=0,l=Math.min(e.length,this._blendShapeCount);s<l;s++){var c=e[s];if(s<r)this._attributeModeUpdateVertexElement(i,a,s,s),t[s]=c,c<o&&(o=c,n=s);else if(c>o){this._attributeModeUpdateVertexElement(i,a,s,n),t[n]=c,o=Number.POSITIVE_INFINITY;for(var u=0;u<r;u++){var h=t[u];h<o&&(o=h,n=u)}}}},tI);cu._blendShapeMacro=lk.getByName("RENDERER_HAS_BLENDSHAPE"),cu._blendShapeTextureMacro=lk.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),cu._blendShapeNormalMacro=lk.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),cu._blendShapeTangentMacro=lk.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),cu._blendShapeWeightsProperty=lS.getByName("renderer_BlendShapeWeights"),cu._blendShapeTextureProperty=lS.getByName("renderer_BlendShapeTexture"),cu._blendShapeTextureInfoProperty=lS.getByName("renderer_BlendShapeTextureInfo"),(tN=se||(se={})).Position="POSITION",tN.Normal="NORMAL",tN.Color="COLOR_0",tN.Tangent="TANGENT",tN.BoneWeight="WEIGHTS_0",tN.BoneIndex="JOINTS_0",tN.UV="TEXCOORD_0",tN.UV1="TEXCOORD_1",tN.UV2="TEXCOORD_2",tN.UV3="TEXCOORD_3",tN.UV4="TEXCOORD_4",tN.UV5="TEXCOORD_5",tN.UV6="TEXCOORD_6",tN.UV7="TEXCOORD_7";var ch=(s3(tV=function(e,t){var n;return(n=cl.call(this,e)||this)._vertexCount=0,n._readable=!0,n._verticesFloat32=null,n._verticesUint8=null,n._indices=null,n._indicesFormat=null,n._indicesChangeFlag=!1,n._positions=null,n._normals=null,n._colors=null,n._tangents=null,n._uv=null,n._uv1=null,n._uv2=null,n._uv3=null,n._uv4=null,n._uv5=null,n._uv6=null,n._uv7=null,n._boneWeights=null,n._boneIndices=null,n._bufferStrides=[],n._vertexBufferUpdateFlag=0,n._vertexDataUpdateFlag=0,n._vertexElementsUpdate=!1,n._customVertexElements=[],n._vertexCountChanged=!1,n.name=t,n._blendShapeManager=new cu(e,s$(n)),n},cl),(tO=tV.prototype).setPositions=function(e){if(this._positions||e){var t=(null==e?void 0:e.length)||0;this._vertexCountChanged=this._vertexCount!=t,this._vertexCount=t,this._vertexElementsUpdate=!!this._positions!=!!e,this._vertexBufferUpdateFlag|=1,this._vertexDataUpdateFlag&=-2,this._positions=e}},tO.getPositions=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._positions},tO.setNormals=function(e){if(e){if(e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count."}else if(!this._normals)return;this._vertexElementsUpdate=!!this._normals!=!!e,this._vertexBufferUpdateFlag|=2,this._vertexDataUpdateFlag&=-3,this._normals=e},tO.getNormals=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._normals},tO.setColors=function(e){if(e){if(e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count."}else if(!this._colors)return;this._vertexElementsUpdate=!!this._colors!=!!e,this._vertexBufferUpdateFlag|=4,this._vertexDataUpdateFlag&=-5,this._colors=e},tO.getColors=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._colors},tO.setBoneWeights=function(e){if(e){if(e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count."}else if(!this._boneWeights)return;this._vertexElementsUpdate=!!this._boneWeights!=!!e,this._vertexBufferUpdateFlag|=16,this._vertexDataUpdateFlag&=-17,this._boneWeights=e},tO.getBoneWeights=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneWeights},tO.setBoneIndices=function(e){if(e){if((null==e?void 0:e.length)!==this._vertexCount)throw"The array provided needs to be the same size as vertex count."}else if(!this._boneIndices)return;this._vertexElementsUpdate=!!this._boneIndices!=!!e,this._vertexBufferUpdateFlag|=32,this._vertexDataUpdateFlag&=-33,this._boneIndices=e},tO.getBoneIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneIndices},tO.setTangents=function(e){if(e){if(e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count."}else if(!this._tangents)return;this._vertexElementsUpdate=!!this._tangents!=!!e,this._vertexBufferUpdateFlag|=8,this._vertexDataUpdateFlag&=-9,this._tangents=e},tO.getTangents=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._tangents},tO.setUVs=function(e,t){if(e&&e.length!==this._vertexCount)throw"The array provided needs to be the same size as vertex count.";switch(t=null!=t?t:0){case 0:if(!this._uv&&!e)return;this._vertexElementsUpdate=!!this._uv!=!!e,this._vertexBufferUpdateFlag|=64,this._vertexDataUpdateFlag&=-65,this._uv=e;break;case 1:if(!this._uv1&&!e)return;this._vertexElementsUpdate=!!this._uv1!=!!e,this._vertexBufferUpdateFlag|=128,this._vertexDataUpdateFlag&=-129,this._uv1=e;break;case 2:if(!this._uv2&&!e)return;this._vertexElementsUpdate=!!this._uv2!=!!e,this._vertexBufferUpdateFlag|=256,this._vertexDataUpdateFlag&=-257,this._uv2=e;break;case 3:if(!this._uv3&&!e)return;this._vertexElementsUpdate=!!this._uv3!=!!e,this._vertexBufferUpdateFlag|=512,this._vertexDataUpdateFlag&=-513,this._uv3=e;break;case 4:if(!this._uv4&&!e)return;this._vertexElementsUpdate=!!this._uv4!=!!e,this._vertexBufferUpdateFlag|=1024,this._vertexDataUpdateFlag&=-1025,this._uv4=e;break;case 5:if(!this._uv5&&!e)return;this._vertexElementsUpdate=!!this._uv5!=!!e,this._vertexBufferUpdateFlag|=2048,this._vertexDataUpdateFlag&=-2049,this._uv5=e;break;case 6:if(!this._uv6&&!e)return;this._vertexElementsUpdate=!!this._uv6!=!!e,this._vertexBufferUpdateFlag|=4096,this._vertexDataUpdateFlag&=-4097,this._uv6=e;break;case 7:if(!this._uv7&&!e)return;this._vertexElementsUpdate=!!this._uv7!=!!e,this._vertexBufferUpdateFlag|=8192,this._vertexDataUpdateFlag&=-8193,this._uv7=e;break;default:throw"The index of channel needs to be in range [0 - 7]."}},tO.getUVs=function(e){if(!this._readable)throw"Not allowed to access data while accessible is false.";switch(e=null!=e?e:0){case 0:return this._uv;case 1:return this._uv1;case 2:return this._uv2;case 3:return this._uv3;case 4:return this._uv4;case 5:return this._uv5;case 6:return this._uv6;case 7:return this._uv7}throw"The index of channel needs to be in range [0 - 7]."},tO.setIndices=function(t){this._indices!==t&&(this._indices=t,s6(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:s6(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:s6(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},tO.getIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._indices},tO.setVertexElements=function(e){var t=this._customVertexElements;t.length=0;for(var n={},r=0,i=e.length;r<i;r++){var a=e[r];t.push(a),n[a.semantic]=a}n[se.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[se.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[se.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[se.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[se.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[se.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[se.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[se.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[se.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[se.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[se.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[se.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[se.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[se.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},tO.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,i=void 0!==r.buffer;i||(r=new cc(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},tO.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._vertexBufferBindings,r=e.length,i=t+r;n.length<i&&(n.length=i);for(var a=0;a<r;a++)this._setVertexBufferBinding(t+a,e[a])},tO.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},tO.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},tO.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},tO.uploadData=function(t){this._updateVertexElements();var n=null==(u=this._vertexBufferBindings[0])?void 0:u._buffer;if(this._vertexCountChanged){this._vertexBufferUpdateFlag=65535,null==n||n.destroy();var r=this._bufferStrides[0]/4,i=r*this.vertexCount,a=new Float32Array(i);this._verticesFloat32=a,this._verticesUint8=new Uint8Array(a.buffer),this._updateVertices(a);var o=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,s=new ca(this._engine,e.BufferBindFlag.VertexBuffer,a,o);this._setVertexBufferBinding(0,new cc(s,4*r)),this._vertexCountChanged=!1}else if(65535&this._vertexBufferUpdateFlag){var l=this._verticesFloat32;if(!l){var c=this._bufferStrides[0]/4*this.vertexCount;this._verticesFloat32=l=new Float32Array(c)}this._updateVertices(l),n.setData(l)}if(this._indicesChangeFlag){var u,h,d=this._indices,_=null==(h=this._indexBufferBinding)?void 0:h._buffer;if(d){if(_&&d.byteLength==_.byteLength)_.setData(d),this._indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new co(_,this._indicesFormat));else{null==_||_.destroy();var f=new ca(this._engine,e.BufferBindFlag.IndexBuffer,d);this._setIndexBufferBinding(new co(f,this._indicesFormat))}}else _&&(_.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var p=this._blendShapeManager;p._blendShapeCount>0&&p._update(this._vertexCountChanged,t),t&&(this._readable=!1,this._releaseCache())},tO.calculateTangents=function(){if(!this._normals||!this._uv)throw"Set normal and uv before calculation.";for(var e=this._indices,t=this._positions,n=this._normals,r=this._uv,i=this._vertexCount,a=tV._tempVec0,o=tV._tempVec1,s=tV._tempVec2,l=tV._tempVec3,c=tV._tempVec4,u=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new sY,d[_]=new sO;for(var f=0;f<u;f++){var p=3*f,g=3*f+1,m=3*f+2;e&&(p=e[p],g=e[g],m=e[m]);var v=t[p],y=t[g],x=t[m],T=r[p],C=r[g],S=r[m];sO.subtract(y,v,a),sO.subtract(x,v,o);var A=C.x-T.x,w=S.x-T.x,E=C.y-T.y,M=S.y-T.y,b=1/(A*M-w*E);sO.scale(a,M*b,s),sO.scale(o,E*b,c),sO.subtract(s,c,s),sO.scale(o,A*b,l),sO.scale(a,w*b,c),sO.subtract(l,c,l);var F=h[p];F.set(F.x+s.x,F.y+s.y,F.z+s.z,1),(F=h[g]).set(F.x+s.x,F.y+s.y,F.z+s.z,1),(F=h[m]).set(F.x+s.x,F.y+s.y,F.z+s.z,1),d[p].add(l),d[g].add(l),d[m].add(l)}for(var R=0;R<i;R++){var P=n[R],L=d[R],D=h[R];s.set(D.x,D.y,D.z),sO.cross(s,L,c);var I=sO.dot(c,P)>0?1:-1;sO.scale(P,sO.dot(s,P),c),sO.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,I)}this.setTangents(h)},tO._onDestroy=function(){cl.prototype._onDestroy.call(this),this._readable&&this._releaseCache()},tO._supplementaryVertexElements=function(){this._clearVertexElements();for(var e=this._customVertexElements,t=0,n=e.length;t<n;t++)this._addVertexElement(e[t]);var r=this._vertexElementMap;this._positions&&!r[se.Position]&&this._insertVertexAttribute(se.Position),this._normals&&!r[se.Normal]&&this._insertVertexAttribute(se.Normal),this._colors&&!r[se.Color]&&this._insertVertexAttribute(se.Color),this._boneWeights&&!r[se.BoneWeight]&&this._insertVertexAttribute(se.BoneWeight),this._boneIndices&&!r[se.BoneIndex]&&this._insertVertexAttribute(se.BoneIndex),this._tangents&&!r[se.Tangent]&&this._insertVertexAttribute(se.Tangent),this._uv&&!r[se.UV]&&this._insertVertexAttribute(se.UV),this._uv1&&!r[se.UV1]&&this._insertVertexAttribute(se.UV1),this._uv2&&!r[se.UV2]&&this._insertVertexAttribute(se.UV2),this._uv3&&!r[se.UV3]&&this._insertVertexAttribute(se.UV3),this._uv4&&!r[se.UV4]&&this._insertVertexAttribute(se.UV4),this._uv5&&!r[se.UV5]&&this._insertVertexAttribute(se.UV5),this._uv6&&!r[se.UV6]&&this._insertVertexAttribute(se.UV6),this._uv7&&!r[se.UV7]&&this._insertVertexAttribute(se.UV7)},tO._updateVertexElements=function(){var e=this._blendShapeManager,t=!e._useTextureMode()&&e._vertexElementsNeedUpdate();(this._vertexElementsUpdate||t)&&(this._supplementaryVertexElements(),t&&e._blendShapeCount>0&&(e._setAttributeModeOffsetInfo(this._vertexElements.length,this._vertexBufferBindings.length||1),e._addVertexElements(this)),this._vertexElementsUpdate=!1)},tO._updateVertices=function(e){var t=this._bufferStrides,n=this._vertexCount,r=this._positions,i=this._normals,a=this._colors,o=this._vertexBufferUpdateFlag,s=this._boneWeights,l=this._boneIndices,c=this._tangents,u=this._uv,h=this._uv1,d=this._uv2,_=this._uv3,f=this._uv4,p=this._uv5,g=this._uv6,m=this._uv7,v=t[0]/4;if(1&o)for(var y=0;y<n;y++){var x=v*y,T=r[y];e[x]=T.x,e[x+1]=T.y,e[x+2]=T.z}var C=3;if(i){if(2&o)for(var S=0;S<n;S++){var A=v*S+C,w=i[S];w&&(e[A]=w.x,e[A+1]=w.y,e[A+2]=w.z)}C+=3}if(a){if(4&o)for(var E=0;E<n;E++){var M=v*E+C,b=a[E];b&&(e[M]=b.r,e[M+1]=b.g,e[M+2]=b.b,e[M+3]=b.a)}C+=4}if(s){if(16&o)for(var F=0;F<n;F++){var R=v*F+C,P=s[F];P&&(e[R]=P.x,e[R+1]=P.y,e[R+2]=P.z,e[R+3]=P.w)}C+=4}if(l){if(32&o)for(var L=this._verticesUint8,D=0;D<n;D++){var I=v*D+C,B=l[D];if(B){var N=4*I;L[N]=B.x,L[N+1]=B.y,L[N+2]=B.z,L[N+3]=B.w}}C+=1}if(c){if(8&o)for(var V=0;V<n;V++){var O=v*V+C,U=c[V];U&&(e[O]=U.x,e[O+1]=U.y,e[O+2]=U.z,e[O+3]=U.w)}C+=4}if(u){if(64&o)for(var z=0;z<n;z++){var k=v*z+C,G=u[z];G&&(e[k]=G.x,e[k+1]=G.y)}C+=2}if(h){if(128&o)for(var H=0;H<n;H++){var W=v*H+C,X=h[H];X&&(e[W]=X.x,e[W+1]=X.y)}C+=2}if(d){if(256&o)for(var K=0;K<n;K++){var j=v*K+C,q=d[K];q&&(e[j]=q.x,e[j+1]=q.y)}C+=2}if(_){if(512&o)for(var Y=0;Y<n;Y++){var Q=v*Y+C,J=_[Y];J&&(e[Q]=J.x,e[Q+1]=J.y)}C+=2}if(f){if(1024&o)for(var Z=0;Z<n;Z++){var $=v*Z+C,ee=f[Z];ee&&(e[$]=ee.x,e[$+1]=ee.y)}C+=2}if(p){if(2048&o)for(var et=0;et<n;et++){var en=v*et+C,er=p[et];er&&(e[en]=er.x,e[en+1]=er.y)}C+=2}if(g){if(4096&o)for(var ei=0;ei<n;ei++){var ea=v*ei+C,eo=g[ei];eo&&(e[ea]=eo.x,e[ea+1]=eo.y)}C+=2}if(m){if(8192&o)for(var es=0;es<n;es++){var el=v*es+C,ec=m[es];ec&&(e[el]=ec.x,e[el+1]=ec.y)}C+=2}this._vertexBufferUpdateFlag=0},tO._insertVertexAttribute=function(e){for(var t=this._getAttributeFormat(e),n=this._getAttributeByteLength(e),r=this._vertexElements,i=0,a=0,o=r.length;i<o;i++){var s=r[i];if(0==s.bindingIndex){if(s.offset-a>=n)break;a=s.offset+this._getAttributeByteLength(s.semantic)}}this._insertVertexElement(i,new ci(e,a,t,0)),this._bufferStrides[0]=a+n},tO._getAttributeFormat=function(t){switch(t){case se.Position:case se.Normal:return e.VertexElementFormat.Vector3;case se.Color:case se.BoneWeight:return e.VertexElementFormat.Vector4;case se.BoneIndex:return e.VertexElementFormat.UByte4;case se.Tangent:return e.VertexElementFormat.Vector4;case se.UV:case se.UV1:case se.UV2:case se.UV3:case se.UV4:case se.UV5:case se.UV6:case se.UV7:return e.VertexElementFormat.Vector2}},tO._getAttributeByteLength=function(e){switch(e){case se.Position:case se.Normal:return 12;case se.Color:case se.BoneWeight:return 16;case se.BoneIndex:return 4;case se.Tangent:return 16;case se.UV:case se.UV1:case se.UV2:case se.UV3:case se.UV4:case se.UV5:case se.UV6:case se.UV7:return 8}},tO._releaseCache=function(){this._verticesUint8=null,this._indices=null,this._verticesFloat32=null,this._positions=null,this._tangents=null,this._normals=null,this._colors=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._blendShapeManager._releaseMemoryCache()},s1(tV,[{key:"readable",get:function(){return this._readable}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[se.Position];if(t){var n=this._vertexBufferBindings[t.bindingIndex];n&&(e=n.buffer.byteLength/n.stride)}this._vertexCount=e,this._vertexDataUpdateFlag&=-2}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._vertexElements}},{key:"vertexBufferBindings",get:function(){return this._vertexBufferBindings}},{key:"blendShapes",get:function(){return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}}]),tV);ch._tempVec0=new sO,ch._tempVec1=new sO,ch._tempVec2=new sO,ch._tempVec3=new sO,ch._tempVec4=new sO,(tU=st||(st={}))[tU.Position=1]="Position",tU[tU.Normal=2]="Normal",tU[tU.Color=4]="Color",tU[tU.Tangent=8]="Tangent",tU[tU.BoneWeight=16]="BoneWeight",tU[tU.BoneIndex=32]="BoneIndex",tU[tU.UV=64]="UV",tU[tU.UV1=128]="UV1",tU[tU.UV2=256]="UV2",tU[tU.UV3=512]="UV3",tU[tU.UV4=1024]="UV4",tU[tU.UV5=2048]="UV5",tU[tU.UV6=4096]="UV6",tU[tU.UV7=8192]="UV7",tU[tU.All=65535]="All";var cd=(s3(tz=function(e){var t;return(t=lr.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},lr),tz),c_=(tk=e.Renderer,s3(tG=function(e){var t;return(t=tk.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(s$(t)),t},tk),(tH=tG.prototype)._onDestroy=function(){tk.prototype._onDestroy.call(this);var e=this._mesh;e&&!e.destroyed&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},tH._cloneTo=function(e){tk.prototype._cloneTo.call(this,e),e.mesh=this._mesh},tH._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sz.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tH._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(tG._uvMacro),n.disableMacro(tG._uv1Macro),n.disableMacro(tG._normalMacro),n.disableMacro(tG._tangentMacro),n.disableMacro(tG._enableVertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(tG._uvMacro);break;case"TEXCOORD_1":n.enableMacro(tG._uv1Macro);break;case"NORMAL":n.enableMacro(tG._normalMacro);break;case"TANGENT":n.enableMacro(tG._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&n.enableMacro(tG._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._meshRenderDataPool,u=0,h=s.length;u<h;u++){var d=o[u];if(d){var _=c.getFromPool();_.set(this,d,t,s[u]),l.pushRenderData(e,_)}}}else ld.error("mesh is null.")},tH._setMesh=function(e){var t=this._mesh;t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tH._onMeshChanged=function(e){e&o9.Bounds&&(this._dirtyUpdateFlag|=o5.WorldVolume),e&o9.VertexElements&&(this._dirtyUpdateFlag|=2)},s1(tG,[{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)}}]),tG);c_._uvMacro=lk.getByName("RENDERER_HAS_UV"),c_._uv1Macro=lk.getByName("RENDERER_HAS_UV1"),c_._normalMacro=lk.getByName("RENDERER_HAS_NORMAL"),c_._tangentMacro=lk.getByName("RENDERER_HAS_TANGENT"),c_._enableVertexColorMacro=lk.getByName("RENDERER_ENABLE_VERTEXCOLOR"),s8([s7],c_.prototype,"_mesh",void 0),s8([s7],c_.prototype,"_onMeshChanged",null),(tW=sn||(sn={}))[tW.VertexElementMacro=2]="VertexElementMacro",tW[tW.All=3]="All";var cf=(s3(tX=function(e){(t=c_.call(this,e)||this)._hasInitSkin=!1,t._jointDataCreateCache=new sq(-1,-1),t._localBounds=new sz,t._skin=null;var t,n=t.entity.engine._hardwareRenderer,r=n.renderStates.getParameter(n.gl.MAX_VERTEX_UNIFORM_VECTORS);r=Math.min(r,256),t._maxVertexUniformVectors=r,t._onLocalBoundsChanged=t._onLocalBoundsChanged.bind(s$(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},c_),(tK=tX.prototype).update=function(){this._hasInitSkin||(this._initSkin(),this._hasInitSkin=!0);var e=this._skin;if(e)for(var t=e.inverseBindMatrices,n=this._rootBone.getInvModelMatrix(),r=this._jointEntities,i=this._jointMatrices,a=r.length-1;a>=0;a--){var o=r[a],s=16*a;o?lF._floatMatrixMultiply(o.transform.worldMatrix,t[a].elements,0,i,s):i.set(t[a].elements,s),lF._floatMatrixMultiply(n,i,s,i,s)}},tK._updateShaderData=function(t){var n=this.entity,r=this._rootBone?this._rootBone.transform.worldMatrix:n.transform.worldMatrix;this._updateTransformShaderData(t,r);var i=this.shaderData,a=this.mesh._blendShapeManager;a._updateShaderData(i,this);var o=this._skin;if(o){var s=a._uniformOccupiesCount,l=o.joints.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var h,d=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>d){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new lp(f,4,l,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),i.disableMacro("RENDERER_JOINTS_NUM"),i.enableMacro("RENDERER_USE_JOINT_TEXTURE"),i.setTexture(tX._jointSamplerProperty,this._jointTexture)):ld.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 "+d+".",this)}else null==(h=this._jointTexture)||h.destroy(),i.disableMacro("RENDERER_USE_JOINT_TEXTURE"),i.enableMacro("RENDERER_JOINTS_NUM",d.toString()),i.setFloatArray(tX._jointMatrixProperty,this._jointMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var p=n.layer;this._rendererLayer.set(65535&p,p>>>16&65535,0,0)},tK._onDestroy=function(){var e,t;c_.prototype._onDestroy.call(this),null==(e=this.rootBone)||e.transform._updateFlagManager.removeListener(this._onTransformChanged),null==(t=this._jointTexture)||t.destroy()},tK._cloneTo=function(e){c_.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},tK._registerEntityTransformListener=function(){},tK._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sz.transform(t,n,e)}else c_.prototype._updateBounds.call(this,e)},tK._initSkin=function(){if(this.entity.engine._hardwareRenderer){var e=this._skin,t=this.shaderData;if(!e){t.disableMacro("RENDERER_HAS_SKIN");return}for(var n=e.joints,r=n.length,i=Array(r),a=r-1;a>=0;a--)i[a]=this._findByEntityName(this.entity,n[a]);this._jointEntities=i,this._jointMatrices=new Float32Array(16*r);var o=this._rootBone,s=this._findByEntityName(this.entity,e.skeleton);o&&o.transform._updateFlagManager.removeListener(this._onTransformChanged),s.transform._updateFlagManager.addListener(this._onTransformChanged);var l=n.indexOf(e.skeleton);if(-1!==l)sz.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var c=new sK(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),u=this._computeApproximateBindMatrix(i,e.inverseBindMatrices,s,c);0!==u?(sK.multiplyScalar(c,1/u,c),sz.transform(this._mesh.bounds,c,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("RENDERER_HAS_SKIN"),t.setInt(tX._jointCountProperty,r)):t.disableMacro("RENDERER_HAS_SKIN")}},tK._computeApproximateBindMatrix=function(e,t,n,r){for(var i=0,a=n.children,o=0,s=a.length;o<s;o++){var l=a[o],c=e.indexOf(l);-1!==c?(sK.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},tK._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},tK._checkBlendShapeWeightLength=function(){var e=this._mesh,t=e?e.blendShapeCount:0,n=this._blendShapeWeights;if(n){var r=n.length;if(r!==t){var i=new Float32Array(t);if(t>r)i.set(n);else for(var a=0;a<t;a++)i[a]=n[a];this._blendShapeWeights=i}}else this._blendShapeWeights=new Float32Array(t)},tK._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=o5.WorldVolume},s1(tX,[{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:"skin",get:function(){return this._skin},set:function(e){this._skin!==e&&(this._skin=e,this._hasInitSkin=!1)}},{key:"localBounds",get:function(){return this._localBounds},set:function(e){this._localBounds!==e&&this._localBounds.copyFrom(e)}},{key:"rootBone",get:function(){return this._rootBone},set:function(e){this._skin.skeleton=e.name,this._hasInitSkin=!1,this._dirtyUpdateFlag|=o5.WorldVolume}}]),tX);cf._jointCountProperty=lS.getByName("renderer_JointCount"),cf._jointSamplerProperty=lS.getByName("renderer_JointSampler"),cf._jointMatrixProperty=lS.getByName("renderer_JointMatrix"),s8([s7],cf.prototype,"_hasInitSkin",void 0),s8([s7],cf.prototype,"_jointDataCreateCache",void 0),s8([s7],cf.prototype,"_blendShapeWeights",void 0),s8([s7],cf.prototype,"_maxVertexUniformVectors",void 0),s8([s7],cf.prototype,"_rootBone",void 0),s8([s7],cf.prototype,"_localBounds",void 0),s8([s7],cf.prototype,"_jointMatrices",void 0),s8([s7],cf.prototype,"_jointTexture",void 0),s8([s7],cf.prototype,"_jointEntities",void 0),s8([s7],cf.prototype,"_condensedBlendShapeWeights",void 0),s8([s7],cf.prototype,"_onLocalBoundsChanged",null);var cp=(s3(tj=function(e,t){var n;return(n=la.call(this,e)||this).primitiveInfo=t,n},la),tj.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:cA._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0);break;case 1:cA._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0);break;case 2:cA._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0);break;case 3:cA._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 4:cA._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0);break;case 5:cA._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 6:cA._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0)}},tj);(tq=sr||(sr={}))[tq.Sphere=0]="Sphere",tq[tq.Cuboid=1]="Cuboid",tq[tq.Plane=2]="Plane",tq[tq.Cylinder=3]="Cylinder",tq[tq.Torus=4]="Torus",tq[tq.Cone=5]="Cone",tq[tq.Capsule=6]="Capsule";var cg=function(e,t){this.type=e,this.noLongerAccessible=t},cm=(s3(tY=function(e,t,n){var r;return(r=cg.call(this,0,n)||this).radius=e,r.segments=t,r},cg),tY),cv=(s3(tQ=function(e,t,n,r){var i;return(i=cg.call(this,1,r)||this).width=e,i.height=t,i.depth=n,i},cg),tQ),cy=(s3(tJ=function(e,t,n,r,i){var a;return(a=cg.call(this,2,i)||this).width=e,a.height=t,a.horizontalSegments=n,a.verticalSegments=r,a},cg),tJ),cx=(s3(tZ=function(e,t,n,r,i,a){var o;return(o=cg.call(this,3,a)||this).radiusTop=e,o.radiusBottom=t,o.height=n,o.radialSegments=r,o.heightSegments=i,o},cg),tZ),cT=(s3(t$=function(e,t,n,r,i,a){var o;return(o=cg.call(this,4,a)||this).radius=e,o.tubeRadius=t,o.radialSegments=n,o.tubularSegments=r,o.arc=i,o},cg),t$),cC=(s3(t0=function(e,t,n,r,i){var a;return(a=cg.call(this,5,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},cg),t0),cS=(s3(t1=function(e,t,n,r,i){var a;return(a=cg.call(this,6,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},cg),t1),cA=((t2=function(){}).createSphere=function(e,t,n,r){void 0===t&&(t=.5),void 0===n&&(n=18),void 0===r&&(r=!0);var i=new ch(e);return t2._setSphereData(i,t,n,r,!1),e.resourceManager.addContentRestorer(new cp(i,new cm(t,n,r))),i},t2.createCuboid=function(e,t,n,r,i){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=!0);var a=new ch(e);return t2._setCuboidData(a,t,n,r,i,!1),e.resourceManager.addContentRestorer(new cp(a,new cv(t,n,r,i))),a},t2.createPlane=function(e,t,n,r,i,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new ch(e);return t2._setPlaneData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cp(o,new cy(t,n,r,i,a))),o},t2.createCylinder=function(e,t,n,r,i,a,o){void 0===t&&(t=.5),void 0===n&&(n=.5),void 0===r&&(r=2),void 0===i&&(i=20),void 0===a&&(a=1),void 0===o&&(o=!0);var s=new ch(e);return t2._setCylinderData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new cp(s,new cx(t,n,r,i,a,o))),s},t2.createTorus=function(e,t,n,r,i,a,o){void 0===t&&(t=.5),void 0===n&&(n=.1),void 0===r&&(r=30),void 0===i&&(i=30),void 0===a&&(a=360),void 0===o&&(o=!0);var s=new ch(e);return t2._setTorusData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new cp(s,new cT(t,n,r,i,a,o))),s},t2.createCone=function(e,t,n,r,i,a){void 0===t&&(t=.5),void 0===n&&(n=2),void 0===r&&(r=20),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new ch(e);return t2._setConeData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cp(o,new cC(t,n,r,i,a))),o},t2.createCapsule=function(e,t,n,r,i,a){void 0===t&&(t=.5),void 0===n&&(n=2),void 0===r&&(r=6),void 0===i&&(i=1),void 0===a&&(a=!0);var o=new ch(e);return t2._setCapsuleData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cp(o,new cS(t,n,r,i,a))),o},t2._setSphereData=function(e,t,n,r,i){for(var a=(n=Math.max(2,Math.floor(n)))+1,o=a*a,s=n*n,l=t2._generateIndices(e.engine,o,6*s),c=Math.PI,u=2*c,h=1/a,d=1/n,_=Array(o),f=Array(o),p=Array(o),g=0;g<o;++g){var m=g%a*d,v=(g*h|0)*d,y=m*u,x=v*c,T=Math.sin(x),C=-t*Math.cos(y)*T,S=t*Math.cos(x),A=t*Math.sin(y)*T;_[g]=new sO(C,S,A),f[g]=new sO(C,S,A),p[g]=new sq(m,v)}for(var w=0,E=0;E<s;++E){var M=E%n,b=(E*d|0)*a+M,F=b+1,R=b+a,P=R+1;l[w++]=F,l[w++]=b,l[w++]=P,l[w++]=b,l[w++]=R,l[w++]=P}if(!i){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}t2._initialize(e,_,f,p,l,r,i)},t2._setCuboidData=function(e,t,n,r,i,a){var o=t/2,s=n/2,l=r/2,c=Array(24),u=Array(24),h=Array(24);c[0]=new sO(-o,s,-l),c[1]=new sO(o,s,-l),c[2]=new sO(o,s,l),c[3]=new sO(-o,s,l),u[0]=new sO(0,1,0),u[1]=new sO(0,1,0),u[2]=new sO(0,1,0),u[3]=new sO(0,1,0),h[0]=new sq(0,0),h[1]=new sq(1,0),h[2]=new sq(1,1),h[3]=new sq(0,1),c[4]=new sO(-o,-s,-l),c[5]=new sO(o,-s,-l),c[6]=new sO(o,-s,l),c[7]=new sO(-o,-s,l),u[4]=new sO(0,-1,0),u[5]=new sO(0,-1,0),u[6]=new sO(0,-1,0),u[7]=new sO(0,-1,0),h[4]=new sq(0,1),h[5]=new sq(1,1),h[6]=new sq(1,0),h[7]=new sq(0,0),c[8]=new sO(-o,s,-l),c[9]=new sO(-o,s,l),c[10]=new sO(-o,-s,l),c[11]=new sO(-o,-s,-l),u[8]=new sO(-1,0,0),u[9]=new sO(-1,0,0),u[10]=new sO(-1,0,0),u[11]=new sO(-1,0,0),h[8]=new sq(0,0),h[9]=new sq(1,0),h[10]=new sq(1,1),h[11]=new sq(0,1),c[12]=new sO(o,s,-l),c[13]=new sO(o,s,l),c[14]=new sO(o,-s,l),c[15]=new sO(o,-s,-l),u[12]=new sO(1,0,0),u[13]=new sO(1,0,0),u[14]=new sO(1,0,0),u[15]=new sO(1,0,0),h[12]=new sq(1,0),h[13]=new sq(0,0),h[14]=new sq(0,1),h[15]=new sq(1,1),c[16]=new sO(-o,s,l),c[17]=new sO(o,s,l),c[18]=new sO(o,-s,l),c[19]=new sO(-o,-s,l),u[16]=new sO(0,0,1),u[17]=new sO(0,0,1),u[18]=new sO(0,0,1),u[19]=new sO(0,0,1),h[16]=new sq(0,0),h[17]=new sq(1,0),h[18]=new sq(1,1),h[19]=new sq(0,1),c[20]=new sO(-o,s,-l),c[21]=new sO(o,s,-l),c[22]=new sO(o,-s,-l),c[23]=new sO(-o,-s,-l),u[20]=new sO(0,0,-1),u[21]=new sO(0,0,-1),u[22]=new sO(0,0,-1),u[23]=new sO(0,0,-1),h[20]=new sq(1,0),h[21]=new sq(0,0),h[22]=new sq(0,1),h[23]=new sq(1,1);var d=new Uint16Array(36);if(d[0]=0,d[1]=2,d[2]=1,d[3]=2,d[4]=0,d[5]=3,d[6]=4,d[7]=6,d[8]=7,d[9]=6,d[10]=4,d[11]=5,d[12]=8,d[13]=10,d[14]=9,d[15]=10,d[16]=8,d[17]=11,d[18]=12,d[19]=14,d[20]=15,d[21]=14,d[22]=12,d[23]=13,d[24]=16,d[25]=18,d[26]=17,d[27]=18,d[28]=16,d[29]=19,d[30]=20,d[31]=22,d[32]=23,d[33]=22,d[34]=20,d[35]=21,!a){var _=e.bounds;_.min.set(-o,-s,-l),_.max.set(o,s,l)}t2._initialize(e,c,u,h,d,i,a)},t2._setPlaneData=function(e,t,n,r,i,a,o){for(var s=(r=Math.max(1,Math.floor(r)))+1,l=(i=Math.max(1,Math.floor(i)))+1,c=t/2,u=n/2,h=t/r,d=n/i,_=s*l,f=i*r,p=t2._generateIndices(e.engine,_,6*f),g=1/s,m=1/r,v=1/i,y=Array(_),x=Array(_),T=Array(_),C=0;C<_;++C){var S=C%s,A=C*g|0;y[C]=new sO(S*h-c,0,A*d-u),x[C]=new sO(0,1,0),T[C]=new sq(S*m,A*v)}for(var w=0,E=0;E<f;++E){var M=E%r,b=(E*m|0)*s+M,F=b+1,R=b+s,P=R+1;p[w++]=b,p[w++]=R,p[w++]=F,p[w++]=R,p[w++]=P,p[w++]=F}if(!o){var L=e.bounds;L.min.set(-c,0,-u),L.max.set(c,0,u)}t2._initialize(e,y,x,T,p,a,o)},t2._setCylinderData=function(e,t,n,r,i,a,o,s){void 0===t&&(t=.5),void 0===n&&(n=.5),void 0===r&&(r=2),void 0===i&&(i=20),void 0===a&&(a=1);for(var l=(i=Math.floor(i))+1,c=(a=Math.floor(a))+1,u=.5*r,h=r/a,d=l*c,_=i*a,f=2*i,p=d+2+f,g=t2._generateIndices(e.engine,p,6*_+3*f),m=1/l,v=1/i,y=1/a,x=Array(p),T=Array(p),C=Array(p),S=0,A=Math.PI,w=2*Math.PI,E=n-t,M=E/r,b=E/a,F=0;F<d;++F){var R=F%l,P=F*m|0,L=R*v,D=P*y,I=A+L*w,B=Math.sin(I),N=Math.cos(I),V=n-P*b,O=V*B,U=P*h-u,z=V*N;x[F]=new sO(O,U,z),T[F]=new sO(B,M,N),C[F]=new sq(L,1-D)}for(var k=0;k<_;++k){var G=k%i,H=(k*v|0)*l+G,W=H+1,X=H+l,K=X+1;g[S++]=W,g[S++]=X,g[S++]=H,g[S++]=W,g[S++]=K,g[S++]=X}x[d]=new sO(0,-u,0),T[d]=new sO(0,-1,0),C[d]=new sq(.5,.5),x[d+1]=new sO(0,u,0),T[d+1]=new sO(0,1,0),C[d+1]=new sq(.5,.5);for(var j=d+2,q=1/(2*t),Y=1/(2*n),Q=l*a,J=0;J<i;++J){var Z=x[J],$=Z.x,ee=Z.z;x[j]=new sO($,-u,ee),T[j]=new sO(0,-1,0),C[j++]=new sq($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[j]=new sO($,u,ee),T[j]=new sO(0,1,0),C[j++]=new sq($*q+.5,ee*q+.5)}for(var en=d+1,er=d+2,ei=er+1,ea=0;ea<i;++ea){var eo=2*ea,es=ea===i-1?0:eo+2;g[S++]=d,g[S++]=er+es,g[S++]=er+eo,g[S++]=en,g[S++]=ei+eo,g[S++]=ei+es}if(!s){var el=e.bounds,ec=Math.max(t,n);el.min.set(-ec,-u,-ec),el.max.set(ec,u,ec)}t2._initialize(e,x,T,C,g,o,s)},t2._setTorusData=function(e,t,n,r,i,a,o,s){var l=((r=Math.floor(r))+1)*((i=Math.floor(i))+1),c=r*i,u=t2._generateIndices(e.engine,l,6*c),h=Array(l),d=Array(l),_=Array(l);a=a/180*Math.PI;for(var f=0,p=0;p<=r;p++)for(var g=0;g<=i;g++){var m=g/i*a,v=p/r*Math.PI*2,y=Math.cos(v),x=Math.sin(v),T=Math.cos(m),C=Math.sin(m),S=new sO((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var A=t*T,w=t*C;d[f]=new sO(S.x-A,S.y-w,S.z).normalize(),_[f++]=new sq(g/i,p/r)}f=0;for(var E=1;E<=r;E++)for(var M=1;M<=i;M++){var b=(i+1)*E+M-1,F=(i+1)*(E-1)+M-1,R=(i+1)*(E-1)+M,P=(i+1)*E+M;u[f++]=b,u[f++]=F,u[f++]=P,u[f++]=F,u[f++]=R,u[f++]=P}if(!s){var L=e.bounds,D=t+n;L.min.set(-D,-D,-n),L.max.set(D,D,n)}t2._initialize(e,h,d,_,u,o,s)},t2._setConeData=function(e,t,n,r,i,a,o){for(var s=(r=Math.floor(r))+1,l=(i=Math.floor(i))+1,c=.5*n,u=n/i,h=s*l,d=r*i,_=h+1+r,f=t2._generateIndices(e.engine,_,6*d+3*r),p=1/s,g=1/r,m=1/i,v=Array(_),y=Array(_),x=Array(_),T=0,C=Math.PI,S=2*Math.PI,A=t/n,w=0;w<h;++w){var E=w%s,M=w*p|0,b=E*g,F=M*m,R=C+b*S,P=Math.sin(R),L=Math.cos(R),D=t-M*t,I=D*P,B=M*u-c,N=D*L;v[w]=new sO(I,B,N),y[w]=new sO(P,A,L),x[w]=new sq(b,1-F)}for(var V=0;V<d;++V){var O=V%r,U=(V*g|0)*s+O,z=U+1,k=U+s,G=k+1;f[T++]=z,f[T++]=k,f[T++]=U,f[T++]=z,f[T++]=G,f[T++]=k}v[h]=new sO(0,-c,0),y[h]=new sO(0,-1,0),x[h]=new sq(.5,.5);for(var H=h+1,W=1/(2*t),X=0;X<r;++X){var K=v[X],j=K.x,q=K.z;v[H]=new sO(j,-c,q),y[H]=new sO(0,-1,0),x[H++]=new sq(j*W+.5,.5-q*W)}for(var Y=h+1,Q=0;Q<r;++Q){var J=Q,Z=Q===r-1?0:J+1;f[T++]=h,f[T++]=Y+Z,f[T++]=Y+J}if(!o){var $=e.bounds;$.min.set(-t,-c,-t),$.max.set(t,c,t)}t2._initialize(e,v,y,x,f,a,o)},t2._setCapsuleData=function(e,t,n,r,i,a,o){for(var s=(r=Math.max(2,Math.floor(r)))+1,l=(i=Math.floor(i))+1,c=.5*n,u=n/i,h=s*l,d=r*i,_=s*s,f=r*r,p=h+2*_,g=t2._generateIndices(e.engine,p,(d+2*f)*6),m=1/s,v=1/r,y=1/i,x=Math.PI,T=2*Math.PI,C=Array(p),S=Array(p),A=Array(p),w=0,E=0;E<h;++E){var M=E%s,b=E*m|0,F=M*v,R=b*y,P=x+F*T,L=Math.sin(P),D=Math.cos(P);C[E]=new sO(t*L,b*u-c,t*D),S[E]=new sO(L,0,D),A[E]=new sq(F,1-R)}for(var I=0;I<d;++I){var B=I%r,N=(I*v|0)*s+B,V=N+1,O=N+s,U=O+1;g[w++]=V,g[w++]=O,g[w++]=N,g[w++]=V,g[w++]=U,g[w++]=O}if(t2._createCapsuleCap(t,n,r,T,h,1,C,S,A,g,w),t2._createCapsuleCap(t,n,r,-T,h+_,-1,C,S,A,g,w+6*f),!o){var z=e.bounds;z.min.set(-t,-t-c,-t),z.max.set(t,t+c,t)}t2._initialize(e,C,S,A,g,a,o)},t2._initialize=function(e,t,n,r,i,a,o){e.setPositions(t),e.setNormals(n),e.setUVs(r),e.setIndices(i),e.calculateTangents(),e.uploadData(a),o||e.addSubMesh(0,i.length)},t2._generateIndices=function(t,n,r){var i=null;if(n>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))i=new Uint32Array(r);else throw Error("The vertex count is over limit.")}else i=new Uint16Array(r);return i},t2._createCapsuleCap=function(e,t,n,r,i,a,o,s,l,c,u){for(var h=n+1,d=.5*t*a,_=h*h,f=n*n,p=1/h,g=1/n,m=0;m<_;++m){var v=m%h*g,y=(m*p|0)*g,x=v*r,T=y*Math.PI/2,C=Math.sin(T),S=-e*Math.cos(x)*C,A=e*Math.cos(T)*a+d,w=e*Math.sin(x)*C,E=m+i;o[E]=new sO(S,A,w),s[E]=new sO(S,A-d,w),l[E]=new sq(v,y)}for(var M=0;M<f;++M){var b=M%n,F=(M*g|0)*h+b+i,R=F+1,P=F+h,L=P+1;c[u++]=R,c[u++]=F,c[u++]=L,c[u++]=F,c[u++]=P,c[u++]=L}},t2),cw=(s3(t3=function(){return cl.apply(this,arguments)},cl),(t4=t3.prototype).setVertexElements=function(e){this._setVertexElements(e)},t4.setVertexBufferBinding=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var r=e,i=void 0!==r.buffer;i||(r=new cc(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},t4.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=this._vertexBufferBindings,r=e.length,i=t+r;n.length<i&&(n.length=i);for(var a=0;a<r;a++)this._setVertexBufferBinding(t+a,e[a])},t4.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new co(e,t))),this._setIndexBufferBinding(n)},s1(t3,[{key:"instanceCount",get:function(){return this._instanceCount},set:function(e){this._instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}},{key:"vertexElements",get:function(){return this._vertexElements}}]),t3),cE=((t5=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new lI,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}).prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},s1(t5,[{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)}}]),t5);(t8=si||(si={}))[t8.Position=1]="Position",t8[t8.Normal=2]="Normal",t8[t8.Tangent=4]="Tangent",t8[t8.All=7]="All";var cM=((t7=(t6=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new lI,this._dataChangeManager=new lI,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,n,r){if("number"==typeof e){var i=new cE(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},t7.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()},t7._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},t7._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(si.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},t7._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))},t7._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},s1(t6,[{key:"frames",get:function(){return this._frames}}]),t6),cb=((ne=(t9=function(e){this._subMeshPool=new lO(cs),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=e,this._initMeshes(e)}).prototype).drawElement=function(e,t){var n=e.data;if(n.multiRenderData)for(var r=n.charsData,i=t.engine._renderElementPool,a=0,o=r.length;a<o;++a){var s=i.getFromPool();s.set(r[a],e.shaderPass,e.renderState),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},ne._initMeshes=function(e){var t=t9.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var n=this._meshes,r=this._meshCount,i=0;i<r;i++)n[i]=this._createMesh(e,i)},ne.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!t9._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},ne.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},ne.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,i=e.length;r<i;++r)e[r].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},ne._drawSubElement=function(e,t){var n=e.data.verticesData.vertexCount;this._vertexCount+n>t9.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=n,this._batchedQueue[this._elementCount++]=e},ne._createMesh=function(t,n){var r=t9.MAX_VERTEX_COUNT,i=new cw(t,"BufferMesh"+n),a=[],o=this.createVertexElements(a);return this._vertexBuffers[n]=new ca(t,e.BufferBindFlag.VertexBuffer,4*r*o,e.BufferUsage.Dynamic),this._indiceBuffers[n]=new ca(t,e.BufferBindFlag.IndexBuffer,6*r,e.BufferUsage.Dynamic),i.setVertexBufferBinding(this._vertexBuffers[n],o),i.setIndexBufferBinding(this._indiceBuffers[n],e.IndexFormat.UInt16),i.setVertexElements(a),i},ne._updateData=function(e){var t=this._meshes,n=this._flushId;!t9._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,t[n]=this._createMesh(e,n));var r=this._batchedQueue,i=this._vertices,a=this._indices,o=t[n];o.clearSubMesh();for(var s=0,l=0,c=0,u=0,h=0,d=0,_=null,f=0,p=r.length;f<p;f++){var g=r[f],m=g.data;s=this.updateVertices(m,i,s);for(var v=m.verticesData.triangles,y=v.length,x=0;x<y;x++)a[l++]=v[x]+h;h+=m.verticesData.vertexCount,null===_?u+=y:this.canBatch(_,g)?u+=y:(o.addSubMesh(this._getSubMeshFromPool(c,u)),c+=u,u=y,r[d++]=_),_=g}o.addSubMesh(this._getSubMeshFromPool(c,u)),r[d]=_,this._vertexBuffers[n].setData(i,0,0,s),this._indiceBuffers[n].setData(a,0,0,l)},ne._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},t9);cb._disableBatchTag=lK.getByName("spriteDisableBatching"),cb.MAX_VERTEX_COUNT=4096,cb._canUploadSameBuffer=!0;var cF=(s3(nt=function(){return cb.apply(this,arguments)},cb),(nn=nt.prototype).createVertexElements=function(t){return t[0]=new ci("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ci("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},nn.canBatch=function(e,t){var n=e.data,r=t.data;if(n.isAdd!==r.isAdd)return!1;var i=n.component.shaderData,a=r.component.shaderData,o=cn._textureProperty,s=cn._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},nn.updateVertices=function(e,t,n){for(var r=e.verticesData,i=r.positions,a=r.uvs,o=r.vertexCount,s=0;s<o;s++){var l=i[s],c=a[s];t[n++]=l.x,t[n++]=l.y,t[n++]=l.z,t[n++]=c.x,t[n++]=c.y}return n},nn.drawBatches=function(t){for(var n=this._engine,r=this._batchedQueue,i=this._meshes[this._flushId],a=i.subMeshes,o=t.scene.shaderData,s=t.shaderData,l=0,c=a.length;l<c;l++){var u=a[l],h=r[l],d=h.data;if(!u||!h)return;var _=d.component,f=d.material,p=l$._compileMacros;lG.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=f.renderState.stencilState,m=d.isAdd?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate;g.passOperationFront=m,g.passOperationBack=m;var v=f.shader.subShaders[0].passes[0]._getShaderProgram(n,p);if(!v.isValid)return;v.bind(),v.groupingOtherUniformBlock(),v.uploadAll(v.sceneUniformBlock,o),v.uploadAll(v.cameraUniformBlock,s),v.uploadAll(v.rendererUniformBlock,_.shaderData),v.uploadAll(v.materialUniformBlock,f.shaderData),f.renderState._apply(n,!1),n._hardwareRenderer.drawPrimitive(i,u,v)}},nt),cR=((ni=(nr=function(e){this._preMaskLayer=0,this._batcher=new cF(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},ni.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t))},ni.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},ni.destroy=function(){this._batcher.destroy(),this._batcher=null},ni._processMasksDiff=function(e,t){var n=this._preMaskLayer,r=t.maskLayer;if(n!==r)for(var i=e._renderPipeline._allSpriteMasks,a=n&r,o=r&~n,s=n&~r,l=i._elements,c=0,u=i.length;c<u;c++){var h=l[c],d=h.influenceLayers;if(!(d&a)){if(d&o){var _=h._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(d&s){var f=h._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},nr),cP=(s3(na=function(){var e;return(e=lU.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},lU),na.prototype.set=function(e,t,n){this.component=e,this.material=t,this.verticesData=n},na),cL=(s3(no=function(){var e;return(e=lU.call(this)||this).multiRenderData=!1,e},lU),no.prototype.set=function(e,t,n,r,i){void 0===i&&(i=0),this.component=e,this.material=t,this.verticesData=n,this.texture=r,this.dataIndex=i},no),cD=(s3(ns=function(){var e;return(e=lU.call(this)||this).charsData=[],e.multiRenderData=!0,e},lU),ns),cI=((nc=(nl=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.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,n=t.length;e.length=n;for(var r=0;r<n;r++)e[r]=t[r];this._loopArrayDirty=!1}return e},s1(nl,[{key:"length",get:function(){return this._array.length}}]),nl),cB=((nh=(nu=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new cI}).prototype).addScene=function(e,t){if("number"==typeof e?this._scenes.add(e,t):(t=e,this._scenes.push(t)),t.engine!==this.engine)throw"The scene is not belong to this engine.";t._processActive(!0)},nh.removeScene=function(e){var t=this._scenes,n=t.indexOf(e);if(-1!==n){var r=t.getArray()[n];t.removeByIndex(n),r._processActive(!1)}},nh.loadScene=function(e,t){void 0===t&&(t=!0);var n=this,r=this.engine.resourceManager.load(e);return r.then(function(e){var r=n._scenes;if(t)for(var i=0,a=r.length;i<a;i++)r[i].destroy();n.addScene(e)}),r},nh.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},nh._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},s1(nu,[{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)}}]),nu),cN=((n_=(nd=function(e){var t=this;this._state="pending",this._onProgressCallback=[],this._promise=new Promise(function(n,r){t._reject=r,e(function(e){"pending"===t._state&&(n(e),t._state="fulfilled",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(r(e),t._state="rejected",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&t._onProgressCallback.forEach(function(t){return t(e)})},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e){return this._onProgressCallback.push(e),this},n_.then=function(e,t){var n=this;return new nd(function(r,i){n._promise.then(e,t).then(r).catch(i)})},n_.catch=function(e){var t=this;return new nd(function(n,r){t._promise.catch(e).then(n).catch(r)})},n_.finally=function(e){return this._promise.finally(e)},n_.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nd.all=function(e){return new nd(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){s6(e,Promise)||s6(e,nd)?e.then(function(e){i(t,e)},n):Promise.resolve().then(function(){i(t,e)})},o=e.length,s=Array(o),l=0;if(0===o)return t(s);for(var c=0;c<o;c++)a(e[c],c)})},s1(nd,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nd);(nf=sa||(sa={})).Pending="pending",nf.Fulfilled="fulfilled",nf.Rejected="rejected",nf.Canceled="canceled";var cV=((ng=(np=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._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 n=e.map(function(e){return t._loadSingleItem(e)});return cN.all(n)},ng.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},ng.getAssetPath=function(e){return this._assetPool[e]},ng.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()}):lF.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},ng.gc=function(){this._gc(!1)},ng.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},ng._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},ng._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},ng._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},ng._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},ng._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},ng._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},ng._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},ng._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},ng._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)},ng._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},ng._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:np._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(n=e.retryCount)?n:this.retryCount,e.timeout=null!=(r=e.timeout)?r:this.timeout,e.retryInterval=null!=(i=e.retryInterval)?i:this.retryInterval,e.url=null!=(a=e.url)?a:e.urls.join(","),e},ng._loadSingleItem=function(e){var t=this,n=this._assignDefaultOptions("string"==typeof e?{url:e}:e),r=n.url,i=this._virtualPathMap[r]?this._virtualPathMap[r]:r,a=this._parseURL(i),o=a.assetBaseURL,s=a.queryPath,l=s?this._parseQueryPath(s):[],c=this._assetUrlPool[o];if(c)return new cN(function(e){e(t._getResolveResource(c,l))});var u=o;s&&(u+="?q="+l.shift());var h=this._loadingPromises,d=h[u];if(d)return new cN(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=np._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(s6(f,cN))return h[o]=f,f.then(function(e){_.useCache&&t._addAsset(o,e),delete h[o]},function(){return delete h[o]}),f;var p=function(e){var n=f[e],r=o===e;h[e]=n,n.then(function(n){if(r&&_.useCache)for(var i in t._addAsset(e,n),f)delete h[i]},function(){for(var e in f)delete h[e]})};for(var g in f)p(g);return f[u].then(function(e){return t._getResolveResource(e,l)})},ng._gc=function(e){for(var t=lF.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},ng._getResolveResource=function(e,t){var n=e;if(t)for(var r=0,i=t.length;r<i;r++)n=n[t[r]];return n},ng._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},ng._getParameterByName=function(e,t){void 0===t&&(t=window.location.href);var n=RegExp("[?&]"+(e=e.replace(/[\[\]]/g,"\\$&"))+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},ng._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===cU&&t.push(""),e.replace(ck,function(e,n,r,i){var a=e;r?a=i.replace(cz,"$1"):n&&(a=n.trim()),t.push(a)}),t},ng.getResourceByRef=function(e){var t=e.refId,n=e.key,r=e.isClone,i=this._objectPool[t];if(i)a=Promise.resolve(i);else{var a,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return ld.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=n?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+n:s,a=this.load({url:s,type:this._editorResourceConfig[t].type})}return a.then(function(e){return r?e.clone():e})},ng.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},np._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},np._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},np);function cO(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);cV._addLoader(e,i,t)}}cV._loaders={},cV._extTypeMapping={};var cU=46,cz=/\\(\\)?/g,ck=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(nm=e.PointerPhase||(e.PointerPhase={}))[nm.Down=0]="Down",nm[nm.Move=1]="Move",nm[nm.Stationary=2]="Stationary",nm[nm.Up=3]="Up",nm[nm.Leave=4]="Leave";var cG=((ny=(nv=function(t){this.phase=e.PointerPhase.Leave,this.position=new sq,this.deltaPosition=new sq,this._events=[],this._upMap=[],this._downMap=[],this._upList=new lb,this._downList=new lb,this.id=t}).prototype)._firePointerExitAndEnter=function(e){if(this._currentEnteredEntity!==e){if(this._currentEnteredEntity)for(var t=this._currentEnteredEntity._scripts,n=t.length-1;n>=0;n--){var r=t.get(n);r._waitHandlingInValid||r.onPointerExit(this)}if(e)for(var i=e._scripts,a=i.length-1;a>=0;a--){var o=i.get(a);o._waitHandlingInValid||o.onPointerEnter(this)}this._currentEnteredEntity=e}},ny._firePointerDown=function(e){if(e)for(var t=e._scripts,n=t.length-1;n>=0;n--){var r=t.get(n);r._waitHandlingInValid||r.onPointerDown(this)}this._currentPressedEntity=e},ny._firePointerDrag=function(){if(this._currentPressedEntity)for(var e=this._currentPressedEntity._scripts,t=e.length-1;t>=0;t--){var n=e.get(t);n._waitHandlingInValid||n.onPointerDrag(this)}},ny._firePointerUpAndClick=function(e){var t=this._currentPressedEntity;if(t){for(var n=t===e,r=t._scripts,i=r.length-1;i>=0;i--){var a=r.get(i);a._waitHandlingInValid||(n&&a.onPointerClick(this),a.onPointerUp(this))}this._currentPressedEntity=null}},nv);e.PointerButton=void 0,(nx=e.PointerButton||(e.PointerButton={}))[nx.None=0]="None",nx[nx.Primary=1]="Primary",nx[nx.Secondary=2]="Secondary",nx[nx.Auxiliary=4]="Auxiliary",nx[nx.XButton1=8]="XButton1",nx[nx.XButton2=16]="XButton2",nx[nx.XButton3=32]="XButton3",nx[nx.XButton4=64]="XButton4",nx[nx.XButton5=128]="XButton5",nx[nx.XButton6=256]="XButton6",nx[nx.XButton7=512]="XButton7",nx[nx.XButton8=1024]="XButton8";var cH=[1,4,2,8,16,32,64,128,256,512,1024],cW={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},cX=((nT=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?nT.platform=e.Platform.IPhone:/iPad/i.test(n)?nT.platform=e.Platform.IPad:/Android/i.test(n)?nT.platform=e.Platform.Android:/Macintosh/i.test(n)&&(nT.platform=e.Platform.Mac),nT.platform){case e.Platform.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 e.Platform.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 e.Platform.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case e.Platform.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"}}},s1(nT,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nT);cX.platform=e.Platform.Unknown,cX.operatingSystem="",cX._initialize(),e.Keys=void 0,(nC=e.Keys||(e.Keys={}))[nC.Backquote=0]="Backquote",nC[nC.Backslash=1]="Backslash",nC[nC.Backspace=2]="Backspace",nC[nC.BracketLeft=3]="BracketLeft",nC[nC.BracketRight=4]="BracketRight",nC[nC.Comma=5]="Comma",nC[nC.Digit0=6]="Digit0",nC[nC.Digit1=7]="Digit1",nC[nC.Digit2=8]="Digit2",nC[nC.Digit3=9]="Digit3",nC[nC.Digit4=10]="Digit4",nC[nC.Digit5=11]="Digit5",nC[nC.Digit6=12]="Digit6",nC[nC.Digit7=13]="Digit7",nC[nC.Digit8=14]="Digit8",nC[nC.Digit9=15]="Digit9",nC[nC.Equal=16]="Equal",nC[nC.IntlBackslash=17]="IntlBackslash",nC[nC.IntlRo=18]="IntlRo",nC[nC.IntlYen=19]="IntlYen",nC[nC.KeyA=20]="KeyA",nC[nC.KeyB=21]="KeyB",nC[nC.KeyC=22]="KeyC",nC[nC.KeyD=23]="KeyD",nC[nC.KeyE=24]="KeyE",nC[nC.KeyF=25]="KeyF",nC[nC.KeyG=26]="KeyG",nC[nC.KeyH=27]="KeyH",nC[nC.KeyI=28]="KeyI",nC[nC.KeyJ=29]="KeyJ",nC[nC.KeyK=30]="KeyK",nC[nC.KeyL=31]="KeyL",nC[nC.KeyM=32]="KeyM",nC[nC.KeyN=33]="KeyN",nC[nC.KeyO=34]="KeyO",nC[nC.KeyP=35]="KeyP",nC[nC.KeyQ=36]="KeyQ",nC[nC.KeyR=37]="KeyR",nC[nC.KeyS=38]="KeyS",nC[nC.KeyT=39]="KeyT",nC[nC.KeyU=40]="KeyU",nC[nC.KeyV=41]="KeyV",nC[nC.KeyW=42]="KeyW",nC[nC.KeyX=43]="KeyX",nC[nC.KeyY=44]="KeyY",nC[nC.KeyZ=45]="KeyZ",nC[nC.Minus=46]="Minus",nC[nC.Period=47]="Period",nC[nC.Quote=48]="Quote",nC[nC.Semicolon=49]="Semicolon",nC[nC.Slash=50]="Slash",nC[nC.AltLeft=51]="AltLeft",nC[nC.AltRight=52]="AltRight",nC[nC.CapsLock=53]="CapsLock",nC[nC.ContextMenu=54]="ContextMenu",nC[nC.ControlLeft=55]="ControlLeft",nC[nC.ControlRight=56]="ControlRight",nC[nC.Enter=57]="Enter",nC[nC.MetaLeft=58]="MetaLeft",nC[nC.MetaRight=59]="MetaRight",nC[nC.ShiftLeft=60]="ShiftLeft",nC[nC.ShiftRight=61]="ShiftRight",nC[nC.Space=62]="Space",nC[nC.Tab=63]="Tab",nC[nC.Convert=64]="Convert",nC[nC.KanaMode=65]="KanaMode",nC[nC.Lang1=66]="Lang1",nC[nC.Lang2=67]="Lang2",nC[nC.Lang3=68]="Lang3",nC[nC.Lang4=69]="Lang4",nC[nC.Lang5=70]="Lang5",nC[nC.NonConvert=71]="NonConvert",nC[nC.Delete=72]="Delete",nC[nC.End=73]="End",nC[nC.Help=74]="Help",nC[nC.Home=75]="Home",nC[nC.Insert=76]="Insert",nC[nC.PageDown=77]="PageDown",nC[nC.PageUp=78]="PageUp",nC[nC.ArrowDown=79]="ArrowDown",nC[nC.ArrowLeft=80]="ArrowLeft",nC[nC.ArrowRight=81]="ArrowRight",nC[nC.ArrowUp=82]="ArrowUp",nC[nC.NumLock=83]="NumLock",nC[nC.Numpad0=84]="Numpad0",nC[nC.Numpad1=85]="Numpad1",nC[nC.Numpad2=86]="Numpad2",nC[nC.Numpad3=87]="Numpad3",nC[nC.Numpad4=88]="Numpad4",nC[nC.Numpad5=89]="Numpad5",nC[nC.Numpad6=90]="Numpad6",nC[nC.Numpad7=91]="Numpad7",nC[nC.Numpad8=92]="Numpad8",nC[nC.Numpad9=93]="Numpad9",nC[nC.NumpadAdd=94]="NumpadAdd",nC[nC.NumpadBackspace=95]="NumpadBackspace",nC[nC.NumpadClear=96]="NumpadClear",nC[nC.NumpadClearEntry=97]="NumpadClearEntry",nC[nC.NumpadComma=98]="NumpadComma",nC[nC.NumpadDecimal=99]="NumpadDecimal",nC[nC.NumpadDivide=100]="NumpadDivide",nC[nC.NumpadEnter=101]="NumpadEnter",nC[nC.NumpadEqual=102]="NumpadEqual",nC[nC.NumpadHash=103]="NumpadHash",nC[nC.NumpadMemoryAdd=104]="NumpadMemoryAdd",nC[nC.NumpadMemoryClear=105]="NumpadMemoryClear",nC[nC.NumpadMemoryRecall=106]="NumpadMemoryRecall",nC[nC.NumpadMemoryStore=107]="NumpadMemoryStore",nC[nC.NumpadMemorySubtract=108]="NumpadMemorySubtract",nC[nC.NumpadMultiply=109]="NumpadMultiply",nC[nC.NumpadParenLeft=110]="NumpadParenLeft",nC[nC.NumpadParenRight=111]="NumpadParenRight",nC[nC.NumpadStar=112]="NumpadStar",nC[nC.NumpadSubtract=113]="NumpadSubtract",nC[nC.Escape=114]="Escape",nC[nC.F1=115]="F1",nC[nC.F2=116]="F2",nC[nC.F3=117]="F3",nC[nC.F4=118]="F4",nC[nC.F5=119]="F5",nC[nC.F6=120]="F6",nC[nC.F7=121]="F7",nC[nC.F8=122]="F8",nC[nC.F9=123]="F9",nC[nC.F10=124]="F10",nC[nC.F11=125]="F11",nC[nC.F12=126]="F12",nC[nC.F13=127]="F13",nC[nC.F14=128]="F14",nC[nC.F15=129]="F15",nC[nC.Fn=130]="Fn",nC[nC.FnLock=131]="FnLock",nC[nC.PrintScreen=132]="PrintScreen",nC[nC.ScrollLock=133]="ScrollLock",nC[nC.Pause=134]="Pause",nC[nC.BrowserBack=135]="BrowserBack",nC[nC.BrowserFavorites=136]="BrowserFavorites",nC[nC.BrowserForward=137]="BrowserForward",nC[nC.BrowserHome=138]="BrowserHome",nC[nC.BrowserRefresh=139]="BrowserRefresh",nC[nC.BrowserSearch=140]="BrowserSearch",nC[nC.BrowserStop=141]="BrowserStop",nC[nC.Eject=142]="Eject",nC[nC.LaunchApp1=143]="LaunchApp1",nC[nC.LaunchApp2=144]="LaunchApp2",nC[nC.LaunchMail=145]="LaunchMail",nC[nC.MediaPlayPause=146]="MediaPlayPause",nC[nC.MediaSelect=147]="MediaSelect",nC[nC.MediaStop=148]="MediaStop",nC[nC.MediaTrackNext=149]="MediaTrackNext",nC[nC.MediaTrackPrevious=150]="MediaTrackPrevious",nC[nC.Power=151]="Power",nC[nC.Sleep=152]="Sleep",nC[nC.AudioVolumeDown=153]="AudioVolumeDown",nC[nC.AudioVolumeMute=154]="AudioVolumeMute",nC[nC.AudioVolumeUp=155]="AudioVolumeUp",nC[nC.WakeUp=156]="WakeUp",nC[nC.Hyper=157]="Hyper",nC[nC.Super=158]="Super",nC[nC.Turbo=159]="Turbo",nC[nC.Abort=160]="Abort",nC[nC.Resume=161]="Resume",nC[nC.Suspend=162]="Suspend",nC[nC.Again=163]="Again",nC[nC.Copy=164]="Copy",nC[nC.Cut=165]="Cut",nC[nC.Find=166]="Find",nC[nC.Open=167]="Open",nC[nC.Paste=168]="Paste",nC[nC.Props=169]="Props",nC[nC.Select=170]="Select",nC[nC.Undo=171]="Undo",nC[nC.Hiragana=172]="Hiragana",nC[nC.Katakana=173]="Katakana",nC[nC.Unidentified=174]="Unidentified";var cK=((nA=(nS=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new lb,this._curFrameDownList=new lb,this._curFrameUpList=new lb,this._nativeEvents=[],this._hadListener=!1;var t=e._canvas._webCanvas;this._engine=e,this._htmlCanvas=t,t.tabIndex=t.tabIndex,this._onKeyEvent=this._onKeyEvent.bind(this),t.addEventListener("keydown",this._onKeyEvent),t.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0}).prototype)._update=function(){var t=this._nativeEvents,n=this._curFrameDownList,r=this._curFrameUpList;if(n.length=0,r.length=0,t.length>0){for(var i=this._engine.time.frameCount,a=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,c=0,u=t.length;c<u;c++){var h=t[c],d=e.Keys[h.code];switch(h.type){case"keydown":null==a[d]&&(n.add(d),o.add(d),a[d]=o.length-1,s[d]=i);break;case"keyup":var _=a[d];if(null!=_){a[d]=null;var f=o.deleteByIndex(_);f&&(a[f]=_)}if(r.add(d),l[d]=i,cX.platform===e.Platform.Mac&&(d===e.Keys.MetaLeft||d===e.Keys.MetaRight)){for(var p=0,g=o.length;p<g;p++)a[o.get(p)]=null;o.length=0}}}t.length=0}},nA._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},nA._onBlur=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0,this._hadListener=!1)},nA._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._htmlCanvas=null,this._engine=null},nA._onKeyEvent=function(e){this._nativeEvents.push(e)},nS);e.CameraClearFlags=void 0,(nw=e.CameraClearFlags||(e.CameraClearFlags={}))[nw.None=0]="None",nw[nw.Color=1]="Color",nw[nw.Depth=2]="Depth",nw[nw.Stencil=4]="Stencil",nw[nw.ColorDepth=3]="ColorDepth",nw[nw.ColorStencil=5]="ColorStencil",nw[nw.DepthStencil=6]="DepthStencil",nw[nw.All=7]="All",e.Collider=(s3(nE=function(e){var t;return(t=lw.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lw),(nM=nE.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this.scene.physics._addColliderShape(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape))},nM.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this.scene.physics._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},nM.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++){var r=e[t];this.scene.physics._removeColliderShape(r),r._destroy(),this._nativeCollider.removeShape(r._nativeShape)}e.length=0},nM._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}},nM._onLateUpdate=function(){},nM._onEnableInScene=function(){this.scene.physics._addCollider(this)},nM._onDisableInScene=function(){this.scene.physics._removeCollider(this)},nM._onDestroy=function(){lw.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},s1(nE,[{key:"shapes",get:function(){return this._shapes}}]),nE),s8([s7],e.Collider.prototype,"_index",void 0),e.Collider=s8([lM(lB,e.DependentMode.CheckOnly)],e.Collider);var cj=function(){function t(e){var n=this;this._restTime=0,this._colliders=new lb,this._gravity=new sO(0,-9.81,0),this._onContactEnter=function(e,r){for(var i=n._scene.engine._physicalObjectsMap,a=i[e],o=i[r],s=a.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionEnter(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=a,f.onCollisionEnter(p)}}},this._onContactExit=function(e,r){for(var i=n._scene.engine._physicalObjectsMap,a=i[e],o=i[r],s=a.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionExit(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=a,f.onCollisionExit(p)}}},this._onContactStay=function(e,r){for(var i=n._scene.engine._physicalObjectsMap,a=i[e],o=i[r],s=a.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionStay(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=a,f.onCollisionStay(p)}}},this._onTriggerEnter=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,i=r[e],a=r[t],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerEnter(a)}o=a.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerEnter(i)}},this._onTriggerExit=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,i=r[e],a=r[t],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerExit(a)}o=a.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerExit(i)}},this._onTriggerStay=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,i=r[e],a=r[t],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerStay(a)}o=a.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerStay(i)}},this.fixedTimeStep=1/60,this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var r=e.engine;r._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(r._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var n=t.prototype;return n.raycast=function(t,n,r,i){var a,o=this,s=Number.MAX_VALUE;"number"==typeof n?s=n:void 0!=n&&(a=n);var l=e.Layer.Everything;"number"==typeof r?l=r:void 0!=r&&(a=r),i&&(a=i);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsScene.raycast(t,s,c):!!this._nativePhysicsScene.raycast(t,s,c,function(e,t,n,r){a.entity=o._scene.engine._physicalObjectsMap[e]._collider.entity,a.distance=t,a.normal.copyFrom(r),a.point.copyFrom(n)})||(a.entity=null,a.distance=0,a.point.set(0,0,0),a.normal.set(0,0,0),!1)},n._update=function(e){var t=this.fixedTimeStep,n=this._nativePhysicsScene,r=this._scene._componentsManager,i=this._restTime+e,a=Math.floor(i/t);this._restTime=i-a*t;for(var o=0;o<a;o++)r.callScriptOnPhysicsUpdate(),this._callColliderOnUpdate(),n.update(t),this._callColliderOnLateUpdate()},n._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},n._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},n._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},n._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},n._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},n._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},n._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},n._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},n._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},s1(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}}]),t}();cj._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nb=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nb.PreventClimbing=0]="PreventClimbing",nb[nb.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var cq=(nF=e.Collider,s3(nR=function(t){var n;return(n=nF.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sO(0,1,0),n._slopeLimit=.707,n._nativeCollider=cj._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(s$(n)),n._upDirection._onValueChanged=n._setUpDirection,n},nF),(nP=nR.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},nP.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nF.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nP.clearShapes=function(){this._shapes.length>0&&nF.prototype.removeShape.call(this,this._shapes[0])},nP._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,i=t.length;r<i;r++)t[r]._nativeShape.setWorldScale(n);this._updateFlag.flag=!1}},nP._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},nP._onEnableInScene=function(){this.scene.physics._addCharacterController(this)},nP._onDisableInScene=function(){this.scene.physics._removeCharacterController(this)},nP._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},s1(nR,[{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))}}]),nR),cY=(nL=e.Collider,s3(nD=function(e){(t=nL.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sO,t._angularVelocity=new sO,t._mass=1,t._centerOfMass=new sO,t._inertiaTensor=new sO(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,n=t.entity.transform;return t._nativeCollider=cj._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(s$(t)),t._setAngularVelocity=t._setAngularVelocity.bind(s$(t)),t._setCenterOfMass=t._setCenterOfMass.bind(s$(t)),t._setInertiaTensor=t._setInertiaTensor.bind(s$(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},nL),(nI=nD.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},nI.applyTorque=function(e){this._nativeCollider.addTorque(e)},nI.move=function(e,t){this._nativeCollider.move(e,t)},nI.sleep=function(){this._nativeCollider.sleep()},nI.wakeUp=function(){this._nativeCollider.wakeUp()},nI._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},nI._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},nI._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},nI._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},nI._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},s1(nD,[{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))}}]),nD);e.CollisionDetectionMode=void 0,(nB=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nB.Discrete=0]="Discrete",nB[nB.Continuous=1]="Continuous",nB[nB.ContinuousDynamic=2]="ContinuousDynamic",nB[nB.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(nN=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[nN.None=0]="None",nN[nN.FreezePositionX=1]="FreezePositionX",nN[nN.FreezePositionY=2]="FreezePositionY",nN[nN.FreezePositionZ=4]="FreezePositionZ",nN[nN.FreezeRotationX=8]="FreezeRotationX",nN[nN.FreezeRotationY=16]="FreezeRotationY",nN[nN.FreezeRotationZ=32]="FreezeRotationZ";var cQ=function(){this.entity=null,this.distance=0,this.point=new sO,this.normal=new sO};e.PhysicsMaterialCombineMode=void 0,(nV=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nV.Average=0]="Average",nV[nV.Minimum=1]="Minimum",nV[nV.Multiply=2]="Multiply",nV[nV.Maximum=3]="Maximum";var cJ=((nO=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=cj._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},s1(nO,[{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))}}]),nO),cZ=(nU=e.Collider,s3(nz=function(e){var t,n=(t=nU.call(this,e)||this).entity.transform;return t._nativeCollider=cj._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},nU),nz);e.ColliderShapeUpAxis=void 0,(nk=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nk.X=0]="X",nk[nk.Y=1]="Y",nk[nk.Z=2]="Z",e.ControllerCollisionFlag=void 0,(nG=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[nG.Sides=1]="Sides",nG[nG.Up=2]="Up",nG[nG.Down=4]="Down",e.Joint=(s3(nH=function(e){var t;return(t=lw.call(this,e)||this)._connectedCollider=new c$,t._collider=new c$,t._force=0,t._torque=0,t._connectedCollider.localPosition=new sO,t},lw),s1(nH,[{key:"connectedCollider",get:function(){return this._connectedCollider.collider},set:function(e){this._connectedCollider.collider!==e&&(this._connectedCollider.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedCollider.localPosition},set:function(e){var t=this._connectedCollider.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedCollider.massScale},set:function(e){e!==this._connectedCollider.massScale&&(this._connectedCollider.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedCollider.inertiaScale},set:function(e){e!==this._connectedCollider.inertiaScale&&(this._connectedCollider.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._collider.massScale},set:function(e){e!==this._collider.massScale&&(this._collider.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._collider.inertiaScale},set:function(e){e!==this._collider.inertiaScale&&(this._collider.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))}}]),nH),e.Joint=s8([lM(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var c$=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},c0=(nW=e.Joint,s3(nX=function(){return nW.apply(this,arguments)},nW),nX.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=cj._nativePhysics.createFixedJoint(t.collider._nativeCollider)},nX);(nK=so||(so={}))[nK.LimitEnabled=1]="LimitEnabled",nK[nK.DriveEnabled=2]="DriveEnabled",nK[nK.DriveFreeSpin=4]="DriveFreeSpin";var c1=(nj=e.Joint,s3(nq=function(){var e;return e=nj.apply(this,arguments)||this,e._axis=new sO(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},nj),nq.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sO,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=cj._nativePhysics.createHingeJoint(t.collider._nativeCollider)},s1(nq,[{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._collider.localPosition},set:function(e){var t=this._collider.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&so.LimitEnabled)==so.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=so.LimitEnabled),this._nativeJoint.setHingeJointFlag(so.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&so.DriveEnabled)==so.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=so.DriveEnabled),this._nativeJoint.setHingeJointFlag(so.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(so.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))}}]),nq),c2=(nY=e.Joint,s3(nQ=function(){var e;return e=nY.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},nY),nQ.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sO,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=cj._nativePhysics.createSpringJoint(t.collider._nativeCollider)},s1(nQ,[{key:"swingOffset",get:function(){return this._collider.localPosition},set:function(e){var t=this._collider.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))}}]),nQ),c3=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},c4=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},c5=function(){function e(){this._isTrigger=!1,this._rotation=new sO,this._position=new sO,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new cJ,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._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},s1(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}();c5._idGenerator=0;var c8=(s3(nJ=function(){var e;return(e=c5.call(this)||this)._size=new sO(1,1,1),e._nativeShape=cj._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(s$(e)),e._size._onValueChanged=e._setSize,e},c5),nJ.prototype._setSize=function(){this._nativeShape.setSize(this._size)},s1(nJ,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),nJ),c6=(s3(nZ=function(){var e;return(e=c5.call(this)||this)._radius=1,e._nativeShape=cj._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},c5),s1(nZ,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),nZ),c7=(s3(n$=function(){var e;return(e=c5.call(this)||this)._nativeShape=cj._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},c5),n$),c9=(s3(n0=function(){var t;return(t=c5.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=cj._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},c5),s1(n0,[{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))}}]),n0),ue=((n2=(n1=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new lb,this._downList=new lb,this._nativeEvents=[],this._hadListener=!1;var n=t._canvas._webCanvas;this._engine=t,this._canvas=t.canvas,this._htmlCanvas=n,this._onPointerEvent=this._onPointerEvent.bind(this),this._onFocus(),this._pointerPool=Array(11)}).prototype)._update=function(){var t=this._pointers,n=this._nativeEvents,r=t.length-1;if(r>=0)for(var i=r;i>=0;i--)t[i].phase===e.PointerPhase.Leave&&t.splice(i,1);if((r=n.length-1)>=0){for(var a=0;a<=r;a++){var o,s=n[a];null==(o=this._getPointer(s.pointerId))||o._events.push(s)}n.length=0}if(this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None,(r=t.length-1)>=0)for(var l=this._engine.time.frameCount,c=this._htmlCanvas.getBoundingClientRect(),u=c.left,h=c.top,d=this._htmlCanvas,_=d.clientWidth,f=d.clientHeight,p=this._canvas,g=p.width,m=p.height,v=g/_,y=m/f,x=r;x>=0;x--){var T=t[x];T._upList.length=T._downList.length=0,this._updatePointerInfo(l,T,u,h,v,y),this._buttons|=T.pressedButtons}},n2._firePointerScript=function(t){for(var n=this._pointers,r=this._canvas,i=0,a=n.length;i<a;i++){var o=n[i],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/r.width,l.y/r.height);o._firePointerExitAndEnter(c);var u=s.length;if(u>0){for(var h=0;h<u;h++)switch(s[h].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}}},n2._onFocus=function(){if(!this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t),this._hadListener=!0}},n2._onBlur=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1,this._pointers.length=0,this._downList.length=0,this._upList.length=0}},n2._destroy=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1}this._pointerPool.length=0,this._pointerPool=null,this._pointers.length=0,this._pointers=null,this._downList.length=0,this._downList=null,this._upList.length=0,this._upList=null,this._nativeEvents.length=0,this._nativeEvents=null,this._upMap.length=0,this._upMap=null,this._downMap.length=0,this._downMap=null,this._htmlCanvas=null,this._canvas=null,this._engine=null},n2._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},n2._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},n2._getPointer=function(e){var t=this._pointers,n=this._getIndexByPointerID(e);if(n>=0)return t[n];var r=t.length;if(0!==r&&!this._multiPointerEnabled)return null;for(var i=this._pointerPool,a=0;a<r&&!(t[a].id>a);a++);var o=i[a];return o||(o=i[a]=new cG(a)),o._uniqueID=e,t.splice(a,0,o),o},n2._updatePointerInfo=function(t,n,r,i,a,o){var s=n._events,l=n.position,c=s.length;if(c>0){var u=this._upList,h=this._upMap,d=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-r)*a,g=(f.clientY-i)*o;n.deltaPosition.set(p-l.x,g-l.y),l.set(p,g);for(var m=0;m<c;m++){var v=s[m],y=v.button;switch(n.button=cH[y]||e.PointerButton.None,n.pressedButtons=v.buttons,v.type){case"pointerdown":d.add(y),_[y]=t,n._downList.add(y),n._downMap[y]=t,n.phase=e.PointerPhase.Down;break;case"pointerup":u.add(y),h[y]=t,n._upList.add(y),n._upMap[y]=t,n.phase=e.PointerPhase.Up;break;case"pointermove":n.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":n.phase=e.PointerPhase.Leave}}this._engine._physicsInitialized||(s.length=0)}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary},n2._pointerRayCast=function(t,n,r){for(var i=n1._tempPoint,a=n1._tempRay,o=n1._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(!l.destroyed)for(var c=l._activeCameras,u=0;u<c.length;u++){var h=c[s];if(h.enabled&&!h.renderTarget){var d=h.viewport,_=d.x,f=d.y,p=d.z,g=d.w;if(n>=_&&r>=f&&n-_<=p&&r-f<=g){if(i.set((n-_)/p,(r-f)/g),l.physics.raycast(h.viewportPointToRay(i,a),Number.MAX_VALUE,h.cullingMask,o))return o.entity;if(h.clearFlags&e.CameraClearFlags.Color)return null}}}}return null},n1);ue._tempRay=new sj,ue._tempPoint=new sq,ue._tempHitResult=new cQ;var ut=((n4=(n3=function(e){this._delta=new sO,this._nativeEvents=[];var t=e._canvas._webCanvas;this._onWheelEvent=this._onWheelEvent.bind(this),t.addEventListener("wheel",this._onWheelEvent),this._canvas=t,this._hadListener=!0}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var 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}},n4._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},n4._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},n4._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null,this._canvas=null,this._delta=null},n4._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},n3),un=((n8=(n5=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&s6(t,OffscreenCanvas)||(this._wheelManager=new ut(e),this._pointerManager=new ue(e),this._keyboardManager=new cK(e),this._onBlur=this._onBlur.bind(this),window.addEventListener("blur",this._onBlur),this._onFocus=this._onFocus.bind(this),window.addEventListener("focus",this._onFocus),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},n8.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},n8.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},n8.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},n8.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[cW[e]]===this._engine.time.frameCount)},n8.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[cW[e]]===this._engine.time.frameCount)},n8._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},n8._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},n8._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},n8._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},n8._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},s1(n5,[{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}}]),n5),ur=(s3(n6=function(e,t){var n;return(n=li.call(this,e)||this).shaderData=new l0(o3.Material),n._renderStates=[],n.shader=t,n},li),(n7=n6.prototype).clone=function(){var e=new n6(this._engine,this.shader);return this.cloneTo(e),e},n7.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),ln.deepCloneObject(this.renderStates,e.renderStates)},n7._addReferCount=function(e){li.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e)},s1(n6,[{key:"shader",get:function(){return this._shader},set:function(e){this._shader=e;for(var t=this._renderStates,n=t.length,r=0,i=e.subShaders,a=0;a<i.length;a++)r=Math.max(i[a].passes.length,r);if(n<r)for(var o=n;o<r;o++)t.push(new l8);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),n6),ui="#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}",ua=((n9=function(){}).init=function(){var t={pipelineStage:e.PipelineStage.ShadowCaster},n={pipelineStage:e.PipelineStage.Forward},r=new lJ("#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nvoid main(){\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",t);l$.create("blinn-phong",[new lJ("#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),r]),l$.create("pbr",[new lJ(ui,"#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),r]),l$.create("pbr-specular",[new lJ(ui,"#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),r]),l$.create("unlit",[new lJ("#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),r]),l$.create("skybox",[new lJ("#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)]),l$.create("SkyProcedural",[new lJ("#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)]),l$.create("particle-shader",[new lJ("#define GLSLIFY 1\nattribute vec3 a_position;attribute vec3 a_velocity;attribute vec3 a_acceleration;attribute vec4 a_color;attribute vec4 a_lifeAndSize;attribute vec2 a_rotation;attribute vec3 a_uv;attribute vec2 a_normalizedUv;uniform float u_time;uniform bool u_once;uniform mat4 renderer_MVPMat;varying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;\n#ifdef is2d\nuniform mat4 camera_ViewInvMat;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;uniform mat4 renderer_ModelMat;\n#endif\nmat2 rotation2d(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_color=a_color;v_uv=a_uv.xy;float life=a_lifeAndSize.y;float startTime=a_lifeAndSize.x;float deltaTime=max(mod(u_time-startTime,life),0.0);if((u_once&&u_time>life+startTime)){deltaTime=0.0;}v_lifeLeft=1.0-deltaTime/life;float scale=a_lifeAndSize.z;vec3 position=a_position+(a_velocity+a_acceleration*deltaTime*0.5)*deltaTime;\n#ifdef isScaleByLifetime\nscale*=v_lifeLeft;\n#else\nscale*=pow(a_lifeAndSize.w,deltaTime);\n#endif\n#ifdef rotateToVelocity\nvec3 v=a_velocity+a_acceleration*deltaTime;float angle=atan(v.z,v.x)*2.0;\n#else\nfloat deltaAngle=deltaTime*a_rotation.y;float angle=a_rotation.x+deltaAngle;\n#endif\n#ifdef is2d\nvec2 rotatedPoint=rotation2d(angle)*vec2(a_normalizedUv.x,a_normalizedUv.y*a_uv.z);vec3 basisX=camera_ViewInvMat[0].xyz;vec3 basisZ=camera_ViewInvMat[1].xyz;vec3 localPosition=vec3(basisX*rotatedPoint.x+basisZ*rotatedPoint.y)*scale+position;gl_Position=camera_ProjMat*camera_ViewMat*vec4(localPosition+renderer_ModelMat[3].xyz,1.);\n#else\n#ifdef rotateToVelocity\nfloat s=sin(angle);float c=cos(angle);\n#else\nfloat s=sin(angle);float c=cos(angle);\n#endif\nvec4 rotatedPoint=vec4((a_normalizedUv.x*c+a_normalizedUv.y*a_uv.z*s)*scale,0.,(a_normalizedUv.x*s-a_normalizedUv.y*a_uv.z*c)*scale,1.);vec4 orientation=vec4(0,0,0,1);vec4 q2=orientation+orientation;vec4 qx=orientation.xxxw*q2.xyzx;vec4 qy=orientation.xyyw*q2.xyzy;vec4 qz=orientation.xxzw*q2.xxzz;mat4 localMatrix=mat4((1.0-qy.y)-qz.z,qx.y+qz.w,qx.z-qy.w,0,qx.y-qz.w,(1.0-qx.x)-qz.z,qy.z+qx.w,0,qx.z+qy.w,qy.z-qx.w,(1.0-qx.x)-qy.y,0,position.x,position.y,position.z,1);rotatedPoint=localMatrix*rotatedPoint;gl_Position=renderer_MVPMat*rotatedPoint;\n#endif\n}","#define GLSLIFY 1\nvarying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;uniform sampler2D u_texture;void main(){if(v_lifeLeft==1.0){discard;}float alphaFactor=1.0;\n#ifdef fadeIn\nfloat fadeInFactor=step(0.5,v_lifeLeft);alphaFactor=2.0*fadeInFactor*(1.0-v_lifeLeft)+(1.0-fadeInFactor);\n#endif\n#ifdef fadeOut\nfloat fadeOutFactor=step(0.5,v_lifeLeft);alphaFactor=alphaFactor*2.0*(1.0-fadeOutFactor)*v_lifeLeft+alphaFactor*fadeOutFactor;\n#endif\n#ifdef particleTexture\nvec4 tex=texture2D(u_texture,v_uv);\n#ifdef useOriginColor\ngl_FragColor=vec4(tex.rgb,alphaFactor*tex.a*v_color.w);\n#else\ngl_FragColor=vec4(v_color.xyz*tex.rgb,alphaFactor*tex.a*v_color.w);\n#endif\n#else\ngl_FragColor=vec4(v_color.xyz,alphaFactor*v_color.w);\n#endif\n}",n)]),l$.create("SpriteMask",[new lJ("#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)]),l$.create("Sprite",[new lJ("#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)]),l$.create("background-texture",[new lJ("#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",n)])},n9),uo=((rt=(re=function(){this._cacheHierarchy=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,n=e._length;n>this._cacheHierarchy&&this._resizeCacheMapHierarchy(t,0,n);for(var r=e._mask,i=e._length-1,a=this._cacheHierarchy-1,o=0;o<a;o++){var s=i<o?0:r[o],l=t[s];l||(t[s]=l=Object.create(null)),t=l}var c=i<a?0:r[a],u=t[c];return u||(this._lastQueryKey=c,this._lastQueryMap=t),u},rt.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rt._resizeCacheMapHierarchy=function(e,t,n){var r=this._cacheHierarchy-1;if(t==r){for(var i in e)for(var a=e[i],o=e,s=0,l=n-r;s<l;s++)s==l-1?o[0]=a:o=o[0==s?i:0]=Object.create(null);this._cacheHierarchy=n}else for(var c in e)this._resizeCacheMapHierarchy(e[c],++t,n)},re);ua.init();var us=function(t){function n(r,i,a){if((o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new l8,o._renderElementPool=new lO(l7),o._meshRenderDataPool=new lO(lz),o._spriteRenderDataPool=new lO(cL),o._spriteMaskRenderDataPool=new lO(cP),o._textRenderDataPool=new lO(cD),o._renderContext=new l6,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new lG,o._settings={},o._resourceManager=new cV(s$(o)),o._sceneManager=new cB(s$(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new lA,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._animate=function(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=i,o._hardwareRenderer.init(r,o._onDeviceLost.bind(s$(o)),o._onDeviceRestored.bind(s$(o))),o._canvas=r,o._spriteMaskManager=new cR(s$(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=lT.createFromOS(s$(o),"Arial"),o._textDefaultFont.isGCIgnored=!1,o.inputManager=new un(s$(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var o,s=new lp(s$(o),1,1,e.TextureFormat.Depth16,!1);s.isGCIgnored=!0,o._depthTexture2D=s}else o._macroCollection.enable(n._noDepthTextureMacro);var l=new ur(s$(o),l$.find("unlit"));l.shaderData.setColor("material_BaseColor",new s5(1,0,1.01,1)),o._magentaMaterial=l;var c=new ur(s$(o),l$.find("background-texture"));c.isGCIgnored=!0,c.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,o._backgroundTextureMaterial=c;var u=o._settings,h=a.colorSpace||e.ColorSpace.Linear;return h===e.ColorSpace.Gamma&&o._macroCollection.enable(n._gammaMacro),u.colorSpace=h,o}s3(n,t);var r=n.prototype;return r.createEntity=function(e){return new lV(this,e)},r.pause=function(){this._isPaused=!0,cancelAnimationFrame(this._requestId),clearTimeout(this._timeoutId)},r.resume=function(){this._isPaused&&(this._isPaused=!1,this.time._reset(),this._requestId=requestAnimationFrame(this._animate))},r.update=function(){if(!this._isDeviceLost){var e=this._time;e._update();var t=e.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._meshRenderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool();var n=this.inputManager,r=this._physicsInitialized;n._update();for(var i=this._sceneManager._scenes.getLoopArray(),a=i.length,o=0;o<a;o++){var s=i[o];s.destroyed||(s._cameraNeedSorting&&s._sortCameras(),s._componentsManager.callScriptOnStart())}if(r)for(var l=0;l<a;l++){var c=i[l];c.destroyed||c.physics._update(t)}r&&n._firePointerScript(i);for(var u=0;u<a;u++){var h=i[u];h.destroyed||h._componentsManager.callScriptOnUpdate(t)}for(var d=0;d<a;d++){var _=i[d];_.destroyed||_._componentsManager.callAnimationUpdate(t)}for(var f=0;f<a;f++){var p=i[f];p.destroyed||p._componentsManager.callScriptOnLateUpdate(t)}this._render(i);for(var g=0;g<a;g++){var m=i[g];m.destroyed||this._waitingDestroy||m._componentsManager.handlingInvalidScripts()}this._waitingDestroy&&this._destroy(),this._frameInProcess=!1}},r.run=function(){this.resume(),this.dispatch("run",this)},r.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},r.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},r._destroy=function(){this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._magentaTexture2D.destroy(!0),this._magentaTextureCube.destroy(!0),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this.dispatch("shutdown",this),this.pause(),this._spriteMaskManager.destroy(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},r.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},r._getShaderProgramPool=function(e){var t=e._shaderPassId,n=this._shaderProgramPools,r=n[t];if(!r){var i=t+1;i>n.length&&(n.length=i),n[t]=r=new uo}return r},r._render=function(e){for(var t=0,n=e.length;t<n;t++){var r=e[t];if(!r.destroyed){var i=this.time.deltaTime;r._componentsManager.callRendererOnUpdate(i),r._updateShaderData()}}for(var a=0,o=e.length;a<o;a++){var s=e[a];if(!s.destroyed){var l=s._activeCameras,c=l.length;if(c>0)for(var u=0;u<c;u++){var h=l[u],d=s._componentsManager;d.callCameraOnBeginRender(h),h.render(),d.callCameraOnEndRender(h),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else ld.debug("No active camera in scene.")}}},r._initMagentaTextures=function(t){var n=new Uint8Array([255,0,255,255]),r=new lp(this,1,1,e.TextureFormat.R8G8B8A8,!1);r.setPixelBuffer(n),r.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s3(o=function(){return la.call(this,r)},la),o.prototype.restoreContent=function(){this.resource.setPixelBuffer(n)},o));for(var i=new lm(this,1,e.TextureFormat.R8G8B8A8,!1),a=0;a<6;a++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+a,n);if(i.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s3(s=function(){return la.call(this,i)},la),s.prototype.restoreContent=function(){for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,n)},s)),this._magentaTexture2D=r,this._magentaTextureCube=i,t.isWebGL2){var o,s,l,c=new lg(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);c.setPixelBuffer(0,n),c.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s3(l=function(){return la.call(this,c)},la),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,n)},l)),this._magentaTexture2DArray=c}},r._initialize=function(e){var t=this,n=e.physics;return n?n.initialize().then(function(){return cj._nativePhysics=n,t._nativePhysicsManager=n.createPhysicsManager(),t._physicsInitialized=!0,t}):Promise.resolve(this)},r._createSpriteMaterial=function(){var t=new ur(this,l$.find("Sprite")),n=t.renderState,r=n.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=e.BlendFactor.One,r.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=e.BlendOperation.Add,n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,t.renderState.renderQueueType=e.RenderQueueType.Transparent,t.isGCIgnored=!0,t},r._createSpriteMaskMaterial=function(){var t=new ur(this,l$.find("SpriteMask")),n=t.renderState;return n.blendState.targetBlendState.colorWriteMask=e.ColorWriteMask.None,n.rasterState.cullMode=e.CullMode.Off,n.stencilState.enabled=!0,n.depthState.enabled=!1,t.isGCIgnored=!0,t},r._onDeviceLost=function(){this._isDeviceLost=!0,console.log("Device lost."),this.dispatch("devicelost",this)},r._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new l8,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)})},s1(n,[{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}}]),n}(lC);us._gammaMacro=lk.getByName("ENGINE_IS_COLORSPACE_GAMMA"),us._noDepthTextureMacro=lk.getByName("ENGINE_NO_DEPTH_TEXTURE"),us._pixelsPerUnit=100,e.BackgroundMode=void 0,(rn=e.BackgroundMode||(e.BackgroundMode={}))[rn.SolidColor=0]="SolidColor",rn[rn.Sky=1]="Sky",rn[rn.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(rr=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[rr.AspectFitWidth=0]="AspectFitWidth",rr[rr.AspectFitHeight=1]="AspectFitHeight",rr[rr.Fill=2]="Fill";var ul=((ri=function(){}).prototype._render=function(e){var t=this.material,n=this.mesh;if(!t){ld.warn("The material of sky is not defined.");return}if(!n){ld.warn("The mesh of sky is not defined.");return}var r=e.camera,i=r.engine,a=r.aspectRatio,o=r.fieldOfView,s=r.viewMatrix,l=r.shaderData,c=e.camera.scene.shaderData,u=ri._viewProjMatrix,h=ri._projectionMatrix,d=i._hardwareRenderer,_=t.shaderData,f=t.shader,p=t.renderState;u.copyFrom(s);var g=u.elements;g[12]=g[13]=g[14]=0;var m=1/Math.tan(sV.degreeToRadian(o)/2);h.elements[0]=m/a,h.elements[5]=m,sK.multiply(h,u,u);var v=l.getMatrix(l6.vpMatrixProperty);l.setMatrix(l6.vpMatrixProperty,u);var y=l$._compileMacros;lG.unionCollection(e.camera._globalShaderMacro,_._macroCollection,y);var x=f.subShaders[0].passes[0]._getShaderProgram(i,y);x.bind(),x.groupingOtherUniformBlock(),x.uploadAll(x.sceneUniformBlock,c),x.uploadAll(x.cameraUniformBlock,l),x.uploadAll(x.materialUniformBlock,_),x.uploadUnGroupTextures(),p._apply(i,!1),d.drawPrimitive(n,n.subMesh,x),l.setMatrix(l6.vpMatrixProperty,v)},ri);ul._epsilon=1e-6,ul._viewProjMatrix=new sK,ul._projectionMatrix=new sK(1,0,0,0,0,1,0,0,0,0,ul._epsilon-1,-1,0,0,0,0);var uc=((ro=(ra=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new sQ(.25,.25,.25,1),this.sky=new ul,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._initMesh(t)}).prototype)._initMesh=function(e){this._mesh=this._createPlane(e)},ro._resizeBackgroundTexture=function(){if(this._texture){var t=this._engine.canvas,n=t.width,r=t.height,i=this._mesh,a=i.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.Fill:a[0].set(-1,-1,1),a[1].set(1,-1,1),a[2].set(-1,1,1),a[3].set(1,1,1);break;case e.BackgroundTextureFillMode.AspectFitWidth:var o=this._texture.height*n/this.texture.width/r;a[0].set(-1,-o,1),a[1].set(1,-o,1),a[2].set(-1,o,1),a[3].set(1,o,1);break;case e.BackgroundTextureFillMode.AspectFitHeight:var s=this._texture.width*r/this.texture.height/n;a[0].set(-s,-1,1),a[1].set(s,-1,1),a[2].set(-s,1,1),a[3].set(s,1,1)}i.setPositions(a),i.uploadData(!1)}},ro._createPlane=function(e){var t=new ch(e);t.isGCIgnored=!0;for(var n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],i=[,,,,],a=0;a<4;++a)r[a]=new sO,i[a]=new sq(a%2,1-(.5*a|0));return t.setPositions(r),t.setUVs(i),t.setIndices(n),t.uploadData(!1),t.addSubMesh(0,n.length),t},s1(ra,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture",e))}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),ra),uu=((rl=(rs=function(){this._renderers=new lb,this._onStartScripts=new lb,this._onUpdateScripts=new lb,this._onLateUpdateScripts=new lb,this._onPhysicsUpdateScripts=new lb,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new lb,this._onUpdateRenderers=new lb,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},rl.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},rl.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},rl.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},rl.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},rl.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},rl.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},rl.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},rl.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},rl.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},rl.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},rl.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},rl.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},rl.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},rl.addDisableScript=function(e){this._disableScripts.push(e)},rl.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},rl.callScriptOnStart=function(){var e=this._onStartScripts;if(e.length>0){for(var t=e._elements,n=0;n<e.length;n++){var r=t[n];r._waitHandlingInValid||(r._started=!0,r._onStartIndex=-1,r.onStart())}e.length=0}},rl.callScriptOnUpdate=function(e){for(var t=this._onUpdateScripts._elements,n=this._onUpdateScripts.length-1;n>=0;--n){var r=t[n];!r._waitHandlingInValid&&r._started&&r.onUpdate(e)}},rl.callScriptOnLateUpdate=function(e){for(var t=this._onLateUpdateScripts._elements,n=this._onLateUpdateScripts.length-1;n>=0;--n){var r=t[n];!r._waitHandlingInValid&&r._started&&r.onLateUpdate(e)}},rl.callScriptOnPhysicsUpdate=function(){for(var e=this._onPhysicsUpdateScripts._elements,t=this._onPhysicsUpdateScripts.length-1;t>=0;--t){var n=e[t];!n._waitHandlingInValid&&n._started&&n.onPhysicsUpdate()}},rl.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},rl.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},rl.handlingInvalidScripts=function(){var e=this._disableScripts,t=e.length;if(t>0){for(var n=t-1;n>=0;n--){var r=e[n];r._waitHandlingInValid&&r._handlingInValid()}e.length=0}var i=this._disposeDestroyScripts,a=this._pendingDestroyScripts;if(this._disposeDestroyScripts=a,this._pendingDestroyScripts=i,(t=a.length)>0){for(var o=t-1;o>=0;o--)a[o].onDestroy();a.length=0}},rl.callCameraOnBeginRender=function(e){for(var t=e.entity._scripts,n=t.length-1;n>=0;--n){var r=t.get(n);r._waitHandlingInValid||r.onBeginRender(e)}},rl.callCameraOnEndRender=function(e){for(var t=e.entity._scripts,n=t.length-1;n>=0;--n){var r=t.get(n);r._waitHandlingInValid||r.onEndRender(e)}},rl.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},rl.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},rs);e.FogMode=void 0,(rc=e.FogMode||(e.FogMode={}))[rc.None=0]="None",rc[rc.Linear=1]="Linear",rc[rc.Exponential=2]="Exponential",rc[rc.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(ru=e.DiffuseMode||(e.DiffuseMode={}))[ru.SolidColor=0]="SolidColor",ru[ru.SphericalHarmonics=1]="SphericalHarmonics";var uh=((rd=(rh=function(){this._diffuseSolidColor=new sQ(.212,.227,.259),this._diffuseIntensity=1,this._specularIntensity=1,this._diffuseMode=e.DiffuseMode.SolidColor,this._shArray=new Float32Array(27),this._scenes=[],this._specularTextureDecodeRGBM=!1}).prototype)._addToScene=function(e){this._scenes.push(e);var t=e.shaderData;t.setColor(rh._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(rh._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(rh._specularIntensityProperty,this._specularIntensity),t.setFloatArray(rh._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},rd._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},rd._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(rh._shMacro):t.disableMacro(rh._shMacro)},rd._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(rh._specularTextureProperty,this._specularTexture),e.setFloat(rh._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(rh._specularMacro)):e.disableMacro(rh._specularMacro)},rd._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(rh._decodeRGBMMacro):e.disableMacro(rh._decodeRGBMMacro)},rd._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]},s1(rh,[{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 t=this._scenes,n=0,r=t.length;n<r;n++)t[n].shaderData.setFloatArray(rh._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)t[n].shaderData.setFloat(rh._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 t=0,n=this._scenes.length;t<n;t++)this._scenes[t].shaderData.setFloat(rh._specularIntensityProperty,e)}}]),rh);uh._shMacro=lk.getByName("SCENE_USE_SH"),uh._specularMacro=lk.getByName("SCENE_USE_SPECULAR_ENV"),uh._decodeRGBMMacro=lk.getByName("SCENE_IS_DECODE_ENV_RGBM"),uh._diffuseColorProperty=lS.getByName("scene_EnvMapLight.diffuse"),uh._diffuseSHProperty=lS.getByName("scene_EnvSH"),uh._diffuseIntensityProperty=lS.getByName("scene_EnvMapLight.diffuseIntensity"),uh._specularTextureProperty=lS.getByName("scene_EnvSpecularSampler"),uh._specularIntensityProperty=lS.getByName("scene_EnvMapLight.specularIntensity"),uh._mipLevelProperty=lS.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(r_=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[r_.NoCascades=1]="NoCascades",r_[r_.TwoCascades=2]="TwoCascades",r_[r_.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(rf=e.ShadowResolution||(e.ShadowResolution={}))[rf.Low=0]="Low",rf[rf.Medium=1]="Medium",rf[rf.High=2]="High",rf[rf.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(rp=e.ShadowType||(e.ShadowType={}))[rp.None=0]="None",rp[rp.Hard=1]="Hard",rp[rp.SoftLow=2]="SoftLow",rp[rp.SoftHigh=3]="SoftHigh";var ud=(s3(rg=function(){var t;return t=lw.apply(this,arguments)||this,t.intensity=1,t.cullingMask=e.Layer.Everything,t.shadowType=e.ShadowType.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t.shadowStrength=1,t._lightIndex=-1,t._color=new sQ(1,1,1,1),t._lightColor=new sQ,t},lw),rg.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},s1(rg,[{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 sK),sK.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new sK),sK.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),rg);ud._maxLight=10,s8([s7],ud.prototype,"_lightIndex",void 0);var u_=(s3(rm=function(){var e;return e=ud.apply(this,arguments)||this,e._reverseDirection=new sO,e},ud),(rv=rm.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.direction,s=rm._combinedData,l=this.cullingMask;s.cullingMask[n]=65535&l,s.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(s.color[r]=sQ.gammaToLinearSpace(a.r),s.color[r+1]=sQ.gammaToLinearSpace(a.g),s.color[r+2]=sQ.gammaToLinearSpace(a.b)):(s.color[r]=a.r,s.color[r+1]=a.g,s.color[r+2]=a.b),s.direction[i]=o.x,s.direction[i+1]=o.y,s.direction[i+2]=o.z},rv._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},rv._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},rm._updateShaderData=function(e){var t=rm._combinedData;e.setIntArray(rm._cullingMaskProperty,t.cullingMask),e.setFloatArray(rm._colorProperty,t.color),e.setFloatArray(rm._directionProperty,t.direction)},s1(rm,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sO.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),rm);u_._cullingMaskProperty=lS.getByName("scene_DirectLightCullingMask"),u_._colorProperty=lS.getByName("scene_DirectLightColor"),u_._directionProperty=lS.getByName("scene_DirectLightDirection"),u_._combinedData={cullingMask:new Int32Array(2*ud._maxLight),color:new Float32Array(3*ud._maxLight),direction:new Float32Array(3*ud._maxLight)};var uf=(s3(ry=function(){var e;return e=ud.apply(this,arguments)||this,e.distance=100,e},ud),(rx=ry.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.position,s=ry._combinedData,l=this.cullingMask;s.cullingMask[n]=65535&l,s.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(s.color[r]=sQ.gammaToLinearSpace(a.r),s.color[r+1]=sQ.gammaToLinearSpace(a.g),s.color[r+2]=sQ.gammaToLinearSpace(a.b)):(s.color[r]=a.r,s.color[r+1]=a.g,s.color[r+2]=a.b),s.position[i]=o.x,s.position[i+1]=o.y,s.position[i+2]=o.z,s.distance[t]=this.distance},rx._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},rx._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},ry._updateShaderData=function(e){var t=ry._combinedData;e.setIntArray(ry._cullingMaskProperty,t.cullingMask),e.setFloatArray(ry._colorProperty,t.color),e.setFloatArray(ry._positionProperty,t.position),e.setFloatArray(ry._distanceProperty,t.distance)},s1(ry,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),ry);uf._cullingMaskProperty=lS.getByName("scene_PointLightCullingMask"),uf._colorProperty=lS.getByName("scene_PointLightColor"),uf._positionProperty=lS.getByName("scene_PointLightPosition"),uf._distanceProperty=lS.getByName("scene_PointLightDistance"),uf._combinedData={cullingMask:new Int32Array(2*ud._maxLight),color:new Float32Array(3*ud._maxLight),position:new Float32Array(3*ud._maxLight),distance:new Float32Array(ud._maxLight)};var up=(s3(rT=function(){var e;return e=ud.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new sO,e._projectMatrix=new sK,e},ud),(rC=rT.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.direction,c=rT._combinedData,u=this.cullingMask;c.cullingMask[n]=65535&u,c.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(c.color[r]=sQ.gammaToLinearSpace(o.r),c.color[r+1]=sQ.gammaToLinearSpace(o.g),c.color[r+2]=sQ.gammaToLinearSpace(o.b)):(c.color[r]=o.r,c.color[r+1]=o.g,c.color[r+2]=o.b),c.position[i]=s.x,c.position[i+1]=s.y,c.position[i+2]=s.z,c.direction[a]=l.x,c.direction[a+1]=l.y,c.direction[a+2]=l.z,c.distance[t]=this.distance,c.angleCos[t]=Math.cos(this.angle),c.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},rC._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},rC._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},rT._updateShaderData=function(e){var t=rT._combinedData;e.setIntArray(rT._cullingMaskProperty,t.cullingMask),e.setFloatArray(rT._colorProperty,t.color),e.setFloatArray(rT._positionProperty,t.position),e.setFloatArray(rT._directionProperty,t.direction),e.setFloatArray(rT._distanceProperty,t.distance),e.setFloatArray(rT._angleCosProperty,t.angleCos),e.setFloatArray(rT._penumbraCosProperty,t.penumbraCos)},s1(rT,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sO.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 sK.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),rT);up._cullingMaskProperty=lS.getByName("scene_SpotLightCullingMask"),up._colorProperty=lS.getByName("scene_SpotLightColor"),up._positionProperty=lS.getByName("scene_SpotLightPosition"),up._directionProperty=lS.getByName("scene_SpotLightDirection"),up._distanceProperty=lS.getByName("scene_SpotLightDistance"),up._angleCosProperty=lS.getByName("scene_SpotLightAngleCos"),up._penumbraCosProperty=lS.getByName("scene_SpotLightPenumbraCos"),up._combinedData={cullingMask:new Int32Array(2*ud._maxLight),color:new Float32Array(3*ud._maxLight),position:new Float32Array(3*ud._maxLight),direction:new Float32Array(3*ud._maxLight),distance:new Float32Array(ud._maxLight),angleCos:new Float32Array(ud._maxLight),penumbraCos:new Float32Array(ud._maxLight)};var ug=((rA=(rS=function(){this._spotLights=new lb,this._pointLights=new lb,this._directLights=new lb}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},rA._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rA._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},rA._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rA._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},rA._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rA._getSunLightIndex=function(){for(var t=this._directLights,n=-1,r=Number.NEGATIVE_INFINITY,i=!1,a=0,o=t.length;a<o;a++){var s=t.get(a);s.shadowType===e.ShadowType.None||i||(r=Number.NEGATIVE_INFINITY,i=!0);var l=s.intensity*s.color.getBrightness();i?s.shadowType!==e.ShadowType.None&&r<l&&(r=l,n=a):r<l&&(r=l,n=a)}return n},rA._updateShaderData=function(e){for(var t=this._spotLights,n=this._pointLights,r=this._directLights,i=t.length,a=n.length,o=r.length,s=0;s<i;s++)t.get(s)._appendData(s);for(var l=0;l<a;l++)n.get(l)._appendData(l);for(var c=0;c<o;c++)r.get(c)._appendData(c);o?(u_._updateShaderData(e),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),a?(uf._updateShaderData(e),e.enableMacro("SCENE_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),i?(up._updateShaderData(e),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},rS),um=function(t){function n(r,i){(a=t.call(this,r)||this).physics=new cj(s$(a)),a.background=new uc(a._engine),a.shaderData=new l0(o3.Scene),a.castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new sO(1/15,.2,7/15),a.shadowDistance=50,a._cameraNeedSorting=!1,a._lightManager=new ug,a._componentsManager=new uu,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new lG,a._rootEntities=[],a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new sQ(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new sY,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new uh,r.sceneManager._allCreatedScenes.push(s$(a)),o.enableMacro("SCENE_FOG_MODE",a._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",a.shadowCascades.toString()),o.setColor(n._fogColorProperty,a._fogColor),o.setVector4(n._fogParamsProperty,a._fogParams),a._computeLinearFogParams(a._fogStart,a._fogEnd),a._computeExponentialFogParams(a._fogDensity),a}s3(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new lV(this._engine,e);return this.addRootEntity(t),t},r.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());var i=t._scene;i!==this?(i&&r&&i._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var a=o1.None;this._isActiveInEngine?t._isActiveInHierarchy&&i!==this&&(a|=o1.Scene):t._isActiveInHierarchy&&(a|=o1.Hierarchy),a&&t._processInActive(a),i!==this&&lV._traverseSetOwnerScene(t,this);var o=o1.None;this._isActiveInEngine&&t._isActive&&(t._isActiveInHierarchy||(o|=o1.Hierarchy),t._isActiveInScene&&i===this||(o|=o1.Scene)),o&&t._processActive(o)},r.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=o1.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=o1.Hierarchy),e._isActiveInScene&&(t|=o1.Hierarchy),t&&e._processInActive(t),lV._traverseSetOwnerScene(e,null)}},r.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},r.findEntityByName=function(e){for(var t=this._rootEntities,n=0,r=t.length;n<r;n++){var i=t[n].findByName(e);if(i)return i}return null},r.findEntityByPath=function(e){for(var t=e.split("/").filter(Boolean),n=0,r=this.rootEntitiesCount;n<r;n++){var i=this.getRootEntity(n);if(i.name==t[0]){for(var a=1,o=t.length;a<o&&(i=lV._findChildByName(i,t[a]));++a);return i}}return null},r._sortCameras=function(){this._activeCameras.sort(function(e,t){return e.priority-t.priority}),this._cameraNeedSorting=!1},r._attachRenderCamera=function(e){var t=this._activeCameras;-1===t.indexOf(e)?(t.push(e),this._cameraNeedSorting=!0):ld.warn("Camera already attached.")},r._detachRenderCamera=function(e){var t=this._activeCameras,n=t.indexOf(e);-1!==n&&t.splice(n,1)},r._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(o1.Hierarchy):r._processInActive(o1.Hierarchy))}},r._updateShaderData=function(){var t=this.shaderData,r=this._engine,i=this._lightManager;r.time._updateSceneShaderData(t),i._updateShaderData(this.shaderData);var a=i._getSunLightIndex();if(-1!==a){var o=i._directLights.get(a);t.setColor(n._sunlightColorProperty,o._getLightIntensityColor()),t.setVector3(n._sunlightDirectionProperty,o.direction),this._sunLight=o}this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),lG.unionCollection(this.engine._macroCollection,t._macroCollection,this._globalShaderMacro)},r._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},r._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._engine.sceneManager;for(e.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this._activeCameras.length=0,this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var n=e._allCreatedScenes;n.splice(n.indexOf(this),1)},r._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 i=e+1,a=r+1;i<a;i++)n[i]._siblingIndex++}},r._computeLinearFogParams=function(e,t){var n=t-e,r=this._fogParams;r.x=-1/n,r.y=t/n},r._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},s1(n,[{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){ld.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}}]),n}(lr);um._fogColorProperty=lS.getByName("scene_FogColor"),um._fogParamsProperty=lS.getByName("scene_FogParams"),um._sunlightColorProperty=lS.getByName("scene_SunlightColor"),um._sunlightDirectionProperty=lS.getByName("scene_SunlightDirection");var uv=(s3(rw=function(){var e;return e=lw.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._waitHandlingInValid=!1,e},lw),(rE=rw.prototype).onAwake=function(){},rE.onEnable=function(){},rE.onStart=function(){},rE.onUpdate=function(e){},rE.onLateUpdate=function(e){},rE.onBeginRender=function(e){},rE.onEndRender=function(e){},rE.onPhysicsUpdate=function(){},rE.onTriggerEnter=function(e){},rE.onTriggerExit=function(e){},rE.onTriggerStay=function(e){},rE.onCollisionEnter=function(e){},rE.onCollisionExit=function(e){},rE.onCollisionStay=function(e){},rE.onPointerDown=function(e){},rE.onPointerUp=function(e){},rE.onPointerClick=function(e){},rE.onPointerEnter=function(e){},rE.onPointerExit=function(e){},rE.onPointerDrag=function(e){},rE.onDisable=function(){},rE.onDestroy=function(){},rE._onAwake=function(){this.onAwake()},rE._onEnable=function(){this.onEnable()},rE._onDisable=function(){this.onDisable()},rE._onEnableInScene=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.scene._componentsManager,t=rw.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)}},rE._onDisableInScene=function(){this._waitHandlingInValid=!0,this.scene._componentsManager.addDisableScript(this)},rE._handlingInValid=function(){var e=this.scene._componentsManager,t=rw.prototype;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),this._waitHandlingInValid=!1},rE._onDestroy=function(){lw.prototype._onDestroy.call(this),this.scene._componentsManager.addPendingDestroyScript(this)},rw);s8([s7],uv.prototype,"_started",void 0),s8([s7],uv.prototype,"_onStartIndex",void 0),s8([s7],uv.prototype,"_onUpdateIndex",void 0),s8([s7],uv.prototype,"_onLateUpdateIndex",void 0),s8([s7],uv.prototype,"_onPhysicsUpdateIndex",void 0),s8([s7],uv.prototype,"_onPreRenderIndex",void 0),s8([s7],uv.prototype,"_onPostRenderIndex",void 0),s8([s7],uv.prototype,"_entityScriptsIndex",void 0),s8([s7],uv.prototype,"_waitHandlingInValid",void 0);var uy=(s3(rM=function(){return cb.apply(this,arguments)},cb),(rb=rM.prototype).createVertexElements=function(t){return t[0]=new ci("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new ci("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new ci("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rb.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPass.getTagValue(cb._disableBatchTag))return!1;var n=e.data,r=t.data,i=n.component,a=r.component;return!!this.checkBatchWithMask(i,a)&&n.texture===r.texture&&n.material===r.material},rb.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rb.updateVertices=function(e,t,n){for(var r=e.verticesData,i=r.positions,a=r.uvs,o=r.color,s=r.vertexCount,l=0;l<s;l++){var c=i[l],u=a[l];t[n++]=c.x,t[n++]=c.y,t[n++]=c.z,t[n++]=u.x,t[n++]=u.y,t[n++]=o.r,t[n++]=o.g,t[n++]=o.b,t[n++]=o.a}return n},rb.drawBatches=function(e){for(var t=this._engine,n=this._batchedQueue,r=this._meshes[this._flushId],i=r.subMeshes,a=t._spriteMaskManager,o=e.scene.shaderData,s=e.shaderData,l=0,c=i.length;l<c;l++){var u=i[l],h=n[l],d=h.data;if(!u||!h)return;var _=d.component,f=d.material;a.preRender(e,_);var p=l$._compileMacros;lG.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=h.shaderPass._getShaderProgram(t,p);if(!g.isValid)return;_.shaderData.setTexture(rM._textureProperty,d.texture),g.bind(),g.groupingOtherUniformBlock(),g.uploadAll(g.sceneUniformBlock,o),g.uploadAll(g.cameraUniformBlock,s),g.uploadAll(g.rendererUniformBlock,_.shaderData),g.uploadAll(g.materialUniformBlock,f.shaderData),h.renderState._apply(t,!1),t._hardwareRenderer.drawPrimitive(r,u,g),a.postRender(_)}},rb.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,i=e.length;r<i;++r)e[r].destroy();this._meshes=null;for(var a=0,o=t.length;a<o;++a)t[a].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},rM);uy._textureProperty=lS.getByName("renderer_SpriteTexture");var ux=((rR=(rF=function(e){this.elements=[],this._initSpriteBatcher(e)}).prototype).pushRenderElement=function(e){this.elements.push(e)},rR.render=function(e,t){var n=this.elements;if(0!==n.length){for(var r=e.engine,i=e.scene,a=r._renderCount,o=r._hardwareRenderer,s=i.shaderData,l=e.shaderData,c=0,u=n.length;c<u;c++){var h=n[c],d=h.data;if(d.component.entity.layer&t){if(d.mesh){this._spriteBatcher.flush(e);var _=l$._compileMacros,f=d.component,p=d.material.destroyed?r._magentaMaterial:d.material,g=f.shaderData,m=p.shaderData;lG.unionCollection(f._globalShaderMacro,m._macroCollection,_);var v=h.shaderPass._getShaderProgram(r,_);if(!v.isValid)continue;var y=v.bind();a!==v._uploadRenderCount?(v.groupingOtherUniformBlock(),v.uploadAll(v.sceneUniformBlock,s),v.uploadAll(v.cameraUniformBlock,l),v.uploadAll(v.rendererUniformBlock,g),v.uploadAll(v.materialUniformBlock,m),v.uploadUnGroupTextures(),v._uploadScene=i,v._uploadCamera=e,v._uploadRenderer=f,v._uploadMaterial=p,v._uploadRenderCount=a):(v._uploadScene!==i?(v.uploadAll(v.sceneUniformBlock,s),v._uploadScene=i):y&&v.uploadTextures(v.sceneUniformBlock,s),v._uploadCamera!==e?(v.uploadAll(v.cameraUniformBlock,l),v._uploadCamera=e):y&&v.uploadTextures(v.cameraUniformBlock,l),v._uploadRenderer!==f?(v.uploadAll(v.rendererUniformBlock,g),v._uploadRenderer=f):y&&v.uploadTextures(v.rendererUniformBlock,g),v._uploadMaterial!==p?(v.uploadAll(v.materialUniformBlock,m),v._uploadMaterial=p):y&&v.uploadTextures(v.materialUniformBlock,m),y&&v.uploadUnGroupTextures()),h.renderState._apply(r,f.entity.transform._isFrontFaceInvert()),o.drawPrimitive(d.mesh,d.subMesh,v)}else this._spriteBatcher.drawElement(h,e)}}this._spriteBatcher.flush(e)}},rR.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},rR.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rR.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},rR._initSpriteBatcher=function(e){this._spriteBatcher=new uy(e)},rR._quickSort=function(e,t,n,r){for(;;){if(n-t<=10){this._insertionSort(e,t,n,r);return}var i=t+n>>1,a=e[t],o=e[n-1],s=e[i];if(r(a,o)>0){var l=a;a=o,o=l}if(r(a,s)>=0){var c=a;a=s,s=o,o=c}else if(r(o,s)>0){var u=o;o=s,s=u}e[t]=a,e[n-1]=s;var h=o,d=t+1,_=n-1;e[i]=e[d],e[d]=h;e:for(var f=d+1;f<_;f++){var p=e[f],g=r(p,h);if(g<0)e[f]=e[d],e[d]=p,d++;else if(g>0){do{if(--_==f)break e;g=r(e[_],h)}while(g>0);e[f]=e[_],e[_]=p,g<0&&(p=e[f],e[f]=e[d],e[d]=p,d++)}}n-_<d-t?(this._quickSort(e,_,n,r),n=d):(this._quickSort(e,t,d,r),t=_)}},rR._insertionSort=function(e,t,n,r){for(var i=t+1;i<n;i++){var a=void 0,o=e[i];for(a=i-1;a>=t;a--){var s=e[a];if(r(s,o)>0)e[a+1]=s;else break}e[a+1]=o}},rF._compareFromNearToFar=function(e,t){return e.data.component.priority-t.data.component.priority||e.data.component._distanceForSort-t.data.component._distanceForSort},rF._compareFromFarToNear=function(e,t){return e.data.component.priority-t.data.component.priority||t.data.component._distanceForSort-e.data.component._distanceForSort},rF),uT=function(){this.position=new sO,this.isOrthographic=!1,this.viewMatrix=new sK,this.projectionMatrix=new sK,this.viewProjectionMatrix=new sK,this.forward=new sO},uC=function(){this.virtualCamera=new uT,this.cullPlanes=[new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO),new sG(new sO)],this.splitBoundSphere=new sU(new sO,0)};(rP=ss||(ss={}))[rP.FarBottomLeft=0]="FarBottomLeft",rP[rP.FarTopLeft=1]="FarTopLeft",rP[rP.FarTopRight=2]="FarTopRight",rP[rP.FarBottomRight=3]="FarBottomRight",rP[rP.nearBottomLeft=4]="nearBottomLeft",rP[rP.nearTopLeft=5]="nearTopLeft",rP[rP.nearTopRight=6]="nearTopRight",rP[rP.nearBottomRight=7]="nearBottomRight",rP[rP.unknown=8]="unknown";var uS=((rL=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}},rL.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rL.cullingRenderBounds=function(e,t,n){for(var r=e.min,i=e.max,a=0;a<t;a++){var o=n[a],s=o.normal;if(s.x*(s.x>=0?i.x:r.x)+s.y*(s.y>=0?i.y:r.y)+s.z*(s.z>=0?i.z:r.z)<-o.distance)return!1}return!0},rL.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&rL.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time.frameCount,n._prepareRender(e))},rL.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(sV.degreeToRadian(l)/2),u=c*c,h=t-e,d=t+e;u>h/d?(a=t,o=t*c):(a=.5*d*(1+u),o=.5*Math.sqrt(h*h+2*(t*t+e*e)*u+d*d*u*u));var _=i.splitBoundSphere.center;i.splitBoundSphere.radius=o,sO.scale(r,a,_),sO.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},rL.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=rL._frustumCorners,s=rL._backPlaneFaces,l=rL._frustumPlaneNeighbors,c=rL._frustumTwoPlaneCorners,u=rL._edgePlanePoint2,h=a.cullPlanes,d=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),g=t.getPlane(e.FrustumFace.Bottom),m=t.getPlane(e.FrustumFace.Top),v=rL._adjustNearPlane,y=rL._adjustFarPlane;v.normal.copyFrom(d.normal),y.normal.copyFrom(_.normal),v.distance=d.distance-(n-r),y.distance=Math.min(-d.distance+a.sphereCenterZ+a.splitBoundSphere.radius,_.distance),sk.intersectionPointThreePlanes(v,g,p,o[7]),sk.intersectionPointThreePlanes(v,m,p,o[6]),sk.intersectionPointThreePlanes(v,m,f,o[5]),sk.intersectionPointThreePlanes(v,g,f,o[4]),sk.intersectionPointThreePlanes(y,g,p,o[3]),sk.intersectionPointThreePlanes(y,m,p,o[2]),sk.intersectionPointThreePlanes(y,m,f,o[1]),sk.intersectionPointThreePlanes(y,g,f,o[0]);for(var x=0,T=0;T<6;T++){var C=void 0;switch(T){case e.FrustumFace.Near:C=v;break;case e.FrustumFace.Far:C=y;break;default:C=t.getPlane(T)}0>sO.dot(C.normal,i)&&(h[x].copyFrom(C),s[x]=T,x++)}for(var S=x,A=0;A<x;A++)for(var w=s[A],E=l[w],M=0;M<4;M++){for(var b=E[M],F=!0,R=0;R<x;R++)if(b==s[R]){F=!1;break}if(F){var P=c[w][b],L=o[P[0]],D=o[P[1]];sO.add(L,i,u),sG.fromPoints(L,D,u,h[S++])}}a.cullPlaneCount=S},rL.getDirectionalLightMatrices=function(e,t,n,r,i,a,o,s){var l=o.splitBoundSphere;o.resolution=a;var c=l.center,u=l.radius,h=a/2,d=u*h/(h-rL.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sO.dot(c,e)*f)*p,m=Math.ceil(sO.dot(c,t)*f)*p,v=sO.dot(c,n);c.x=e.x*g+t.x*m+n.x*v,c.y=e.y*g+t.y*m+n.y*v,c.z=e.z*g+t.z*m+n.z*v;var y=o.virtualCamera,x=y.position,T=y.viewMatrix,C=y.projectionMatrix;sO.scale(n,u+i,x),sO.subtract(c,x,x),sK.lookAt(x,c,e,T),sK.ortho(-d,d,-d,d,0,2*u+i,C);var S=y.viewProjectionMatrix;sK.multiply(C,T,S),lF._floatMatrixMultiply(rL._shadowMapCoordMatrix,S.elements,0,s,16*r)},rL.getMaxTileResolutionInAtlas=function(e,t,n){for(var r=Math.min(e,t),i=Math.floor(e/r)*Math.floor(t/r);i<n;)i=Math.floor(e/(r=Math.floor(r>>1)))*Math.floor(t/r);return r},rL.getShadowBias=function(t,n,r,i){var a=2/n.elements[0]/r,o=-t.shadowBias*a,s=-t.shadowNormalBias*a;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),i.set(o,s)},rL.applySliceTransform=function(e,t,n,r,i,a){var o=rL._tempMatrix0,s=o.elements,l=1/t,c=1/n,u=i.x*l,h=i.y*c;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*c,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=u,s[13]=h,s[14]=0,s[15]=1;var d=16*r;lF._floatMatrixMultiply(o,a,d,a,d)},rL);uS._tempMatrix0=new sK,uS._shadowMapCoordMatrix=new sK(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),uS._frustumCorners=[new sO,new sO,new sO,new sO,new sO,new sO,new sO,new sO],uS._adjustNearPlane=new sG(new sO),uS._adjustFarPlane=new sG(new sO),uS._backPlaneFaces=[,,,,,],uS._edgePlanePoint2=new sO,uS._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]],uS._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]]],uS.atlasBorderSize=4;var uA=function(){function t(n){this._shadowMapSize=new sY,this._shadowBias=new sq,this._shadowSliceData=new uC,this._lightUp=new sO,this._lightSide=new sO,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sO,this._viewportOffsets=[new sq,new sq,new sq,new sq],this._camera=n,this._engine=n.engine,this._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),this._shadowSliceData.virtualCamera.isOrthographic=!0}var n=t.prototype;return n._render=function(e){this._updateShadowSettings(),this._existShadowMap=!1,this._renderDirectShadowMap(e),this._existShadowMap&&this._updateReceiversShaderData()},n._renderDirectShadowMap=function(n){var r=this._engine,i=this._camera,a=this._viewportOffsets,o=this._shadowSliceData,s=this._splitBoundSpheres,l=this._shadowMatrices,c=i._renderPipeline,u=c._opaqueQueue,h=c._alphaTestQueue,d=c._transparentQueue,_=i.scene,f=_._componentsManager,p=r._hardwareRenderer,g=_.shadowCascades,m=t._cascadesSplitDistance,v=o.splitBoundSphere,y=t._tempMatrix0,x=y.elements,T=this._lightUp,C=this._lightSide,S=o.virtualCamera.forward,A=_._lightManager._getSunLightIndex();if(-1!==A){var w=i.scene._sunLight,E=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(E);var M=this._getAvailableRenderTarget();p.activeRenderTarget(M,t._viewport,0),this._supportDepthTexture?p.clearRenderTarget(r,e.CameraClearFlags.Depth,null):p.clearRenderTarget(r,e.CameraClearFlags.All,t._clearColor),this._shadowInfos.x=w.shadowStrength,this._shadowInfos.z=A,sK.rotationQuaternion(w.entity.transform.worldRotationQuaternion,y),C.set(x[0],x[1],x[2]),T.set(x[4],x[5],x[6]),S.set(-x[8],-x[9],-x[10]);var b=t._tempVector;b.copyFrom(i.entity.transform.worldForward);for(var F=this._shadowTileResolution,R=0;R<g;R++){if(uS.getBoundSphereByFrustum(m[R],m[R+1],i,b,o),uS.getDirectionLightShadowCullPlanes(i._frustum,m[R],i.nearClipPlane,S,o),uS.getDirectionalLightMatrices(T,C,S,R,w.shadowNearPlane,F,o,l),g>1){var P=this._shadowMapSize;uS.applySliceTransform(F,P.z,P.w,R,this._viewportOffsets[R],l)}this._updateSingleShadowCasterShaderData(w,o,n);var L=v.center,D=v.radius,I=4*R;s[I]=L.x,s[I+1]=L.y,s[I+2]=L.z,s[I+3]=D*D,u.clear(),h.clear(),d.clear();for(var B=f._renderers,N=B._elements,V=B.length-1;V>=0;--V)uS.shadowCullFrustum(n,w,N[V],o);if(u.elements.length||h.elements.length){u.sort(ux._compareFromNearToFar),h.sort(ux._compareFromNearToFar);var O=a[R],U=O.x,z=O.y;p.setGlobalDepthBias(1,1),p.viewport(U,z,F,F),p.scissor(U+1,z+1,F-2,F-2),r._renderCount++,u.render(i,e.Layer.Everything),h.render(i,e.Layer.Everything),p.setGlobalDepthBias(0,0)}}this._existShadowMap=!0}},n._updateReceiversShaderData=function(){var e=this._camera.scene,n=this._splitBoundSpheres,r=this._shadowMatrices,i=e.shadowCascades;if(i>1)for(var a=4*i,o=n.length;a<o;a++)n[a]=0;for(var s=16*i,l=r.length;s<l;s++)r[s]=0;var c=e.shaderData;c.setFloatArray(t._shadowMatricesProperty,this._shadowMatrices),c.setVector3(t._shadowInfosProperty,this._shadowInfos),c.setTexture(t._shadowMapsProperty,this._depthTexture),c.setFloatArray(t._shadowSplitSpheresProperty,this._splitBoundSpheres),c.setVector4(t._shadowMapSize,this._shadowMapSize)},n._getCascadesSplitDistance=function(n){var r=t._cascadesSplitDistance,i=this._camera.scene,a=i.shadowTwoCascadeSplits,o=i.shadowFourCascadeSplits,s=i.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,h=l.fieldOfView;r[0]=c;var d=n-c,_=Math.tan(.5*sV.degreeToRadian(h)),f=1+_*_*(u*u+1);switch(s){case e.ShadowCascadesMode.NoCascades:r[1]=this._getFarWithRadius(n,f);break;case e.ShadowCascadesMode.TwoCascades:r[1]=this._getFarWithRadius(c+d*a,f),r[2]=this._getFarWithRadius(n,f);break;case e.ShadowCascadesMode.FourCascades:r[1]=this._getFarWithRadius(c+d*o.x,f),r[2]=this._getFarWithRadius(c+d*o.y,f),r[3]=this._getFarWithRadius(c+d*o.z,f),r[4]=this._getFarWithRadius(n,f)}},n._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},n._getAvailableRenderTarget=function(){var t=this._engine,n=this._shadowMapFormat,r=this._shadowMapSize,i=r.z,a=r.w,o=this._depthTexture,s=this._renderTargets;return(null==s||(null==o?void 0:o.width)!==i||(null==o?void 0:o.height)!==a||(null==o?void 0:o.format)!==n)&&((o=this._depthTexture=new lp(t,i,a,n,!1)).wrapModeV=o.wrapModeU=e.TextureWrapMode.Clamp,t._hardwareRenderer._isWebGL2&&(o.depthCompareFunction=e.TextureDepthCompareFunction.Less),s=this._supportDepthTexture?this._renderTargets=new lf(t,i,a,null,o):this._renderTargets=new lf(t,i,a,o)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=uS.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=uS.shadowResolution(t.shadowResolution),i=t.shadowCascades;if(n!==this._shadowMapFormat||r!==this._shadowMapResolution||i!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=i,i==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var a=uS.getMaxTileResolutionInAtlas(r,r,i);this._shadowTileResolution=a;var o=2*a,s=i==e.ShadowCascadesMode.TwoCascades?a:2*a;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTargets=null;var l=this._viewportOffsets,c=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(c,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(c,0),l[2].set(0,c),l[3].set(c,c)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;uS.getShadowBias(e,i.projectionMatrix,this._shadowTileResolution,this._shadowBias);var a=this._camera.scene.shaderData;a.setVector2(t._lightShadowBiasProperty,this._shadowBias),a.setVector3(t._lightDirectionProperty,e.direction),r.applyVirtualCamera(i)},t}();uA._lightShadowBiasProperty=lS.getByName("scene_ShadowBias"),uA._lightDirectionProperty=lS.getByName("scene_LightDirection"),uA._shadowMatricesProperty=lS.getByName("scene_ShadowMatrices"),uA._shadowMapSize=lS.getByName("scene_ShadowMapSize"),uA._shadowInfosProperty=lS.getByName("scene_ShadowInfo"),uA._shadowMapsProperty=lS.getByName("scene_ShadowMap"),uA._shadowSplitSpheresProperty=lS.getByName("scene_ShadowSplitSpheres"),uA._maxCascades=4,uA._cascadesSplitDistance=Array(uA._maxCascades+1),uA._viewport=new sY(0,0,1,1),uA._clearColor=new sQ(1,1,1,1),uA._tempVector=new sO,uA._tempMatrix0=new sK;var uw=0,uE=((rI=(rD=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uw++),void 0===n&&(n=0),void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=null),this.name=t,this.enabled=!0,this.priority=n,this.renderTarget=r,this.replaceMaterial=i,this.mask=a||e.Layer.Everything,this.renderOverride=!1}).prototype).render=function(e,t,n,r){},rI.preRender=function(e,t,n,r){},rI.postRender=function(e,t,n,r){},rD),uM=((rN=(rB=function(e){this._allSpriteMasks=new lb,this._lastCanvasSize=new sq,this._camera=e;var t=e.engine;this._opaqueQueue=new ux(t),this._alphaTestQueue=new ux(t),this._transparentQueue=new ux(t),this._cascadedShadowCaster=new uA(e),this._renderPassArray=[],this._defaultPass=new uE("default",0,null,null,0),this.addRenderPass(this._defaultPass)}).prototype).addRenderPass=function(e,t,n,r,i){if(void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),"string"==typeof e){var a=new uE(e,t,n,r,i);this._renderPassArray.push(a)}else s6(e,uE)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},rN.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):s6(e,uE)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},rN.getRenderPass=function(e){for(var t=0,n=this._renderPassArray.length;t<n;t++){var r=this._renderPassArray[t];if(r.name===e)return r}return null},rN.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},rN.render=function(t,n,r){var i,a=this._camera,o=a.scene,s=this._opaqueQueue,l=this._alphaTestQueue,c=this._transparentQueue;a.engine._spriteMaskManager.clear(),t.pipelineStageTagValue=rB._shadowCasterPipelineStageTagValue,o.castShadows&&(null==(i=o._sunLight)?void 0:i.shadowType)!==e.ShadowType.None&&this._cascadedShadowCaster._render(t),s.clear(),l.clear(),c.clear(),this._allSpriteMasks.length=0,t.applyVirtualCamera(a._virtualCamera),t.pipelineStageTagValue=rB._forwardPipelineStageTagValue,this._callRender(t),s.sort(ux._compareFromNearToFar),l.sort(ux._compareFromNearToFar),c.sort(ux._compareFromFarToNear);for(var u=0,h=this._renderPassArray.length;u<h;u++)this._drawRenderPass(t,this._renderPassArray[u],a,n,r)},rN._drawRenderPass=function(t,n,r,i,a){if(n.preRender(r,this._opaqueQueue,this._alphaTestQueue,this._transparentQueue),n.enabled){var o,s,l=r.engine,c=r.scene.background,u=l._hardwareRenderer,h=r.renderTarget||n.renderTarget;u.activeRenderTarget(h,r.viewport,a),null==h||h._setRenderTargetInfo(i,a);var d=null!=(o=n.clearFlags)?o:r.clearFlags,_=null!=(s=n.clearColor)?s:c.solidColor;d!==e.CameraClearFlags.None&&u.clearRenderTarget(r.engine,d,_),n.renderOverride?n.render(r,this._opaqueQueue,this._alphaTestQueue,this._transparentQueue):(this._opaqueQueue.render(r,n.mask),this._alphaTestQueue.render(r,n.mask),r.clearFlags&e.CameraClearFlags.Color&&(c.mode===e.BackgroundMode.Sky?c.sky._render(t):c.mode===e.BackgroundMode.Texture&&c.texture&&this._drawBackgroundTexture(l,c)),this._transparentQueue.render(r,n.mask)),null==h||h._blitRenderTarget(),null==h||h.generateMipmaps()}n.postRender(r,this._opaqueQueue,this._alphaTestQueue,this._transparentQueue)},rN.pushRenderData=function(e,t){var n=t.material,r=n.renderStates,i=n.shader.subShaders[0],a=e.replacementShader;if(a){var o=a.subShaders,s=e.replacementTag;if(s)for(var l=0,c=o.length;l<c;l++){var u=o[l];if(u.getTagValue(s)===i.getTagValue(s)){this.pushRenderDataWihShader(e,t,u.passes,r);break}}else this.pushRenderDataWihShader(e,t,o[0].passes,r)}else this.pushRenderDataWihShader(e,t,i.passes,r)},rN.pushRenderDataWihShader=function(t,n,r,i){for(var a=t.pipelineStageTagValue,o=t.camera.engine._renderElementPool,s=0,l=r.length;s<l;s++){var c=r[s];if(c.getTagValue(l6.pipelineStageKey)===a){var u=o.getFromPool();switch(u.set(n,c,i[s]),u.renderState.renderQueueType){case e.RenderQueueType.Transparent:this._transparentQueue.pushRenderElement(u);break;case e.RenderQueueType.AlphaTest:this._alphaTestQueue.pushRenderElement(u);break;case e.RenderQueueType.Opaque:this._opaqueQueue.pushRenderElement(u)}}}},rN._drawBackgroundTexture=function(t,n){var r=t._hardwareRenderer,i=t._backgroundTextureMaterial,a=t.canvas,o=n._mesh;(this._lastCanvasSize.x!==a.width||this._lastCanvasSize.y!==a.height)&&n._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(a.width,a.height),n._resizeBackgroundTexture());var s=i.shader.subShaders[0].passes[0]._getShaderProgram(t,l$._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},rN._callRender=function(e){for(var t=e.camera.engine,n=e.camera,r=n.scene._componentsManager._renderers,i=r._elements,a=r.length-1;a>=0;--a){var o=i[a];n.cullingMask&o._entity.layer&&(!n.enableFrustumCulling||n._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},s1(rB,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rB);uM._shadowCasterPipelineStageTagValue=e.PipelineStage.ShadowCaster,uM._forwardPipelineStageTagValue=e.PipelineStage.Forward;var ub=function(){};ub.tempVec4=new sY,ub.tempVec3=new sO,ub.tempVec2=new sq,e.Camera=(s3(rV=function(t){(n=lw.call(this,t)||this).shaderData=new l0(o3.Camera),n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new lG,n._frustum=new sH,n._virtualCamera=new uT,n._replacementShader=null,n._replacementSubShaderTag=null,n._priority=0,n._isProjMatSetting=!1,n._nearClipPlane=.1,n._farClipPlane=100,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._isFrustumProjectDirty=!0,n._customAspectRatio=void 0,n._renderTarget=null,n._viewport=new sY(0,0,1,1),n._inverseProjectionMatrix=new sK,n._lastAspectSize=new sq(0,0),n._invViewProjMat=new sK;var n,r=n.entity.transform;return n._transform=r,n._isViewMatrixDirty=r.registerWorldChangeFlag(),n._isInvViewProjDirty=r.registerWorldChangeFlag(),n._frustumViewChangeFlag=r.registerWorldChangeFlag(),n._renderPipeline=new uM(s$(n)),n.shaderData._addReferCount(1),n},lw),(rO=rV.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rO.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rO.worldToViewportPoint=function(e,t){var n=ub.tempVec3,r=ub.tempVec4;sO.transformCoordinate(e,this.viewMatrix,n),sO.transformToVec4(n,this.projectionMatrix,r);var i=r.w;return t.set((r.x/i+1)*.5,(1-r.y/i)*.5,-n.z),t},rO.viewportToWorldPoint=function(e,t){var n,r=this.nearClipPlane,i=this.farClipPlane,a=1/(r-i);if(this.isOrthographic)n=-(2*e.z)*a+(i+r)*a;else{var o=e.z;n=(-o*(r+i)*a+2*r*i*a)/o}return this._innerViewportToWorldPoint(e.x,e.y,(n+1)/2,this._getInvViewProjMat(),t),t},rO.viewportPointToRay=function(e,t){var n=this._getInvViewProjMat(),r=this._innerViewportToWorldPoint(e.x,e.y,0,n,t.origin),i=this._innerViewportToWorldPoint(e.x,e.y,1,n,t.direction);return sO.subtract(i,r,i),i.normalize(),t},rO.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},rO.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},rO.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rO.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rO.screenPointToRay=function(e,t){var n=ub.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rO.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;sK.multiply(this.projectionMatrix,this.viewMatrix,r.viewProjectionMatrix),r.position.copyFrom(i.worldPosition),r.isOrthographic&&r.forward.copyFrom(i.worldForward),n.camera=this,n.virtualCamera=r,n.replacementShader=this._replacementShader,n.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&(this._frustumViewChangeFlag.flag||this._isFrustumProjectDirty)&&(this._frustum.calculateFromMatrix(r.viewProjectionMatrix),this._frustumViewChangeFlag.flag=!1,this._isFrustumProjectDirty=!1),this._updateShaderData(),lG.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,ld.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rO.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?lK.getByName(t):t},rO.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},rO._onEnableInScene=function(){this.scene._attachRenderCamera(this)},rO._onDisableInScene=function(){this.scene._detachRenderCamera(this)},rO._onDestroy=function(){var e;lw.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addReferCount(-1)},rO._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rO._innerViewportToWorldPoint=function(e,t,n,r,i){var a=ub.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sO.transformCoordinate(a,r,i),i},rO._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rO._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,sK.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rO._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,sK.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},s1(rV,[{key:"nearClipPlane",get:function(){return this._nearClipPlane},set:function(e){this._nearClipPlane=e,this._projMatChange()}},{key:"farClipPlane",get:function(){return this._farClipPlane},set:function(e){this._farClipPlane=e,this._projMatChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projMatChange()}},{key:"aspectRatio",get:function(){var e,t=this._entity.engine.canvas;return null!=(e=this._customAspectRatio)?e:t.width*this._viewport.z/(t.height*this._viewport.w)},set:function(e){this._customAspectRatio=e,this._projMatChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e),this._projMatChange()}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._entity._isActiveInScene&&this.enabled&&(this.scene._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projMatChange()}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projMatChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(this._isViewMatrixDirty.flag){this._isViewMatrixDirty.flag=!1;var t=this._transform;sK.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert()}return e}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix,n=this._entity.engine.canvas;if((!this._isProjectionDirty||this._isProjMatSetting)&&this._lastAspectSize.x===n.width&&this._lastAspectSize.y===n.height)return t;this._isProjectionDirty=!1,this._lastAspectSize.x=n.width,this._lastAspectSize.y=n.height;var r=this.aspectRatio;if(e.isOrthographic){var i=this._orthographicSize*r,a=this._orthographicSize;sK.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else sK.perspective(sV.degreeToRadian(this._fieldOfView),r,this._nearClipPlane,this._farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isProjMatSetting=!0,this._projMatChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget=e}}]),(sl=rV)._inverseViewMatrixProperty=lS.getByName("camera_ViewInvMat"),sl._cameraPositionProperty=lS.getByName("camera_Position"),sl),s8([lt],e.Camera.prototype,"_frustum",void 0),s8([s7],e.Camera.prototype,"_renderPipeline",void 0),s8([s7],e.Camera.prototype,"_virtualCamera",void 0),s8([s7],e.Camera.prototype,"_frustumViewChangeFlag",void 0),s8([s7],e.Camera.prototype,"_transform",void 0),s8([s7],e.Camera.prototype,"_isViewMatrixDirty",void 0),s8([s7],e.Camera.prototype,"_isInvViewProjDirty",void 0),s8([lt],e.Camera.prototype,"_viewport",void 0),s8([lt],e.Camera.prototype,"_inverseProjectionMatrix",void 0),s8([lt],e.Camera.prototype,"_lastAspectSize",void 0),s8([lt],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=s8([lM(lB,e.DependentMode.CheckOnly)],e.Camera);var uF={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uR=1/0;function uP(e,t){return void 0===t&&(t={}),new cN(function(n,r,i){var a,o,s,l,c,u=null!=(a=t.retryCount)?a:1,h=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:uR,t.type=null!=(l=t.type)?l:uF[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?uL:uD,_=new uI(function(){return d(e,t).onProgress(i).then(function(e){n(e),_.stop()}).catch(function(e){return c=e})},u,h);_.start(function(){r(c)})})}function uL(e,t){return new cN(function(n,r){var i,a=t.timeout,o=new Image,s=function(){r(Error("request "+e+" fail"))};o.onerror=s,o.onabort=s;var l=-1;a!=1/0&&(l=window.setTimeout(function(){r(Error("request "+e+" timeout"))},a)),o.onload=(i=l,function(){requestAnimationFrame(function(){n(o),o.onload=null,o.onerror=null,o.onabort=null}),clearTimeout(i)}),o.crossOrigin="anonymous",o.src=e})}function uD(e,t){return new cN(function(n,r,i){var a,o=new XMLHttpRequest;o.timeout=t.timeout,t.method=null!=(a=t.method)?a:"get",o.onload=function(){var t;if(o.status<200||o.status>=300){r(Error("request failed from: "+e));return}n(null!=(t=o.response)?t:o.responseText)},o.onerror=function(){r(Error("request failed from: "+e))},o.ontimeout=function(){r(Error("request timeout from: "+e))},o.onprogress=function(e){i(e.loaded/e.total)},o.open(t.method,e,!0),o.withCredentials="include"===t.credentials,o.responseType=t.type;var s=t.headers;s&&Object.keys(s).forEach(function(e){o.setRequestHeader(e,s[e])}),o.send(t.body)})}var uI=((rz=(rU=function(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}).prototype).start=function(e){this.done=e,this.exec()},rz.stop=function(){clearTimeout(this._timeoutId)},rz.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this.done&&this.done();return}this._currentCount++,this.execFunc(this._currentCount).then(function(){e._timeoutId=setTimeout(e.exec,e.interval)})},rU),uB=((rk=function(e){this.useCache=e,this.request=uP}).registerClass=function(e,t){this._engineObjects[e]=t},rk.getClass=function(e){return this._engineObjects[e]},rk);uB._engineObjects={},e.AssetType=void 0,(rG=e.AssetType||(e.AssetType={})).Text="Text",rG.JSON="JSON",rG.Buffer="Buffer",rG.Texture2D="Texture2D",rG.TextureCube="TextureCube",rG.Material="Material",rG.Mesh="Mesh",rG.AnimationClip="AnimationClip",rG.AnimatorController="AnimatorController",rG.GLTF="GLTF",rG.KTX="KTX",rG.KTXCube="KTXCube",rG.Sprite="Sprite",rG.SpriteAtlas="SpriteAtlas",rG.Env="Environment",rG.Scene="Scene",rG.HDR="HDR",rG.Font="Font",rG.SourceFont="SourceFont",e.BlendMode=void 0,(rH=e.BlendMode||(e.BlendMode={}))[rH.Normal=0]="Normal",rH[rH.Additive=1]="Additive",e.RenderFace=void 0,(rW=e.RenderFace||(e.RenderFace={}))[rW.Front=0]="Front",rW[rW.Back=1]="Back",rW[rW.Double=2]="Double";var uN=function(t){function n(r,i){var a;return(a=t.call(this,r,i)||this)._renderFace=e.RenderFace.Front,a._isTransparent=!1,a._blendMode=e.BlendMode.Normal,a.shaderData.setFloat(n._alphaCutoffProp,0),a}s3(n,t);var r=n.prototype;return r.setIsTransparent=function(t,r){var i=this.renderStates;if(i.length<t)throw"Pass should less than pass count.";var a=i[t];r?(a.blendState.targetBlendState.enabled=!0,a.depthState.writeEnabled=!1,a.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(n._transparentMacro)):(a.blendState.targetBlendState.enabled=!1,a.depthState.writeEnabled=!0,a.renderQueueType=this.shaderData.getFloat(n._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,this.shaderData.disableMacro(n._transparentMacro))},r.setBlendMode=function(t,n){var r=this.renderStates;if(r.length<t)throw"Pass should less than pass count.";var i=r[t].blendState.targetBlendState;switch(n){case e.BlendMode.Normal:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add;break;case e.BlendMode.Additive:i.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,i.destinationColorBlendFactor=e.BlendFactor.One,i.sourceAlphaBlendFactor=e.BlendFactor.One,i.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,i.colorBlendOperation=i.alphaBlendOperation=e.BlendOperation.Add}},r.setRenderFace=function(t,n){var r=this.renderStates;if(r.length<t)throw"Pass should less than pass count.";switch(n){case e.RenderFace.Front:r[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:r[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:r[t].rasterState.cullMode=e.CullMode.Off}},r.clone=function(){var e=new n(this._engine,this.shader);return this.cloneTo(e),e},r.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},s1(n,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader=t;for(var n=this._renderStates,r=n.length,i=0,a=t.subShaders,o=0;o<a.length;o++)i=Math.max(a[o].passes.length,i);if(r<i)for(var s=r;s<i;s++)n.push(new l8),this.setBlendMode(s,e.BlendMode.Normal);else n.length=i}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){e!==this._isTransparent&&(this.setIsTransparent(0,e),this._isTransparent=e)}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(n._alphaCutoffProp)},set:function(t){var r=this.shaderData;if(r.getFloat(n._alphaCutoffProp)!==t){t?r.enableMacro(n._alphaCutoffMacro):r.disableMacro(n._alphaCutoffMacro);for(var i=this.renderStates,a=0,o=i.length;a<o;a++){var s=i[a];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}r.setFloat(n._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),n}(ur);uN._baseTextureMacro=lk.getByName("MATERIAL_HAS_BASETEXTURE"),uN._normalTextureMacro=lk.getByName("MATERIAL_HAS_NORMALTEXTURE"),uN._emissiveTextureMacro=lk.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uN._transparentMacro=lk.getByName("MATERIAL_IS_TRANSPARENT"),uN._baseColorProp=lS.getByName("material_BaseColor"),uN._baseTextureProp=lS.getByName("material_BaseTexture"),uN._tilingOffsetProp=lS.getByName("material_TilingOffset"),uN._normalTextureProp=lS.getByName("material_NormalTexture"),uN._normalIntensityProp=lS.getByName("material_NormalIntensity"),uN._emissiveColorProp=lS.getByName("material_EmissiveColor"),uN._emissiveTextureProp=lS.getByName("material_EmissiveTexture"),uN._alphaCutoffProp=lS.getByName("material_AlphaCutoff"),uN._alphaCutoffMacro=lk.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uV=function(e){function t(n){var r,i=(r=e.call(this,n,l$.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new sQ(1,1,1,1)),i.setColor(t._specularColorProp,new sQ(1,1,1,1)),i.setColor(t._emissiveColorProp,new sQ(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new sY(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return s3(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s1(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}(uN);uV._specularColorProp=lS.getByName("material_SpecularColor"),uV._shininessProp=lS.getByName("material_Shininess"),uV._specularTextureProp=lS.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rX=e.TextureCoordinate||(e.TextureCoordinate={}))[rX.UV0=0]="UV0",rX[rX.UV1=1]="UV1",rX[rX.UV2=2]="UV2",rX[rX.UV3=3]="UV3",rX[rX.UV4=4]="UV4",rX[rX.UV5=5]="UV5",rX[rX.UV6=6]="UV6",rX[rX.UV7=7]="UV7";var uO=function(t){function n(r,i){var a,o=(a=t.call(this,r,i)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(n._baseColorProp,new sQ(1,1,1,1)),o.setColor(n._emissiveColorProp,new sQ(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new sY(1,1,0,0)),o.setFloat(n._normalIntensityProp,1),o.setFloat(n._occlusionTextureIntensityProp,1),o.setFloat(n._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(n._clearCoatProp,0),o.setFloat(n._clearCoatRoughnessProp,0),a}return s3(n,t),s1(n,[{key:"baseColor",get:function(){return this.shaderData.getColor(n._baseColorProp)},set:function(e){var t=this.shaderData.getColor(n._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(n._baseTextureProp)},set:function(e){this.shaderData.setTexture(n._baseTextureProp,e),e?this.shaderData.enableMacro(n._baseTextureMacro):this.shaderData.disableMacro(n._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(n._normalTextureProp)},set:function(e){this.shaderData.setTexture(n._normalTextureProp,e),e?this.shaderData.enableMacro(n._normalTextureMacro):this.shaderData.disableMacro(n._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(n._normalIntensityProp)},set:function(e){this.shaderData.setFloat(n._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(n._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(n._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(n._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(n._emissiveTextureProp,e),e?this.shaderData.enableMacro(n._emissiveTextureMacro):this.shaderData.disableMacro(n._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(n._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(n._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(n._occlusionTextureCoordProp)},set:function(t){t>e.TextureCoordinate.UV1&&ld.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(n._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(n._tilingOffsetProp)},set:function(e){var t=this.shaderData.getVector4(n._tilingOffsetProp);e!==t&&t.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(n._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(n._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(n._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(n._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(n._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(n._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(n._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),n}(uN);uO._occlusionTextureIntensityProp=lS.getByName("material_OcclusionIntensity"),uO._occlusionTextureCoordProp=lS.getByName("material_OcclusionTextureCoord"),uO._occlusionTextureProp=lS.getByName("material_OcclusionTexture"),uO._clearCoatProp=lS.getByName("material_ClearCoat"),uO._clearCoatTextureProp=lS.getByName("material_ClearCoatTexture"),uO._clearCoatRoughnessProp=lS.getByName("material_ClearCoatRoughness"),uO._clearCoatRoughnessTextureProp=lS.getByName("material_ClearCoatRoughnessTexture"),uO._clearCoatNormalTextureProp=lS.getByName("material_ClearCoatNormalTexture");var uU=function(e){function t(n){var r;return(r=e.call(this,n,l$.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return s3(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s1(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}}]),t}(uO);uU._metallicProp=lS.getByName("material_Metal"),uU._roughnessProp=lS.getByName("material_Roughness"),uU._roughnessMetallicTextureProp=lS.getByName("material_RoughnessMetallicTexture"),uU._iorProp=l$.getPropertyByName("material_IOR");var uz=function(e){function t(n){var r;return(r=e.call(this,n,l$.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new sQ(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return s3(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s1(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}(uO);uz._specularColorProp=lS.getByName("material_PBRSpecularColor"),uz._glossinessProp=lS.getByName("material_Glossiness"),uz._specularGlossinessTextureProp=lS.getByName("material_SpecularGlossinessTexture"),uz._specularGlossinessTextureMacro=lk.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uk=function(e){function t(n){var r,i=(r=e.call(this,n,l$.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new sQ(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new sY(1,1,0,0)),r}return s3(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s1(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}(uN);e.TextHorizontalAlignment=void 0,(rK=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rK.Left=0]="Left",rK[rK.Center=1]="Center",rK[rK.Right=2]="Right",e.TextVerticalAlignment=void 0,(rj=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[rj.Top=0]="Top",rj[rj.Center=1]="Center",rj[rj.Bottom=2]="Bottom";var uG=(s3(rq=function(e){var t;return(t=li.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},li),(rY=rq.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},rY.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 i=r[n];i.name===e&&t.push(i)}else console.warn("The name of the sprite you want to find is not exit in SpriteAtlas.");return t},rY._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1},rY._onDestroy=function(){li.prototype._onDestroy.call(this),this._sprites=null,this._spriteNamesToIndex=null},s1(rq,[{key:"sprites",get:function(){return this._sprites}}]),rq);e.SpriteDrawMode=void 0,(rQ=e.SpriteDrawMode||(e.SpriteDrawMode={}))[rQ.Simple=0]="Simple",rQ[rQ.Sliced=1]="Sliced",rQ[rQ.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(rJ=e.SpriteTileMode||(e.SpriteTileMode={}))[rJ.Continuous=0]="Continuous",rJ[rJ.Adaptive=1]="Adaptive";var uH=(s3(rZ=function(e,t,n,r,i,a){var o;return void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=null),void 0===a&&(a=null),(o=li.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new sq,new sq,new sq,new sq],o._uvs=[new sq,new sq,new sq,new sq],o._bounds=new sz,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new sJ(0,0,1,1),o._atlasRegionOffset=new sY(0,0,0,0),o._region=new sJ(0,0,1,1),o._pivot=new sq(.5,.5),o._border=new sY(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new lI,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},li),(r$=rZ.prototype).clone=function(){var e=new rZ(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},r$._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},r$._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},r$._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},r$._onDestroy=function(){li.prototype._onDestroy.call(this),this._texture=null},r$._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/us._pixelsPerUnit;this._automaticWidth=e.width*t.width/(1-n.x-n.z)*r.width*i,this._automaticHeight=e.height*t.height/(1-n.y-n.w)*r.height*i}else this._automaticWidth=this._automaticHeight=0;this._dirtyUpdateFlag&=-5},r$._updatePositions=function(){var e=this._atlasRegionOffset,t=this._region,n=t.x,r=t.y,i=t.width,a=t.height,o=Math.max(e.x-n,0)/i,s=Math.max(e.w-r,0)/a,l=1-Math.max(e.z-(1-n-i),0)/i,c=1-Math.max(e.y-(1-r-a),0)/a,u=this._positions;u[0].set(o,s),u[1].set(l,s),u[2].set(o,c),u[3].set(l,c);var h=this._bounds,d=h.min,_=h.max;d.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},r$._updateUVs=function(){var e=this._uvs,t=this._atlasRegionOffset,n=this._region,r=n.x,i=n.y,a=n.width,o=n.height,s=1-r-a,l=1-i-o,c=this._atlasRegion,u=c.x,h=c.y,d=c.width,_=c.height,f=t.x,p=t.y,g=t.z,m=t.w,v=d/(1-f-g),y=_/(1-p-m),x=this._border,T=x.x,C=x.y,S=x.z,A=x.w;e[0].set(Math.max(r-f,0)*v+u,_+h-Math.max(i-m,0)*y),e[1].set((r-f+T*a)*v+u,_+h-(i-m+C*o)*y),e[2].set(d+u-(s-g+S*a)*v,(l-p+A*o)*y+h),e[3].set(d+u-Math.max(s-g,0)*v,Math.max(l-p,0)*y+h),this._dirtyUpdateFlag&=-3},r$._dispatchSpriteChange=function(e){switch(e){case o6.texture:this._dirtyUpdateFlag|=4;break;case o6.atlasRegionOffset:case o6.region:this._dirtyUpdateFlag|=7;break;case o6.atlasRegion:this._dirtyUpdateFlag|=6;break;case o6.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},s1(rZ,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(o6.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(o6.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(o6.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(o6.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=sV.clamp(e.x,0,1),n=sV.clamp(e.y,0,1);this._atlasRegion.set(t,n,sV.clamp(e.width,0,1-t),sV.clamp(e.height,0,1-n)),this._dispatchSpriteChange(o6.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(o6.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=sV.clamp(e.x,0,1),n=sV.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,sV.clamp(e.z,0,1-t),sV.clamp(e.w,0,1-n)),this._dispatchSpriteChange(o6.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(o6.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=sV.clamp(e.x,0,1),r=sV.clamp(e.y,0,1);t.set(n,r,sV.clamp(e.width,0,1-n),sV.clamp(e.height,0,1-r)),this._dispatchSpriteChange(o6.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(o6.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(o6.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(o6.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=sV.clamp(e.x,0,1),r=sV.clamp(e.y,0,1);t.set(n,r,sV.clamp(e.z,0,1-n),sV.clamp(e.w,0,1-r)),this._dispatchSpriteChange(o6.border)}}]),rZ);(r0=sc||(sc={}))[r0.positions=1]="positions",r0[r0.uvs=2]="uvs",r0[r0.automaticSize=4]="automaticSize",r0[r0.all=7]="all";var uW=((r1=function(){}).resetData=function(e){var t=e._verticesData,n=t.positions,r=t.uvs;if(n.length<16)for(var i=n.length;i<16;i++)n.push(new sO),r.push(new sq);t.triangles=[]},r1.updatePositions=function(e){var t,n,r=e.width,i=e.height,a=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=o.triangles,u=a.border,h=a._getUVs(),d=a._getPositions(),_=d[0],f=_.x,p=_.y,g=d[3],m=g.x,v=g.y,y=a.width,x=a.height,T=y*u.x,C=x*u.y,S=y*u.z,A=x*u.w;if(T+S>r){var w=r/(T+S);t=[y*f*w,T*w,T*w,r-y*(1-m)*w]}else t=[y*f,T,r-S,r-y*(1-m)];if(A+C>i){var E=i/(A+C);n=[x*p*E,C*E,C*E,i-x*(1-v)*E]}else n=[x*p,C,i-A,i-x*(1-v)];var M=e.sprite.pivot,b=M.x,F=M.y,R=e.width*b,P=e.height*F,L=uW._worldMatrix,D=L.elements,I=e.entity.transform.worldMatrix.elements,B=e.flipX?-1:1,N=e.flipY?-1:1;D[0]=I[0]*B,D[1]=I[1]*B,D[2]=I[2]*B,D[4]=I[4]*N,D[5]=I[5]*N,D[6]=I[6]*N,D[8]=I[8],D[9]=I[9],D[10]=I[10],D[12]=I[12]-R*D[0]-P*D[4],D[13]=I[13]-R*D[1]-P*D[5],D[14]=I[14]-R*D[2]-P*D[6];for(var V=0,O=0,U=0;U<4;U++){for(var z=t[U],k=h[U].x,G=0;G<4;G++){var H=n[G];s[V].set(D[0]*z+D[4]*H+D[12],D[1]*z+D[5]*H+D[13],D[2]*z+D[6]*H+D[14]),l[V].set(k,h[G].y),++V}++O}for(var W=V/O,X=0,K=0;K<O-1;++K)for(var j=0;j<W-1;++j){var q=K*W+j;c[X++]=q,c[X++]=q+1,c[X++]=q+W,c[X++]=q+1,c[X++]=q+W+1,c[X++]=q+W}e._verticesData.vertexCount=O*W,c.length=(O-1)*(W-1)*6;var Y=e._bounds,Q=Y.min,J=Y.max;Q.set(t[0],n[0],0),J.set(t[3],n[3],0),e._bounds.transform(L)},r1.updateUVs=function(e){},r1._worldMatrix=new sK,r1);uW=s8([l9()],uW);var uX=((r2=function(){}).resetData=function(e){var t;(t=e._verticesData).triangles||(t.triangles=[])},r2.updatePositions=function(t){var n,r,i,a,o,s,l=t.width,c=t.height,u=t.sprite,h=t.tileMode,d=t.tiledAdaptiveThreshold,_=t._verticesData,f=_.positions,p=_.uvs,g=_.triangles,m=this._posRow,v=this._posColumn,y=this._uvRow,x=this._uvColumn;m.length=v.length=y.length=x.length=0,h===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(u,l,c,d,m,v,y,x):this._calculateContinuousDividing(u,l,c,m,v,y,x);var T=t.sprite.pivot,C=T.x,S=T.y,A=t.width*C,w=t.height*S,E=uX._worldMatrix,M=E.elements,b=t.entity.transform.worldMatrix.elements,F=t.flipX?-1:1,R=t.flipY?-1:1;n=M[0]=b[0]*F,r=M[1]=b[1]*F,i=M[2]=b[2]*F,a=M[4]=b[4]*R,o=M[5]=b[5]*R,s=M[6]=b[6]*R,M[8]=b[8],M[9]=b[9],M[10]=b[10];for(var P=M[12]=b[12]-A*M[0]-w*M[4],L=M[13]=b[13]-A*M[1]-w*M[5],D=M[14]=b[14]-A*M[2]-w*M[6],I=m.length-1,B=v.length-1,N=0,V=0,O=0;O<B;O++)for(var U=2*O,z=0;z<I;z++){var k=y.get(2*z),G=x.get(U),H=y.get(2*z+1),W=x.get(U+1);if(!(isNaN(k)||isNaN(k)||isNaN(H)||isNaN(W))){g[V++]=N,g[V++]=N+1,g[V++]=N+2,g[V++]=N+2,g[V++]=N+1,g[V++]=N+3;var X=m.get(z),K=v.get(O),j=m.get(z+1),q=v.get(O+1);p[N]?p[N].set(k,G):p[N]=new sq(k,G);var Y=f[N];Y?Y.set(n*X+a*K+P,r*X+o*K+L,i*X+s*K+D):f[N]=new sO(n*X+a*K+P,r*X+o*K+L,i*X+s*K+D),p[++N]?p[N].set(H,G):p[N]=new sq(H,G),(Y=f[N])?Y.set(n*j+a*K+P,r*j+o*K+L,i*j+s*K+D):f[N]=new sO(n*j+a*K+P,r*j+o*K+L,i*j+s*K+D),p[++N]?p[N].set(k,W):p[N]=new sq(k,W),(Y=f[N])?Y.set(n*X+a*q+P,r*X+o*q+L,i*X+s*q+D):f[N]=new sO(n*X+a*q+P,r*X+o*q+L,i*X+s*q+D),p[++N]?p[N].set(H,W):p[N]=new sq(H,W),(Y=f[N])?Y.set(n*j+a*q+P,r*j+o*q+L,i*j+s*q+D):f[N]=new sO(n*j+a*q+P,r*j+o*q+L,i*j+s*q+D),N++}}t._verticesData.vertexCount=N,g.length=V;var Q=t._bounds,J=Q.min,Z=Q.max;J.set(m.get(0),v.get(0),0),Z.set(m.get(I),v.get(B),0),t._bounds.transform(E)},r2.updateUVs=function(e){},r2._calculateAdaptiveDividing=function(e,t,n,r,i,a,o,s){var l,c,u,h,d,_,f,p=e.border,g=e._getPositions(),m=g[0],v=m.x,y=m.y,x=g[3],T=x.x,C=x.y,S=e._getUVs(),A=S[0],w=S[1],E=S[2],M=S[3],b=e.width,F=e.height,R=b*p.x,P=b*p.z,L=R+P,D=b-L,I=F*p.w,B=F*p.y,N=I+B,V=F-N;if(L>=t?(h=3,c=0):D>sV.zeroTolerance?(h=4+(_=(_=(t-L)/D)%1>=r?Math.ceil(_):Math.floor(_))-1,c=2):(h=4,c=1),N>=n?(d=3,u=0):V>sV.zeroTolerance?(d=4+(f=(f=(n-N)/V)%1>=r?Math.ceil(f):Math.floor(f))-1,u=2):(d=4,u=1),(h-1)*(d-1)*4>cb.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*T),a.add(n*y),a.add(n*C),o.add(A.x),o.add(M.x),s.add(A.y),s.add(M.y),ld.warn("The number of vertices exceeds the upper limit("+cb.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,i.add(b*v*l),i.add(R*l),i.add(t-b*(1-T)*l),o.add(A.x),o.add(w.x),o.add(E.x),o.add(M.x);break;case 1:i.add(b*v),i.add(R),i.add(t-P),i.add(t-b*(1-T)),o.add(A.x),o.add(w.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(M.x);break;case 2:l=t/(L+_*D),i.add(b*v*l),i.add(R*l),o.add(A.x),o.add(w.x),o.add(w.x);for(var O=0,U=_-1;O<U;O++)i.add(R+(O+1)*D*l),o.add(E.x),o.add(w.x);i.add(t-P*l),i.add(t-b*(1-T)*l),o.add(E.x),o.add(E.x),o.add(M.x)}switch(u){case 0:l=n/N,a.add(F*y*l),a.add(B*l),a.add(n-F*(1-C)*l),s.add(A.y),s.add(w.y),s.add(E.y),s.add(M.y);break;case 1:a.add(F*y),a.add(B),a.add(n-I),a.add(n-F*(1-C)),s.add(A.y),s.add(w.y),s.add(NaN),s.add(NaN),s.add(E.y),s.add(M.y);break;case 2:l=n/(N+f*V),a.add(F*y*l),a.add(B*l),s.add(A.y),s.add(w.y),s.add(w.y);for(var z=0,k=f-1;z<k;z++)a.add(B+(z+1)*V*l),s.add(E.y),s.add(w.y);a.add(n-I*l),a.add(n-F*(1-C)*l),s.add(E.y),s.add(E.y),s.add(M.y)}},r2._calculateContinuousDividing=function(e,t,n,r,i,a,o){var s,l,c,u,h,d,_=e.border,f=e._getPositions(),p=f[0],g=p.x,m=p.y,v=f[3],y=v.x,x=v.y,T=e._getUVs(),C=T[0],S=T[1],A=T[2],w=T[3],E=e.width,M=e.height,b=E*_.x,F=E*_.z,R=b+F,P=E-R,L=M*_.w,D=M*_.y,I=L+D,B=M-I;if(R>=t?(c=3,s=0):P>sV.zeroTolerance?(c=4+(0|(h=(t-R)/P)),s=2):(c=4,s=1),I>=n?(u=3,l=0):B>sV.zeroTolerance?(u=4+(0|(d=(n-I)/B)),l=2):(u=4,l=1),(c-1)*(u-1)*4>cb.MAX_VERTEX_COUNT){r.add(t*g),r.add(t*y),i.add(n*m),i.add(n*x),a.add(C.x),a.add(w.x),o.add(C.y),o.add(w.y),ld.warn("The number of vertices exceeds the upper limit("+cb.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var N=t/R;r.add(E*g*N),r.add(b*N),r.add(t-E*(1-y)*N),a.add(C.x),a.add(S.x),a.add(A.x),a.add(w.x);break;case 1:r.add(E*g),r.add(b),r.add(t-F),r.add(t-E*(1-y)),a.add(C.x),a.add(S.x),a.add(NaN),a.add(NaN),a.add(A.x),a.add(w.x);break;case 2:r.add(E*g),r.add(b),a.add(C.x),a.add(S.x),a.add(S.x);for(var V=0|h,O=0;O<V;O++)r.add(b+(O+1)*P),a.add(A.x),a.add(S.x);r.add(t-F),r.add(t-E*(1-y)),a.add((A.x-S.x)*(h-V)+S.x),a.add(A.x),a.add(w.x)}switch(l){case 0:var U=n/I;i.add(M*m*U),i.add(D*U),i.add(n-M*(1-x)*U),o.add(C.y),o.add(S.y),o.add(A.y),o.add(w.y);break;case 1:i.add(M*m),i.add(D),i.add(n-L),i.add(n-M*(1-x)),o.add(C.y),o.add(S.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(w.y);break;case 2:i.add(M*m),i.add(D),o.add(C.y),o.add(S.y),o.add(S.y);for(var z=0|d,k=0;k<z;k++)i.add(D+(k+1)*B),o.add(A.y),o.add(S.y);i.add(n-L),i.add(n-M*(1-x)),o.add((A.y-S.y)*(d-z)+S.y),o.add(A.y),o.add(w.y)}},(su=r2)._worldMatrix=new sK,su._posRow=new lb,su._posColumn=new lb,su._uvRow=new lb,su._uvColumn=new lb,su);uX=s8([l9()],uX),(r3=sh||(sh={}))[r3.Compressed=0]="Compressed",r3[r3.WithoutTiled=1]="WithoutTiled",r3[r3.WithTiled=2]="WithTiled";var uK=(r4=e.Renderer,s3(r5=function(t){var n;return(n=r4.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new sQ(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._maskLayer=e.SpriteMaskLayer.Layer0,n._maskInteraction=e.SpriteMaskInteraction.None,n._verticesData=new ct(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(s$(n)),n},r4),(r8=r5.prototype)._cloneTo=function(e){r4.prototype._cloneTo.call(this,e),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},r8._updateShaderData=function(e){this._updateTransformShaderData(e,sK._identity)},r8._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},r8._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&o5.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~o5.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var t,n=this.getMaterial(),r=this.sprite.texture,i=this._engine._spriteRenderDataPool.getFromPool();i.set(this,n,this._verticesData,r),e.camera._renderPipeline.pushRenderData(e,i)}},r8._onDestroy=function(){var e;r4.prototype._onDestroy.call(this),null==(e=this._sprite)||e._updateFlagManager.removeListener(this._onSpriteChange),this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},r8._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},r8._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,n=this._maskInteraction;if(n===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 r=n===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=r,t.compareFunctionBack=r}},r8._onSpriteChange=function(t){switch(t){case o6.texture:this.shaderData.setTexture(r5._textureProperty,this.sprite.texture);break;case o6.size:var n=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=o5.WorldVolume:n===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=o5.WorldVolume);break;case o6.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case o6.region:case o6.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case o6.atlasRegion:this._dirtyUpdateFlag|=2;break;case o6.pivot:this._dirtyUpdateFlag|=o5.WorldVolume}},s1(r5,[{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=ce;break;case e.SpriteDrawMode.Sliced:this._assembler=uW;break;case e.SpriteDrawMode.Tiled:this._assembler=uX}this._assembler.resetData(this),this._dirtyUpdateFlag|=3}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=sV.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&t._updateFlagManager.removeListener(this._onSpriteChange),this._dirtyUpdateFlag|=7,e?(e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(r5._textureProperty,e.texture)):this.shaderData.setTexture(r5._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=o5.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|=o5.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=o5.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=o5.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,this._updateStencilState())}}]),r5);uK._textureProperty=lS.getByName("renderer_SpriteTexture"),s8([s7],uK.prototype,"_verticesData",void 0),s8([s7],uK.prototype,"_drawMode",void 0),s8([s9],uK.prototype,"_assembler",void 0),s8([s9],uK.prototype,"_tileMode",void 0),s8([s9],uK.prototype,"_tiledAdaptiveThreshold",void 0),s8([lt],uK.prototype,"_color",void 0),s8([s7],uK.prototype,"_sprite",void 0),s8([s7],uK.prototype,"_automaticWidth",void 0),s8([s7],uK.prototype,"_automaticHeight",void 0),s8([s9],uK.prototype,"_customWidth",void 0),s8([s9],uK.prototype,"_customHeight",void 0),s8([s9],uK.prototype,"_flipX",void 0),s8([s9],uK.prototype,"_flipY",void 0),s8([s9],uK.prototype,"_maskLayer",void 0),s8([s9],uK.prototype,"_maskInteraction",void 0),s8([s7],uK.prototype,"_onSpriteChange",null),(r6=sd||(sd={}))[r6.UV=2]="UV",r6[r6.RenderData=3]="RenderData",r6[r6.AutomaticSize=4]="AutomaticSize",r6[r6.All=7]="All";var uj=function e(){this.localPositions=new sY;var t=[new sO,new sO,new sO,new sO];this.renderData=new ct(4,t,null,e.triangles,null)};uj.triangles=[0,2,1,2,0,3];var uq=((r9=(r7=function(e,t){this._elements=[],this._type=e;for(var n=this._elements,r=0;r<t;++r)n[r]=new e}).prototype).get=function(){return this._elements.length>0?this._elements.pop():new this._type},r9.put=function(e){this._elements.push(e)},r7),uY=(ie=e.Renderer,s3(it=function(t){var n;return(n=ie.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new sQ(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sz,n._font=null,n._fontSize=24,n._fontStyle=e.FontStyle.None,n._lineSpacing=0,n._horizontalAlignment=e.TextHorizontalAlignment.Center,n._verticalAlignment=e.TextVerticalAlignment.Center,n._enableWrapping=!1,n._overflowMode=e.OverflowMode.Overflow,n._maskInteraction=e.SpriteMaskInteraction.None,n._maskLayer=e.SpriteMaskLayer.Layer0,n._init(),n},ie),(ir=it.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},ir._onDestroy=function(){ie.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)it._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},ir._cloneTo=function(e){ie.prototype._cloneTo.call(this,e),e.font=this._font,e._subFont=this._subFont},ir._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ir._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ir._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ir._updateShaderData=function(e){this._updateTransformShaderData(e,sK._identity)},ir._updateBounds=function(e){sz.transform(this._localBounds,this._entity.transform.worldMatrix,e)},ir._render=function(t){if(""!==this._text&&(!this.enableWrapping||!(this.width<=0))&&(this.overflowMode!==e.OverflowMode.Truncate||!(this.height<=0))){this._isContainDirtyFlag(16)&&(this._updateStencilState(),this._setDirtyFlagFalse(16)),this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4));var n=this._engine._spriteRenderDataPool,r=this._engine._textRenderDataPool.getFromPool(),i=r.charsData,a=this.getMaterial(),o=this._charRenderDatas,s=o.length;r.component=this,r.material=a,i.length=s;for(var l=0;l<s;++l){var c=o[l],u=n.getFromPool();u.set(this,a,c.renderData,c.texture,l),i[l]=u}t.camera._renderPipeline.pushRenderData(t,r)}},ir._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,n=this._maskInteraction;if(n===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 r=n===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=r,t.compareFunctionBack=r}},ir._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=ly.getNativeFontString(e.name,this.fontSize,this.fontStyle)},ir._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,n=e[0],r=e[1],i=e[2],a=e[4],o=e[5],s=e[6],l=e[12],c=e[13],u=e[14],h=it._tempVec31.set(a,o,s),d=it._tempVec30.set(n,r,i),_=0,f=t.length;_<f;++_){var p=t[_],g=p.localPositions,m=p.renderData.positions,v=g.x,y=g.y,x=m[0];x.x=v*n+y*a+l,x.y=v*r+y*o+c,x.z=v*i+y*s+u;var T=m[1];sO.scale(d,g.z-v,T),sO.add(x,T,T);var C=m[2];sO.scale(h,g.w-y,C),sO.add(x,C,m[3]),sO.add(T,C,C)}},ir._updateLocalData=function(){var t=this.color,n=this.horizontalAlignment,r=this.verticalAlignment,i=this._charRenderDatas,a=this._localBounds,o=a.min,s=a.max,l=us._pixelsPerUnit,c=1/l,u=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?ly.measureTextWithWrap(this):ly.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=it._charRenderDataPool,x=.5*m,T=p.length,C=0,S=.5*m-v[0].ascent,A=.5*m-v[T-1].descent-1;switch(r){case e.TextVerticalAlignment.Top:C=.5*d-x+S;break;case e.TextVerticalAlignment.Center:C=.5*f-x-(A-S)*.5;break;case e.TextVerticalAlignment.Bottom:C=f-.5*d-x-A}for(var w=0,E=-1,M=Number.MAX_SAFE_INTEGER,b=Number.MAX_SAFE_INTEGER,F=Number.MIN_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,P=0;P<T;++P){var L=g[P];if(L>0){var D=p[P],I=0,B=-1;switch(E<0&&(E=P),n){case e.TextHorizontalAlignment.Left:I=-h;break;case e.TextHorizontalAlignment.Center:I=-(.5*L);break;case e.TextHorizontalAlignment.Right:I=h-L}for(var N=0,V=D.length;N<V;++N){var O=D[N],U=u._getCharInfo(O);if(U.h>0){B<0&&(B=N);var z,k,G=(z=i)[k=w++]||(z[k]=y.get()),H=G.renderData,W=G.localPositions;G.texture=u._getTextureByIndex(U.index),H.color=t,H.uvs=U.uvs;var X=U.w,K=U.ascent,j=U.descent,q=I*c,Y=(I+X)*c,Q=(C+K)*c,J=(C-j+1)*c;W.set(q,Q,Y,J),P===E&&(R=Math.max(R,Q)),b=Math.min(b,J),N===B&&(M=Math.min(M,q)),F=Math.max(F,Y)}I+=U.xAdvance}}C-=m}E<0?(o.set(0,0,0),s.set(0,0,0)):(o.set(M,b,0),s.set(F,R,0));var Z=i.length;if(Z>w){for(var $=w;$<Z;++$)y.put(i[$]);i.length=w}u._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},ir._onTransformChanged=function(e){ie.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},s1(it,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&t._addReferCount(-1),e&&e._addReferCount(1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){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}}]),it);uY._charRenderDataPool=new uq(uj,50),uY._tempVec30=new sO,uY._tempVec31=new sO,s8([s9],uY.prototype,"_subFont",void 0),s8([s7],uY.prototype,"_charRenderDatas",void 0),s8([s7],uY.prototype,"_dirtyFlag",void 0),s8([lt],uY.prototype,"_color",void 0),s8([s9],uY.prototype,"_text",void 0),s8([s9],uY.prototype,"_width",void 0),s8([s9],uY.prototype,"_height",void 0),s8([s7],uY.prototype,"_localBounds",void 0),s8([s9],uY.prototype,"_font",void 0),s8([s9],uY.prototype,"_fontSize",void 0),s8([s9],uY.prototype,"_fontStyle",void 0),s8([s9],uY.prototype,"_lineSpacing",void 0),s8([s9],uY.prototype,"_horizontalAlignment",void 0),s8([s9],uY.prototype,"_verticalAlignment",void 0),s8([s9],uY.prototype,"_enableWrapping",void 0),s8([s9],uY.prototype,"_overflowMode",void 0),s8([s9],uY.prototype,"_maskInteraction",void 0),s8([s9],uY.prototype,"_maskLayer",void 0),(ii=s_||(s_={}))[ii.SubFont=1]="SubFont",ii[ii.LocalPositionBounds=2]="LocalPositionBounds",ii[ii.WorldPosition=4]="WorldPosition",ii[ii.WorldBounds=8]="WorldBounds",ii[ii.MaskInteraction=16]="MaskInteraction",ii[ii.Position=14]="Position",ii[ii.Font=15]="Font";var uQ=((io=(ia=function(){}).prototype).initialize=function(e){for(var t=e.component,n=e.property.split("."),r=n.length-1,i=0;i<r;i++)t=t[n[i]];this._mounted=t,this._propertyName=n[r]},io.getTargetValue=function(){return this._mounted[this._propertyName]},io.setTargetValue=function(e){this._mounted[this._propertyName]=e},ia),uJ=function(){function e(t,n,r,i){this.hasSavedDefaultValue=!1,this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.target=t,this.type=n,this.property=r,this.component=t.getComponent(n),this._cureType=i;var a=e.getAssemblerType(n,r);this._assembler=new a,this._assembler.initialize(this),i._isReferenceType&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateAndApplyValue=function(e,t,n,r){if(e.keys.length){if(r){var i=e._evaluateAdditive(t,this.baseEvaluateData),a=this._cureType;if(a._isReferenceType)a._additiveValue(i,n,this.referenceTargetValue);else{var o=this._assembler,s=o.getTargetValue(),l=a._additiveValue(i,n,s);o.setTargetValue(l)}}else{var c=e._evaluate(t,this.baseEvaluateData);this._applyValue(c,n)}}},t.crossFadeAndApplyValue=function(e,t,n,r,i,a,o){var s=e&&e.keys.length?o?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):o?this._cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,l=t&&t.keys.length?o?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):o?this._cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;this._applyCrossValue(s,l,i,a,o)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r,i){var a=i?this._cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,o=e&&e.keys.length?i?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):i?this._cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;this._applyCrossValue(a,o,n,r,i)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.saveDefaultValue=function(){this._cureType._isReferenceType?this._cureType._copyValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue(),this.hasSavedDefaultValue=!0},t.saveFixedPoseValue=function(){this._cureType._isReferenceType?this._cureType._copyValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t._applyValue=function(e,t){if(1===t)this._cureType._isReferenceType?this._cureType._copyValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(this._cureType._isReferenceType){var n=this.referenceTargetValue;this._cureType._lerpValue(n,e,t,n)}else{var r=this._assembler.getTargetValue(),i=this._cureType._lerpValue(r,e,t);this._assembler.setTargetValue(i)}},t._applyCrossValue=function(e,t,n,r,i){var a;if(this._cureType._isReferenceType?(a=this.baseEvaluateData.value,this._cureType._lerpValue(e,t,n,a)):a=this._cureType._lerpValue(e,t,n),i){if(this._cureType._isReferenceType)this._cureType._additiveValue(a,r,this.referenceTargetValue);else{var o=this._assembler.getTargetValue(),s=this._cureType._additiveValue(a,r,o);this._assembler.setTargetValue(s)}}else this._applyValue(a,r)},e.registerAssembler=function(t,n,r){var i=e._assemblerMap.get(t);i||(i={},e._assemblerMap.set(t,i)),i[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),i=r?r[n]:void 0;return null!=i?i:uQ},e}();uJ._assemblerMap=new Map;var uZ=((il=(is=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},il.getTargetValue=function(){return this._transform.position},il.setTargetValue=function(e){this._transform.position=e},is);uJ.registerAssembler(lB,"position",uZ);var u$=((iu=(ic=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iu.getTargetValue=function(){return this._transform.rotationQuaternion},iu.setTargetValue=function(e){this._transform.rotationQuaternion=e},ic);uJ.registerAssembler(lB,"rotationQuaternion",u$);var u0=((id=(ih=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},id.getTargetValue=function(){return this._transform.scale},id.setTargetValue=function(e){this._transform.scale=e},ih);uJ.registerAssembler(lB,"scale",u0);var u1=((ip=(i_=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(cf)},ip.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},ip.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},i_);uJ.registerAssembler(cf,"blendShapeWeights",u1);var u2=function(){this.crossCurveMark=0},u3=((im=(ig=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new uJ(e,this.type,this.property,t);return t._initializeOwner(n),n},im._createCurveLayerOwner=function(e){var t=new u2;return t.curveOwner=e,t},im._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},ig),u4=function(){},u5=(s3(iv=function(e){var t;return(t=lr.call(this,null)||this).name=e,t._curveBindings=[],t._length=0,t._events=[],t},lr),(iy=iv.prototype).addEvent=function(e,t,n){if("string"==typeof e){var r=new u4;r.functionName=e,r.time=t,r.parameter=n,this._events.push(r)}else this._events.push(e);this._events.sort(function(e,t){return e.time-t.time})},iy.clearEvents=function(){this._events.length=0},iy.addCurveBinding=function(e,t,n,r){var i=new u3;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},iy.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iy._sampleAnimation=function(e,t){for(var n=this._curveBindings,r=n.length-1;r>=0;r--){var i=n[r],a=e.findByPath(i.relativePath);a&&i._getTempCurveOwner(a).evaluateAndApplyValue(i.curve,t,1,!1)}},s1(iv,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),iv);e.InterpolationType=void 0,(ix=e.InterpolationType||(e.InterpolationType={}))[ix.Linear=0]="Linear",ix[ix.CubicSpine=1]="CubicSpine",ix[ix.Step=2]="Step",ix[ix.Hermite=3]="Hermite";var u8=((iC=(iT=function(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var t=this.constructor;this._interpolation=t._isInterpolationType?e.InterpolationType.Linear:e.InterpolationType.Step,this._type=t}).prototype).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)}},iC.evaluate=function(e){return this._evaluate(e,this._evaluateData)},iC.removeKey=function(e){this.keys.splice(e,1);for(var t=this.keys,n=0,r=t.length-1;r>=0;r--){var i=t[r];i.time>length&&(n=i.time)}this._length=n},iC._evaluate=function(t,n){var r,i=this.keys.length;if(!i){console.warn("This curve don't have any keyframes: ",this);return}var a=this.keys,o=this.interpolation,s=n.curKeyframeIndex;-1!==s&&(s>=i||t<a[s].time)&&(s=-1);for(var l=s+1;l<i&&!(t<a[l].time);)s++,l++;if(n.curKeyframeIndex=s,-1===s)r=this._type._copyValue(a[0].value,n.value);else if(l===i)r=this._type._copyValue(a[s].value,n.value);else{var c=a[s],u=a[l],h=c.time,d=u.time-h,_=(t-h)/d;switch(o){case e.InterpolationType.Linear:r=this._type._lerpValue(c.value,u.value,_,n.value);break;case e.InterpolationType.Step:r=this._type._copyValue(c.value,n.value);break;case e.InterpolationType.CubicSpine:case e.InterpolationType.Hermite:r=this._type._hermiteInterpolationValue(c,u,_,d,n.value)}}return r},iC._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},s1(iT,[{key:"interpolation",get:function(){return this._interpolation},set:function(t){this._type._isInterpolationType||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}}]),iT);e.AnimationArrayCurve=(s3(iS=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=[],e},u8),iS._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iS._lerpValue=function(e,t,n,r){for(var i=0,a=r.length;i<a;++i){var o=e[i];r[i]=o+(t[i]-o)*n}return r},iS._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iS._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iS._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iS._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iS._hermiteInterpolationValue=function(e,t,n,r,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,g=s.length;p<g;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=h*s[p]+d*a[p]*r+_*o[p]*r+f*l[p]:i[p]=e.value[p];return i},(sf=iS)._isReferenceType=!0,sf._isInterpolationType=!0,sf),e.AnimationArrayCurve=s8([l9()],e.AnimationArrayCurve),e.AnimationBoolCurve=(s3(iA=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=!1,e},u8),iA._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},iA._lerpValue=function(e,t){return t},iA._subtractValue=function(e,t,n){return e},iA._getZeroValue=function(){return!1},iA._additiveValue=function(e,t,n){return e},iA._copyValue=function(e){return e},iA._hermiteInterpolationValue=function(e){return e.value},(sp=iA)._isReferenceType=!1,sp._isInterpolationType=!1,sp),e.AnimationBoolCurve=s8([l9()],e.AnimationBoolCurve),e.AnimationColorCurve=(s3(iw=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=new sQ,e},u8),iw._initializeOwner=function(e){e.defaultValue=new sQ,e.fixedPoseValue=new sQ,e.baseEvaluateData.value=new sQ,e.crossEvaluateData.value=new sQ},iw._lerpValue=function(e,t,n,r){return sQ.lerp(e,t,n,r),r},iw._subtractValue=function(e,t,n){return sQ.subtract(e,t,n),n},iw._getZeroValue=function(e){return e.set(0,0,0,0),e},iw._additiveValue=function(e,t,n){return sQ.scale(e,t,e),sQ.add(n,e,n),n},iw._copyValue=function(e,t){return t.copyFrom(e),t},iw._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?i.r=h*a.r+d*p*r+_*g*r+f*s.r:i.r=a.r,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?i.g=h*a.g+d*p*r+_*g*r+f*s.g:i.g=a.g,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?i.b=h*a.b+d*p*r+_*g*r+f*s.b:i.b=a.b,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?i.a=h*a.a+d*p*r+_*g*r+f*s.a:i.a=a.a,i},(sg=iw)._isReferenceType=!0,sg._isInterpolationType=!0,sg),e.AnimationColorCurve=s8([l9()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(s3(iE=function(){return u8.apply(this,arguments)},u8),iE.prototype.addKey=function(e){u8.prototype.addKey.call(this,e);var t=this._evaluateData;if(!t.value||t.value.length!==e.value.length){var n=e.value.length;t.value=new Float32Array(n)}},iE._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},iE._lerpValue=function(e,t,n,r){for(var i=0,a=r.length;i<a;++i){var o=e[i];r[i]=o+(t[i]-o)*n}return r},iE._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iE._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iE._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iE._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iE._hermiteInterpolationValue=function(e,t,n,r,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,g=s.length;p<g;++p)Number.isFinite(a[p])&&Number.isFinite(o[p])?i[p]=h*s[p]+d*a[p]*r+_*o[p]*r+f*l[p]:i[p]=e.value[p];return i},(sm=iE)._isReferenceType=!0,sm._isInterpolationType=!0,sm),e.AnimationFloatArrayCurve=s8([l9()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(s3(iM=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=0,e},u8),iM._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},iM._lerpValue=function(e,t,n){return e+(t-e)*n},iM._additiveValue=function(e,t,n){return n+e*t},iM._subtractValue=function(e,t){return e-t},iM._getZeroValue=function(){return 0},iM._copyValue=function(e){return e},iM._hermiteInterpolationValue=function(e,t,n,r){var i=e.outTangent,a=t.inTangent;if(!(Number.isFinite(i)&&Number.isFinite(a)))return e.value;var o=n*n,s=o*n;return(2*s-3*o+1)*e.value+(s-2*o+n)*i*r+(s-o)*a*r+(-2*s+3*o)*t.value},(sv=iM)._isReferenceType=!1,sv._isInterpolationType=!0,sv),e.AnimationFloatCurve=s8([l9()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(s3(ib=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=new sX,e},u8),ib._initializeOwner=function(e){e.defaultValue=new sX,e.fixedPoseValue=new sX,e.baseEvaluateData.value=new sX,e.crossEvaluateData.value=new sX},ib._lerpValue=function(e,t,n,r){return sX.slerp(e,t,n,r),r},ib._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},ib._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return sX.conjugate(n,i),sX.multiply(i,t,r),r},ib._getZeroValue=function(e){return e.set(0,0,0,1),e},ib._copyValue=function(e,t){return t.copyFrom(e),t},ib._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?i.x=h*a.x+d*p*r+_*g*r+f*s.x:i.x=a.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?i.y=h*a.y+d*p*r+_*g*r+f*s.y:i.y=a.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?i.z=h*a.z+d*p*r+_*g*r+f*s.z:i.z=a.z,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?i.w=h*a.w+d*p*r+_*g*r+f*s.w:i.w=a.w,i},(sy=ib)._isInterpolationType=!0,sy._isReferenceType=!0,sy._tempConjugateQuat=new sX,sy),e.AnimationQuaternionCurve=s8([l9()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(s3(iF=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=new sq,e},u8),iF._initializeOwner=function(e){e.defaultValue=new sq,e.fixedPoseValue=new sq,e.baseEvaluateData.value=new sq,e.crossEvaluateData.value=new sq},iF._lerpValue=function(e,t,n,r){return sq.lerp(e,t,n,r),r},iF._additiveValue=function(e,t,n){return sq.scale(e,t,e),sq.add(n,e,n),n},iF._subtractValue=function(e,t,n){return sq.subtract(e,t,n),n},iF._getZeroValue=function(e){return e.set(0,0),e},iF._copyValue=function(e,t){return t.copyFrom(e),t},iF._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?i.x=h*a.x+d*p*r+_*g*r+f*s.x:i.x=a.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?i.y=h*a.y+d*p*r+_*g*r+f*s.y:i.y=a.y,i},(sx=iF)._isReferenceType=!0,sx._isInterpolationType=!0,sx),e.AnimationVector2Curve=s8([l9()],e.AnimationVector2Curve),e.AnimationVector3Curve=(s3(iR=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=new sO,e},u8),iR._initializeOwner=function(e){e.defaultValue=new sO,e.fixedPoseValue=new sO,e.baseEvaluateData.value=new sO,e.crossEvaluateData.value=new sO},iR._lerpValue=function(e,t,n,r){return sO.lerp(e,t,n,r),r},iR._relativeBaseValue=function(e,t){return sO.subtract(t,e,t),t},iR._additiveValue=function(e,t,n){return sO.scale(e,t,e),sO.add(n,e,n),n},iR._subtractValue=function(e,t,n){return sO.subtract(e,t,n),n},iR._getZeroValue=function(e){return e.set(0,0,0),e},iR._copyValue=function(e,t){return t.copyFrom(e),t},iR._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?i.x=h*a.x+d*p*r+_*g*r+f*s.x:i.x=a.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?i.y=h*a.y+d*p*r+_*g*r+f*s.y:i.y=a.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?i.z=h*a.z+d*p*r+_*g*r+f*s.z:i.z=a.z,i},(sT=iR)._isReferenceType=!0,sT._isInterpolationType=!0,sT),e.AnimationVector3Curve=s8([l9()],e.AnimationVector3Curve),e.AnimationVector4Curve=(s3(iP=function(){var e;return(e=u8.call(this)||this)._evaluateData.value=new sY,e},u8),iP._initializeOwner=function(e){e.defaultValue=new sY,e.fixedPoseValue=new sY,e.baseEvaluateData.value=new sY,e.crossEvaluateData.value=new sY},iP._lerpValue=function(e,t,n,r){return sY.lerp(e,t,n,r),r},iP._additiveValue=function(e,t,n){return sY.scale(e,t,e),sY.add(n,e,n),n},iP._subtractValue=function(e,t,n){return sY.subtract(e,t,n),n},iP._getZeroValue=function(e){return e.set(0,0,0,0),e},iP._copyValue=function(e,t){return t.copyFrom(e),t},iP._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,c=n*n,u=c*n,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?i.x=h*a.x+d*p*r+_*g*r+f*s.x:i.x=a.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?i.y=h*a.y+d*p*r+_*g*r+f*s.y:i.y=a.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?i.z=h*a.z+d*p*r+_*g*r+f*s.z:i.z=a.z,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?i.w=h*a.w+d*p*r+_*g*r+f*s.w:i.w=a.w,i},(sC=iP)._isReferenceType=!0,sC._isInterpolationType=!0,sC),e.AnimationVector4Curve=s8([l9()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(iL=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[iL.None=0]="None",iL[iL.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iD=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iD.Override=0]="Override",iD[iD.Additive=1]="Additive",(iI=sS||(sS={}))[iI.UnStarted=0]="UnStarted",iI[iI.Playing=1]="Playing",iI[iI.Finished=2]="Finished",(iB=sA||(sA={}))[iB.Standby=0]="Standby",iB[iB.Playing=1]="Playing",iB[iB.CrossFading=2]="CrossFading",iB[iB.FixedCrossFading=3]="FixedCrossFading";var u6=function(){this.handlers=[]},u7=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(iN=e.WrapMode||(e.WrapMode={}))[iN.Once=0]="Once",iN[iN.Loop=1]="Loop";var u9=((iO=(iV=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=sS.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},iO.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=sS.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=sS.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},iV),he=((iU=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new u9,this.destPlayData=new u9,this.layerState=sA.Standby,this.crossCurveMark=0,this.manuallyTransition=new u7,this.crossOwnerLayerDataCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iU),ht=function(){this.curveLayerOwner=[],this.eventHandlers=[]},hn=(s3(iz=function(t){var n;return(n=lw.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new lO(u6),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lw),(ik=iz.prototype).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,i=this._getAnimatorStateInfo(e,t),a=i.state;if(a){if(!a.clip){console.warn("The state named "+e+" has no AnimationClip data.");return}var o=this._getAnimatorLayerData(i.layerIndex),s=this._getAnimatorStateData(e,a,o);this._preparePlay(o,a,s),o.layerState=sA.Playing,o.srcPlayData.reset(a,s,a._getDuration()*n)}},ik.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),(null==(i=this._controllerUpdateFlag)?void 0:i.flag)&&this._reset();var i,a=this._getAnimatorStateInfo(e,n).state,o=this._getAnimatorLayerData(n).manuallyTransition;o.duration=t,o.offset=r,o.destinationState=a,this._crossFadeByTransition(o,n)},ik.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){r=!1;for(var n,r,i=this._controlledRenderers,a=0,o=i.length;a<o;a++)if(!i[a].isCulled){r=!0;break}}else r=!0;var s=this._animatorController;if(s){if(null==(n=this._controllerUpdateFlag)?void 0:n.flag){this._checkAutoPlay();return}t*=this.speed;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==sA.Standby&&this._updateLayer(l,0===l,t,r)}},ik.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},ik.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},ik._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},ik._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},ik._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},ik._reset=function(){var e=this._curveOwnerPool;for(var t in e){var n=e[t];for(var r in n){var i=n[r];i.hasSavedDefaultValue&&i.revertDefaultValue()}}this._animatorLayersData.length=0,this._curveOwnerPool={},this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},ik._getAnimatorStateInfo=function(e,t){var n=this._animatorController,r=this._tempAnimatorStateInfo,i=null;if(n){var a=n.layers;if(-1===t){for(var o=0,s=a.length;o<s;o++)if(i=a[o].stateMachine.findStateByName(e)){t=o;break}}else i=a[t].stateMachine.findStateByName(e)}return r.layerIndex=t,r.state=i,r},ik._saveDefaultValues=function(e){for(var t,n=e.curveLayerOwner,r=n.length-1;r>=0;r--)null==(t=n[r])||t.curveOwner.saveDefaultValue()},ik._getAnimatorStateData=function(e,t,n){var r=n.animatorStateDataMap,i=r[e];return i||(i=new ht,r[e]=i,this._saveAnimatorStateData(t,i,n),this._saveAnimatorEventHandlers(t,i)),i},ik._saveAnimatorStateData=function(e,t,n){for(var r=this.entity,i=this._curveOwnerPool,a=t.curveLayerOwner,o=n.curveOwnerPool,s=e.clip._curveBindings,l=s.length-1;l>=0;l--){var c=s[l],u=""===c.relativePath?r:r.findByPath(c.relativePath);if(u){var h,d,_,f,p=c.property,g=u.instanceId,m=(d=(h=i)[g]||(h[g]=Object.create(null)))[p]||(d[p]=c._createCurveOwner(u)),v=(f=(_=o)[g]||(_[g]=Object.create(null)))[p]||(f[p]=c._createCurveLayerOwner(m));a[l]=v}else a[l]=null,console.warn("The entity don't have the child entity which path is "+c.relativePath+".")}},ik._saveAnimatorEventHandlers=function(e,t){var n=this._animationEventHandlerPool,r=this._entity._scripts,i=r.length,a=t.eventHandlers,o=e.clip.events;a.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.getFromPool(),h=c.functionName,d=u.handlers;u.event=c,d.length=0;for(var _=i-1;_>=0;_--){var f=r.get(_)[h];f&&d.push(f)}a.push(u)}},ik._clearCrossData=function(e){e.crossCurveMark++,e.crossOwnerLayerDataCollection.length=0},ik._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossOwnerLayerDataCollection.push(t)},ik._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},ik._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},ik._prepareFixedPoseCrossFading=function(e){for(var t=e.crossOwnerLayerDataCollection,n=t.length-1;n>=0;n--){var r=t[n];r&&(r.curveOwner.saveFixedPoseValue(),r.crossDestCurveIndex=-1)}this._prepareDestCrossData(e,!0)},ik._prepareSrcCrossData=function(e,t){for(var n=e.srcPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var i=n[r];i&&(i.crossCurveMark=e.crossCurveMark,t&&i.curveOwner.saveFixedPoseValue(),this._addCrossOwner(e,i,r,-1))}},ik._prepareDestCrossData=function(e,t){for(var n=e.destPlayData.stateData.curveLayerOwner,r=n.length-1;r>=0;r--){var i=n[r];if(i){if(i.crossCurveMark===e.crossCurveMark)i.crossDestCurveIndex=r;else{var a=i.curveOwner;a.saveDefaultValue(),t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,r)}}}},ik._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new he),t},ik._updateLayer=function(t,n,r,i){var a=this._animatorController.layers[t],o=a.blendingMode,s=a.weight,l=this._animatorLayersData[t],c=l.srcPlayData,u=l.destPlayData,h=l.crossFadeTransition,d=o===e.AnimatorLayerBlendingMode.Additive;switch(n&&(s=1),l.layerState!==sA.FixedCrossFading&&this._checkTransition(c,h,t),l.layerState){case sA.Playing:this._updatePlayingState(c,l,t,s,r,d,i);break;case sA.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,r,d,i);break;case sA.CrossFading:this._updateCrossFade(c,u,l,t,s,r,d,i)}},ik._updatePlayingState=function(e,t,n,r,i,a,o){var s,l=e.stateData,c=l.curveLayerOwner,u=l.eventHandlers,h=e.state,d=e.playState,_=e.clipTime,f=h.clip._curveBindings;if(e.update(this.speed<0),o){var p=e.clipTime,g=e.playState;u.length&&this._fireAnimationEvents(e,u,_,p);for(var m=f.length-1;m>=0;m--)null==(s=c[m])||s.curveOwner.evaluateAndApplyValue(f[m].curve,p,r,a);e.frameTime+=h.speed*i,g===sS.Finished&&(t.layerState=sA.Standby),d===sS.UnStarted&&this._callAnimatorScriptOnEnter(h,n),g===sS.Finished?this._callAnimatorScriptOnExit(h,n):this._callAnimatorScriptOnUpdate(h,n)}},ik._updateCrossFade=function(e,t,n,r,i,a,o,s){var l=n.crossOwnerLayerDataCollection,c=e.state.clip._curveBindings,u=e.state,h=e.stateData,d=e.playState,_=h.eventHandlers,f=t.state,p=t.stateData,g=t.playState,m=p.eventHandlers,v=f.clip._curveBindings,y=e.clipTime,x=t.clipTime,T=Math.abs(t.frameTime)/(f._getDuration()*n.crossFadeTransition.duration);T>=1&&(T=1),e.update(this.speed<0),t.update(this.speed<0);var C=e.playState,S=t.playState;if(this._updateCrossFadeData(n,T,a,!1),s){var A=e.clipTime,w=t.clipTime;_.length&&this._fireAnimationEvents(e,_,y,A),m.length&&this._fireAnimationEvents(t,m,x,w),d===sS.UnStarted&&this._callAnimatorScriptOnEnter(u,r),1===T||C===sS.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),g===sS.UnStarted&&this._callAnimatorScriptOnEnter(f,r),S===sS.Finished?this._callAnimatorScriptOnExit(f,r):this._callAnimatorScriptOnUpdate(f,r);for(var E=l.length-1;E>=0;E--){var M=l[E];if(M){var b=M.crossSrcCurveIndex,F=M.crossDestCurveIndex;M.curveOwner.crossFadeAndApplyValue(b>=0?c[b].curve:null,F>=0?v[F].curve:null,A,w,T,i,o)}}}},ik._updateCrossFadeFromPose=function(e,t,n,r,i,a,o){var s=t.crossOwnerLayerDataCollection,l=e.state,c=e.stateData,u=e.playState,h=c.eventHandlers,d=l.clip._curveBindings,_=e.clipTime,f=Math.abs(e.frameTime)/(l._getDuration()*t.crossFadeTransition.duration);f>=1&&(f=1),e.update(this.speed<0);var p=e.playState;if(this._updateCrossFadeData(t,f,i,!0),o){var g=e.clipTime;h.length&&this._fireAnimationEvents(e,h,_,g),u===sS.UnStarted&&this._callAnimatorScriptOnEnter(l,n),p===sS.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n);for(var m=s.length-1;m>=0;m--){var v=s[m];if(v){var y=v.crossDestCurveIndex;v.curveOwner.crossFadeFromPoseAndApplyValue(y>=0?d[y].curve:null,g,f,r,a)}}}},ik._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===sS.Finished?e.layerState=sA.Standby:e.layerState=sA.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},ik._preparePlay=function(e,t,n){if(e.layerState===sA.Playing){var r=e.srcPlayData;if(r.state!==t){for(var i=r.stateData.curveLayerOwner,a=i.length-1;a>=0;a--){var o,s=null==(o=i[a])?void 0:o.curveOwner;(null==s?void 0:s.hasSavedDefaultValue)&&s.revertDefaultValue()}this._saveDefaultValues(n)}}else{for(var l=e.crossOwnerLayerDataCollection,c=l.length-1;c>=0;c--){var u=l[c].curveOwner;u.hasSavedDefaultValue&&u.revertDefaultValue()}this._saveDefaultValues(n)}},ik._checkTransition=function(e,t,n){for(var r=e.state,i=e.clipTime,a=r.transitions,o=r._getDuration(),s=0,l=a.length;s<l;++s){var c=a[s];o*c.exitTime<=i&&t!==c&&this._crossFadeByTransition(c,n)}},ik._crossFadeByTransition=function(e,t){var n=e.destinationState.name,r=this._getAnimatorStateInfo(n,t),i=r.state;if(i){if(!i.clip){console.warn("The state named "+n+" has no AnimationClip data.");return}var a=this._getAnimatorLayerData(r.layerIndex),o=a.layerState,s=a.destPlayData,l=this._getAnimatorStateData(n,i,a),c=i._getDuration()*e.offset;switch(s.reset(i,l,c),o){case sA.Standby:a.layerState=sA.FixedCrossFading,this._clearCrossData(a),this._prepareStandbyCrossFading(a);break;case sA.Playing:a.layerState=sA.CrossFading,this._clearCrossData(a),this._prepareCrossFading(a);break;case sA.CrossFading:a.layerState=sA.FixedCrossFading,this._prepareFixedPoseCrossFading(a);break;case sA.FixedCrossFading:this._prepareFixedPoseCrossFading(a)}a.crossFadeTransition=e}},ik._fireAnimationEvents=function(e,t,n,r){var i=e.state,a=i.clip.length;this.speed>=0?r<n?(this._fireSubAnimationEvents(e,t,n,i.clipEndTime*a),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,i.clipStartTime*a,r)):this._fireSubAnimationEvents(e,t,n,r):r>n?(this._fireBackwardSubAnimationEvents(e,t,n,i.clipStartTime*a),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,i.clipEndTime*a,r)):this._fireBackwardSubAnimationEvents(e,t,n,r)},ik._fireSubAnimationEvents=function(e,t,n,r){for(var i=e.currentEventIndex,a=t.length;i<a;i++){var o=t[i],s=o.event,l=s.time,c=s.parameter;if(l>r)break;var u=o.handlers;if(l>=n){for(var h=u.length-1;h>=0;h--)u[h](c);e.currentEventIndex=Math.min(i+1,a-1)}}},ik._fireBackwardSubAnimationEvents=function(e,t,n,r){for(var i=e.currentEventIndex;i>=0;i--){var a=t[i],o=a.event,s=o.time,l=o.parameter;if(s<r)break;if(s<=n){for(var c=a.handlers,u=c.length-1;u>=0;u--)c[u](l);e.currentEventIndex=Math.max(i-1,0)}}},ik._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},ik._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},ik._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},ik._checkAutoPlay=function(){for(var e=this._animatorController.layers,t=0,n=e.length;t<n;++t){var r=e[t].stateMachine;(null==r?void 0:r.defaultState)&&this.play(r.defaultState.name,t)}},s1(iz,[{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)}}]),iz);s8([s9],hn.prototype,"speed",void 0),s8([s7],hn.prototype,"_controllerUpdateFlag",void 0),s8([s7],hn.prototype,"_animatorLayersData",void 0),s8([s7],hn.prototype,"_curveOwnerPool",void 0),s8([s7],hn.prototype,"_animationEventHandlerPool",void 0),s8([s7],hn.prototype,"_tempAnimatorStateInfo",void 0),s8([s7],hn.prototype,"_controlledRenderers",void 0);var hr=((iH=(iG=function(){this._updateFlagManager=new lI,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iH.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iH.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iH.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iH._registerChangeFlag=function(){return this._updateFlagManager.createFlag(lD)},s1(iG,[{key:"layers",get:function(){return this._layers}}]),iG),hi=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},ha=((iX=(iW=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iX.onStateUpdate=function(e,t,n){},iX.onStateExit=function(e,t,n){},iX.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iW),ho=((ij=(iK=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._clipStartTime=0,this._clipEndTime=1,this._transitions=[]}).prototype).addTransition=function(e){this._transitions.push(e)},ij.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},ij.addStateMachineScript=function(e){var t=new e;t._state=this;var n=ha.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},ij.clearTransitions=function(){this._transitions.length=0},ij._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},ij._removeStateMachineScript=function(e){var t=ha.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 i=this._onStateExitScripts.indexOf(e);-1!==i&&this._onStateExitScripts.splice(i,1)}},s1(iK,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1)}},{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)}}]),iK),hs=((iY=(iq=function(){this.states=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new ho(e),this.states.push(t),this._statesMap[e]=t),t},iY.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},iY.findStateByName=function(e){return this._statesMap[e]},iY.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},iq);e.AnimatorConditionMode=void 0,(iQ=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iQ.If=0]="If",iQ[iQ.IfNot=1]="IfNot",iQ[iQ.Greater=2]="Greater",iQ[iQ.Less=3]="Less",iQ[iQ.Equals=4]="Equals",iQ[iQ.NotEquals=5]="NotEquals";var hl=function(){},hc=function(t){function n(r){var i;return(i=t.call(this,r,l$.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new sQ(1,1,1,1),i.renderState.rasterState.cullMode=e.CullMode.Off,i.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,i.shaderData.setFloat(n._rotationProp,0),i.shaderData.setFloat(n._exposureProp,1),i.shaderData.setColor(n._tintColorProp,i._tintColor),i}return s3(n,t),n.prototype.clone=function(){var e=new n(this._engine);return this.cloneTo(e),e},s1(n,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(n._decodeSkyRGBMMacro):this.shaderData.disableMacro(n._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(n._textureCubeProp)},set:function(e){this.shaderData.setTexture(n._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(n._rotationProp)},set:function(e){this.shaderData.setFloat(n._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(n._exposureProp)},set:function(e){this.shaderData.setFloat(n._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),n}(ur);hc._tintColorProp=lS.getByName("material_TintColor"),hc._textureCubeProp=lS.getByName("material_CubeTexture"),hc._rotationProp=lS.getByName("material_Rotation"),hc._exposureProp=lS.getByName("material_Exposure"),hc._decodeSkyRGBMMacro=lk.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(iJ=e.SunMode||(e.SunMode={}))[iJ.None=0]="None",iJ[iJ.Simple=1]="Simple",iJ[iJ.HighQuality=2]="HighQuality";var hu=(s3(iZ=function(t){var n;return(n=ur.call(this,t,l$.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new sQ(.5,.5,.5,1),n.groundTint=new sQ(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n},ur),iZ.prototype.clone=function(){var e=new iZ(this._engine);return this.cloneTo(e),e},s1(iZ,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(iZ._sunSimpleMacro),t.enableMacro(iZ._sunHighQualityMacro);break;case 1:t.disableMacro(iZ._sunHighQualityMacro),t.enableMacro(iZ._sunSimpleMacro);break;case 0:t.disableMacro(iZ._sunHighQualityMacro),t.disableMacro(iZ._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(iZ._sunSizeProp)},set:function(e){this.shaderData.setFloat(iZ._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(iZ._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(iZ._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(iZ._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(iZ._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(iZ._skyTintProp)},set:function(e){this.shaderData.setColor(iZ._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(iZ._groundTintProp)},set:function(e){this.shaderData.setColor(iZ._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(iZ._exposureProp)},set:function(e){this.shaderData.setFloat(iZ._exposureProp,Math.min(Math.max(0,e),8))}}]),iZ);hu._sunSizeProp=lS.getByName("material_SunSize"),hu._sunSizeConvergenceProp=lS.getByName("material_SunSizeConvergence"),hu._atmosphereThicknessProp=lS.getByName("material_AtmosphereThickness"),hu._skyTintProp=lS.getByName("material_SkyTint"),hu._groundTintProp=lS.getByName("material_GroundTint"),hu._exposureProp=lS.getByName("material_Exposure"),hu._sunHighQualityMacro=lk.getByName("MATERIAL_SUN_HIGH_QUALITY"),hu._sunSimpleMacro=lk.getByName("MATERIAL_SUN_SIMPLE"),(i$=sw||(sw={}))[i$.Position=1]="Position",i$[i$.Velocity=2]="Velocity",i$[i$.Acceleration=4]="Acceleration",i$[i$.Color=8]="Color",i$[i$.Alpha=16]="Alpha",i$[i$.Size=32]="Size",i$[i$.StartAngle=64]="StartAngle",i$[i$.StartTime=128]="StartTime",i$[i$.LifeTime=256]="LifeTime",i$[i$.RotateVelocity=512]="RotateVelocity",i$[i$.Scale=1024]="Scale",i$[i$.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(i0=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[i0.Transparent=0]="Transparent",i0[i0.Additive=1]="Additive";var hh=(s3(i1=function(e){var t;return(t=c_.call(this,e)||this)._maxCount=1e3,t._position=new sO,t._positionRandomness=new sO,t._velocity=new sO,t._velocityRandomness=new sO,t._acceleration=new sO,t._accelerationRandomness=new sO,t._color=new sQ(1,1,1,1),t._colorRandomness=0,t._size=1,t._sizeRandomness=0,t._alpha=1,t._alphaRandomness=0,t._startAngle=0,t._startAngleRandomness=0,t._rotateVelocity=0,t._rotateVelocityRandomness=0,t._lifetime=5,t._startTimeRandomness=0,t._scale=1,t._isOnce=!1,t._onceTime=0,t._time=0,t._isInit=!1,t._isStart=!1,t._updateDirtyFlag=4294967295,t._isRotateToVelocity=!1,t._isUseOriginColor=!1,t._isScaleByLifetime=!1,t._is2d=!0,t._isFadeIn=!1,t._isFadeOut=!1,t._playOnEnable=!0,t._blendMode=0,t._onColorChanged=t._onColorChanged.bind(s$(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},c_),(i2=i1.prototype).update=function(e){if(this._isInit&&this._isStart){if(this._isOnce&&this._time>this._onceTime)return this.stop();this._updateDirtyFlag&&(this._updateBuffer(),this._updateDirtyFlag=0),this._time+=e,this.shaderData.setFloat("u_time",this._time)}},i2._onEnable=function(){c_.prototype._onEnable.call(this),this._playOnEnable&&this.start()},i2.start=function(){this._isStart=!0,this._time=0},i2.stop=function(){this._isStart=!1},i2._createMaterial=function(){var t=new ur(this.engine,l$.find("particle-shader")),n=t.renderState,r=n.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=e.BlendFactor.One,r.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.depthState.writeEnabled=!1,t.renderState.renderQueueType=e.RenderQueueType.Transparent,this.isUseOriginColor=!0,this.is2d=!0,this.isFadeOut=!0,t},i2._createMesh=function(){var t=new cw(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>i1._uint16VertexLimit){if(this.engine._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))o=!0,a=new Uint32Array(6*this._maxCount);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(6*this._maxCount);for(var s=0,l=0;s<this._maxCount;++s){var c=4*s;a[l++]=c,a[l++]=c+1,a[l++]=c+2,a[l++]=c,a[l++]=c+2,a[l++]=c+3}var u=[new ci("a_position",0,e.VertexElementFormat.Vector3,0),new ci("a_velocity",12,e.VertexElementFormat.Vector3,0),new ci("a_acceleration",24,e.VertexElementFormat.Vector3,0),new ci("a_color",36,e.VertexElementFormat.Vector4,0),new ci("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new ci("a_rotation",68,e.VertexElementFormat.Vector2,0),new ci("a_uv",76,e.VertexElementFormat.Vector3,0),new ci("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new ca(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new ca(this.engine,e.BufferBindFlag.IndexBuffer,a,e.BufferUsage.Dynamic);t.setVertexBufferBinding(h,96),t.setIndexBufferBinding(d,o?e.IndexFormat.UInt32:e.IndexFormat.UInt16),t.setVertexElements(u),t.addSubMesh(0,a.length),this._vertexBuffer=h,this._vertexStride=24,this._vertices=i;var _=t.bounds,f=Number.MIN_SAFE_INTEGER,p=Number.MAX_SAFE_INTEGER;return _.min.set(f,f,f),_.max.set(p,p,p),t},i2._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},i2._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=i1._getRandom,a=4*e,o=a*r,s=(a+1)*r,l=(a+2)*r,c=(a+3)*r;if(1&t){var u=this._position,h=u.x,d=u.y,_=u.z,f=this._positionArray,p=this._positionRandomness;if(f){if(f.length!==this._maxCount)throw Error("The length of positionArray must be equal to maxCount.");var g=f[e];h+=g.x,d+=g.y,_+=g.z}else h+=i()*p.x,d+=i()*p.y,_+=i()*p.z;n[o]=n[s]=n[l]=n[c]=h,n[o+1]=n[s+1]=n[l+1]=n[c+1]=d,n[o+2]=n[s+2]=n[l+2]=n[c+2]=_}if(2&t){var m=this._velocity,v=this._velocityRandomness;n[o+3]=n[s+3]=n[l+3]=n[c+3]=m.x+i()*v.x,n[o+4]=n[s+4]=n[l+4]=n[c+4]=m.y+i()*v.y,n[o+5]=n[s+5]=n[l+5]=n[c+5]=m.z+i()*v.z}if(4&t){var y=this._acceleration,x=this._accelerationRandomness;n[o+6]=n[s+6]=n[l+6]=n[c+6]=y.x+i()*x.x,n[o+7]=n[s+7]=n[l+7]=n[c+7]=y.y+i()*x.y,n[o+8]=n[s+8]=n[l+8]=n[c+8]=y.z+i()*x.z}if(8&t){var T=this._color,C=this._colorRandomness;n[o+9]=n[s+9]=n[l+9]=n[c+9]=sV.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[c+10]=sV.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[c+11]=sV.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[c+12]=sV.clamp(this._alpha+i()*this._alphaRandomness,0,1)),128&t&&(n[o+13]=n[s+13]=n[l+13]=n[c+13]=Math.random()*this._startTimeRandomness),256&t){var S=this._lifetime;n[o+14]=n[s+14]=n[l+14]=n[c+14]=S+i()*S}if((128&t||256&t)&&(this._onceTime=Math.max(this._onceTime,n[o+13]+n[o+14])),32&t){var A=this._size;n[o+15]=n[s+15]=n[l+15]=n[c+15]=Math.max(A+i()*this._sizeRandomness*A*2,0)}1024&t&&(n[o+16]=n[s+16]=n[l+16]=n[c+16]=this._scale),64&t&&(n[o+17]=n[s+17]=n[l+17]=n[c+17]=this._startAngle+i()*Math.PI*this._startAngleRandomness*2),512&t&&(n[o+18]=n[s+18]=n[l+18]=n[c+18]=this._rotateVelocity+i()*this._rotateVelocityRandomness),this._updateSingleUv(e,o,s,l,c)},i2._updateSingleUv=function(e,t,n,r,i){var a=this.spriteSheet,o=this.getMaterial().shaderData.getTexture("u_texture"),s=this._vertices;if(o){var l=o.width,c=o.height;if(a){var u=a[e%a.length],h=u.x,d=u.y,_=u.w,f=u.h,p=h/l,g=d/c,m=p+_/l,v=g+f/c,y=f/_;s[t+19]=p,s[t+20]=v,s[t+21]=y,s[n+19]=m,s[n+20]=v,s[n+21]=y,s[r+19]=m,s[r+20]=g,s[r+21]=y,s[i+19]=p,s[i+20]=g,s[i+21]=y}else{var x=c/l;s[t+19]=0,s[t+20]=1,s[t+21]=x,s[n+19]=1,s[n+20]=1,s[n+21]=x,s[r+19]=1,s[r+20]=0,s[r+21]=x,s[i+19]=0,s[i+20]=0,s[i+21]=x}}else s[t+19]=0,s[t+20]=0,s[t+21]=1,s[n+19]=1,s[n+20]=0,s[n+21]=1,s[r+19]=1,s[r+20]=1,s[r+21]=1,s[i+19]=0,s[i+20]=1,s[i+21]=1;s[t+22]=-.5,s[t+23]=-.5,s[n+22]=.5,s[n+23]=-.5,s[r+22]=.5,s[r+23]=.5,s[i+22]=-.5,s[i+23]=.5},i2._onColorChanged=function(){this._updateDirtyFlag|=8},i1._getRandom=function(){return Math.random()-.5},s1(i1,[{key:"texture",get:function(){return this.getMaterial().shaderData.getTexture("u_texture")},set:function(e){e?(this.shaderData.enableMacro("particleTexture"),this.getMaterial().shaderData.setTexture("u_texture",e)):this.shaderData.disableMacro("particleTexture")}},{key:"position",get:function(){return this._position},set:function(e){this._updateDirtyFlag|=1,this._position=e}},{key:"positionRandomness",get:function(){return this._positionRandomness},set:function(e){this._updateDirtyFlag|=1,this._positionRandomness=e}},{key:"positionArray",get:function(){return this._positionArray},set:function(e){this._updateDirtyFlag|=1,this._positionArray=e}},{key:"velocity",get:function(){return this._velocity},set:function(e){this._updateDirtyFlag|=2,this._velocity=e}},{key:"velocityRandomness",get:function(){return this._velocityRandomness},set:function(e){this._updateDirtyFlag|=2,this._velocityRandomness=e}},{key:"acceleration",get:function(){return this._acceleration},set:function(e){this._updateDirtyFlag|=4,this._acceleration=e}},{key:"accelerationRandomness",get:function(){return this._accelerationRandomness},set:function(e){this._updateDirtyFlag|=4,this._accelerationRandomness=e}},{key:"color",get:function(){return this._color},set:function(e){this._color.copyFrom(e)}},{key:"colorRandomness",get:function(){return this._colorRandomness},set:function(e){this._updateDirtyFlag|=8,this._colorRandomness=e}},{key:"size",get:function(){return this._size},set:function(e){this._updateDirtyFlag|=32,this._size=e}},{key:"sizeRandomness",get:function(){return this._sizeRandomness},set:function(e){this._updateDirtyFlag|=32,this._sizeRandomness=e}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._updateDirtyFlag|=16,this._alpha=e}},{key:"alphaRandomness",get:function(){return this._alphaRandomness},set:function(e){this._updateDirtyFlag|=16,this._alphaRandomness=e}},{key:"angle",get:function(){return this._startAngle},set:function(e){this._updateDirtyFlag|=64,this._startAngle=e}},{key:"angleRandomness",get:function(){return this._startAngleRandomness},set:function(e){this._updateDirtyFlag|=64,this._startAngleRandomness=e}},{key:"rotateVelocity",get:function(){return this._rotateVelocity},set:function(e){this._updateDirtyFlag|=512,this._rotateVelocity=e}},{key:"rotateVelocityRandomness",get:function(){return this._rotateVelocityRandomness},set:function(e){this._updateDirtyFlag|=512,this._rotateVelocityRandomness=e}},{key:"lifetime",get:function(){return this._lifetime},set:function(e){this._updateDirtyFlag|=256,this._lifetime=e,this._onceTime=0}},{key:"startTimeRandomness",get:function(){return this._startTimeRandomness},set:function(e){this._updateDirtyFlag|=128,this._startTimeRandomness=e,this._onceTime=0}},{key:"scale",get:function(){return this._scale},set:function(e){this._updateDirtyFlag|=1024,this._scale=e}},{key:"maxCount",get:function(){return this._maxCount},set:function(e){this._isStart=!1,this._isInit=!1,this._maxCount=e,this._updateDirtyFlag=4294967295,this.mesh=this._createMesh(),this._updateBuffer(),this._isInit=!0,this.shaderData.setFloat("u_time",0)}},{key:"isOnce",get:function(){return this._isOnce},set:function(e){this._time=0,this.shaderData.setInt("u_once",e?1:0),this._isOnce=e}},{key:"isRotateToVelocity",get:function(){return this._isRotateToVelocity},set:function(e){e?this.shaderData.enableMacro("rotateToVelocity"):this.shaderData.disableMacro("rotateToVelocity"),this._isRotateToVelocity=e}},{key:"isUseOriginColor",get:function(){return this._isUseOriginColor},set:function(e){e?this.shaderData.enableMacro("useOriginColor"):this.shaderData.disableMacro("useOriginColor"),this._isUseOriginColor=e}},{key:"isScaleByLifetime",get:function(){return this._isScaleByLifetime},set:function(e){e?this.shaderData.enableMacro("isScaleByLifetime"):this.shaderData.disableMacro("isScaleByLifetime"),this._isScaleByLifetime=e}},{key:"is2d",get:function(){return this._is2d},set:function(t){t?this.shaderData.enableMacro("is2d"):(this.shaderData.disableMacro("is2d"),this.getMaterial().renderState.rasterState.cullMode=e.CullMode.Off),this._is2d=t}},{key:"isFadeIn",get:function(){return this._isFadeIn},set:function(e){e?this.shaderData.enableMacro("fadeIn"):this.shaderData.disableMacro("fadeIn"),this._isFadeIn=e}},{key:"isFadeOut",get:function(){return this._isFadeOut},set:function(e){e?this.shaderData.enableMacro("fadeOut"):this.shaderData.disableMacro("fadeOut"),this._isFadeOut=e}},{key:"playOnEnable",get:function(){return this._playOnEnable},set:function(e){this._playOnEnable=e,e?this.start():this.stop()}},{key:"blendMode",get:function(){return this._blendMode},set:function(t){var n=this.getMaterial().renderState.blendState.targetBlendState;0===t?(n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha):1===t&&(n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.One,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha),this._blendMode=t}}]),i1);hh._uint16VertexLimit=65535,s8([s7],hh.prototype,"_onColorChanged",null),l$.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 hd=(s3(i3=function(t){var n,r=(n=ur.call(this,t,l$.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=e.BlendFactor.One,n.renderState.depthState.writeEnabled=!1,n},ur),i3),h_=new sO,hf=(s3(i4=function(e,t){(n=c_.call(this,e)||this)._stroke=t.stroke||.2,n._minSeg=t.minSeg||.02,n._lifetime=t.lifetime||1e3,n._maxPointNum=n._lifetime/1e3*e.engine.targetFrameRate,n._points=[],n._pointStates=[],n._strapPoints=[];for(var n,r=0;r<n._maxPointNum;r++)n._points.push(new sO),n._pointStates.push(n._lifetime),n._strapPoints.push(new sO),n._strapPoints.push(new sO);n._curPointNum=0;var i=t.material||new hd(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},c_),(i5=i4.prototype).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 i=!0;if(this._curPointNum===this._maxPointNum)i=!1;else if(this._curPointNum>0){var a=this._points[this._points.length-1];sO.distance(this.entity.transform.worldPosition,a)<this._minSeg&&(i=!1)}i&&(this._pointStates[this._curPointNum]=this._lifetime,this._points[this._curPointNum].copyFrom(this.entity.transform.worldPosition),this._curPointNum++)},i5.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},i5._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),c_.prototype._render.call(this,e)},i5._initGeometry=function(){var t=new cw(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new ci("POSITION",0,e.VertexElementFormat.Vector3,0),new ci("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new ca(this.engine,4*r,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(a),t.addSubMesh(0,n,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=i,this.mesh=t},i5._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sO(n[0],n[4],n[8]),i=new sO(n[1],n[5],n[9]),a=new sO(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sO,l=new sO,c=new sX;sO.transformByQuat(r,c,r),sO.transformByQuat(i,c,i);var u=new sO,h=new sO,d=new sO;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?sO.subtract(p,t[f-1],d):sO.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sO.dot(r,d));sO.cross(r,d,h),0>=sO.dot(h,a)&&(g=2*Math.PI-g),sX.rotationAxisAngle(a,g,c),sO.transformByQuat(i,c,u),sO.add(p,u,s),sO.subtract(p,u,l)}var m=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[m]=s.x,_[m+1]=s.y,_[m+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},i5._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 i=1-r*t,a=2*r*this._vertexStride/4,o=(2*r+1)*this._vertexStride/4;n[a]=0,n[a+1]=i,n[o]=1,n[o+1]=i}}},i5._projectOnVector=function(e,t,n){var r=t.clone();sO.normalize(r,r);var i=sO.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},i5._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,h_),sO.subtract(e,h_,n)},i4),hp=(s3(i8=function(){var t;return t=uv.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uv),(i6=i8.prototype).onTextureChange=function(e){},i6.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 lf(this.engine,this.width,this.height,this._isCube?new lm(this.engine,this.width):new lp(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new lf(this.engine,this.width,this.height,this._isCube?new lm(this.engine,this.width):new lp(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},i6.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},i6._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},s1(i8,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),i8),hg=new sO,hm=new sO,hv=new sO,hy=(s3(i7=function(){var e;return e=hp.apply(this,arguments)||this,e.position=new sO(0,0,0),e._isCube=!0,e.oriViewMatrix=new sK,e},hp),(i9=i7.prototype).onBeginRender=function(t){if(this.enabled){hp.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var n=0;n<6;n++)this._setCamera(n,t),t.render(e.TextureCubeFace.PositiveX+n);this._restoreCamera(t),hp.prototype._reset.call(this)}},i9._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},i9._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},i9._setCamera=function(e,t){switch(e){case 0:hm.set(0,-1,0),hv.set(1,0,0);break;case 1:hm.set(0,-1,0),hv.set(-1,0,0);break;case 2:hm.set(0,0,1),hv.set(0,1,0);break;case 3:hm.set(0,0,-1),hv.set(0,-1,0);break;case 4:hm.set(0,-1,0),hv.set(0,0,1);break;case 5:hm.set(0,-1,0),hv.set(0,0,-1)}sO.add(this.position,hv,hg),sK.lookAt(this.position,hg,hm,t.viewMatrix),t.fieldOfView=90},i7),hx=Object.freeze({__proto__:null,AmbientLight:uh,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:u5,AnimationClipCurveBinding:u3,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:u8,AnimationEvent:u4,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:hn,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hr,AnimatorControllerLayer:hi,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:ho,AnimatorStateMachine:hs,AnimatorStateTransition:u7,AssetPromise:cN,get AssetType(){return e.AssetType},Background:uc,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uN,Basic2DBatcher:cb,BasicRenderPipeline:uM,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:cM,BlendShapeFrame:cE,BlendState:l2,BlinnPhongMaterial:uV,BoolUpdateFlag:lD,BoxColliderShape:c8,Buffer:ca,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:cw,get BufferUsage(){return e.BufferUsage},BufferUtil:cr,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:c9,CharacterController:cq,CloneManager:ln,get Collider(){return e.Collider},ColliderShape:c5,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:lw,ContentRestorer:la,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:hy,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:l3,get DiffuseMode(){return e.DiffuseMode},DirectLight:u_,DynamicCollider:cY,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:us,EngineObject:lr,Entity:lV,EventDispatcher:lC,FixedJoint:c0,get FogMode(){return e.FogMode},Font:lT,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:c1,HitResult:cQ,IndexBufferBinding:co,get IndexFormat(){return e.IndexFormat},InputManager:un,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:c3,JointMotor:c4,Keyframe:hl,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:ud,Loader:uB,Logger:ld,Material:ur,Mesh:cl,MeshRenderer:c_,get MeshTopology(){return e.MeshTopology},ModelMesh:ch,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uO,PBRMaterial:uU,PBRSpecularMaterial:uz,ParticleRenderer:hh,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsMaterial:cJ,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:cj,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:c7,get Platform(){return e.Platform},PointLight:uf,Pointer:cG,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:cA,Probe:hp,RasterState:l4,ReferResource:li,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uE,RenderQueue:ux,get RenderQueueType(){return e.RenderQueueType},RenderState:l8,RenderTarget:lf,RenderTargetBlendState:l1,get Renderer(){return e.Renderer},ResourceManager:cV,Scene:um,SceneManager:cB,Script:uv,get SetDataOptions(){return e.SetDataOptions},Shader:l$,ShaderData:l0,ShaderFactory:lX,ShaderMacro:lk,ShaderMacroCollection:lG,ShaderPass:lJ,ShaderProperty:lS,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:lK,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:cd,SkinnedMeshRenderer:cf,Sky:ul,SkyBoxMaterial:hc,SkyProceduralMaterial:hu,SphereColliderShape:c6,SpotLight:up,SpringJoint:c2,Sprite:uH,SpriteAtlas:uG,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:cn,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:uK,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:ha,StaticCollider:cZ,get StencilOperation(){return e.StencilOperation},StencilState:l5,SubMesh:cs,SubShader:lZ,get SunMode(){return e.SunMode},SystemInfo:cX,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:uY,TextUtils:ly,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:l_,Texture2D:lp,Texture2DArray:lg,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:lm,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},get TextureWrapMode(){return e.TextureWrapMode},Time:lA,TrailMaterial:hd,TrailRenderer:hf,Transform:lB,UnlitMaterial:uk,Utils:lF,VertexBufferBinding:cc,VertexElement:ci,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:s9,deepClone:lt,dependentComponents:lM,ignoreClone:s7,request:uP,resourceLoader:cO,shallowClone:le});function hT(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 hC(e,t,n){return t&&hT(e.prototype,t),n&&hT(e,n),e}function hS(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(ae=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[ae.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",ae[ae.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",ae[ae.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",ae[ae.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",ae[ae.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",ae[ae.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",ae[ae.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",ae[ae.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",ae[ae.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",ae[ae.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",ae[ae.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",ae[ae.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",ae[ae.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",ae[ae.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",ae[ae.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",ae[ae.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",ae[ae.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",ae[ae.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",ae[ae.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",ae[ae.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",ae[ae.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",ae[ae.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",ae[ae.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",ae[ae.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",ae[ae.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",ae[ae.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",ae[ae.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",ae[ae.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",ae[ae.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",ae[ae.R11_EAC=37488]="R11_EAC",ae[ae.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",ae[ae.RG11_EAC=37490]="RG11_EAC",ae[ae.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",ae[ae.RGB8_ETC2=37492]="RGB8_ETC2",ae[ae.SRGB8_ETC2=37493]="SRGB8_ETC2",ae[ae.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",ae[ae.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",ae[ae.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",ae[ae.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",ae[ae.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",ae[ae.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",ae[ae.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",ae[ae.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",ae[ae.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",ae[ae.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",ae[ae.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",ae[ae.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var hA=((an=(at=function(e){this._scale=new sq;var t=e.width,n=e.height;this._webCanvas=e,this._width=t,this._height=n}).prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&hS(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},an.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},hC(at,[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._webCanvas.width=e,this._width=e)}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._webCanvas.height=e,this._height=e)}},{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&hS(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&&hS(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),at);function hw(e,t){return(hw=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hE(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&&hw(e,t)}var hM=(hE(ar=function(){return us.apply(this,arguments)},us),ar.create=function(e){var t=e.canvas,n=new hA("string"==typeof t?document.getElementById(t):t),r=new hU(e.graphicDeviceOptions),i=new ar(n,r,e);return i._initialize(e).then(function(){return i.sceneManager.addScene(new um(i,"DefaultScene")),i})},hC(ar,[{key:"canvas",get:function(){return this._canvas}}]),ar);function hb(){return(hb=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 hF=((aa=(ai=function(t,n,r,i,a){void 0===i&&(i=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,i),c=n===e.BufferBindFlag.VertexBuffer?o.ARRAY_BUFFER:o.ELEMENT_ARRAY_BUFFER;this._gl=o,this._glBuffer=s,this._glBufferUsage=l,this._glBindTarget=c,this._isWebGL2=t.isWebGL2,this.bind(),a?o.bufferData(c,a,l):o.bufferData(c,r,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},aa.setData=function(t,n,r,i,a,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=n.BYTES_PER_ELEMENT||1,u=a?c*a:n.byteLength;if(0!==i||u<n.byteLength){var h=void 0!==n.byteOffset;if(this._isWebGL2&&h)s.bufferSubData(l,r,n,i,u/c);else{var d=new Uint8Array(h?n.buffer:n,i*c,u);s.bufferSubData(l,r,d)}}else s.bufferSubData(l,r,n);s.bindBuffer(l,null)},aa.getData=function(e,t,n,r){if(this._isWebGL2){var i=this._gl;this.bind(),i.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},aa.resize=function(e){this.bind(),this._gl.bufferData(this._glBindTarget,e,this._glBufferUsage)},aa.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},aa._getGLBufferUsage=function(t,n){switch(n){case e.BufferUsage.Static:return t.STATIC_DRAW;case e.BufferUsage.Dynamic:return t.DYNAMIC_DRAW;case e.BufferUsage.Stream:return t.STREAM_DRAW}},ai),hR=((as=(ao=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},as.canIUseCompressedTextureInternalFormat=function(t){var n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,r=e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,i=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_4X4_KHR,a=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ASTC_12X12_KHR,o=e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,s=e.GLCompressedTextureInternalFormat.R11_EAC,l=e.GLCompressedTextureInternalFormat.SRGB8_ALPHA8_ETC2_EAC,c=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,u=e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,h=e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,d=e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT;return t>=n&&r<=r||t>=i&&t<=a?this.canIUse(e.GLCapabilityType.astc):t===o?this.canIUse(e.GLCapabilityType.etc1):t>=s&&t<=l?this.canIUse(e.GLCapabilityType.etc):t>=c&&t<=u?this.canIUse(e.GLCapabilityType.pvrtc):!!(t>=h)&&!!(t<=d)&&this.canIUse(e.GLCapabilityType.s3tc)},as._init=function(){var t=this.capabilityList,n=this.rhi.isWebGL2,r=this.rhi.requireExtension.bind(this.rhi),i=e.GLCapabilityType.shaderVertexID,a=e.GLCapabilityType.standardDerivatives,o=e.GLCapabilityType.shaderTextureLod,s=e.GLCapabilityType.elementIndexUint,l=e.GLCapabilityType.depthTexture,c=e.GLCapabilityType.vertexArrayObject,u=e.GLCapabilityType.instancedArrays,h=e.GLCapabilityType.multipleSample,d=e.GLCapabilityType.drawBuffers,_=e.GLCapabilityType.astc,f=e.GLCapabilityType.astc_webkit,p=e.GLCapabilityType.etc,g=e.GLCapabilityType.etc_webkit,m=e.GLCapabilityType.etc1,v=e.GLCapabilityType.etc1_webkit,y=e.GLCapabilityType.pvrtc,x=e.GLCapabilityType.pvrtc_webkit,T=e.GLCapabilityType.s3tc,C=e.GLCapabilityType.s3tc_webkit,S=e.GLCapabilityType.textureFloat,A=e.GLCapabilityType.textureHalfFloat,w=e.GLCapabilityType.textureFloatLinear,E=e.GLCapabilityType.textureHalfFloatLinear,M=e.GLCapabilityType.WEBGL_colorBufferFloat,b=e.GLCapabilityType.colorBufferFloat,F=e.GLCapabilityType.colorBufferHalfFloat,R=e.GLCapabilityType.textureFilterAnisotropic;t.set(i,n),t.set(a,n||!!r(a)),t.set(o,n||!!r(o)),t.set(s,n||!!r(s)),t.set(l,n||!!r(l)),t.set(c,n||!!r(c)),t.set(u,n||!!r(u)),t.set(h,n),t.set(d,n||!!r(d)),t.set(S,n||!!r(S)),t.set(A,n||!!r(A)),t.set(w,!!r(w)),t.set(E,n||!!r(E)),t.set(b,n&&!!r(b)||!!r(M)),t.set(F,n&&!!r(b)||!!r(F)),t.set(R,!!r(R)),t.set(_,!!(r(_)||r(f))),t.set(p,!!(r(p)||r(g))),t.set(m,!!(r(m)||r(v))),t.set(y,!!(r(y)||r(x))),t.set(T,!!(r(T)||r(C)))},as._compatibleInterface=function(e,t){var n=this.rhi,r=n.gl,i=null;if(i=n.requireExtension(e))for(var a in t){var o=i[t[a]];(null==o?void 0:o.bind)?r[a]=o.bind(i):r[a]=o}},as._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,n=e.GLCapabilityType.vertexArrayObject,r=e.GLCapabilityType.instancedArrays,i=e.GLCapabilityType.drawBuffers,a=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat;if(!this.rhi.isWebGL2){this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(n,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(r,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(i,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var c={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var u=this.maxDrawBuffers,h=0;h<u;h++)0!=h&&(c["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),c["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(i,hb({drawBuffers:"drawBuffersWEBGL"},c))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},hC(ao,[{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,n=this.canIUse(e.GLCapabilityType.multipleSample);this._maxAntiAliasing=n?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),ao),hP=((al=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]},al),hL=((au=(ac=function(t,n){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=n,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._useVao=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var n=this._gl,r=this._primitive,i=this._useVao&&r._enableVAO;if(i){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var a=this._vaoMap.get(e.id);n.bindVertexArray(a)}else this._bindBufferAndAttrib(e);var o=r._indexBufferBinding,s=r._instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,h=t.start,d=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)n.drawElementsInstanced(u,d,l,h*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,d,l,h*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,h,d,s)}else ld.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(i)n.drawElements(u,d,l,h*c);else{var f=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(u,d,l,h*c),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(u,h,d);i?n.bindVertexArray(null):this._disableAttrib()},au.destroy=function(){this._useVao&&this._clearVAO()},au._bindBufferAndAttrib=function(e){var t,n,r=this._gl,i=this._primitive,a=i._vertexBufferBindings;this._attribLocArray.length=0;var o=e.attributeLocation,s=i._vertexElementMap;for(var l in o){var c=o[l];if(-1!==c){var u=s[l];if(u){var h=a[u.bindingIndex],d=h.buffer,_=h.stride;n!==(t=d._platformBuffer._glBuffer)&&(n=t,r.bindBuffer(r.ARRAY_BUFFER,t)),r.enableVertexAttribArray(c);var f=u._glElementInfo;r.vertexAttribPointer(c,f.size,f.type,f.normalized,_,u.offset),this._canUseInstancedArrays&&r.vertexAttribDivisor(c,u.instanceStepRate),this._attribLocArray.push(c)}else ld.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},au._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},au._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)},au._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},ac),hD=((ah=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]},ah),hI=((a_=(ad=function(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()}).prototype).destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},a_.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},a_.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},a_._bind=function(){this._rhi.bindTexture(this)},a_._init=function(e){var t=this._gl,n=this._isWebGL2,r=this._formatDetail,i=r.internalFormat,a=r.baseFormat,o=r.dataType,s=this._texture,l=s.mipmapCount,c=s.width,u=s.height,h=s._isDepthTexture;if(this._bind(),n&&!(a===t.LUMINANCE_ALPHA||a===t.ALPHA))t.texStorage2D(this._target,l,i,c,u);else if(e)for(var d=0;d<l;d++)for(var _=Math.max(1,c>>d),f=0;f<6;f++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+f,d,i,_,_,0,a,o,null);else if(h)t.texImage2D(this._target,0,i,c,u,0,a,o,null);else for(var p=0;p<l;p++){var g=Math.max(1,c>>p),m=Math.max(1,u>>p);t.texImage2D(this._target,p,i,g,m,0,a,o,null)}},a_._getPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,ld.error("mipLevel only take effect in WebGL2.0")),null!=e?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+e,this._glTexture,a):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,this._glTexture,a),s.readPixels(t,n,r,i,c,u,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},a_._setWrapMode=function(t,n){var r=this._gl,i=this._isWebGL2,a=this._target,o=this._texture,s=o.width,l=o.height;switch(i||t===e.TextureWrapMode.Clamp||ad._isPowerOf2(s)&&ad._isPowerOf2(l)||(ld.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:r.texParameteri(a,n,r.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:r.texParameteri(a,n,r.REPEAT);break;case e.TextureWrapMode.Mirror:r.texParameteri(a,n,r.MIRRORED_REPEAT)}},a_._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},ad._isPowerOf2=function(e){return(e&e-1)==0},ad._getFormatDetail=function(t,n,r){switch(t){case e.TextureFormat.R8G8B8:return{internalFormat:r?n.RGB8:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R8G8B8A8:return{internalFormat:r?n.RGBA8:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R4G4B4A4:return{internalFormat:r?n.RGBA4:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case e.TextureFormat.R5G5B5A1:return{internalFormat:r?n.RGB5_A1:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case e.TextureFormat.R5G6B5:return{internalFormat:r?n.RGB565:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case e.TextureFormat.Alpha8:return{internalFormat:n.ALPHA,baseFormat:n.ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.LuminanceAlpha:return{internalFormat:n.LUMINANCE_ALPHA,baseFormat:n.LUMINANCE_ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:r?n.RGBA16F:n.RGBA,baseFormat:n.RGBA,dataType:n.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:r?n.RGBA32F:n.RGBA,baseFormat:n.RGBA,dataType:n.FLOAT,isCompressed:!1};case e.TextureFormat.DXT1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.DXT5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_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:r?n.DEPTH_COMPONENT32F:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:r?n.FLOAT:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:r?n.DEPTH32F_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:r?n.FLOAT_32_UNSIGNED_INT_24_8_REV:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r?n.DEPTH_COMPONENT16:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:r?n.DEPTH24_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:n.DEPTH32F_STENCIL8,baseFormat:n.DEPTH_STENCIL,dataType:n.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},ad._getRenderBufferDepthFormatDetail=function(t,n,r){switch(t){case e.RenderBufferDepthFormat.Depth:return{internalFormat:r?n.DEPTH_COMPONENT32F:n.DEPTH_COMPONENT16,baseFormat:n.DEPTH_COMPONENT,dataType:r?n.FLOAT:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.DepthStencil:return{internalFormat:r?n.DEPTH32F_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:r?n.FLOAT_32_UNSIGNED_INT_24_8_REV:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Stencil:return{internalFormat:n.STENCIL_INDEX8,baseFormat:n.STENCIL_ATTACHMENT,dataType:n.UNSIGNED_BYTE,isCompressed:!1,attachment:n.STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth16:return{internalFormat:n.DEPTH_COMPONENT16,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth24Stencil8:return{internalFormat:r?n.DEPTH24_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32Stencil8:return{internalFormat:n.DEPTH32F_STENCIL8,baseFormat:n.DEPTH_STENCIL,dataType:n.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},ad._supportTextureFormat=function(t,n){switch(t){case e.TextureFormat.R16G16B16A16:if(!n.canIUse(e.GLCapabilityType.textureHalfFloat))return!1;break;case e.TextureFormat.R32G32B32A32:if(!n.canIUse(e.GLCapabilityType.textureFloat))return!1;break;case e.TextureFormat.Depth16:case e.TextureFormat.Depth24Stencil8:case e.TextureFormat.Depth:case e.TextureFormat.DepthStencil:if(!n.canIUse(e.GLCapabilityType.depthTexture))return!1;break;case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return n.isWebGL2}return!0},ad._supportRenderBufferColorFormat=function(t,n){var r=!0;switch(t){case e.TextureFormat.R16G16B16A16:n.canIUse(e.GLCapabilityType.colorBufferHalfFloat)&&n.canIUse(e.GLCapabilityType.textureHalfFloat)||(r=!1);break;case e.TextureFormat.R32G32B32A32:n.canIUse(e.GLCapabilityType.colorBufferFloat)&&n.canIUse(e.GLCapabilityType.textureFloat)||(r=!1)}return r},ad._supportRenderBufferDepthFormat=function(t,n){if(!n.isWebGL2)switch(t){case e.RenderBufferDepthFormat.Depth24:case e.RenderBufferDepthFormat.Depth32:case e.RenderBufferDepthFormat.Depth32Stencil8:return!1}return!0},hC(ad,[{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 n=this._gl,r=this._target,i=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(r,n.TEXTURE_MIN_FILTER,i?n.NEAREST_MIPMAP_NEAREST:n.NEAREST);break;case e.TextureFilterMode.Bilinear:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(r,n.TEXTURE_MIN_FILTER,i?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);break;case e.TextureFilterMode.Trilinear:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(r,n.TEXTURE_MIN_FILTER,i?n.LINEAR_MIPMAP_LINEAR:n.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 n=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.NEVER);break;case e.TextureDepthCompareFunction.Less:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.LESS);break;case e.TextureDepthCompareFunction.Equal:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.GEQUAL);break;case e.TextureDepthCompareFunction.Always:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.ALWAYS)}}}]),ad),hB=((ap=(af=function(t,n){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=n;for(var r=n._colorTextures,i=n._depth,a=n.width,o=n.height,s=hS(i,l_),l=0,c=r.length;l<c;l++){var u=r[l]._format;if(!hI._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!hI._supportRenderBufferDepthFormat(i,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[i]+" in RenderTarget");if(r.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(r.some(function(e){return e.width!==a||e.height!==o}))throw Error("ColorTexture's size must as same as RenderTarget");if(s&&(i.width!==a||i.height!==o))throw Error("DepthTexture's size must as same as RenderTarget");if(r.length>1&&r.some(function(e){return hS(e,lm)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(ld.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+h),n._antiAliasing=h),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),n.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).setRenderTargetInfo=function(e,t){var n=this._gl,r=this._target,i=r.depthTexture,a=r.getColorTexture(0),o=t!==this._curMipLevel;if(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),a){var s=hS(a,lm);(o||s)&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,s?n.TEXTURE_CUBE_MAP_POSITIVE_X+e:n.TEXTURE_2D,a._platformTexture._glTexture,t)}if(i){var l=hS(i,lm);if(o||l){var c=i._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,c._formatDetail.attachment,l?n.TEXTURE_CUBE_MAP_POSITIVE_X+e:n.TEXTURE_2D,c._glTexture,t)}}else if(o){var u=hI._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,u,r.width>>t,r.height>>t)}this._curMipLevel=t,this._activeRenderTarget()},ap.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,i=n.width,a=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,i,a,0,0,i,a,t,e.NEAREST),this._blitDrawBuffers[o]=e.NONE}e.bindFramebuffer(e.FRAMEBUFFER,null)}},ap.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},ap._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},ap._bindMainFBO=function(){var e=this._gl,t=this._isWebGL2,n=this._target,r=n._depth,i=n.colorTextureCount,a=n.width,o=n.height,s=Array(i);e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer);for(var l=0;l<i;l++){var c=this._target.getColorTexture(l),u=e.COLOR_ATTACHMENT0+l;s[l]=u,hS(c,lm)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(hS(r,l_)&&!hS(r,lm)){var h=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,h._formatDetail.attachment,e.TEXTURE_2D,h._glTexture,0)}else if(this._target.antiAliasing<=1){var d=hI._getRenderBufferDepthFormatDetail(r,e,t),_=d.internalFormat,f=d.attachment,p=e.createRenderbuffer();this._depthRenderBuffer=p,e.bindRenderbuffer(e.RENDERBUFFER,p),e.renderbufferStorage(e.RENDERBUFFER,_,a,o),e.framebufferRenderbuffer(e.FRAMEBUFFER,f,e.RENDERBUFFER,p)}}e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},ap._bindMSAAFBO=function(){var e=this._gl,t=this._isWebGL2,n=e.createRenderbuffer(),r=this._target,i=r._depth,a=r.colorTextureCount,o=r.antiAliasing,s=r.width,l=r.height;this._blitDrawBuffers=Array(a),this._MSAADepthRenderBuffer=n,e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer);for(var c=0;c<a;c++){var u=e.createRenderbuffer();this._MSAAColorRenderBuffers[c]=u,this._blitDrawBuffers[c]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,u),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(c)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+c,e.RENDERBUFFER,u)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var h=hS(i,l_)?i._platformTexture._formatDetail:hI._getRenderBufferDepthFormatDetail(i,e,t),d=h.internalFormat,_=h.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,d,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},ap._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.")},af),hN=(hE(ag=function(t,n){(r=hI.call(this,t,n,t.gl.TEXTURE_2D)||this)._compressedMipFilled=0;var r,i=n.format,a=n._mipmap,o=n.width,s=n.height,l=r._isWebGL2;if(!hI._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||hI._isPowerOf2(o)&&hI._isPowerOf2(s)||(ld.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=hI._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},hI),(am=ag.prototype).setPixelBuffer=function(e,t,n,r,i,a){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,h=l.dataType,d=l.isCompressed,_=Math.max(1,this._texture.width>>t),f=Math.max(1,this._texture.height>>t);if(i=i||_-n,a=a||f-r,this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,0),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),d){var p=1<<t;s||this._compressedMipFilled&p?o.compressedTexSubImage2D(this._target,t,n,r,i,a,c,e):(o.compressedTexImage2D(this._target,t,c,i,a,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,i,a,u,h,e)},am.setImageSource=function(e,t,n,r,i,a){var o=this._gl,s=this._formatDetail,l=s.baseFormat,c=s.dataType;this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,+n),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+r),o.texSubImage2D(this._target,t,i||0,a||0,l,c,e)},am.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hI.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},ag),hV=(hE(av=function(t,n){r=hI.call(this,t,n,t.gl.TEXTURE_2D_ARRAY)||this;var r,i=n.format,a=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(!hI._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=hI._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},hI),(ay=av.prototype).setPixelBuffer=function(e,t,n,r,i,a,o,s){var l=this._target,c=this._gl,u=this._formatDetail,h=u.internalFormat,d=u.baseFormat,_=u.dataType,f=u.isCompressed;a=a||Math.max(1,this._texture.width>>n)-r,o=o||Math.max(1,this._texture.height>>n)-i,s=s||this._texture.length,this._bind(),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?c.compressedTexSubImage3D(l,n,r,i,e,a,o,s,h,t):c.texSubImage3D(l,n,r,i,e,a,o,s,d,_,t)},ay.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage3D(this._target,n,a,o,e,t.width,t.height,1,c,u,t)},ay.getPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail;if(l.isCompressed)throw Error("Unable to read compressed texture");s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,this._glTexture,a,e),s.readPixels(t,n,r,i,l.baseFormat,l.dataType,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},av),hO=(hE(ax=function(t,n){(r=hI.call(this,t,n,t.gl.TEXTURE_CUBE_MAP)||this)._compressedFaceFilled=[0,0,0,0,0,0];var r,i=n.format,a=n._mipmap,o=n.width,s=r._isWebGL2;if(!hI._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||hI._isPowerOf2(o)||(ld.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=hI._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},hI),(aT=ax.prototype).setPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,h=c.baseFormat,d=c.dataType,_=c.isCompressed,f=Math.max(1,this._texture.width>>n);if(a=a||f-r,o=o||f-i,this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,0),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),_){var p=1<<n;l||this._compressedFaceFilled[e]&p?s.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,u,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,u,a,o,0,t),this._compressedFaceFilled[e]|=p)}else s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,r,i,a,o,h,d,t)},aT.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,c=l.baseFormat,u=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+i),s.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,a||0,o||0,c,u,t)},aT.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hI.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},ax);e.WebGLMode=void 0,(aC=e.WebGLMode||(e.WebGLMode={}))[aC.Auto=0]="Auto",aC[aC.WebGL2=1]="WebGL2",aC[aC.WebGL1=2]="WebGL1";var hU=((aA=(aS=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new sY(null,null,null,null),this._lastScissor=new sY(null,null,null,null),this._lastClearColor=new sQ(null,null,null,null),this._scissorEnable=!1;var n=hb({webGLMode:0,stencil:!0,_forceFlush:!1},t);if(cX.platform===e.Platform.IPhone||cX.platform===e.Platform.IPad){var r=cX.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(r){var i=parseInt(r[1]),a=parseInt(r[2]);15===i&&a>=0&&a<=4&&(n._forceFlush=!0)}}this._options=n,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).init=function(e,t,n){var r,i=this._options,a=e._webCanvas,o=i.webGLMode;if(this._onDeviceLost=t,this._onDeviceRestored=n,a.addEventListener("webglcontextlost",this._onWebGLContextLost,!1),a.addEventListener("webglcontextrestored",this._onWebGLContextRestored,!1),a.addEventListener("webglcontextcreationerror",this._onContextCreationError,!1),this._webCanvas=a,(0==o||1==o)&&((r=a.getContext("webgl2",i))||"undefined"!=typeof OffscreenCanvas&&hS(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl2",i)),this._isWebGL2=!0,r&&!r.deleteQuery&&(this._isWebGL2=!1)),r||0!=o&&2!=o||((r=a.getContext("webgl",i))||"undefined"!=typeof OffscreenCanvas&&hS(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},aA.createPlatformPrimitive=function(e){return new hL(this,e)},aA.createPlatformTexture2D=function(e){return new hN(this,e)},aA.createPlatformTexture2DArray=function(e){return new hV(this,e)},aA.createPlatformTextureCube=function(e){return new hO(this,e)},aA.createPlatformRenderTarget=function(e){return new hB(this,e)},aA.createPlatformBuffer=function(t,n,r,i){return void 0===r&&(r=e.BufferUsage.Static),new hF(this,t,n,r,i)},aA.requireExtension=function(e){return this._extensions.requireExtension(e)},aA.canIUse=function(e){return this.capability.canIUse(e)},aA.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},aA.viewport=function(e,t,n,r){var i=this._gl,a=this._lastViewport;(e!==a.x||t!==a.y||n!==a.z||r!==a.w)&&(i.viewport(e,t,n,r),a.set(e,t,n,r))},aA.scissor=function(e,t,n,r){var i=this._gl,a=this._lastScissor;if(e!==a.x||t!==a.y||n!==a.z||r!==a.w){var o=this._webCanvas;0===e&&0===t&&n===o.width&&r===o.height?this._scissorEnable&&(i.disable(i.SCISSOR_TEST),this._scissorEnable=!1):(this._scissorEnable||(i.enable(i.SCISSOR_TEST),this._scissorEnable=!0),i.scissor(e,t,n,r)),a.set(e,t,n,r)}},aA.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},aA.clearRenderTarget=function(t,n,r){var i=this._gl,a=t._lastRenderState,o=a.blendState.targetBlendState,s=a.depthState,l=a.stencilState,c=0;if(n&e.CameraClearFlags.Color){c|=i.COLOR_BUFFER_BIT;var u=this._lastClearColor,h=r.r,d=r.g,_=r.b,f=r.a;r&&(h!==u.r||d!==u.g||_!==u.b||f!==u.a)&&(i.clearColor(h,d,_,f),u.set(h,d,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(i.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}n&e.CameraClearFlags.Depth&&(c|=i.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(i.depthMask(!0),s.writeEnabled=!0)),n&e.CameraClearFlags.Stencil&&(c|=i.STENCIL_BUFFER_BIT,255!==l.writeMask&&(i.stencilMask(255),l.writeMask=255)),i.clear(c)},aA.drawPrimitive=function(e,t,n){e?e._draw(n,t):ld.error("draw primitive failed.")},aA.activeRenderTarget=function(e,t,n){var r,i,a,o=this._gl;e?(null==(a=e._platformRenderTarget)||a._activeRenderTarget(),r=e.width>>n,i=e.height>>n):(o.bindFramebuffer(o.FRAMEBUFFER,null),r=o.drawingBufferWidth,i=o.drawingBufferHeight);var s=r*t.z,l=i*t.w,c=t.x*r,u=i-t.y*i-l;this.viewport(c,u,s,l),this.scissor(c,u,s,l)},aA.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},aA.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)},aA.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},aA.flush=function(){this._gl.flush()},aA.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},aA.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},aA.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)},aA._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new hD(e),this._extensions=new hP(this),this._capability=new hR(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},aA.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},aA._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},aA._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},aA._onWebGLContextRestored=function(e){this._onDeviceRestored()},hC(aS,[{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}}]),aS);function hz(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)}}var hk=((aE=(aw=function(e,t){var n=this;this._costs={},this._currentLoad=0,this._callbacks={},this._worker=new Worker(e),this._worker.onmessage=function(e){var t=e.data;switch(t.type){case"decode":n._callbacks[t.id].resolve(t.geometry);break;case"error":n._callbacks[t.id].reject(t);break;default:ld.error('DRACOWorker: Unexpected message, "'+t.type+'"')}},t?this._worker.postMessage({type:"init",decoderConfig:{wasmBinary:t}}):this._worker.postMessage({type:"init",decoderConfig:{}})}).prototype).setCosts=function(e,t){this._costs[e]=t},aE.addCurrentLoad=function(e){this._currentLoad+=e},aE.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},aE.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},aE.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},hz(aw.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),aM&&hz(aw,aM),aw),hG='let decoderPending;\nlet decoderConfig;\n\nonmessage = function(e) {\n const message = e.data;\n\n switch (message.type) {\n case "init":\n decoderConfig = message.decoderConfig;\n decoderPending = new Promise(function(resolve /*, reject*/) {\n decoderConfig.onModuleLoaded = function(draco) {\n // Module is Promise-like. Wrap before resolving to avoid loop.\n resolve({ draco: draco });\n };\n DracoDecoderModule(decoderConfig);\n });\n break;\n\n case "decode":\n const buffer = message.buffer;\n const taskConfig = message.taskConfig;\n decoderPending.then(module => {\n const draco = module.draco;\n const decoder = new draco.Decoder();\n const decoderBuffer = new draco.DecoderBuffer();\n decoderBuffer.Init(new Int8Array(buffer), buffer.byteLength);\n try {\n const geometry = decodeGeometry(draco, decoder, decoderBuffer, taskConfig);\n const buffers = geometry.attributes.map(attr => attr.array.buffer);\n if (geometry.index) buffers.push(geometry.index.array.buffer);\n self.postMessage({ type: "decode", id: message.id, geometry }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n } finally {\n draco.destroy(decoderBuffer);\n draco.destroy(decoder);\n }\n });\n break;\n }\n};\n\nfunction decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {\n const attributeIDs = taskConfig.attributeIDs;\n const attributeTypes = taskConfig.attributeTypes;\n\n let dracoGeometry;\n let decodingStatus;\n\n const geometryType = decoder.GetEncodedGeometryType(decoderBuffer);\n if (geometryType === draco.TRIANGULAR_MESH) {\n dracoGeometry = new draco.Mesh();\n decodingStatus = decoder.DecodeBufferToMesh(decoderBuffer, dracoGeometry);\n } else {\n throw new Error("DRACODecoder worker: Unexpected geometry type.");\n }\n\n if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {\n throw new Error("DRACODecoder worker: Decoding failed: " + decodingStatus.error_msg());\n }\n\n const geometry = { index: null, attributes: [] };\n\n // Gather all vertex attributes.\n for (let attributeName in attributeIDs) {\n const attributeType = self[attributeTypes[attributeName]];\n\n let attribute;\n let attributeID;\n\n // A Draco file may be created with default vertex attributes, whose attribute IDs\n // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,\n // a Draco file may contain a custom set of attributes, identified by known unique\n // IDs. glTF files always do the latter, and .drc files typically do the former.\n if (taskConfig.useUniqueIDs) {\n attributeID = attributeIDs[attributeName];\n attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);\n } else {\n attributeID = decoder.GetAttributeId(dracoGeometry, draco[attributeIDs[attributeName]]);\n if (attributeID === -1) continue;\n attribute = decoder.GetAttribute(dracoGeometry, attributeID);\n }\n geometry.attributes.push(decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute));\n }\n // Add index.\n if (geometryType === draco.TRIANGULAR_MESH) {\n // Generate mesh faces.\n const numFaces = dracoGeometry.num_faces();\n const numIndices = numFaces * 3;\n let dataSize;\n let ptr;\n let index;\n const indexType = self[taskConfig.indexType];\n\n switch (indexType) {\n case Uint16Array:\n dataSize = numIndices * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt16Array(dracoGeometry, dataSize, ptr);\n index = new Uint16Array(draco.HEAPU16.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n case Uint32Array:\n dataSize = numIndices * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt32Array(dracoGeometry, dataSize, ptr);\n index = new Uint32Array(draco.HEAPU32.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n default:\n throw new Error("DRACODecoder: Unexpected index type.");\n }\n geometry.index = { array: index, itemSize: 1 };\n }\n draco.destroy(dracoGeometry);\n return geometry;\n}\n\nfunction decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute) {\n const numComponents = attribute.num_components();\n const numPoints = dracoGeometry.num_points();\n const numValues = numPoints * numComponents;\n let ptr;\n let array;\n let dataSize;\n switch (attributeType) {\n case Float32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_FLOAT32, dataSize, ptr);\n array = new Float32Array(draco.HEAPF32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT8, numValues, ptr);\n array = new Int8Array(draco.HEAP8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT16, dataSize, ptr);\n array = new Int16Array(draco.HEAP16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT32, dataSize, ptr);\n array = new Int32Array(draco.HEAP32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT8, numValues, ptr);\n array = new Uint8Array(draco.HEAPU8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT16, dataSize, ptr);\n array = new Uint16Array(draco.HEAPU16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT32, dataSize, ptr);\n array = new Uint32Array(draco.HEAPU32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n default:\n throw new Error("DRACODecoder: Unexpected attribute type.");\n }\n\n return {\n name: attributeName,\n array: array,\n itemSize: numComponents\n };\n}\n',hH="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",hW=((aF=(ab=function(e){if(void 0===e&&(e={type:"wasm",workerLimit:4}),this.pool=[],this.workerLimit=Math.min(navigator.hardwareConcurrency||4,4),this.currentTaskId=1,this.taskCache=new WeakMap,e.workerLimit>this.workerLimit)ld.warn("DRACOWorkerPool: Can not initialize worker pool with limit:"+e.workerLimit);else{var t;this.workerLimit=null!=(t=e.workerLimit)?t:4}this.useJS="object"!=typeof WebAssembly||"js"===e.type,this.loadLibPromise=this.preloadLib()}).prototype).preloadLib=function(){var e=this;return this.loadLibPromise?this.loadLibPromise:new Promise(function(t,n){e.useJS?uP(""+hH+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,hG].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uP(""+hH+"draco_wasm_wrapper_gltf.js",{type:"text"}),uP(""+hH+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,hG].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},aF.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new hk(t.workerSourceURL,t.decoderWASMBinary);e.pool.push(n)}else e.pool.sort(function(e,t){return e.currentLoad>t.currentLoad?-1:1});return e.pool[e.pool.length-1]})},aF.decode=function(e,t){var n,r=this,i=JSON.stringify(t);if(this.taskCache.has(e)){var a=this.taskCache.get(e);if(a.key===i)return a.promise;if(0===e.byteLength)throw Error("DRACODecoder: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var o=this.currentTaskId++,s=e.byteLength,l=new Promise(function(i,a){r.getWorker().then(function(r){n=r,r.setCosts(o,s),r.addCurrentLoad(s),r.setCallback(o,i,a),r.decode(o,t,e)}).catch(function(e){a(e)})});return l.finally(function(){n&&o&&n.releaseTask(o)}),this.taskCache.set(e,{key:i,promise:l}),l},ab);function hX(){return(hX=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 hK(e,t){return(hK=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hj(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&&hK(e,t)}function hq(e,t,n,r){var i,a=arguments.length,o=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o}function hY(e,t){var n,r,i,a,o=function(e){return function(t){return s([e,t])}},s=function(o){if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,o[0]&&(l=0)),l;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,r=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!(i=(i=l.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){l=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){l.label=o[1];break}if(6===o[0]&&l.label<i[1]){l.label=i[1],i=o;break}if(i&&l.label<i[2]){l.label=i[2],l.ops.push(o);break}i[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}},l={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a}var hQ=(hj(aR=function(){return uB.apply(this,arguments)},uB),aR.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"json"})).then(function(e){var n=new hr,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hi(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,h=c.stateMachine=new hs;u.forEach(function(e,n){var i=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,u=e.isDefaultState,d=e.clip,_=e.scripts,f=h.addState(i);u&&(h.defaultState=f),f.speed=o,f.wrapMode=s,f.clipStartTime=l,f.clipEndTime=c,null==_||_.forEach(function(e){f.addStateMachineScript(uB.getClass(e))}),d&&a.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),u.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var n=e.targetStateName,r=e.duration,i=e.offset,a=e.exitTime,o=h.findStateByName(t),s=h.findStateByName(n),l=new u7;l.destinationState=s,l.duration=r,l.exitTime=a,l.offset=i,o.addTransition(l)})})}n.addLayer(c)}),Promise.all(a).then(function(e){e.forEach(function(e){var t=e.layerIndex,r=e.stateIndex,i=e.clip;n.layers[t].stateMachine.states[r].clip=i}),r(n)})}).catch(i)})},aR);hQ=hq([cO(e.AssetType.AnimatorController,["json"],!1)],hQ);var hJ=(hj(aP=function(){return uB.apply(this,arguments)},uB),aP.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new cN(function(e){var n=t.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(n),function(e){return e.charCodeAt(0)}).buffer)}):this.request(t,hX({},e,{type:"arraybuffer"}))},aP);hJ=hq([cO(e.AssetType.Buffer,["bin","r3bin"],!1)],hJ);var hZ=(hj(aL=function(){return uB.apply(this,arguments)},uB),aL.prototype.load=function(t,n){var r=this;return new cN(function(i,a){r.request(t.url,{type:"arraybuffer"}).then(function(t){var r=new Float32Array(t,0,27),a=new Uint16Array(t,108,1)[0],o=new lm(n.engine,a);o.filterMode=e.TextureFilterMode.Trilinear;for(var s=o.mipmapCount,l=110,c=0;c<s;c++)for(var u=a>>c,h=0;h<6;h++){var d=u*u*4,_=new Uint8Array(t,l,d);l+=d,o.setPixelBuffer(e.TextureCubeFace.PositiveX+h,_,c)}var f=new uh,p=new sZ;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},aL);function h$(e,t,n,r,i,a,o){try{var s=e[a](o),l=s.value}catch(e){n(e);return}s.done?t(l):Promise.resolve(l).then(r,i)}function h0(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){h$(a,r,i,o,s,"next",e)}function s(e){h$(a,r,i,o,s,"throw",e)}o(void 0)})}}hZ=hq([cO(e.AssetType.Env,["env"])],hZ);var h1=(hj(aD=function(){return uB.apply(this,arguments)},uB),(aI=aD.prototype).load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,{type:"json"}).then(function(e){var a=e.fontName,o=e.fontUrl;o?n._registerFont(a,o).then(function(){r(new lT(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new lT(t.engine,a))}).catch(function(e){i(e)})})},aI._registerFont=function(e,t){return h0(function(){var n;return hY(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]}})})()},aD);function h2(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 h3(e,t){if(e){if("string"==typeof e)return h2(e,t);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 h2(e,t)}}function h4(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=h3(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.")}h1=hq([cO(e.AssetType.Font,["font"],!1)],h1);var h5=(hj(aB=function(){var e;return e=la.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},la),(aN=aB.prototype).restoreContent=function(){var e=this;return new cN(function(t,n){Promise.all(e.bufferRequests.map(function(e){return uP(e.url,e.config)})).then(function(r){if(e.isGLB){var i=e.glbBufferSlices,a=r[0],o=i.length;r.length=o;for(var s=0;s<o;s++){var l=i[s];r[s]=a.slice(l.x,l.x+l.y)}}cN.all(e.bufferTextures.map(function(e){var t,n=e.bufferView,i=r[n.buffer],a=new Uint8Array(i,null!=(t=n.byteOffset)?t:0,n.byteLength);return ds.loadImageBuffer(a,e.mimeType).then(function(t){e.texture.setImageSource(t),e.texture.generateMipmaps()})})).then(function(){for(var n,i=h4(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=h4(o.vertexBuffers);!(a=l()).done;){var c=a.value,u=e._getBufferData(r,c.data);c.buffer.setData(u)}if(o.indexBuffer){var h=e._getBufferData(r,o.indexBuffer);s.setIndices(h)}for(var d,_=h4(o.blendShapes);!(d=_()).done;){var f=d.value,p=f.blendShape.frames[0],g=e._getBufferData(r,f.position);if(p.deltaPositions=ds.floatBufferToVector3Array(g),f.normal){var m=e._getBufferData(r,f.normal);p.deltaNormals=ds.floatBufferToVector3Array(m)}if(f.tangent){var v=e._getBufferData(r,f.tangent);p.deltaTangents=ds.floatBufferToVector3Array(v)}}s.uploadData(!0)}t(e.resource)}).catch(n)}).catch(n)})},aN._getBufferData=function(e,t){var n=t.main,r=e[n.bufferIndex],i=new n.TypedArray(r,n.byteOffset,n.length),a=t.sparseCount;if(a)for(var o=t.sparseIndices,s=e[o.bufferIndex],l=new o.TypedArray(s,o.byteOffset,o.length),c=t.sparseValues,u=e[c.bufferIndex],h=new c.TypedArray(u,c.byteOffset,c.length),d=t.typeSize,_=0;_<a;_++)for(var f=l[_],p=0;p<d;p++)i[f*d+p]=h[_*d+p];return i},aB),h8=function(e,t){this.url=e,this.config=t},h6=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},h7=function(){this.vertexBuffers=[],this.blendShapes=[]},h9=function(e,t){this.buffer=e,this.data=t},de=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},dt=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},dn=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r};(aV=sE||(sE={}))[aV.BYTE=5120]="BYTE",aV[aV.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",aV[aV.SHORT=5122]="SHORT",aV[aV.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",aV[aV.UNSIGNED_INT=5125]="UNSIGNED_INT",aV[aV.FLOAT=5126]="FLOAT",(aO=sM||(sM={})).SCALAR="SCALAR",aO.VEC2="VEC2",aO.VEC3="VEC3",aO.VEC4="VEC4",aO.MAT2="MAT2",aO.MAT3="MAT3",aO.MAT4="MAT4",(aU=sb||(sb={})).TRANSLATION="translation",aU.ROTATION="rotation",aU.SCALE="scale",aU.WEIGHTS="weights",(az=sF||(sF={})).Linear="LINEAR",az.Step="STEP",az.CubicSpine="CUBICSPLINE",(ak=sR||(sR={})).PERSPECTIVE="perspective",ak.ORTHOGRAPHIC="orthographic",(aG=sP||(sP={})).JPEG="image/jpeg",aG.PNG="image/png",(aH=sL||(sL={})).OPAQUE="OPAQUE",aH.MASK="MASK",aH.BLEND="BLEND",(aW=sD||(sD={}))[aW.NEAREST=9728]="NEAREST",aW[aW.LINEAR=9729]="LINEAR",(aX=sI||(sI={}))[aX.NEAREST=9728]="NEAREST",aX[aX.LINEAR=9729]="LINEAR",aX[aX.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",aX[aX.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",aX[aX.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",aX[aX.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(aK=sB||(sB={}))[aK.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",aK[aK.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",aK[aK.REPEAT=10497]="REPEAT";var dr=((aj=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new da,this.materialsPromiseInfo=new da,this.meshesPromiseInfo=new da,this.animationClipsPromiseInfo=new da,this.defaultSceneRootPromiseInfo=new da,this.masterPromiseInfo=new da,this.promiseMap={};var t=this.promiseMap;t[""+e+"?q=textures"]=this._initPromiseInfo(this.texturesPromiseInfo),t[""+e+"?q=materials"]=this._initPromiseInfo(this.materialsPromiseInfo),t[""+e+"?q=meshes"]=this._initPromiseInfo(this.meshesPromiseInfo),t[""+e+"?q=animations"]=this._initPromiseInfo(this.animationClipsPromiseInfo),t[""+e+"?q=defaultSceneRoot"]=this._initPromiseInfo(this.defaultSceneRootPromiseInfo),t[""+e]=this._initPromiseInfo(this.masterPromiseInfo)}).prototype._initPromiseInfo=function(e){var t=new cN(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},aj),di=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},da=function(){},ds=((aq=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new sq(e[r],e[r+1]);return n},aq.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sO(e[r],e[r+1],e[r+2]);return n},aq.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new sY(e[r],e[r+1],e[r+2],e[r+3]);return n},aq.floatBufferToColorArray=function(e,t){var n=e.length,r=Array(n/(t?3:4));if(t)for(var i=0;i<n;i+=3)r[i/3]=new sQ(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new sQ(e[a],e[a+1],e[a+2],e[a+3]);return r},aq.getAccessorTypeSize=function(e){switch(e){case sM.SCALAR:return 1;case sM.VEC2:return 2;case sM.VEC3:return 3;case sM.VEC4:case sM.MAT2:return 4;case sM.MAT3:return 9;case sM.MAT4:return 16}},aq.getComponentType=function(e){switch(e){case sE.BYTE:return Int8Array;case sE.UNSIGNED_BYTE:return Uint8Array;case sE.SHORT:return Int16Array;case sE.UNSIGNED_SHORT:return Uint16Array;case sE.UNSIGNED_INT:return Uint32Array;case sE.FLOAT:return Float32Array}},aq.getNormalizedComponentScale=function(e){switch(e){case sE.BYTE:return 1/127;case sE.UNSIGNED_BYTE:return 1/255;case sE.SHORT:return 1/32767;case sE.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},aq.getAccessorBuffer=function(e,t,n){var r,i=e.buffers,a=n.componentType,o=t[n.bufferView],s=o.buffer,l=i[s],c=o.byteOffset||0,u=n.byteOffset||0,h=aq.getComponentType(a),d=aq.getAccessorTypeSize(n.type),_=h.BYTES_PER_ELEMENT,f=d*_,p=n.count,g=o.byteStride;if(void 0!==g&&g!==f){var m=Math.floor(u/g),v=n.bufferView+":"+a+":"+m+":"+p,y=e.accessorBufferCache;if(!(r=y[v])){var x=c+m*g,T=p*(g/_),C=new h(l,x,T);y[v]=r=new di(C,!0,g),r.restoreInfo=new de(new dt(s,h,x,T))}}else{var S=c+u,A=p*d,w=new h(l,S,A);(r=new di(w,!1,f)).restoreInfo=new de(new dt(s,h,S,A))}return n.sparse&&aq.processingSparseData(t,n,i,r),r},aq.getAccessorData=function(e,t,n){var r=e.bufferViews,i=r[t.bufferView],a=n[i.buffer],o=t.hasOwnProperty("byteOffset")?t.byteOffset:0,s=i.hasOwnProperty("byteOffset")?i.byteOffset:0,l=o+s,c=aq.getAccessorTypeSize(t.type),u=c*t.count,h=null!=(v=i.byteStride)?v:0,d=aq.getComponentType(t.componentType);if(h){var _=c*d.BYTES_PER_ELEMENT;y=new Uint8Array(t.count*_);for(var f=new Uint8Array(a,s,i.byteLength),p=0;p<t.count;p++)for(var g=0;g<_;g++)y[p*_+g]=f[p*h+o+g]}else y=new Uint8Array(a.slice(l,l+u*d.BYTES_PER_ELEMENT));var m=new d(y.buffer);if(t.sparse)for(var v,y,x,T,C,S,A=t.sparse,w=A.count,E=A.indices,M=A.values,b=r[E.bufferView],F=r[M.bufferView],R=n[b.buffer],P=n[F.buffer],L=(null!=(x=E.byteOffset)?x:0)+(null!=(T=b.byteOffset)?T:0),D=b.byteLength,I=(null!=(C=M.byteOffset)?C:0)+(null!=(S=F.byteOffset)?S:0),B=F.byteLength,N=aq.getComponentType(E.componentType),V=new N(R,L,D/N.BYTES_PER_ELEMENT),O=new d(P,I,B/d.BYTES_PER_ELEMENT),U=0;U<w;U++)for(var z=V[U],k=0;k<c;k++)m[z*c+k]=O[U*c+k];return m},aq.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},aq.processingSparseData=function(e,t,n,r){var i,a,o,s,l=r.restoreInfo,c=aq.getAccessorTypeSize(t.type),u=aq.getComponentType(t.componentType),h=r.data.slice(),d=t.sparse,_=d.count,f=d.indices,p=d.values,g=e[f.bufferView],m=e[p.bufferView],v=g.buffer,y=m.buffer,x=n[v],T=n[y],C=(null!=(i=f.byteOffset)?i:0)+(null!=(a=g.byteOffset)?a:0),S=g.byteLength,A=(null!=(o=p.byteOffset)?o:0)+(null!=(s=m.byteOffset)?s:0),w=m.byteLength;l.typeSize=c,l.sparseCount=_;var E=aq.getComponentType(f.componentType),M=S/E.BYTES_PER_ELEMENT,b=new E(x,C,M);l.sparseIndices=new dt(v,E,C,M);var F=w/u.BYTES_PER_ELEMENT,R=new u(T,A,F);l.sparseValues=new dt(y,u,A,F);for(var P=0;P<_;P++)for(var L=b[P],D=0;D<c;D++)h[L*c+D]=R[P*c+D];r.data=h},aq.getIndexFormat=function(t){switch(t){case sE.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case sE.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case sE.UNSIGNED_INT:return e.IndexFormat.UInt32}},aq.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==sE.FLOAT)switch(n){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==sE.SHORT)switch(n){case 2:return r?e.VertexElementFormat.NormalizedShort2:e.VertexElementFormat.Short2;case 3:case 4:return r?e.VertexElementFormat.NormalizedShort4:e.VertexElementFormat.Short4}if(t==sE.UNSIGNED_SHORT)switch(n){case 2:return r?e.VertexElementFormat.NormalizedUShort2:e.VertexElementFormat.UShort2;case 3:case 4:return r?e.VertexElementFormat.NormalizedUShort4:e.VertexElementFormat.UShort4}if(t==sE.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==sE.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},aq.loadImageBuffer=function(e,t){return new Promise(function(n,r){var i=new window.Blob([e],{type:t}),a=new Image;a.onerror=function(){r(Error("Failed to load image buffer"))},a.onload=function(){requestAnimationFrame(function(){n(a),a.onload=null,a.onerror=null,a.onabort=null})},a.crossOrigin="anonymous",a.src=URL.createObjectURL(i)})},aq.parseGLB=function(e,t){var n={JSON:1313821514,BIN:5130562},r=new DataView(t),i={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(1179937895!==i.magic)return console.error("Invalid glb magic number. Expected 0x46546C67, found 0x"+i.magic.toString(16)),null;var a=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,a),l=JSON.parse(lF.decodeText(s)),c=[],u=20+a,h=e.contentRestorer.glbBufferSlices;u<i.length;){if(a=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 d=u+8,_=t.slice(d,d+a);c.push(_),h.push(new sq(d,a)),u+=a+8}return{glTF:l,buffers:c}},aq._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},aq);function dl(e){return function(e){if(Array.isArray(e))return h2(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h3(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var dc=((aQ=(aY=function(){}).prototype).initialize=function(){},aQ.createAndParse=function(e,t,n){for(var r=arguments.length,i=Array(r>3?r-3:0),a=3;a<r;a++)i[a-3]=arguments[a];throw"Not implemented."},aQ.additiveParse=function(e,t,n,r){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];throw"Not implemented."},aY);e.GLTFExtensionMode=void 0,(aJ=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[aJ.CreateAndParse=0]="CreateAndParse",aJ[aJ.AdditiveParse=1]="AdditiveParse";var du=((aZ=function(){}).executeExtensionsInitialize=function(e){var t=aZ._extensionParsers[e],n=null==t?void 0:t.length;if(n)return t[n-1].initialize()},aZ.executeExtensionsCreateAndParse=function(e,t,n){void 0===e&&(e={});for(var r=arguments.length,i=Array(r>3?r-3:0),a=3;a<r;a++)i[a-3]=arguments[a];for(var o=null,s=Object.keys(e),l=s.length-1;l>=0;--l){var c=s[l],u=e[c];if(o=aZ._createAndParse.apply(aZ,[c,t,u,n].concat(dl(i))))return o}},aZ.executeExtensionsAdditiveAndParse=function(e,t,n,r){for(var i=arguments.length,a=Array(i>4?i-4:0),o=4;o<i;o++)a[o-4]=arguments[o];for(var s in e){var l=e[s];aZ._additiveParse.apply(aZ,[s,t,n,l,r].concat(dl(a)))}},aZ.hasExtensionParser=function(e){var t;return!!(null==(t=aZ._extensionParsers[e])?void 0:t.length)},aZ.getExtensionParser=function(e,t){var n=aZ._extensionParsers[e],r=null==n?void 0:n.length;if(r)for(var i=r-1;i>=0;--i){var a=n[i];if(a._mode===t)return a}},aZ._addExtensionParser=function(e,t){aZ._extensionParsers[e]||(aZ._extensionParsers[e]=[]),aZ._extensionParsers[e].push(t)},aZ._createAndParse=function(t,n,r,i){for(var a=arguments.length,o=Array(a>4?a-4:0),s=4;s<a;s++)o[s-4]=arguments[s];var l=aZ.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,i].concat(dl(o)))},aZ._additiveParse=function(t,n,r,i,a){for(var o=arguments.length,s=Array(o>5?o-5:0),l=5;l<o;l++)s[l-5]=arguments[l];var c=aZ.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[n,r,i,a].concat(dl(s)))},aZ);function dh(e,t){return function(n){var r=new n;r._mode=t,du._addExtensionParser(e,r)}}du._extensionParsers={};var dd=(hj(a$=function(){return du.apply(this,arguments)},du),a$.prototype.parse=function(e){var t=e.glTF;e.buffers;var n=e.glTFResource;n.entities;var r=t.animations;if(t.accessors,t.bufferViews,r){for(var i=e.animationClipsPromiseInfo,a=r.length,o=[],s=0;s<a;s++){var l=r[s],c=l.name,u=void 0===c?"AnimationClip"+s:c,h=du.executeExtensionsCreateAndParse(l.extensions,e,l);h||(h=new u5(u),a$._parseStandardProperty(e,h,l)),o.push(h)}return cN.all(o).then(function(r){n.animations=r;for(var a=0;a<t.animations.length;a++){var o=t.animations[a];du.executeExtensionsAdditiveAndParse(o.extensions,e,r[a],o)}return i.resolve(r),i.promise})}},a$._parseStandardProperty=function(t,n,r){for(var i=t.glTF,a=t.glTFResource.entities,o=i.accessors,s=i.bufferViews,l=r.channels,c=r.samplers,u=[],h=0,d=c.length;h<d;h++){var _,f=c[h],p=o[f.input],g=o[f.output],m=ds.getAccessorBuffer(t,s,p).data,v=ds.getAccessorBuffer(t,s,g).data;if(g.normalized){for(var y=ds.getNormalizedComponentScale(g.componentType),x=new Float32Array(v.length),T=0,C=v.length;T<C;T++)x[T]=v[T]*y;v=x}var S=v.length/m.length,A=null!=(_=f.interpolation)?_:sF.Linear,w=void 0;switch(A){case sF.CubicSpine:w=e.InterpolationType.CubicSpine;break;case sF.Step:w=e.InterpolationType.Step;break;case sF.Linear:w=e.InterpolationType.Linear}m[m.length-1],u.push({type:g.type,interpolation:w,input:m,output:v,outputSize:S})}for(var E=0,M=l.length;E<M;E++){for(var b=l[E],F=b.target,R=a[F.node],P="",L=R;L.parent;)P=""===P?""+L.name:L.name+"/"+P,L=L.parent;var D=void 0,I=void 0;switch(F.path){case sb.TRANSLATION:D=lB,I="position";break;case sb.ROTATION:D=lB,I="rotationQuaternion";break;case sb.SCALE:D=lB,I="scale";break;case sb.WEIGHTS:D=cf,I="blendShapeWeights"}var B=this._addCurve(F.path,b,u);n.addCurveBinding(P,D,I,B)}},a$._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case sb.TRANSLATION:case sb.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,h=0,d=a.length;h<d;h++){var _=new hl;_.time=a[h],c===e.InterpolationType.CubicSpine?(_.inTangent=new sO(o[u++],o[u++],o[u++]),_.value=new sO(o[u++],o[u++],o[u++]),_.outTangent=new sO(o[u++],o[u++],o[u++])):_.value=new sO(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case sb.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=i.interpolation,g=0,m=0,v=a.length;m<v;m++){var y=new hl;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new sY(o[g++],o[g++],o[g++],o[g++]),y.value=new sX(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new sY(o[g++],o[g++],o[g++],o[g++])):y.value=new sX(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case sb.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var T=0,C=0,S=a.length;C<S;C++){var A=new hl;A.time=a[C],x.interpolation===e.InterpolationType.CubicSpine?(A.inTangent=Array.from(o.subarray(T,T+s)),T+=s,A.value=o.subarray(T,T+s),T+=s,A.outTangent=Array.from(o.subarray(T,T+s)),T+=s):(A.value=o.subarray(T,T+s),T+=s),x.addKey(A)}return x}},a$),d_=(hj(a0=function(){return du.apply(this,arguments)},du),(a1=a0.prototype).parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=t.url,i=n.bufferRequests,a={type:"arraybuffer"},o=this._isGLB(r);return(n.isGLB=o,o)?uP(r,a).then(function(t){return i.push(new h8(r,a)),ds.parseGLB(e,t)}).then(function(t){var n=t.glTF,r=t.buffers;e.glTF=n,e.buffers=r}):uP(r,{type:"json"}).then(function(t){return e.glTF=t,Promise.all(t.buffers.map(function(e){var t=lF.resolveAbsoluteUrl(r,e.uri);return i.push(new h8(t,a)),uP(t,a)})).then(function(t){e.buffers=t})})},a1._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},a0),df=(hj(a2=function(){return du.apply(this,arguments)},du),(a3=a2.prototype).parse=function(e){var t=e.glTFResource,n=e.glTF.nodes,r=t.engine;if(n){for(var i=[],a=0;a<n.length;a++){var o=n[a],s=o.matrix,l=o.translation,c=o.rotation,u=o.scale,h=new lV(r,o.name||""+a2._defaultName+a),d=h.transform;if(s){var _=d.localMatrix;_.copyFromArray(s),d.localMatrix=_}else l&&d.setPosition(l[0],l[1],l[2]),c&&d.setRotationQuaternion(c[0],c[1],c[2],c[3]),u&&d.setScale(u[0],u[1],u[2]);i[a]=h}t.entities=i,this._buildEntityTree(e,t),this._createSceneRoots(e,t)}},a3._buildEntityTree=function(e,t){for(var n=e.glTF.nodes,r=t.entities,i=0;i<n.length;i++){var a=n[i].children,o=r[i];if(a)for(var s=0;s<a.length;s++){var l=r[a[s]];o.addChild(l)}}},a3._createSceneRoots=function(e,t){var n=e.glTF,r=n.scene,i=n.scenes,a=t.engine,o=t.entities;if(i){for(var s=[],l=0;l<i.length;l++){var c=i[l].nodes;if(c){if(1===c.length)s[l]=o[c[0]];else{for(var u=new lV(a,"GLTF_ROOT"),h=0;h<c.length;h++)u.addChild(o[c[h]]);s[l]=u}}}t.sceneRoots=s,t.defaultSceneRoot=s[void 0===r?0:r]}},a2);df._defaultName="_GLTF_ENTITY_";var dp=(hj(a4=function(){return du.apply(this,arguments)},du),a4.prototype.parse=function(e){var t=e.glTF,n=e.glTFResource,r=e.materialsPromiseInfo;if(t.materials){for(var i=n.engine,a=[],o=0;o<t.materials.length;o++){var s=t.materials[o],l=du.executeExtensionsCreateAndParse(s.extensions,e,s);l||((l=new uU(i)).name=s.name,a4._parseStandardProperty(e,l,s)),a.push(l)}return cN.all(a).then(function(i){n.materials=i;for(var a=0;a<t.materials.length;a++){var o=t.materials[a];du.executeExtensionsAdditiveAndParse(o.extensions,e,i[a],o)}return r.resolve(i),r.promise})}},a4._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&ld.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},a4._parseStandardProperty=function(t,n,r){var i=t.glTFResource.textures,a=r.pbrMetallicRoughness,o=r.normalTexture,s=r.occlusionTexture,l=r.emissiveTexture,c=r.emissiveFactor,u=r.alphaMode,h=r.alphaCutoff,d=r.doubleSided;if(a){var _=a.baseColorFactor,f=a.baseColorTexture,p=a.metallicFactor,g=a.roughnessFactor,m=a.metallicRoughnessTexture;_&&(n.baseColor=new sQ(sQ.linearToGammaSpace(_[0]),sQ.linearToGammaSpace(_[1]),sQ.linearToGammaSpace(_[2]),_[3])),f&&(n.baseTexture=i[f.index],du.executeExtensionsAdditiveAndParse(f.extensions,t,n,f)),n.constructor===uU&&(n.metallic=null!=p?p:1,n.roughness=null!=g?g:1,m&&(n.roughnessMetallicTexture=i[m.index],a4._checkOtherTextureTransform(m,"Roughness metallic")))}if(n.constructor===uU||n.constructor===uz){if(l&&(n.emissiveTexture=i[l.index],a4._checkOtherTextureTransform(l,"Emissive")),c&&(n.emissiveColor=new sQ(sQ.linearToGammaSpace(c[0]),sQ.linearToGammaSpace(c[1]),sQ.linearToGammaSpace(c[2]))),o){var v=o.index,y=o.scale;n.normalTexture=i[v],a4._checkOtherTextureTransform(o,"Normal"),void 0!==y&&(n.normalTextureIntensity=y)}if(s){var x=s.index,T=s.strength,C=s.texCoord;n.occlusionTexture=i[x],a4._checkOtherTextureTransform(s,"Occlusion"),void 0!==T&&(n.occlusionTextureIntensity=T),C===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:C>e.TextureCoordinate.UV1&&ld.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,u){case sL.OPAQUE:n.isTransparent=!1;break;case sL.BLEND:n.isTransparent=!0;break;case sL.MASK:n.alphaCutoff=null!=h?h:.5}},a4);function dg(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var dm=(hj(a5=function(){return du.apply(this,arguments)},du),a5.prototype.parse=function(e){var t=e.glTF,n=e.buffers,r=e.glTFResource,i=r.engine;if(t.meshes){for(var a=e.meshesPromiseInfo,o=[],s=0;s<t.meshes.length;s++)!function(r){for(var a=function(r){var a=s.primitives[r];l[r]=new Promise(function(o){var l=du.executeExtensionsCreateAndParse(a.extensions,e,a,s);if(l)dg(l,ch)?o(l):l.then(function(e){return o(e)});else{var c=new ch(i,s.name||r+""),u=new h7;u.mesh=c,e.contentRestorer.meshes.push(u),a5._parseMeshFromGLTFPrimitive(e,c,u,s,a,t,function(e){return null},function(n,r){var i=a.targets[r][n];if(!i)return null;var o=t.accessors[i];return ds.getAccessorBuffer(e,e.glTF.bufferViews,o)},function(){var e=t.accessors[a.indices];return ds.getAccessorData(t,e,n)},e.keepMeshData).then(o)}})},s=t.meshes[r],l=[],c=0;c<s.primitives.length;c++)a(c);o[r]=Promise.all(l)}(s);return cN.all(o).then(function(e){r.meshes=e,a.resolve(e)}).catch(a.reject),a.promise}},a5._parseMeshFromGLTFPrimitive=function(t,n,r,i,a,o,s,l,c,u){var h,d,_,f,p=o.accessors;t.buffers;var g=a.attributes,m=a.targets,v=a.indices,y=a.mode,x=n.engine,T=[],C=0;for(var S in u&&(d=Array(h),_=Array(h),f=Array(h)),g){var A=p[g[S]],w=ds.getAccessorBuffer(t,o.bufferViews,A),E=ds.getAccessorTypeSize(A.type),M=A.count,b=w.data,F=void 0,R=n.instanceId,P=w.vertexBindingInfos,L=A.normalized,D=ds.getElementFormat(A.componentType,E,L),I=void 0;L&&(I=ds.getNormalizedComponentScale(A.componentType));var B=void 0;if(w.interleaved){var N=A.byteOffset||0,V=w.stride;if(B=N%V,void 0===P[R]){F=new ci(S,B,D,C);var O=w.vertexBuffer;O||((O=new ca(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static)).setData(b),w.vertexBuffer=O,r.vertexBuffers.push(new h9(O,w.restoreInfo))),n.setVertexBufferBinding(O,V,C),P[R]=C++}else F=new ci(S,B,D,P[R])}else{B=0,F=new ci(S,B,D,C);var U=new ca(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static);U.setData(b),r.vertexBuffers.push(new h9(U,w.restoreInfo)),n.setVertexBufferBinding(U,w.stride,C),P[R]=C++}if(T.push(F),"POSITION"===S){h=M;var z=n.bounds,k=z.min,G=z.max;if(A.min&&A.max){if(k.copyFromArray(A.min),G.copyFromArray(A.max),u)for(var H=B/b.BYTES_PER_ELEMENT,W=b.length/M,X=0;X<M;X++){var K=H+X*W,j=new sO(b[K],b[K+1],b[K+2]);L&&j.scale(I),d[X]=j}}else{var q=a5._tempVector3;k.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),G.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var Y=B/b.BYTES_PER_ELEMENT,Q=b.length/M,J=0;J<M;J++){var Z=Y+J*Q;if(q.copyFromArray(b,Z),sO.min(k,q,k),sO.max(G,q,G),u){var $=q.clone();L&&$.scale(I),d[J]=$}}}L&&(k.scale(I),G.scale(I))}else if("JOINTS_0"===S&&u)for(var ee=B/b.BYTES_PER_ELEMENT,et=b.length/M,en=0;en<M;en++){var er=ee+en*et,ei=new sY(b[er],b[er+1],b[er+2],b[er+3]);L&&ei.scale(I),_[en]=ei}else if("WEIGHTS_0"===S&&u)for(var ea=B/b.BYTES_PER_ELEMENT,eo=b.length/M,es=0;es<M;es++){var el=ea+es*eo,ec=new sY(b[el],b[el+1],b[el+2],b[el+3]);L&&ec.scale(I),f[es]=ec}}if(n.setVertexElements(T),void 0!==v){var eu=o.accessors[v],eh=ds.getAccessorBuffer(t,o.bufferViews,eu);n.setIndices(eh.data),n.addSubMesh(0,eu.count,y),r.indexBuffer=eh.restoreInfo}else n.addSubMesh(0,h,y);return m&&a5._createBlendShape(n,r,i,m,l),n.uploadData(!u),n._positions=d,n._boneIndices=_,n._boneWeights=f,Promise.resolve(n)},a5._createBlendShape=function(e,t,n,r,i){for(var a=n.extras?n.extras.targetNames:null,o=0,s=r.length;o<s;o++){var l=a?a[o]:"blendShape"+o,c=i("POSITION",o),u=i("NORMAL",o),h=i("TANGENT",o),d=c.data?ds.floatBufferToVector3Array(c.data):null,_=(null==u?void 0:u.data)?ds.floatBufferToVector3Array(null==u?void 0:u.data):null,f=(null==h?void 0:h.data)?ds.floatBufferToVector3Array(null==h?void 0:h.data):null,p=new cM(l);p.addFrame(1,d,_,f),e.addBlendShape(p),t.blendShapes.push(new dn(p,c.restoreInfo,null==u?void 0:u.restoreInfo,null==h?void 0:h.restoreInfo))}},a5);dm._tempVector3=new sO;var dv=(hj(a8=function(){return du.apply(this,arguments)},du),(a6=a8.prototype).parse=function(e){var t=e.glTFResource,n=e.glTF,r=t.entities,i=n.nodes,a=n.cameras;if(i){for(var o=e.defaultSceneRootPromiseInfo,s=0;s<i.length;s++){var l=i[s],c=l.camera,u=l.mesh,h=l.extensions,d=r[s];void 0!==c&&this._createCamera(t,a[c],d),void 0!==u&&this._createRenderer(e,l,d),du.executeExtensionsAdditiveAndParse(h,e,d,l)}return t.defaultSceneRoot&&this._createAnimator(e),o.resolve(t.defaultSceneRoot),o.promise}},a6._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===sR.ORTHOGRAPHIC){var l=i.xmag,c=i.ymag,u=i.zfar,h=i.znear;s.isOrthographic=!0,void 0!==h&&(s.nearClipPlane=h),void 0!==u&&(s.farClipPlane=u),s.orthographicSize=Math.max(null!=c?c:0,null!=l?l:0)/2}else if(o===sR.PERSPECTIVE){var d=a.aspectRatio,_=a.yfov,f=a.zfar,p=a.znear;void 0!==d&&(s.aspectRatio=d),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},a6._createRenderer=function(e,t,n){for(var r=e.glTFResource,i=e.glTF.meshes,a=r.engine,o=r.meshes,s=r.materials,l=r.skins,c=t.mesh,u=t.skin,h=i[c],d=h.primitives,_=t.weights||h.weights,f=0;f<d.length;f++)!function(t){var r=d[t],i=o[c][t],h=void 0;if(void 0!==u||_){e.hasSkinned=!0;var f=n.addComponent(cf);f.mesh=i,void 0!==u&&(f.skin=l[u]),_&&(f.blendShapeWeights=new Float32Array(_)),h=f}else(h=n.addComponent(c_)).mesh=i;var p=r.material,g=(null==s?void 0:s[p])||a8._getDefaultMaterial(a);h.setMaterial(g),i.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(h.enableVertexColor=!0)}),du.executeExtensionsAdditiveAndParse(r.extensions,e,h,r)}(f)},a6._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(hn),a=new hr,o=new hi("layer"),s=new hs;if(a.addLayer(o),i.animatorController=a,o.stateMachine=s,r)for(var l=0;l<r.length;l++){var c=r[l],u=c.name,h=s.makeUniqueStateName(u);h!==u&&console.warn("AnimatorState name is existed, name: "+u+" reset to "+h),s.addState(h).clip=c}}},a8._getDefaultMaterial=function(e){return a8._defaultMaterial||(a8._defaultMaterial=new uV(e)),a8._defaultMaterial},a8),dy=(hj(a7=function(){return du.apply(this,arguments)},du),(a9=a7.prototype).parse=function(e){var t=e.glTFResource,n=e.glTF;e.buffers;var r=t.entities,i=n.skins;if(i){for(var a=i.length,o=Array(a),s=0;s<a;s++){var l=i[s],c=l.inverseBindMatrices,u=l.skeleton,h=l.joints,d=l.name,_=void 0===d?"SKIN_"+s:d,f=h.length,p=new cd(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[c],m=ds.getAccessorBuffer(e,n.bufferViews,g).data,v=0;v<f;v++){var y=new sK;y.copyFromArray(m,16*v),p.inverseBindMatrices[v]=y}for(var x=0;x<f;x++){var T=h[x],C=r[T].name;p.joints[x]=C;for(var S=r.length-1;S>=0;S--)T!==S&&r[S].name===C&&(r[S].name=C+"_"+S)}if(void 0!==u)p.skeleton=r[u].name;else{var A=this._findSkeletonRootBone(h,r);if(A)p.skeleton=A.name;else throw"Failed to find skeleton root bone."}o[s]=p}t.skins=o}},a9._findSkeletonRootBone=function(e,t){for(var n,r={},i=h4(e);!(n=i()).done;){for(var a=n.value,o=[],s=t[a];s;)o.unshift(s),s=s.parent;r[a]=o}for(var l=null,c=0;;c++){var u=r[e[0]];if(c>=u.length)return l;for(var h=u[c],d=1,_=e.length;d<_;d++)if(c>=(u=r[e[d]]).length||h!==u[c])return l;l=h}},a7),dx=(hj(oe=function(){return du.apply(this,arguments)},du),(ot=oe.prototype).parse=function(t){var n=this,r=t.glTFResource,i=t.glTF,a=t.buffers,o=r.engine,s=r.url;if(i.textures){var l=t.texturesPromiseInfo;return cN.all(i.textures.map(function(r,l){var c=r.sampler,u=r.source,h=r.name,d=i.images[void 0===u?0:u],_=d.uri,f=d.bufferView,p=d.mimeType,g=d.name;if(_){var m=_.lastIndexOf("."),v=_.substring(m+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;return o.resourceManager.load({url:lF.resolveAbsoluteUrl(s,_),type:v}).then(function(e){return e.name||(e.name=h||g||"texture_"+m),void 0!==c&&n._parseSampler(e,i.samplers[c]),e})}var y=i.bufferViews[f],x=a[y.buffer],T=new Uint8Array(x,y.byteOffset,y.byteLength);return ds.loadImageBuffer(T,p).then(function(e){var r=new lp(o,e.width,e.height);r.setImageSource(e),r.generateMipmaps(),r.name=h||g||"texture_"+l,void 0!==c&&n._parseSampler(r,i.samplers[c]);var a=new h6(r,y,p);return t.contentRestorer.bufferTextures.push(a),r})})).then(function(e){r.textures=e,l.resolve(e)}).catch(l.reject),l.promise}},ot._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===sD.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=sI.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=oe._wrapMap[a]),o&&(t.wrapModeV=oe._wrapMap[o])},oe);dx._wrapMap=((on={})[sB.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,on[sB.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,on[sB.REPEAT]=e.TextureWrapMode.Repeat,on);var dT=(hj(or=function(){return du.apply(this,arguments)},du),or.prototype.parse=function(e){var t=e.glTF,n=t.asset.version,r=t.extensionsUsed,i=t.extensionsRequired,a=Number(n);if(!(a>=2&&a<3))throw"Only support glTF 2.x.";var o=[];if(r){ld.info("extensionsUsed: ",r);for(var s=0;s<r.length;s++){var l=r[s];du.hasExtensionParser(l)||ld.warn("Extension "+l+" is not implemented, you can customize this extension in gltf.")}}if(i){ld.info("extensionsRequired: "+i);for(var c=0;c<i.length;c++){var u=i[c];du.hasExtensionParser(u)?o.push(du.executeExtensionsInitialize(u)):ld.error("GLTF parser has not supported required extension "+u+".")}}return cN.all(o).then(null)},or),dC=((oi=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=this;this._parsers=[],t.forEach(function(e,t){r._parsers[t]=new e})}).prototype._parse=function(e){var t,n=this,r=e.glTFResource;return new cN(function(i,a){n._parsers.forEach(function(n){t?(t=t.then(function(){return n.parse(e)})).cancel&&e.chainPromises.push(t):t=n.parse(e)}),t&&t.then(function(){i(r)}).catch(a)})},oi);dC.defaultPipeline=new dC(d_,dT,dx,dp,dm,df,dy,dd,dv);var dS=(hj(oa=function(e,t){var n;return(n=lr.call(this,e)||this).url=t,n},lr),oa.prototype._onDestroy=function(){lr.prototype._onDestroy.call(this),this.defaultSceneRoot.destroy(),this.textures=null,this.materials=null,this.meshes=null,this.skins=null,this.animations=null,this.entities=null,this.cameras=null,this.lights=null,this.sceneRoots=null,this.extensionsData=null},oa),dA=(hj(oo=function(){return uB.apply(this,arguments)},uB),oo.prototype.load=function(e,t){var n,r=e.url,i=e.params,a=new dr(r),o=new dS(t.engine,r),s=new h5(o),l=a.masterPromiseInfo;return a.contentRestorer=s,a.glTFResource=o,a.keepMeshData=null!=(n=null==i?void 0:i.keepMeshData)&&n,l.onCancel(function(){for(var e,t=a.chainPromises,n=h4(t);!(e=n()).done;)e.value.cancel()}),((null==i?void 0:i.pipeline)||dC.defaultPipeline)._parse(a).then(function(e){t.addContentRestorer(s),l.resolve(e)}).catch(function(e){console.error(e),l.reject("Error loading glTF model from "+r+" .")}),a.promiseMap},oo);dA=hq([cO(e.AssetType.GLTF,["gltf","glb"])],dA);var dw=Math.PI,dE=(hj(os=function(){return uB.apply(this,arguments)},uB),os.prototype.load=function(t,n){var r=this;return new cN(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=dE._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,c=dE._readPixels(n.subarray(l),a,s),u=s>>1,h=dE._convertToCubemap(c,a,s,u),d=new lm(o,u),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},os._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)]},os._createCubemapData=function(e,t,n,r,i){for(var a=new Uint8ClampedArray(e*e*4),o=this._tempVector3.set(0,0,0).add(t[1]).subtract(t[0]).scale(1/e),s=this._temp2Vector3.set(0,0,0).add(t[3]).subtract(t[2]).scale(1/e),l=1/e,c=0,u=0;u<e;u++){for(var h=this._temp3Vector3.set(0,0,0).add(t[0]),d=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(d).subtract(h).scale(c).add(h);f.normalize();var p=this._calcProjectionSpherical(f,n,r,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var g=u*e*4+4*_;a[g]=p.r,a[g+1]=p.g,a[g+2]=p.b,a[g+3]=p.a,h.add(o),d.add(s)}c+=l}return a},os._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-dw;)i+=2*dw;for(;i>dw;)i-=2*dw;var o=i/dw,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/dw*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s,u=t[c],h=t[c+1],d=t[c+2],_=t[c+3];return new sQ(u,h,d,_)},os._readStringLine=function(e,t){for(var n="",r="",i=t;i<e.length-t&&"\n"!=(r=String.fromCharCode(e[i]));i++)n+=r;return n},os._parseHeader=function(e){var t=0,n=0,r=this._readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var i=!1,a=!1,o=0;do o+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this._readStringLine(e,o))?a=!0:0==r.length&&(i=!0);while(!i);if(!a)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}},os._readPixels=function(e,t,n){for(var r=e.byteLength,i=new Uint8Array(4*t*n),a=0,o=0,s=4*t,l=new Uint8Array(4),c=new Uint8Array(s),u=n;u>0&&o<r;){if(l[0]=e[o++],l[1]=e[o++],l[2]=e[o++],l[3]=e[o++],2!=l[0]||2!=l[1]||(l[2]<<8|l[3])!=t)throw"HDR Bad header format, wrong scan line width";for(var h=0,d=void 0;h<s&&o<r;){var _=(d=e[o++])>128;if(_&&(d-=128),0===d||h+d>s)throw"HDR Bad Format, bad scanline data (run)";if(_)for(var f=e[o++],p=0;p<d;p++)c[h++]=f;else c.set(e.subarray(o,o+d),h),h+=d,o+=d}for(var g=0;g<t;g++){var m=0;i[a]=c[g+m],m+=t,i[a+1]=c[g+m],m+=t,i[a+2]=c[g+m],m+=t,i[a+3]=c[g+m],a+=4}u--}return i},os._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},os._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},(sN=os)._rightBottomBack=new sO(1,-1,-1),sN._rightBottomFront=new sO(1,-1,1),sN._rightUpBack=new sO(1,1,-1),sN._rightUpFront=new sO(1,1,1),sN._leftBottomBack=new sO(-1,-1,-1),sN._leftBottomFront=new sO(-1,-1,1),sN._leftUpBack=new sO(-1,1,-1),sN._leftUpFront=new sO(-1,1,1),sN._faceRight=[sN._rightBottomBack,sN._rightBottomFront,sN._rightUpBack,sN._rightUpFront],sN._faceLeft=[sN._leftBottomFront,sN._leftBottomBack,sN._leftUpFront,sN._leftUpBack],sN._faceUp=[sN._leftBottomFront,sN._rightBottomFront,sN._leftBottomBack,sN._rightBottomBack],sN._faceBottom=[sN._leftUpBack,sN._rightUpBack,sN._leftUpFront,sN._rightUpFront],sN._faceFront=[sN._leftBottomBack,sN._rightBottomBack,sN._leftUpBack,sN._rightUpBack],sN._faceBack=[sN._rightBottomFront,sN._leftBottomFront,sN._rightUpFront,sN._leftUpFront],sN._tempVector3=new sO,sN._temp2Vector3=new sO,sN._temp3Vector3=new sO,sN._temp4Vector3=new sO,sN._temp5Vector3=new sO,sN);dE=hq([cO(e.AssetType.HDR,["hdr"])],dE);var dM=(hj(ol=function(){return uB.apply(this,arguments)},uB),ol.prototype.load=function(e){return this.request(e.url,hX({},e,{type:"json"}))},ol);dM=hq([cO(e.AssetType.JSON,["json"],!1)],dM);var db={parse:function(t,n,r,i){if(void 0===i&&(i=!1),!function(e){if(e.byteLength>=12){var t=new Uint8Array(e,0,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1}(t))throw Error("khronosTextureContainerParser: invalid KTX file, texture missing KTX identifier");var a=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(t,12,13*a),s=67305985===o.getUint32(0,!0),l={buffer:t,glType:o.getUint32(1*a,s),glTypeSize:o.getUint32(2*a,s),glFormat:o.getUint32(3*a,s),glInternalFormat:o.getUint32(4*a,s),glBaseInternalFormat:o.getUint32(5*a,s),pixelWidth:o.getUint32(6*a,s),pixelHeight:o.getUint32(7*a,s),pixelDepth:o.getUint32(8*a,s),numberOfArrayElements:o.getUint32(9*a,s),numberOfFaces:o.getUint32(10*a,s),numberOfMipmapLevels:o.getUint32(11*a,s),bytesOfKeyValueData:o.getUint32(12*a,s),loadType:0};if(0!==l.glType)throw Error("only compressed formats currently supported");if(l.numberOfMipmapLevels=Math.max(1,l.numberOfMipmapLevels),0===l.pixelHeight||0!==l.pixelDepth)throw Error("only 2D textures currently supported");if(0!==l.numberOfArrayElements)throw Error("texture arrays not currently supported");if(l.numberOfFaces!==n)throw Error("number of faces expected"+n+", but found "+l.numberOfFaces);return r&&(l.mipmaps=function(e,t){for(var n=[],r=64+e.bytesOfKeyValueData,i=e.pixelWidth,a=e.pixelHeight,o=t?e.numberOfMipmapLevels:1,s=0;s<o;s++){var l=new Int32Array(e.buffer,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:i,height:a}),r+=l+(3-(l+3)%4)}i=Math.max(1,.5*i),a=Math.max(1,.5*a)}return n}(l,!0)),i&&(l.engineFormat=function(t){switch(t){case e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT:return e.TextureFormat.DXT1;case e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT:return e.TextureFormat.DXT5;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 dF(e){var t=db.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var dR=(hj(oc=function(){return uB.apply(this,arguments)},uB),oc.prototype.load=function(t,n){var r=this;return new cN(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,hX({},t,{type:"arraybuffer"}))})).then(function(t){for(var r=function(e){for(var t,n,r,i,a=[],o=0;o<e.length;o++){var s=db.parse(e[o],1,!0,!0);a.push(s.mipmaps),0===o&&(r=s.pixelWidth,i=s.pixelHeight,t=s.glInternalFormat,n=s.engineFormat)}return{mipmapsFaces:a,engineFormat:n,internalFormat:t,width:r,height:i}}(t),a=r.width,o=r.mipmapsFaces,s=r.engineFormat,l=o[0].length>1,c=new lm(n.engine,a,s,l),u=0;u<6;u++)for(var h=o[u].length,d=0;d<h;d++){var _=o[u][d],f=_.data,p=_.width,g=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,f,d,0,0,p,g)}i(c)}).catch(function(e){a(e)})})},oc);dR=hq([cO(e.AssetType.KTXCube,[])],dR);var dP=(hj(ou=function(){return uB.apply(this,arguments)},uB),ou.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"arraybuffer"})).then(function(e){for(var n=dF(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new lp(t.engine,i,a,s,l),u=0;u<o.length;u++){var h=o[u],d=h.width,_=h.height,f=h.data;c.setPixelBuffer(f,u,0,0,d,_)}r(c)}).catch(function(e){i(e)})})},ou);dP=hq([cO(e.AssetType.KTX,["ktx"])],dP);var dL=(hj(oh=function(){return uB.apply(this,arguments)},uB),oh.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"json"})).then(function(e){var n=function(e){var n=s[e],r=n.type,i=n.value;switch(r){case"Vector2":d.setVector2(e,new sq(i.x,i.y));break;case"Vector3":d.setVector3(e,new sO(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new sY(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new sQ(i.r,i.g,i.b,i.a));break;case"Float":d.setFloat(e,i);break;case"Texture":h.push(t.getResourceByRef(i).then(function(t){d.setTexture(e,t)}))}},i=t.engine,a=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new ur(i,l$.find(o));u.name=a;var h=[],d=u.shaderData;for(var _ in s)n(_);for(var f=0,p=l.length;f<p;f++){var g=l[f],m=g.name,v=g.value;void 0==v?d.enableMacro(m):d.enableMacro(m,v)}return function e(t,n,r){if("object"==typeof r)for(var i in r)e(t[n],i,r[i]);else t[n]=r}(u,"renderState",c),Promise.all(h).then(function(){r(u)})}).catch(i)})},oh);function dD(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 dI(e,t,n){return t&&dD(e.prototype,t),n&&dD(e,n),e}dL=hq([cO(e.AssetType.Material,["json"])],dL);var dB=((o_=(od=function(e,t,n,r){void 0===t&&(t=0),void 0===r&&(r=!0),this.buffer=e,this._dataView=new DataView(e),this._littleEndian=r,this._offset=t}).prototype).nextUint8=function(){var e=this._dataView.getUint8(this._offset);return this._offset+=1,e},o_.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},o_.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},o_.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},o_.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},o_.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},o_.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},o_.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},o_.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},o_.nextUint64=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e+4294967296*t},o_.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,lF.decodeText(t)},o_.nextImageData=function(e){return this.buffer.slice(this._offset)},o_.nextImagesData=function(e){for(var t=Array(e),n=0;n<e;n++){var r=this._dataView.getUint32(this._offset,this._littleEndian);t[n]=r,this._offset+=4}for(var i=[],a=0;a<e;a++){var o=t[a],s=this.buffer.slice(this._offset,this._offset+o);this._offset+=o,i.push(s)}return i},o_.skip=function(e){return this._offset+=e,this},o_.scan=function(e,t){void 0===t&&(t=0);for(var n=this._offset,r=0;this._dataView.getUint8(this._offset)!==t&&r<e;)r++,this._offset++;return r<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)},dI(od,[{key:"offset",get:function(){return this._offset}}]),od);dB.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var dN={};function dV(e){return function(t){dN[e]=t}}var dO=((of=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),n=t.getUint32(0,!0),r=t.getUint8(4),i=t.getUint16(5,!0),a=new Uint8Array(e,7,i),o=t.getUint16(7+i,!0),s=new Uint8Array(e,9+i,o),l=lF.decodeText(s),c=lF.decodeText(a),u=new of;return u.totalLength=n,u.name=l,u.type=c,u.version=r,u.headerLength=s.byteLength+a.byteLength+9,u},dI(of,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),of);function dU(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sY(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function dz(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sO(e[3*r],e[3*r+1],e[3*r+2]);return n}function dk(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sq(e[2*r],e[2*r+1]);return n}function dG(e,t,n){return(dG=!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,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&hK(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((op=function(){}).decode=function(e,t){return new Promise(function(n){var r=new ch(e),i=JSON.parse(t.nextStr());i.bounds&&r.bounds.copyFrom(i.bounds);var a=4*Math.ceil(t.offset/4),o=new Float32Array(t.buffer,i.positions.start+a,(i.positions.end-i.positions.start)/4),s=o.length/3,l=dz(o,s);if(r.setPositions(l),i.normals){var c=dz(new Float32Array(t.buffer,i.normals.start+a,(i.normals.end-i.normals.start)/4),s);r.setNormals(c)}if(i.uvs){var u=new Float32Array(t.buffer,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);r.setUVs(dk(u,s))}if(i.uv1){var h=new Float32Array(t.buffer,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(dk(h,s),1)}if(i.uv2){var d=new Float32Array(t.buffer,i.uv2.start+a,(i.uv2.end-i.uv2.start)/4);r.setUVs(dk(d,s),2)}if(i.uv3){var _=new Float32Array(t.buffer,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(dk(_,s),3)}if(i.uv4){var f=new Float32Array(t.buffer,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(dk(f,s),4)}if(i.uv5){var p=new Float32Array(t.buffer,i.uv5.start+a,(i.uv5.end-i.uv5.start)/4);r.setUVs(dk(p,s),5)}if(i.uv6){var g=new Float32Array(t.buffer,i.uv6.start+a,(i.uv6.end-i.uv6.start)/4);r.setUVs(dk(g,s),6)}if(i.uv7){var m=new Float32Array(t.buffer,i.uv7.start+a,(i.uv7.end-i.uv7.start)/4);r.setUVs(dk(m,s),7)}if(i.colors){var v=new Float32Array(t.buffer,i.colors.start+a,(i.colors.end-i.colors.start)/4);r.setColors(function(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sQ(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(v,s))}if(i.boneWeights){var y=new Float32Array(t.buffer,i.boneWeights.start+a,(i.boneWeights.end-i.boneWeights.start)/4);r.setBoneWeights(dU(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(dU(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new cM(e.name);e.frames.forEach(function(e){var r=new Float32Array(t.buffer,e.deltaPosition.start+a,(e.deltaPosition.end-e.deltaPosition.start)/4),i=r.length/3,o=dz(r,i);e.deltaNormals&&dz(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&dU(new Float32Array(t.buffer,e.deltaTangents.start+a,(e.deltaTangents.end-e.deltaTangents.start)/4),i),n.addFrame(e.weight,o)}),r.addBlendShape(n)}),i.indices){var T=null;T=0===i.indices.type?new Uint16Array(t.buffer,i.indices.start+a,(i.indices.end-i.indices.start)/2):new Uint32Array(t.buffer,i.indices.start+a,(i.indices.end-i.indices.start)/4),r.setIndices(T)}i.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},op),e.MeshDecoder=hq([dV("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((og=function(){}).decode=function(e,t){return new Promise(function(n,r){var i=t.nextStr(),a=!!t.nextUint8(),o=t.nextUint8(),s=t.nextUint8(),l=t.nextUint8(),c=t.nextUint8(),u=t.nextUint8(),h=t.nextUint16(),d=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),g=new lp(e,h,d,u,a);if(g.filterMode=o,g.anisoLevel=s,g.wrapModeU=l,g.wrapModeV=c,_){var m=new Uint8Array(p[0]);if(g.setPixelBuffer(m),a){g.generateMipmaps();for(var v=1;v<f;v++){var y=new Uint8Array(p[v]);g.setPixelBuffer(y,v)}}e.resourceManager._objectPool[i]=g,n(g)}else{var x=new window.Blob([p[0]]),T=new Image;T.onload=function(){g.setImageSource(T);var e=0,t=function(){++e>=f&&n(g)};if(t(),a){var r=function(e){var n=new window.Blob([p[e]]),r=new Image;r.onload=function(){g.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};g.generateMipmaps();for(var i=1;i<f;i++)r(i)}},T.src=URL.createObjectURL(x)}})},og),e.Texture2DDecoder=hq([dV("Texture2D")],e.Texture2DDecoder);var dH=((om=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},om.parseEntity=function(e,t){return om.getEntityByConfig(e,t).then(function(t){t.isActive=null==(n=e.isActive)||n;var n,r=e.position,i=e.rotation,a=e.scale;return r&&t.transform.position.copyFrom(r),i&&t.transform.rotation.copyFrom(i),a&&t.transform.scale.copyFrom(a),t})},om.getEntityByConfig=function(e,t){var n=e.assetRefId;return n?t.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(t){return t.name=e.name,t}):Promise.resolve(new lV(t,e.name))},om.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=dG(uB.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},om.parseBasicType=function(e,t,n){void 0===n&&(n=t.resourceManager);var r=this;return Array.isArray(e)?Promise.all(e.map(function(e){return r.parseBasicType(e,t,n)})):"object"!=typeof e||null==e?Promise.resolve(e):this._isClass(e)?this.parseClassObject(e,t,n):this._isRef(e)?n.getResourceByRef(e):Promise.resolve(e)},om.parsePropsAndMethods=function(e,t,n,r){void 0===r&&(r=n.resourceManager);var i=this,a=[];if(t.methods)for(var o in t.methods)for(var s=t.methods[o],l=0,c=s.length;l<c;l++){var u=s[l],h=this.parseMethod(e,o,u,n,r);a.push(h)}if(t.props){var d=this,_=function(r){var i=t.props[r],o=d.parseBasicType(i,n).then(function(t){return e[r]=t});a.push(o)};for(var f in t.props)_(f)}return Promise.all(a).then(function(){var r=i.customParseComponentHandles[e.constructor.name];return r?r(e,t,n):e})},om.parseMethod=function(e,t,n,r,i){void 0===i&&(i=r.resourceManager);var a=this;return Promise.all(n.map(function(e){return a.parseBasicType(e,r,i)})).then(function(n){return e[t].apply(e,n)})},om._isClass=function(e){return void 0!=e.class},om._isRef=function(e){return void 0!=e.refId},om);dH.customParseComponentHandles=new Map;var dW=((ov=function(){}).parseChildren=function(e,t,n){var r=e.get(n).children;if(r&&r.length>0)for(var i=t.get(n),a=0;a<r.length;a++){var o=r[a],s=t.get(o);i.addChild(s),this.parseChildren(e,t,o)}},ov),dX={Transform:lB,Animator:hn,DirectLight:u_,Camera:e.Camera,MeshRenderer:c_,ParticleRenderer:hh,PointLight:uf,SpotLight:up,Script:uv,SpriteMask:cn,SpriteRenderer:uK,TextRenderer:uY};e.InterpolableValueType=void 0,(oy=e.InterpolableValueType||(e.InterpolableValueType={}))[oy.Float=0]="Float",oy[oy.FloatArray=1]="FloatArray",oy[oy.Vector2=2]="Vector2",oy[oy.Vector3=3]="Vector3",oy[oy.Vector4=4]="Vector4",oy[oy.Quaternion=5]="Quaternion",oy[oy.Color=6]="Color",oy[oy.Array=7]="Array",oy[oy.Boolean=8]="Boolean",e.AnimationClipDecoder=((ox=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new u5(r),a=n.nextUint16(),o=0;o<a;++o){var s=new u4;s.time=n.nextFloat32(),s.functionName=n.nextStr(),s.parameter=JSON.parse(n.nextStr()).val,i.addEvent(s)}for(var l=n.nextUint16(),c=0;c<l;++c){var u=n.nextStr(),h=dX[n.nextStr()],d=n.nextStr(),_=void 0,f=n.nextUint8(),p=n.nextUint16();switch(n.nextStr()){case"AnimationFloatCurve":(_=_||new e.AnimationFloatCurve).interpolation=f;for(var g=0;g<p;++g){var m=new hl;m.time=n.nextFloat32(),m.value=n.nextFloat32(),m.inTangent=n.nextFloat32(),m.outTangent=n.nextFloat32(),_.addKey(m)}break;case"AnimationArrayCurve":(_=_||new e.AnimationArrayCurve).interpolation=f;for(var v=0;v<p;++v){var y=new hl;y.time=n.nextFloat32();var x=n.nextUint16();y.value=Array.from(n.nextFloat32Array(x)),y.inTangent=Array.from(n.nextFloat32Array(x)),y.outTangent=Array.from(n.nextFloat32Array(x)),_.addKey(y)}break;case"AnimationFloatArrayCurve":(_=_||new e.AnimationFloatArrayCurve).interpolation=f;for(var T=0;T<p;++T){var C=new hl;C.time=n.nextFloat32();var S=n.nextUint16();C.value=n.nextFloat32Array(S),C.inTangent=Array.from(n.nextFloat32Array(S)),C.outTangent=Array.from(n.nextFloat32Array(S)),_.addKey(C)}break;case"AnimationVector2Curve":(_=_||new e.AnimationVector2Curve).interpolation=f;for(var A=0;A<p;++A){var w=new hl;w.time=n.nextFloat32(),w.value=new sq(n.nextFloat32(),n.nextFloat32()),w.inTangent=new sq(n.nextFloat32(),n.nextFloat32()),w.outTangent=new sq(n.nextFloat32(),n.nextFloat32()),_.addKey(w)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var E=0;E<p;++E){var M=new hl;M.time=n.nextFloat32(),M.value=new sO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sO(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var b=new hl;b.time=n.nextFloat32(),b.value=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.inTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.outTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(b);break;case"AnimationColorCurve":(_=_||new e.AnimationColorCurve).interpolation=f;for(var F=0;F<p;++F){var R=new hl;R.time=n.nextFloat32(),R.value=new sQ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),R.inTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),R.outTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(R)}break;case"AnimationQuaternionCurve":(_=_||new e.AnimationQuaternionCurve).interpolation=f;for(var P=0;P<p;++P){var L=new hl;L.time=n.nextFloat32(),L.value=new sX(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new sY(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(u,h,d,_)}t(i)})},ox),e.AnimationClipDecoder=hq([dV("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(oT=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",oT.Custom="Custom";var dK=((oC=function(e,t){this.originalData=e,this.scene=t,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[]}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},oC),dj=((oA=(oS=function(e){var t=this;this.context=e,this._engine=this.context.scene.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._clearAndResolveScene=this._clearAndResolveScene.bind(this),this.promise=new Promise(function(e,n){t._reject=n,t._resolve=e})}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject)},oA._parseEntities=function(){var e=this.context.originalData.entities,t=this.context.entityConfigMap,n=this.context.entityMap,r=this.context.rootIds,i=this._engine;return Promise.all(e.map(function(e){return t.set(e.id,e),e.parent||r.push(e.id),dH.parseEntity(e,i)})).then(function(t){for(var r=0,i=t.length;r<i;r++)n.set(e[r].id,t[r]);return t})},oA._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=h4(a);!(e=o()).done;){var s=e.value;dW.parseChildren(n,r,s)}for(var l=a.map(function(e){return r.get(e)}),c=0;c<l.length;c++)i.addRootEntity(l[c])},oA._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,n=[],r=0,i=e.length;r<i;r++)for(var a=e[r],o=t.get(a.id),s=0;s<a.components.length;s++){var l=a.components[s],c=l.refId?l.refId:l.class,u=void 0;"Animator"===c&&(u=o.getComponent(uB.getClass(c))),u=u||o.addComponent(uB.getClass(c));var h=dH.parsePropsAndMethods(u,l,o.engine);n.push(h)}return Promise.all(n)},oA._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oS.parse=function(e,t){var n=new um(e),r=new dK(t,n),i=new oS(r);return i.start(),i.promise},oS);function dq(e,t){var n=dO.decode(e),r=new dB(e,n.headerLength,n.dataLength);return dN[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(hj(ow=function(){return uB.apply(this,arguments)},uB),ow.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){dq(e,t.engine).then(function(e){r(e)})})})},ow),e.MeshLoader=hq([cO("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(hj(oE=function(){return uB.apply(this,arguments)},uB),oE.prototype.load=function(e,t){var n=this;return new cN(function(r){n.request(e.url,{type:"arraybuffer"}).then(function(e){dq(e,t.engine).then(function(e){r(e)})})})},oE),e.EditorTextureLoader=hq([cO("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var dY=(hj(oM=function(){return uB.apply(this,arguments)},uB),oM.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"arraybuffer"})).then(function(e){return dq(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oM);dY=hq([cO(e.AssetType.Mesh,["mesh"])],dY);var dQ=(hj(ob=function(){return uB.apply(this,arguments)},uB),(oF=ob.prototype).load=function(e,t){var n=this;return new cN(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new lT(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},oF._registerFont=function(e,t){return h0(function(){var n;return hY(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]}})})()},ob);dQ=hq([cO(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],dQ);var dJ=(hj(oR=function(){var e;return e=uB.apply(this,arguments)||this,e._tempRect=new sJ,e._tempVec2=new sq,e._tempVec4=new sY,e},uB),(oP=oR.prototype).load=function(t,n){var r=this;return new cN(function(i,a,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=r.request(t.url,hX({},t,{type:"json"}));l.push(c),c.then(function(o){var s=o.atlasItems,c=o.mipmap,u=o.anisoLevel,h=o.filterMode,d=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,g=n.engine,m=new uG(g);if(p<0){i(m);return}l.length=0;for(var v=0;v<s.length;v++)!function(i){var o=s[i];if(o.img)l.push(n.load({url:lF.resolveAbsoluteUrl(t.url,o.img),type:e.AssetType.Texture2D,params:{format:f,mipmap:c}}).then(function(e){u&&(e.anisoLevel=u),void 0!==h&&(e.filterMode=h),void 0!==d&&(e.wrapModeU=d),void 0!==_&&(e.wrapModeV=_);for(var t=0;t<o.sprites.length;t++)m._addSprite(r._makeSprite(g,o.sprites[t],e))}).catch(a));else for(var p=0;p<o.sprites.length;p++)m._addSprite(r._makeSprite(g,o.sprites[p]))}(v);cN.all(l).then(function(){i(m)}).catch(a)}).catch(a)})},oP._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new uH(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 c=1/n.width,u=1/n.height;if(l.atlasRegion.set(a.x*c,a.y*u,a.w*c,a.h*u),i){var h=i.x,d=i.y,_=i.z,f=i.w;l.atlasRegionOffset.set(h*c,d*u,_*c,f*u)}t.atlasRotated&&(l.atlasRotated=!0)}return l},oR);dJ=hq([cO(e.AssetType.SpriteAtlas,["atlas"],!1)],dJ);var dZ=(hj(oL=function(){return uB.apply(this,arguments)},uB),oL.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"json"})).then(function(e){e.belongToAtlas?t.getResourceByRef(e.belongToAtlas).then(function(t){r(t.getSprite(e.fullPath))}).catch(i):e.texture?t.getResourceByRef(e.texture).then(function(n){r(new uH(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new uH(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},oL);dZ=hq([cO(e.AssetType.Sprite,["sprite"],!1)],dZ);var d$=(hj(oD=function(e,t,n){var r;return(r=la.call(this,e)||this).url=t,r.requestConfig=n,r},la),oD.prototype.restoreContent=function(){var e=this;return uP(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},oD),d0=(hj(oI=function(){return uB.apply(this,arguments)},uB),oI.prototype.load=function(e,t){var n=this;return new cN(function(r,i){var a=e.url,o=hX({},e,{type:"image"});n.request(a,o).then(function(n){var i=e.params,s=new lp(t.engine,n.width,n.height,null==i?void 0:i.format,null==i?void 0:i.mipmap);if(s.setImageSource(n),s.generateMipmaps(),0!==a.indexOf("data:")){var l=a.lastIndexOf("/");s.name=a.substring(l+1)}t.addContentRestorer(new d$(s,a,o)),r(s)}).catch(function(e){i(e)})})},oI);d0=hq([cO(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],d0);var d1=(hj(oB=function(e,t,n){var r;return(r=la.call(this,e)||this).urls=t,r.requestConfig=n,r},la),oB.prototype.restoreContent=function(){var t=this;return new cN(function(n,r){Promise.all(t.urls.map(function(e){return uP(e,t.requestConfig)})).then(function(r){for(var i=t.resource,a=0;a<6;a++)i.setImageSource(e.TextureCubeFace.PositiveX+a,r[a],0);i.generateMipmaps(),n(i)}).catch(function(e){r(e)})})},oB),d2=(hj(oN=function(){return uB.apply(this,arguments)},uB),oN.prototype.load=function(t,n){var r=this;return new cN(function(i,a){var o=t.urls,s=hX({},t,{type:"image"});Promise.all(o.map(function(e){return r.request(e,s)})).then(function(t){var r=t[0],a=r.width;if(a!==r.height){console.error("The cube texture must have the same width and height");return}for(var l=new lm(n.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),n.addContentRestorer(new d1(l,o,s)),i(l)}).catch(function(e){a(e)})})},oN);d2=hq([cO(e.AssetType.TextureCube,[""])],d2);var d3=(hj(oV=function(){return uB.apply(this,arguments)},uB),oV.prototype.load=function(e,t){var n=this;return new cN(function(r,i){n.request(e.url,hX({},e,{type:"arraybuffer"})).then(function(e){return dq(e,t.engine)}).catch(i)})},oV);d3=hq([cO(e.AssetType.AnimationClip,["ani"])],d3);var d4=(hj(oO=function(){return uB.apply(this,arguments)},uB),oO.prototype.load=function(t,n){var r=this,i=n.engine;return new cN(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),dj.parse(i,t).then(function(r){var i=[],o=t.scene.ambient,s="Custom"===o.specularMode;if(s&&o.customAmbientLight){var l=n.getResourceByRef(o.customAmbientLight).then(function(e){r.ambientLight=e,r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseMode=o.diffuseMode,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor)});i.push(l)}else if(!s&&o.ambientLight){var c=n.getResourceByRef(o.ambientLight).then(function(e){r.ambientLight=e,r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseMode=o.diffuseMode,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor)});i.push(c)}var u=t.scene.background;switch(r.background.mode=u.mode,r.background.mode){case e.BackgroundMode.SolidColor:r.background.solidColor.copyFrom(u.color);break;case e.BackgroundMode.Sky:if(u.skyMesh&&u.skyMaterial){var h=n.getResourceByRef(u.skyMesh).then(function(e){r.background.sky.mesh=e}),d=n.getResourceByRef(u.skyMaterial).then(function(e){r.background.sky.material=e});i.push(h,d)}else ld.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var _=n.getResourceByRef(u.texture).then(function(e){r.background.texture=e});i.push(_)}}var f=t.scene.shadow;return f&&(void 0!=f.castShadows&&(r.castShadows=f.castShadows),void 0!=f.shadowResolution&&(r.shadowResolution=f.shadowResolution),void 0!=f.shadowDistance&&(r.shadowDistance=f.shadowDistance),void 0!=f.shadowCascades&&(r.shadowCascades=f.shadowCascades)),Promise.all(i).then(function(){a(r)})})}).catch(o)})},oO);d4=hq([cO(e.AssetType.Scene,["prefab"],!0)],d4),dH.registerCustomParseComponent("TextRenderer",h0(function(e,t,n){var r;return hY(this,function(i){return(r=t.props).font||(e.font=lT.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var d5=(hj(oU=function(){return dc.apply(this,arguments)},dc),(oz=oU.prototype).initialize=function(){d5._decoder||(d5._decoder=new hW)},oz.createAndParse=function(e,t,n,r){var i=this,a=e.glTF,o=e.buffers,s=e.glTFResource.engine,l=a.bufferViews,c=a.accessors,u=t.bufferView,h=t.attributes,d={},_={};for(var f in h)d[f]=h[f];for(var p in n.attributes)if(void 0!==h[p]){var g=c[n.attributes[p]];_[p]=ds.getComponentType(g.componentType).name}var m=c[n.indices],v=ds.getComponentType(m.componentType).name,y=ds.getBufferViewData(l[u],o);return d5._decoder.decode(y,{attributeIDs:d,attributeTypes:_,useUniqueIDs:!0,indexType:v}).then(function(t){var o=new ch(s,r.name);return i._parseMeshFromGLTFPrimitiveDraco(o,r,n,a,function(e){for(var n=0;n<t.attributes.length;n++)if(t.attributes[n].name===e)return t.attributes[n].array;return null},function(e,t){throw"BlendShape animation is not supported when using draco."},function(){return t.index.array},e.keepMeshData)})},oz._parseMeshFromGLTFPrimitiveDraco=function(e,t,n,r,i,a,o,s){var l,c=n.attributes,u=n.targets,h=n.indices,d=n.mode,_=r.accessors,f=_[c.POSITION],p=i("POSITION"),g=ds.floatBufferToVector3Array(p);e.setPositions(g);var m=e.bounds;if(l=f.count,f.min&&f.max)m.min.copyFromArray(f.min),m.max.copyFromArray(f.max);else{var v=d5._tempVector3,y=m.min,x=m.max;y.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),x.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var T=p.length/l,C=0;C<l;C++){var S=C*T;v.copyFromArray(p,S),sO.min(y,v,y),sO.max(x,v,x)}}for(var A in c)if("POSITION"!==A){var w=i(A);switch(A){case"NORMAL":var E=ds.floatBufferToVector3Array(w);e.setNormals(E);break;case"TEXCOORD_0":var M=ds.floatBufferToVector2Array(w);e.setUVs(M,0);break;case"TEXCOORD_1":var b=ds.floatBufferToVector2Array(w);e.setUVs(b,1);break;case"TEXCOORD_2":var F=ds.floatBufferToVector2Array(w);e.setUVs(F,2);break;case"TEXCOORD_3":var R=ds.floatBufferToVector2Array(w);e.setUVs(R,3);break;case"TEXCOORD_4":var P=ds.floatBufferToVector2Array(w);e.setUVs(P,4);break;case"TEXCOORD_5":var L=ds.floatBufferToVector2Array(w);e.setUVs(L,5);break;case"TEXCOORD_6":var D=ds.floatBufferToVector2Array(w);e.setUVs(D,6);break;case"TEXCOORD_7":var I=ds.floatBufferToVector2Array(w);e.setUVs(I,7);break;case"COLOR_0":var B=ds.floatBufferToColorArray(w,_[c.COLOR_0].type===sM.VEC3);e.setColors(B);break;case"TANGENT":var N=ds.floatBufferToVector4Array(w);e.setTangents(N);break;case"JOINTS_0":var V=ds.floatBufferToVector4Array(w);e.setBoneIndices(V);break;case"WEIGHTS_0":var O=ds.floatBufferToVector4Array(w);e.setBoneWeights(O)}}if(void 0!==h){var U=r.accessors[h],z=o();e.setIndices(z),e.addSubMesh(0,U.count,d)}else e.addSubMesh(0,l,d);return u&&dm._createBlendShape(e,null,t,u,a),e.uploadData(!s),Promise.resolve(e)},oU._tempVector3=new sO,oU);d5=hq([dh("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],d5);var d8=(hj(ok=function(){return dc.apply(this,arguments)},dc),ok.prototype.additiveParse=function(e,t,n){var r,i=e.glTF.extensions.KHR_lights_punctual.lights[n.light],a=i.color,o=i.intensity,s=i.type,l=i.range,c=i.spot,u=e.glTFResource;if("directional"===s?r=t.addComponent(u_):"point"===s?r=t.addComponent(uf):"spot"===s&&(r=t.addComponent(up)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!dg(r,u_)&&(r.distance=l),c&&dg(r,up)){var h=c.innerConeAngle,d=void 0===h?0:h,_=c.outerConeAngle;r.angle=d,r.penumbra=(void 0===_?Math.PI/4:_)-d}u.lights||(u.lights=[]),u.lights.push(r)},ok);d8=hq([dh("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],d8);var d6=(hj(oG=function(){return dc.apply(this,arguments)},dc),oG.prototype.additiveParse=function(e,t,n){var r=e.glTFResource.textures,i=n.clearcoatFactor,a=n.clearcoatTexture,o=n.clearcoatRoughnessFactor,s=n.clearcoatRoughnessTexture,l=n.clearcoatNormalTexture;t.clearCoat=void 0===i?0:i,t.clearCoatRoughness=void 0===o?0:o,a&&(t.clearCoatTexture=r[a.index],dp._checkOtherTextureTransform(a,"Clear coat")),s&&(t.clearCoatRoughnessTexture=r[s.index],dp._checkOtherTextureTransform(s,"Clear coat roughness")),l&&(t.clearCoatNormalTexture=r[l.index],dp._checkOtherTextureTransform(l,"Clear coat normal"))},oG);d6=hq([dh("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],d6);var d7=(hj(oH=function(){return dc.apply(this,arguments)},dc),oH.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},oH);d7=hq([dh("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],d7);var d9=(hj(oW=function(){return dc.apply(this,arguments)},dc),oW.prototype.createAndParse=function(e,t,n){var r=e.glTFResource,i=r.engine,a=r.textures,o=new uz(i),s=t.diffuseFactor,l=t.diffuseTexture,c=t.specularFactor,u=t.glossinessFactor,h=t.specularGlossinessTexture;return s&&(o.baseColor=new sQ(sQ.linearToGammaSpace(s[0]),sQ.linearToGammaSpace(s[1]),sQ.linearToGammaSpace(s[2]),s[3])),l&&(o.baseTexture=a[l.index],du.executeExtensionsAdditiveAndParse(l.extensions,e,o,l)),c&&(o.specularColor=new sQ(sQ.linearToGammaSpace(c[0]),sQ.linearToGammaSpace(c[1]),sQ.linearToGammaSpace(c[2]))),void 0!==u&&(o.glossiness=u),h&&(o.specularGlossinessTexture=a[h.index],dp._checkOtherTextureTransform(h,"Specular glossiness")),o.name=n.name,dp._parseStandardProperty(e,o,n),o},oW);d9=hq([dh("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],d9);var _e=(hj(oX=function(){return dc.apply(this,arguments)},dc),oX.prototype.createAndParse=function(e,t,n){var r=e.glTFResource.engine,i=new uk(r);return i.name=n.name,dp._parseStandardProperty(e,i,n),i},oX);_e=hq([dh("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],_e);var _t=(hj(oK=function(){return dc.apply(this,arguments)},dc),oK);_t=hq([dh("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],_t);var _n=(hj(oj=function(){return dc.apply(this,arguments)},dc),oj.prototype.additiveParse=function(e,t,n){var r=n.offset,i=n.rotation,a=n.scale,o=n.texCoord;r&&(t.tilingOffset.z=r[0],t.tilingOffset.w=r[1]),a&&(t.tilingOffset.x=a[0],t.tilingOffset.y=a[1]),i&&ld.warn("rotation in KHR_texture_transform is not supported now"),o&&ld.warn("texCoord in KHR_texture_transform is not supported now")},oj);_n=hq([dh("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],_n);var _r=(hj(oq=function(){return dc.apply(this,arguments)},dc),oq.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},oq);_r=hq([dh("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],_r);var _i=(hj(oY=function(){return dc.apply(this,arguments)},dc),oY.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new u4;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},oY);_i=hq([dh("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],_i);var _a="1.1.0-alpha.0";for(var _o in console.log("Galacean engine version: "+_a),hx)uB.registerClass(_o,hx[_o]);e.AmbientLight=uh,e.AnimationClip=u5,e.AnimationClipCurveBinding=u3,e.AnimationCurve=u8,e.AnimationEvent=u4,e.Animator=hn,e.AnimatorController=hr,e.AnimatorControllerLayer=hi,e.AnimatorState=ho,e.AnimatorStateMachine=hs,e.AnimatorStateTransition=u7,e.AssetPromise=cN,e.Background=uc,e.BaseMaterial=uN,e.Basic2DBatcher=cb,e.BasicRenderPipeline=uM,e.BlendShape=cM,e.BlendShapeFrame=cE,e.BlendState=l2,e.BlinnPhongMaterial=uV,e.BoolUpdateFlag=lD,e.BoundingBox=sz,e.BoundingFrustum=sH,e.BoundingSphere=sU,e.BoxColliderShape=c8,e.Buffer=ca,e.BufferMesh=cw,e.BufferUtil=cr,e.CapsuleColliderShape=c9,e.CharacterController=cq,e.CloneManager=ln,e.ColliderShape=c5,e.CollisionUtil=sk,e.Color=sQ,e.Component=lw,e.ComponentMap=dX,e.ContentRestorer=la,e.CubeProbe=hy,e.DepthState=l3,e.DirectLight=u_,e.DynamicCollider=cY,e.Engine=us,e.EngineObject=lr,e.Entity=lV,e.EventDispatcher=lC,e.FixedJoint=c0,e.Font=lT,e.GLTFAnimationParser=dd,e.GLTFBufferParser=d_,e.GLTFEntityParser=df,e.GLTFExtensionParser=dc,e.GLTFMaterialParser=dp,e.GLTFMeshParser=dm,e.GLTFParser=du,e.GLTFParserContext=dr,e.GLTFPipeline=dC,e.GLTFResource=dS,e.GLTFSceneParser=dv,e.GLTFSkinParser=dy,e.GLTFTextureParser=dx,e.GLTFUtils=ds,e.GLTFValidator=dT,e.HingeJoint=c1,e.HitResult=cQ,e.IndexBufferBinding=co,e.InputManager=un,e.JointLimits=c3,e.JointMotor=c4,e.Keyframe=hl,e.Light=ud,e.Loader=uB,e.Logger=ld,e.Material=ur,e.MathUtil=sV,e.Matrix=sK,e.Matrix3x3=sW,e.Mesh=cl,e.MeshRenderer=c_,e.ModelMesh=ch,e.PBRBaseMaterial=uO,e.PBRMaterial=uU,e.PBRSpecularMaterial=uz,e.ParticleRenderer=hh,e.PhysicsMaterial=cJ,e.PhysicsScene=cj,e.Plane=sG,e.PlaneColliderShape=c7,e.PointLight=uf,e.Pointer=cG,e.PrefabParser=dW,e.PrimitiveMesh=cA,e.Probe=hp,e.Quaternion=sX,e.RasterState=l4,e.Ray=sj,e.Rect=sJ,e.ReferResource=li,e.ReflectionParser=dH,e.RenderPass=uE,e.RenderQueue=ux,e.RenderState=l8,e.RenderTarget=lf,e.RenderTargetBlendState=l1,e.ResourceManager=cV,e.Scene=um,e.SceneManager=cB,e.SceneParser=dj,e.Script=uv,e.Shader=l$,e.ShaderData=l0,e.ShaderFactory=lX,e.ShaderMacro=lk,e.ShaderMacroCollection=lG,e.ShaderPass=lJ,e.ShaderProperty=lS,e.ShaderTagKey=lK,e.Skin=cd,e.SkinnedMeshRenderer=cf,e.Sky=ul,e.SkyBoxMaterial=hc,e.SkyProceduralMaterial=hu,e.SphereColliderShape=c6,e.SphericalHarmonics3=sZ,e.SpotLight=up,e.SpringJoint=c2,e.Sprite=uH,e.SpriteAtlas=uG,e.SpriteMask=cn,e.SpriteRenderer=uK,e.StateMachineScript=ha,e.StaticCollider=cZ,e.StencilState=l5,e.SubMesh=cs,e.SubShader=lZ,e.SystemInfo=cX,e.TextRenderer=uY,e.TextUtils=ly,e.Texture=l_,e.Texture2D=lp,e.Texture2DArray=lg,e.TextureCube=lm,e.Time=lA,e.TrailMaterial=hd,e.TrailRenderer=hf,e.Transform=lB,e.UnlitMaterial=uk,e.Utils=lF,e.Vector2=sq,e.Vector3=sO,e.Vector4=sY,e.VertexBufferBinding=cc,e.VertexElement=ci,e.WebCanvas=hA,e.WebGLEngine=hM,e.WebGLGraphicDevice=hU,e.assignmentClone=s9,e.decode=dq,e.deepClone=lt,e.dependentComponents=lM,e.ignoreClone=s7,e.parseSingleKTX=dF,e.registerGLTFExtension=dh,e.request=uP,e.resourceLoader=cO,e.shallowClone=le,e.version=_a,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,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 r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}e.ContainmentType=void 0,(sb=e.ContainmentType||(e.ContainmentType={}))[sb.Disjoint=0]="Disjoint",sb[sb.Contains=1]="Contains",sb[sb.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(sM=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[sM.Back=0]="Back",sM[sM.Front=1]="Front",sM[sM.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(sF=e.FrustumFace||(e.FrustumFace={}))[sF.Near=0]="Near",sF[sF.Far=1]="Far",sF[sF.Left=2]="Left",sF[sF.Right=3]="Right",sF[sF.Bottom=4]="Bottom",sF[sF.Top=5]="Top";var a,i,o,s,l,c,u,h,d,_,f,p,g,m,v,y,x,T,S,C,A,w,E,b,M,F,R,P,L,D,B,I,V,O,N,U,z,k,G,H,W,X,K,j,q,Y,Q,J,Z,$,ee,et,en,er,ea,ei,eo,es,el,ec,eu,eh,ed,e_,ef,ep,eg,em,ev,ey,ex,eT,eS,eC,eA,ew,eE,eb,eM,eF,eR,eP,eL,eD,eB,eI,eV,eO,eN,eU,ez,ek,eG,eH,eW,eX,eK,ej,eq,eY,eQ,eJ,eZ,e$,e0,e1,e2,e3,e4,e5,e8,e6,e7,e9,te,tt,tn,tr,ta,ti,to,ts,tl,tc,tu,th,td,t_,tf,tp,tg,tm,tv,ty,tx,tT,tS,tC,tA,tw,tE,tb,tM,tF,tR,tP,tL,tD,tB,tI,tV,tO,tN,tU,tz,tk,tG,tH,tW,tX,tK,tj,tq,tY,tQ,tJ,tZ,t$,t0,t1,t2,t3,t4,t5,t8,t6,t7,t9,ne,nt,nn,nr,na,ni,no,ns,nl,nc,nu,nh,nd,n_,nf,np,ng,nm,nv,ny,nx,nT,nS,nC,nA,nw,nE,nb,nM,nF,nR,nP,nL,nD,nB,nI,nV,nO,nN,nU,nz,nk,nG,nH,nW,nX,nK,nj,nq,nY,nQ,nJ,nZ,n$,n0,n1,n2,n3,n4,n5,n8,n6,n7,n9,re,rt,rn,rr,ra,ri,ro,rs,rl,rc,ru,rh,rd,r_,rf,rp,rg,rm,rv,ry,rx,rT,rS,rC,rA,rw,rE,rb,rM,rF,rR,rP,rL,rD,rB,rI,rV,rO,rN,rU,rz,rk,rG,rH,rW,rX,rK,rj,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ae,at,an,ar,aa,ai,ao,as,al,ac,au,ah,ad,a_,af,ap,ag,am,av,ay,ax,aT,aS,aC,aA,aw,aE,ab,aM,aF,aR,aP,aL,aD,aB,aI,aV,aO,aN,aU,az,ak,aG,aH,aW,aX,aK,aj,aq,aY,aQ,aJ,aZ,a$,a0,a1,a2,a3,a4,a5,a8,a6,a7,a9,ie,it,ir,ia,ii,io,is,il,ic,iu,ih,id,i_,ip,ig,im,iv,iy,ix,iT,iS,iC,iA,iw,iE,ib,iM,iF,iR,iP,iL,iD,iB,iI,iV,iO,iN,iU,iz,ik,iG,iH,iW,iX,iK,ij,iq,iY,iQ,iJ,iZ,i$,i0,i1,i2,i3,i4,i5,i8,i6,i7,i9,oe,ot,on,or,oa,oi,oo,os,ol,oc,ou,oh,od,o_,of,op,og,om,ov,oy,ox,oT,oS,oC,oA,ow,oE,ob,oM,oF,oR,oP,oL,oD,oB,oI,oV,oO,oN,oU,oz,ok,oG,oH,oW,oX,oK,oj,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st,sn,sr,sa,si,so,ss,sl,sc,su,sh,sd,s_,sf,sp,sg,sm,sv,sy,sx,sT,sS,sC,sA,sw,sE,sb,sM,sF,sR,sP,sL,sD,sB,sI,sV,sO,sN,sU,sz,sk,sG,sH,sW,sX,sK,sj,sq,sY,sQ,sJ,sZ,s$,s0,s1,s2,s3,s4,s5,s8,s6,s7,s9,le,lt,ln,lr,la,li,lo,ls,ll,lc,lu,lh,ld,l_,lf,lp,lg,lm,lv,ly,lx,lT=((sR=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},sR.equals=function(e,t){return Math.abs(e-t)<=sR.zeroTolerance},sR.isPowerOf2=function(e){return(e&e-1)==0},sR.radianToDegree=function(e){return e*sR.radToDegreeFactor},sR.degreeToRadian=function(e){return e*sR.degreeToRadFactor},sR);lT.zeroTolerance=1e-6,lT.radToDegreeFactor=180/Math.PI,lT.degreeToRadFactor=Math.PI/180;var lS=((i=(a=function(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}).prototype).set=function(e,t,n){return this._x=e,this._y=t,this._z=n,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,n=this._z;return Math.sqrt(e*e+t*t+n*n)},i.lengthSquared=function(){var e=this._x,t=this._y,n=this._z;return e*e+t*t+n*n},i.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._onValueChanged&&this._onValueChanged(),this},i.normalize=function(){return a.normalize(this,this),this},i.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._onValueChanged&&this._onValueChanged(),this},i.transformNormal=function(e){return a.transformNormal(this,e,this),this},i.transformToVec3=function(e){return a.transformToVec3(this,e,this),this},i.transformCoordinate=function(e){return a.transformCoordinate(this,e,this),this},i.transformByQuat=function(e){return a.transformByQuat(this,e,this),this},i.clone=function(){return new a(this._x,this._y,this._z)},i.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._onValueChanged&&this._onValueChanged(),this},i.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._onValueChanged&&this._onValueChanged(),this},i.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z},i.toJSON=function(){return{x:this._x,y:this._y,z:this._z}},a.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._z=e._z+t._z,n._onValueChanged&&n._onValueChanged()},a.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()},a.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()},a.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()},a.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z},a.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)},a.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)},a.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},a.equals=function(e,t){return lT.equals(e._x,t._x)&&lT.equals(e._y,t._y)&&lT.equals(e._z,t._z)},a.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()},a.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()},a.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()},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 n=e._x,r=e._y,a=e._z,i=Math.sqrt(n*n+r*r+a*a);i>lT.zeroTolerance&&(i=1/i,t.set(n*i,r*i,a*i))},a.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._z=e._z*t,n._onValueChanged&&n._onValueChanged()},a.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()},a.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()},a.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()},a.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()},a.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,h=c*a+l*r-o*i,d=c*i+o*a-s*r,_=-o*r-s*a-l*i;n._x=u*c-_*o-h*l+d*s,n._y=h*c-_*s-d*o+u*l,n._z=d*c-_*l-u*s+h*o,n._onValueChanged&&n._onValueChanged()},r(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);lS._zero=new lS(0,0,0),lS._one=new lS(1,1,1);var lC=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new lS,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 n=e.length,r=o._tempVec30;r.x=r.y=r.z=0;for(var a=0;a<n;++a)lS.add(e[a],r,r);lS.scale(r,1/n,t.center);for(var i=0,s=0;s<n;++s){var l=lS.distanceSquared(r,e[s]);l>i&&(i=l)}t.radius=Math.sqrt(i)},o.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=lS.distance(n,a)},o);lC._tempVec30=new lS;var lA=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new lS,this.max=new lS,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return lS.add(this.min,this.max,e),lS.scale(e,.5,e),e},c.getExtent=function(e){return lS.subtract(this.max,this.min,e),lS.scale(e,.5,e),e},c.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,h=8-c;u<h;++u)e[c+u]=new lS;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},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,n){lS.subtract(e,t,n.min),lS.add(e,t,n.max)},l.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];lS.min(n,o,n),lS.max(r,o,r)}},l.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},l.transform=function(e,t,n){var r=l._tempVec30,a=l._tempVec31;e.getCenter(r),e.getExtent(a),lS.transformCoordinate(r,t,r);var i=a.x,o=a.y,s=a.z,c=t.elements;a.x=Math.abs(i*c[0])+Math.abs(o*c[4])+Math.abs(s*c[8]),a.y=Math.abs(i*c[1])+Math.abs(o*c[5])+Math.abs(s*c[9]),a.z=Math.abs(i*c[2])+Math.abs(o*c[6])+Math.abs(s*c[10]),lS.subtract(r,a,n.min),lS.add(r,a,n.max)},l.merge=function(e,t,n){return lS.min(e.min,t.min,n.min),lS.max(e.max,t.max,n.max),n},l);lA._tempVec30=new lS,lA._tempVec31=new lS;var lw=((u=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var a=e.normal,i=t.normal,o=n.normal;lS.cross(i,o,u._tempVec30),lS.cross(o,a,u._tempVec31),lS.cross(a,i,u._tempVec32);var s=-lS.dot(a,u._tempVec30),l=-lS.dot(i,u._tempVec31),c=-lS.dot(o,u._tempVec32);lS.scale(u._tempVec30,e.distance/s,u._tempVec30),lS.scale(u._tempVec31,t.distance/l,u._tempVec31),lS.scale(u._tempVec32,n.distance/c,u._tempVec32),lS.add(u._tempVec30,u._tempVec31,r),lS.add(r,u._tempVec32,r)},u.distancePlaneAndPoint=function(e,t){return lS.dot(e.normal,t)+e.distance},u.intersectsPlaneAndPoint=function(t,n){var r=u.distancePlaneAndPoint(t,n);return r>0?e.PlaneIntersectionType.Front:r<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndBox=function(t,n){var r=n.min,a=n.max,i=t.normal,o=u._tempVec30,s=u._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>u.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:u.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},u.intersectsPlaneAndSphere=function(t,n){var r=n.center,a=n.radius,i=u.distancePlaneAndPoint(t,r);return i>a?e.PlaneIntersectionType.Front:i<-a?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},u.intersectsRayAndPlane=function(e,t){var n=t.normal,r=lT.zeroTolerance,a=lS.dot(n,e.direction);if(Math.abs(a)<r)return -1;var i=lS.dot(n,e.origin),o=(-t.distance-i)/a;if(o<0){if(o<-r)return -1;o=0}return o},u.intersectsRayAndBox=function(e,t){var n=lT.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,h=r.y,d=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,g=(i.x-u)*p,m=(o.x-u)*p;if(g>m){var v=g;g=m,m=v}if((_=Math.max(g,_))>(f=Math.min(m,f)))return -1}if(Math.abs(l)<n){if(h<i.y||h>o.y)return -1}else{var y=1/l,x=(i.y-h)*y,T=(o.y-h)*y;if(x>T){var S=x;x=T,T=S}if((_=Math.max(x,_))>(f=Math.min(T,f)))return -1}if(Math.abs(c)<n){if(d<i.z||d>o.z)return -1}else{var C=1/c,A=(i.z-d)*C,w=(o.z-d)*C;if(A>w){var E=A;A=w,w=E}if((_=Math.max(A,_))>(f=Math.min(w,f)))return -1}return _},u.intersectsRayAndSphere=function(e,t){var n=e.origin,r=e.direction,a=t.center,i=t.radius,o=u._tempVec30;lS.subtract(n,a,o);var s=lS.dot(o,r),l=lS.dot(o,o)-i*i;if(s>0&&l>0)return -1;var c=s*s-l;if(c<0)return -1;var h=-s-Math.sqrt(c);return h<0&&(h=0),h},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 n=e.radius+t.radius;return lS.distanceSquared(e.center,t.center)<n*n},u.intersectsSphereAndBox=function(e,t){var n=e.center,r=t.max,a=t.min,i=u._tempVec30;return i.set(Math.max(a.x,Math.min(n.x,r.x)),Math.max(a.y,Math.min(n.y,r.y)),Math.max(a.z,Math.min(n.z,r.z))),lS.distanceSquared(n,i)<=e.radius*e.radius},u.intersectsFrustumAndBox=function(e,t){for(var n=t.min,r=t.max,a=u._tempVec30,i=0;i<6;++i){var o=e.getPlane(i),s=o.normal;if(a.set(s.x>=0?r.x:n.x,s.y>=0?r.y:n.y,s.z>=0?r.z:n.z),lS.dot(s,a)<-o.distance)return!1}return!0},u.frustumContainsPoint=function(t,n){var r=u.distancePlaneAndPoint(t.near,n);return Math.abs(r)<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.far,n))<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.left,n))<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.right,n))<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.top,n))<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.bottom,n))<lT.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:e.ContainmentType.Contains},u.frustumContainsBox=function(t,n){for(var r=n.min,a=n.max,i=u._tempVec30,o=u._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var c=t.getPlane(l),h=c.normal;if(h.x>=0?(i.x=a.x,o.x=r.x):(i.x=r.x,o.x=a.x),h.y>=0?(i.y=a.y,o.y=r.y):(i.y=r.y,o.y=a.y),h.z>=0?(i.z=a.z,o.z=r.z):(i.z=r.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,n){for(var r=e.ContainmentType.Contains,a=0;a<6;++a){var i=t.getPlane(a),o=u.intersectsPlaneAndSphere(i,n);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){r=e.ContainmentType.Intersects;break}}return r},u);lw._tempVec30=new lS,lw._tempVec31=new lS,lw._tempVec32=new lS;var lE=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new lS,this.distance=0,e&&this.normal.copyFrom(e),this.distance=t}).prototype).normalize=function(){return h.normalize(this,this),this},d.clone=function(){var e=new h;return e.copyFrom(this),e},d.copyFrom=function(e){return this.normal.copyFrom(e.normal),this.distance=e.distance,this},h.normalize=function(e,t){var n=e.normal,r=1/n.length();lS.scale(n,r,t.normal),t.distance=e.distance*r},h.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,h=n.y-i,d=n.z-o,_=l*d-c*h,f=c*u-s*d,p=s*h-l*u,g=1/Math.sqrt(_*_+f*f+p*p),m=_*g,v=f*g,y=p*g,x=r.normal;x.x=m,x.y=v,x.z=y,r.distance=-(m*a+v*i+y*o)},h),lb=((f=(_=function(e){void 0===e&&(e=null),this.near=new lE,this.far=new lE,this.left=new lE,this.right=new lE,this.top=new lE,this.bottom=new lE,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,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],h=t[9],d=t[10],_=t[11],f=t[12],p=t[13],g=t[14],m=t[15];this.near.normal.set(i+a,c+l,_+d),this.near.distance=m+g,this.near.normalize(),this.far.normal.set(i-a,c-l,_-d),this.far.distance=m-g,this.far.normalize(),this.left.normal.set(i+n,c+o,_+u),this.left.distance=m+f,this.left.normalize(),this.right.normal.set(i-n,c-o,_-u),this.right.distance=m-f,this.right.normalize(),this.bottom.normal.set(i+r,c+s,_+h),this.bottom.distance=m+p,this.bottom.normalize(),this.top.normal.set(i-r,c-s,_-h),this.top.distance=m-p,this.top.normalize()},f.intersectsBox=function(e){return lw.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return lw.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},_),lM=((g=(p=function(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}).prototype).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},g.add=function(e){return p.add(this,e,this),this},g.subtract=function(e){return p.subtract(this,e,this),this},g.multiply=function(e){return p.multiply(this,e,this),this},g.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)},g.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},g.invert=function(){return p.invert(this,this),this},g.rotate=function(e){return p.rotate(this,e,this),this},g.scale=function(e){return p.scale(this,e,this),this},g.translate=function(e){return p.translate(this,e,this),this},g.transpose=function(){return p.transpose(this,this),this},g.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])},g.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},g.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},g.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]},g.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},p.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]},p.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]},p.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],h=r[5],d=r[6],_=r[7],f=r[8],p=a[0],g=a[1],m=a[2],v=a[3],y=a[4],x=a[5],T=a[6],S=a[7],C=a[8];i[0]=o*p+c*g+d*m,i[1]=s*p+u*g+_*m,i[2]=l*p+h*g+f*m,i[3]=o*v+c*y+d*x,i[4]=s*v+u*y+_*x,i[5]=l*v+h*y+f*x,i[6]=o*T+c*S+d*C,i[7]=s*T+u*S+_*C,i[8]=l*T+h*S+f*C},p.equals=function(e,t){var n=e.elements,r=t.elements;return lT.equals(n[0],r[0])&&lT.equals(n[1],r[1])&&lT.equals(n[2],r[2])&&lT.equals(n[3],r[3])&&lT.equals(n[4],r[4])&&lT.equals(n[5],r[5])&&lT.equals(n[6],r[6])&&lT.equals(n[7],r[7])&&lT.equals(n[8],r[8])},p.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},p.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,h=a*s,d=a*l,_=i*s,f=i*l,p=i*c,g=o*s,m=o*l,v=o*c;n[0]=1-d-p,n[3]=h-v,n[6]=_+m,n[1]=h+v,n[4]=1-u-p,n[7]=f-g,n[2]=_-m,n[5]=f+g,n[8]=1-u-d},p.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},p.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},p.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],h=n[7],d=n[8],_=d*l-c*h,f=-d*s+c*u,p=h*s-l*u,g=a*_+i*f+o*p;g&&(g=1/g,r[0]=_*g,r[1]=(-d*i+o*h)*g,r[2]=(c*i-o*l)*g,r[3]=f*g,r[4]=(d*a-o*u)*g,r[5]=(-c*a+o*s)*g,r[6]=p*g,r[7]=(-h*a+i*u)*g,r[8]=(l*a-i*s)*g)},p.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],h=n[7],d=n[8],_=n[9],f=n[10],p=n[11],g=n[12],m=n[13],v=n[14],y=n[15],x=a*c-i*l,T=a*u-o*l,S=a*h-s*l,C=i*u-o*c,A=i*h-s*c,w=o*h-s*u,E=d*m-_*g,b=d*v-f*g,M=d*y-p*g,F=_*v-f*m,R=_*y-p*m,P=f*y-p*v,L=x*P-T*R+S*F+C*M-A*b+w*E;if(!L)return null;L=1/L,r[0]=(c*P-u*R+h*F)*L,r[1]=(u*M-l*P-h*b)*L,r[2]=(l*R-c*M+h*E)*L,r[3]=(o*R-i*P-s*F)*L,r[4]=(a*P-o*M+s*b)*L,r[5]=(i*M-a*R-s*E)*L,r[6]=(m*w-v*A+y*C)*L,r[7]=(v*S-g*w-y*T)*L,r[8]=(g*A-m*S+y*x)*L},p.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],h=r[4],d=r[5],_=r[6],f=r[7],p=r[8];a[0]=o*s+i*u,a[1]=o*l+i*h,a[2]=o*c+i*d,a[3]=o*u-i*s,a[4]=o*h-i*l,a[5]=o*d-i*c,a[6]=_,a[7]=f,a[8]=p},p.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]},p.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],h=i[4],d=i[5],_=i[6],f=i[7],p=i[8];o[0]=s,o[1]=l,o[2]=c,o[3]=u,o[4]=h,o[5]=d,o[6]=r*s+a*u+_,o[7]=r*l+a*h+f,o[8]=r*c+a*d+p},p.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]},p),lF=((v=(m=function(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}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,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,n=this._y,r=this._z,a=t*t+n*n+r*r;if(a<lT.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,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},v.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},v.normalize=function(){return m.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 m.rotateX(this,e,this),this},v.rotateY=function(e){return m.rotateY(this,e,this),this},v.rotateZ=function(e){return m.rotateZ(this,e,this),this},v.rotationAxisAngle=function(e,t){return m.rotationAxisAngle(e,t,this),this},v.multiply=function(e){return m.multiply(this,e,this),this},v.invert=function(){return m.invert(this,this),this},v.dot=function(e){return m.dot(this,e)},v.lerp=function(e,t){return m.lerp(this,e,t,this),this},v.rotateAxisAngle=function(e,t){return m._tempQuat1.rotationAxisAngle(e,t),this.multiply(m._tempQuat1),this},v.clone=function(){return new m(this._x,this._y,this._z,this._w)},v.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},v.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},v.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},v.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},v._toYawPitchRoll=function(e){var t=this._x,n=this._y,r=this._z,a=this._w,i=t*t,o=2*(t*a-n*r);e._y=Math.abs(o)>=1?Math.sign(o)*(Math.PI/2):Math.asin(o),e._x=Math.atan2(2*(r*t+n*a),1-2*(n*n+i)),e._z=Math.atan2(2*(t*n+r*a),1-2*(r*r+i))},m.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()},m.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()},m.conjugate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=e._w,t._onValueChanged&&t._onValueChanged()},m.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},m.equals=function(e,t){return lT.equals(e._x,t._x)&&lT.equals(e._y,t._y)&&lT.equals(e._z,t._z)&&lT.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;lS.normalize(e,r);var a=Math.sin(t*=.5);n._x=r._x*a,n._y=r._y*a,n._z=r._z*a,n._w=Math.cos(t),n._onValueChanged&&n._onValueChanged()},m.rotationEuler=function(e,t,n,r){m.rotationYawPitchRoll(t,e,n,r)},m.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),h=Math.sin(o),d=Math.cos(o),_=d*u,f=h*c;r._x=d*c*l+h*u*s,r._y=h*u*l-d*c*s,r._z=_*s-f*l,r._w=_*l+f*s,r._onValueChanged&&r._onValueChanged()},m.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],h=a[6],d=a[7],_=a[8],f=i+c+_;f>0?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(u-d)*n,t._y=(h-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+h)*r,t._w=(u-d)*r):c>_?(r=.5/(n=Math.sqrt(1+c-i-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(d+u)*r,t._w=(h-s)*r):(r=.5/(n=Math.sqrt(1+_-i-c)),t._x=(s+h)*r,t._y=(u+d)*r,t._z=.5*n,t._w=(o-l)*r),t._onValueChanged&&t._onValueChanged()},m.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>lT.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()}},m.lerp=function(e,t,n,r){var a=1-n;m.dot(e,t)>=0?(r._x=e._x*a+t._x*n,r._y=e._y*a+t._y*n,r._z=e._z*a+t._z*n,r._w=e._w*a+t._w*n):(r._x=e._x*a-t._x*n,r._y=e._y*a-t._y*n,r._z=e._z*a-t._z*n,r._w=e._w*a-t._w*n),r.normalize()},m.slerp=function(e,t,n,r){var a,i,o=m.dot(e,t);if(Math.abs(o)>1-lT.zeroTolerance)i=1-n,a=n*Math.sign(o);else{var s=Math.acos(Math.abs(o)),l=1/Math.sin(s);i=Math.sin((1-n)*s)*l,a=Math.sin(n*s)*l*Math.sign(o)}r.x=i*e.x+a*t.x,r.y=i*e.y+a*t.y,r.z=i*e.z+a*t.z,r.w=i*e.w+a*t.w,r._onValueChanged&&r._onValueChanged()},m.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>lT.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},m.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()},m.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()},m.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()},m.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()},m.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()},m.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()},m.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()},r(m,[{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)<lT.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);lF._tempVector3=new lS,lF._tempQuat1=new lF;var lR=((x=(y=function(e,t,n,r,a,i,o,s,l,c,u,h,d,_,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===h&&(h=0),void 0===d&&(d=0),void 0===_&&(_=0),void 0===f&&(f=0),void 0===p&&(p=1),this.elements=new Float32Array(16);var g=this.elements;g[0]=e,g[1]=t,g[2]=n,g[3]=r,g[4]=a,g[5]=i,g[6]=o,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=_,g[14]=f,g[15]=p}).prototype).set=function(e,t,n,r,a,i,o,s,l,c,u,h,d,_,f,p){var g=this.elements;return g[0]=e,g[1]=t,g[2]=n,g[3]=r,g[4]=a,g[5]=i,g[6]=o,g[7]=s,g[8]=l,g[9]=c,g[10]=u,g[11]=h,g[12]=d,g[13]=_,g[14]=f,g[15]=p,this},x.multiply=function(e){return y.multiply(this,e,this),this},x.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],h=e[10],d=e[11],_=e[12],f=e[13],p=e[14],g=e[15];return(t*o-n*i)*(h*g-d*p)-(t*s-r*i)*(u*g-d*f)+(t*l-a*i)*(u*p-h*f)+(n*s-r*o)*(c*g-d*_)-(n*l-a*o)*(c*p-h*_)+(r*l-a*s)*(c*f-u*_)},x.decompose=function(e,t,n){var r=y._tempMat30,a=this.elements,i=r.elements,o=a[0],s=a[1],l=a[2],c=a[3],u=a[4],h=a[5],d=a[6],_=a[7],f=a[8],p=a[9],g=a[10],m=a[11];e.set(a[12],a[13],a[14]);var v=(0>Math.sign(o*s*l*c)?-1:1)*Math.sqrt(o*o+s*s+l*l),x=(0>Math.sign(u*h*d*_)?-1:1)*Math.sqrt(u*u+h*h+d*d),T=(0>Math.sign(f*p*g*m)?-1:1)*Math.sqrt(f*f+p*p+g*g);if(n.set(v,x,T),Math.abs(v)<lT.zeroTolerance||Math.abs(x)<lT.zeroTolerance||Math.abs(T)<lT.zeroTolerance)return t.identity(),!1;var S=1/v,C=1/x,A=1/T;return i[0]=o*S,i[1]=s*S,i[2]=l*S,i[3]=u*C,i[4]=h*C,i[5]=d*C,i[6]=f*A,i[7]=p*A,i[8]=g*A,lF.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>lT.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},x.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},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,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},x.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},x.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]},y.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],h=r[5],d=r[6],_=r[7],f=r[8],p=r[9],g=r[10],m=r[11],v=r[12],y=r[13],x=r[14],T=r[15],S=a[0],C=a[1],A=a[2],w=a[3],E=a[4],b=a[5],M=a[6],F=a[7],R=a[8],P=a[9],L=a[10],D=a[11],B=a[12],I=a[13],V=a[14],O=a[15];i[0]=o*S+u*C+f*A+v*w,i[1]=s*S+h*C+p*A+y*w,i[2]=l*S+d*C+g*A+x*w,i[3]=c*S+_*C+m*A+T*w,i[4]=o*E+u*b+f*M+v*F,i[5]=s*E+h*b+p*M+y*F,i[6]=l*E+d*b+g*M+x*F,i[7]=c*E+_*b+m*M+T*F,i[8]=o*R+u*P+f*L+v*D,i[9]=s*R+h*P+p*L+y*D,i[10]=l*R+d*P+g*L+x*D,i[11]=c*R+_*P+m*L+T*D,i[12]=o*B+u*I+f*V+v*O,i[13]=s*B+h*I+p*V+y*O,i[14]=l*B+d*I+g*V+x*O,i[15]=c*B+_*I+m*V+T*O},y.equals=function(e,t){var n=e.elements,r=t.elements;return lT.equals(n[0],r[0])&&lT.equals(n[1],r[1])&&lT.equals(n[2],r[2])&&lT.equals(n[3],r[3])&&lT.equals(n[4],r[4])&&lT.equals(n[5],r[5])&&lT.equals(n[6],r[6])&&lT.equals(n[7],r[7])&&lT.equals(n[8],r[8])&&lT.equals(n[9],r[9])&&lT.equals(n[10],r[10])&&lT.equals(n[11],r[11])&&lT.equals(n[12],r[12])&&lT.equals(n[13],r[13])&&lT.equals(n[14],r[14])&&lT.equals(n[15],r[15])},y.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},y.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]},y.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},y.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,h=a*s,d=a*l,_=i*s,f=i*l,p=i*c,g=o*s,m=o*l,v=o*c;n[0]=1-d-p,n[1]=h+v,n[2]=_-m,n[3]=0,n[4]=h-v,n[5]=1-u-p,n[6]=f+g,n[7]=0,n[8]=_+m,n[9]=f-g,n[10]=1-u-d,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1},y.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)<lT.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)},y.rotationTranslation=function(e,t,n){y.rotationQuaternion(e,n);var r=n.elements;r[12]=t._x,r[13]=t._y,r[14]=t._z},y.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,h=s+s,d=i*c,_=i*u,f=i*h,p=o*u,g=o*h,m=s*h,v=l*c,y=l*u,x=l*h,T=e._x,S=e._y,C=e._z;a[0]=(1-(p+m))*T,a[1]=(_+x)*T,a[2]=(f-y)*T,a[3]=0,a[4]=(_-x)*S,a[5]=(1-(d+m))*S,a[6]=(g+v)*S,a[7]=0,a[8]=(f+y)*C,a[9]=(g-v)*C,a[10]=(1-(d+p))*C,a[11]=0,a[12]=n._x,a[13]=n._y,a[14]=n._z,a[15]=1},y.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},y.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},y.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],h=n[7],d=n[8],_=n[9],f=n[10],p=n[11],g=n[12],m=n[13],v=n[14],y=n[15],x=a*c-i*l,T=a*u-o*l,S=a*h-s*l,C=i*u-o*c,A=i*h-s*c,w=o*h-s*u,E=d*m-_*g,b=d*v-f*g,M=d*y-p*g,F=_*v-f*m,R=_*y-p*m,P=f*y-p*v,L=x*P-T*R+S*F+C*M-A*b+w*E;if(!L)return null;L=1/L,r[0]=(c*P-u*R+h*F)*L,r[1]=(o*R-i*P-s*F)*L,r[2]=(m*w-v*A+y*C)*L,r[3]=(f*A-_*w-p*C)*L,r[4]=(u*M-l*P-h*b)*L,r[5]=(a*P-o*M+s*b)*L,r[6]=(v*S-g*w-y*T)*L,r[7]=(d*w-f*S+p*T)*L,r[8]=(l*R-c*M+h*E)*L,r[9]=(i*M-a*R-s*E)*L,r[10]=(g*A-m*S+y*x)*L,r[11]=(_*S-d*A-p*x)*L,r[12]=(c*b-l*F-u*E)*L,r[13]=(a*F-i*b+o*E)*L,r[14]=(m*T-g*C-v*x)*L,r[15]=(d*C-_*T+f*x)*L},y.lookAt=function(e,t,n,r){var a=r.elements,i=y._tempVec30,o=y._tempVec31,s=y._tempVec32;lS.subtract(e,t,s),s.normalize(),lS.cross(n,s,i),i.normalize(),lS.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]=-lS.dot(i,e),a[13]=-lS.dot(o,e),a[14]=-lS.dot(s,e),a[15]=1},y.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},y.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},y.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)<lT.zeroTolerance)){var h=e.elements,d=r.elements;s*=u=1/u,l*=u,c*=u,a=Math.sin(n),o=1-(i=Math.cos(n));var _=h[0],f=h[1],p=h[2],g=h[3],m=h[4],v=h[5],y=h[6],x=h[7],T=h[8],S=h[9],C=h[10],A=h[11],w=s*s*o+i,E=l*s*o+c*a,b=c*s*o-l*a,M=s*l*o-c*a,F=l*l*o+i,R=c*l*o+s*a,P=s*c*o+l*a,L=l*c*o-s*a,D=c*c*o+i;d[0]=_*w+m*E+T*b,d[1]=f*w+v*E+S*b,d[2]=p*w+y*E+C*b,d[3]=g*w+x*E+A*b,d[4]=_*M+m*F+T*R,d[5]=f*M+v*F+S*R,d[6]=p*M+y*F+C*R,d[7]=g*M+x*F+A*R,d[8]=_*P+m*L+T*D,d[9]=f*P+v*L+S*D,d[10]=p*P+y*L+C*D,d[11]=g*P+x*L+A*D,e!==r&&(d[12]=h[12],d[13]=h[13],d[14]=h[14],d[15]=h[15])}},y.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]},y.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],h=r[3],d=r[4],_=r[5],f=r[6],p=r[7],g=r[8],m=r[9],v=r[10],y=r[11];a[0]=l,a[1]=c,a[2]=u,a[3]=h,a[4]=d,a[5]=_,a[6]=f,a[7]=p,a[8]=g,a[9]=m,a[10]=v,a[11]=y,a[12]=l*i+d*o+g*s+r[12],a[13]=c*i+_*o+m*s+r[13],a[14]=u*i+f*o+v*s+r[14],a[15]=h*i+p*o+y*s+r[15]}},y.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]},y);lR._tempVec30=new lS,lR._tempVec31=new lS,lR._tempVec32=new lS,lR._tempMat30=new lM,lR._identity=new lR(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var lP=((S=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new lS,this.direction=new lS,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return lw.intersectsRayAndPlane(this,e)},S.intersectSphere=function(e){return lw.intersectsRayAndSphere(this,e)},S.intersectBox=function(e){return lw.intersectsRayAndBox(this,e)},S.getPoint=function(e,t){return lS.scale(this.direction,e,t),t.add(this.origin)},T),lL=((A=(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},A.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},A.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},A.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},A.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},A.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},A.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},A.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},A.normalize=function(){return C.normalize(this,this),this},A.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},A.clone=function(){return new C(this._x,this._y)},A.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},A.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},A.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},A.toJSON=function(){return{x:this._x,y:this._y}},C.add=function(e,t,n){n._x=e._x+t._x,n._y=e._y+t._y,n._onValueChanged&&n._onValueChanged()},C.subtract=function(e,t,n){n._x=e._x-t._x,n._y=e._y-t._y,n._onValueChanged&&n._onValueChanged()},C.multiply=function(e,t,n){n._x=e._x*t._x,n._y=e._y*t._y,n._onValueChanged&&n._onValueChanged()},C.divide=function(e,t,n){n._x=e._x/t._x,n._y=e._y/t._y,n._onValueChanged&&n._onValueChanged()},C.dot=function(e,t){return e._x*t._x+e._y*t._y},C.distance=function(e,t){var n=t._x-e._x,r=t._y-e._y;return Math.sqrt(n*n+r*r)},C.distanceSquared=function(e,t){var n=t._x-e._x,r=t._y-e._y;return n*n+r*r},C.equals=function(e,t){return lT.equals(e._x,t._x)&&lT.equals(e._y,t._y)},C.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()},C.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()},C.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()},C.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._onValueChanged&&t._onValueChanged()},C.normalize=function(e,t){var n=e._x,r=e._y,a=Math.sqrt(n*n+r*r);a>lT.zeroTolerance&&(a=1/a,t._x=n*a,t._y=r*a,t._onValueChanged&&t._onValueChanged())},C.scale=function(e,t,n){n._x=e._x*t,n._y=e._y*t,n._onValueChanged&&n._onValueChanged()},r(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);lL._zero=new lL(0,0),lL._one=new lL(1,1);var lD=((E=(w=function(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}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onValueChanged&&this._onValueChanged(),this},E.add=function(e){return this._x+=e._x,this._y+=e._y,this._z+=e._z,this._w+=e._w,this._onValueChanged&&this._onValueChanged(),this},E.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._z-=e._z,this._w-=e._w,this._onValueChanged&&this._onValueChanged(),this},E.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._z*=e._z,this._w*=e._w,this._onValueChanged&&this._onValueChanged(),this},E.divide=function(e){return this._x/=e._x,this._y/=e._y,this._z/=e._z,this._w/=e._w,this._onValueChanged&&this._onValueChanged(),this},E.length=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return Math.sqrt(e*e+t*t+n*n+r*r)},E.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},E.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},E.normalize=function(){return w.normalize(this,this),this},E.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new w(this._x,this._y,this._z,this._w)},E.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},E.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},E.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},E.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},w.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()},w.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()},w.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()},w.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()},w.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},w.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)},w.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},w.equals=function(e,t){return lT.equals(e._x,t._x)&&lT.equals(e._y,t._y)&&lT.equals(e._z,t._z)&&lT.equals(e._w,t._w)},w.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()},w.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()},w.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()},w.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},w.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>lT.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=a*o,t._w=i*o,t._onValueChanged&&t._onValueChanged())},w.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()},w.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()},w.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,h=u*r+l*i-c*a,d=u*a+c*r-s*i,_=u*i+s*a-l*r,f=-s*r-l*a-c*i;n._x=h*u-f*s-d*c+_*l,n._y=d*u-f*l-_*s+h*c,n._z=_*u-f*c-h*l+d*s,n._w=o,n._onValueChanged&&n._onValueChanged()},r(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:"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()}}]),w);lD._zero=new lD(0,0,0,0),lD._one=new lD(1,1,1,1);var lB=((M=(b=function(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}).prototype).set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},M.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},M.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},M.clone=function(){return new b(this._r,this._g,this._b,this._a)},M.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},M.toLinear=function(e){return e._r=b.gammaToLinearSpace(this._r),e._g=b.gammaToLinearSpace(this._g),e._b=b.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},M.toGamma=function(e){return e._r=b.linearToGammaSpace(this._r),e._g=b.linearToGammaSpace(this._g),e._b=b.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},M.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},M.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},b.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)},b.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)},b.equals=function(e,t){return lT.equals(e._r,t._r)&&lT.equals(e._g,t._g)&&lT.equals(e._b,t._b)&&lT.equals(e._a,t._a)},b.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},b.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()},b.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},b.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},r(b,[{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()}}]),b),lI=((R=(F=function(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}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._width=n,this._height=r,this._onValueChanged&&this._onValueChanged(),this},R.clone=function(){return new F(this.x,this.y,this.width,this.height)},R.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},r(F,[{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()}}]),F),lV=((L=(P=function(){this.coefficients=new Float32Array(27)}).prototype).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,h=.488603*o,d=-.488603*a,_=1.092548*(a*i),f=-1.092548*(i*o),p=.315392*(3*o*o-1),g=-1.092548*(a*o),m=.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*h,r[7]+=l*h,r[8]+=c*h,r[9]+=s*d,r[10]+=l*d,r[11]+=c*d,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*g,r[22]+=l*g,r[23]+=c*g,r[24]+=s*m,r[25]+=l*m,r[26]+=c*m},L.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,h=.247708*(3*i*i-1),d=-.858086*i*r,_=.429042*(r*r-a*a),f=.886227*n[0],p=.886227*n[1],g=.886227*n[2];return f+=n[3]*o+n[6]*s+n[9]*l,p+=n[4]*o+n[7]*s+n[10]*l,g+=n[5]*o+n[8]*s+n[11]*l,f+=n[12]*c+n[15]*u+n[18]*h+n[21]*d+n[24]*_,p+=n[13]*c+n[16]*u+n[19]*h+n[22]*d+n[25]*_,g+=n[14]*c+n[17]*u+n[20]*h+n[23]*d+n[26]*_,t.set(f,p,g,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 P;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 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]},L.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]},P);function lO(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function lN(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 lU(e,t,n){return t&&lN(e.prototype,t),n&&lN(e,n),e}function lz(e,t){return(lz=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function lk(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&&lz(e,t)}e.Platform=void 0,(D=e.Platform||(e.Platform={}))[D.Android=0]="Android",D[D.IPhone=1]="IPhone",D[D.IPad=2]="IPad",D[D.Mac=3]="Mac",D[D.Unknown=4]="Unknown";var lG=((B=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},B.equals=function(e,t){return Math.abs(e-t)<=B.zeroTolerance},B.isPowerOf2=function(e){return(e&e-1)==0},B.radianToDegree=function(e){return e*B.radToDegreeFactor},B.degreeToRadian=function(e){return e*B.degreeToRadFactor},B);lG.zeroTolerance=1e-6,lG.radToDegreeFactor=180/Math.PI,lG.degreeToRadFactor=Math.PI/180;var lH=((V=(I=function(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}).prototype).set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},V.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},V.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},V.clone=function(){return new I(this._r,this._g,this._b,this._a)},V.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},V.toLinear=function(e){return e._r=I.gammaToLinearSpace(this._r),e._g=I.gammaToLinearSpace(this._g),e._b=I.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},V.toGamma=function(e){return e._r=I.linearToGammaSpace(this._r),e._g=I.linearToGammaSpace(this._g),e._b=I.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},V.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},V.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},I.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)},I.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)},I.equals=function(e,t){return lG.equals(e._r,t._r)&&lG.equals(e._g,t._g)&&lG.equals(e._b,t._b)&&lG.equals(e._a,t._a)},I.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},I.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()},I.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},I.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},lU(I,[{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()}}]),I);function lW(e,t,n,r){var a,i=arguments.length,o=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,n,o):a(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}function lX(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function lK(e,t){lQ.registerCloneMode(e,t,sP.Ignore)}function lj(e,t){lQ.registerCloneMode(e,t,sP.Assignment)}function lq(e,t){lQ.registerCloneMode(e,t,sP.Shallow)}function lY(e,t){lQ.registerCloneMode(e,t,sP.Deep)}(O=sP||(sP={}))[O.Ignore=0]="Ignore",O[O.Assignment=1]="Assignment",O[O.Shallow=2]="Shallow",O[O.Deep=3]="Deep";var lQ=((N=function(){}).registerCloneMode=function(e,t,n){var r=N._subCloneModeMap.get(e.constructor);r||(r=Object.create(null),N._subCloneModeMap.set(e.constructor,r)),r[t]=n},N.getCloneMode=function(e){var t=N._cloneModeMap.get(e);if(!t){t=Object.create(null),N._cloneModeMap.set(e,t);for(var n=N._objectType,r=N._subCloneModeMap;e!==n;){var a=r.get(e);a&&Object.assign(t,a),e=Object.getPrototypeOf(e)}}return t},N.deepCloneObject=function(e,t){switch(e.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:t.set(e);break;case Array:for(var n=0,r=e.length;n<r;n++)N._deepCloneObjectItem(e,t,n);break;default:if(e.clone&&e.cloneTo)e.cloneTo(t);else for(var a=Object.keys(e),i=0,o=a.length;i<o;i++)N._deepCloneObjectItem(e,t,a[i])}},N._deepCloneObjectItem=function(e,t,n){var r=e[n];if(lX(r,Object))switch(r.constructor){case Uint8Array:case Uint16Array:case Uint32Array:case Int8Array:case Int16Array:case Int32Array:case Float32Array:case Float64Array:var a=t[n];null==a?t[n]=r.slice():a.set(r);break;case Array:var i=t[n];null==i?t[n]=Array(r.length):i.length=r.length,N.deepCloneObject(r,i);break;default:if(r.clone&&r.cloneTo){var o=t[n];o?r.cloneTo(o):t[n]=r.clone()}else{var s=t[n];null==s&&(t[n]=s=new r.constructor),N.deepCloneObject(r,s)}}else t[n]=r},N);lQ._subCloneModeMap=new Map,lQ._cloneModeMap=new Map,lQ._objectType=Object.getPrototypeOf(Object);var lJ=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)},lU(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();lJ._instanceIdCounter=0,lW([lK],lJ.prototype,"instanceId",void 0),lW([lK],lJ.prototype,"_engine",void 0);var lZ=(lk(U=function(e){var t;return(t=lJ.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(lO(t)),t},lJ),(z=U.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(lJ.prototype.destroy.call(this),!0)},z._getReferCount=function(){return this._refCount},z._addReferCount=function(e){this._refCount+=e},z._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},z._onDestroy=function(){lJ.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},lU(U,[{key:"refCount",get:function(){return this._refCount}}]),U),l$=function(e){this.resource=e};e.RenderBufferDepthFormat=void 0,(k=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[k.Depth=0]="Depth",k[k.DepthStencil=1]="DepthStencil",k[k.Stencil=2]="Stencil",k[k.Depth16=3]="Depth16",k[k.Depth24=4]="Depth24",k[k.Depth32=5]="Depth32",k[k.Depth24Stencil8=6]="Depth24Stencil8",k[k.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(G=e.TextureCubeFace||(e.TextureCubeFace={}))[G.PositiveX=0]="PositiveX",G[G.NegativeX=1]="NegativeX",G[G.PositiveY=2]="PositiveY",G[G.NegativeY=3]="NegativeY",G[G.PositiveZ=4]="PositiveZ",G[G.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(H=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[H.Never=0]="Never",H[H.Less=1]="Less",H[H.Equal=2]="Equal",H[H.LessEqual=3]="LessEqual",H[H.Greater=4]="Greater",H[H.NotEqual=5]="NotEqual",H[H.GreaterEqual=6]="GreaterEqual",H[H.Always=7]="Always",e.TextureFilterMode=void 0,(W=e.TextureFilterMode||(e.TextureFilterMode={}))[W.Point=0]="Point",W[W.Bilinear=1]="Bilinear",W[W.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(X=e.TextureFormat||(e.TextureFormat={}))[X.R8G8B8=0]="R8G8B8",X[X.R8G8B8A8=1]="R8G8B8A8",X[X.R4G4B4A4=2]="R4G4B4A4",X[X.R5G5B5A1=3]="R5G5B5A1",X[X.R5G6B5=4]="R5G6B5",X[X.Alpha8=5]="Alpha8",X[X.LuminanceAlpha=6]="LuminanceAlpha",X[X.R16G16B16A16=7]="R16G16B16A16",X[X.R32G32B32A32=8]="R32G32B32A32",X[X.BC1=9]="BC1",X[X.BC3=10]="BC3",X[X.BC7=11]="BC7",X[X.ETC1_RGB=12]="ETC1_RGB",X[X.ETC2_RGB=13]="ETC2_RGB",X[X.ETC2_RGBA5=14]="ETC2_RGBA5",X[X.ETC2_RGBA8=15]="ETC2_RGBA8",X[X.PVRTC_RGB2=16]="PVRTC_RGB2",X[X.PVRTC_RGBA2=17]="PVRTC_RGBA2",X[X.PVRTC_RGB4=18]="PVRTC_RGB4",X[X.PVRTC_RGBA4=19]="PVRTC_RGBA4",X[X.ASTC_4x4=20]="ASTC_4x4",X[X.ASTC_5x5=21]="ASTC_5x5",X[X.ASTC_6x6=22]="ASTC_6x6",X[X.ASTC_8x8=23]="ASTC_8x8",X[X.ASTC_10x10=24]="ASTC_10x10",X[X.ASTC_12x12=25]="ASTC_12x12",X[X.Depth=26]="Depth",X[X.DepthStencil=27]="DepthStencil",X[X.Depth16=28]="Depth16",X[X.Depth24=29]="Depth24",X[X.Depth32=30]="Depth32",X[X.Depth24Stencil8=31]="Depth24Stencil8",X[X.Depth32Stencil8=32]="Depth32Stencil8",X[X.DXT1=33]="DXT1",X[X.DXT5=34]="DXT5",e.TextureUsage=void 0,(K=e.TextureUsage||(e.TextureUsage={}))[K.Static=0]="Static",K[K.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(j=e.TextureWrapMode||(e.TextureWrapMode={}))[j.Clamp=0]="Clamp",j[j.Repeat=1]="Repeat",j[j.Mirror=2]="Mirror";var l0=(lk(q=function(e){var t;return t=lZ.call(this,e)||this,e.resourceManager._addGraphicResource(lO(t)),t},lZ),q.prototype._onDestroy=function(){lZ.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},q),l1=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},l2=console.log.bind(console),l3=console.info.bind(console),l4=console.warn.bind(console),l5=console.error.bind(console),l8={debug:l1,info:l1,warn:l1,error:l1,isEnabled:!1,enable:function(){this.debug=l2,this.info=l3,this.warn=l4,this.error=l5,this.isEnabled=!0},disable:function(){this.debug=l1,this.info=l1,this.warn=l1,this.error=l1,this.isEnabled=!1}},l6=(lk(Y=function(){var e;return e=l0.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},l0),(Q=Y.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},Q._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},Q._rebuild=function(){var e=this._platformTexture;e.wrapModeU=this._wrapModeU,e.wrapModeV=this._wrapModeV,e.filterMode=this._filterMode,e.anisoLevel=this._anisoLevel,e.depthCompareFunction=this._depthCompareFunction,e.setUseDepthCompareMode(this._useDepthCompareMode)},Q._onDestroy=function(){l0.prototype._onDestroy.call(this),this._platformTexture.destroy(),this._platformTexture=null},Q._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},Q._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},lU(Y,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"usage",get:function(){return this._usage}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){e!==this._filterMode&&(this._filterMode=e,this._platformTexture.filterMode=e)}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(l8.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(l8.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)}}]),Y),l7=(lk(J=function(t,n,r,a,i,o){if(void 0===i&&(i=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=l0.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=i,a){for(var s,l=lX(a,Array)?a.slice():[a],c=0,u=l.length;c<u;c++){var h=l[c];if(h._isDepthTexture)throw"Render texture can't use depth format.";h._addReferCount(1)}s._colorTextures=l}else s._colorTextures=[];if(lX(i,l6)){if(!i._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=i,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(lO(s)),s},l0),(Z=J.prototype).getColorTexture=function(e){var t;return void 0===e&&(e=0),null!=(t=this._colorTextures[e])?t:null},Z.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()}},Z._onDestroy=function(){l0.prototype._onDestroy.call(this),this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,n=0,r=t.length;n<r;n++)t[n]._addReferCount(-1);t.length=0,null==(e=this._depthTexture)||e._addReferCount(-1),this._depthTexture=null,this._depth=null},Z._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t)},Z._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},Z._rebuild=function(){this._platformRenderTarget=this._engine._hardwareRenderer.createPlatformRenderTarget(this)},lU(J,[{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}}]),J),l9=(lk($=function(t,n,r,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=l6.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==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(lO(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},l6),(ee=$.prototype).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)},ee.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)},ee.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)},ee._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),l6.prototype._rebuild.call(this)},$),ce=(lk(et=function(t,n,r,a,i,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=l6.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(lO(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},l6),(en=et.prototype).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)},en.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)},en.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)},en._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),l6.prototype._rebuild.call(this)},lU(et,[{key:"length",get:function(){return this._length}}]),et),ct=(lk(er=function(t,n,r,a){var i;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(i=l6.call(this,t)||this)._mipmap=a,i._width=n,i._height=n,i._format=r,i._mipmapCount=i._getMipmapCount(),i._platformTexture=t._hardwareRenderer.createPlatformTextureCube(lO(i)),i.filterMode=e.TextureFilterMode.Bilinear,i.wrapModeU=i.wrapModeV=e.TextureWrapMode.Clamp,i},l6),(ea=er.prototype).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)},ea.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)},ea.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)},ea._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),l6.prototype._rebuild.call(this)},er),cn=(lk(ei=function(e){var t;return(t=lZ.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},lZ),(eo=ei.prototype).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 lL(this._curX,this._curY),i.setPixelBuffer(r,0,this._curX,this._curY,t,n),i.generateMipmaps());var u=1/o,h=this._curX,d=this._curY,_=h*u,f=(h+t)*u,p=d*u,g=(d+n)*u;e.x=h,e.y=d;var m=e.uvs;return m[0].set(_,p),m[1].set(f,p),m[2].set(f,g),m[3].set(_,g),this._curX+=s+a,!0},eo.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},eo.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},eo._onDestroy=function(){lZ.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},ei);e.FontStyle=void 0,(es=e.FontStyle||(e.FontStyle={}))[es.None=0]="None",es[es.Bold=1]="Bold",es[es.Italic=2]="Italic",e.OverflowMode=void 0,(el=e.OverflowMode||(e.OverflowMode={}))[el.Overflow=0]="Overflow",el[el.Truncate=1]="Truncate";var cr=((ec=function(){}).textContext=function(){var e=ec._textContext;if(!e){try{t=new OffscreenCanvas(0,0)}catch(e){t=document.createElement("canvas")}var t,n=t.getContext("2d",{willReadFrequently:!0});e={canvas:t,context:n},ec._textContext=e}return e},ec.measureFont=function(e){var t=ec._fontSizeInfoCache,n=t[e];return n||(n=ec._measureFontOrChar(e),t[e]=n),n},ec.getNativeFontString=function(t,n,r){var a=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(a+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),a+=n+"px "+t},ec.measureChar=function(e,t){return ec._measureFontOrChar(t,e)},ec.measureTextWithWrap=function(t){var n=t._subFont,r=n.nativeFontString,a=ec.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=u4._pixelsPerUnit,u=a.size+t.lineSpacing*c,h=t.width*c,d=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 g="",m=0,v=0,y=0,x="",T=0,S=0,C=0,A=!1,w=0,E=p.length;w<E;++w){var b=p[w],M=ec._getCharInfo(b,r,n),F=b.charCodeAt(0),R=32===F;if(!R||!A||0!==x.length||0!==g.length){var P=R||F>=19968&&F<=40959,L=M.w,D=M.offsetY,B=.5*M.h,I=B+D,V=B-D;P?(g.length>0&&(T+m>h?(T>0&&this._pushLine(o,s,l,x,T,S,C),d=Math.max(d,T),A=!0,x=g,T=m,S=v,C=y):(x+=g,T+=m,S=Math.max(S,v),C=Math.max(C,y)),g="",m=v=y=0),T+L>h&&T>0?(this._pushLine(o,s,l,x,T,S,C),d=Math.max(d,T),A=!0,R?(x="",T=S=C=0):(x=b,T=M.xAdvance,S=I,C=V)):(x+=b,T+=M.xAdvance,S=Math.max(S,I),C=Math.max(C,V))):m+M.w>h?(T>0&&(this._pushLine(o,s,l,x,T,S,C),d=Math.max(d,T),x="",T=S=C=0),m>0&&this._pushLine(o,s,l,g,m,v,y),d=Math.max(d,m),A=!0,g=b,m=M.xAdvance,v=I,y=V):(g+=b,m+=M.xAdvance,v=S=Math.max(v,I),y=C=Math.max(y,V))}}m>0&&(T+m>h?(T>0&&this._pushLine(o,s,l,x,T,S,C),d=Math.max(d,T),T=0,m>0&&this._pushLine(o,s,l,g,m,v,y),d=Math.max(d,m)):(x+=g,T+=m,S=Math.max(S,v),C=Math.max(C,y))),T>0&&(this._pushLine(o,s,l,x,T,S,C),d=Math.max(d,T))}var O=t.height*c;return t.overflowMode===e.OverflowMode.Overflow&&(O=u*o.length),{width:d,height:O,lines:o,lineWidths:s,lineHeight:u,lineMaxSizes:l}},ec.measureTextWithoutWrap=function(t){var n=t._subFont,r=n.nativeFontString,a=ec.measureFont(r),i=t.text.split(/(?:\r\n|\r|\n)/),o=i.length,s=[],l=[],c=[],u=u4._pixelsPerUnit,h=a.size+t.lineSpacing*u,d=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=i[_],p=0,g=0,m=0,v=0,y=f.length;v<y;++v){var x=ec._getCharInfo(f[v],r,n);p+=x.xAdvance;var T=x.offsetY,S=.5*x.h,C=S+T,A=S-T;g<C&&(g=C),m<A&&(m=A)}p>0&&(this._pushLine(s,l,c,f,p,g,m),d=Math.max(d,p))}var w=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(w=h*s.length),{width:d,height:w,lines:s,lineWidths:l,lineHeight:h,lineMaxSizes:c}},ec.getNativeFontHash=function(t,n,r){var a=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(a+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t=""+t),a+=n+"px"+t},ec._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=ec.textContext(),a=r.canvas,i=r.context;i.font=e;var o=t||ec._measureString,s=Math.max(1,Math.round(i.measureText(o).width)),l=Math.ceil(i.measureText(ec._measureBaseline).width),c=l*ec._heightMultiplier;l=ec._baselineMultiplier*l|0,a.width=s,a.height=c,i.font=e,i.fillStyle="#000",i.clearRect(0,0,s,c),i.textBaseline="middle",i.fillStyle="#fff",i.fillText(o,0,l);for(var u=i.getImageData(0,0,s,c).data,h=u.length,d=-1,_=-1,f=0,p=0,g=0,m=a.width,v=1/m,y=0;y<h;y+=4)0!==u[y+3]?(n=~~(.25*y*v),-1===d&&(d=n),n>_&&(_=n)):u[y]=u[y+1]=u[y+2]=255;-1!==d&&-1!==_&&(g=(f=l-d)+(p=_-l+1));var x={ascent:f,descent:p,size:g};if(!t)return x;var T=null;if(g>0){var S=4*m;T=new Uint8Array(u.buffer,d*S,g*S)}return{char:t,x:0,y:0,w:s,h:g,offsetX:0,offsetY:(f-p)*.5,xAdvance:s,uvs:[new lL,new lL,new lL,new lL],ascent:f,descent:p,index:0,data:T}},ec._getCharInfo=function(e,t,n){var r=n._getCharInfo(e);return r||(r=ec.measureChar(e,t),n._uploadCharTexture(r),n._addCharInfo(e,r)),r},ec._pushLine=function(e,t,n,r,a,i,o){e.push(r),t.push(a),n.push({ascent:i,descent:o,size:i+o})},ec);cr._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],cr._measureString="|\xc9q\xc5",cr._measureBaseline="M",cr._heightMultiplier=2,cr._baselineMultiplier=1.4,cr._fontSizeInfoCache={},cr._textContext=null;var ca=((eh=(eu=function(e){this._fontAtlases=[],this._lastIndex=-1,this._engine=e}).prototype).destroy=function(){for(var e=this._fontAtlases,t=0,n=e.length;t<n;++t)e[t].destroy(!0);e.length=0},eh._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},eh._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},eh._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},eh._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},eh._getLastIndex=function(){return this._lastIndex},eh._createFontAtlas=function(){var e,t=this._engine,n=new cn(t),r=new l9(t,256,256);n.texture=r,n.isGCIgnored=r.isGCIgnored=!0,this._fontAtlases.push(n);var a=this.nativeFontString;return t.resourceManager.addContentRestorer(new(lk(e=function(){return l$.call(this,n)},l$),e.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var r in t){var i=t[r],o=cr.measureChar(i.char,a).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()},e)),n},eu),ci=(lk(ed=function(e,t){var n;return void 0===t&&(t=""),(n=lZ.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},lZ),(e_=ed.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,a=r[n];return a||(a=new ca(this.engine),r[n]=a),a},e_._onDestroy=function(){lZ.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]},ed.createFromOS=function(e,t){if(t){var n=e._fontMap,r=n[t];return r||(r=new ed(e,t),n[t]=r),r}return null},lU(ed,[{key:"name",get:function(){return this._name}}]),ed),co=((ep=(ef=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},ep.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ep.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ep.dispatch=function(e,t){if(!this._events[e])return!1;var n=this._events[e];if(Array.isArray(n)){var r=n.length,a=ef._dispatchingListenersPool,i=a.length>0?a.pop():[];i.length=r;for(var o=0;o<r;o++)i[o]=n[o];for(var s=0;s<r;s++){var l=i[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}i.length=0,a.push(i)}else n.once&&this.off(e,n.fn),n.fn(t);return!0},ep.on=function(e,t){return this._addEventListener(e,t)},ep.once=function(e,t){return this._addEventListener(e,t,!0)},ep.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},ep.removeEventListener=function(e,t){return this.off(e,t)},ep.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ep._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},ep._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},ef);co._dispatchingListenersPool=[];var cs=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},lU(e,[{key:"type",get:function(){return this._type}}]),e}();cs._propertyIdMap=Object.create(null),cs._propertyNameCounter=0,cs._propertyNameMap=Object.create(null);var cl=((em=(eg=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new lD,this._deltaTimeValue=new lD,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},em._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},em._updateSceneShaderData=function(e){var t=this._elapsedTimeValue,n=this._deltaTimeValue,r=this._elapsedTime;t.set(r,Math.sin(r),Math.cos(r),0),e.setVector4(eg._elapsedTimeProperty,t),n.set(this._deltaTime,0,0,0),e.setVector4(eg._deltaTimeProperty,n)},lU(eg,[{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}}]),eg);cl._elapsedTimeProperty=cs.getByName("scene_ElapsedTime"),cl._deltaTimeProperty=cs.getByName("scene_DeltaTime"),e.DataType=void 0,(ev=e.DataType||(e.DataType={}))[ev.FLOAT=5126]="FLOAT",ev[ev.FLOAT_VEC2=35664]="FLOAT_VEC2",ev[ev.FLOAT_VEC3=35665]="FLOAT_VEC3",ev[ev.FLOAT_VEC4=35666]="FLOAT_VEC4",ev[ev.INT=5124]="INT",ev[ev.INT_VEC2=35667]="INT_VEC2",ev[ev.INT_VEC3=35668]="INT_VEC3",ev[ev.INT_VEC4=35669]="INT_VEC4",ev[ev.BOOL=35670]="BOOL",ev[ev.BOOL_VEC2=35671]="BOOL_VEC2",ev[ev.BOOL_VEC3=35672]="BOOL_VEC3",ev[ev.BOOL_VEC4=35673]="BOOL_VEC4",ev[ev.FLOAT_MAT2=35674]="FLOAT_MAT2",ev[ev.FLOAT_MAT3=35675]="FLOAT_MAT3",ev[ev.FLOAT_MAT4=35676]="FLOAT_MAT4",ev[ev.FLOAT_ARRAY=35677]="FLOAT_ARRAY",ev[ev.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",ev[ev.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",ev[ev.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",ev[ev.INT_ARRAY=100003]="INT_ARRAY",ev[ev.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",ev[ev.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",ev[ev.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",ev[ev.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",ev[ev.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",ev[ev.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",ev[ev.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",ev[ev.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",ev[ev.SAMPLER_2D=35678]="SAMPLER_2D",ev[ev.SAMPLER_CUBE=35680]="SAMPLER_CUBE",ev[ev.BYTE=5120]="BYTE",ev[ev.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ev[ev.SHORT=5122]="SHORT",ev[ev.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ev[ev.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(ey=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",ey.standardDerivatives="OES_standard_derivatives",ey.shaderTextureLod="EXT_shader_texture_lod",ey.elementIndexUint="OES_element_index_uint",ey.depthTexture="WEBGL_depth_texture",ey.drawBuffers="WEBGL_draw_buffers",ey.vertexArrayObject="OES_vertex_array_object",ey.instancedArrays="ANGLE_instanced_arrays",ey.multipleSample="multipleSampleOnlySupportedInWebGL2",ey.textureFloat="OES_texture_float",ey.textureFloatLinear="OES_texture_float_linear",ey.textureHalfFloat="OES_texture_half_float",ey.textureHalfFloatLinear="OES_texture_half_float_linear",ey.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",ey.colorBufferFloat="EXT_color_buffer_float",ey.colorBufferHalfFloat="EXT_color_buffer_half_float",ey.textureFilterAnisotropic="EXT_texture_filter_anisotropic",ey.blendMinMax="EXT_blend_minmax",ey.astc="WEBGL_compressed_texture_astc",ey.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",ey.etc="WEBGL_compressed_texture_etc",ey.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",ey.etc1="WEBGL_compressed_texture_etc1",ey.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",ey.pvrtc="WEBGL_compressed_texture_pvrtc",ey.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",ey.s3tc="WEBGL_compressed_texture_s3tc",ey.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",ey.bptc="EXT_texture_compression_bptc",ey.WEBGL_lose_context="WEBGL_lose_context",(ex=sL||(sL={}))[ex.None=0]="None",ex[ex.Scene=1]="Scene",ex[ex.Hierarchy=2]="Hierarchy",ex[ex.All=3]="All";var cc=(lk(eT=function(e){var t;return(t=lJ.call(this,e.engine)||this)._awoken=!1,t._phasedActive=!1,t._phasedActiveInScene=!1,t._enabled=!0,t._entity=e,t},lJ),(eS=eT.prototype)._onAwake=function(){},eS._onEnable=function(){},eS._onDisable=function(){},eS._onEnableInScene=function(){},eS._onDisableInScene=function(){},eS._setActive=function(e,t){var n=this._entity;t&sL.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&sL.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()))},eS._onDestroy=function(){lJ.prototype._onDestroy.call(this);var e=this._entity;e._removeComponent(this),this._enabled&&(e._isActiveInScene&&this._onDisableInScene(),e._isActiveInHierarchy&&this._onDisable())},lU(eT,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,this._entity._isActiveInScene&&(e?(this._phasedActiveInScene=!0,this._onEnableInScene()):(this._phasedActiveInScene=!1,this._onDisableInScene())),this._entity.isActiveInHierarchy&&(e?(this._phasedActive=!0,this._onEnable()):(this._phasedActive=!1,this._onDisable())))}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),eT);lW([lK],cc.prototype,"_entity",void 0),lW([lK],cc.prototype,"_awoken",void 0),lW([lK],cc.prototype,"_phasedActive",void 0),lW([lK],cc.prototype,"_phasedActiveInScene",void 0),lW([lj],cc.prototype,"_enabled",void 0);var cu=((eC=function(){})._addCheck=function(e,t){for(;t!==cc;){var n=eC._dependenciesMap.get(t);if(n)for(var r=n.components,a=n.mode,i=0,o=r.length;i<o;i++){var s=r[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)}},eC._removeCheck=function(e,t){for(;t!==cc;){var n=eC._invDependenciesMap.get(t);if(n){for(var r=0,a=n.length;r<a;r++)if(e.getComponent(n[r]))throw"Should remove "+n[r].name+" before adding "+t.name}t=Object.getPrototypeOf(t)}},eC._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eC._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eC);function ch(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){cu._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return cu._addInvDependency(t,e)})}}cu._invDependenciesMap=new Map,cu._dependenciesMap=new Map,e.DependentMode=void 0,(eA=e.DependentMode||(e.DependentMode={}))[eA.CheckOnly=0]="CheckOnly",eA[eA.AutoAdd=1]="AutoAdd";var cd=((eE=(ew=function(e){void 0===e&&(e=0),this.length=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++},eE.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},eE.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},eE.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},eE.deleteByIndex=function(e){var t=this._elements,n=null,r=this.length-1;return e!==r&&(n=t[r],t[e]=n),this.length--,n},eE.garbageCollection=function(){this._elements.length=this.length},ew);e.Layer=void 0,(eb=e.Layer||(e.Layer={}))[eb.Layer0=1]="Layer0",eb[eb.Layer1=2]="Layer1",eb[eb.Layer2=4]="Layer2",eb[eb.Layer3=8]="Layer3",eb[eb.Layer4=16]="Layer4",eb[eb.Layer5=32]="Layer5",eb[eb.Layer6=64]="Layer6",eb[eb.Layer7=128]="Layer7",eb[eb.Layer8=256]="Layer8",eb[eb.Layer9=512]="Layer9",eb[eb.Layer10=1024]="Layer10",eb[eb.Layer11=2048]="Layer11",eb[eb.Layer12=4096]="Layer12",eb[eb.Layer13=8192]="Layer13",eb[eb.Layer14=16384]="Layer14",eb[eb.Layer15=32768]="Layer15",eb[eb.Layer16=65536]="Layer16",eb[eb.Layer17=131072]="Layer17",eb[eb.Layer18=262144]="Layer18",eb[eb.Layer19=524288]="Layer19",eb[eb.Layer20=1048576]="Layer20",eb[eb.Layer21=2097152]="Layer21",eb[eb.Layer22=4194304]="Layer22",eb[eb.Layer23=8388608]="Layer23",eb[eb.Layer24=16777216]="Layer24",eb[eb.Layer25=33554432]="Layer25",eb[eb.Layer26=67108864]="Layer26",eb[eb.Layer27=134217728]="Layer27",eb[eb.Layer28=268435456]="Layer28",eb[eb.Layer29=536870912]="Layer29",eb[eb.Layer30=1073741824]="Layer30",eb[eb.Layer31=2147483648]="Layer31",eb[eb.Everything=4294967295]="Everything",eb[eb.Nothing=0]="Nothing";var c_=((eM=function(){})._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],h=i[5],d=i[6],_=i[7],f=i[8],p=i[9],g=i[10],m=i[11],v=i[12],y=i[13],x=i[14],T=i[15],S=t[n],C=t[n+1],A=t[n+2],w=t[n+3],E=t[n+4],b=t[n+5],M=t[n+6],F=t[n+7],R=t[n+8],P=t[n+9],L=t[n+10],D=t[n+11],B=t[n+12],I=t[n+13],V=t[n+14],O=t[n+15];r[a]=o*S+u*C+f*A+v*w,r[a+1]=s*S+h*C+p*A+y*w,r[a+2]=l*S+d*C+g*A+x*w,r[a+3]=c*S+_*C+m*A+T*w,r[a+4]=o*E+u*b+f*M+v*F,r[a+5]=s*E+h*b+p*M+y*F,r[a+6]=l*E+d*b+g*M+x*F,r[a+7]=c*E+_*b+m*M+T*F,r[a+8]=o*R+u*P+f*L+v*D,r[a+9]=s*R+h*P+p*L+y*D,r[a+10]=l*R+d*P+g*L+x*D,r[a+11]=c*R+_*P+m*L+T*D,r[a+12]=o*B+u*I+f*V+v*O,r[a+13]=s*B+h*I+p*V+y*O,r[a+14]=l*B+d*I+g*V+x*O,r[a+15]=c*B+_*I+m*V+T*O},eM._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},eM.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},eM.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))},eM.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eM.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eM.resolveAbsoluteUrl=function(e,t){return eM.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+this._formatRelativePath(t)},eM._stringToPath=function(e){var t=[];return e.charCodeAt(0)===cf&&t.push(""),e.replace(cg,function(e,n,r,a){var i=e;r?i=a.replace(cp,"$1"):n&&(i=n.trim()),t.push(i)}),t},eM._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},eM),cf=46,cp=/\\(\\)?/g,cg=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),cm=((eR=(eF=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eR.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eR._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)c_.removeFromArray(e[t]._updateFlags,this)},lk(eP=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eP.prototype.dispatch=function(){this.flag=!0},eP),cv=((eD=(eL=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eD.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eD.removeFlag=function(e){c_.removeFromArray(this._updateFlags,e)&&c_.removeFromArray(e._flagManagers,this)},eD.addListener=function(e){this._listeners.push(e)},eD.removeListener=function(e){c_.removeFromArray(this._listeners,e)},eD.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)},eL),cy=(lk(eB=function(e){var t;return(t=cc.call(this,e)||this)._position=new lS,t._rotation=new lS,t._rotationQuaternion=new lF,t._scale=new lS(1,1,1),t._worldPosition=new lS,t._worldRotation=new lS,t._worldRotationQuaternion=new lF,t._lossyWorldScale=new lS(1,1,1),t._localMatrix=new lR,t._worldMatrix=new lR,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new cv,t._onPositionChanged=t._onPositionChanged.bind(lO(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(lO(t)),t._onRotationChanged=t._onRotationChanged.bind(lO(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(lO(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(lO(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(lO(t)),t._onScaleChanged=t._onScaleChanged.bind(lO(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},cc),(eI=eB.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eI.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eI.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eI.setScale=function(e,t,n){this._scale.set(e,t,n)},eI.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eI.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eI.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eI.translate=function(e,t,n,r){if("number"==typeof e){var a=eB._tempVec30;a.set(e,t,n),this._translate(a,r)}else this._translate(e,t)},eI.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eI.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*lT.degreeToRadFactor;lF.rotationAxisAngle(e,r,eB._tempQuat0),this._rotateByQuat(eB._tempQuat0,n)},eI.lookAt=function(e,t){var n=eB._tempVec30;lS.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=lT.zeroTolerance)){n.scale(1/r);var a=eB._tempVec31;if(t?lS.cross(t,n,a):a.set(n.z,0,-n.x),!((r=a.length())<=lT.zeroTolerance)){a.scale(1/r);var i=eB._tempVec32;lS.cross(n,a,i);var o=eB._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]=n.x,s[9]=n.y,s[10]=n.z,o.getRotation(this._worldRotationQuaternion)}}},eI.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(cm)},eI._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eI._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eI._onDestroy=function(){cc.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},eI._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()}},eI._updateWorldRotationFlag=function(){if(!this._isContainDirtyFlags(152)){this._worldAssociatedChange(152);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndRotationFlag()}},eI._updateWorldPositionAndRotationFlag=function(){if(!this._isContainDirtyFlags(156)){this._worldAssociatedChange(156);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndRotationFlag()}},eI._updateWorldScaleFlag=function(){if(!this._isContainDirtyFlags(160)){this._worldAssociatedChange(160);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndScaleFlag()}},eI._updateWorldPositionAndScaleFlag=function(){if(!this._isContainDirtyFlags(164)){this._worldAssociatedChange(164);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateWorldPositionAndScaleFlag()}},eI._updateAllWorldFlag=function(){if(!this._isContainDirtyFlags(188)){this._worldAssociatedChange(188);for(var e,t=this._entity._children,n=0,r=t.length;n<r;n++)null==(e=t[n].transform)||e._updateAllWorldFlag()}},eI._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},eI._getScaleMatrix=function(){var e=eB._tempQuat0,t=eB._tempMat30,n=eB._tempMat31,r=eB._tempMat32;return n.copyFromMatrix(this.worldMatrix),lF.invert(this.worldRotationQuaternion,e),lM.rotationQuaternion(e,t),lM.multiply(t,n,r),r},eI._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eI._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eI._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eI._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eI._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eI._rotateByQuat=function(e,t){t?lF.multiply(this.rotationQuaternion,e,this._rotationQuaternion):lF.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eI._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eB._tempVec30;lS.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eI._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var a=lT.degreeToRadFactor,i=eB._tempQuat0;lF.rotationEuler(e*a,t*a,n*a,i),this._rotateByQuat(i,r)},eI._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eI._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(lR.invert(t.worldMatrix,eB._tempMat41),lS.transformCoordinate(e,eB._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eI._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eI._onWorldRotationChanged=function(){var e=this._worldRotation;lF.rotationEuler(lT.degreeToRadian(e.x),lT.degreeToRadian(e.y),lT.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eI._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eI._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eB._tempQuat0;lF.invert(t.worldRotationQuaternion,n),lF.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eI._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},lU(eB,[{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(lT.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(lT.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,lF.rotationEuler(lT.degreeToRadian(this._rotation.x),lT.degreeToRadian(this._rotation.y),lT.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):lF.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?lF.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):lF.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)&&(lR.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?lR.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?(lR.invert(t.worldMatrix,eB._tempMat42),lR.multiply(eB._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 lS),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 lS),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 lS),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eB);cy._tempQuat0=new lF,cy._tempVec30=new lS,cy._tempVec31=new lS,cy._tempVec32=new lS,cy._tempMat30=new lM,cy._tempMat31=new lM,cy._tempMat32=new lM,cy._tempMat41=new lR,cy._tempMat42=new lR,lW([lY],cy.prototype,"_position",void 0),lW([lY],cy.prototype,"_rotation",void 0),lW([lY],cy.prototype,"_rotationQuaternion",void 0),lW([lY],cy.prototype,"_scale",void 0),lW([lY],cy.prototype,"_worldPosition",void 0),lW([lY],cy.prototype,"_worldRotation",void 0),lW([lY],cy.prototype,"_worldRotationQuaternion",void 0),lW([lY],cy.prototype,"_lossyWorldScale",void 0),lW([lY],cy.prototype,"_localMatrix",void 0),lW([lY],cy.prototype,"_worldMatrix",void 0),lW([lK],cy.prototype,"_worldForward",void 0),lW([lK],cy.prototype,"_worldRight",void 0),lW([lK],cy.prototype,"_worldUp",void 0),lW([lK],cy.prototype,"_isParentDirty",void 0),lW([lK],cy.prototype,"_parentTransformCache",void 0),lW([lK],cy.prototype,"_updateFlagManager",void 0),lW([lK],cy.prototype,"_onPositionChanged",null),lW([lK],cy.prototype,"_onWorldPositionChanged",null),lW([lK],cy.prototype,"_onRotationChanged",null),lW([lK],cy.prototype,"_onWorldRotationChanged",null),lW([lK],cy.prototype,"_onRotationQuaternionChanged",null),lW([lK],cy.prototype,"_onWorldRotationQuaternionChanged",null),lW([lK],cy.prototype,"_onScaleChanged",null),(eV=sD||(sD={}))[eV.LocalEuler=1]="LocalEuler",eV[eV.LocalQuat=2]="LocalQuat",eV[eV.WorldPosition=4]="WorldPosition",eV[eV.WorldEuler=8]="WorldEuler",eV[eV.WorldQuat=16]="WorldQuat",eV[eV.WorldScale=32]="WorldScale",eV[eV.LocalMatrix=64]="LocalMatrix",eV[eV.WorldMatrix=128]="WorldMatrix",eV[eV.WmWp=132]="WmWp",eV[eV.WmWeWq=152]="WmWeWq",eV[eV.WmWpWeWq=156]="WmWpWeWq",eV[eV.WmWs=160]="WmWs",eV[eV.WmWpWs=164]="WmWpWs",eV[eV.WmWpWeWqWs=188]="WmWpWeWqWs";var cx=((eO=function(){}).cloneComponent=function(e,t,n,r){for(var a=lQ.getCloneMode(e.constructor),i=Object.keys(e),o=0,s=i.length;o<s;o++){var l=i[o];switch(a[l]){case void 0:case sP.Assignment:t[l]=e[l];break;case sP.Shallow:var c=e[l];if(lX(c,Object)){var u=t[l];null==u&&(u=t[l]=c.constructor()),Object.assign(u,c)}else t[l]=c;break;case sP.Deep:var h=e[l];if(lX(h,Object)){var d=t[l];null==d&&(d=t[l]=h.constructor()),lQ.deepCloneObject(h,d)}else t[l]=h}}e._cloneTo&&e._cloneTo(t,n,r)},eO),cT=(lk(eN=function(t,n){var r;return(r=lJ.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._isActiveInScene=!1,r._components=[],r._scripts=new cd,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new lR,r.name=n,r.transform=r.addComponent(cy),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},lJ),(eU=eN.prototype).addComponent=function(e){cu._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0,sL.All),t},eU.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(lX(r,e))return r}return null},eU.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,a=n.length;r<a;r++){var i=n[r];lX(i,e)&&t.push(i)}return t},eU.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eU.addChild=function(e,t){var n;if("number"==typeof e?n=e:(n=void 0,t=e),t._isRoot){t._scene._removeFromEntityList(t),t._isRoot=!1,this._addToChildrenList(n,t),t._parent=this;var r=t._scene,a=this._scene,i=sL.None;!this._isActiveInHierarchy&&t._isActiveInHierarchy&&(i|=sL.Hierarchy),this._isActiveInScene?t._isActiveInScene&&r!==a&&(i|=sL.Scene):t._isActiveInScene&&(i|=sL.Scene),i&&t._processInActive(i),t._scene!==a&&eN._traverseSetOwnerScene(t,a);var o=sL.None;t._isActive&&(this._isActiveInHierarchy&&(t._isActiveInHierarchy||(o|=sL.Hierarchy)),this._isActiveInScene&&(t._isActiveInScene&&r===a||(o|=sL.Scene))),o&&t._processActive(o),t._setTransformDirty()}else t._setParent(this,n)},eU.removeChild=function(e){e._setParent(null)},eU.getChild=function(e){return this._children[e]},eU.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},eU.findByPath=function(e){for(var t=e.split("/"),n=this,r=0,a=t.length;r<a;++r){var i=t[r];if(i&&!(n=eN._findChildByName(n,i)))return null}return n},eU.createChild=function(e){var t=new eN(this.engine,e);return t.layer=this.layer,t.parent=this,t},eU.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n._parent=null;var r=sL.None;n._isActiveInHierarchy&&(r|=sL.Hierarchy),n._isActiveInScene&&(r|=sL.Scene),r&&n._processInActive(r),eN._traverseSetOwnerScene(n,null)}e.length=0},eU.clone=function(){var e=this._createCloneEntity(this);return this._parseCloneEntity(this,e,this,e),e},eU._createCloneEntity=function(e){var t=new eN(e._engine,e.name),n=this._hookResource;n&&(t._hookResource=n,n._addReferCount(1)),t.layer=e.layer,t._isActive=e._isActive,t.transform.localMatrix=e.transform.localMatrix;for(var r=e._children,a=0,i=e._children.length;a<i;a++)t.addChild(this._createCloneEntity(r[a]));return t},eU._parseCloneEntity=function(e,t,n,r){for(var a=e._children,i=t._children,o=0,s=a.length;o<s;o++)this._parseCloneEntity(a[o],i[o],n,r);for(var l=e._components,c=0,u=l.length;c<u;c++){var h=l[c];if(!lX(h,cy)){var d=t.addComponent(h.constructor);cx.cloneComponent(h,d,n,r)}}},eU.destroy=function(){if(!this._destroyed){lJ.prototype.destroy.call(this),this._hookResource&&(this._hookResource._addReferCount(-1),this._hookResource=null);for(var e=this._components,t=e.length-1;t>=0;t--)e[t].destroy();this._components.length=0;for(var n=this._children;n.length>0;)n[0].destroy();this._isRoot?(this._scene._removeFromEntityList(this),this._isRoot=!1):this._removeFromParent()}},eU._removeComponent=function(e){cu._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eU._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eU._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eU._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}},eU._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)},eU._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)},eU._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++}},eU._setParent=function(e,t){var n=this._parent;if(e!==n){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var r=this._scene,a=e._scene,i=sL.None;!e._isActiveInHierarchy&&this._isActiveInHierarchy&&(i|=sL.Hierarchy),e._isActiveInScene?this._isActiveInScene&&r!==a&&(i|=sL.Scene):this._isActiveInScene&&(i|=sL.Scene),i&&this._processInActive(i),r!==a&&eN._traverseSetOwnerScene(this,a);var o=sL.None;this._isActive&&(e._isActiveInHierarchy&&(this._isActiveInHierarchy||(o|=sL.Hierarchy)),e._isActiveInScene&&(this._isActiveInScene&&r===a||(o|=sL.Scene))),o&&this._processActive(o)}else{var s=sL.None;this._isActiveInHierarchy&&(s|=sL.Hierarchy),this._isActiveInScene&&(s|=sL.Scene),s&&this._processInActive(s),n&&eN._traverseSetOwnerScene(this,null)}this._setTransformDirty()}},eU._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];lX(r,e)&&t.push(r)}for(var a=this._children.length-1;a>=0;a--)this._children[a]._getComponentsInChildren(e,t)},eU._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},eU._setActiveInHierarchy=function(e,t){t&sL.Hierarchy&&(this._isActiveInHierarchy=!0),t&sL.Scene&&(this._isActiveInScene=!0);for(var n=this._components,r=n.length-1;r>=0;r--){var a=n[r];(a.enabled||!a._awoken)&&e.push(a)}for(var i=this._children,o=i.length-1;o>=0;o--){var s=i[o];s.isActive&&s._setActiveInHierarchy(e,t)}},eU._setInActiveInHierarchy=function(e,t){t&sL.Hierarchy&&(this._isActiveInHierarchy=!1),t&sL.Scene&&(this._isActiveInScene=!1);for(var n=this._components,r=n.length-1;r>=0;r--){var a=n[r];a.enabled&&e.push(a)}for(var i=this._children,o=i.length-1;o>=0;o--){var s=i[o];s.isActive&&s._setInActiveInHierarchy(e,t)}},eU._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eU._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}}},eU.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(lR.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eN._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},eN._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=n.length-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},lU(eN,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent,n=sL.None;this._isRoot&&this._scene._isActiveInEngine?n|=sL.All:((null==t?void 0:t._isActiveInHierarchy)&&(n|=sL.Hierarchy),(null==t?void 0:t._isActiveInScene)&&(n|=sL.Scene)),n&&this._processActive(n)}else{var r=sL.None;this._isActiveInHierarchy&&(r|=sL.Hierarchy),this._isActiveInScene&&(r|=sL.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)}}]),eN),cS=((ek=(ez=function(e){this._elementPoolIndex=0,this._elementPool=[],this._type=e}).prototype).getFromPool=function(){var e=this._elementPoolIndex,t=this._elementPool;if(this._elementPoolIndex++,t.length!==e)return t[e];var n=new this._type;return t.push(n),n},ek.resetPool=function(){this._elementPoolIndex=0},ek.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},ez),cC=function(){},cA=(lk(eG=function(){return cC.apply(this,arguments)},cC),(eH=eG.prototype).set=function(e,t,n,r){this.component=e,this.material=t,this.mesh=n,this.subMesh=r},eH.dispose=function(){this.component=this.material=this.mesh=this.subMesh=null},eG);e.BlendFactor=void 0,(eW=e.BlendFactor||(e.BlendFactor={}))[eW.Zero=0]="Zero",eW[eW.One=1]="One",eW[eW.SourceColor=2]="SourceColor",eW[eW.OneMinusSourceColor=3]="OneMinusSourceColor",eW[eW.DestinationColor=4]="DestinationColor",eW[eW.OneMinusDestinationColor=5]="OneMinusDestinationColor",eW[eW.SourceAlpha=6]="SourceAlpha",eW[eW.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eW[eW.DestinationAlpha=8]="DestinationAlpha",eW[eW.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eW[eW.SourceAlphaSaturate=10]="SourceAlphaSaturate",eW[eW.BlendColor=11]="BlendColor",eW[eW.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(eX=e.BlendOperation||(e.BlendOperation={}))[eX.Add=0]="Add",eX[eX.Subtract=1]="Subtract",eX[eX.ReverseSubtract=2]="ReverseSubtract",eX[eX.Min=3]="Min",eX[eX.Max=4]="Max",e.ColorWriteMask=void 0,(eK=e.ColorWriteMask||(e.ColorWriteMask={}))[eK.None=0]="None",eK[eK.Red=1]="Red",eK[eK.Green=2]="Green",eK[eK.Blue=4]="Blue",eK[eK.Alpha=8]="Alpha",eK[eK.All=15]="All",e.CompareFunction=void 0,(ej=e.CompareFunction||(e.CompareFunction={}))[ej.Never=0]="Never",ej[ej.Less=1]="Less",ej[ej.Equal=2]="Equal",ej[ej.LessEqual=3]="LessEqual",ej[ej.Greater=4]="Greater",ej[ej.NotEqual=5]="NotEqual",ej[ej.GreaterEqual=6]="GreaterEqual",ej[ej.Always=7]="Always",e.CullMode=void 0,(eq=e.CullMode||(e.CullMode={}))[eq.Off=0]="Off",eq[eq.Front=1]="Front",eq[eq.Back=2]="Back",e.RenderStateDataKey=void 0,(eY=e.RenderStateDataKey||(e.RenderStateDataKey={}))[eY.BlendStateEnabled0=0]="BlendStateEnabled0",eY[eY.BlendStateColorBlendOperation0=1]="BlendStateColorBlendOperation0",eY[eY.BlendStateAlphaBlendOperation0=2]="BlendStateAlphaBlendOperation0",eY[eY.BlendStateSourceColorBlendFactor0=3]="BlendStateSourceColorBlendFactor0",eY[eY.BlendStateSourceAlphaBlendFactor0=4]="BlendStateSourceAlphaBlendFactor0",eY[eY.BlendStateDestinationColorBlendFactor0=5]="BlendStateDestinationColorBlendFactor0",eY[eY.BlendStateDestinationAlphaBlendFactor0=6]="BlendStateDestinationAlphaBlendFactor0",eY[eY.BlendStateColorWriteMask0=7]="BlendStateColorWriteMask0",eY[eY.BlendStateBlendColor=8]="BlendStateBlendColor",eY[eY.BlendStateAlphaToCoverage=9]="BlendStateAlphaToCoverage",eY[eY.DepthStateEnabled=10]="DepthStateEnabled",eY[eY.DepthStateWriteEnabled=11]="DepthStateWriteEnabled",eY[eY.DepthStateCompareFunction=12]="DepthStateCompareFunction",eY[eY.StencilStateEnabled=13]="StencilStateEnabled",eY[eY.StencilStateReferenceValue=14]="StencilStateReferenceValue",eY[eY.StencilStateMask=15]="StencilStateMask",eY[eY.StencilStateWriteMask=16]="StencilStateWriteMask",eY[eY.StencilStateCompareFunctionFront=17]="StencilStateCompareFunctionFront",eY[eY.StencilStateCompareFunctionBack=18]="StencilStateCompareFunctionBack",eY[eY.StencilStatePassOperationFront=19]="StencilStatePassOperationFront",eY[eY.StencilStatePassOperationBack=20]="StencilStatePassOperationBack",eY[eY.StencilStateFailOperationFront=21]="StencilStateFailOperationFront",eY[eY.StencilStateFailOperationBack=22]="StencilStateFailOperationBack",eY[eY.StencilStateZFailOperationFront=23]="StencilStateZFailOperationFront",eY[eY.StencilStateZFailOperationBack=24]="StencilStateZFailOperationBack",eY[eY.RasterStateCullMode=25]="RasterStateCullMode",eY[eY.RasterStateDepthBias=26]="RasterStateDepthBias",eY[eY.RasterStateSlopeScaledDepthBias=27]="RasterStateSlopeScaledDepthBias",e.RenderQueueType=void 0,(eQ=e.RenderQueueType||(e.RenderQueueType={}))[eQ.Opaque=0]="Opaque",eQ[eQ.AlphaTest=1]="AlphaTest",eQ[eQ.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eJ=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eJ.Float=0]="Float",eJ[eJ.Int=1]="Int",eJ[eJ.Vector2=2]="Vector2",eJ[eJ.Vector3=3]="Vector3",eJ[eJ.Vector4=4]="Vector4",eJ[eJ.Matrix=5]="Matrix",eJ[eJ.Color=6]="Color",eJ[eJ.Texture=7]="Texture",eJ[eJ.FloatArray=8]="FloatArray",eJ[eJ.IntArray=9]="IntArray",eJ[eJ.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eZ=e.StencilOperation||(e.StencilOperation={}))[eZ.Keep=0]="Keep",eZ[eZ.Zero=1]="Zero",eZ[eZ.Replace=2]="Replace",eZ[eZ.IncrementSaturate=3]="IncrementSaturate",eZ[eZ.DecrementSaturate=4]="DecrementSaturate",eZ[eZ.Invert=5]="Invert",eZ[eZ.IncrementWrap=6]="IncrementWrap",eZ[eZ.DecrementWrap=7]="DecrementWrap";var cw=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]=r,e._macroCounter++}return a},e._getNamesByMacros=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}();cw._macroMaskMap=[],cw._macroNameIdMap=Object.create(null),cw._macroNameCounter=0,cw._macroCounter=0,cw._macroMap=Object.create(null);var cE=((e0=(e$=function(){this._mask=[],this._length=0}).prototype).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},e0.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}},e0.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]},e0.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}},e0.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}},e0.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},e0.clear=function(){this._length=0},e$.unionCollection=function(e,t,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 cb(){return(cb=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)}e.PipelineStage=void 0,(e1=e.PipelineStage||(e.PipelineStage={})).DepthOnly="DepthOnly",e1.ShadowCaster="ShadowCaster",e1.Forward="Forward";var cM=cb({common:"#define GLSLIFY 1\n#define PI 3.14159265359\n#define RECIPROCAL_PI 0.31830988618\n#define EPSILON 1e-6\n#define LOG2 1.442695\n#define saturate( a ) clamp( a, 0.0, 1.0 )\nfloat pow2(float x){return x*x;}vec4 RGBMToLinear(vec4 value,float maxRange){return vec4(value.rgb*value.a*maxRange,1.0);}vec4 gammaToLinear(vec4 srgbIn){return vec4(pow(srgbIn.rgb,vec3(2.2)),srgbIn.a);}vec4 linearToGamma(vec4 linearIn){return vec4(pow(linearIn.rgb,vec3(1.0/2.2)),linearIn.a);}uniform vec4 camera_DepthBufferParams;float remapDepthBufferLinear01(float z){return 1.0/(camera_DepthBufferParams.x*z+camera_DepthBufferParams.y);}\n#ifdef GRAPHICS_API_WEBGL2\n#define INVERSE_MAT(mat) inverse(mat)\n#else\nmat2 inverseMat(mat2 m){return mat2(m[1][1],-m[0][1],-m[1][0],m[0][0])/(m[0][0]*m[1][1]-m[0][1]*m[1][0]);}mat3 inverseMat(mat3 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2];float a10=m[1][0],a11=m[1][1],a12=m[1][2];float a20=m[2][0],a21=m[2][1],a22=m[2][2];float b01=a22*a11-a12*a21;float b11=-a22*a10+a12*a20;float b21=a21*a10-a11*a20;float det=a00*b01+a01*b11+a02*b21;return mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),b11,(a22*a00-a02*a20),(-a12*a00+a02*a10),b21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;}mat4 inverseMat(mat4 m){float a00=m[0][0],a01=m[0][1],a02=m[0][2],a03=m[0][3],a10=m[1][0],a11=m[1][1],a12=m[1][2],a13=m[1][3],a20=m[2][0],a21=m[2][1],a22=m[2][2],a23=m[2][3],a30=m[3][0],a31=m[3][1],a32=m[3][2],a33=m[3][3],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return mat4(a11*b11-a12*b10+a13*b09,a02*b10-a01*b11-a03*b09,a31*b05-a32*b04+a33*b03,a22*b04-a21*b05-a23*b03,a12*b08-a10*b11-a13*b07,a00*b11-a02*b08+a03*b07,a32*b02-a30*b05-a33*b01,a20*b05-a22*b02+a23*b01,a10*b10-a11*b08+a13*b06,a01*b08-a00*b10-a03*b06,a30*b04-a31*b02+a33*b00,a21*b02-a20*b04-a23*b00,a11*b07-a10*b09-a12*b06,a00*b09-a01*b07+a02*b06,a31*b01-a30*b03-a32*b00,a20*b03-a21*b01+a22*b00)/det;}\n#define INVERSE_MAT(mat) inverseMat(mat)\n#endif\n",common_vert:"#define GLSLIFY 1\nattribute vec3 POSITION;\n#ifdef RENDERER_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef RENDERER_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef RENDERER_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef RENDERER_USE_JOINT_TEXTURE\nuniform sampler2D renderer_JointSampler;uniform float renderer_JointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/renderer_JointCount;float hf=0.5/renderer_JointCount;float v=base+hf;vec4 m0=texture2D(smp,vec2(0.125,v));vec4 m1=texture2D(smp,vec2(0.375,v));vec4 m2=texture2D(smp,vec2(0.625,v));vec4 m3=texture2D(smp,vec2(0.875,v));return mat4(m0,m1,m2,m3);}\n#else\nuniform mat4 renderer_JointMatrix[RENDERER_JOINTS_NUM];\n#endif\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 material_TilingOffset;\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef RENDERER_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 renderer_LocalMat;uniform mat4 renderer_ModelMat;uniform mat4 camera_ViewMat;uniform mat4 camera_ProjMat;uniform mat4 renderer_MVMat;uniform mat4 renderer_MVPMat;uniform mat4 renderer_NormalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 camera_Position;",color_share:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef RENDERER_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 scene_FogColor;uniform vec4 scene_FogParams;float ComputeFogIntensity(float fogDepth){\n#if SCENE_FOG_MODE == 1\nreturn clamp(fogDepth*scene_FogParams.x+scene_FogParams.y,0.0,1.0);\n#elif SCENE_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*scene_FogParams.z),0.0,1.0);\n#elif SCENE_FOG_MODE == 3\nfloat factor=fogDepth*scene_FogParams.w;return clamp(exp2(-factor*factor),0.0,1.0);\n#endif\n}\n#endif\n",begin_normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef RENDERER_HAS_TANGENT\nvec4 tangent=vec4(TANGENT);\n#endif\n#endif\n",begin_position_vert:"#define GLSLIFY 1\nvec4 position=vec4(POSITION,1.0);",position_vert:"#define GLSLIFY 1\ngl_Position=renderer_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nv_normal=normalize(mat3(renderer_NormalMat)*normal);\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvec3 normalW=normalize(mat3(renderer_NormalMat)*normal.xyz);vec3 tangentW=normalize(mat3(renderer_NormalMat)*tangent.xyz);vec3 bitangentW=cross(normalW,tangentW)*tangent.w;v_TBN=mat3(tangentW,bitangentW,normalW);\n#endif\n#endif\n#endif\n",skinning_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_SKIN\n#ifdef RENDERER_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(renderer_JointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(renderer_JointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(renderer_JointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(renderer_JointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*renderer_JointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*renderer_JointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*renderer_JointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*renderer_JointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(RENDERER_HAS_NORMAL) && !defined(MATERIAL_OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nuniform mediump sampler2DArray renderer_BlendShapeTexture;uniform ivec3 renderer_BlendShapeTextureInfo;uniform float renderer_BlendShapeWeights[RENDERER_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float renderer_BlendShapeWeights[2];\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef RENDERER_BLENDSHAPE_HAS_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef RENDERER_BLENDSHAPE_HAS_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float renderer_BlendShapeWeights[4];\n#else\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;attribute vec3 POSITION_BS4;attribute vec3 POSITION_BS5;attribute vec3 POSITION_BS6;attribute vec3 POSITION_BS7;uniform float renderer_BlendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/renderer_BlendShapeTextureInfo.y;int x=vertexElementIndex-y*renderer_BlendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(renderer_BlendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_BLENDSHAPE\n#ifdef RENDERER_BLENDSHAPE_USE_TEXTURE\nint vertexOffset=gl_VertexID*renderer_BlendShapeTextureInfo.x;for(int i=0;i<RENDERER_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=renderer_BlendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef MATERIAL_OMIT_NORMAL\n#if defined( RENDERER_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*renderer_BlendShapeWeights[0];position.xyz+=POSITION_BS1*renderer_BlendShapeWeights[1];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];\n#endif\n#if defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) || defined( RENDERER_BLENDSHAPE_HAS_TANGENT )\n#ifndef MATERIAL_OMIT_NORMAL\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];\n#if defined( RENDERER_BLENDSHAPE_HAS_NORMAL ) && defined( RENDERER_HAS_NORMAL )\nnormal+=NORMAL_BS0*renderer_BlendShapeWeights[0];normal+=NORMAL_BS1*renderer_BlendShapeWeights[1];normal+=NORMAL_BS2*renderer_BlendShapeWeights[2];normal+=NORMAL_BS3*renderer_BlendShapeWeights[3];\n#endif\n#if defined(RENDERER_BLENDSHAPE_HAS_TANGENT) && defined( RENDERER_HAS_TANGENT ) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\ntangent.xyz+=TANGENT_BS0*renderer_BlendShapeWeights[0];tangent.xyz+=TANGENT_BS1*renderer_BlendShapeWeights[1];tangent.xyz+=TANGENT_BS2*renderer_BlendShapeWeights[2];tangent.xyz+=TANGENT_BS3*renderer_BlendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*renderer_BlendShapeWeights[2];position.xyz+=POSITION_BS3*renderer_BlendShapeWeights[3];position.xyz+=POSITION_BS4*renderer_BlendShapeWeights[4];position.xyz+=POSITION_BS5*renderer_BlendShapeWeights[5];position.xyz+=POSITION_BS6*renderer_BlendShapeWeights[6];position.xyz+=POSITION_BS7*renderer_BlendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef RENDERER_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef RENDERER_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef MATERIAL_NEED_TILING_OFFSET\nv_uv=v_uv*material_TilingOffset.xy+material_TilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec4 temp_pos=renderer_ModelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nvec4 positionVS=renderer_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 scene_DirectLightCullingMask[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightColor[SCENE_DIRECT_LIGHT_COUNT];uniform vec3 scene_DirectLightDirection[SCENE_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 scene_PointLightCullingMask[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightColor[SCENE_POINT_LIGHT_COUNT];uniform vec3 scene_PointLightPosition[SCENE_POINT_LIGHT_COUNT];uniform float scene_PointLightDistance[SCENE_POINT_LIGHT_COUNT];\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 scene_SpotLightCullingMask[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightColor[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightPosition[SCENE_SPOT_LIGHT_COUNT];uniform vec3 scene_SpotLightDirection[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightDistance[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightAngleCos[SCENE_SPOT_LIGHT_COUNT];uniform float scene_SpotLightPenumbraCos[SCENE_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight scene_EnvMapLight;uniform ivec4 renderer_Layer;\n#ifdef SCENE_USE_SH\nuniform vec3 scene_EnvSH[9];\n#endif\n#ifdef SCENE_USE_SPECULAR_ENV\nuniform samplerCube scene_EnvSpecularSampler;\n#endif\n#ifndef GRAPHICS_API_WEBGL2\nbool isBitSet(float value,float mask,float bitIndex){return mod(floor(value/pow(2.0,bitIndex)),2.0)==1.0&&mod(floor(mask/pow(2.0,bitIndex)),2.0)==1.0;}\n#endif\nbool isRendererCulledByLight(ivec2 rendererLayer,ivec2 lightCullingMask){\n#ifdef GRAPHICS_API_WEBGL2\nreturn!((rendererLayer.x&lightCullingMask.x)!=0||(rendererLayer.y&lightCullingMask.y)!=0);\n#else\nfor(int i=0;i<16;i++){if(isBitSet(float(rendererLayer.x),float(lightCullingMask.x),float(i))||isBitSet(float(rendererLayer.y),float(lightCullingMask.y),float(i))){return false;}}return true;\n#endif\n}",mobile_material_frag:"#define GLSLIFY 1\nuniform vec4 material_EmissiveColor;uniform vec4 material_BaseColor;uniform vec4 material_SpecularColor;uniform float material_Shininess;uniform float material_NormalIntensity;uniform float material_AlphaCutoff;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nuniform sampler2D material_SpecularTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if SCENE_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(scene_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=material_EmissiveColor;vec4 diffuse=material_BaseColor;vec4 specular=material_SpecularColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 diffuseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(material_SpecularTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_NEED_WORLD_POS\nvec3 V=normalize(camera_Position-v_pos);\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,gl_FrontFacing);\n#else\nvec3 N=getNormal(gl_FrontFacing);\n#endif\nvec3 lightDiffuse=vec3(0.0,0.0,0.0);vec3 lightSpecular=vec3(0.0,0.0,0.0);float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;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]))continue;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]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec3 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i]))continue;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]))continue;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]))continue;spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"}),cF=((e2=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},e2.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=cM[t];return void 0===n?(l8.error('Shader slice "'+e.trim()+'" not founded.'),""):e2.parseIncludes(n)})},e2.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},e2.convertTo300=function(e,t){if(e=(e=(e=(e=e.replace(/\battribute\b/g,"in")).replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),t){if(/\bgl_FragData\[.+?\]/g.test(e)){var n=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,n)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}return e},e2._replaceMRTShader=function(e,t){for(var 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)},e2),cR=function(){function e(t){this.name=t,this._uniqueId=e._nameCounter++}return e.getByName=function(t){var n;return(n=e._nameMap)[t]||(n[t]=new e(t))},e}();cR._nameCounter=0,cR._nameMap=Object.create(null);var cP=((e4=(e3=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var n="string"==typeof e?cR.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&l8.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},e4.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?cR.getByName(e):e)._uniqueId]},e4.getTagValue=function(e){return this._tagsMap["string"==typeof e?cR.getByName(e)._uniqueId:e._uniqueId]},e3);(e5=sB||(sB={}))[e5.Scene=0]="Scene",e5[e5.Camera=1]="Camera",e5[e5.Renderer=2]="Renderer",e5[e5.Material=3]="Material",e.ColorSpace=void 0,(e8=e.ColorSpace||(e.ColorSpace={}))[e8.Linear=0]="Linear",e8[e8.Gamma=1]="Gamma";var cL=((e7=(e6=function(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}).prototype).upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},e7.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},e7.upload2f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform2f(t.location,lB.gammaToLinearSpace(n.r),lB.gammaToLinearSpace(n.g)):this._gl.uniform2f(t.location,n.r,n.g),r.x=n.r,r.y=n.g):(r.x!==n.x||r.y!==n.y)&&(this._gl.uniform2f(t.location,n.x,n.y),r.x=n.x,r.y=n.y)},e7.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},e7.upload3f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform3f(t.location,lB.gammaToLinearSpace(n.r),lB.gammaToLinearSpace(n.g),lB.gammaToLinearSpace(n.b)):this._gl.uniform3f(t.location,n.r,n.g,n.b),r.x=n.r,r.y=n.g,r.z=n.b):(r.x!==n.x||r.y!==n.y||r.z!==n.z)&&(this._gl.uniform3f(t.location,n.x,n.y,n.z),r.x=n.x,r.y=n.y,r.z=n.z)},e7.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},e7.upload4f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b||r.w!==n.a)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform4f(t.location,lB.gammaToLinearSpace(n.r),lB.gammaToLinearSpace(n.g),lB.gammaToLinearSpace(n.b),n.a):this._gl.uniform4f(t.location,n.r,n.g,n.b,n.a),r.x=n.r,r.y=n.g,r.z=n.b,r.w=n.a):(r.x!==n.x||r.y!==n.y||r.z!==n.z||r.w!==n.w)&&(this._gl.uniform4f(t.location,n.x,n.y,n.z,n.w),r.x=n.x,r.y=n.y,r.z=n.z,r.w=n.w)},e7.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},e7.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},e7.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},e7.upload2i=function(e,t){var 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)},e7.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},e7.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)},e7.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},e7.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)},e7.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},e7.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},e7.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},e7.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},e7.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)}},e6),cD=function(){this.constUniforms=[],this.textureUniforms=[]},cB=function(){function e(t,n,r){this.sceneUniformBlock=new cD,this.cameraUniformBlock=new cD,this.rendererUniformBlock=new cD,this.materialUniformBlock=new cD,this.otherUniformBlock=new cD,this._uploadRenderCount=-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=cs._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 sB.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case sB.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case sB.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case sB.Material:n?this.materialUniformBlock.textureUniforms.push(e):this.materialUniformBlock.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),!l8.isEnabled||n.getProgramParameter(i,n.LINK_STATUS)||n.isContextLost())?i:(l8.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),!l8.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();r.forEach(function(r){var a,i=r.name,o=r.size,s=r.type,l=new cL(e._engine),c=!1,u=!1;i.indexOf("[0]")>0&&(i=i.substr(0,i.length-3),c=!0);var h=t.getUniformLocation(n,i);switch(l.name=i,l.propertyId=cs.getByName(i)._uniqueId,l.location=h,s){case t.FLOAT:c?l.applyFunc=l.upload1fv:(l.applyFunc=l.upload1f,l.cacheValue=0);break;case t.FLOAT_VEC2:c?l.applyFunc=l.upload2fv:(l.applyFunc=l.upload2f,l.cacheValue=new lL(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new lS(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new lD(0,0,0,0));break;case t.BOOL:case t.INT:c?l.applyFunc=l.upload1iv:(l.applyFunc=l.upload1i,l.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:c?l.applyFunc=l.upload2iv:(l.applyFunc=l.upload2i,l.cacheValue=new lL(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=c?l.upload3iv:l.upload3i,l.cacheValue=new lS(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new lD(0,0,0));break;case t.FLOAT_MAT4:l.applyFunc=c?l.uploadMat4v:l.uploadMat4;break;case t.SAMPLER_2D:case t.SAMPLER_CUBE:case t.SAMPLER_2D_ARRAY:case t.SAMPLER_2D_SHADOW:switch(s){case t.SAMPLER_2D:a=e._engine._magentaTexture2D;break;case t.SAMPLER_CUBE:a=e._engine._magentaTextureCube;break;case t.SAMPLER_2D_ARRAY:a=e._engine._magentaTexture2DArray;break;case t.SAMPLER_2D_SHADOW:a=e._engine._depthTexture2D,l.textureUseCompareMode=!0}if(u=!0,c){for(var d=Array(o),_=new Int32Array(o),f=Array(o),p=0;p<o;p++)d[p]=a,_[p]=e._activeTextureUint,f[p]=t.TEXTURE0+e._activeTextureUint++;l.textureDefault=d,l.textureIndex=f,l.applyFunc=l.uploadTextureArray,e.bind(),t.uniform1iv(h,_)}else{var g=t.TEXTURE0+e._activeTextureUint;l.textureDefault=a,l.textureIndex=g,l.applyFunc=l.uploadTexture,e.bind(),t.uniform1i(h,e._activeTextureUint++)}break;default:throw Error("Unsupported uniform type")}var m=cs._getShaderPropertyGroup(i);e._groupingUniform(l,m,u)}),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")},lU(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();cB._counter=0;var cI=function(t){function n(r,a,i){var o;for(var s in void 0===i&&(i={pipelineStage:e.PipelineStage.Forward}),(o=t.call(this)||this)._shaderPassId=0,o._renderStateDataMap={},o._shaderPassId=n._shaderPassCounter++,o._vertexSource=r,o._fragmentSource=a,i)o.setTag(s,i[s]);return o}return lk(n,t),n.prototype._getShaderProgram=function(t,n){var r=t._getShaderProgramPool(this),a=r.get(n);if(a)return a;var i=t._hardwareRenderer.isWebGL2,o=[];cw._getNamesByMacros(n,o);var s=cF.parseCustomMacros(o),l=i?"#version 300 es":"#version 100",c=i?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",u="\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n #else\n precision mediump float;\n precision mediump int;\n #endif\n ";t._hardwareRenderer.canIUse(e.GLCapabilityType.shaderTextureLod)&&(u+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(u+="#define HAS_DERIVATIVES\n");var h=" "+l+"\n "+c+"\n "+s+"\n "+cF.parseIncludes(this._vertexSource),d=" "+l+"\n "+c+"\n "+(i?"":cF.parseExtension(cH._shaderExtension))+"\n "+u+"\n "+s+"\n "+cF.parseIncludes(this._fragmentSource);return i&&(h=cF.convertTo300(h),d=cF.convertTo300(d,!0)),a=new cB(t,h,d),r.cache(a),a},n}(cP);cI._shaderPassCounter=0;var cV=(lk(e9=function(e,t,n){var r;if((r=cP.call(this)||this).name=e,t.length<1)throw" count must large than 0.";for(var a in r._passes=t.slice(),n)r.setTag(a,n[a]);return r},cP),lU(e9,[{key:"passes",get:function(){return this._passes}}]),e9),cO=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},cN=((tt=(te=function(){this.targetBlendState=new cO,this.blendColor=new lB(0,0,0,0),this.alphaToCoverage=!1}).prototype)._applyShaderDataValue=function(t,n){var r,a,i,o,s,l,c,u=this.targetBlendState,h=t[e.RenderStateDataKey.BlendStateEnabled0];if(void 0!==h){var d=n.getFloat(h);u.enabled=void 0!==d&&!!d}var _=t[e.RenderStateDataKey.BlendStateColorBlendOperation0];void 0!==_&&(u.colorBlendOperation=null!=(r=n.getFloat(_))?r:e.BlendOperation.Add);var f=t[e.RenderStateDataKey.BlendStateAlphaBlendOperation0];void 0!==f&&(u.alphaBlendOperation=null!=(a=n.getFloat(f))?a:e.BlendOperation.Add);var p=t[e.RenderStateDataKey.BlendStateSourceColorBlendFactor0];void 0!==p&&(u.sourceColorBlendFactor=null!=(i=n.getFloat(p))?i:e.BlendFactor.One);var g=t[e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0];void 0!==g&&(u.sourceAlphaBlendFactor=null!=(o=n.getFloat(g))?o:e.BlendFactor.One);var m=t[e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0];void 0!==m&&(u.destinationColorBlendFactor=null!=(s=n.getFloat(m))?s:e.BlendFactor.Zero);var v=t[e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0];void 0!==v&&(u.destinationAlphaBlendFactor=null!=(l=n.getFloat(v))?l:e.BlendFactor.Zero);var y=t[e.RenderStateDataKey.BlendStateColorWriteMask0];void 0!==y&&(u.colorWriteMask=null!=(c=n.getFloat(y))?c:e.ColorWriteMask.All);var x=t[e.RenderStateDataKey.BlendStateBlendColor];if(void 0!==x){var T=n.getColor(x);void 0!==T&&this.blendColor.copyFrom(T)}var S=t[e.RenderStateDataKey.BlendStateAlphaToCoverage];if(void 0!==S){var C=n.getFloat(S);this.alphaToCoverage=void 0!==C&&!!C}},tt._apply=function(e,t){this._platformApply(e,t.blendState)},tt._platformApply=function(t,n){var r=t.gl,a=n.targetBlendState,i=this.targetBlendState,o=i.enabled,s=i.colorBlendOperation,l=i.alphaBlendOperation,c=i.sourceColorBlendFactor,u=i.destinationColorBlendFactor,h=i.sourceAlphaBlendFactor,d=i.destinationAlphaBlendFactor,_=i.colorWriteMask;if(o!==a.enabled&&(o?r.enable(r.BLEND):r.disable(r.BLEND),a.enabled=o),o){(c!==a.sourceColorBlendFactor||u!==a.destinationColorBlendFactor||h!==a.sourceAlphaBlendFactor||d!==a.destinationAlphaBlendFactor)&&(r.blendFuncSeparate(te._getGLBlendFactor(t,c),te._getGLBlendFactor(t,u),te._getGLBlendFactor(t,h),te._getGLBlendFactor(t,d)),a.sourceColorBlendFactor=c,a.destinationColorBlendFactor=u,a.sourceAlphaBlendFactor=h,a.destinationAlphaBlendFactor=d),(s!==a.colorBlendOperation||l!==a.alphaBlendOperation)&&(r.blendEquationSeparate(te._getGLBlendOperation(t,s),te._getGLBlendOperation(t,l)),a.colorBlendOperation=s,a.alphaBlendOperation=l);var f=this.blendColor;lB.equals(n.blendColor,f)||(r.blendColor(f.r,f.g,f.b,f.a),n.blendColor.copyFrom(f))}_!==a.colorWriteMask&&(r.colorMask((_&e.ColorWriteMask.Red)!=0,(_&e.ColorWriteMask.Green)!=0,(_&e.ColorWriteMask.Blue)!=0,(_&e.ColorWriteMask.Alpha)!=0),a.colorWriteMask=_);var p=this.alphaToCoverage;p!==n.alphaToCoverage&&(p?r.enable(r.SAMPLE_ALPHA_TO_COVERAGE):r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n.alphaToCoverage=p)},te._getGLBlendFactor=function(t,n){var r=t.gl;switch(n){case e.BlendFactor.Zero:return r.ZERO;case e.BlendFactor.One:return r.ONE;case e.BlendFactor.SourceColor:return r.SRC_COLOR;case e.BlendFactor.OneMinusSourceColor:return r.ONE_MINUS_SRC_COLOR;case e.BlendFactor.DestinationColor:return r.DST_COLOR;case e.BlendFactor.OneMinusDestinationColor:return r.ONE_MINUS_DST_COLOR;case e.BlendFactor.SourceAlpha:return r.SRC_ALPHA;case e.BlendFactor.OneMinusSourceAlpha:return r.ONE_MINUS_SRC_ALPHA;case e.BlendFactor.DestinationAlpha:return r.DST_ALPHA;case e.BlendFactor.OneMinusDestinationAlpha:return r.ONE_MINUS_DST_ALPHA;case e.BlendFactor.SourceAlphaSaturate:return r.SRC_ALPHA_SATURATE;case e.BlendFactor.BlendColor:return r.CONSTANT_COLOR;case e.BlendFactor.OneMinusBlendColor:return r.ONE_MINUS_CONSTANT_COLOR}},te._getGLBlendOperation=function(t,n){var r=t.gl;switch(n){case e.BlendOperation.Add:return r.FUNC_ADD;case e.BlendOperation.Subtract:return r.FUNC_SUBTRACT;case e.BlendOperation.ReverseSubtract:return r.FUNC_REVERSE_SUBTRACT;case e.BlendOperation.Min:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Min is not supported in this context");return r.MIN;case e.BlendOperation.Max:if(!t.canIUse(e.GLCapabilityType.blendMinMax))throw Error("BlendOperation.Max is not supported in this context");return r.MAX}},te),cU=((tr=(tn=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._applyShaderDataValue=function(t,n){var r,a=t[e.RenderStateDataKey.DepthStateEnabled];if(void 0!==a){var i=n.getFloat(a);this.enabled=void 0!==i&&!!i}var o=t[e.RenderStateDataKey.DepthStateWriteEnabled];if(void 0!==o){var s=n.getFloat(o);this.writeEnabled=void 0!==s&&!!s}var l=t[e.RenderStateDataKey.DepthStateCompareFunction];void 0!==l&&(this.compareFunction=null!=(r=n.getFloat(l))?r:e.CompareFunction.Less)},tr._apply=function(e,t){this._platformApply(e,t.depthState)},tr._platformApply=function(e,t){var n=e.gl,r=this.enabled,a=this.compareFunction,i=this.writeEnabled;r!=t.enabled&&(r?n.enable(n.DEPTH_TEST):n.disable(n.DEPTH_TEST),t.enabled=r),r&&(a!=t.compareFunction&&(n.depthFunc(tn._getGLCompareFunction(e,a)),t.compareFunction=a),i!=t.writeEnabled&&(n.depthMask(i),t.writeEnabled=i))},tn._getGLCompareFunction=function(t,n){var r=t.gl;switch(n){case e.CompareFunction.Never:return r.NEVER;case e.CompareFunction.Less:return r.LESS;case e.CompareFunction.Equal:return r.EQUAL;case e.CompareFunction.LessEqual:return r.LEQUAL;case e.CompareFunction.Greater:return r.GREATER;case e.CompareFunction.NotEqual:return r.NOTEQUAL;case e.CompareFunction.GreaterEqual:return r.GEQUAL;case e.CompareFunction.Always:return r.ALWAYS}},tn),cz=((ti=(ta=function(){this.cullMode=e.CullMode.Back,this.depthBias=0,this.slopeScaledDepthBias=0,this._cullFaceEnable=!0,this._frontFaceInvert=!1}).prototype)._applyShaderDataValue=function(t,n){var r,a,i,o=t[e.RenderStateDataKey.RasterStateCullMode];void 0!==o&&(this.cullMode=null!=(r=n.getFloat(o))?r:e.CullMode.Back);var s=t[e.RenderStateDataKey.RasterStateDepthBias];void 0!==s&&(this.depthBias=null!=(a=n.getFloat(s))?a:0);var l=t[e.RenderStateDataKey.RasterStateSlopeScaledDepthBias];void 0!==l&&(this.slopeScaledDepthBias=null!=(i=n.getFloat(l))?i:0)},ti._apply=function(e,t,n){this._platformApply(e,t.rasterState,n)},ti._platformApply=function(t,n,r){var a=t.gl,i=this.cullMode,o=this.depthBias,s=this.slopeScaledDepthBias,l=i!==e.CullMode.Off;l!==n._cullFaceEnable&&(l?a.enable(a.CULL_FACE):a.disable(a.CULL_FACE),n._cullFaceEnable=l),l&&i!==n.cullMode&&(i==e.CullMode.Back?a.cullFace(a.BACK):a.cullFace(a.FRONT),n.cullMode=i),r!==n._frontFaceInvert&&(r?a.frontFace(a.CW):a.frontFace(a.CCW),n._frontFaceInvert=r),t._enableGlobalDepthBias||o===n.depthBias&&s===n.slopeScaledDepthBias||(0!==o||0!==s?(a.enable(a.POLYGON_OFFSET_FILL),a.polygonOffset(s,o)):a.disable(a.POLYGON_OFFSET_FILL),n.depthBias=o,n.slopeScaledDepthBias=s)},ta),ck=((ts=(to=function(){this.enabled=!1,this.referenceValue=0,this.mask=255,this.writeMask=255,this.compareFunctionFront=e.CompareFunction.Always,this.compareFunctionBack=e.CompareFunction.Always,this.passOperationFront=e.StencilOperation.Keep,this.passOperationBack=e.StencilOperation.Keep,this.failOperationFront=e.StencilOperation.Keep,this.failOperationBack=e.StencilOperation.Keep,this.zFailOperationFront=e.StencilOperation.Keep,this.zFailOperationBack=e.StencilOperation.Keep}).prototype)._applyShaderDataValue=function(t,n){var r,a,i,o,s,l,c,u,h,d,_,f=t[e.RenderStateDataKey.StencilStateEnabled];if(void 0!==f){var p=n.getFloat(f);this.enabled=void 0!==p&&!!p}var g=t[e.RenderStateDataKey.StencilStateReferenceValue];void 0!==g&&(this.referenceValue=null!=(r=n.getFloat(g))?r:0);var m=t[e.RenderStateDataKey.StencilStateMask];void 0!==m&&(this.mask=null!=(a=n.getFloat(m))?a:255);var v=t[e.RenderStateDataKey.StencilStateWriteMask];void 0!==v&&(this.writeMask=null!=(i=n.getFloat(v))?i:255);var y=t[e.RenderStateDataKey.StencilStateCompareFunctionFront];void 0!==y&&(this.compareFunctionFront=null!=(o=n.getFloat(y))?o:e.CompareFunction.Always);var x=t[e.RenderStateDataKey.StencilStateCompareFunctionBack];void 0!==x&&(this.compareFunctionBack=null!=(s=n.getFloat(x))?s:e.CompareFunction.Always);var T=t[e.RenderStateDataKey.StencilStatePassOperationFront];void 0!==T&&(this.passOperationFront=null!=(l=n.getFloat(T))?l:e.StencilOperation.Keep);var S=t[e.RenderStateDataKey.StencilStatePassOperationBack];void 0!==S&&(this.passOperationBack=null!=(c=n.getFloat(S))?c:e.StencilOperation.Keep);var C=t[e.RenderStateDataKey.StencilStateFailOperationFront];void 0!==C&&(this.failOperationFront=null!=(u=n.getFloat(C))?u:e.StencilOperation.Keep);var A=t[e.RenderStateDataKey.StencilStateFailOperationBack];void 0!==A&&(this.failOperationBack=null!=(h=n.getFloat(A))?h:e.StencilOperation.Keep);var w=t[e.RenderStateDataKey.StencilStateZFailOperationFront];void 0!==w&&(this.zFailOperationFront=null!=(d=n.getFloat(w))?d:e.StencilOperation.Keep);var E=t[e.RenderStateDataKey.StencilStateZFailOperationBack];void 0!==E&&(this.zFailOperationBack=null!=(_=n.getFloat(E))?_:e.StencilOperation.Keep)},ts._apply=function(e,t){this._platformApply(e,t.stencilState)},ts._platformApply=function(e,t){var n=e.gl,r=this.enabled,a=this.referenceValue,i=this.mask,o=this.compareFunctionFront,s=this.compareFunctionBack,l=this.failOperationFront,c=this.zFailOperationFront,u=this.passOperationFront,h=this.failOperationBack,d=this.zFailOperationBack,_=this.passOperationBack,f=this.writeMask;if(r!=t.enabled&&(r?n.enable(n.STENCIL_TEST):n.disable(n.STENCIL_TEST),t.enabled=r),r){var p=a!==t.referenceValue||i!==t.mask;(p||o!==t.compareFunctionFront)&&(n.stencilFuncSeparate(n.FRONT,to._getGLCompareFunction(e,o),a,i),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(n.stencilFuncSeparate(n.BACK,to._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)&&(n.stencilOpSeparate(n.FRONT,to._getGLStencilOperation(e,l),to._getGLStencilOperation(e,c),to._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(h!==t.failOperationBack||d!==t.zFailOperationBack||_!==t.passOperationBack)&&(n.stencilOpSeparate(n.BACK,to._getGLStencilOperation(e,h),to._getGLStencilOperation(e,d),to._getGLStencilOperation(e,_)),t.failOperationBack=h,t.zFailOperationBack=d,t.passOperationBack=_),f!==t.writeMask&&(n.stencilMask(f),t.writeMask=f)}},to._getGLCompareFunction=function(t,n){var r=t.gl;switch(n){case e.CompareFunction.Never:return r.NEVER;case e.CompareFunction.Less:return r.LESS;case e.CompareFunction.Equal:return r.EQUAL;case e.CompareFunction.LessEqual:return r.LEQUAL;case e.CompareFunction.Greater:return r.GREATER;case e.CompareFunction.NotEqual:return r.NOTEQUAL;case e.CompareFunction.GreaterEqual:return r.GEQUAL;case e.CompareFunction.Always:return r.ALWAYS}},to._getGLStencilOperation=function(t,n){var r=t.gl;switch(n){case e.StencilOperation.Keep:return r.KEEP;case e.StencilOperation.Zero:return r.ZERO;case e.StencilOperation.Replace:return r.REPLACE;case e.StencilOperation.IncrementSaturate:return r.INCR;case e.StencilOperation.DecrementSaturate:return r.DECR;case e.StencilOperation.Invert:return r.INVERT;case e.StencilOperation.IncrementWrap:return r.INCR_WRAP;case e.StencilOperation.DecrementWrap:return r.DECR_WRAP}},to),cG=((tc=(tl=function(){this.blendState=new cN,this.depthState=new cU,this.stencilState=new ck,this.rasterState=new cz,this.renderQueueType=e.RenderQueueType.Opaque}).prototype)._applyShaderDataValue=function(e,t){this.blendState._applyShaderDataValue(e,t),this.depthState._applyShaderDataValue(e,t),this.stencilState._applyShaderDataValue(e,t),this.rasterState._applyShaderDataValue(e,t)},tc._apply=function(e,t,n,r){n&&this._applyShaderDataValue(n,r);var a=e._hardwareRenderer,i=e._lastRenderState;this.blendState._apply(a,i),this.depthState._apply(a,i),this.stencilState._apply(a,i),this.rasterState._apply(a,i,t)},tl),cH=((tu=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var n=tu._compileMacros;n.clear();for(var r=0,a=t.length;r<a;r++)n.enable(cw.getByName(t[r]));for(var i=this._subShaders,o=0,s=i.length;o<s;o++){for(var l=void 0,c=i[o].passes,u=0,h=c.length;u<h;u++)void 0===l?l=c[u]._getShaderProgram(e,n).isValid:l&&(l=c[u]._getShaderProgram(e,n).isValid);if(l)return!0}return!1},tu.create=function(e,t,n){var r,a=tu._shaderMap;if(t){if(a[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var i=new cI(t,n);r=new tu(e,[new cV("Default",[i])])}else if(t.length>0)r=t[0].constructor===cI?new tu(e,[new cV("Default",t)]):new tu(e,t.slice());else throw"SubShader or ShaderPass count must large than 0."}else{if(!tu._shaderLab)throw"ShaderLab has not been set up yet.";var o=tu._shaderLab.parseShader(e),s=o.subShaders.map(function(e){var t=e.passes.map(function(e){var t=new cI(e.vertexSource,e.fragmentSource,e.tags),n=e.renderStates,r=new cG;t._renderState=r;var a=n[0];for(var i in a)tu._applyConstRenderStates(r,i,a[i]);var o=n[1],s={};for(var l in o)s[l]=cs.getByName(o[l]);return t._renderStateDataMap=s,t});return new cV(o.name,t,e.tags)});return r=new tu(o.name,s),a[o.name]=r,r}return a[e]=r,r},tu.find=function(e){return tu._shaderMap[e]},tu._applyConstRenderStates=function(t,n,r){switch(n){case e.RenderStateDataKey.BlendStateEnabled0:t.blendState.targetBlendState.enabled=r;break;case e.RenderStateDataKey.BlendStateColorBlendOperation0:t.blendState.targetBlendState.colorBlendOperation=r;break;case e.RenderStateDataKey.BlendStateAlphaBlendOperation0:t.blendState.targetBlendState.alphaBlendOperation=r;break;case e.RenderStateDataKey.BlendStateSourceColorBlendFactor0:t.blendState.targetBlendState.sourceColorBlendFactor=r;break;case e.RenderStateDataKey.BlendStateDestinationColorBlendFactor0:t.blendState.targetBlendState.destinationColorBlendFactor=r;break;case e.RenderStateDataKey.BlendStateSourceAlphaBlendFactor0:t.blendState.targetBlendState.sourceAlphaBlendFactor=r;break;case e.RenderStateDataKey.BlendStateDestinationAlphaBlendFactor0:t.blendState.targetBlendState.destinationAlphaBlendFactor=r;break;case e.RenderStateDataKey.BlendStateColorWriteMask0:t.blendState.targetBlendState.colorWriteMask=r;break;case e.RenderStateDataKey.DepthStateEnabled:t.depthState.enabled=r;break;case e.RenderStateDataKey.DepthStateWriteEnabled:t.depthState.writeEnabled=r;break;case e.RenderStateDataKey.DepthStateCompareFunction:t.depthState.compareFunction=r;break;case e.RenderStateDataKey.StencilStateEnabled:t.stencilState.enabled=r;break;case e.RenderStateDataKey.StencilStateReferenceValue:t.stencilState.referenceValue=r;break;case e.RenderStateDataKey.StencilStateMask:t.stencilState.mask=r;break;case e.RenderStateDataKey.StencilStateWriteMask:t.stencilState.writeMask=r;break;case e.RenderStateDataKey.StencilStateCompareFunctionFront:t.stencilState.compareFunctionFront=r;break;case e.RenderStateDataKey.StencilStateCompareFunctionBack:t.stencilState.compareFunctionBack=r;break;case e.RenderStateDataKey.StencilStatePassOperationFront:t.stencilState.passOperationFront=r;break;case e.RenderStateDataKey.StencilStatePassOperationBack:t.stencilState.passOperationBack=r;break;case e.RenderStateDataKey.StencilStateFailOperationFront:t.stencilState.failOperationFront=r;break;case e.RenderStateDataKey.StencilStateFailOperationBack:t.stencilState.failOperationBack=r;break;case e.RenderStateDataKey.StencilStateZFailOperationFront:t.stencilState.zFailOperationFront=r;break;case e.RenderStateDataKey.StencilStateZFailOperationBack:t.stencilState.zFailOperationBack=r;break;case e.RenderStateDataKey.RasterStateCullMode:t.rasterState.cullMode=r;break;case e.RenderStateDataKey.RasterStateDepthBias:t.rasterState.depthBias=r;break;case e.RenderStateDataKey.RasterStateSlopeScaledDepthBias:t.rasterState.slopeScaledDepthBias=r}},tu.getMacroByName=function(e,t){return cw.getByName(e,t)},tu.getPropertyByName=function(e){return cs.getByName(e)},lU(tu,[{key:"subShaders",get:function(){return this._subShaders}}]),tu);cH._compileMacros=new cE,cH._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],cH._shaderMap=Object.create(null);var cW=((td=(th=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new cE,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},td.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},td.getInt=function(e){return this.getPropertyValue(e)},td.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},td.getFloatArray=function(e){return this.getPropertyValue(e)},td.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},td.getIntArray=function(e){return this.getPropertyValue(e)},td.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},td.getVector2=function(e){return this.getPropertyValue(e)},td.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},td.getVector3=function(e){return this.getPropertyValue(e)},td.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},td.getVector4=function(e){return this.getPropertyValue(e)},td.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},td.getMatrix=function(e){return this.getPropertyValue(e)},td.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},td.getColor=function(e){return this.getPropertyValue(e)},td.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},td.getTexture=function(e){return this.getPropertyValue(e)},td.setTexture=function(t,n){if(this._getReferCount()>0){var r=this.getPropertyValue(t);r&&r._addReferCount(-1),n&&n._addReferCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,n)},td.getTextureArray=function(e){return this.getPropertyValue(e)},td.setTextureArray=function(t,n){if(this._getReferCount()>0){var r=this.getPropertyValue(t);if(r)for(var a=0,i=r.length;a<i;a++)r[a]._addReferCount(-1);if(n)for(var o=0,s=n.length;o<s;o++)n[o]._addReferCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,n)},td.getPropertyValue=function(e){return"string"==typeof e&&(e=cs.getByName(e)),this._propertyValueMap[e._uniqueId]},td.enableMacro=function(e,t){"string"==typeof e&&(e=cw.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}},td.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=cw._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},td.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])},td.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=cs._propertyIdMap;for(var a in n)t.push(r[a]);if(!e)return t},td.clone=function(){var e=new th(this._group);return this.cloneTo(e),e},td.cloneTo=function(e){lQ.deepCloneObject(this._macroCollection,e._macroCollection),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(lX(l,l6))r[s]=l,t>0&&l._addReferCount(t);else if(lX(l,Array)||lX(l,Float32Array)||lX(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},td._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=cs.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 "+sB[t._group]+" group."}if(t._type!==n){if(void 0===t._type)t._type=n;else throw"Shader property "+t.name+" has been used as "+e.ShaderPropertyType[t._type]+" type."}this._propertyValueMap[t._uniqueId]=r},td._getReferCount=function(){return this._refCount},td._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&lX(r,l6)&&r._addReferCount(e)}},th),cX=((t_=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(t_._viewMatrixProperty,e.viewMatrix),t.setMatrix(t_._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(t_.vpMatrixProperty,e.viewProjectionMatrix)},t_);cX.vpMatrixProperty=cs.getByName("camera_VPMat"),cX.pipelineStageKey=cR.getByName("pipelineStage"),cX._viewMatrixProperty=cs.getByName("camera_ViewMat"),cX._projectionMatrixProperty=cs.getByName("camera_ProjMat");var cK=((tp=(tf=function(){}).prototype).set=function(e,t){this.data=e,this.shaderPasses=t},tp.dispose=function(){this.data=this.shaderPasses=null},tf);function cj(){return function(e){}}e.SpriteMaskInteraction=void 0,(tg=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[tg.None=0]="None",tg[tg.VisibleInsideMask=1]="VisibleInsideMask",tg[tg.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(lk(tm=function(t){(n=cc.call(this,t)||this)._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new cE,n._bounds=new lA,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._shaderData=new cW(sB.Renderer),n._mvMatrix=new lR,n._mvpMatrix=new lR,n._mvInvMatrix=new lR,n._normalMatrix=new lR,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new lD,n.castShadows=!0;var n,r=e.Renderer.prototype,a=n.shaderData;return n._overrideUpdate=n.update!==r.update,a._addReferCount(1),n._onTransformChanged=n._onTransformChanged.bind(lO(n)),n._registerEntityTransformListener(),a.enableMacro(e.Renderer._receiveShadowMacro),a.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},cc),(tv=tm.prototype).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},tv.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},tv.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},tv.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},tv.getMaterials=function(){return this._materials},tv.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&&o._addReferCount(-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&&l._addReferCount(-1),c&&c._addReferCount(1))}},tv.update=function(e){},tv._onEnableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},tv._onDisableInScene=function(){var e=this.scene._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},tv._prepareRender=function(t){var n=t.virtualCamera,r=n.position,a=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(lS.subtract(a,r,a),this._distanceForSort=lS.dot(a,n.forward)):this._distanceForSort=lS.distanceSquared(a,r),this._updateShaderData(t),this._render(t),cE.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},tv._cloneTo=function(e,t,n){for(var r=this._materials,a=0,i=r.length;a<i;a++)e._setMaterial(a,r[a])},tv._onDestroy=function(){cc.prototype._onDestroy.call(this),this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged),this.shaderData._addReferCount(-1);for(var e,t=this._materials,n=0,r=t.length;n<r;n++)null==(e=t[n])||e._addReferCount(-1);this._entity=null,this._globalShaderMacro=null,this._bounds=null,this._materials=null,this._shaderData=null,this._mvMatrix=null,this._mvpMatrix=null,this._mvInvMatrix=null,this._normalMatrix=null,this._materialsInstanced=null,this._rendererLayer=null},tv._updateShaderData=function(e){var t=this.entity,n=t.transform.worldMatrix;this._updateTransformShaderData(e,n);var r=t.layer;this._rendererLayer.set(65535&r,r>>>16&65535,0,0)},tv._updateTransformShaderData=function(t,n){var r=this.shaderData,a=t.virtualCamera,i=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;lR.multiply(a.viewMatrix,n,i),lR.multiply(a.viewProjectionMatrix,n,o),lR.invert(i,s),lR.invert(n,l),l.transpose(),r.setMatrix(e.Renderer._localMatrixProperty,this.entity.transform.localMatrix),r.setMatrix(e.Renderer._worldMatrixProperty,n),r.setMatrix(e.Renderer._mvMatrixProperty,i),r.setMatrix(e.Renderer._mvpMatrixProperty,o),r.setMatrix(e.Renderer._mvInvMatrixProperty,s),r.setMatrix(e.Renderer._normalMatrixProperty,l)},tv._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},tv._updateBounds=function(e){},tv._render=function(e){throw"not implement"},tv._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",e._addReferCount(-1),n._addReferCount(1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},tv._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&&r._addReferCount(-1),t&&t._addReferCount(1),n[e]=t}},tv._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},lU(tm,[{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,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}}]),(sI=tm)._tempVector0=new lS,sI._receiveShadowMacro=cw.getByName("RENDERER_IS_RECEIVE_SHADOWS"),sI._localMatrixProperty=cs.getByName("renderer_LocalMat"),sI._worldMatrixProperty=cs.getByName("renderer_ModelMat"),sI._mvMatrixProperty=cs.getByName("renderer_MVMat"),sI._mvpMatrixProperty=cs.getByName("renderer_MVPMat"),sI._mvInvMatrixProperty=cs.getByName("renderer_MVInvMat"),sI._normalMatrixProperty=cs.getByName("renderer_NormalMat"),sI._rendererLayerProperty=cs.getByName("renderer_Layer"),sI),lW([lK],e.Renderer.prototype,"_distanceForSort",void 0),lW([lK],e.Renderer.prototype,"_onUpdateIndex",void 0),lW([lK],e.Renderer.prototype,"_rendererIndex",void 0),lW([lK],e.Renderer.prototype,"_globalShaderMacro",void 0),lW([lY],e.Renderer.prototype,"_bounds",void 0),lW([lK],e.Renderer.prototype,"_renderFrameCount",void 0),lW([lK],e.Renderer.prototype,"_overrideUpdate",void 0),lW([lK],e.Renderer.prototype,"_materials",void 0),lW([lK],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),lW([lY],e.Renderer.prototype,"_shaderData",void 0),lW([lK],e.Renderer.prototype,"_mvMatrix",void 0),lW([lK],e.Renderer.prototype,"_mvpMatrix",void 0),lW([lK],e.Renderer.prototype,"_mvInvMatrix",void 0),lW([lK],e.Renderer.prototype,"_normalMatrix",void 0),lW([lK],e.Renderer.prototype,"_materialsInstanced",void 0),lW([lK],e.Renderer.prototype,"_priority",void 0),lW([lj],e.Renderer.prototype,"_receiveShadows",void 0),lW([lK],e.Renderer.prototype,"_rendererLayer",void 0),lW([lK],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=lW([ch(cy,e.DependentMode.CheckOnly)],e.Renderer),(ty=sV||(sV={}))[ty.WorldVolume=1]="WorldVolume";var cq=((tx=function(){}).resetData=function(e){var t=e._verticesData,n=t.vertexCount=4,r=t.positions,a=t.uvs;if(r.length<n)for(var i=r.length;i<n;i++)r.push(new lS),a.push(new lL);t.triangles=cq._rectangleTriangles},tx.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,a=r.pivot,i=a.x,o=a.y,s=cq._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,u=e.flipX?-t:t,h=e.flipY?-n:n;l[0]=c[0]*u,l[1]=c[1]*u,l[2]=c[2]*u,l[4]=c[4]*h,l[5]=c[5]*h,l[6]=c[6]*h,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 d=r._getPositions(),_=e._verticesData.positions,f=0;f<4;f++){var p=d[f],g=p.x,m=p.y;_[f].set(l[0]*g+l[4]*m+l[12],l[1]*g+l[5]*m+l[13],l[2]*g+l[6]*m+l[14])}lA.transform(r._getBounds(),s,e._bounds)},tx.updateUVs=function(e){var t=e.sprite._getUVs(),n=e._verticesData.uvs,r=t[0],a=r.x,i=r.y,o=t[3],s=o.x,l=o.y;n[0].set(a,i),n[1].set(s,i),n[2].set(a,l),n[3].set(s,l)},(sO=tx)._rectangleTriangles=[0,1,2,2,1,3],sO._worldMatrix=new lR,sO);cq=lW([cj()],cq);var cY=function(e,t,n,r,a){void 0===r&&(r=null),void 0===a&&(a=null),this.vertexCount=e,this.positions=t,this.uvs=n,this.triangles=r,this.color=a};e.SpriteMaskLayer=void 0,(tT=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[tT.Layer0=1]="Layer0",tT[tT.Layer1=2]="Layer1",tT[tT.Layer2=4]="Layer2",tT[tT.Layer3=8]="Layer3",tT[tT.Layer4=16]="Layer4",tT[tT.Layer5=32]="Layer5",tT[tT.Layer6=64]="Layer6",tT[tT.Layer7=128]="Layer7",tT[tT.Layer8=256]="Layer8",tT[tT.Layer9=512]="Layer9",tT[tT.Layer10=1024]="Layer10",tT[tT.Layer11=2048]="Layer11",tT[tT.Layer12=4096]="Layer12",tT[tT.Layer13=8192]="Layer13",tT[tT.Layer14=16384]="Layer14",tT[tT.Layer15=32768]="Layer15",tT[tT.Layer16=65536]="Layer16",tT[tT.Layer17=131072]="Layer17",tT[tT.Layer18=262144]="Layer18",tT[tT.Layer19=524288]="Layer19",tT[tT.Layer20=1048576]="Layer20",tT[tT.Layer21=2097152]="Layer21",tT[tT.Layer22=4194304]="Layer22",tT[tT.Layer23=8388608]="Layer23",tT[tT.Layer24=16777216]="Layer24",tT[tT.Layer25=33554432]="Layer25",tT[tT.Layer26=67108864]="Layer26",tT[tT.Layer27=134217728]="Layer27",tT[tT.Layer28=268435456]="Layer28",tT[tT.Layer29=536870912]="Layer29",tT[tT.Layer30=1073741824]="Layer30",tT[tT.Layer31=2147483648]="Layer31",tT[tT.Everything=4294967295]="Everything",(tS=sN||(sN={}))[tS.texture=1]="texture",tS[tS.size=2]="size",tS[tS.atlasRotate=4]="atlasRotate",tS[tS.atlasRegion=8]="atlasRegion",tS[tS.atlasRegionOffset=16]="atlasRegionOffset",tS[tS.region=32]="region",tS[tS.pivot=64]="pivot",tS[tS.border=128]="border";var cQ=function(t){function n(r){var a;return(a=t.call(this,r)||this).influenceLayers=e.SpriteMaskLayer.Everything,a._sprite=null,a._automaticWidth=0,a._automaticHeight=0,a._customWidth=void 0,a._customHeight=void 0,a._flipX=!1,a._flipY=!1,a._alphaCutoff=.5,a._verticesData=new cY(4,[],[]),cq.resetData(lO(a)),a.setMaterial(a._engine._spriteMaskDefaultMaterial),a.shaderData.setFloat(n._alphaCutoffProperty,a._alphaCutoff),a._onSpriteChange=a._onSpriteChange.bind(lO(a)),a}lk(n,t);var r=n.prototype;return r._cloneTo=function(e,n,r){t.prototype._cloneTo.call(this,e,n,r),e.sprite=this._sprite},r._updateBounds=function(e){this.sprite?cq.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},r._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&sV.WorldVolume&&(cq.updatePositions(this),this._dirtyUpdateFlag&=~sV.WorldVolume),2&this._dirtyUpdateFlag&&(cq.updateUVs(this),this._dirtyUpdateFlag&=-3),e.camera._renderPipeline._allSpriteMasks.add(this);var t,n=this._engine._spriteMaskRenderDataPool.getFromPool(),r=this.getMaterial();n.set(this,r,this._verticesData);var a=this._engine._renderElementPool.getFromPool();a.set(n,r.shader.subShaders[0].passes),this._maskElement=a}},r._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._sprite=null,this._verticesData=null},r._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},r._onSpriteChange=function(e){switch(e){case sN.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case sN.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sV.WorldVolume);break;case sN.region:case sN.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sN.atlasRegion:this._dirtyUpdateFlag|=2;break;case sN.pivot:this._dirtyUpdateFlag|=sV.WorldVolume}},lU(n,[{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|=sV.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|=sV.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sV.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sV.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(n._textureProperty,e.texture)):this.shaderData.setTexture(n._textureProperty,null),this._sprite=e)}},{key:"alphaCutoff",get:function(){return this._alphaCutoff},set:function(e){this._alphaCutoff!==e&&(this._alphaCutoff=e,this.shaderData.setFloat(n._alphaCutoffProperty,e))}}]),n}(e.Renderer);cQ._textureProperty=cs.getByName("renderer_MaskTexture"),cQ._alphaCutoffProperty=cs.getByName("renderer_MaskAlphaCutoff"),lW([lj],cQ.prototype,"influenceLayers",void 0),lW([lK],cQ.prototype,"_sprite",void 0),lW([lK],cQ.prototype,"_automaticWidth",void 0),lW([lK],cQ.prototype,"_automaticHeight",void 0),lW([lj],cQ.prototype,"_customWidth",void 0),lW([lj],cQ.prototype,"_customHeight",void 0),lW([lj],cQ.prototype,"_flipX",void 0),lW([lj],cQ.prototype,"_flipY",void 0),lW([lj],cQ.prototype,"_alphaCutoff",void 0),lW([lK],cQ.prototype,"_onSpriteChange",null),(tC=sU||(sU={}))[tC.UV=2]="UV",tC[tC.RenderData=3]="RenderData",tC[tC.AutomaticSize=4]="AutomaticSize",tC[tC.All=7]="All",e.VertexElementFormat=void 0,(tA=e.VertexElementFormat||(e.VertexElementFormat={}))[tA.Float=0]="Float",tA[tA.Vector2=1]="Vector2",tA[tA.Vector3=2]="Vector3",tA[tA.Vector4=3]="Vector4",tA[tA.Byte4=4]="Byte4",tA[tA.UByte4=5]="UByte4",tA[tA.NormalizedByte4=6]="NormalizedByte4",tA[tA.NormalizedUByte4=7]="NormalizedUByte4",tA[tA.Short2=8]="Short2",tA[tA.UShort2=9]="UShort2",tA[tA.NormalizedShort2=10]="NormalizedShort2",tA[tA.NormalizedUShort2=11]="NormalizedUShort2",tA[tA.Short4=12]="Short4",tA[tA.UShort4=13]="UShort4",tA[tA.NormalizedShort4=14]="NormalizedShort4",tA[tA.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(tw=e.IndexFormat||(e.IndexFormat={}))[tw.UInt8=0]="UInt8",tw[tw.UInt16=1]="UInt16",tw[tw.UInt32=2]="UInt32";var cJ=((tE=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}},tE._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tE._getElementInfo=function(t){var n,r,a,i=!1;switch(t){case e.VertexElementFormat.Float:n=1,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector2:n=2,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector3:n=3,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Vector4:n=4,r=e.DataType.FLOAT;break;case e.VertexElementFormat.Byte4:n=4,r=e.DataType.BYTE;break;case e.VertexElementFormat.UByte4:n=4,r=e.DataType.UNSIGNED_BYTE;break;case e.VertexElementFormat.NormalizedByte4:n=4,r=e.DataType.BYTE,i=!0,a=1/127;break;case e.VertexElementFormat.NormalizedUByte4:n=4,r=e.DataType.UNSIGNED_BYTE,i=!0,a=1/255;break;case e.VertexElementFormat.Short2:n=2,r=e.DataType.SHORT;break;case e.VertexElementFormat.UShort2:n=2,r=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort2:n=2,r=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort2:n=2,r=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535;break;case e.VertexElementFormat.Short4:n=4,r=e.DataType.SHORT;break;case e.VertexElementFormat.UShort4:n=4,r=e.DataType.UNSIGNED_SHORT;break;case e.VertexElementFormat.NormalizedShort4:n=4,r=e.DataType.SHORT,i=!0,a=1/32767;break;case e.VertexElementFormat.NormalizedUShort4:n=4,r=e.DataType.UNSIGNED_SHORT,i=!0,a=1/65535}return{size:n,type:r,normalized:i,normalizedScaleFactor:a}},tE),cZ=(lU(tb=function(e,t,n,r,a){void 0===a&&(a=0),this._attributeName=e,this._offset=t,this._format=n,this._bindingIndex=r,this._formatMetaInfo=cJ._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}}]),tb);e.BufferUsage=void 0,(tM=e.BufferUsage||(e.BufferUsage={}))[tM.Static=0]="Static",tM[tM.Dynamic=1]="Dynamic",tM[tM.Stream=2]="Stream",e.SetDataOptions=void 0,(tF=e.SetDataOptions||(e.SetDataOptions={}))[tF.None=0]="None",tF[tF.Discard=1]="Discard";var c$=(lk(tR=function(t,n,r,a,i){if(void 0===a&&(a=e.BufferUsage.Static),void 0===i&&(i=!1),(o=l0.call(this,t)||this)._dataUpdateManager=new cv,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:r.buffer).slice(0,s);o._data=new Uint8Array(l)}}return o},l0),(tP=tR.prototype).bind=function(){this._platformBuffer.bind()},tP.setData=function(t,n,r,a,i){if(void 0===n&&(n=0),void 0===r&&(r=0),void 0===i&&(i=e.SetDataOptions.None),this._platformBuffer.setData(this._byteLength,t,n,r,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+r*s:r,u=new Uint8Array(o,c,l);this._data.set(u,n)}}this._dataUpdateManager.dispatch()},tP.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},tP.markAsUnreadable=function(){this._data=null,this._readable=!1},tP._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},tP._onDestroy=function(){l0.prototype._onDestroy.call(this),this._platformBuffer.destroy()},lU(tR,[{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."}}]),tR);e.BufferBindFlag=void 0,(tL=e.BufferBindFlag||(e.BufferBindFlag={}))[tL.VertexBuffer=0]="VertexBuffer",tL[tL.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(tD=e.MeshTopology||(e.MeshTopology={}))[tD.Points=0]="Points",tD[tD.Lines=1]="Lines",tD[tD.LineLoop=2]="LineLoop",tD[tD.LineStrip=3]="LineStrip",tD[tD.Triangles=4]="Triangles",tD[tD.TriangleStrip=5]="TriangleStrip",tD[tD.TriangleFan=6]="TriangleFan";var c0=(lU(tB=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tB),c1=((tI=function(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=e.MeshTopology.Triangles),this.start=t,this.count=n,this.topology=r}).prototype.dispose=function(){},tI),c2=(lk(tV=function(e,t){(n=l0.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new cv,n._bounds=new lA,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(lO(n)),n._onBoundsChanged=n._onBoundsChanged.bind(lO(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},l0),(tO=tV.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new c1(t,n,r)),this._subMeshes.push(t),t},tO.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},tO.clearSubMesh=function(){this._subMeshes.length=0},tO._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},tO._addVertexElement=function(e){var t=this._vertexElementMap,n=this._vertexElements,r=e.semantic,a=t[r];a&&(console.warn("VertexElement "+r+" already exists."),n.splice(n.indexOf(a),1)),t[r]=e,n.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tO._removeVertexElement=function(e){var t=this._vertexElements,n=t[e];t.splice(e,1),delete this._vertexElementMap[n.semantic],this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tO._setVertexElement=function(e,t){var n=this._vertexElementMap,r=this._vertexElements,a=r[e];a&&delete n[a.semantic],n[t.semantic]=t,r[e]=t,this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tO._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.semantic]}n.length=e},tO._setVertexBufferBinding=function(e,t){var n,r=this._getReferCount();r>0&&(null==(n=this._vertexBufferBindings[e])||n.buffer._addReferCount(-r),null==t||t.buffer._addReferCount(r)),this._vertexBufferBindings[e]=t,this._bufferStructChanged=!0},tO._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tO._addReferCount=function(e){l0.prototype._addReferCount.call(this,e);for(var t,n,r=this._vertexBufferBindings,a=0,i=r.length;a<i;a++)null==(n=r[a])||n.buffer._addReferCount(e);null==(t=this._indexBufferBinding)||t._buffer._addReferCount(e)},tO._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this)},tO._onDestroy=function(){l0.prototype._onDestroy.call(this),this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},tO._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},tO._setIndexBufferBinding=function(e){var t=this._indexBufferBinding,n=this._getReferCount();n>0&&(null==t||t.buffer._addReferCount(-n),null==e||e.buffer._addReferCount(n)),e?(this._indexBufferBinding=e,this._glIndexType=cJ._getGLIndexType(e.format),this._glIndexByteCount=cJ._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},tO._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},lU(tV,[{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}}]),tV);(tN=sz||(sz={}))[tN.Bounds=1]="Bounds",tN[tN.VertexElements=2]="VertexElements";var c3=(lU(tU=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tU),c4=((tz=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new cv,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}).prototype._releaseData=function(){this._deltaPositions=null,this._deltaNormals=null,this._deltaTangents=null},lU(tz,[{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)}}]),tz);(tk=sk||(sk={}))[tk.Position=1]="Position",tk[tk.Normal=2]="Normal",tk[tk.Tangent=4]="Tangent",tk[tk.All=7]="All";var c5=((tH=(tG=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new cv,this._dataChangeManager=new cv,this._frames=[],this.name=e,this._frameDataChangeListener=this._frameDataChangeListener.bind(this)}).prototype).addFrame=function(e,t,n,r){if("number"==typeof e){var a=new c4(e,t,n,r);return this._addFrame(a),a}this._addFrame(e)},tH.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()},tH._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},tH._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(sk.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},tH._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))},tH._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},lU(tG,[{key:"frames",get:function(){return this._frames}}]),tG),c8=(lk(tW=function(){return c2.apply(this,arguments)},c2),(tX=tW.prototype).setVertexElements=function(e){this._setVertexElements(e)},tX.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 c3(e,t));var i=this._vertexBufferBindings;i.length<=n&&(i.length=n+1),this._setVertexBufferBinding(a?t:n,r)},tX.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])},tX.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new c0(e,t))),this._setIndexBufferBinding(n)},lU(tW,[{key:"instanceCount",get:function(){return this._instanceCount},set:function(e){this._instanceCount=e}},{key:"vertexBufferBindings",get:function(){return this._vertexBufferBindings}},{key:"indexBufferBinding",get:function(){return this._indexBufferBinding}},{key:"vertexElements",get:function(){return this._vertexElements}}]),tW),c6=(tK=e.Renderer,lk(tj=function(e){var t;return(t=tK.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(lO(t)),t},tK),(tq=tj.prototype)._onDestroy=function(){tK.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},tq._cloneTo=function(e,t,n){tK.prototype._cloneTo.call(this,e,t,n),e.mesh=this._mesh},tq._prepareRender=function(e){if(!this._mesh){l8.error("mesh is null.");return}tK.prototype._prepareRender.call(this,e)},tq._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;lA.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tq._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(tj._uvMacro),n.disableMacro(tj._uv1Macro),n.disableMacro(tj._normalMacro),n.disableMacro(tj._tangentMacro),n.disableMacro(tj._enableVertexColorMacro);for(var a=0,i=r.length;a<i;a++)switch(r[a].semantic){case"TEXCOORD_0":n.enableMacro(tj._uvMacro);break;case"TEXCOORD_1":n.enableMacro(tj._uv1Macro);break;case"NORMAL":n.enableMacro(tj._normalMacro);break;case"TANGENT":n.enableMacro(tj._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&n.enableMacro(tj._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._meshRenderDataPool,u=0,h=s.length;u<h;u++){var d=o[u];if(d){var _=c.getFromPool();_.set(this,d,t,s[u]),l.pushRenderData(e,_)}}},tq._setMesh=function(e){var t=this._mesh;t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tq._onMeshChanged=function(e){e&sz.Bounds&&(this._dirtyUpdateFlag|=sV.WorldVolume),e&sz.VertexElements&&(this._dirtyUpdateFlag|=2)},lU(tj,[{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)}}]),tj);c6._uvMacro=cw.getByName("RENDERER_HAS_UV"),c6._uv1Macro=cw.getByName("RENDERER_HAS_UV1"),c6._normalMacro=cw.getByName("RENDERER_HAS_NORMAL"),c6._tangentMacro=cw.getByName("RENDERER_HAS_TANGENT"),c6._enableVertexColorMacro=cw.getByName("RENDERER_ENABLE_VERTEXCOLOR"),lW([lK],c6.prototype,"_mesh",void 0),lW([lK],c6.prototype,"_onMeshChanged",null),(tY=sG||(sG={}))[tY.VertexElementMacro=2]="VertexElementMacro",tY[tY.All=3]="All";var c7=((tJ=(tQ=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 lD,this._canUseTextureStoreData=!0,this._dataTextureInfo=new lS,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(cm))},tJ._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},tJ._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(tQ._blendShapeMacro),this._useTextureMode())e.enableMacro(tQ._blendShapeTextureMacro),e.setTexture(tQ._blendShapeTextureProperty,this._vertexTexture),e.setVector3(tQ._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(tQ._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("RENDERER_BLENDSHAPE_COUNT",n.toString()),this._uniformOccupiesCount=n+1;else{var r=this._getVertexBufferModeSupportCount();if(n>r){var a=t._condensedBlendShapeWeights;a||(a=new Float32Array(r),t._condensedBlendShapeWeights=a),this._filterCondensedBlendShapeWeights(t.blendShapeWeights,a),e.setFloatArray(tQ._blendShapeWeightsProperty,a),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(tQ._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(tQ._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(tQ._blendShapeNormalMacro):e.disableMacro(tQ._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(tQ._blendShapeTangentMacro):e.disableMacro(tQ._blendShapeTangentMacro)}else e.disableMacro(tQ._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},tJ._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},tJ._isCreateHost=function(e){var t=this._lastHostCreatedInfo;return t.x!==this._blendShapeCount||!!t.y!==this._useBlendNormal||!!t.z!==this._useBlendTangent||t.w!==e},tJ._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},tJ._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},tJ._updateVertexBufferIndex=function(){if(-1===this._bufferBindingOffset){for(var e=this._modelMesh,t=e._internalVertexBufferIndex,n=e._vertexBufferBindings,r=0,a=Math.max(n.length,t+1);r<a&&(n[r]||r===t);r++);this._bufferBindingOffset=r}},tJ._addVertexElements=function(t){this._updateVertexBufferIndex();for(var n=this._vertexElementOffset,r=this._bufferBindingOffset,a=0,i=0,o=Math.min(this._blendShapeCount,this._getVertexBufferModeSupportCount());i<o;i++)t._setVertexElement(n++,new cZ("POSITION_BS"+i,a,e.VertexElementFormat.Vector3,r)),a+=12,this._useBlendNormal&&(t._setVertexElement(n++,new cZ("NORMAL_BS"+i,a,e.VertexElementFormat.Vector3,r)),a+=12),this._useBlendTangent&&(t._setVertexElement(n++,new cZ("TANGENT_BS"+i,a,e.VertexElementFormat.Vector3,r)),a+=12);return n},tJ._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))},tJ._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},tJ._createVertexBuffers=function(t,n){var r=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);o.length=u,this._vertices=new Float32Array(s*t*Math.min(c,i)),this._maxCountSingleVertexBuffer=c,this._storeInVertexBufferInfo.length=i;for(var h=this._bufferBindingOffset,d=0;d<u;d++){var _=u-1,f=(d===_?i-_*c:c)*l,p=f*t,g=n?e.BufferUsage.Static:e.BufferUsage.Dynamic,m=new c$(r,e.BufferBindFlag.VertexBuffer,p,g);a._setVertexBufferBinding(h+d,new c3(m,f)),o[d]=m}},tJ._createTextureArray=function(t){var n=this._engine._hardwareRenderer.capability.maxTextureSize,r=this._vertexElementCount,a=r*t,i=1;a>n&&(i=Math.ceil(a/n),a=n);var o=this._vertexTexture,s=this._blendShapes.length;o&&o.destroy(),(o=new ce(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(r,a,i)},tJ._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,h=0,d=n.length;h<d;h++){var _=s[h];if(t||_.flag){var f=n[h].frames,p=f.length,g=f[p-1];if(p>0&&g.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";var m=Math.floor(h/r),v=h%r,y=i[m],x=y.byteLength/(4*e),T=v*l,S=o[h];S||(o[h]=S=new lL),S.set(u+m,v*c);for(var C=g.deltaPositions,A=0;A<e;A++){var w=T+x*A,E=C[A];E&&(a[w]=E.x,a[w+1]=E.y,a[w+2]=E.z)}if(T+=3,this._useBlendNormal){var b=g.deltaNormals;if(b)for(var M=0;M<e;M++){var F=T+x*M,R=b[M];R&&(a[F]=R.x,a[F+1]=R.y,a[F+2]=R.z)}T+=3}if(this._useBlendTangent){var P=g.deltaTangents;if(P)for(var L=0;L<e;L++){var D=T+x*L,B=P[L];B&&(a[D]=B.x,a[D+1]=B.y,a[D+2]=B.z)}T+=3}(v===r-1||h===d-1)&&y.setData(a,0,0,y.byteLength/4),_.flag=!1}}},tJ._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,h=u.length,d=u[h-1];if(h>0&&d.deltaPositions.length!==e)throw"BlendShape frame deltaPositions length must same with mesh vertexCount.";for(var _=d.deltaPositions,f=d.deltaNormals,p=d.deltaTangents,g=o*c,m=0;m<e;m++){var v=_[m];if(a[g]=v.x,a[g+1]=v.y,a[g+2]=v.z,g+=4,f){var y=f[m];a[g]=y.x,a[g+1]=y.y,a[g+2]=y.z,g+=4}if(p){var x=p[m];a[g]=x.x,a[g+1]=x.y,a[g+2]=x.z,g+=4}}l.flag=!1}}r.setPixelBuffer(0,a)},tJ._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},tJ._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}},tJ._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},tJ._filterCondensedBlendShapeWeights=function(e,t){for(var n,r=t.length,a=this._modelMesh._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 h=t[u];h<o&&(o=h,n=u)}}}},tQ);c7._blendShapeMacro=cw.getByName("RENDERER_HAS_BLENDSHAPE"),c7._blendShapeTextureMacro=cw.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),c7._blendShapeNormalMacro=cw.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),c7._blendShapeTangentMacro=cw.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),c7._blendShapeWeightsProperty=cs.getByName("renderer_BlendShapeWeights"),c7._blendShapeTextureProperty=cs.getByName("renderer_BlendShapeTexture"),c7._blendShapeTextureInfoProperty=cs.getByName("renderer_BlendShapeTextureInfo"),e.VertexAttribute=void 0,(tZ=e.VertexAttribute||(e.VertexAttribute={})).Position="POSITION",tZ.Normal="NORMAL",tZ.Color="COLOR_0",tZ.Tangent="TANGENT",tZ.BoneWeight="WEIGHTS_0",tZ.BoneIndex="JOINTS_0",tZ.UV="TEXCOORD_0",tZ.UV1="TEXCOORD_1",tZ.UV2="TEXCOORD_2",tZ.UV3="TEXCOORD_3",tZ.UV4="TEXCOORD_4",tZ.UV5="TEXCOORD_5",tZ.UV6="TEXCOORD_6",tZ.UV7="TEXCOORD_7";var c9=(lk(t$=function(e,t){var n;return(n=c2.call(this,e)||this)._internalVertexBufferIndex=-1,n._vertexCount=0,n._vertexCountDirty=!1,n._dataVersionCounter=0,n._positions=null,n._normals=null,n._colors=null,n._tangents=null,n._uv=null,n._uv1=null,n._uv2=null,n._uv3=null,n._uv4=null,n._uv5=null,n._uv6=null,n._uv7=null,n._boneWeights=null,n._boneIndices=null,n._advancedElementUpdateFlag=0,n._advancedDataUpdateFlag=0,n._advancedVertexDataVersions=Array(14),n._advancedDataSyncToBuffer=!1,n._internalVertexBufferStride=0,n._internalVertexBufferCreatedInfo=new lS(0,0,-1),n._internalVertexElementsOffset=0,n._internalVertexElementsFlags=0,n._vertexBufferInfos=[],n._indices=null,n._indicesFormat=null,n._indicesChangeFlag=!1,n._accessible=!0,n.name=t,n._blendShapeManager=new c7(e,lO(n)),n},c2),(t0=t$.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)},t0.getPositions=function(){var t=this._getVertexElementData(this._positions,e.VertexAttribute.Position,0,this._readVector3VertexData);return this._positions=t,t},t0.setNormals=function(e){this._beforeSetAdvancedVertexData(e,2,1),this._normals=e},t0.getNormals=function(){var t=this._getVertexElementData(this._normals,e.VertexAttribute.Normal,1,this._readVector3VertexData);return this._normals=t,t},t0.setColors=function(e){this._beforeSetAdvancedVertexData(e,4,2),this._colors=e},t0.getColors=function(){var t=this._getVertexElementData(this._colors,e.VertexAttribute.Color,2,this._readColorVertexData);return this._colors=t,t},t0.setBoneWeights=function(e){this._beforeSetAdvancedVertexData(e,16,4),this._boneWeights=e},t0.getBoneWeights=function(){var t=this._getVertexElementData(this._boneWeights,e.VertexAttribute.BoneWeight,4,this._readVector4VertexData);return this._boneWeights=t,t},t0.setBoneIndices=function(e){this._beforeSetAdvancedVertexData(e,32,5),this._boneIndices=e},t0.getBoneIndices=function(){var t=this._getVertexElementData(this._boneIndices,e.VertexAttribute.BoneIndex,5,this._readVector4VertexData);return this._boneIndices=t,t},t0.setTangents=function(e){this._beforeSetAdvancedVertexData(e,8,3),this._tangents=e},t0.getTangents=function(){var t=this._getVertexElementData(this._tangents,e.VertexAttribute.Tangent,3,this._readVector4VertexData);return this._tangents=t,t},t0.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]."}},t0.getUVs=function(t){switch(t=null!=t?t:0){case 0:var n=this._getVertexElementData(this._uv,e.VertexAttribute.UV,6,this._readVector2VertexData);return this._uv=n,n;case 1:var r=this._getVertexElementData(this._uv1,e.VertexAttribute.UV1,7,this._readVector2VertexData);return this._uv1=r,r;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]."},t0.setIndices=function(t){this._indices!==t&&(this._indices=t,lX(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:lX(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:lX(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},t0.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},t0.setVertexElements=function(t){this._clearVertexElements();for(var n,r=t.length,a=0;a<r;a++)this._addVertexElement(t[a]);var i=this._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==(n=this._vertexBufferBindings[o])||n.buffer.destroy(),this._setVertexBufferBinding(o,null),this._internalVertexBufferCreatedInfo.z=-1),this._internalVertexBufferStride=0,this._internalVertexElementsOffset=r,this._advancedElementUpdateFlag=0,this._vertexCountDirty=!0,this._blendShapeManager._bufferBindingOffset=-1,this._blendShapeManager._vertexElementOffset=r},t0.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 c3(e,t));var i=a?t:n,o=this._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},t0.setVertexBufferBindings=function(e,t){void 0===t&&(t=0);var n=e.length,r=this._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},t0.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},t0.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},t0.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},t0.uploadData=function(t){if(this._updateVertexElements(),this._advancedDataSyncToBuffer=!0,this._updateInternalVertexBuffer(t),65535&this._advancedDataUpdateFlag){this._updateAdvancedVertices();for(var n=this._vertexBufferInfos,r=this._vertexBufferBindings,a=0,i=r.length;a<i;a++){var o=n[a];if(null==o?void 0:o.uploadAdvancedData){var s,l=null==(s=r[a])?void 0:s.buffer;l.setData(l.data),o.uploadAdvancedData=!1}}}if(this._advancedDataSyncToBuffer=!1,this._indicesChangeFlag){var c,u=this._indices,h=null==(c=this._indexBufferBinding)?void 0:c._buffer;if(u){if(h&&u.byteLength==h.byteLength)h.setData(u),this._indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new c0(h,this._indicesFormat));else{null==h||h.destroy();var d=new c$(this._engine,e.BufferBindFlag.IndexBuffer,u);this._setIndexBufferBinding(new c0(d,this._indicesFormat))}}else h&&(h.destroy(),this._setIndexBufferBinding(null));this._indicesChangeFlag=!1}var _=this._blendShapeManager;_._blendShapeCount>0&&_._update(t),t&&(this._accessible=!1,this._releaseCache(!1))},t0.calculateTangents=function(){var e=this.getPositions(),t=this.getNormals(),n=this.getUVs();if(!t||!n)throw"Set normal and uv before calculation.";for(var r=this._indices,a=this.vertexCount,i=t$._tempVec0,o=t$._tempVec1,s=t$._tempVec2,l=t$._tempVec3,c=t$._tempVec4,u=r?r.length/3:e.length/3,h=Array(a),d=Array(a),_=0;_<a;_++)h[_]=new lD,d[_]=new lS;for(var f=0;f<u;f++){var p=3*f,g=3*f+1,m=3*f+2;r&&(p=r[p],g=r[g],m=r[m]);var v=e[p],y=e[g],x=e[m],T=n[p],S=n[g],C=n[m];lS.subtract(y,v,i),lS.subtract(x,v,o);var A=S.x-T.x,w=C.x-T.x,E=S.y-T.y,b=C.y-T.y,M=1/(A*b-w*E);lS.scale(i,b*M,s),lS.scale(o,E*M,c),lS.subtract(s,c,s),lS.scale(o,A*M,l),lS.scale(i,w*M,c),lS.subtract(l,c,l);var F=h[p];F.set(F.x+s.x,F.y+s.y,F.z+s.z,1),(F=h[g]).set(F.x+s.x,F.y+s.y,F.z+s.z,1),(F=h[m]).set(F.x+s.x,F.y+s.y,F.z+s.z,1),d[p].add(l),d[g].add(l),d[m].add(l)}for(var R=0;R<a;R++){var P=t[R],L=d[R],D=h[R];s.set(D.x,D.y,D.z),lS.cross(s,L,c);var B=lS.dot(c,P)>0?1:-1;lS.scale(P,lS.dot(s,P),c),lS.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,B)}this.setTangents(h)},t0._setVertexBufferBinding=function(e,t){var n,r=this,a=this._vertexBufferBindings,i=this._vertexBufferInfos,o=function(){r._advancedDataSyncToBuffer||(i[e].dataVersion=r._dataVersionCounter++)},s=a[e];s&&s.buffer._dataUpdateManager.removeListener(o),c2.prototype._setVertexBufferBinding.call(this,e,t),t?(t.buffer._dataUpdateManager.addListener(o),((n=i)[e]||(n[e]=new ue)).reset(),o()):e+1==a.length&&a.length--},t0._getVertexTypedArray=function(t,n){switch(n){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)}},t0._onDestroy=function(){c2.prototype._onDestroy.call(this),this._releaseCache(!0)},t0._getVertexElementData=function(e,t,n,r){var a,i=this._advancedVertexDataVersions,o=null!=(a=i[n])?a:-1,s=this._vertexElementMap[t],l=s?this._vertexBufferInfos[s.bindingIndex].dataVersion:-1;return o>=l?e:(i[n]=l,r.call(this,t))},t0._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)},t0._updateAdvancedVertexDataMarks=function(e,t){this._advancedElementUpdateFlag|=e,this._advancedDataUpdateFlag|=e,this._advancedVertexDataVersions[t]=this._dataVersionCounter++},t0._updateInternalVertexBuffer=function(t){var n=this._internalVertexBufferStride,r=this.vertexCount,a=this._internalVertexBufferCreatedInfo,i=n*r;if(a.x*a.y!==i){var o,s=a.z;-1!==s&&(null==(o=this._vertexBufferBindings[s])||o.buffer.destroy(),this._setVertexBufferBinding(s,null));var l=this._internalVertexBufferIndex,c=n*this.vertexCount>0;if(c){this._advancedDataUpdateFlag|=this._internalVertexElementsFlags;var u=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,h=new c$(this._engine,e.BufferBindFlag.VertexBuffer,i,u,!0);this._setVertexBufferBinding(l,new c3(h,n))}a.set(n,r,c?l:-1)}},t0._readVector2VertexData=function(e){return this._readVertexData(e,function(e,t){return new lL(e[t],e[t+1])})},t0._readVector3VertexData=function(e){return this._readVertexData(e,function(e,t){return new lS(e[t],e[t+1],e[t+2])})},t0._readVector4VertexData=function(e){return this._readVertexData(e,function(e,t){return new lD(e[t],e[t+1],e[t+2],e[t+3])})},t0._readColorVertexData=function(e){return this._readVertexData(e,function(e,t){return new lB(e[t],e[t+1],e[t+2],e[t+3])})},t0._readVertexData=function(e,t){var n=this._vertexElementMap[e];if(!n)return null;var r=this._vertexBufferBindings[n.bindingIndex],a=null==r?void 0:r.buffer;if(!a)return null;if(!a.readable)throw"Not allowed to access data while vertex buffer readable is false.";for(var i=this.vertexCount,o=n._formatMetaInfo,s=Array(i),l=this._getVertexTypedArray(a.data.buffer,o.type),c=n.offset,u=r.stride,h=0;h<i;h++){var d=(h*u+c)/l.BYTES_PER_ELEMENT,_=t(l,d);o.normalized&&_.scale(o.normalizedScaleFactor),s[h]=_}return s},t0._updateAdvancedVertexElement=function(e,t,n){var r=this._vertexElementMap;if(e){if(!r[t]){var a=this._getAttributeFormat(t),i=this._internalVertexBufferStride,o=this._getInternalVertexBufferIndex();this._addVertexElement(new cZ(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._vertexElements.indexOf(s);l>=this._internalVertexElementsOffset?(this._internalVertexBufferStride-=this._getAttributeByteLength(t),this._internalVertexElementsFlags&=~n):this._internalVertexElementsOffset--,this._blendShapeManager._vertexElementOffset--,this._removeVertexElement(l)}}},t0._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)},t0._updateVertexElements=function(){var e=this._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)}},t0._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)})},t0._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)})},t0._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)})},t0._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)})},t0._writeAdvancedVertexData=function(e,t,n){var r,a=this._vertexElementMap[e],i=a.bindingIndex,o=this._vertexBufferBindings[i],s=null==o?void 0:o.buffer;if(s){if(!s.readable)throw"Vertex buffer is not readable, can't write vertex data.";var l=null!=(r=this._advancedVertexDataVersions[t])?r:-1,c=this._vertexBufferInfos[i];if(l>c.dataVersion){for(var u=a._formatMetaInfo,h=this._getVertexTypedArray(s.data.buffer,u.type),d=a.offset,_=o.stride,f=h.BYTES_PER_ELEMENT,p=u.normalized,g=u.size,m=u.normalizedScaleFactor,v=0,y=this._vertexCount;v<y;v++){var x=(v*_+d)/f;if(n(h,x,v),p)for(var T=0;T<g;T++)h[x+T]/=m}c.uploadAdvancedData=!0}}},t0._updateAdvancedVertices=function(){var t=this._positions,n=this._normals,r=this._colors,a=this._advancedDataUpdateFlag,i=this._boneWeights,o=this._boneIndices,s=this._tangents,l=this._uv,c=this._uv1,u=this._uv2,h=this._uv3,d=this._uv4,_=this._uv5,f=this._uv6,p=this._uv7;1&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Position,0,t),n&&2&a&&this._writeVector3AdvancedVertexData(e.VertexAttribute.Normal,1,n),r&&4&a&&this._writeColorAdvancedVertexData(e.VertexAttribute.Color,2,r),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),h&&512&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV3,9,h),d&&1024&a&&this._writeVector2AdvancedVertexData(e.VertexAttribute.UV4,10,d),_&&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},t0._getInternalVertexBufferIndex=function(){var e=this._internalVertexBufferIndex;if(-1!==e)return e;for(var t=0,n=this._vertexBufferBindings,r=n.length;t<r&&n[t];t++);return this._internalVertexBufferIndex=t,t},t0._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}},t0._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}},t0._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._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)}}},lU(t$,[{key:"vertexCount",get:function(){if(this._vertexCountDirty){var t=0,n=this._vertexElementMap[e.VertexAttribute.Position];if(n){var r=this._vertexBufferBindings[n.bindingIndex];r&&(t=r.buffer.byteLength/r.stride)}this._vertexCount=t,this._vertexCountDirty=!1}return this._vertexCount}},{key:"vertexElements",get:function(){return this._updateVertexElements(),this._vertexElements}},{key:"vertexBufferBindings",get:function(){return this._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$);c9._tempVec0=new lS,c9._tempVec1=new lS,c9._tempVec2=new lS,c9._tempVec3=new lS,c9._tempVec4=new lS;var ue=((t1=function(){this.dataVersion=-1,this.uploadAdvancedData=!1}).prototype.reset=function(){this.uploadAdvancedData=!1},t1);(t2=sH||(sH={}))[t2.None=0]="None",t2[t2.Position=1]="Position",t2[t2.Normal=2]="Normal",t2[t2.Color=4]="Color",t2[t2.Tangent=8]="Tangent",t2[t2.BoneWeight=16]="BoneWeight",t2[t2.BoneIndex=32]="BoneIndex",t2[t2.UV=64]="UV",t2[t2.UV1=128]="UV1",t2[t2.UV2=256]="UV2",t2[t2.UV3=512]="UV3",t2[t2.UV4=1024]="UV4",t2[t2.UV5=2048]="UV5",t2[t2.UV6=4096]="UV6",t2[t2.UV7=8192]="UV7",t2[t2.All=65535]="All",(t3=sW||(sW={}))[t3.Position=0]="Position",t3[t3.Normal=1]="Normal",t3[t3.Color=2]="Color",t3[t3.Tangent=3]="Tangent",t3[t3.BoneWeight=4]="BoneWeight",t3[t3.BoneIndex=5]="BoneIndex",t3[t3.UV=6]="UV",t3[t3.UV1=7]="UV1",t3[t3.UV2=8]="UV2",t3[t3.UV3=9]="UV3",t3[t3.UV4=10]="UV4",t3[t3.UV5=11]="UV5",t3[t3.UV6=12]="UV6",t3[t3.UV7=13]="UV7";var ut=(lk(t4=function(e,t){var n;return(n=l$.call(this,e)||this).primitiveInfo=t,n},l$),t4.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:uu._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 1:uu._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0,e.vertexBuffer);break;case 2:uu._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 3:uu._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 4:uu._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0,e.vertexBuffer);break;case 5:uu._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer);break;case 6:uu._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0,e.vertexBuffer)}},t4);(t5=sX||(sX={}))[t5.Sphere=0]="Sphere",t5[t5.Cuboid=1]="Cuboid",t5[t5.Plane=2]="Plane",t5[t5.Cylinder=3]="Cylinder",t5[t5.Torus=4]="Torus",t5[t5.Cone=5]="Cone",t5[t5.Capsule=6]="Capsule";var un=function(e,t,n){this.type=e,this.vertexBuffer=t,this.noLongerAccessible=n},ur=(lk(t8=function(e,t,n,r){var a;return(a=un.call(this,0,n,r)||this).radius=e,a.segments=t,a},un),t8),ua=(lk(t6=function(e,t,n,r,a){var i;return(i=un.call(this,1,r,a)||this).width=e,i.height=t,i.depth=n,i},un),t6),ui=(lk(t7=function(e,t,n,r,a,i){var o;return(o=un.call(this,2,a,i)||this).width=e,o.height=t,o.horizontalSegments=n,o.verticalSegments=r,o},un),t7),uo=(lk(t9=function(e,t,n,r,a,i,o){var s;return(s=un.call(this,3,i,o)||this).radiusTop=e,s.radiusBottom=t,s.height=n,s.radialSegments=r,s.heightSegments=a,s},un),t9),us=(lk(ne=function(e,t,n,r,a,i,o){var s;return(s=un.call(this,4,i,o)||this).radius=e,s.tubeRadius=t,s.radialSegments=n,s.tubularSegments=r,s.arc=a,s},un),ne),ul=(lk(nt=function(e,t,n,r,a,i){var o;return(o=un.call(this,5,a,i)||this).radius=e,o.height=t,o.radialSegments=n,o.heightSegments=r,o},un),nt),uc=(lk(nn=function(e,t,n,r,a,i){var o;return(o=un.call(this,6,a,i)||this).radius=e,o.height=t,o.radialSegments=n,o.heightSegments=r,o},un),nn),uu=((nr=function(){}).createSphere=function(e,t,n,r){void 0===t&&(t=.5),void 0===n&&(n=18),void 0===r&&(r=!0);var a=new c9(e);nr._setSphereData(a,t,n,r,!1);var i=a.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(a,new ur(t,n,i,r))),a},nr.createCuboid=function(e,t,n,r,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=!0);var i=new c9(e);nr._setCuboidData(i,t,n,r,a,!1);var o=i.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(i,new ua(t,n,r,o,a))),i},nr.createPlane=function(e,t,n,r,a,i){void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new c9(e);nr._setPlaneData(o,t,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(o,new ui(t,n,r,a,s,i))),o},nr.createCylinder=function(e,t,n,r,a,i,o){void 0===t&&(t=.5),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 c9(e);nr._setCylinderData(s,t,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(s,new uo(t,n,r,a,i,l,o))),s},nr.createTorus=function(e,t,n,r,a,i,o){void 0===t&&(t=.5),void 0===n&&(n=.1),void 0===r&&(r=30),void 0===a&&(a=30),void 0===i&&(i=360),void 0===o&&(o=!0);var s=new c9(e);nr._setTorusData(s,t,n,r,a,i,o,!1);var l=s.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(s,new us(t,n,r,a,i,l,o))),s},nr.createCone=function(e,t,n,r,a,i){void 0===t&&(t=.5),void 0===n&&(n=2),void 0===r&&(r=20),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new c9(e);nr._setConeData(o,t,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(o,new ul(t,n,r,a,s,i))),o},nr.createCapsule=function(e,t,n,r,a,i){void 0===t&&(t=.5),void 0===n&&(n=2),void 0===r&&(r=6),void 0===a&&(a=1),void 0===i&&(i=!0);var o=new c9(e);nr._setCapsuleData(o,t,n,r,a,i,!1);var s=o.vertexBufferBindings[0].buffer;return e.resourceManager.addContentRestorer(new ut(o,new uc(t,n,r,a,s,i))),o},nr._setSphereData=function(e,t,n,r,a,i){for(var o=(n=Math.max(2,Math.floor(n)))+1,s=o*o,l=n*n,c=nr._generateIndices(e.engine,s,6*l),u=Math.PI,h=2*u,d=1/o,_=1/n,f=new Float32Array(8*s),p=0;p<s;++p){var g=p%o*_,m=(p*d|0)*_,v=g*h,y=m*u,x=Math.sin(y),T=-t*Math.cos(v)*x,S=t*Math.cos(y),C=t*Math.sin(v)*x,A=8*p;f[A++]=T,f[A++]=S,f[A++]=C,f[A++]=T,f[A++]=S,f[A++]=C,f[A++]=g,f[A++]=m}for(var w=0,E=0;E<l;++E){var b=E%n,M=(E*_|0)*o+b,F=M+1,R=M+o,P=R+1;c[w++]=F,c[w++]=M,c[w++]=P,c[w++]=M,c[w++]=R,c[w++]=P}if(!a){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}nr._initialize(e,f,c,r,a,i)},nr._setCuboidData=function(e,t,n,r,a,i,o){var s=t/2,l=n/2,c=r/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 h=0;h<4;h++){var d=8*h+3;u[d++]=0,u[d++]=1,u[d++]=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 g=8*p+67;u[g++]=-1,u[g++]=0,u[g++]=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 m=0;m<4;m++){var v=8*m+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 T=0;T<4;T++){var S=8*T+163;u[S++]=0,u[S++]=0,u[S++]=-1}var C=new Uint16Array(36);if(C[0]=0,C[1]=2,C[2]=1,C[3]=2,C[4]=0,C[5]=3,C[6]=4,C[7]=6,C[8]=7,C[9]=6,C[10]=4,C[11]=5,C[12]=8,C[13]=10,C[14]=9,C[15]=10,C[16]=8,C[17]=11,C[18]=12,C[19]=14,C[20]=15,C[21]=14,C[22]=12,C[23]=13,C[24]=16,C[25]=18,C[26]=17,C[27]=18,C[28]=16,C[29]=19,C[30]=20,C[31]=22,C[32]=23,C[33]=22,C[34]=20,C[35]=21,!i){var A=e.bounds;A.min.set(-s,-l,-c),A.max.set(s,l,c)}nr._initialize(e,u,C,a,i,o)},nr._setPlaneData=function(e,t,n,r,a,i,o,s){for(var l=(r=Math.max(1,Math.floor(r)))+1,c=(a=Math.max(1,Math.floor(a)))+1,u=t/2,h=n/2,d=t/r,_=n/a,f=l*c,p=a*r,g=nr._generateIndices(e.engine,f,6*p),m=1/l,v=1/r,y=1/a,x=new Float32Array(8*f),T=0;T<f;++T){var S=T%l,C=T*m|0,A=8*T;x[A++]=S*d-u,x[A++]=0,x[A++]=C*_-h,x[A++]=0,x[A++]=1,x[A++]=0,x[A++]=S*v,x[A++]=C*y}for(var w=0,E=0;E<p;++E){var b=E%r,M=(E*v|0)*l+b,F=M+1,R=M+l,P=R+1;g[w++]=M,g[w++]=R,g[w++]=F,g[w++]=R,g[w++]=P,g[w++]=F}if(!o){var L=e.bounds;L.min.set(-u,0,-h),L.max.set(u,0,h)}nr._initialize(e,x,g,i,o,s)},nr._setCylinderData=function(e,t,n,r,a,i,o,s,l){void 0===t&&(t=.5),void 0===n&&(n=.5),void 0===r&&(r=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,h=.5*r,d=r/i,_=c*u,f=a*i,p=2*a,g=_+2+p,m=nr._generateIndices(e.engine,g,6*f+3*p),v=1/c,y=1/a,x=1/i,T=new Float32Array(8*g),S=0,C=Math.PI,A=2*Math.PI,w=n-t,E=w/r,b=w/i,M=0;M<_;++M){var F=M%c,R=M*v|0,P=F*y,L=R*x,D=C+P*A,B=Math.sin(D),I=Math.cos(D),V=n-R*b,O=V*B,N=R*d-h,U=V*I,z=8*M;T[z++]=O,T[z++]=N,T[z++]=U,T[z++]=B,T[z++]=E,T[z++]=I,T[z++]=P,T[z++]=1-L}for(var k=0;k<f;++k){var G=k%a,H=(k*y|0)*c+G,W=H+1,X=H+c,K=X+1;m[S++]=W,m[S++]=X,m[S++]=H,m[S++]=W,m[S++]=K,m[S++]=X}var j=8*_;T[j++]=0,T[j++]=-h,T[j++]=0,T[j++]=0,T[j++]=-1,T[j++]=0,T[j++]=.5,T[j++]=.5,T[j++]=0,T[j++]=h,T[j++]=0,T[j++]=0,T[j++]=1,T[j++]=0,T[j++]=.5,T[j++]=.5,j=(_+2)*8;for(var q=1/(2*t),Y=1/(2*n),Q=c*i,J=0;J<a;++J){var Z=8*J,$=T[Z],ee=T[Z+2];T[j++]=$,T[j++]=-h,T[j++]=ee,T[j++]=0,T[j++]=-1,T[j++]=0,T[j++]=$*Y+.5,T[j++]=.5-ee*Y;var et=(J+Q)*8;$=T[et],ee=T[et+2],T[j++]=$,T[j++]=h,T[j++]=ee,T[j++]=0,T[j++]=1,T[j++]=0,T[j++]=$*q+.5,T[j++]=.5-ee*q}for(var en=_+1,er=_+2,ea=er+1,ei=0;ei<a;++ei){var eo=2*ei,es=ei===a-1?0:eo+2;m[S++]=_,m[S++]=er+es,m[S++]=er+eo,m[S++]=en,m[S++]=ea+eo,m[S++]=ea+es}if(!s){var el=e.bounds,ec=Math.max(t,n);el.min.set(-ec,-h,-ec),el.max.set(ec,h,ec)}nr._initialize(e,T,m,o,s,l)},nr._setTorusData=function(e,t,n,r,a,i,o,s,l){var c=((r=Math.floor(r))+1)*((a=Math.floor(a))+1),u=r*a,h=nr._generateIndices(e.engine,c,6*u),d=new Float32Array(8*c);i=i/180*Math.PI;for(var _=0,f=nr._tempVec30,p=0;p<=r;p++)for(var g=0;g<=a;g++){var m=g/a*i,v=p/r*Math.PI*2,y=Math.cos(v),x=Math.cos(m),T=Math.sin(m),S=(t+n*y)*x,C=(t+n*y)*T,A=n*Math.sin(v);d[_++]=S,d[_++]=C,d[_++]=A;var w=t*x,E=t*T;f.set(S-w,C-E,A).normalize(),d[_++]=f.x,d[_++]=f.y,d[_++]=f.z,d[_++]=g/a,d[_++]=p/r}_=0;for(var b=1;b<=r;b++)for(var M=1;M<=a;M++){var F=(a+1)*b+M-1,R=(a+1)*(b-1)+M-1,P=(a+1)*(b-1)+M,L=(a+1)*b+M;h[_++]=F,h[_++]=R,h[_++]=L,h[_++]=R,h[_++]=P,h[_++]=L}if(!s){var D=e.bounds,B=t+n;D.min.set(-B,-B,-n),D.max.set(B,B,n)}nr._initialize(e,d,h,o,s,l)},nr._setConeData=function(e,t,n,r,a,i,o,s){for(var l=(r=Math.floor(r))+1,c=(a=Math.floor(a))+1,u=.5*n,h=n/a,d=l*c,_=r*a,f=d+1+r,p=nr._generateIndices(e.engine,f,6*_+3*r),g=1/l,m=1/r,v=1/a,y=new Float32Array(8*f),x=0,T=Math.PI,S=2*Math.PI,C=t/n,A=0;A<d;++A){var w=A%l,E=A*g|0,b=w*m,M=E*v,F=T+b*S,R=Math.sin(F),P=Math.cos(F),L=t-E*t,D=L*R,B=E*h-u,I=L*P,V=8*A;y[V++]=D,y[V++]=B,y[V++]=I,y[V++]=R,y[V++]=C,y[V++]=P,y[V++]=b,y[V++]=1-M}for(var O=0;O<_;++O){var N=O%r,U=(O*m|0)*l+N,z=U+1,k=U+l,G=k+1;p[x++]=z,p[x++]=k,p[x++]=U,p[x++]=z,p[x++]=G,p[x++]=k}var H=8*d;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=(d+1)*8;for(var W=1/(2*t),X=0;X<r;++X){var K=y[8*X],j=y[8*X+2];y[H++]=K,y[H++]=-u,y[H++]=j,y[H++]=0,y[H++]=-1,y[H++]=0,y[H++]=K*W+.5,y[H++]=.5-j*W}for(var q=d+1,Y=0;Y<r;++Y){var Q=Y,J=Y===r-1?0:Q+1;p[x++]=d,p[x++]=q+J,p[x++]=q+Q}if(!o){var Z=e.bounds;Z.min.set(-t,-u,-t),Z.max.set(t,u,t)}nr._initialize(e,y,p,i,o,s)},nr._setCapsuleData=function(e,t,n,r,a,i,o,s){for(var l=(r=Math.max(2,Math.floor(r)))+1,c=(a=Math.floor(a))+1,u=.5*n,h=n/a,d=l*c,_=r*a,f=l*l,p=r*r,g=d+2*f,m=nr._generateIndices(e.engine,g,(_+2*p)*6),v=1/l,y=1/r,x=1/a,T=Math.PI,S=2*Math.PI,C=new Float32Array(8*g),A=0,w=0;w<d;++w){var E=w%l,b=w*v|0,M=E*y,F=b*x,R=T+M*S,P=Math.sin(R),L=Math.cos(R),D=8*w;C[D++]=t*P,C[D++]=b*h-u,C[D++]=t*L,C[D++]=P,C[D++]=0,C[D++]=L,C[D++]=M,C[D++]=1-F}for(var B=0;B<_;++B){var I=B%r,V=(B*y|0)*l+I,O=V+1,N=V+l,U=N+1;m[A++]=O,m[A++]=N,m[A++]=V,m[A++]=O,m[A++]=U,m[A++]=N}if(nr._createCapsuleCap(t,n,r,S,d,1,C,m,A),nr._createCapsuleCap(t,n,r,-S,d+f,-1,C,m,A+6*p),!o){var z=e.bounds;z.min.set(-t,-t-u,-t),z.max.set(t,t+u,t)}nr._initialize(e,C,m,i,o,s)},nr._initialize=function(t,n,r,a,i,o){if(i)o.setData(n),t.setIndices(r),t.uploadData(a);else{var s=[new cZ(e.VertexAttribute.Position,0,e.VertexElementFormat.Vector3,0),new cZ(e.VertexAttribute.Normal,12,e.VertexElementFormat.Vector3,0),new cZ(e.VertexAttribute.UV,24,e.VertexElementFormat.Vector2,0)];t.setVertexElements(s);var l=new c$(t.engine,e.BufferBindFlag.VertexBuffer,n,e.BufferUsage.Static,!0);t.setVertexBufferBinding(l,32,0),t.setIndices(r),t.calculateTangents(),t.uploadData(a),t.addSubMesh(0,r.length)}},nr._generateIndices=function(t,n,r){var a=null;if(n>65535){if(t._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))a=new Uint32Array(r);else throw Error("The vertex count is over limit.")}else a=new Uint16Array(r);return a},nr._createCapsuleCap=function(e,t,n,r,a,i,o,s,l){for(var c=n+1,u=.5*t*i,h=c*c,d=n*n,_=1/c,f=1/n,p=0;p<h;++p){var g=p%c*f,m=(p*_|0)*f,v=g*r,y=m*Math.PI/2,x=Math.sin(y),T=-e*Math.cos(v)*x,S=e*Math.cos(y)*i+u,C=e*Math.sin(v)*x,A=(p+a)*8;o[A++]=T,o[A++]=S,o[A++]=C,o[A++]=T,o[A++]=S-u,o[A++]=C,o[A++]=g,o[A++]=m}for(var w=0;w<d;++w){var E=w%n,b=(w*f|0)*c+E+a,M=b+1,F=b+c,R=F+1;s[l++]=M,s[l++]=b,s[l++]=R,s[l++]=b,s[l++]=F,s[l++]=R}},nr);uu._tempVec30=new lS;var uh=(lk(na=function(e){var t;return(t=lJ.call(this,null)||this).name=e,t._bones=[],t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},lJ),na),ud=(lk(ni=function(e){(t=c6.call(this,e)||this)._jointDataCreateCache=new lL(-1,-1),t._localBounds=new lA,t._skin=null;var t,n=t.entity.engine._hardwareRenderer,r=n.renderStates.getParameter(n.gl.MAX_VERTEX_UNIFORM_VECTORS);r=Math.min(r,n._options._maxAllowSkinUniformVectorCount),t._maxVertexUniformVectors=r,t._onLocalBoundsChanged=t._onLocalBoundsChanged.bind(lO(t));var a=t._localBounds;return a.min._onValueChanged=t._onLocalBoundsChanged,a.max._onValueChanged=t._onLocalBoundsChanged,t},c6),(no=ni.prototype).update=function(){var e=this._skin;if(e)for(var t=e.inverseBindMatrices,n=this._rootBone.getInvModelMatrix(),r=this._bones,a=this._jointMatrices,i=r.length-1;i>=0;i--){var o=r[i],s=16*i;o?c_._floatMatrixMultiply(o.transform.worldMatrix,t[i].elements,0,a,s):a.set(t[i].elements,s),c_._floatMatrixMultiply(n,a,s,a,s)}},no._updateShaderData=function(t){var n=this.entity,r=this._rootBone?this._rootBone.transform.worldMatrix:n.transform.worldMatrix;this._updateTransformShaderData(t,r);var a=this.shaderData,i=this.mesh._blendShapeManager;i._updateShaderData(a,this);var o=this._bones;if(o){var s=i._uniformOccupiesCount,l=o.length,c=this._jointDataCreateCache,u=l!==c.x;if(u||s!==c.y){var h,d=Math.ceil((this._maxVertexUniformVectors-(44+s))/4);if(l>d){var _,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(_=this._jointTexture)||_.destroy(),this._jointTexture=new l9(f,4,l,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),a.disableMacro("RENDERER_JOINTS_NUM"),a.enableMacro("RENDERER_USE_JOINT_TEXTURE"),a.setTexture(ni._jointSamplerProperty,this._jointTexture)):l8.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 "+d+".",this)}else null==(h=this._jointTexture)||h.destroy(),a.disableMacro("RENDERER_USE_JOINT_TEXTURE"),a.enableMacro("RENDERER_JOINTS_NUM",d.toString()),a.setFloatArray(ni._jointMatrixProperty,this._jointMatrices);c.set(l,s)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var p=n.layer;this._rendererLayer.set(65535&p,p>>>16&65535,0,0)},no._onDestroy=function(){var e,t;c6.prototype._onDestroy.call(this),null==(e=this._rootBone)||e.transform._updateFlagManager.removeListener(this._onTransformChanged),this._rootBone=null,this._jointDataCreateCache=null,this._skin=null,this._blendShapeWeights=null,this._localBounds=null,this._jointMatrices=null,null==(t=this._jointTexture)||t.destroy(),this._jointTexture=null,this._bones=null},no._cloneTo=function(e,t,n){c6.prototype._cloneTo.call(this,e,t,n);var r=[];if(this.rootBone){var a=this._getEntityHierarchyPath(t,this.rootBone,r);e.rootBone=a?this._getEntityByHierarchyPath(n,r):this.rootBone}var i=this._bones;if(i){for(var o=i.length,s=Array(o),l=0;l<o;l++){var c=i[l],u=this._getEntityHierarchyPath(t,c,r);s[l]=u?this._getEntityByHierarchyPath(n,r):c}e.bones=s}this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},no._registerEntityTransformListener=function(){},no._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;lA.transform(t,n,e)}else c6.prototype._updateBounds.call(this,e)},no._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)},no._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=sV.WorldVolume},no._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},no._getEntityByHierarchyPath=function(e,t){for(var n=e,r=t.length-1;r>=0;r--)n=n.children[t[r]];return n},lU(ni,[{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._rootBone},set:function(e){if(this._rootBone!==e){var t;null==(t=this._rootBone)||t.transform._updateFlagManager.removeListener(this._onTransformChanged),e.transform._updateFlagManager.addListener(this._onTransformChanged),this._rootBone=e,this._dirtyUpdateFlag|=sV.WorldVolume}}},{key:"bones",get:function(){return this._bones},set:function(e){if(this._bones!==e){var t,n,r,a=null!=(n=null==(t=this._bones)?void 0:t.length)?n:0,i=null!=(r=null==e?void 0:e.length)?r:0;if(a!==i){var o=this.shaderData;i>0?(this._jointMatrices=new Float32Array(16*i),o.enableMacro("RENDERER_HAS_SKIN"),o.setInt(ni._jointCountProperty,i)):(this._jointMatrices=null,o.disableMacro("RENDERER_HAS_SKIN"))}this._bones=e}}},{key:"skin",get:function(){return this._skin},set:function(e){this._skin=e}}]),ni);ud._jointCountProperty=cs.getByName("renderer_JointCount"),ud._jointSamplerProperty=cs.getByName("renderer_JointSampler"),ud._jointMatrixProperty=cs.getByName("renderer_JointMatrix"),lW([lK],ud.prototype,"_jointDataCreateCache",void 0),lW([lK],ud.prototype,"_blendShapeWeights",void 0),lW([lK],ud.prototype,"_maxVertexUniformVectors",void 0),lW([lK],ud.prototype,"_rootBone",void 0),lW([lK],ud.prototype,"_localBounds",void 0),lW([lK],ud.prototype,"_jointMatrices",void 0),lW([lK],ud.prototype,"_jointTexture",void 0),lW([lK],ud.prototype,"_bones",void 0),lW([lK],ud.prototype,"_condensedBlendShapeWeights",void 0),lW([lK],ud.prototype,"_onLocalBoundsChanged",null);var u_=((nl=(ns=function(e){this._subMeshPool=new cS(c1),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=e,this._initMeshes(e)}).prototype).drawElement=function(e,t){var n=e.data;if(n.multiRenderData)for(var r=n.charsData,a=t.engine._renderElementPool,i=0,o=r.length;i<o;++i){var s=a.getFromPool();s.set(r[i],e.shaderPasses),this._drawSubElement(s,t)}else this._drawSubElement(e,t)},nl._initMeshes=function(e){var t=ns.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*t),this._indices=new Uint16Array(3*t);for(var n=this._meshes,r=this._meshCount,a=0;a<r;a++)n[a]=this._createMesh(e,a)},nl.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!ns._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},nl.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},nl.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,a=e.length;r<a;++r)e[r].destroy();this._meshes=null;for(var i=0,o=t.length;i<o;++i)t[i].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},nl._drawSubElement=function(e,t){var n=e.data.verticesData.vertexCount;this._vertexCount+n>ns.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=n,this._batchedQueue[this._elementCount++]=e},nl._createMesh=function(t,n){var r=ns.MAX_VERTEX_COUNT,a=new c8(t,"BufferMesh"+n);a.isGCIgnored=!0;var i=[],o=this.createVertexElements(i),s=this._vertexBuffers[n]=new c$(t,e.BufferBindFlag.VertexBuffer,r*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[n]=new c$(t,e.BufferBindFlag.IndexBuffer,6*r,e.BufferUsage.Dynamic);return l.isGCIgnored=!0,a.setVertexBufferBinding(s,o),a.setIndexBufferBinding(l,e.IndexFormat.UInt16),a.setVertexElements(i),a},nl._updateData=function(e){var t=this._meshes,n=this._flushId;!ns._canUploadSameBuffer&&this._meshCount<=n&&(this._meshCount++,t[n]=this._createMesh(e,n));var r=this._batchedQueue,a=this._vertices,i=this._indices,o=t[n];o.clearSubMesh();for(var s=0,l=0,c=0,u=0,h=0,d=0,_=null,f=0,p=r.length;f<p;f++){var g=r[f],m=g.data;s=this.updateVertices(m,a,s);for(var v=m.verticesData.triangles,y=v.length,x=0;x<y;x++)i[l++]=v[x]+h;h+=m.verticesData.vertexCount,null===_?u+=y:this.canBatch(_,g)?u+=y:(o.addSubMesh(this._getSubMeshFromPool(c,u)),c+=u,u=y,r[d++]=_),_=g}o.addSubMesh(this._getSubMeshFromPool(c,u)),r[d]=_,this._vertexBuffers[n].setData(a,0,0,s),this._indiceBuffers[n].setData(i,0,0,l)},nl._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},ns);u_._disableBatchTag=cR.getByName("spriteDisableBatching"),u_.MAX_VERTEX_COUNT=4096,u_._canUploadSameBuffer=!0;var uf=(lk(nc=function(){return u_.apply(this,arguments)},u_),(nu=nc.prototype).createVertexElements=function(t){return t[0]=new cZ("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cZ("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},nu.canBatch=function(e,t){var n=e.data,r=t.data;if(n.isAdd!==r.isAdd)return!1;var a=n.component.shaderData,i=r.component.shaderData,o=cQ._textureProperty,s=cQ._alphaCutoffProperty;return a.getTexture(o)===i.getTexture(o)&&a.getTexture(s)===i.getTexture(s)},nu.updateVertices=function(e,t,n){for(var r=e.verticesData,a=r.positions,i=r.uvs,o=r.vertexCount,s=0;s<o;s++){var l=a[s],c=i[s];t[n++]=l.x,t[n++]=l.y,t[n++]=l.z,t[n++]=c.x,t[n++]=c.y}return n},nu.drawBatches=function(t){for(var n=this._engine,r=this._batchedQueue,a=this._meshes[this._flushId],i=a.subMeshes,o=t.scene.shaderData,s=t.shaderData,l=0,c=i.length;l<c;l++){var u=i[l],h=r[l],d=h.data;if(!u||!h)return;var _=d.component,f=d.material,p=cH._compileMacros;cE.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=f.renderState.stencilState,m=d.isAdd?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate;g.passOperationFront=m,g.passOperationBack=m;var v=f.shader.subShaders[0].passes[0],y=v._getShaderProgram(n,p);if(!y.isValid)return;y.bind(),y.groupingOtherUniformBlock(),y.uploadAll(y.sceneUniformBlock,o),y.uploadAll(y.cameraUniformBlock,s),y.uploadAll(y.rendererUniformBlock,_.shaderData),y.uploadAll(y.materialUniformBlock,f.shaderData),f.renderState._apply(n,!1,v._renderStateDataMap,f.shaderData),n._hardwareRenderer.drawPrimitive(a,u,y)}},nc),up=((nd=(nh=function(e){this._preMaskLayer=0,this._batcher=new uf(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},nd.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t))},nd.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},nd.destroy=function(){this._batcher.destroy(),this._batcher=null},nd._processMasksDiff=function(e,t){var n=this._preMaskLayer,r=t.maskLayer;if(n!==r)for(var a=e._renderPipeline._allSpriteMasks,i=n&r,o=r&~n,s=n&~r,l=a._elements,c=0,u=a.length;c<u;c++){var h=l[c],d=h.influenceLayers;if(!(d&i)){if(d&o){var _=h._maskElement;_.data.isAdd=!0,this._batcher.drawElement(_,e);continue}if(d&s){var f=h._maskElement;f.data.isAdd=!1,this._batcher.drawElement(f,e)}}}},nh),ug=(lk(n_=function(){var e;return(e=cC.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},cC),(nf=n_.prototype).set=function(e,t,n){this.component=e,this.material=t,this.verticesData=n},nf.dispose=function(){this.component=this.material=this.verticesData=null},n_),um=(lk(np=function(){var e;return(e=cC.call(this)||this).multiRenderData=!1,e},cC),(ng=np.prototype).set=function(e,t,n,r,a){void 0===a&&(a=0),this.component=e,this.material=t,this.verticesData=n,this.texture=r,this.dataIndex=a},ng.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},np),uv=(lk(nm=function(){var e;return(e=cC.call(this)||this).charsData=[],e.multiRenderData=!0,e},cC),nm.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},nm),uy=((ny=(nv=function(){this._array=[],this._loopArray=[],this._loopArrayDirty=!1}).prototype).push=function(e){this._array.push(e),this._loopArrayDirty=!0},ny.add=function(e,t){this._array.splice(e,0,t),this._loopArrayDirty=!0},ny.removeByIndex=function(e){this._array.splice(e,1),this._loopArrayDirty=!0},ny.indexOf=function(e){return this._array.indexOf(e)},ny.getArray=function(){return this._array},ny.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},lU(nv,[{key:"length",get:function(){return this._array.length}}]),nv),ux=((nT=(nx=function(e){this.engine=e,this._allCreatedScenes=[],this._scenes=new uy}).prototype).addScene=function(e,t){if("number"==typeof e?this._scenes.add(e,t):(t=e,this._scenes.push(t)),t.engine!==this.engine)throw"The scene is not belong to this engine.";t._processActive(!0)},nT.removeScene=function(e){var t=this._scenes,n=t.indexOf(e);if(-1!==n){var r=t.getArray()[n];t.removeByIndex(n),r._processActive(!1)}},nT.loadScene=function(e,t){void 0===t&&(t=!0);var n=this,r=this.engine.resourceManager.load(e);return r.then(function(e){var r=n._scenes;if(t)for(var a=0,i=r.length;a<i;a++)r[a].destroy();n.addScene(e)}),r},nT.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,a=n.length;r<a;r++)t.addRootEntity(n[r])},nT._destroyAllScene=function(){for(var e=this._allCreatedScenes;e.length>0;)e[0].destroy()},lU(nx,[{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)}}]),nx),uT=((nC=(nS=function(e){var t=this;this._state="pending",this._onProgressCallback=[],this._promise=new Promise(function(n,r){t._reject=r,e(function(e){"pending"===t._state&&(n(e),t._state="fulfilled",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&(r(e),t._state="rejected",t._onProgressCallback=void 0)},function(e){"pending"===t._state&&t._onProgressCallback.forEach(function(t){return t(e)})},function(e){"pending"===t._state&&(t._onCancelHandler=e)})})}).prototype).onProgress=function(e){return this._onProgressCallback.push(e),this},nC.then=function(e,t){var n=this;return new nS(function(r,a){n._promise.then(e,t).then(r).catch(a)})},nC.catch=function(e){var t=this;return new nS(function(n,r){t._promise.catch(e).then(n).catch(r)})},nC.finally=function(e){return this._promise.finally(e)},nC.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nS.all=function(e){return new nS(function(t,n,r){var a=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},i=function(e,t){lX(e,Promise)||lX(e,nS)?e.then(function(e){a(t,e)},n):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)})},lU(nS,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nS);(nA=sK||(sK={})).Pending="pending",nA.Fulfilled="fulfilled",nA.Rejected="rejected",nA.Canceled="canceled";var uS=((nE=(nw=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this._loadingPromises={},this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._referResourcePool=Object.create(null),this._graphicResourcePool=Object.create(null),this._contentRestorerPool=Object.create(null),this._subAssetPromiseCallbacks={},this._objectPool=Object.create(null),this._editorResourceConfig=Object.create(null),this._virtualPathMap=Object.create(null)}).prototype).load=function(e){var t=this;if(!Array.isArray(e))return this._loadSingleItem(e);var n=e.map(function(e){return t._loadSingleItem(e)});return uT.all(n)},nE.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},nE.findResourcesByType=function(e){var t=[],n=this._referResourcePool;for(var r in n){var a=n[r];lX(a,e)&&t.push(a)}return t},nE.getAssetPath=function(e){return this._assetPool[e]},nE.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()}):c_.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},nE.gc=function(){this._gc(!1),this.engine._pendingGC()},nE.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},nE._onSubAssetSuccess=function(e,t){var n;null==(n=this._subAssetPromiseCallbacks[e])||n.resolve(t),delete this._subAssetPromiseCallbacks[e]},nE._onSubAssetFail=function(e,t){var n;null==(n=this._subAssetPromiseCallbacks[e])||n.reject(t),delete this._subAssetPromiseCallbacks[e]},nE._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},nE._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},nE._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},nE._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},nE._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},nE._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},nE._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},nE._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},nE._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)},nE._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._referResourcePool=null,this._graphicResourcePool=null,this._contentRestorerPool=null,this._loadingPromises=null},nE._assignDefaultOptions=function(e){var t,n,r,a,i;if(e.type=null!=(t=e.type)?t:nw._getTypeByUrl(e.url),void 0===e.type)throw"asset type should be specified: "+e.url;return e.retryCount=null!=(n=e.retryCount)?n:this.retryCount,e.timeout=null!=(r=e.timeout)?r:this.timeout,e.retryInterval=null!=(a=e.retryInterval)?a:this.retryInterval,e.url=null!=(i=e.url)?i:e.urls.join(","),e},nE._loadSingleItem=function(e){var t,n=this,r=this._assignDefaultOptions("string"==typeof e?{url:e}:e),a=r.url,i=this._virtualPathMap[a]?this._virtualPathMap[a]:a,o=this._parseURL(i),s=o.assetBaseURL,l=o.queryPath,c=l?this._parseQueryPath(l):[],u=this._assetUrlPool[s];if(u)return new uT(function(e){e(n._getResolveResource(u,c))});var h=s;if(l)for(h+="?q="+c.shift();t=c.shift();)h+="["+t+"]";var d=this._loadingPromises,_=d[h];if(_)return new uT(function(e,t){_.then(function(t){e(t)}).catch(function(e){t(e)})});var f=nw._loaders[r.type];if(!f)throw"loader not found: "+r.type;r.url=s;var p=f.load(r,this);if(d[s]=p,p.then(function(e){f.useCache&&n._addAsset(s,e),delete d[s]},function(){return delete d[s]}),l){var g=new uT(function(e,t){n._pushSubAssetPromiseCallback(h,e,t)});return d[h]=g,g.then(function(){delete d[h]},function(){return delete d[h]}),p.catch(function(e){n._onSubAssetFail(h,e)}),g}return p},nE._pushSubAssetPromiseCallback=function(e,t,n){this._subAssetPromiseCallbacks[e]={resolve:t,reject:n}},nE._gc=function(e){for(var t=c_.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},nE._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},nE._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},nE._getParameterByName=function(e,t){void 0===t&&(t=window.location.href);var n=RegExp("[?&]"+(e=e.replace(/[\[\]]/g,"\\$&"))+"(=([^&#]*)|&|#|$)").exec(t);return n?n[2]?decodeURIComponent(n[2].replace(/\+/g," ")):"":null},nE._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===uA&&t.push(""),e.replace(uE,function(e,n,r,a){var i=e;r?i=a.replace(uw,"$1"):n&&(i=n.trim()),t.push(i)}),t},nE.getResourceByRef=function(e){var t=e.refId,n=e.key,r=e.isClone,a=this._objectPool[t];if(a)i=Promise.resolve(a);else{var i,o,s=null==(o=this._editorResourceConfig[t])?void 0:o.path;if(!s)return l8.warn("refId:"+t+" is not find in this._editorResourceConfig."),Promise.resolve(null);s=n?""+s+(s.indexOf("?")>-1?"&":"?")+"q="+n:s,i=this.load({url:s,type:this._editorResourceConfig[t].type})}return i.then(function(e){return r?e.clone():e})},nE.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},nw._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,a=n.length;r<a;r++)this._extTypeMapping[n[r]]=e},nw._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},nw);function uC(e,t,n){return void 0===n&&(n=!0),function(r){var a=new r(n);uS._addLoader(e,a,t)}}uS._loaders={},uS._extTypeMapping={};var uA=46,uw=/\\(\\)?/g,uE=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 ub=((nF=(nM=function(t){this.phase=e.PointerPhase.Leave,this.position=new lL,this.deltaPosition=new lL,this._events=[],this._upMap=[],this._downMap=[],this._upList=new cd,this._downList=new cd,this.id=t}).prototype)._firePointerExitAndEnter=function(e){if(this._currentEnteredEntity!==e){if(this._currentEnteredEntity)for(var t=this._currentEnteredEntity._scripts,n=t.length-1;n>=0;n--){var r=t.get(n);r._waitHandlingInValid||r.onPointerExit(this)}if(e)for(var a=e._scripts,i=a.length-1;i>=0;i--){var o=a.get(i);o._waitHandlingInValid||o.onPointerEnter(this)}this._currentEnteredEntity=e}},nF._firePointerDown=function(e){if(e)for(var t=e._scripts,n=t.length-1;n>=0;n--){var r=t.get(n);r._waitHandlingInValid||r.onPointerDown(this)}this._currentPressedEntity=e},nF._firePointerDrag=function(){if(this._currentPressedEntity)for(var e=this._currentPressedEntity._scripts,t=e.length-1;t>=0;t--){var n=e.get(t);n._waitHandlingInValid||n.onPointerDrag(this)}},nF._firePointerUpAndClick=function(e){var t=this._currentPressedEntity;if(t){for(var n=t===e,r=t._scripts,a=r.length-1;a>=0;a--){var i=r.get(a);i._waitHandlingInValid||(n&&i.onPointerClick(this),i.onPointerUp(this))}this._currentPressedEntity=null}},nM);e.PointerButton=void 0,(nR=e.PointerButton||(e.PointerButton={}))[nR.None=0]="None",nR[nR.Primary=1]="Primary",nR[nR.Secondary=2]="Secondary",nR[nR.Auxiliary=4]="Auxiliary",nR[nR.XButton1=8]="XButton1",nR[nR.XButton2=16]="XButton2",nR[nR.XButton3=32]="XButton3",nR[nR.XButton4=64]="XButton4",nR[nR.XButton5=128]="XButton5",nR[nR.XButton6=256]="XButton6",nR[nR.XButton7=512]="XButton7",nR[nR.XButton8=1024]="XButton8";var uM=[1,4,2,8,16,32,64,128,256,512,1024],uF={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},uR=((nP=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?nP.platform=e.Platform.IPhone:/iPad/i.test(n)?nP.platform=e.Platform.IPad:/Android/i.test(n)?nP.platform=e.Platform.Android:/Macintosh/i.test(n)&&(nP.platform=e.Platform.Mac),nP.platform){case e.Platform.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 e.Platform.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 e.Platform.Android:t=n.match(/Android (\d+).?(\d+)?.?(\d+)?/),this.operatingSystem=t?"Android "+t[1]+"."+(t[2]||0)+"."+(t[3]||0):"Android";break;case e.Platform.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"}}},lU(nP,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nP);uR.platform=e.Platform.Unknown,uR.operatingSystem="",uR._initialize(),e.Keys=void 0,(nL=e.Keys||(e.Keys={}))[nL.Backquote=0]="Backquote",nL[nL.Backslash=1]="Backslash",nL[nL.Backspace=2]="Backspace",nL[nL.BracketLeft=3]="BracketLeft",nL[nL.BracketRight=4]="BracketRight",nL[nL.Comma=5]="Comma",nL[nL.Digit0=6]="Digit0",nL[nL.Digit1=7]="Digit1",nL[nL.Digit2=8]="Digit2",nL[nL.Digit3=9]="Digit3",nL[nL.Digit4=10]="Digit4",nL[nL.Digit5=11]="Digit5",nL[nL.Digit6=12]="Digit6",nL[nL.Digit7=13]="Digit7",nL[nL.Digit8=14]="Digit8",nL[nL.Digit9=15]="Digit9",nL[nL.Equal=16]="Equal",nL[nL.IntlBackslash=17]="IntlBackslash",nL[nL.IntlRo=18]="IntlRo",nL[nL.IntlYen=19]="IntlYen",nL[nL.KeyA=20]="KeyA",nL[nL.KeyB=21]="KeyB",nL[nL.KeyC=22]="KeyC",nL[nL.KeyD=23]="KeyD",nL[nL.KeyE=24]="KeyE",nL[nL.KeyF=25]="KeyF",nL[nL.KeyG=26]="KeyG",nL[nL.KeyH=27]="KeyH",nL[nL.KeyI=28]="KeyI",nL[nL.KeyJ=29]="KeyJ",nL[nL.KeyK=30]="KeyK",nL[nL.KeyL=31]="KeyL",nL[nL.KeyM=32]="KeyM",nL[nL.KeyN=33]="KeyN",nL[nL.KeyO=34]="KeyO",nL[nL.KeyP=35]="KeyP",nL[nL.KeyQ=36]="KeyQ",nL[nL.KeyR=37]="KeyR",nL[nL.KeyS=38]="KeyS",nL[nL.KeyT=39]="KeyT",nL[nL.KeyU=40]="KeyU",nL[nL.KeyV=41]="KeyV",nL[nL.KeyW=42]="KeyW",nL[nL.KeyX=43]="KeyX",nL[nL.KeyY=44]="KeyY",nL[nL.KeyZ=45]="KeyZ",nL[nL.Minus=46]="Minus",nL[nL.Period=47]="Period",nL[nL.Quote=48]="Quote",nL[nL.Semicolon=49]="Semicolon",nL[nL.Slash=50]="Slash",nL[nL.AltLeft=51]="AltLeft",nL[nL.AltRight=52]="AltRight",nL[nL.CapsLock=53]="CapsLock",nL[nL.ContextMenu=54]="ContextMenu",nL[nL.ControlLeft=55]="ControlLeft",nL[nL.ControlRight=56]="ControlRight",nL[nL.Enter=57]="Enter",nL[nL.MetaLeft=58]="MetaLeft",nL[nL.MetaRight=59]="MetaRight",nL[nL.ShiftLeft=60]="ShiftLeft",nL[nL.ShiftRight=61]="ShiftRight",nL[nL.Space=62]="Space",nL[nL.Tab=63]="Tab",nL[nL.Convert=64]="Convert",nL[nL.KanaMode=65]="KanaMode",nL[nL.Lang1=66]="Lang1",nL[nL.Lang2=67]="Lang2",nL[nL.Lang3=68]="Lang3",nL[nL.Lang4=69]="Lang4",nL[nL.Lang5=70]="Lang5",nL[nL.NonConvert=71]="NonConvert",nL[nL.Delete=72]="Delete",nL[nL.End=73]="End",nL[nL.Help=74]="Help",nL[nL.Home=75]="Home",nL[nL.Insert=76]="Insert",nL[nL.PageDown=77]="PageDown",nL[nL.PageUp=78]="PageUp",nL[nL.ArrowDown=79]="ArrowDown",nL[nL.ArrowLeft=80]="ArrowLeft",nL[nL.ArrowRight=81]="ArrowRight",nL[nL.ArrowUp=82]="ArrowUp",nL[nL.NumLock=83]="NumLock",nL[nL.Numpad0=84]="Numpad0",nL[nL.Numpad1=85]="Numpad1",nL[nL.Numpad2=86]="Numpad2",nL[nL.Numpad3=87]="Numpad3",nL[nL.Numpad4=88]="Numpad4",nL[nL.Numpad5=89]="Numpad5",nL[nL.Numpad6=90]="Numpad6",nL[nL.Numpad7=91]="Numpad7",nL[nL.Numpad8=92]="Numpad8",nL[nL.Numpad9=93]="Numpad9",nL[nL.NumpadAdd=94]="NumpadAdd",nL[nL.NumpadBackspace=95]="NumpadBackspace",nL[nL.NumpadClear=96]="NumpadClear",nL[nL.NumpadClearEntry=97]="NumpadClearEntry",nL[nL.NumpadComma=98]="NumpadComma",nL[nL.NumpadDecimal=99]="NumpadDecimal",nL[nL.NumpadDivide=100]="NumpadDivide",nL[nL.NumpadEnter=101]="NumpadEnter",nL[nL.NumpadEqual=102]="NumpadEqual",nL[nL.NumpadHash=103]="NumpadHash",nL[nL.NumpadMemoryAdd=104]="NumpadMemoryAdd",nL[nL.NumpadMemoryClear=105]="NumpadMemoryClear",nL[nL.NumpadMemoryRecall=106]="NumpadMemoryRecall",nL[nL.NumpadMemoryStore=107]="NumpadMemoryStore",nL[nL.NumpadMemorySubtract=108]="NumpadMemorySubtract",nL[nL.NumpadMultiply=109]="NumpadMultiply",nL[nL.NumpadParenLeft=110]="NumpadParenLeft",nL[nL.NumpadParenRight=111]="NumpadParenRight",nL[nL.NumpadStar=112]="NumpadStar",nL[nL.NumpadSubtract=113]="NumpadSubtract",nL[nL.Escape=114]="Escape",nL[nL.F1=115]="F1",nL[nL.F2=116]="F2",nL[nL.F3=117]="F3",nL[nL.F4=118]="F4",nL[nL.F5=119]="F5",nL[nL.F6=120]="F6",nL[nL.F7=121]="F7",nL[nL.F8=122]="F8",nL[nL.F9=123]="F9",nL[nL.F10=124]="F10",nL[nL.F11=125]="F11",nL[nL.F12=126]="F12",nL[nL.F13=127]="F13",nL[nL.F14=128]="F14",nL[nL.F15=129]="F15",nL[nL.Fn=130]="Fn",nL[nL.FnLock=131]="FnLock",nL[nL.PrintScreen=132]="PrintScreen",nL[nL.ScrollLock=133]="ScrollLock",nL[nL.Pause=134]="Pause",nL[nL.BrowserBack=135]="BrowserBack",nL[nL.BrowserFavorites=136]="BrowserFavorites",nL[nL.BrowserForward=137]="BrowserForward",nL[nL.BrowserHome=138]="BrowserHome",nL[nL.BrowserRefresh=139]="BrowserRefresh",nL[nL.BrowserSearch=140]="BrowserSearch",nL[nL.BrowserStop=141]="BrowserStop",nL[nL.Eject=142]="Eject",nL[nL.LaunchApp1=143]="LaunchApp1",nL[nL.LaunchApp2=144]="LaunchApp2",nL[nL.LaunchMail=145]="LaunchMail",nL[nL.MediaPlayPause=146]="MediaPlayPause",nL[nL.MediaSelect=147]="MediaSelect",nL[nL.MediaStop=148]="MediaStop",nL[nL.MediaTrackNext=149]="MediaTrackNext",nL[nL.MediaTrackPrevious=150]="MediaTrackPrevious",nL[nL.Power=151]="Power",nL[nL.Sleep=152]="Sleep",nL[nL.AudioVolumeDown=153]="AudioVolumeDown",nL[nL.AudioVolumeMute=154]="AudioVolumeMute",nL[nL.AudioVolumeUp=155]="AudioVolumeUp",nL[nL.WakeUp=156]="WakeUp",nL[nL.Hyper=157]="Hyper",nL[nL.Super=158]="Super",nL[nL.Turbo=159]="Turbo",nL[nL.Abort=160]="Abort",nL[nL.Resume=161]="Resume",nL[nL.Suspend=162]="Suspend",nL[nL.Again=163]="Again",nL[nL.Copy=164]="Copy",nL[nL.Cut=165]="Cut",nL[nL.Find=166]="Find",nL[nL.Open=167]="Open",nL[nL.Paste=168]="Paste",nL[nL.Props=169]="Props",nL[nL.Select=170]="Select",nL[nL.Undo=171]="Undo",nL[nL.Hiragana=172]="Hiragana",nL[nL.Katakana=173]="Katakana",nL[nL.Unidentified=174]="Unidentified";var uP=((nB=(nD=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new cd,this._curFrameDownList=new cd,this._curFrameUpList=new cd,this._nativeEvents=[],this._hadListener=!1;var t=e._canvas._webCanvas;this._engine=e,this._htmlCanvas=t,t.tabIndex=t.tabIndex,this._onKeyEvent=this._onKeyEvent.bind(this),t.addEventListener("keydown",this._onKeyEvent),t.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0}).prototype)._update=function(){var t=this._nativeEvents,n=this._curFrameDownList,r=this._curFrameUpList;if(n.length=0,r.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 h=t[c],d=e.Keys[h.code];switch(h.type){case"keydown":null==i[d]&&(n.add(d),o.add(d),i[d]=o.length-1,s[d]=a);break;case"keyup":var _=i[d];if(null!=_){i[d]=null;var f=o.deleteByIndex(_);f&&(i[f]=_)}if(r.add(d),l[d]=a,uR.platform===e.Platform.Mac&&(d===e.Keys.MetaLeft||d===e.Keys.MetaRight)){for(var p=0,g=o.length;p<g;p++)i[o.get(p)]=null;o.length=0}}}t.length=0}},nB._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},nB._onBlur=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._curHeldDownKeyToIndexMap.length=0,this._curFrameHeldDownList.length=0,this._curFrameDownList.length=0,this._curFrameUpList.length=0,this._nativeEvents.length=0,this._hadListener=!1)},nB._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),this._curHeldDownKeyToIndexMap.length=0,this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap.length=0,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap.length=0,this._downKeyToFrameCountMap=null,this._nativeEvents.length=0,this._nativeEvents=null,this._curFrameHeldDownList.length=0,this._curFrameHeldDownList=null,this._curFrameDownList.length=0,this._curFrameDownList=null,this._curFrameUpList.length=0,this._curFrameUpList=null,this._htmlCanvas=null,this._engine=null},nB._onKeyEvent=function(e){this._nativeEvents.push(e)},nD);e.CameraClearFlags=void 0,(nI=e.CameraClearFlags||(e.CameraClearFlags={}))[nI.None=0]="None",nI[nI.Color=1]="Color",nI[nI.Depth=2]="Depth",nI[nI.Stencil=4]="Stencil",nI[nI.ColorDepth=3]="ColorDepth",nI[nI.ColorStencil=5]="ColorStencil",nI[nI.DepthStencil=6]="DepthStencil",nI[nI.All=7]="All",e.Collider=(lk(nV=function(e){var t;return(t=cc.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},cc),(nO=nV.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this.scene.physics._addColliderShape(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape))},nO.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this.scene.physics._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},nO.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++){var r=e[t];this.scene.physics._removeColliderShape(r),r._destroy(),this._nativeCollider.removeShape(r._nativeShape)}e.length=0},nO._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}},nO._onLateUpdate=function(){},nO._onEnableInScene=function(){this.scene.physics._addCollider(this)},nO._onDisableInScene=function(){this.scene.physics._removeCollider(this)},nO._onDestroy=function(){cc.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},lU(nV,[{key:"shapes",get:function(){return this._shapes}}]),nV),lW([lK],e.Collider.prototype,"_index",void 0),e.Collider=lW([ch(cy,e.DependentMode.CheckOnly)],e.Collider);var uL=function(){function t(e){var n=this;this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new cd,this._gravity=new lS(0,-9.81,0),this._onContactEnter=function(e,r){for(var a=n._scene.engine._physicalObjectsMap,i=a[e],o=a[r],s=i.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionEnter(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=i,f.onCollisionEnter(p)}}},this._onContactExit=function(e,r){for(var a=n._scene.engine._physicalObjectsMap,i=a[e],o=a[r],s=i.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionExit(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=i,f.onCollisionExit(p)}}},this._onContactStay=function(e,r){for(var a=n._scene.engine._physicalObjectsMap,i=a[e],o=a[r],s=i.collider.entity._scripts,l=0,c=s.length;l<c;l++){var u=s.get(l);if(!u._waitHandlingInValid){var h=t._collision;h.shape=o,u.onCollisionStay(h)}}s=o.collider.entity._scripts;for(var d=0,_=s.length;d<_;d++){var f=s.get(d);if(!f._waitHandlingInValid){var p=t._collision;p.shape=i,f.onCollisionStay(p)}}},this._onTriggerEnter=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t],o=a.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerEnter(i)}o=i.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerEnter(a)}},this._onTriggerExit=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t],o=a.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerExit(i)}o=i.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerExit(a)}},this._onTriggerStay=function(e,t){for(var r=n._scene.engine._physicalObjectsMap,a=r[e],i=r[t],o=a.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);c._waitHandlingInValid||c.onTriggerStay(i)}o=i.collider.entity._scripts;for(var u=0,h=o.length;u<h;u++){var d=o.get(u);d._waitHandlingInValid||d.onTriggerStay(a)}},this._scene=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity;var r=e.engine;r._physicsInitialized&&(this._nativePhysicsScene=t._nativePhysics.createPhysicsScene(r._nativePhysicsManager,this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay))}var n=t.prototype;return n.raycast=function(t,n,r,a){var i,o=this,s=Number.MAX_VALUE;"number"==typeof n?s=n:void 0!=n&&(i=n);var l=e.Layer.Everything;"number"==typeof r?l=r:void 0!=r&&(i=r),a&&(i=a);var c=function(e){var t=o._scene.engine._physicalObjectsMap[e];return 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,n,r){i.entity=o._scene.engine._physicalObjectsMap[e]._collider.entity,i.distance=t,i.normal.copyFrom(r),i.point.copyFrom(n)})||(i.entity=null,i.distance=0,i.point.set(0,0,0),i.normal.set(0,0,0),!1)},n._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()},n._addColliderShape=function(e){this._scene.engine._physicalObjectsMap[e.id]=e,this._nativePhysicsScene.addColliderShape(e._nativeShape)},n._removeColliderShape=function(e){delete this._scene.engine._physicalObjectsMap[e.id],this._nativePhysicsScene.removeColliderShape(e._nativeShape)},n._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCollider(e._nativeCollider)},n._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsScene.addCharacterController(e._nativeCollider)},n._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCollider(e._nativeCollider)},n._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsScene.removeCharacterController(e._nativeCollider)},n._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},n._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},n._gc=function(){this._colliders.garbageCollection()},n._setGravity=function(){this._nativePhysicsScene.setGravity(this._gravity)},lU(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,lT.zeroTolerance)}}]),t}();uL._collision=new function(){},e.ControllerNonWalkableMode=void 0,(nN=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nN.PreventClimbing=0]="PreventClimbing",nN[nN.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var uD=(nU=e.Collider,lk(nz=function(t){var n;return(n=nU.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new lS(0,1,0),n._slopeLimit=.707,n._nativeCollider=uL._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(lO(n)),n._upDirection._onValueChanged=n._setUpDirection,n},nU),(nk=nz.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},nk.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nU.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nk.clearShapes=function(){this._shapes.length>0&&nU.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 n=e.lossyWorldScale,r=0,a=t.length;r<a;r++)t[r]._nativeShape.setWorldScale(n);this._updateFlag.flag=!1}},nk._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},nk._onEnableInScene=function(){this.scene.physics._addCharacterController(this)},nk._onDisableInScene=function(){this.scene.physics._removeCharacterController(this)},nk._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},lU(nz,[{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))}}]),nz),uB=(nG=e.Collider,lk(nH=function(e){(t=nG.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new lS,t._angularVelocity=new lS,t._mass=1,t._centerOfMass=new lS,t._inertiaTensor=new lS(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,n=t.entity.transform;return t._nativeCollider=uL._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(lO(t)),t._setAngularVelocity=t._setAngularVelocity.bind(lO(t)),t._setCenterOfMass=t._setCenterOfMass.bind(lO(t)),t._setInertiaTensor=t._setInertiaTensor.bind(lO(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},nG),(nW=nH.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},nW.applyTorque=function(e){this._nativeCollider.addTorque(e)},nW.move=function(e,t){this._nativeCollider.move(e,t)},nW.sleep=function(){this._nativeCollider.sleep()},nW.wakeUp=function(){this._nativeCollider.wakeUp()},nW._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},nW._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},nW._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},nW._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},nW._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},lU(nH,[{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))}}]),nH);e.CollisionDetectionMode=void 0,(nX=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[nX.Discrete=0]="Discrete",nX[nX.Continuous=1]="Continuous",nX[nX.ContinuousDynamic=2]="ContinuousDynamic",nX[nX.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(nK=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[nK.None=0]="None",nK[nK.FreezePositionX=1]="FreezePositionX",nK[nK.FreezePositionY=2]="FreezePositionY",nK[nK.FreezePositionZ=4]="FreezePositionZ",nK[nK.FreezeRotationX=8]="FreezeRotationX",nK[nK.FreezeRotationY=16]="FreezeRotationY",nK[nK.FreezeRotationZ=32]="FreezeRotationZ";var uI=function(){this.entity=null,this.distance=0,this.point=new lS,this.normal=new lS};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 uV=((nq=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=uL._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},lU(nq,[{key:"bounciness",get:function(){return this._bounciness},set:function(e){this._bounciness!==e&&(this._bounciness=e,this._nativeMaterial.setBounciness(e))}},{key:"dynamicFriction",get:function(){return this._dynamicFriction},set:function(e){this._dynamicFriction!==e&&(this._dynamicFriction=e,this._nativeMaterial.setDynamicFriction(e))}},{key:"staticFriction",get:function(){return this._staticFriction},set:function(e){this._staticFriction!==e&&(this._staticFriction=e,this._nativeMaterial.setStaticFriction(e))}},{key:"bounceCombine",get:function(){return this._bounceCombine},set:function(e){this._bounceCombine!==e&&(this._bounceCombine=e,this._nativeMaterial.setBounceCombine(e))}},{key:"frictionCombine",get:function(){return this._frictionCombine},set:function(e){this._frictionCombine!==e&&(this._frictionCombine=e,this._nativeMaterial.setFrictionCombine(e))}}]),nq),uO=(nY=e.Collider,lk(nQ=function(e){var t,n=(t=nY.call(this,e)||this).entity.transform;return t._nativeCollider=uL._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},nY),nQ);e.ColliderShapeUpAxis=void 0,(nJ=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[nJ.X=0]="X",nJ[nJ.Y=1]="Y",nJ[nJ.Z=2]="Z",e.ControllerCollisionFlag=void 0,(nZ=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[nZ.Sides=1]="Sides",nZ[nZ.Up=2]="Up",nZ[nZ.Down=4]="Down",e.Joint=(lk(n$=function(e){var t;return(t=cc.call(this,e)||this)._connectedCollider=new uN,t._collider=new uN,t._force=0,t._torque=0,t._connectedCollider.localPosition=new lS,t},cc),lU(n$,[{key:"connectedCollider",get:function(){return this._connectedCollider.collider},set:function(e){this._connectedCollider.collider!==e&&(this._connectedCollider.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedCollider.localPosition},set:function(e){var t=this._connectedCollider.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedCollider.massScale},set:function(e){e!==this._connectedCollider.massScale&&(this._connectedCollider.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedCollider.inertiaScale},set:function(e){e!==this._connectedCollider.inertiaScale&&(this._connectedCollider.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._collider.massScale},set:function(e){e!==this._collider.massScale&&(this._collider.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._collider.inertiaScale},set:function(e){e!==this._collider.inertiaScale&&(this._collider.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))}}]),n$),e.Joint=lW([ch(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var uN=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},uU=(n0=e.Joint,lk(n1=function(){return n0.apply(this,arguments)},n0),n1.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uL._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n1);(n2=sj||(sj={}))[n2.LimitEnabled=1]="LimitEnabled",n2[n2.DriveEnabled=2]="DriveEnabled",n2[n2.DriveFreeSpin=4]="DriveFreeSpin";var uz=(n3=e.Joint,lk(n4=function(){var e;return e=n3.apply(this,arguments)||this,e._axis=new lS(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},n3),n4.prototype._onAwake=function(){var t=this._collider;t.localPosition=new lS,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uL._nativePhysics.createHingeJoint(t.collider._nativeCollider)},lU(n4,[{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._collider.localPosition},set:function(e){var t=this._collider.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&sj.LimitEnabled)==sj.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=sj.LimitEnabled),this._nativeJoint.setHingeJointFlag(sj.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&sj.DriveEnabled)==sj.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=sj.DriveEnabled),this._nativeJoint.setHingeJointFlag(sj.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(sj.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))}}]),n4),uk=(n5=e.Joint,lk(n8=function(){var e;return e=n5.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},n5),n8.prototype._onAwake=function(){var t=this._collider;t.localPosition=new lS,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=uL._nativePhysics.createSpringJoint(t.collider._nativeCollider)},lU(n8,[{key:"swingOffset",get:function(){return this._collider.localPosition},set:function(e){var t=this._collider.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))}}]),n8),uG=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},uH=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1},uW=function(){function e(){this._isTrigger=!1,this._rotation=new lS,this._position=new lS,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new uV,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._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},lU(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}();uW._idGenerator=0;var uX=(lk(n6=function(){var e;return(e=uW.call(this)||this)._size=new lS(1,1,1),e._nativeShape=uL._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(lO(e)),e._size._onValueChanged=e._setSize,e},uW),n6.prototype._setSize=function(){this._nativeShape.setSize(this._size)},lU(n6,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),n6),uK=(lk(n7=function(){var e;return(e=uW.call(this)||this)._radius=1,e._nativeShape=uL._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},uW),lU(n7,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),n7),uj=(lk(n9=function(){var e;return(e=uW.call(this)||this)._nativeShape=uL._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},uW),n9),uq=(lk(re=function(){var t;return(t=uW.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=uL._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},uW),lU(re,[{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))}}]),re),uY=((rn=(rt=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new cd,this._downList=new cd,this._nativeEvents=[],this._hadListener=!1;var n=t._canvas._webCanvas;this._engine=t,this._canvas=t.canvas,this._htmlCanvas=n,this._onPointerEvent=this._onPointerEvent.bind(this),this._onFocus(),this._pointerPool=Array(11)}).prototype)._update=function(){var t=this._pointers,n=this._nativeEvents,r=t.length-1;if(r>=0)for(var a=r;a>=0;a--)t[a].phase===e.PointerPhase.Leave&&t.splice(a,1);if((r=n.length-1)>=0){for(var i=0;i<=r;i++){var o,s=n[i];null==(o=this._getPointer(s.pointerId))||o._events.push(s)}n.length=0}if(this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None,(r=t.length-1)>=0)for(var l=this._engine.time.frameCount,c=this._htmlCanvas.getBoundingClientRect(),u=c.left,h=c.top,d=this._htmlCanvas,_=d.clientWidth,f=d.clientHeight,p=this._canvas,g=p.width,m=p.height,v=g/_,y=m/f,x=r;x>=0;x--){var T=t[x];T._upList.length=T._downList.length=0,this._updatePointerInfo(l,T,u,h,v,y),this._buttons|=T.pressedButtons}},rn._firePointerScript=function(t){for(var n=this._pointers,r=this._canvas,a=0,i=n.length;a<i;a++){var o=n[a],s=o._events,l=o.position;o._firePointerDrag();var c=this._pointerRayCast(t,l.x/r.width,l.y/r.height);o._firePointerExitAndEnter(c);var u=s.length;if(u>0){for(var h=0;h<u;h++)switch(s[h].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}}},rn._onFocus=function(){if(!this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.addEventListener("pointerdown",t),e.addEventListener("pointerup",t),e.addEventListener("pointerleave",t),e.addEventListener("pointermove",t),e.addEventListener("pointercancel",t),this._hadListener=!0}},rn._onBlur=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1,this._pointers.length=0,this._downList.length=0,this._upList.length=0}},rn._destroy=function(){if(this._hadListener){var e=this._htmlCanvas,t=this._onPointerEvent;e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",t),e.removeEventListener("pointerleave",t),e.removeEventListener("pointermove",t),e.removeEventListener("pointercancel",t),this._hadListener=!1}this._pointerPool.length=0,this._pointerPool=null,this._pointers.length=0,this._pointers=null,this._downList.length=0,this._downList=null,this._upList.length=0,this._upList=null,this._nativeEvents.length=0,this._nativeEvents=null,this._upMap.length=0,this._upMap=null,this._downMap.length=0,this._downMap=null,this._htmlCanvas=null,this._canvas=null,this._engine=null},rn._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},rn._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},rn._getPointer=function(e){var t=this._pointers,n=this._getIndexByPointerID(e);if(n>=0)return t[n];var r=t.length;if(0!==r&&!this._multiPointerEnabled)return null;for(var a=this._pointerPool,i=0;i<r&&!(t[i].id>i);i++);var o=a[i];return o||(o=a[i]=new ub(i)),o._uniqueID=e,t.splice(i,0,o),o},rn._updatePointerInfo=function(t,n,r,a,i,o){var s=n._events,l=n.position,c=s.length;if(c>0){var u=this._upList,h=this._upMap,d=this._downList,_=this._downMap,f=s[c-1],p=(f.clientX-r)*i,g=(f.clientY-a)*o;n.deltaPosition.set(p-l.x,g-l.y),l.set(p,g);for(var m=0;m<c;m++){var v=s[m],y=v.button;switch(n.button=uM[y]||e.PointerButton.None,n.pressedButtons=v.buttons,v.type){case"pointerdown":d.add(y),_[y]=t,n._downList.add(y),n._downMap[y]=t,n.phase=e.PointerPhase.Down;break;case"pointerup":u.add(y),h[y]=t,n._upList.add(y),n._upMap[y]=t,n.phase=e.PointerPhase.Up;break;case"pointermove":n.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":n.phase=e.PointerPhase.Leave}}this._engine._physicsInitialized||(s.length=0)}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary},rn._pointerRayCast=function(t,n,r){for(var a=rt._tempPoint,i=rt._tempRay,o=rt._tempHitResult,s=t.length-1;s>=0;s--){var l=t[s];if(!l.destroyed)for(var c=l._activeCameras,u=0;u<c.length;u++){var h=c[s];if(h.enabled&&!h.renderTarget){var d=h.viewport,_=d.x,f=d.y,p=d.z,g=d.w;if(n>=_&&r>=f&&n-_<=p&&r-f<=g){if(a.set((n-_)/p,(r-f)/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},rt);uY._tempRay=new lP,uY._tempPoint=new lL,uY._tempHitResult=new uI;var uQ=((ra=(rr=function(e){this._delta=new lS,this._nativeEvents=[];var t=e._canvas._webCanvas;this._onWheelEvent=this._onWheelEvent.bind(this),t.addEventListener("wheel",this._onWheelEvent),this._canvas=t,this._hadListener=!0}).prototype)._update=function(){var e=this._delta;e.set(0,0,0);var t=this._nativeEvents;if(t.length>0){for(var 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}},ra._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},ra._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},ra._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null,this._canvas=null,this._delta=null},ra._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},rr),uJ=((ro=(ri=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&lX(t,OffscreenCanvas)||(this._wheelManager=new uQ(e),this._pointerManager=new uY(e),this._keyboardManager=new uP(e),this._onBlur=this._onBlur.bind(this),window.addEventListener("blur",this._onBlur),this._onFocus=this._onFocus.bind(this),window.addEventListener("focus",this._onFocus),this._initialized=!0)}).prototype).isKeyHeldDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameHeldDownList.length>0:null!=this._keyboardManager._curHeldDownKeyToIndexMap[e])},ro.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},ro.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},ro.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},ro.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[uF[e]]===this._engine.time.frameCount)},ro.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[uF[e]]===this._engine.time.frameCount)},ro._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},ro._firePointerScript=function(e){this._initialized&&this._pointerManager._firePointerScript(e)},ro._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._wheelManager=null,this._pointerManager._destroy(),this._pointerManager=null,this._keyboardManager._destroy(),this._keyboardManager=null)},ro._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},ro._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},lU(ri,[{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}}]),ri),uZ=(lk(rs=function(e,t){var n;return(n=lZ.call(this,e)||this)._renderStates=[],n._shaderData=new cW(sB.Material),n.shader=t,n},lZ),(rl=rs.prototype).clone=function(){var e=new rs(this._engine,this.shader);return this.cloneTo(e),e},rl.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),lQ.deepCloneObject(this.renderStates,e.renderStates)},rl._addReferCount=function(e){this._destroyed||(lZ.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e))},rl._onDestroy=function(){lZ.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},lU(rs,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){this._shader=e;for(var t=this._renderStates,n=t.length,r=0,a=e.subShaders,i=0;i<a.length;i++)r=Math.max(a[i].passes.length,r);if(n<r)for(var o=n;o<r;o++)t.push(new cG);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rs);function u$(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 u0(e){return function(e){if(Array.isArray(e))return u$(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return u$(e,t);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 u$(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var u1="#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}",u2=((rc=function(){}).init=function(){var t=new cI("#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\nuniform mat4 camera_VPMat;uniform vec2 scene_ShadowBias;uniform vec3 scene_LightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=scene_LightDirection*scene_ShadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-scene_LightDirection,normalWS),0.0,1.0);float scale=invNdotL*scene_ShadowBias.y;positionWS+=normalWS*vec3(scale);return positionWS;}void main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\nvec4 positionWS=renderer_ModelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef MATERIAL_OMIT_NORMAL\n#ifdef RENDERER_HAS_NORMAL\nvec3 normalWS=normalize(mat3(renderer_NormalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=camera_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nvec4 pack(float depth){const vec4 bitShift=vec4(1.0,256.0,256.0*256.0,256.0*256.0*256.0);const vec4 bitMask=vec4(1.0/256.0,1.0/256.0,1.0/256.0,0.0);vec4 rgbaDepth=fract(depth*bitShift);rgbaDepth-=rgbaDepth.gbaa*bitMask;return rgbaDepth;}\n#endif\nvoid main(){\n#ifdef ENGINE_NO_DEPTH_TEXTURE\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\n#endif\n}",{pipelineStage:e.PipelineStage.ShadowCaster}),n=new cI("#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}),r=[t,n],a={pipelineStage:e.PipelineStage.Forward};cH.create("blinn-phong",[new cI("#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)].concat(u0(r))),cH.create("pbr",[new cI(u1,"#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)].concat(u0(r))),cH.create("pbr-specular",[new cI(u1,"#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)].concat(u0(r))),cH.create("unlit",[new cI("#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)].concat(u0(r))),cH.create("skybox",[new cI("#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)]),cH.create("SkyProcedural",[new cI("#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)]),cH.create("particle-shader",[new cI("#define GLSLIFY 1\nattribute vec3 a_position;attribute vec3 a_velocity;attribute vec3 a_acceleration;attribute vec4 a_color;attribute vec4 a_lifeAndSize;attribute vec2 a_rotation;attribute vec3 a_uv;attribute vec2 a_normalizedUv;uniform float u_time;uniform bool u_once;uniform mat4 renderer_MVPMat;varying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;\n#ifdef is2d\nuniform mat4 camera_ViewInvMat;uniform mat4 camera_ProjMat;uniform mat4 camera_ViewMat;uniform mat4 renderer_ModelMat;\n#endif\nmat2 rotation2d(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_color=a_color;v_uv=a_uv.xy;float life=a_lifeAndSize.y;float startTime=a_lifeAndSize.x;float deltaTime=max(mod(u_time-startTime,life),0.0);if((u_once&&u_time>life+startTime)){deltaTime=0.0;}v_lifeLeft=1.0-deltaTime/life;float scale=a_lifeAndSize.z;vec3 position=a_position+(a_velocity+a_acceleration*deltaTime*0.5)*deltaTime;\n#ifdef isScaleByLifetime\nscale*=v_lifeLeft;\n#else\nscale*=pow(a_lifeAndSize.w,deltaTime);\n#endif\n#ifdef rotateToVelocity\nvec3 v=a_velocity+a_acceleration*deltaTime;float angle=atan(v.z,v.x)*2.0;\n#else\nfloat deltaAngle=deltaTime*a_rotation.y;float angle=a_rotation.x+deltaAngle;\n#endif\n#ifdef is2d\nvec2 rotatedPoint=rotation2d(angle)*vec2(a_normalizedUv.x,a_normalizedUv.y*a_uv.z);vec3 basisX=camera_ViewInvMat[0].xyz;vec3 basisZ=camera_ViewInvMat[1].xyz;vec3 localPosition=vec3(basisX*rotatedPoint.x+basisZ*rotatedPoint.y)*scale+position;gl_Position=camera_ProjMat*camera_ViewMat*vec4(localPosition+renderer_ModelMat[3].xyz,1.);\n#else\n#ifdef rotateToVelocity\nfloat s=sin(angle);float c=cos(angle);\n#else\nfloat s=sin(angle);float c=cos(angle);\n#endif\nvec4 rotatedPoint=vec4((a_normalizedUv.x*c+a_normalizedUv.y*a_uv.z*s)*scale,0.,(a_normalizedUv.x*s-a_normalizedUv.y*a_uv.z*c)*scale,1.);vec4 orientation=vec4(0,0,0,1);vec4 q2=orientation+orientation;vec4 qx=orientation.xxxw*q2.xyzx;vec4 qy=orientation.xyyw*q2.xyzy;vec4 qz=orientation.xxzw*q2.xxzz;mat4 localMatrix=mat4((1.0-qy.y)-qz.z,qx.y+qz.w,qx.z-qy.w,0,qx.y-qz.w,(1.0-qx.x)-qz.z,qy.z+qx.w,0,qx.z+qy.w,qy.z-qx.w,(1.0-qx.x)-qy.y,0,position.x,position.y,position.z,1);rotatedPoint=localMatrix*rotatedPoint;gl_Position=renderer_MVPMat*rotatedPoint;\n#endif\n}","#define GLSLIFY 1\nvarying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;uniform sampler2D u_texture;void main(){if(v_lifeLeft==1.0){discard;}float alphaFactor=1.0;\n#ifdef fadeIn\nfloat fadeInFactor=step(0.5,v_lifeLeft);alphaFactor=2.0*fadeInFactor*(1.0-v_lifeLeft)+(1.0-fadeInFactor);\n#endif\n#ifdef fadeOut\nfloat fadeOutFactor=step(0.5,v_lifeLeft);alphaFactor=alphaFactor*2.0*(1.0-fadeOutFactor)*v_lifeLeft+alphaFactor*fadeOutFactor;\n#endif\n#ifdef particleTexture\nvec4 tex=texture2D(u_texture,v_uv);\n#ifdef useOriginColor\ngl_FragColor=vec4(tex.rgb,alphaFactor*tex.a*v_color.w);\n#else\ngl_FragColor=vec4(v_color.xyz*tex.rgb,alphaFactor*tex.a*v_color.w);\n#endif\n#else\ngl_FragColor=vec4(v_color.xyz,alphaFactor*v_color.w);\n#endif\n}",a)]),cH.create("SpriteMask",[new cI("#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)]),cH.create("Sprite",[new cI("#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)]),cH.create("background-texture",[new cI("#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D material_BaseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(material_BaseTexture,v_uv);}",a)])},rc),u3=((rh=(ru=function(){this._cacheHierarchy=1,this._cacheMap=Object.create(null)}).prototype).get=function(e){var t=this._cacheMap,n=e._length;n>this._cacheHierarchy&&this._resizeCacheMapHierarchy(t,0,n);for(var r=e._mask,a=e._length-1,i=this._cacheHierarchy-1,o=0;o<i;o++){var s=a<o?0:r[o],l=t[s];l||(t[s]=l=Object.create(null)),t=l}var c=a<i?0:r[i],u=t[c];return u||(this._lastQueryKey=c,this._lastQueryMap=t),u},rh.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rh._resizeCacheMapHierarchy=function(e,t,n){var r=this._cacheHierarchy-1;if(t==r){for(var a in e)for(var i=e[a],o=e,s=0,l=n-r;s<l;s++)s==l-1?o[0]=i:o=o[0==s?a:0]=Object.create(null);this._cacheHierarchy=n}else for(var c in e)this._resizeCacheMapHierarchy(e[c],++t,n)},ru);u2.init();var u4=function(t){function n(r,a,i){if((o=t.call(this)||this)._physicsInitialized=!1,o._physicalObjectsMap={},o._lastRenderState=new cG,o._renderElementPool=new cS(cK),o._meshRenderDataPool=new cS(cA),o._spriteRenderDataPool=new cS(um),o._spriteMaskRenderDataPool=new cS(ug),o._textRenderDataPool=new cS(uv),o._renderContext=new cX,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new cE,o._settings={},o._resourceManager=new uS(lO(o)),o._sceneManager=new ux(lO(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new cl,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=a,o._hardwareRenderer.init(r,o._onDeviceLost.bind(lO(o)),o._onDeviceRestored.bind(lO(o))),o._canvas=r,o._spriteMaskManager=new up(lO(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=ci.createFromOS(lO(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new uJ(lO(o)),o._initMagentaTextures(a),a.canIUse(e.GLCapabilityType.depthTexture)){var o,s=new l9(lO(o),1,1,e.TextureFormat.Depth16,!1);s.isGCIgnored=!0,o._depthTexture2D=s}else o._macroCollection.enable(n._noDepthTextureMacro);var l=new uZ(lO(o),cH.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new lH(1,0,1.01,1)),o._magentaMaterial=l;var c=new uZ(lO(o),cH.find("background-texture"));c.isGCIgnored=!0,c.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,o._backgroundTextureMaterial=c;var u=o._settings,h=i.colorSpace||e.ColorSpace.Linear;return h===e.ColorSpace.Gamma&&o._macroCollection.enable(n._gammaMacro),u.colorSpace=h,o}lk(n,t);var r=n.prototype;return r.createEntity=function(e){return new cT(this,e)},r.pause=function(){this._isPaused=!0,cancelAnimationFrame(this._requestId),clearTimeout(this._timeoutId)},r.resume=function(){this._isPaused&&(this._isPaused=!1,this.time._reset(),this._requestId=requestAnimationFrame(this._animate))},r.update=function(){if(!this._isDeviceLost){var e=this._time;e._update();var t=e.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._meshRenderDataPool.resetPool(),this._spriteRenderDataPool.resetPool(),this._spriteMaskRenderDataPool.resetPool(),this._textRenderDataPool.resetPool();var n=this.inputManager,r=this._physicsInitialized;n._update();for(var a=this._sceneManager._scenes.getLoopArray(),i=a.length,o=0;o<i;o++){var s=a[o];s.destroyed||(s._cameraNeedSorting&&s._sortCameras(),s._componentsManager.callScriptOnStart())}if(r)for(var l=0;l<i;l++){var c=a[l];c.destroyed||c.physics._update(t)}r&&n._firePointerScript(a);for(var u=0;u<i;u++){var h=a[u];h.destroyed||h._componentsManager.callScriptOnUpdate(t)}for(var d=0;d<i;d++){var _=a[d];_.destroyed||_._componentsManager.callAnimationUpdate(t)}for(var f=0;f<i;f++){var p=a[f];p.destroyed||p._componentsManager.callScriptOnLateUpdate(t)}this._render(a);for(var g=0;g<i;g++){var m=a[g];m.destroyed||this._waitingDestroy||m._componentsManager.handlingInvalidScripts()}this._waitingDestroy&&this._destroy(),this._waitingGC&&(this._gc(),this._waitingGC=!1),this._frameInProcess=!1}},r.run=function(){this.resume(),this.dispatch("run",this)},r.forceLoseDevice=function(){this._hardwareRenderer.forceLoseDevice()},r.forceRestoreDevice=function(){this._hardwareRenderer.forceRestoreDevice()},r._destroy=function(){this._sceneManager._destroyAllScene(),this._resourceManager._destroy(),this._whiteTexture2D.destroy(!0),this._magentaTexture2D.destroy(!0),this._magentaTextureCube.destroy(!0),this._textDefaultFont=null,this._fontMap=null,this.inputManager._destroy(),this.dispatch("shutdown",this),this.pause(),this._spriteMaskManager.destroy(),this._hardwareRenderer.destroy(),this.removeAllEventListeners(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._waitingDestroy=!1,this._destroyed=!0},r.destroy=function(){this._destroyed||(this._frameInProcess?this._waitingDestroy=!0:this._destroy())},r._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 u3}return r},r._render=function(e){for(var t=0,n=e.length;t<n;t++){var r=e[t];if(!r.destroyed){var a=this.time.deltaTime;r._componentsManager.callRendererOnUpdate(a),r._updateShaderData()}}for(var i=0,o=e.length;i<o;i++){var s=e[i];if(!s.destroyed){var l=s._activeCameras,c=l.length;if(c>0)for(var u=0;u<c;u++){var h=l[u],d=s._componentsManager;d.callCameraOnBeginRender(h),h.render(),d.callCameraOnEndRender(h),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else l8.debug("No active camera in scene.")}}},r._initMagentaTextures=function(t){var n=new Uint8Array([255,255,255,255]),r=new l9(this,1,1,e.TextureFormat.R8G8B8A8,!1);r.setPixelBuffer(n),r.isGCIgnored=!0;var a=new Uint8Array([255,0,255,255]),i=new l9(this,1,1,e.TextureFormat.R8G8B8A8,!1);i.setPixelBuffer(a),i.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(lk(l=function(){return l$.call(this,i)},l$),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(a)},l));for(var o=new ct(this,1,e.TextureFormat.R8G8B8A8,!1),s=0;s<6;s++)o.setPixelBuffer(e.TextureCubeFace.PositiveX+s,a);if(o.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(lk(c=function(){return l$.call(this,o)},l$),c.prototype.restoreContent=function(){for(var t=0;t<6;t++)this.resource.setPixelBuffer(e.TextureCubeFace.PositiveX+t,a)},c)),this._whiteTexture2D=r,this._magentaTexture2D=i,this._magentaTextureCube=o,t.isWebGL2){var l,c,u,h=new ce(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);h.setPixelBuffer(0,a),h.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(lk(u=function(){return l$.call(this,h)},l$),u.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,a)},u)),this._magentaTexture2DArray=h}},r._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},r._initialize=function(e){var t=this,n=e.shaderLab,r=e.physics;n&&(cH._shaderLab=n);var a=[];r&&a.push(r.initialize().then(function(){return uL._nativePhysics=r,t._nativePhysicsManager=r.createPhysicsManager(),t._physicsInitialized=!0,t}));var i=uS._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})},r._createSpriteMaterial=function(){var t=new uZ(this,cH.find("Sprite")),n=t.renderState,r=n.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=e.BlendFactor.One,r.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.colorBlendOperation=r.alphaBlendOperation=e.BlendOperation.Add,n.depthState.writeEnabled=!1,n.rasterState.cullMode=e.CullMode.Off,t.renderState.renderQueueType=e.RenderQueueType.Transparent,t.isGCIgnored=!0,t},r._createSpriteMaskMaterial=function(){var t=new uZ(this,cH.find("SpriteMask")),n=t.renderState;return n.blendState.targetBlendState.colorWriteMask=e.ColorWriteMask.None,n.rasterState.cullMode=e.CullMode.Off,n.stencilState.enabled=!0,n.depthState.enabled=!1,t.isGCIgnored=!0,t},r._onDeviceLost=function(){this._isDeviceLost=!0,console.log("Device lost."),this.dispatch("devicelost",this)},r._onDeviceRestored=function(){var e=this;this._hardwareRenderer.resetState(),this._lastRenderState=new cG,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)})},r._gc=function(){this._renderElementPool.garbageCollection(),this._meshRenderDataPool.garbageCollection(),this._spriteRenderDataPool.garbageCollection(),this._spriteMaskRenderDataPool.garbageCollection(),this._textRenderDataPool.garbageCollection()},lU(n,[{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}}]),n}(co);u4._gammaMacro=cw.getByName("ENGINE_IS_COLORSPACE_GAMMA"),u4._noDepthTextureMacro=cw.getByName("ENGINE_NO_DEPTH_TEXTURE"),u4._pixelsPerUnit=100,e.BackgroundMode=void 0,(rd=e.BackgroundMode||(e.BackgroundMode={}))[rd.SolidColor=0]="SolidColor",rd[rd.Sky=1]="Sky",rd[rd.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(r_=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[r_.AspectFitWidth=0]="AspectFitWidth",r_[r_.AspectFitHeight=1]="AspectFitHeight",r_[r_.Fill=2]="Fill";var u5=((rp=(rf=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},rp._render=function(e){var t=this.material,n=this.mesh;if(!t){l8.warn("The material of sky is not defined.");return}if(!n){l8.warn("The mesh of sky is not defined.");return}var r=e.camera,a=r.engine,i=r.aspectRatio,o=r.fieldOfView,s=r.viewMatrix,l=r.shaderData,c=e.camera.scene.shaderData,u=rf._viewProjMatrix,h=rf._projectionMatrix,d=a._hardwareRenderer,_=t.shaderData,f=t.shader,p=t.renderState;u.copyFrom(s);var g=u.elements;g[12]=g[13]=g[14]=0;var m=1/Math.tan(lT.degreeToRadian(o)/2);h.elements[0]=m/i,h.elements[5]=m,lR.multiply(h,u,u);var v=l.getMatrix(cX.vpMatrixProperty);l.setMatrix(cX.vpMatrixProperty,u);var y=cH._compileMacros;cE.unionCollection(e.camera._globalShaderMacro,_._macroCollection,y);var x=f.subShaders[0].passes[0],T=x._getShaderProgram(a,y);T.bind(),T.groupingOtherUniformBlock(),T.uploadAll(T.sceneUniformBlock,c),T.uploadAll(T.cameraUniformBlock,l),T.uploadAll(T.materialUniformBlock,_),T.uploadUnGroupTextures(),p._apply(a,!1,x._renderStateDataMap,_),d.drawPrimitive(n,n.subMesh,T),l.setMatrix(cX.vpMatrixProperty,v)},lU(rf,[{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}}}]),rf);u5._epsilon=1e-6,u5._viewProjMatrix=new lR,u5._projectionMatrix=new lR(1,0,0,0,0,1,0,0,0,0,u5._epsilon-1,-1,0,0,0,0);var u8=((rm=(rg=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new lB(.25,.25,.25,1),this.sky=new u5,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._initMesh(t)}).prototype).destroy=function(){this._mesh._addReferCount(-1),this._mesh=null,this.texture=null,this.solidColor=null,this.sky.destroy()},rm._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},rm._resizeBackgroundTexture=function(){if(this._texture){var t=this._engine.canvas,n=t.width,r=t.height,a=this._mesh,i=a.getPositions();switch(this._textureFillMode){case e.BackgroundTextureFillMode.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 e.BackgroundTextureFillMode.AspectFitWidth:var o=this._texture.height*n/this.texture.width/r;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 e.BackgroundTextureFillMode.AspectFitHeight:var s=this._texture.width*r/this.texture.height/n;i[0].set(-s,-1,1),i[1].set(s,-1,1),i[2].set(-s,1,1),i[3].set(s,1,1)}a.setPositions(i),a.uploadData(!1)}},rm._createPlane=function(e){var t=new c9(e);t.isGCIgnored=!0;for(var n=new Uint8Array([1,2,0,1,3,2]),r=[,,,,],a=[,,,,],i=0;i<4;++i)r[i]=new lS,a[i]=new lL(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},lU(rg,[{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._engine._backgroundTextureMaterial.shaderData.setTexture("material_BaseTexture",e)}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),rg),u6=((ry=(rv=function(){this._renderers=new cd,this._onStartScripts=new cd,this._onUpdateScripts=new cd,this._onLateUpdateScripts=new cd,this._onPhysicsUpdateScripts=new cd,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new cd,this._onUpdateRenderers=new cd,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},ry.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},ry.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},ry.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},ry.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},ry.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ry.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},ry.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},ry.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},ry.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},ry.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},ry.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ry.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},ry.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},ry.addDisableScript=function(e){this._disableScripts.push(e)},ry.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},ry.callScriptOnStart=function(){var e=this._onStartScripts;if(e.length>0){for(var t=e._elements,n=0;n<e.length;n++){var r=t[n];r._waitHandlingInValid||(r._started=!0,r._onStartIndex=-1,r.onStart())}e.length=0}},ry.callScriptOnUpdate=function(e){for(var t=this._onUpdateScripts._elements,n=this._onUpdateScripts.length-1;n>=0;--n){var r=t[n];!r._waitHandlingInValid&&r._started&&r.onUpdate(e)}},ry.callScriptOnLateUpdate=function(e){for(var t=this._onLateUpdateScripts._elements,n=this._onLateUpdateScripts.length-1;n>=0;--n){var r=t[n];!r._waitHandlingInValid&&r._started&&r.onLateUpdate(e)}},ry.callScriptOnPhysicsUpdate=function(){for(var e=this._onPhysicsUpdateScripts._elements,t=this._onPhysicsUpdateScripts.length-1;t>=0;--t){var n=e[t];!n._waitHandlingInValid&&n._started&&n.onPhysicsUpdate()}},ry.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},ry.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},ry.handlingInvalidScripts=function(){var e=this._disableScripts,t=e.length;if(t>0){for(var n=t-1;n>=0;n--){var r=e[n];r._waitHandlingInValid&&r._handlingInValid()}e.length=0}var a=this._disposeDestroyScripts,i=this._pendingDestroyScripts;if(this._disposeDestroyScripts=i,this._pendingDestroyScripts=a,(t=i.length)>0){for(var o=t-1;o>=0;o--)i[o].onDestroy();i.length=0}},ry.callCameraOnBeginRender=function(e){for(var t=e.entity._scripts,n=t.length-1;n>=0;--n){var r=t.get(n);r._waitHandlingInValid||r.onBeginRender(e)}},ry.callCameraOnEndRender=function(e){for(var t=e.entity._scripts,n=t.length-1;n>=0;--n){var r=t.get(n);r._waitHandlingInValid||r.onEndRender(e)}},ry.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},ry.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},ry._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},rv);e.FogMode=void 0,(rx=e.FogMode||(e.FogMode={}))[rx.None=0]="None",rx[rx.Linear=1]="Linear",rx[rx.Exponential=2]="Exponential",rx[rx.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(rT=e.DiffuseMode||(e.DiffuseMode={}))[rT.SolidColor=0]="SolidColor",rT[rT.SphericalHarmonics=1]="SphericalHarmonics";var u7=(lk(rS=function(t){var n;return(n=lZ.call(this,t)||this)._diffuseSolidColor=new lB(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=e.DiffuseMode.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n},lZ),(rC=rS.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(rS._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(rS._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(rS._specularIntensityProperty,this._specularIntensity),t.setFloatArray(rS._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},rC._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,n=t.indexOf(e);t.splice(n,1);var r=e.shaderData;r.setTexture(rS._specularTextureProperty,null),r.disableMacro(rS._specularMacro)},rC._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(rS._shMacro):t.disableMacro(rS._shMacro)},rC._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(rS._specularTextureProperty,this._specularTexture),e.setFloat(rS._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(rS._specularMacro)):e.disableMacro(rS._specularMacro)},rC._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(rS._decodeRGBMMacro):e.disableMacro(rS._decodeRGBMMacro)},rC._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]},lU(rS,[{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 t=this._scenes,n=0,r=t.length;n<r;n++)t[n].shaderData.setFloatArray(rS._diffuseSHProperty,this._shArray)}}},{key:"diffuseIntensity",get:function(){return this._diffuseIntensity},set:function(e){this._diffuseIntensity=e;for(var t=this._scenes,n=0,r=t.length;n<r;n++)t[n].shaderData.setFloat(rS._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 t=0,n=this._scenes.length;t<n;t++)this._scenes[t].shaderData.setFloat(rS._specularIntensityProperty,e)}}]),rS);u7._shMacro=cw.getByName("SCENE_USE_SH"),u7._specularMacro=cw.getByName("SCENE_USE_SPECULAR_ENV"),u7._decodeRGBMMacro=cw.getByName("SCENE_IS_DECODE_ENV_RGBM"),u7._diffuseColorProperty=cs.getByName("scene_EnvMapLight.diffuse"),u7._diffuseSHProperty=cs.getByName("scene_EnvSH"),u7._diffuseIntensityProperty=cs.getByName("scene_EnvMapLight.diffuseIntensity"),u7._specularTextureProperty=cs.getByName("scene_EnvSpecularSampler"),u7._specularIntensityProperty=cs.getByName("scene_EnvMapLight.specularIntensity"),u7._mipLevelProperty=cs.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(rA=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[rA.NoCascades=1]="NoCascades",rA[rA.TwoCascades=2]="TwoCascades",rA[rA.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(rw=e.ShadowResolution||(e.ShadowResolution={}))[rw.Low=0]="Low",rw[rw.Medium=1]="Medium",rw[rw.High=2]="High",rw[rw.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(rE=e.ShadowType||(e.ShadowType={}))[rE.None=0]="None",rE[rE.Hard=1]="Hard",rE[rE.SoftLow=2]="SoftLow",rE[rE.SoftHigh=3]="SoftHigh";var u9=(lk(rb=function(){var t;return t=cc.apply(this,arguments)||this,t.intensity=1,t.cullingMask=e.Layer.Everything,t.shadowType=e.ShadowType.None,t.shadowBias=1,t.shadowNormalBias=1,t.shadowNearPlane=.1,t.shadowStrength=1,t._lightIndex=-1,t._color=new lB(1,1,1,1),t._lightColor=new lB,t},cc),rb.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},lU(rb,[{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 lR),lR.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new lR),lR.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),rb);u9._maxLight=10,lW([lK],u9.prototype,"_lightIndex",void 0);var he=(lk(rM=function(){var e;return e=u9.apply(this,arguments)||this,e._reverseDirection=new lS,e},u9),(rF=rM.prototype)._appendData=function(t){var n=2*t,r=3*t,a=3*t,i=this._getLightIntensityColor(),o=this.direction,s=rM._combinedData,l=this.cullingMask;s.cullingMask[n]=65535&l,s.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(s.color[r]=lB.gammaToLinearSpace(i.r),s.color[r+1]=lB.gammaToLinearSpace(i.g),s.color[r+2]=lB.gammaToLinearSpace(i.b)):(s.color[r]=i.r,s.color[r+1]=i.g,s.color[r+2]=i.b),s.direction[a]=o.x,s.direction[a+1]=o.y,s.direction[a+2]=o.z},rF._onEnableInScene=function(){this.scene._lightManager._attachDirectLight(this)},rF._onDisableInScene=function(){this.scene._lightManager._detachDirectLight(this)},rM._updateShaderData=function(e){var t=rM._combinedData;e.setIntArray(rM._cullingMaskProperty,t.cullingMask),e.setFloatArray(rM._colorProperty,t.color),e.setFloatArray(rM._directionProperty,t.direction)},lU(rM,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return lS.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),rM);he._cullingMaskProperty=cs.getByName("scene_DirectLightCullingMask"),he._colorProperty=cs.getByName("scene_DirectLightColor"),he._directionProperty=cs.getByName("scene_DirectLightDirection"),he._combinedData={cullingMask:new Int32Array(2*u9._maxLight),color:new Float32Array(3*u9._maxLight),direction:new Float32Array(3*u9._maxLight)};var ht=(lk(rR=function(){var e;return e=u9.apply(this,arguments)||this,e.distance=100,e},u9),(rP=rR.prototype)._appendData=function(t){var n=2*t,r=3*t,a=3*t,i=this._getLightIntensityColor(),o=this.position,s=rR._combinedData,l=this.cullingMask;s.cullingMask[n]=65535&l,s.cullingMask[n+1]=l>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(s.color[r]=lB.gammaToLinearSpace(i.r),s.color[r+1]=lB.gammaToLinearSpace(i.g),s.color[r+2]=lB.gammaToLinearSpace(i.b)):(s.color[r]=i.r,s.color[r+1]=i.g,s.color[r+2]=i.b),s.position[a]=o.x,s.position[a+1]=o.y,s.position[a+2]=o.z,s.distance[t]=this.distance},rP._onEnableInScene=function(){this.scene._lightManager._attachPointLight(this)},rP._onDisableInScene=function(){this.scene._lightManager._detachPointLight(this)},rR._updateShaderData=function(e){var t=rR._combinedData;e.setIntArray(rR._cullingMaskProperty,t.cullingMask),e.setFloatArray(rR._colorProperty,t.color),e.setFloatArray(rR._positionProperty,t.position),e.setFloatArray(rR._distanceProperty,t.distance)},lU(rR,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),rR);ht._cullingMaskProperty=cs.getByName("scene_PointLightCullingMask"),ht._colorProperty=cs.getByName("scene_PointLightColor"),ht._positionProperty=cs.getByName("scene_PointLightPosition"),ht._distanceProperty=cs.getByName("scene_PointLightDistance"),ht._combinedData={cullingMask:new Int32Array(2*u9._maxLight),color:new Float32Array(3*u9._maxLight),position:new Float32Array(3*u9._maxLight),distance:new Float32Array(u9._maxLight)};var hn=(lk(rL=function(){var e;return e=u9.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new lS,e._projectMatrix=new lR,e},u9),(rD=rL.prototype)._appendData=function(t){var n=2*t,r=3*t,a=3*t,i=3*t,o=this._getLightIntensityColor(),s=this.position,l=this.direction,c=rL._combinedData,u=this.cullingMask;c.cullingMask[n]=65535&u,c.cullingMask[n+1]=u>>>16&65535,this.engine.settings.colorSpace===e.ColorSpace.Linear?(c.color[r]=lB.gammaToLinearSpace(o.r),c.color[r+1]=lB.gammaToLinearSpace(o.g),c.color[r+2]=lB.gammaToLinearSpace(o.b)):(c.color[r]=o.r,c.color[r+1]=o.g,c.color[r+2]=o.b),c.position[a]=s.x,c.position[a+1]=s.y,c.position[a+2]=s.z,c.direction[i]=l.x,c.direction[i+1]=l.y,c.direction[i+2]=l.z,c.distance[t]=this.distance,c.angleCos[t]=Math.cos(this.angle),c.penumbraCos[t]=Math.cos(this.angle+this.penumbra)},rD._onEnableInScene=function(){this.scene._lightManager._attachSpotLight(this)},rD._onDisableInScene=function(){this.scene._lightManager._detachSpotLight(this)},rL._updateShaderData=function(e){var t=rL._combinedData;e.setIntArray(rL._cullingMaskProperty,t.cullingMask),e.setFloatArray(rL._colorProperty,t.color),e.setFloatArray(rL._positionProperty,t.position),e.setFloatArray(rL._directionProperty,t.direction),e.setFloatArray(rL._distanceProperty,t.distance),e.setFloatArray(rL._angleCosProperty,t.angleCos),e.setFloatArray(rL._penumbraCosProperty,t.penumbraCos)},lU(rL,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return lS.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 lR.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),rL);hn._cullingMaskProperty=cs.getByName("scene_SpotLightCullingMask"),hn._colorProperty=cs.getByName("scene_SpotLightColor"),hn._positionProperty=cs.getByName("scene_SpotLightPosition"),hn._directionProperty=cs.getByName("scene_SpotLightDirection"),hn._distanceProperty=cs.getByName("scene_SpotLightDistance"),hn._angleCosProperty=cs.getByName("scene_SpotLightAngleCos"),hn._penumbraCosProperty=cs.getByName("scene_SpotLightPenumbraCos"),hn._combinedData={cullingMask:new Int32Array(2*u9._maxLight),color:new Float32Array(3*u9._maxLight),position:new Float32Array(3*u9._maxLight),direction:new Float32Array(3*u9._maxLight),distance:new Float32Array(u9._maxLight),angleCos:new Float32Array(u9._maxLight),penumbraCos:new Float32Array(u9._maxLight)};var hr=((rI=(rB=function(){this._spotLights=new cd,this._pointLights=new cd,this._directLights=new cd}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},rI._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rI._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},rI._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rI._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},rI._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rI._updateSunLightIndex=function(){var e=this._directLights,t=this._getSunLightIndex();if(t>0){var n=e.get(0),r=e.get(t);e.set(0,r),e.set(t,n),r._lightIndex=0,n._lightIndex=t}},rI._updateShaderData=function(e){for(var t=this._spotLights,n=this._pointLights,r=this._directLights,a=t.length,i=n.length,o=r.length,s=0;s<a;s++)t.get(s)._appendData(s);for(var l=0;l<i;l++)n.get(l)._appendData(l);for(var c=0;c<o;c++)r.get(c)._appendData(c);o?(he._updateShaderData(e),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),i?(ht._updateShaderData(e),e.enableMacro("SCENE_POINT_LIGHT_COUNT",i.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),a?(hn._updateShaderData(e),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",a.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},rI._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},rI._getSunLightIndex=function(){for(var t=this._directLights,n=-1,r=Number.NEGATIVE_INFINITY,a=!1,i=0,o=t.length;i<o;i++){var s=t.get(i);s.shadowType===e.ShadowType.None||a||(r=Number.NEGATIVE_INFINITY,a=!0);var l=s.intensity*s.color.getBrightness();a?s.shadowType!==e.ShadowType.None&&r<l&&(r=l,n=i):r<l&&(r=l,n=i)}return n},rB),ha=function(t){function n(r,a){(i=t.call(this,r)||this).physics=new uL(lO(i)),i.castShadows=!0,i.shadowResolution=e.ShadowResolution.Medium,i.shadowTwoCascadeSplits=1/3,i.shadowFourCascadeSplits=new lS(1/15,.2,7/15),i.shadowDistance=50,i._cameraNeedSorting=!1,i._lightManager=new hr,i._componentsManager=new u6,i._activeCameras=[],i._isActiveInEngine=!1,i._globalShaderMacro=new cE,i._rootEntities=[],i._background=new u8(i._engine),i._shaderData=new cW(sB.Scene),i._shadowCascades=e.ShadowCascadesMode.NoCascades,i._fogMode=e.FogMode.None,i._fogColor=new lB(.5,.5,.5,1),i._fogStart=0,i._fogEnd=300,i._fogDensity=.01,i._fogParams=new lD,i.name=a||"";var i,o=i.shaderData;return o._addReferCount(1),i.ambientLight=new u7(r),r.sceneManager._allCreatedScenes.push(lO(i)),o.enableMacro("SCENE_FOG_MODE",i._fogMode.toString()),o.enableMacro("SCENE_SHADOW_CASCADED_COUNT",i.shadowCascades.toString()),o.setColor(n._fogColorProperty,i._fogColor),o.setVector4(n._fogParamsProperty,i._fogParams),i._computeLinearFogParams(i._fogStart,i._fogEnd),i._computeExponentialFogParams(i._fogDensity),i}lk(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new cT(this._engine,e);return this.addRootEntity(t),t},r.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());var a=t._scene;a!==this?(a&&r&&a._removeFromEntityList(t),this._addToRootEntityList(n,t)):r||this._addToRootEntityList(n,t);var i=sL.None;this._isActiveInEngine?t._isActiveInHierarchy&&a!==this&&(i|=sL.Scene):t._isActiveInHierarchy&&(i|=sL.Hierarchy),i&&t._processInActive(i),a!==this&&cT._traverseSetOwnerScene(t,this);var o=sL.None;this._isActiveInEngine&&t._isActive&&(t._isActiveInHierarchy||(o|=sL.Hierarchy),t._isActiveInScene&&a===this||(o|=sL.Scene)),o&&t._processActive(o)},r.removeRootEntity=function(e){if(e._isRoot&&e._scene==this){this._removeFromEntityList(e),e._isRoot=!1;var t=sL.None;this._isActiveInEngine&&e._isActiveInHierarchy&&(t|=sL.Hierarchy),e._isActiveInScene&&(t|=sL.Scene),t&&e._processInActive(t),cT._traverseSetOwnerScene(e,null)}},r.getRootEntity=function(e){return void 0===e&&(e=0),this._rootEntities[e]},r.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},r.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=cT._findChildByName(a,t[i]));++i);return a}}return null},r._sortCameras=function(){this._activeCameras.sort(function(e,t){return e.priority-t.priority}),this._cameraNeedSorting=!1},r._attachRenderCamera=function(e){var t=this._activeCameras;-1===t.indexOf(e)?(t.push(e),this._cameraNeedSorting=!0):l8.warn("Camera already attached.")},r._detachRenderCamera=function(e){var t=this._activeCameras,n=t.indexOf(e);-1!==n&&t.splice(n,1)},r._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(sL.Hierarchy):r._processInActive(sL.Hierarchy))}},r._updateShaderData=function(){var t=this.shaderData,r=this._engine,a=this._lightManager;if(r.time._updateSceneShaderData(t),a._updateShaderData(this.shaderData),a._updateSunLightIndex(),a._directLights.length>0){var i=a._directLights.get(0);t.setColor(n._sunlightColorProperty,i._getLightIntensityColor()),t.setVector3(n._sunlightDirectionProperty,i.direction),this._sunLight=i}else this._sunLight=null;this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),cE.unionCollection(this.engine._macroCollection,t._macroCollection,this._globalShaderMacro)},r._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},r._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._engine.sceneManager;for(e.removeScene(this);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this._activeCameras.length=0,this.background.destroy(),this._ambientLight&&this._ambientLight._removeFromScene(this),this.shaderData._addReferCount(-1),this._componentsManager.handlingInvalidScripts();var n=e._allCreatedScenes;n.splice(n.indexOf(this),1)},r._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++}},r._computeLinearFogParams=function(e,t){var n=t-e,r=this._fogParams;r.x=-1/n,r.y=t/n},r._computeExponentialFogParams=function(e){this._fogParams.z=e/Math.LN2,this._fogParams.w=e/Math.sqrt(Math.LN2)},lU(n,[{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){l8.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}}]),n}(lJ);ha._fogColorProperty=cs.getByName("scene_FogColor"),ha._fogParamsProperty=cs.getByName("scene_FogParams"),ha._sunlightColorProperty=cs.getByName("scene_SunlightColor"),ha._sunlightDirectionProperty=cs.getByName("scene_SunlightDirection");var hi=(lk(rV=function(){var e;return e=cc.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._waitHandlingInValid=!1,e},cc),(rO=rV.prototype).onAwake=function(){},rO.onEnable=function(){},rO.onStart=function(){},rO.onUpdate=function(e){},rO.onLateUpdate=function(e){},rO.onBeginRender=function(e){},rO.onEndRender=function(e){},rO.onPhysicsUpdate=function(){},rO.onTriggerEnter=function(e){},rO.onTriggerExit=function(e){},rO.onTriggerStay=function(e){},rO.onCollisionEnter=function(e){},rO.onCollisionExit=function(e){},rO.onCollisionStay=function(e){},rO.onPointerDown=function(e){},rO.onPointerUp=function(e){},rO.onPointerClick=function(e){},rO.onPointerEnter=function(e){},rO.onPointerExit=function(e){},rO.onPointerDrag=function(e){},rO.onDisable=function(){},rO.onDestroy=function(){},rO._onAwake=function(){this.onAwake()},rO._onEnable=function(){this.onEnable()},rO._onDisable=function(){this.onDisable()},rO._onEnableInScene=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.scene._componentsManager,t=rV.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)}},rO._onDisableInScene=function(){this._waitHandlingInValid=!0,this.scene._componentsManager.addDisableScript(this)},rO._handlingInValid=function(){var e=this.scene._componentsManager,t=rV.prototype;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),this._waitHandlingInValid=!1},rO._onDestroy=function(){cc.prototype._onDestroy.call(this),this.scene._componentsManager.addPendingDestroyScript(this)},rV);lW([lK],hi.prototype,"_started",void 0),lW([lK],hi.prototype,"_onStartIndex",void 0),lW([lK],hi.prototype,"_onUpdateIndex",void 0),lW([lK],hi.prototype,"_onLateUpdateIndex",void 0),lW([lK],hi.prototype,"_onPhysicsUpdateIndex",void 0),lW([lK],hi.prototype,"_onPreRenderIndex",void 0),lW([lK],hi.prototype,"_onPostRenderIndex",void 0),lW([lK],hi.prototype,"_entityScriptsIndex",void 0),lW([lK],hi.prototype,"_waitHandlingInValid",void 0),e.DepthTextureMode=void 0,(rN=e.DepthTextureMode||(e.DepthTextureMode={}))[rN.None=0]="None",rN[rN.PrePass=1]="PrePass";var ho=0,hs=((rz=(rU=function(t,n,r,a,i){void 0===t&&(t="RENDER_PASS"+ho++),void 0===n&&(n=0),void 0===r&&(r=null),void 0===a&&(a=null),void 0===i&&(i=null),this.name=t,this.enabled=!0,this.priority=n,this.renderTarget=r,this.replaceMaterial=a,this.mask=i||e.Layer.Everything,this.renderOverride=!1}).prototype).render=function(e,t,n,r){},rz.preRender=function(e,t,n,r){},rz.postRender=function(e,t,n,r){},rU),hl=(lk(rk=function(){return u_.apply(this,arguments)},u_),(rG=rk.prototype).createVertexElements=function(t){return t[0]=new cZ("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cZ("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new cZ("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rG.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPasses[0].getTagValue(u_._disableBatchTag))return!1;var n=e.data,r=t.data,a=n.component,i=r.component;return!!this.checkBatchWithMask(a,i)&&n.texture===r.texture&&n.material===r.material},rG.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rG.updateVertices=function(e,t,n){for(var r=e.verticesData,a=r.positions,i=r.uvs,o=r.color,s=r.vertexCount,l=0;l<s;l++){var c=a[l],u=i[l];t[n++]=c.x,t[n++]=c.y,t[n++]=c.z,t[n++]=u.x,t[n++]=u.y,t[n++]=o.r,t[n++]=o.g,t[n++]=o.b,t[n++]=o.a}return n},rG.drawBatches=function(e){for(var t=this._engine,n=this._batchedQueue,r=this._meshes[this._flushId],a=r.subMeshes,i=t._spriteMaskManager,o=e.scene.shaderData,s=e.shaderData,l=0,c=a.length;l<c;l++){var u=a[l],h=n[l],d=h.data;if(!u||!h)return;var _=d.component,f=d.material;i.preRender(e,_);var p=cH._compileMacros;cE.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=h.shaderPasses[0],m=g._getShaderProgram(t,p);if(!m.isValid)return;_.shaderData.setTexture(rk._textureProperty,d.texture),m.bind(),m.groupingOtherUniformBlock(),m.uploadAll(m.sceneUniformBlock,o),m.uploadAll(m.cameraUniformBlock,s),m.uploadAll(m.rendererUniformBlock,_.shaderData),m.uploadAll(m.materialUniformBlock,f.shaderData),f.renderState._apply(t,!1,g._renderStateDataMap,f.shaderData),t._hardwareRenderer.drawPrimitive(r,u,m),i.postRender(_)}},rG.destroy=function(){this._batchedQueue=null;for(var e=this._meshes,t=this._vertexBuffers,n=this._indiceBuffers,r=0,a=e.length;r<a;++r)e[r].destroy();this._meshes=null;for(var i=0,o=t.length;i<o;++i)t[i].destroy();this._vertexBuffers=null;for(var s=0,l=n.length;s<l;++s)n[s].destroy();this._indiceBuffers=null},rk);hl._textureProperty=cs.getByName("renderer_SpriteTexture");var hc=((rW=(rH=function(e){this.elements=[],this._initSpriteBatcher(e)}).prototype).pushRenderElement=function(e){this.elements.push(e)},rW.render=function(e,t,n){var r=this.elements;if(0!==r.length){for(var a=e.engine,i=e.scene,o=a._renderCount,s=a._hardwareRenderer,l=i.shaderData,c=e.shaderData,u=cX.pipelineStageKey,h=0,d=r.length;h<d;h++){var _=r[h],f=_.data,p=_.shaderPasses,g=f.material.renderStates;if(f.component.entity.layer&t){if(f.mesh){this._spriteBatcher.flush(e);var m=cH._compileMacros,v=f.component,y=f.material.destroyed?a._magentaMaterial:f.material,x=v.shaderData,T=y.shaderData;cE.unionCollection(v._globalShaderMacro,T._macroCollection,m);for(var S=0,C=p.length;S<C;S++){var A,w=p[S];if(w.getTagValue(u)===n){var E=w._getShaderProgram(a,m);if(E.isValid){var b=E.bind();o!==E._uploadRenderCount?(E.groupingOtherUniformBlock(),E.uploadAll(E.sceneUniformBlock,l),E.uploadAll(E.cameraUniformBlock,c),E.uploadAll(E.rendererUniformBlock,x),E.uploadAll(E.materialUniformBlock,T),E.uploadUnGroupTextures(),E._uploadScene=i,E._uploadCamera=e,E._uploadRenderer=v,E._uploadMaterial=y,E._uploadRenderCount=o):(E._uploadScene!==i?(E.uploadAll(E.sceneUniformBlock,l),E._uploadScene=i):b&&E.uploadTextures(E.sceneUniformBlock,l),E._uploadCamera!==e?(E.uploadAll(E.cameraUniformBlock,c),E._uploadCamera=e):b&&E.uploadTextures(E.cameraUniformBlock,c),E._uploadRenderer!==v?(E.uploadAll(E.rendererUniformBlock,x),E._uploadRenderer=v):b&&E.uploadTextures(E.rendererUniformBlock,x),E._uploadMaterial!==y?(E.uploadAll(E.materialUniformBlock,T),E._uploadMaterial=y):b&&E.uploadTextures(E.materialUniformBlock,T),b&&E.uploadUnGroupTextures()),(null!=(A=w._renderState)?A:g[S])._apply(a,v.entity.transform._isFrontFaceInvert(),w._renderStateDataMap,y.shaderData),s.drawPrimitive(f.mesh,f.subMesh,E)}}}}else this._spriteBatcher.drawElement(_,e)}}this._spriteBatcher.flush(e)}},rW.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},rW.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rW.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},rW._initSpriteBatcher=function(e){this._spriteBatcher=new hl(e)},rW._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 h=o,d=t+1,_=n-1;e[a]=e[d],e[d]=h;e:for(var f=d+1;f<_;f++){var p=e[f],g=r(p,h);if(g<0)e[f]=e[d],e[d]=p,d++;else if(g>0){do{if(--_==f)break e;g=r(e[_],h)}while(g>0);e[f]=e[_],e[_]=p,g<0&&(p=e[f],e[f]=e[d],e[d]=p,d++)}}n-_<d-t?(this._quickSort(e,_,n,r),n=d):(this._quickSort(e,t,d,r),t=_)}},rW._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}},rH._compareFromNearToFar=function(e,t){return e.data.component.priority-t.data.component.priority||e.data.component._distanceForSort-t.data.component._distanceForSort},rH._compareFromFarToNear=function(e,t){return e.data.component.priority-t.data.component.priority||t.data.component._distanceForSort-e.data.component._distanceForSort},rH),hu=((rX=function(){}).recreateTextureIfNeeded=function(e,t,n,r,a,i){if(t){if(t.width===n&&t.height===r&&t.format===a&&t.mipmapCount>1===i)return t;t.destroy();var o=new l9(e,n,r,a,i);return o.isGCIgnored=!0,o}var s=new l9(e,n,r,a,i);return s.isGCIgnored=!0,s},rX.recreateRenderTargetIfNeeded=function(e,t,n,r,a,i,o){var s=null==t?void 0:t.getColorTexture(0),l=null==t?void 0:t.depthTexture,c=a?rX.recreateTextureIfNeeded(e,s,n,r,a,o):null,u=i?rX.recreateTextureIfNeeded(e,l,n,r,i,o):null;return(s!==c||l!==u)&&(null==t||t.destroy(),(t=new l7(e,n,r,c,u)).isGCIgnored=!0),t},rX),hh=function(){this.position=new lS,this.isOrthographic=!1,this.viewMatrix=new lR,this.projectionMatrix=new lR,this.viewProjectionMatrix=new lR,this.forward=new lS},hd=function(){this.virtualCamera=new hh,this.cullPlanes=[new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS),new lE(new lS)],this.splitBoundSphere=new lC(new lS,0)};(rK=sq||(sq={}))[rK.FarBottomLeft=0]="FarBottomLeft",rK[rK.FarTopLeft=1]="FarTopLeft",rK[rK.FarTopRight=2]="FarTopRight",rK[rK.FarBottomRight=3]="FarBottomRight",rK[rK.nearBottomLeft=4]="nearBottomLeft",rK[rK.nearTopLeft=5]="nearTopLeft",rK[rK.nearTopRight=6]="nearTopRight",rK[rK.nearBottomRight=7]="nearBottomRight",rK[rK.unknown=8]="unknown";var h_=((rj=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}},rj.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rj.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},rj.shadowCullFrustum=function(e,t,n,r){var a=n._entity.layer;e.camera.cullingMask&a&&t.cullingMask&a&&n.castShadows&&rj.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time.frameCount,n._prepareRender(e))},rj.getBoundSphereByFrustum=function(e,t,n,r,a){var i,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(lT.degreeToRadian(l)/2),u=c*c,h=t-e,d=t+e;u>h/d?(i=t,o=t*c):(i=.5*d*(1+u),o=.5*Math.sqrt(h*h+2*(t*t+e*e)*u+d*d*u*u));var _=a.splitBoundSphere.center;a.splitBoundSphere.radius=o,lS.scale(r,i,_),lS.add(n.entity.transform.worldPosition,_,_),a.sphereCenterZ=i},rj.getDirectionLightShadowCullPlanes=function(t,n,r,a,i){var o=rj._frustumCorners,s=rj._backPlaneFaces,l=rj._frustumPlaneNeighbors,c=rj._frustumTwoPlaneCorners,u=rj._edgePlanePoint2,h=i.cullPlanes,d=t.getPlane(e.FrustumFace.Near),_=t.getPlane(e.FrustumFace.Far),f=t.getPlane(e.FrustumFace.Left),p=t.getPlane(e.FrustumFace.Right),g=t.getPlane(e.FrustumFace.Bottom),m=t.getPlane(e.FrustumFace.Top),v=rj._adjustNearPlane,y=rj._adjustFarPlane;v.normal.copyFrom(d.normal),y.normal.copyFrom(_.normal),v.distance=d.distance-(n-r),y.distance=Math.min(-d.distance+i.sphereCenterZ+i.splitBoundSphere.radius,_.distance),lw.intersectionPointThreePlanes(v,g,p,o[7]),lw.intersectionPointThreePlanes(v,m,p,o[6]),lw.intersectionPointThreePlanes(v,m,f,o[5]),lw.intersectionPointThreePlanes(v,g,f,o[4]),lw.intersectionPointThreePlanes(y,g,p,o[3]),lw.intersectionPointThreePlanes(y,m,p,o[2]),lw.intersectionPointThreePlanes(y,m,f,o[1]),lw.intersectionPointThreePlanes(y,g,f,o[0]);for(var x=0,T=0;T<6;T++){var S=void 0;switch(T){case e.FrustumFace.Near:S=v;break;case e.FrustumFace.Far:S=y;break;default:S=t.getPlane(T)}0>lS.dot(S.normal,a)&&(h[x].copyFrom(S),s[x]=T,x++)}for(var C=x,A=0;A<x;A++)for(var w=s[A],E=l[w],b=0;b<4;b++){for(var M=E[b],F=!0,R=0;R<x;R++)if(M==s[R]){F=!1;break}if(F){var P=c[w][M],L=o[P[0]],D=o[P[1]];lS.add(L,a,u),lE.fromPoints(L,D,u,h[C++])}}i.cullPlaneCount=C},rj.getDirectionalLightMatrices=function(e,t,n,r,a,i,o,s){var l=o.splitBoundSphere;o.resolution=i;var c=l.center,u=l.radius,h=i/2,d=u*h/(h-rj.atlasBorderSize),_=2*d,f=i/_,p=_/i,g=Math.ceil(lS.dot(c,e)*f)*p,m=Math.ceil(lS.dot(c,t)*f)*p,v=lS.dot(c,n);c.x=e.x*g+t.x*m+n.x*v,c.y=e.y*g+t.y*m+n.y*v,c.z=e.z*g+t.z*m+n.z*v;var y=o.virtualCamera,x=y.position,T=y.viewMatrix,S=y.projectionMatrix;lS.scale(n,u+a,x),lS.subtract(c,x,x),lR.lookAt(x,c,e,T),lR.ortho(-d,d,-d,d,0,2*u+a,S);var C=y.viewProjectionMatrix;lR.multiply(S,T,C),c_._floatMatrixMultiply(rj._shadowMapCoordMatrix,C.elements,0,s,16*r)},rj.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},rj.getShadowBias=function(t,n,r,a){var i=2/n.elements[0]/r,o=-t.shadowBias*i,s=-t.shadowNormalBias*i;t.shadowType==e.ShadowType.SoftHigh&&(o*=2.5,s*=2.5),a.set(o,s)},rj.applySliceTransform=function(e,t,n,r,a,i){var o=rj._tempMatrix0,s=o.elements,l=1/t,c=1/n,u=a.x*l,h=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]=h,s[14]=0,s[15]=1;var d=16*r;c_._floatMatrixMultiply(o,i,d,i,d)},rj);h_._tempMatrix0=new lR,h_._shadowMapCoordMatrix=new lR(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),h_._frustumCorners=[new lS,new lS,new lS,new lS,new lS,new lS,new lS,new lS],h_._adjustNearPlane=new lE(new lS),h_._adjustFarPlane=new lE(new lS),h_._backPlaneFaces=[,,,,,],h_._edgePlanePoint2=new lS,h_._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]],h_._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]]],h_.atlasBorderSize=4;var hf=function(e){this._engine=e},hp=function(t){function n(r){var a;return(a=t.call(this,r.engine)||this)._shadowMapSize=new lD,a._shadowBias=new lL,a._shadowSliceData=new hd,a._lightUp=new lS,a._lightSide=new lS,a._existShadowMap=!1,a._splitBoundSpheres=new Float32Array(4*n._maxCascades),a._shadowMatrices=new Float32Array((n._maxCascades+1)*16),a._shadowInfos=new lS,a._viewportOffsets=[new lL,new lL,new lL,new lL],a._camera=r,a._supportDepthTexture=r.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),a._shadowSliceData.virtualCamera.isOrthographic=!0,a}lk(n,t);var r=n.prototype;return r.onRender=function(e){this._updateShadowSettings(),this._existShadowMap=!1,this._renderDirectShadowMap(e),this._existShadowMap&&this._updateReceiversShaderData()},r._renderDirectShadowMap=function(t){var r=this._engine,a=this._camera,i=this._viewportOffsets,o=this._shadowSliceData,s=this._splitBoundSpheres,l=this._shadowMatrices,c=a._renderPipeline._cullingResults,u=c.opaqueQueue,h=c.alphaTestQueue,d=c.transparentQueue,_=a.scene,f=_._componentsManager,p=r._hardwareRenderer,g=_.shadowCascades,m=n._cascadesSplitDistance,v=o.splitBoundSphere,y=n._tempMatrix0,x=y.elements,T=this._lightUp,S=this._lightSide,C=o.virtualCamera.forward,A=a.scene._sunLight;if(A){var w,E,b=Math.min(a.scene.shadowDistance,a.farClipPlane);this._getCascadesSplitDistance(b);var M=this._shadowMapSize,F=M.z,R=M.w,P=this._shadowMapFormat;(E=this._supportDepthTexture?(w=hu.recreateRenderTargetIfNeeded(r,this._renderTarget,F,R,null,P,!1)).depthTexture:(w=hu.recreateRenderTargetIfNeeded(r,this._renderTarget,F,R,P,null,!1)).getColorTexture(0)).wrapModeU=E.wrapModeV=e.TextureWrapMode.Clamp,r._hardwareRenderer._isWebGL2&&(E.depthCompareFunction=e.TextureDepthCompareFunction.Less),this._renderTarget=w,this._depthTexture=E,p.activeRenderTarget(w,n._viewport,0),this._supportDepthTexture?p.clearRenderTarget(r,e.CameraClearFlags.Depth,null):p.clearRenderTarget(r,e.CameraClearFlags.All,n._clearColor),this._shadowInfos.x=A.shadowStrength,this._shadowInfos.z=0,lR.rotationQuaternion(A.entity.transform.worldRotationQuaternion,y),S.set(x[0],x[1],x[2]),T.set(x[4],x[5],x[6]),C.set(-x[8],-x[9],-x[10]);var L=n._tempVector;L.copyFrom(a.entity.transform.worldForward);for(var D=this._shadowTileResolution,B=0;B<g;B++){h_.getBoundSphereByFrustum(m[B],m[B+1],a,L,o),h_.getDirectionLightShadowCullPlanes(a._frustum,m[B],a.nearClipPlane,C,o),h_.getDirectionalLightMatrices(T,S,C,B,A.shadowNearPlane,D,o,l),g>1&&h_.applySliceTransform(D,F,R,B,this._viewportOffsets[B],l),this._updateSingleShadowCasterShaderData(A,o,t);var I=v.center,V=v.radius,O=4*B;s[O]=I.x,s[O+1]=I.y,s[O+2]=I.z,s[O+3]=V*V,u.clear(),h.clear(),d.clear();for(var N=f._renderers,U=N._elements,z=N.length-1;z>=0;--z)h_.shadowCullFrustum(t,A,U[z],o);if(u.elements.length||h.elements.length){u.sort(hc._compareFromNearToFar),h.sort(hc._compareFromNearToFar);var k=i[B],G=k.x,H=k.y;p.setGlobalDepthBias(1,1),p.viewport(G,H,D,D),p.scissor(G+1,H+1,D-2,D-2),r._renderCount++,u.render(a,e.Layer.Everything,e.PipelineStage.ShadowCaster),h.render(a,e.Layer.Everything,e.PipelineStage.ShadowCaster),p.setGlobalDepthBias(0,0)}}this._existShadowMap=!0}},r._updateReceiversShaderData=function(){var e=this._camera.scene,t=this._splitBoundSpheres,r=this._shadowMatrices,a=e.shadowCascades;if(a>1)for(var i=4*a,o=t.length;i<o;i++)t[i]=0;for(var s=16*a,l=r.length;s<l;s++)r[s]=0;var c=e.shaderData;c.setFloatArray(n._shadowMatricesProperty,this._shadowMatrices),c.setVector3(n._shadowInfosProperty,this._shadowInfos),c.setTexture(n._shadowMapsProperty,this._depthTexture),c.setFloatArray(n._shadowSplitSpheresProperty,this._splitBoundSpheres),c.setVector4(n._shadowMapSize,this._shadowMapSize)},r._getCascadesSplitDistance=function(t){var r=n._cascadesSplitDistance,a=this._camera.scene,i=a.shadowTwoCascadeSplits,o=a.shadowFourCascadeSplits,s=a.shadowCascades,l=this._camera,c=l.nearClipPlane,u=l.aspectRatio,h=l.fieldOfView;r[0]=c;var d=t-c,_=Math.tan(.5*lT.degreeToRadian(h)),f=1+_*_*(u*u+1);switch(s){case e.ShadowCascadesMode.NoCascades:r[1]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.TwoCascades:r[1]=this._getFarWithRadius(c+d*i,f),r[2]=this._getFarWithRadius(t,f);break;case e.ShadowCascadesMode.FourCascades:r[1]=this._getFarWithRadius(c+d*o.x,f),r[2]=this._getFarWithRadius(c+d*o.y,f),r[3]=this._getFarWithRadius(c+d*o.z,f),r[4]=this._getFarWithRadius(t,f)}},r._getFarWithRadius=function(e,t){return Math.sqrt(e*e/t)},r._updateShadowSettings=function(){var t=this._camera.scene,n=h_.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=h_.shadowResolution(t.shadowResolution),a=t.shadowCascades;if(n!==this._shadowMapFormat||r!==this._shadowMapResolution||a!==this._shadowCascadeMode){if(this._shadowMapFormat=n,this._shadowMapResolution=r,this._shadowCascadeMode=a,a==e.ShadowCascadesMode.NoCascades)this._shadowTileResolution=r,this._shadowMapSize.set(1/r,1/r,r,r);else{var i=h_.getMaxTileResolutionInAtlas(r,r,a);this._shadowTileResolution=i;var o=2*i,s=a==e.ShadowCascadesMode.TwoCascades?i:2*i;this._shadowMapSize.set(1/o,1/s,o,s)}this._renderTarget=null;var l=this._viewportOffsets,c=this._shadowTileResolution;switch(a){case e.ShadowCascadesMode.NoCascades:l[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:l[0].set(0,0),l[1].set(c,0);break;case e.ShadowCascadesMode.FourCascades:l[0].set(0,0),l[1].set(c,0),l[2].set(0,c),l[3].set(c,c)}}},r._updateSingleShadowCasterShaderData=function(e,t,r){var a=t.virtualCamera;h_.getShadowBias(e,a.projectionMatrix,this._shadowTileResolution,this._shadowBias);var i=this._camera.scene.shaderData;i.setVector2(n._lightShadowBiasProperty,this._shadowBias),i.setVector3(n._lightDirectionProperty,e.direction),r.applyVirtualCamera(a)},n}(hf);hp._lightShadowBiasProperty=cs.getByName("scene_ShadowBias"),hp._lightDirectionProperty=cs.getByName("scene_LightDirection"),hp._shadowMatricesProperty=cs.getByName("scene_ShadowMatrices"),hp._shadowMapSize=cs.getByName("scene_ShadowMapSize"),hp._shadowInfosProperty=cs.getByName("scene_ShadowInfo"),hp._shadowMapsProperty=cs.getByName("scene_ShadowMap"),hp._shadowSplitSpheresProperty=cs.getByName("scene_ShadowSplitSpheres"),hp._maxCascades=4,hp._cascadesSplitDistance=Array(hp._maxCascades+1),hp._viewport=new lD(0,0,1,1),hp._clearColor=new lB(1,1,1,1),hp._tempVector=new lS,hp._tempMatrix0=new lR;var hg=((rY=(rq=function(e){this.opaqueQueue=new hc(e),this.transparentQueue=new hc(e),this.alphaTestQueue=new hc(e)}).prototype).reset=function(){this.opaqueQueue.clear(),this.transparentQueue.clear(),this.alphaTestQueue.clear()},rY.sort=function(){this.opaqueQueue.sort(hc._compareFromNearToFar),this.alphaTestQueue.sort(hc._compareFromNearToFar),this.transparentQueue.sort(hc._compareFromFarToNear)},rY.destroy=function(){this.opaqueQueue.destroy(),this.transparentQueue.destroy(),this.alphaTestQueue.destroy()},rq),hm=(lk(rQ=function(t){var n;return(n=hf.call(this,t)||this)._supportDepthTexture=t._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),n},hf),(rJ=rQ.prototype).onConfig=function(t){var n=this._engine,r=t.pixelViewport,a=r.width,i=r.height,o=hu.recreateRenderTargetIfNeeded(n,this._renderTarget,a,i,null,e.TextureFormat.Depth16,!1),s=o.depthTexture;s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Clamp,s.filterMode=e.TextureFilterMode.Point,this._renderTarget=o},rJ.onRender=function(t,n){var r=this._engine,a=this._renderTarget,i=t.camera,o=r._hardwareRenderer;o.activeRenderTarget(a,i.viewport,0),o.clearRenderTarget(r,e.CameraClearFlags.Depth,null),o.viewport(0,0,a.width,a.height),o.scissor(0,0,a.width,a.height),n.opaqueQueue.render(i,e.Layer.Everything,e.PipelineStage.DepthOnly),n.alphaTestQueue.render(i,e.Layer.Everything,e.PipelineStage.DepthOnly),i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,this._renderTarget.depthTexture)},rQ),hv=((r$=(rZ=function(e){this._allSpriteMasks=new cd,this._lastCanvasSize=new lL,this._camera=e;var t=e.engine;this._cullingResults=new hg(t),this._cascadedShadowCaster=new hp(e),this._depthOnlyPass=new hm(t),this._renderPassArray=[],this._defaultPass=new hs("default",0,null,null,0),this.addRenderPass(this._defaultPass)}).prototype).addRenderPass=function(e,t,n,r,a){if(void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null),"string"==typeof e){var i=new hs(e,t,n,r,a);this._renderPassArray.push(i)}else lX(e,hs)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},r$.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):lX(e,hs)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},r$.getRenderPass=function(e){for(var t=0,n=this._renderPassArray.length;t<n;t++){var r=this._renderPassArray[t];if(r.name===e)return r}return null},r$.destroy=function(){this._cullingResults.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},r$.render=function(t,n,r){var a,i=this._camera,o=i.scene,s=this._cullingResults;i.engine._spriteMaskManager.clear(),o.castShadows&&(null==(a=o._sunLight)?void 0:a.shadowType)!==e.ShadowType.None&&this._cascadedShadowCaster.onRender(t),s.reset(),this._allSpriteMasks.length=0,t.applyVirtualCamera(i._virtualCamera),this._callRender(t),s.sort();var l=this._depthOnlyPass;i.depthTextureMode===e.DepthTextureMode.PrePass&&l._supportDepthTexture?(l.onConfig(i),l.onRender(t,s)):i.shaderData.setTexture(e.Camera._cameraDepthTextureProperty,i.engine._whiteTexture2D);for(var c=0,u=this._renderPassArray.length;c<u;c++)this._drawRenderPass(t,this._renderPassArray[c],i,n,r)},r$._drawRenderPass=function(t,n,r,a,i){var o=this._cullingResults,s=o.opaqueQueue,l=o.alphaTestQueue,c=o.transparentQueue;if(n.preRender(r,s,l,c),n.enabled){var u,h,d=r.engine,_=r.scene.background,f=d._hardwareRenderer,p=r.renderTarget||n.renderTarget;f.activeRenderTarget(p,r.viewport,i),null==p||p._setRenderTargetInfo(a,i);var g=null!=(u=n.clearFlags)?u:r.clearFlags,m=null!=(h=n.clearColor)?h:_.solidColor;g!==e.CameraClearFlags.None&&f.clearRenderTarget(r.engine,g,m),n.renderOverride?n.render(r,s,l,c):(s.render(r,n.mask,e.PipelineStage.Forward),l.render(r,n.mask,e.PipelineStage.Forward),r.clearFlags&e.CameraClearFlags.Color&&(_.mode===e.BackgroundMode.Sky?_.sky._render(t):_.mode===e.BackgroundMode.Texture&&_.texture&&this._drawBackgroundTexture(d,_)),o.transparentQueue.render(r,n.mask,e.PipelineStage.Forward)),null==p||p._blitRenderTarget(),null==p||p.generateMipmaps()}n.postRender(r,o.opaqueQueue,o.alphaTestQueue,o.transparentQueue)},r$.pushRenderData=function(e,t){var n=t.material,r=n.renderStates,a=n.shader.subShaders[0],i=e.replacementShader;if(i){var o=i.subShaders,s=e.replacementTag;if(s)for(var l=0,c=o.length;l<c;l++){var u=o[l];if(u.getTagValue(s)===a.getTagValue(s)){this.pushRenderDataWihShader(e,t,u.passes,r);break}}else this.pushRenderDataWihShader(e,t,o[0].passes,r)}else this.pushRenderDataWihShader(e,t,a.passes,r)},r$.pushRenderDataWihShader=function(t,n,r,a){for(var i=this._cullingResults,o=i.opaqueQueue,s=i.alphaTestQueue,l=i.transparentQueue,c=t.camera.engine._renderElementPool,u=0,h=0,d=r.length;h<d;h++){var _=a[h].renderQueueType;if(!(u&1<<_)){var f=c.getFromPool();switch(f.set(n,r),_){case e.RenderQueueType.Opaque:o.pushRenderElement(f),u|=1;break;case e.RenderQueueType.AlphaTest:s.pushRenderElement(f),u|=2;break;case e.RenderQueueType.Transparent:l.pushRenderElement(f),u|=4}}}},r$._drawBackgroundTexture=function(t,n){var r=t._hardwareRenderer,a=t._backgroundTextureMaterial,i=t.canvas,o=n._mesh;(this._lastCanvasSize.x!==i.width||this._lastCanvasSize.y!==i.height)&&n._textureFillMode!==e.BackgroundTextureFillMode.Fill&&(this._lastCanvasSize.set(i.width,i.height),n._resizeBackgroundTexture());var s=a.shader.subShaders[0].passes[0],l=s._getShaderProgram(t,cH._compileMacros);l.bind(),l.uploadAll(l.materialUniformBlock,a.shaderData),l.uploadUnGroupTextures(),(s._renderState||a.renderState)._apply(t,!1,s._renderStateDataMap,a.shaderData),r.drawPrimitive(o,o.subMesh,l)},r$._callRender=function(e){for(var t=e.camera.engine,n=e.camera,r=n.scene._componentsManager._renderers,a=r._elements,i=r.length-1;i>=0;--i){var o=a[i];n.cullingMask&o._entity.layer&&(!n.enableFrustumCulling||n._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},lU(rZ,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rZ);(r0=sY||(sY={}))[r0.None=0]="None",r0[r0.Opaque=1]="Opaque",r0[r0.AlphaTest=2]="AlphaTest",r0[r0.Transparent=4]="Transparent";var hy=function(){};hy.tempVec4=new lD,hy.tempVec3=new lS,hy.tempVec2=new lL,e.Camera=(lk(r1=function(t){(n=cc.call(this,t)||this).enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n.depthTextureMode=e.DepthTextureMode.None,n._globalShaderMacro=new cE,n._frustum=new lb,n._virtualCamera=new hh,n._replacementShader=null,n._replacementSubShaderTag=null,n._priority=0,n._shaderData=new cW(sB.Camera),n._isProjMatSetting=!1,n._nearClipPlane=.1,n._farClipPlane=100,n._fieldOfView=45,n._orthographicSize=10,n._isProjectionDirty=!0,n._isInvProjMatDirty=!0,n._isFrustumProjectDirty=!0,n._customAspectRatio=void 0,n._renderTarget=null,n._depthBufferParams=new lD,n._viewport=new lD(0,0,1,1),n._pixelViewport=new lI(0,0,0,0),n._inverseProjectionMatrix=new lR,n._lastAspectSize=new lL(0,0),n._invViewProjMat=new lR;var n,r=n.entity.transform;return n._transform=r,n._isViewMatrixDirty=r.registerWorldChangeFlag(),n._isInvViewProjDirty=r.registerWorldChangeFlag(),n._frustumViewChangeFlag=r.registerWorldChangeFlag(),n._renderPipeline=new hv(lO(n)),n.shaderData._addReferCount(1),n._updatePixelViewport(),n},cc),(r2=r1.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},r2.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},r2.worldToViewportPoint=function(e,t){var n=hy.tempVec3,r=hy.tempVec4;lS.transformCoordinate(e,this.viewMatrix,n),lS.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},r2.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},r2.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,n,t.direction);return lS.subtract(a,r,a),a.normalize(),t},r2.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},r2.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},r2.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},r2.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},r2.screenPointToRay=function(e,t){var n=hy.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},r2.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,a=this.entity.transform;lR.multiply(this.projectionMatrix,this.viewMatrix,r.viewProjectionMatrix),r.position.copyFrom(a.worldPosition),r.isOrthographic&&r.forward.copyFrom(a.worldForward),n.camera=this,n.virtualCamera=r,n.replacementShader=this._replacementShader,n.replacementTag=this._replacementSubShaderTag,this.enableFrustumCulling&&(this._frustumViewChangeFlag.flag||this._isFrustumProjectDirty)&&(this._frustum.calculateFromMatrix(r.viewProjectionMatrix),this._frustumViewChangeFlag.flag=!1,this._isFrustumProjectDirty=!1),this._updateShaderData(),cE.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,l8.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},r2.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?cR.getByName(t):t},r2.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},r2._onEnableInScene=function(){this.scene._attachRenderCamera(this)},r2._onDisableInScene=function(){this.scene._detachRenderCamera(this)},r2._onDestroy=function(){var e;cc.prototype._onDestroy.call(this),null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addReferCount(-1),this._entity=null,this._globalShaderMacro=null,this._frustum=null,this._renderPipeline=null,this._virtualCamera=null,this._shaderData=null,this._frustumViewChangeFlag=null,this._transform=null,this._isViewMatrixDirty=null,this._isInvViewProjDirty=null,this._viewport=null,this._inverseProjectionMatrix=null,this._lastAspectSize=null,this._invViewProjMat=null},r2._updatePixelViewport=function(){var e,t,n,r,a=this._viewport,i=null!=(n=null==(e=this._renderTarget)?void 0:e.width)?n:this.engine.canvas.width,o=null!=(r=null==(t=this._renderTarget)?void 0:t.height)?r:this.engine.canvas.height;this._pixelViewport.set(a.x*i,a.y*o,a.z*i,a.w*o)},r2._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},r2._innerViewportToWorldPoint=function(e,t,n,r,a){var i=hy.tempVec3;return i.set(2*e-1,1-2*t,2*n-1),lS.transformCoordinate(i,r,a),a},r2._updateShaderData=function(){var t=this._depthBufferParams,n=this._farClipPlane/this._nearClipPlane;t.set(1-n,n,0,0);var r=this.shaderData;r.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),r.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition),r.setVector4(e.Camera._cameraDepthBufferParamsProperty,t)},r2._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,lR.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},r2._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,lR.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},lU(r1,[{key:"shaderData",get:function(){return this._shaderData}},{key:"nearClipPlane",get:function(){return this._nearClipPlane},set:function(e){this._nearClipPlane=e,this._projMatChange()}},{key:"farClipPlane",get:function(){return this._farClipPlane},set:function(e){this._farClipPlane=e,this._projMatChange()}},{key:"fieldOfView",get:function(){return this._fieldOfView},set:function(e){this._fieldOfView=e,this._projMatChange()}},{key:"aspectRatio",get:function(){var e,t=this._entity.engine.canvas;return null!=(e=this._customAspectRatio)?e:t.width*this._viewport.z/(t.height*this._viewport.w)},set:function(e){this._customAspectRatio=e,this._projMatChange()}},{key:"viewport",get:function(){return this._viewport},set:function(e){e!==this._viewport&&this._viewport.copyFrom(e),this._projMatChange(),this._updatePixelViewport()}},{key:"pixelViewport",get:function(){return this._pixelViewport}},{key:"priority",get:function(){return this._priority},set:function(e){this._priority!==e&&(this._entity._isActiveInScene&&this.enabled&&(this.scene._cameraNeedSorting=!0),this._priority=e)}},{key:"isOrthographic",get:function(){return this._virtualCamera.isOrthographic},set:function(e){this._virtualCamera.isOrthographic=e,this._projMatChange()}},{key:"orthographicSize",get:function(){return this._orthographicSize},set:function(e){this._orthographicSize=e,this._projMatChange()}},{key:"viewMatrix",get:function(){var e=this._virtualCamera.viewMatrix;if(this._isViewMatrixDirty.flag){this._isViewMatrixDirty.flag=!1;var t=this._transform;lR.rotationTranslation(t.worldRotationQuaternion,t.worldPosition,e),e.invert()}return e}},{key:"projectionMatrix",get:function(){var e=this._virtualCamera,t=e.projectionMatrix,n=this._entity.engine.canvas;if((!this._isProjectionDirty||this._isProjMatSetting)&&this._lastAspectSize.x===n.width&&this._lastAspectSize.y===n.height)return t;this._isProjectionDirty=!1,this._lastAspectSize.x=n.width,this._lastAspectSize.y=n.height;var r=this.aspectRatio;if(e.isOrthographic){var a=this._orthographicSize*r,i=this._orthographicSize;lR.ortho(-a,a,-i,i,this._nearClipPlane,this._farClipPlane,t)}else lR.perspective(lT.degreeToRadian(this._fieldOfView),r,this._nearClipPlane,this._farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isProjMatSetting=!0,this._projMatChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){if(this._renderTarget!==e){var t;null==e||e._addReferCount(1),null==(t=this._renderTarget)||t._addReferCount(-1),this._renderTarget=e,this._updatePixelViewport()}}}]),(sQ=r1)._cameraDepthTextureProperty=cs.getByName("camera_DepthTexture"),sQ._inverseViewMatrixProperty=cs.getByName("camera_ViewInvMat"),sQ._cameraPositionProperty=cs.getByName("camera_Position"),sQ._cameraDepthBufferParamsProperty=cs.getByName("camera_DepthBufferParams"),sQ),lW([lY],e.Camera.prototype,"_frustum",void 0),lW([lK],e.Camera.prototype,"_renderPipeline",void 0),lW([lK],e.Camera.prototype,"_virtualCamera",void 0),lW([lK],e.Camera.prototype,"_frustumViewChangeFlag",void 0),lW([lK],e.Camera.prototype,"_transform",void 0),lW([lK],e.Camera.prototype,"_isViewMatrixDirty",void 0),lW([lK],e.Camera.prototype,"_isInvViewProjDirty",void 0),lW([lY],e.Camera.prototype,"_viewport",void 0),lW([lY],e.Camera.prototype,"_pixelViewport",void 0),lW([lY],e.Camera.prototype,"_inverseProjectionMatrix",void 0),lW([lY],e.Camera.prototype,"_lastAspectSize",void 0),lW([lY],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=lW([ch(cy,e.DependentMode.CheckOnly)],e.Camera);var hx={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},hT=1/0;function hS(e,t){return void 0===t&&(t={}),new uT(function(n,r,a){var i,o,s,l,c=null!=(i=t.retryCount)?i:1,u=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:hT,t.type=null!=(l=t.type)?l:hx[e.substring(e.lastIndexOf(".")+1)];var h="image"===t.type?hC:hA;new hw(function(){return h(e,t).onProgress(a)},c,u).start().onError(r).onComplete(n)})}function hC(e,t){return new uT(function(n,r){var a,i=t.timeout,o=new Image,s=function(){r(Error("request "+e+" fail"))};o.onerror=s,o.onabort=s;var l=-1;i!=1/0&&(l=window.setTimeout(function(){r(Error("request "+e+" timeout"))},i)),o.onload=(a=l,function(){requestAnimationFrame(function(){n(o),o.onload=null,o.onerror=null,o.onabort=null}),clearTimeout(a)}),o.crossOrigin="anonymous",o.src=e})}function hA(e,t){return new uT(function(n,r,a){var i,o=new XMLHttpRequest;o.timeout=t.timeout,t.method=null!=(i=t.method)?i:"get",o.onload=function(){var t;if(o.status<200||o.status>=300){r(Error("request failed from: "+e));return}n(null!=(t=o.response)?t:o.responseText)},o.onerror=function(){r(Error("request failed from: "+e))},o.ontimeout=function(){r(Error("request timeout from: "+e))},o.onprogress=function(e){a(e.loaded/e.total)},o.open(t.method,e,!0),o.withCredentials="include"===t.credentials,o.responseType=t.type;var s=t.headers;s&&Object.keys(s).forEach(function(e){o.setRequestHeader(e,s[e])}),o.send(t.body)})}var hw=((r4=(r3=function(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}).prototype).start=function(){return this.exec(),this},r4.onComplete=function(e){return this._onComplete=e,this},r4.onError=function(e){return this._onError=e,this},r4.cancel=function(){window.clearTimeout(this._timeoutId)},r4.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)})},r3),hE=((r5=function(e){this.useCache=e,this.request=hS}).registerClass=function(e,t){this._engineObjects[e]=t},r5.getClass=function(e){return this._engineObjects[e]},r5);hE._engineObjects={},e.AssetType=void 0,(r8=e.AssetType||(e.AssetType={})).Text="Text",r8.JSON="JSON",r8.Buffer="Buffer",r8.Texture2D="Texture2D",r8.TextureCube="TextureCube",r8.Material="Material",r8.Mesh="Mesh",r8.AnimationClip="AnimationClip",r8.AnimatorController="AnimatorController",r8.GLTF="GLTF",r8.KTX="KTX",r8.KTXCube="KTXCube",r8.KTX2="KTX2",r8.Sprite="Sprite",r8.SpriteAtlas="SpriteAtlas",r8.Env="Environment",r8.Scene="Scene",r8.HDR="HDR",r8.Font="Font",r8.SourceFont="SourceFont",e.BlendMode=void 0,(r6=e.BlendMode||(e.BlendMode={}))[r6.Normal=0]="Normal",r6[r6.Additive=1]="Additive",e.RenderFace=void 0,(r7=e.RenderFace||(e.RenderFace={}))[r7.Front=0]="Front",r7[r7.Back=1]="Back",r7[r7.Double=2]="Double";var hb=function(t){function n(r,a){var i;return(i=t.call(this,r,a)||this)._renderFace=e.RenderFace.Front,i._isTransparent=!1,i._blendMode=e.BlendMode.Normal,i.shaderData.setFloat(n._alphaCutoffProp,0),i}lk(n,t);var r=n.prototype;return r.setIsTransparent=function(t,r){var a=this.renderStates;if(a.length<t)throw"Pass should less than pass count.";var i=a[t];r?(i.blendState.targetBlendState.enabled=!0,i.depthState.writeEnabled=!1,i.renderQueueType=e.RenderQueueType.Transparent,this.shaderData.enableMacro(n._transparentMacro)):(i.blendState.targetBlendState.enabled=!1,i.depthState.writeEnabled=!0,i.renderQueueType=this.shaderData.getFloat(n._alphaCutoffProp)?e.RenderQueueType.AlphaTest:e.RenderQueueType.Opaque,this.shaderData.disableMacro(n._transparentMacro))},r.setBlendMode=function(t,n){var r=this.renderStates;if(r.length<t)throw"Pass should less than pass count.";var a=r[t].blendState.targetBlendState;switch(n){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}},r.setRenderFace=function(t,n){var r=this.renderStates;if(r.length<t)throw"Pass should less than pass count.";switch(n){case e.RenderFace.Front:r[t].rasterState.cullMode=e.CullMode.Back;break;case e.RenderFace.Back:r[t].rasterState.cullMode=e.CullMode.Front;break;case e.RenderFace.Double:r[t].rasterState.cullMode=e.CullMode.Off}},r.clone=function(){var e=new n(this._engine,this.shader);return this.cloneTo(e),e},r.cloneTo=function(e){t.prototype.cloneTo.call(this,e),e._renderFace=this._renderFace,e._isTransparent=this._isTransparent,e._blendMode=this._blendMode},lU(n,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader=t;for(var n=this._renderStates,r=n.length,a=0,i=t.subShaders,o=0;o<i.length;o++)a=Math.max(i[o].passes.length,a);if(r<a)for(var s=r;s<a;s++)n.push(new cG),this.setBlendMode(s,e.BlendMode.Normal);else n.length=a}},{key:"isTransparent",get:function(){return this._isTransparent},set:function(e){e!==this._isTransparent&&(this.setIsTransparent(0,e),this._isTransparent=e)}},{key:"blendMode",get:function(){return this._blendMode},set:function(e){e!==this._blendMode&&(this.setBlendMode(0,e),this._blendMode=e)}},{key:"alphaCutoff",get:function(){return this.shaderData.getFloat(n._alphaCutoffProp)},set:function(t){var r=this.shaderData;if(r.getFloat(n._alphaCutoffProp)!==t){t?r.enableMacro(n._alphaCutoffMacro):r.disableMacro(n._alphaCutoffMacro);for(var a=this.renderStates,i=0,o=a.length;i<o;i++){var s=a[i];t>0?s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.AlphaTest:s.renderQueueType=s.blendState.targetBlendState.enabled?e.RenderQueueType.Transparent:e.RenderQueueType.Opaque}r.setFloat(n._alphaCutoffProp,t)}}},{key:"renderFace",get:function(){return this._renderFace},set:function(e){e!==this._renderFace&&(this.setRenderFace(0,e),this._renderFace=e)}}]),n}(uZ);hb._baseTextureMacro=cw.getByName("MATERIAL_HAS_BASETEXTURE"),hb._normalTextureMacro=cw.getByName("MATERIAL_HAS_NORMALTEXTURE"),hb._emissiveTextureMacro=cw.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),hb._transparentMacro=cw.getByName("MATERIAL_IS_TRANSPARENT"),hb._baseColorProp=cs.getByName("material_BaseColor"),hb._baseTextureProp=cs.getByName("material_BaseTexture"),hb._tilingOffsetProp=cs.getByName("material_TilingOffset"),hb._normalTextureProp=cs.getByName("material_NormalTexture"),hb._normalIntensityProp=cs.getByName("material_NormalIntensity"),hb._emissiveColorProp=cs.getByName("material_EmissiveColor"),hb._emissiveTextureProp=cs.getByName("material_EmissiveTexture"),hb._alphaCutoffProp=cs.getByName("material_AlphaCutoff"),hb._alphaCutoffMacro=cw.getByName("MATERIAL_IS_ALPHA_CUTOFF");var hM=function(e){function t(n){var r,a=(r=e.call(this,n,cH.find("blinn-phong"))||this).shaderData;return a.enableMacro("MATERIAL_NEED_WORLD_POS"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new lB(1,1,1,1)),a.setColor(t._specularColorProp,new lB(1,1,1,1)),a.setColor(t._emissiveColorProp,new lB(0,0,0,1)),a.setVector4(t._tilingOffsetProp,new lD(1,1,0,0)),a.setFloat(t._shininessProp,16),a.setFloat(t._normalIntensityProp,1),r}return lk(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lU(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}(hb);hM._specularColorProp=cs.getByName("material_SpecularColor"),hM._shininessProp=cs.getByName("material_Shininess"),hM._specularTextureProp=cs.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(r9=e.TextureCoordinate||(e.TextureCoordinate={}))[r9.UV0=0]="UV0",r9[r9.UV1=1]="UV1",r9[r9.UV2=2]="UV2",r9[r9.UV3=3]="UV3",r9[r9.UV4=4]="UV4",r9[r9.UV5=5]="UV5",r9[r9.UV6=6]="UV6",r9[r9.UV7=7]="UV7";var hF=function(t){function n(r,a){var i,o=(i=t.call(this,r,a)||this).shaderData;return o.enableMacro("MATERIAL_NEED_WORLD_POS"),o.enableMacro("MATERIAL_NEED_TILING_OFFSET"),o.setColor(n._baseColorProp,new lB(1,1,1,1)),o.setColor(n._emissiveColorProp,new lB(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new lD(1,1,0,0)),o.setFloat(n._normalIntensityProp,1),o.setFloat(n._occlusionTextureIntensityProp,1),o.setFloat(n._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(n._clearCoatProp,0),o.setFloat(n._clearCoatRoughnessProp,0),i}return lk(n,t),lU(n,[{key:"baseColor",get:function(){return this.shaderData.getColor(n._baseColorProp)},set:function(e){var t=this.shaderData.getColor(n._baseColorProp);e!==t&&t.copyFrom(e)}},{key:"baseTexture",get:function(){return this.shaderData.getTexture(n._baseTextureProp)},set:function(e){this.shaderData.setTexture(n._baseTextureProp,e),e?this.shaderData.enableMacro(n._baseTextureMacro):this.shaderData.disableMacro(n._baseTextureMacro)}},{key:"normalTexture",get:function(){return this.shaderData.getTexture(n._normalTextureProp)},set:function(e){this.shaderData.setTexture(n._normalTextureProp,e),e?this.shaderData.enableMacro(n._normalTextureMacro):this.shaderData.disableMacro(n._normalTextureMacro)}},{key:"normalTextureIntensity",get:function(){return this.shaderData.getFloat(n._normalIntensityProp)},set:function(e){this.shaderData.setFloat(n._normalIntensityProp,e)}},{key:"emissiveColor",get:function(){return this.shaderData.getColor(n._emissiveColorProp)},set:function(e){var t=this.shaderData.getColor(n._emissiveColorProp);e!==t&&t.copyFrom(e)}},{key:"emissiveTexture",get:function(){return this.shaderData.getTexture(n._emissiveTextureProp)},set:function(e){this.shaderData.setTexture(n._emissiveTextureProp,e),e?this.shaderData.enableMacro(n._emissiveTextureMacro):this.shaderData.disableMacro(n._emissiveTextureMacro)}},{key:"occlusionTexture",get:function(){return this.shaderData.getTexture(n._occlusionTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._occlusionTextureIntensityProp)},set:function(e){this.shaderData.setFloat(n._occlusionTextureIntensityProp,e)}},{key:"occlusionTextureCoord",get:function(){return this.shaderData.getFloat(n._occlusionTextureCoordProp)},set:function(t){t>e.TextureCoordinate.UV1&&l8.warn("Occlusion texture uv coordinate must be UV0 or UV1."),this.shaderData.setFloat(n._occlusionTextureCoordProp,t)}},{key:"tilingOffset",get:function(){return this.shaderData.getVector4(n._tilingOffsetProp)},set:function(e){var t=this.shaderData.getVector4(n._tilingOffsetProp);e!==t&&t.copyFrom(e)}},{key:"clearCoat",get:function(){return this.shaderData.getFloat(n._clearCoatProp)},set:function(e){!!this.shaderData.getFloat(n._clearCoatProp)!=!!e&&(0===e?this.shaderData.disableMacro("MATERIAL_ENABLE_CLEAR_COAT"):this.shaderData.enableMacro("MATERIAL_ENABLE_CLEAR_COAT")),this.shaderData.setFloat(n._clearCoatProp,e)}},{key:"clearCoatTexture",get:function(){return this.shaderData.getTexture(n._clearCoatTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._clearCoatRoughnessProp)},set:function(e){this.shaderData.setFloat(n._clearCoatRoughnessProp,e)}},{key:"clearCoatRoughnessTexture",get:function(){return this.shaderData.getTexture(n._clearCoatRoughnessTextureProp)},set:function(e){this.shaderData.setTexture(n._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(n._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(n._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE")}}]),n}(hb);hF._occlusionTextureIntensityProp=cs.getByName("material_OcclusionIntensity"),hF._occlusionTextureCoordProp=cs.getByName("material_OcclusionTextureCoord"),hF._occlusionTextureProp=cs.getByName("material_OcclusionTexture"),hF._clearCoatProp=cs.getByName("material_ClearCoat"),hF._clearCoatTextureProp=cs.getByName("material_ClearCoatTexture"),hF._clearCoatRoughnessProp=cs.getByName("material_ClearCoatRoughness"),hF._clearCoatRoughnessTextureProp=cs.getByName("material_ClearCoatRoughnessTexture"),hF._clearCoatNormalTextureProp=cs.getByName("material_ClearCoatNormalTexture");var hR=function(e){function t(n){var r;return(r=e.call(this,n,cH.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return lk(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lU(t,[{key:"ior",get:function(){return this.shaderData.getFloat(t._iorProp)},set:function(e){this.shaderData.setFloat(t._iorProp,Math.max(e,0))}},{key:"metallic",get:function(){return this.shaderData.getFloat(t._metallicProp)},set:function(e){this.shaderData.setFloat(t._metallicProp,e)}},{key:"roughness",get:function(){return this.shaderData.getFloat(t._roughnessProp)},set:function(e){this.shaderData.setFloat(t._roughnessProp,e)}},{key:"roughnessMetallicTexture",get:function(){return this.shaderData.getTexture(t._roughnessMetallicTextureProp)},set:function(e){this.shaderData.setTexture(t._roughnessMetallicTextureProp,e),e?this.shaderData.enableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE"):this.shaderData.disableMacro("MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE")}}]),t}(hF);hR._metallicProp=cs.getByName("material_Metal"),hR._roughnessProp=cs.getByName("material_Roughness"),hR._roughnessMetallicTextureProp=cs.getByName("material_RoughnessMetallicTexture"),hR._iorProp=cH.getPropertyByName("material_IOR");var hP=function(e){function t(n){var r;return(r=e.call(this,n,cH.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new lB(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return lk(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lU(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}(hF);hP._specularColorProp=cs.getByName("material_PBRSpecularColor"),hP._glossinessProp=cs.getByName("material_Glossiness"),hP._specularGlossinessTextureProp=cs.getByName("material_SpecularGlossinessTexture"),hP._specularGlossinessTextureMacro=cw.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var hL=function(e){function t(n){var r,a=(r=e.call(this,n,cH.find("unlit"))||this).shaderData;return a.enableMacro("MATERIAL_OMIT_NORMAL"),a.enableMacro("MATERIAL_NEED_TILING_OFFSET"),a.setColor(t._baseColorProp,new lB(1,1,1,1)),a.setVector4(t._tilingOffsetProp,new lD(1,1,0,0)),r}return lk(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lU(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}(hb);e.TextHorizontalAlignment=void 0,(ae=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[ae.Left=0]="Left",ae[ae.Center=1]="Center",ae[ae.Right=2]="Right",e.TextVerticalAlignment=void 0,(at=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[at.Top=0]="Top",at[at.Center=1]="Center",at[at.Bottom=2]="Bottom";var hD=(lk(an=function(e){var t;return(t=lZ.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},lZ),(ar=an.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},ar.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},ar._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},ar._onDestroy=function(){lZ.prototype._onDestroy.call(this);for(var e=this._sprites,t=0,n=e.length;t<n;t++)e[t].destroy();e.length=0,this._sprites=null,this._spriteNamesToIndex=null},lU(an,[{key:"sprites",get:function(){return this._sprites}}]),an);e.SpriteDrawMode=void 0,(aa=e.SpriteDrawMode||(e.SpriteDrawMode={}))[aa.Simple=0]="Simple",aa[aa.Sliced=1]="Sliced",aa[aa.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(ai=e.SpriteTileMode||(e.SpriteTileMode={}))[ai.Continuous=0]="Continuous",ai[ai.Adaptive=1]="Adaptive";var hB=(lk(ao=function(e,t,n,r,a,i){var o;return void 0===t&&(t=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===a&&(a=null),void 0===i&&(i=null),(o=lZ.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new lL,new lL,new lL,new lL],o._uvs=[new lL,new lL,new lL,new lL],o._bounds=new lA,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new lI(0,0,1,1),o._atlasRegionOffset=new lD(0,0,0,0),o._region=new lI(0,0,1,1),o._pivot=new lL(.5,.5),o._border=new lD(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new cv,o._texture=t,o._onRegionChange=o._onRegionChange.bind(lO(o)),o._onPivotChange=o._onPivotChange.bind(lO(o)),o._onBorderChange=o._onBorderChange.bind(lO(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),a&&o._border.copyFrom(a),o.name=i,o},lZ),(as=ao.prototype).clone=function(){var e=new ao(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},as._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},as._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},as._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},as._addReferCount=function(e){var t;lZ.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},as._onDestroy=function(){lZ.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},as._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,a=1/u4._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},as._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 h=this._bounds,d=h.min,_=h.max;d.set(o,s,0),_.set(l,c,0),this._dirtyUpdateFlag&=-2},as._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,h=c.y,d=c.width,_=c.height,f=t.x,p=t.y,g=t.z,m=t.w,v=d/(1-f-g),y=_/(1-p-m),x=this._border,T=x.x,S=x.y,C=x.z,A=x.w;e[0].set(Math.max(r-f,0)*v+u,_+h-Math.max(a-m,0)*y),e[1].set((r-f+T*i)*v+u,_+h-(a-m+S*o)*y),e[2].set(d+u-(s-g+C*i)*v,(l-p+A*o)*y+h),e[3].set(d+u-Math.max(s-g,0)*v,Math.max(l-p,0)*y+h),this._dirtyUpdateFlag&=-3},as._dispatchSpriteChange=function(e){switch(e){case sN.texture:this._dirtyUpdateFlag|=4;break;case sN.atlasRegionOffset:case sN.region:this._dirtyUpdateFlag|=7;break;case sN.atlasRegion:this._dirtyUpdateFlag|=6;break;case sN.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},as._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=lT.clamp(e.x,0,1),n=lT.clamp(e.y,0,1);e.set(t,n,lT.clamp(e.width,0,1-t),lT.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sN.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sN.size),e._onValueChanged=this._onRegionChange},as._onPivotChange=function(){this._dispatchSpriteChange(sN.pivot)},as._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=lT.clamp(e.x,0,1),n=lT.clamp(e.y,0,1);e.set(t,n,lT.clamp(e.z,0,1-t),lT.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sN.border),e._onValueChanged=this._onBorderChange},lU(ao,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(sN.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sN.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(sN.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(sN.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=lT.clamp(e.x,0,1),n=lT.clamp(e.y,0,1);this._atlasRegion.set(t,n,lT.clamp(e.width,0,1-t),lT.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sN.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sN.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=lT.clamp(e.x,0,1),n=lT.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,lT.clamp(e.z,0,1-t),lT.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sN.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sN.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)}}]),ao);(al=sJ||(sJ={}))[al.positions=1]="positions",al[al.uvs=2]="uvs",al[al.automaticSize=4]="automaticSize",al[al.all=7]="all";var hI=((ac=function(){}).resetData=function(e){var t=e._verticesData,n=t.positions,r=t.uvs;if(n.length<16)for(var a=n.length;a<16;a++)n.push(new lS),r.push(new lL);t.triangles=[]},ac.updatePositions=function(e){var t,n,r=e.width,a=e.height,i=e.sprite,o=e._verticesData,s=o.positions,l=o.uvs,c=o.triangles,u=i.border,h=i._getUVs(),d=i._getPositions(),_=d[0],f=_.x,p=_.y,g=d[3],m=g.x,v=g.y,y=i.width,x=i.height,T=y*u.x,S=x*u.y,C=y*u.z,A=x*u.w;if(T+C>r){var w=r/(T+C);t=[y*f*w,T*w,T*w,r-y*(1-m)*w]}else t=[y*f,T,r-C,r-y*(1-m)];if(A+S>a){var E=a/(A+S);n=[x*p*E,S*E,S*E,a-x*(1-v)*E]}else n=[x*p,S,a-A,a-x*(1-v)];var b=e.sprite.pivot,M=b.x,F=b.y,R=e.width*M,P=e.height*F,L=hI._worldMatrix,D=L.elements,B=e.entity.transform.worldMatrix.elements,I=e.flipX?-1:1,V=e.flipY?-1:1;D[0]=B[0]*I,D[1]=B[1]*I,D[2]=B[2]*I,D[4]=B[4]*V,D[5]=B[5]*V,D[6]=B[6]*V,D[8]=B[8],D[9]=B[9],D[10]=B[10],D[12]=B[12]-R*D[0]-P*D[4],D[13]=B[13]-R*D[1]-P*D[5],D[14]=B[14]-R*D[2]-P*D[6];for(var O=0,N=0,U=0;U<4;U++){for(var z=t[U],k=h[U].x,G=0;G<4;G++){var H=n[G];s[O].set(D[0]*z+D[4]*H+D[12],D[1]*z+D[5]*H+D[13],D[2]*z+D[6]*H+D[14]),l[O].set(k,h[G].y),++O}++N}for(var W=O/N,X=0,K=0;K<N-1;++K)for(var j=0;j<W-1;++j){var q=K*W+j;c[X++]=q,c[X++]=q+1,c[X++]=q+W,c[X++]=q+1,c[X++]=q+W+1,c[X++]=q+W}e._verticesData.vertexCount=N*W,c.length=(N-1)*(W-1)*6;var Y=e._bounds,Q=Y.min,J=Y.max;Q.set(t[0],n[0],0),J.set(t[3],n[3],0),e._bounds.transform(L)},ac.updateUVs=function(e){},ac._worldMatrix=new lR,ac);hI=lW([cj()],hI);var hV=((au=function(){}).resetData=function(e){var t;(t=e._verticesData).triangles||(t.triangles=[])},au.updatePositions=function(t){var n,r,a,i,o,s,l=t.width,c=t.height,u=t.sprite,h=t.tileMode,d=t.tiledAdaptiveThreshold,_=t._verticesData,f=_.positions,p=_.uvs,g=_.triangles,m=this._posRow,v=this._posColumn,y=this._uvRow,x=this._uvColumn;m.length=v.length=y.length=x.length=0,h===e.SpriteTileMode.Adaptive?this._calculateAdaptiveDividing(u,l,c,d,m,v,y,x):this._calculateContinuousDividing(u,l,c,m,v,y,x);var T=t.sprite.pivot,S=T.x,C=T.y,A=t.width*S,w=t.height*C,E=hV._worldMatrix,b=E.elements,M=t.entity.transform.worldMatrix.elements,F=t.flipX?-1:1,R=t.flipY?-1:1;n=b[0]=M[0]*F,r=b[1]=M[1]*F,a=b[2]=M[2]*F,i=b[4]=M[4]*R,o=b[5]=M[5]*R,s=b[6]=M[6]*R,b[8]=M[8],b[9]=M[9],b[10]=M[10];for(var P=b[12]=M[12]-A*b[0]-w*b[4],L=b[13]=M[13]-A*b[1]-w*b[5],D=b[14]=M[14]-A*b[2]-w*b[6],B=m.length-1,I=v.length-1,V=0,O=0,N=0;N<I;N++)for(var U=2*N,z=0;z<B;z++){var k=y.get(2*z),G=x.get(U),H=y.get(2*z+1),W=x.get(U+1);if(!(isNaN(k)||isNaN(k)||isNaN(H)||isNaN(W))){g[O++]=V,g[O++]=V+1,g[O++]=V+2,g[O++]=V+2,g[O++]=V+1,g[O++]=V+3;var X=m.get(z),K=v.get(N),j=m.get(z+1),q=v.get(N+1);p[V]?p[V].set(k,G):p[V]=new lL(k,G);var Y=f[V];Y?Y.set(n*X+i*K+P,r*X+o*K+L,a*X+s*K+D):f[V]=new lS(n*X+i*K+P,r*X+o*K+L,a*X+s*K+D),p[++V]?p[V].set(H,G):p[V]=new lL(H,G),(Y=f[V])?Y.set(n*j+i*K+P,r*j+o*K+L,a*j+s*K+D):f[V]=new lS(n*j+i*K+P,r*j+o*K+L,a*j+s*K+D),p[++V]?p[V].set(k,W):p[V]=new lL(k,W),(Y=f[V])?Y.set(n*X+i*q+P,r*X+o*q+L,a*X+s*q+D):f[V]=new lS(n*X+i*q+P,r*X+o*q+L,a*X+s*q+D),p[++V]?p[V].set(H,W):p[V]=new lL(H,W),(Y=f[V])?Y.set(n*j+i*q+P,r*j+o*q+L,a*j+s*q+D):f[V]=new lS(n*j+i*q+P,r*j+o*q+L,a*j+s*q+D),V++}}t._verticesData.vertexCount=V,g.length=O;var Q=t._bounds,J=Q.min,Z=Q.max;J.set(m.get(0),v.get(0),0),Z.set(m.get(B),v.get(I),0),t._bounds.transform(E)},au.updateUVs=function(e){},au._calculateAdaptiveDividing=function(e,t,n,r,a,i,o,s){var l,c,u,h,d,_,f,p=e.border,g=e._getPositions(),m=g[0],v=m.x,y=m.y,x=g[3],T=x.x,S=x.y,C=e._getUVs(),A=C[0],w=C[1],E=C[2],b=C[3],M=e.width,F=e.height,R=M*p.x,P=M*p.z,L=R+P,D=M-L,B=F*p.w,I=F*p.y,V=B+I,O=F-V;if(L>=t?(h=3,c=0):D>lT.zeroTolerance?(h=4+(_=(_=(t-L)/D)%1>=r?Math.ceil(_):Math.floor(_))-1,c=2):(h=4,c=1),V>=n?(d=3,u=0):O>lT.zeroTolerance?(d=4+(f=(f=(n-V)/O)%1>=r?Math.ceil(f):Math.floor(f))-1,u=2):(d=4,u=1),(h-1)*(d-1)*4>u_.MAX_VERTEX_COUNT){a.add(t*v),a.add(t*T),i.add(n*y),i.add(n*S),o.add(A.x),o.add(b.x),s.add(A.y),s.add(b.y),l8.warn("The number of vertices exceeds the upper limit("+u_.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,a.add(M*v*l),a.add(R*l),a.add(t-M*(1-T)*l),o.add(A.x),o.add(w.x),o.add(E.x),o.add(b.x);break;case 1:a.add(M*v),a.add(R),a.add(t-P),a.add(t-M*(1-T)),o.add(A.x),o.add(w.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(b.x);break;case 2:l=t/(L+_*D),a.add(M*v*l),a.add(R*l),o.add(A.x),o.add(w.x),o.add(w.x);for(var N=0,U=_-1;N<U;N++)a.add(R+(N+1)*D*l),o.add(E.x),o.add(w.x);a.add(t-P*l),a.add(t-M*(1-T)*l),o.add(E.x),o.add(E.x),o.add(b.x)}switch(u){case 0:l=n/V,i.add(F*y*l),i.add(I*l),i.add(n-F*(1-S)*l),s.add(A.y),s.add(w.y),s.add(E.y),s.add(b.y);break;case 1:i.add(F*y),i.add(I),i.add(n-B),i.add(n-F*(1-S)),s.add(A.y),s.add(w.y),s.add(NaN),s.add(NaN),s.add(E.y),s.add(b.y);break;case 2:l=n/(V+f*O),i.add(F*y*l),i.add(I*l),s.add(A.y),s.add(w.y),s.add(w.y);for(var z=0,k=f-1;z<k;z++)i.add(I+(z+1)*O*l),s.add(E.y),s.add(w.y);i.add(n-B*l),i.add(n-F*(1-S)*l),s.add(E.y),s.add(E.y),s.add(b.y)}},au._calculateContinuousDividing=function(e,t,n,r,a,i,o){var s,l,c,u,h,d,_=e.border,f=e._getPositions(),p=f[0],g=p.x,m=p.y,v=f[3],y=v.x,x=v.y,T=e._getUVs(),S=T[0],C=T[1],A=T[2],w=T[3],E=e.width,b=e.height,M=E*_.x,F=E*_.z,R=M+F,P=E-R,L=b*_.w,D=b*_.y,B=L+D,I=b-B;if(R>=t?(c=3,s=0):P>lT.zeroTolerance?(c=4+(0|(h=(t-R)/P)),s=2):(c=4,s=1),B>=n?(u=3,l=0):I>lT.zeroTolerance?(u=4+(0|(d=(n-B)/I)),l=2):(u=4,l=1),(c-1)*(u-1)*4>u_.MAX_VERTEX_COUNT){r.add(t*g),r.add(t*y),a.add(n*m),a.add(n*x),i.add(S.x),i.add(w.x),o.add(S.y),o.add(w.y),l8.warn("The number of vertices exceeds the upper limit("+u_.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var V=t/R;r.add(E*g*V),r.add(M*V),r.add(t-E*(1-y)*V),i.add(S.x),i.add(C.x),i.add(A.x),i.add(w.x);break;case 1:r.add(E*g),r.add(M),r.add(t-F),r.add(t-E*(1-y)),i.add(S.x),i.add(C.x),i.add(NaN),i.add(NaN),i.add(A.x),i.add(w.x);break;case 2:r.add(E*g),r.add(M),i.add(S.x),i.add(C.x),i.add(C.x);for(var O=0|h,N=0;N<O;N++)r.add(M+(N+1)*P),i.add(A.x),i.add(C.x);r.add(t-F),r.add(t-E*(1-y)),i.add((A.x-C.x)*(h-O)+C.x),i.add(A.x),i.add(w.x)}switch(l){case 0:var U=n/B;a.add(b*m*U),a.add(D*U),a.add(n-b*(1-x)*U),o.add(S.y),o.add(C.y),o.add(A.y),o.add(w.y);break;case 1:a.add(b*m),a.add(D),a.add(n-L),a.add(n-b*(1-x)),o.add(S.y),o.add(C.y),o.add(NaN),o.add(NaN),o.add(A.y),o.add(w.y);break;case 2:a.add(b*m),a.add(D),o.add(S.y),o.add(C.y),o.add(C.y);for(var z=0|d,k=0;k<z;k++)a.add(D+(k+1)*I),o.add(A.y),o.add(C.y);a.add(n-L),a.add(n-b*(1-x)),o.add((A.y-C.y)*(d-z)+C.y),o.add(A.y),o.add(w.y)}},(sZ=au)._worldMatrix=new lR,sZ._posRow=new cd,sZ._posColumn=new cd,sZ._uvRow=new cd,sZ._uvColumn=new cd,sZ);hV=lW([cj()],hV),(ah=s$||(s$={}))[ah.Compressed=0]="Compressed",ah[ah.WithoutTiled=1]="WithoutTiled",ah[ah.WithTiled=2]="WithTiled";var hO=(ad=e.Renderer,lk(a_=function(t){var n;return(n=ad.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new lB(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._maskLayer=e.SpriteMaskLayer.Layer0,n._maskInteraction=e.SpriteMaskInteraction.None,n._verticesData=new cY(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(lO(n)),n},ad),(af=a_.prototype)._cloneTo=function(e,t,n){ad.prototype._cloneTo.call(this,e,t,n),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},af._updateShaderData=function(e){this._updateTransformShaderData(e,lR._identity)},af._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},af._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&sV.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~sV.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);var t,n=this.getMaterial(),r=this.sprite.texture,a=this._engine._spriteRenderDataPool.getFromPool();a.set(this,n,this._verticesData,r),e.camera._renderPipeline.pushRenderData(e,a)}},af._onDestroy=function(){ad.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addReferCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._verticesData=null},af._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},af._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,n=this._maskInteraction;if(n===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 r=n===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=r,t.compareFunctionBack=r}},af._onSpriteChange=function(t){switch(t){case sN.texture:this.shaderData.setTexture(a_._textureProperty,this.sprite.texture);break;case sN.size:var n=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=sV.WorldVolume:n===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sV.WorldVolume);break;case sN.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case sN.region:case sN.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sN.atlasRegion:this._dirtyUpdateFlag|=2;break;case sN.pivot:this._dirtyUpdateFlag|=sV.WorldVolume}},lU(a_,[{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=cq;break;case e.SpriteDrawMode.Sliced:this._assembler=hI;break;case e.SpriteDrawMode.Tiled:this._assembler=hV}this._assembler.resetData(this),this._dirtyUpdateFlag|=3}}},{key:"tileMode",get:function(){return this._tileMode},set:function(t){this._tileMode!==t&&(this._tileMode=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"tiledAdaptiveThreshold",get:function(){return this._tiledAdaptiveThreshold},set:function(t){t!==this._tiledAdaptiveThreshold&&(t=lT.clamp(t,0,1),this._tiledAdaptiveThreshold=t,this.drawMode===e.SpriteDrawMode.Tiled&&(this._dirtyUpdateFlag|=3))}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addReferCount(1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(a_._textureProperty,e.texture)):this.shaderData.setTexture(a_._textureProperty,null),this._sprite=e)}},{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"width",get:function(){return void 0!==this._customWidth?this._customWidth:(4&this._dirtyUpdateFlag&&this._calDefaultSize(),this._automaticWidth)},set:function(e){this._customWidth!==e&&(this._customWidth=e,this._dirtyUpdateFlag|=sV.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|=sV.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sV.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sV.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,this._updateStencilState())}}]),a_);hO._textureProperty=cs.getByName("renderer_SpriteTexture"),lW([lK],hO.prototype,"_verticesData",void 0),lW([lK],hO.prototype,"_drawMode",void 0),lW([lj],hO.prototype,"_assembler",void 0),lW([lj],hO.prototype,"_tileMode",void 0),lW([lj],hO.prototype,"_tiledAdaptiveThreshold",void 0),lW([lY],hO.prototype,"_color",void 0),lW([lK],hO.prototype,"_sprite",void 0),lW([lK],hO.prototype,"_automaticWidth",void 0),lW([lK],hO.prototype,"_automaticHeight",void 0),lW([lj],hO.prototype,"_customWidth",void 0),lW([lj],hO.prototype,"_customHeight",void 0),lW([lj],hO.prototype,"_flipX",void 0),lW([lj],hO.prototype,"_flipY",void 0),lW([lj],hO.prototype,"_maskLayer",void 0),lW([lj],hO.prototype,"_maskInteraction",void 0),lW([lK],hO.prototype,"_onSpriteChange",null),(ap=s0||(s0={}))[ap.UV=2]="UV",ap[ap.RenderData=3]="RenderData",ap[ap.AutomaticSize=4]="AutomaticSize",ap[ap.All=7]="All";var hN=function e(){this.localPositions=new lD;var t=[new lS,new lS,new lS,new lS];this.renderData=new cY(4,t,null,e.triangles,null)};hN.triangles=[0,2,1,2,0,3];var hU=((am=(ag=function(e,t){this._elements=[],this._type=e;for(var n=this._elements,r=0;r<t;++r)n[r]=new e}).prototype).get=function(){return this._elements.length>0?this._elements.pop():new this._type},am.put=function(e){this._elements.push(e)},ag),hz=(av=e.Renderer,lk(ay=function(t){var n;return(n=av.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new lB(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new lA,n._font=null,n._fontSize=24,n._fontStyle=e.FontStyle.None,n._lineSpacing=0,n._horizontalAlignment=e.TextHorizontalAlignment.Center,n._verticalAlignment=e.TextVerticalAlignment.Center,n._enableWrapping=!1,n._overflowMode=e.OverflowMode.Overflow,n._maskInteraction=e.SpriteMaskInteraction.None,n._maskLayer=e.SpriteMaskLayer.Layer0,n._init(),n},av),(ax=ay.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},ax._onDestroy=function(){av.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)ay._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},ax._cloneTo=function(e,t,n){av.prototype._cloneTo.call(this,e,t,n),e.font=this._font,e._subFont=this._subFont},ax._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ax._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ax._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ax._updateShaderData=function(e){this._updateTransformShaderData(e,lR._identity)},ax._updateBounds=function(e){lA.transform(this._localBounds,this._entity.transform.worldMatrix,e)},ax._render=function(t){if(""!==this._text&&(!this.enableWrapping||!(this.width<=0))&&(this.overflowMode!==e.OverflowMode.Truncate||!(this.height<=0))){this._isContainDirtyFlag(16)&&(this._updateStencilState(),this._setDirtyFlagFalse(16)),this._isContainDirtyFlag(1)&&(this._resetSubFont(),this._setDirtyFlagFalse(1)),this._isContainDirtyFlag(2)&&(this._updateLocalData(),this._setDirtyFlagFalse(2)),this._isContainDirtyFlag(4)&&(this._updatePosition(),this._setDirtyFlagFalse(4));var n=this._engine._spriteRenderDataPool,r=this._engine._textRenderDataPool.getFromPool(),a=r.charsData,i=this.getMaterial(),o=this._charRenderDatas,s=o.length;r.component=this,r.material=i,a.length=s;for(var l=0;l<s;++l){var c=o[l],u=n.getFromPool();u.set(this,i,c.renderData,c.texture,l),a[l]=u}t.camera._renderPipeline.pushRenderData(t,r)}},ax._updateStencilState=function(){var t=this.getInstanceMaterial().renderState.stencilState,n=this._maskInteraction;if(n===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 r=n===e.SpriteMaskInteraction.VisibleInsideMask?e.CompareFunction.LessEqual:e.CompareFunction.Greater;t.compareFunctionFront=r,t.compareFunctionBack=r}},ax._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=cr.getNativeFontString(e.name,this.fontSize,this.fontStyle)},ax._updatePosition=function(){for(var e=this.entity.transform.worldMatrix.elements,t=this._charRenderDatas,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],h=ay._tempVec31.set(i,o,s),d=ay._tempVec30.set(n,r,a),_=0,f=t.length;_<f;++_){var p=t[_],g=p.localPositions,m=p.renderData.positions,v=g.x,y=g.y,x=m[0];x.x=v*n+y*i+l,x.y=v*r+y*o+c,x.z=v*a+y*s+u;var T=m[1];lS.scale(d,g.z-v,T),lS.add(x,T,T);var S=m[2];lS.scale(h,g.w-y,S),lS.add(x,S,m[3]),lS.add(T,S,S)}},ax._updateLocalData=function(){var t=this.color,n=this._charRenderDatas,r=this._subFont,a=this._localBounds,i=a.min,o=a.max,s=this.enableWrapping?cr.measureTextWithWrap(this):cr.measureTextWithoutWrap(this),l=s.height,c=s.lines,u=s.lineWidths,h=s.lineHeight,d=s.lineMaxSizes,_=ay._charRenderDataPool,f=c.length,p=0;if(f>0){var g=u4._pixelsPerUnit,m=this.horizontalAlignment,v=1/g,y=.5*(this.width*g),x=this.height*g,T=.5*h,S=0,C=.5*h-d[0].ascent,A=.5*h-d[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:S=.5*x-T+C;break;case e.TextVerticalAlignment.Center:S=.5*l-T-(A-C)*.5;break;case e.TextVerticalAlignment.Bottom:S=l-.5*x-T-A}for(var w=-1,E=Number.MAX_SAFE_INTEGER,b=Number.MAX_SAFE_INTEGER,M=Number.MIN_SAFE_INTEGER,F=Number.MIN_SAFE_INTEGER,R=0;R<f;++R){var P=u[R];if(P>0){var L=c[R],D=0,B=-1;switch(w<0&&(w=R),m){case e.TextHorizontalAlignment.Left:D=-y;break;case e.TextHorizontalAlignment.Center:D=-(.5*P);break;case e.TextHorizontalAlignment.Right:D=y-P}for(var I=0,V=L.length;I<V;++I){var O=L[I],N=r._getCharInfo(O);if(N.h>0){B<0&&(B=I);var U,z,k=(U=n)[z=p++]||(U[z]=_.get()),G=k.renderData,H=k.localPositions;k.texture=r._getTextureByIndex(N.index),G.color=t,G.uvs=N.uvs;var W=N.w,X=N.ascent,K=N.descent,j=D*v,q=(D+W)*v,Y=(S+X)*v,Q=(S-K+1)*v;H.set(j,Y,q,Q),R===w&&(F=Math.max(F,Y)),b=Math.min(b,Q),I===B&&(E=Math.min(E,j)),M=Math.max(M,q)}D+=N.xAdvance}}S-=h}w<0?(i.set(0,0,0),o.set(0,0,0)):(i.set(E,b,0),o.set(M,F,0))}else i.set(0,0,0),o.set(0,0,0);var J=n.length;if(J>p){for(var Z=p;Z<J;++Z)_.put(n[Z]);n.length=p}r._getLastIndex()>0&&n.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},ax._onTransformChanged=function(e){av.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},lU(ay,[{key:"color",get:function(){return this._color},set:function(e){this._color!==e&&this._color.copyFrom(e)}},{key:"text",get:function(){return this._text},set:function(e){e=e||"",this._text!==e&&(this._text=e,this._setDirtyFlagTrue(14))}},{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._width=e,this._setDirtyFlagTrue(14))}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._height=e,this._setDirtyFlagTrue(14))}},{key:"font",get:function(){return this._font},set:function(e){var t=this._font;t!==e&&(t&&t._addReferCount(-1),e&&e._addReferCount(1),this._font=e,this._setDirtyFlagTrue(15))}},{key:"fontSize",get:function(){return this._fontSize},set:function(e){this._fontSize!==e&&(this._fontSize=e,this._setDirtyFlagTrue(15))}},{key:"fontStyle",get:function(){return this._fontStyle},set:function(e){this.fontStyle!==e&&(this._fontStyle=e,this._setDirtyFlagTrue(15))}},{key:"lineSpacing",get:function(){return this._lineSpacing},set:function(e){this._lineSpacing!==e&&(this._lineSpacing=e,this._setDirtyFlagTrue(14))}},{key:"horizontalAlignment",get:function(){return this._horizontalAlignment},set:function(e){this._horizontalAlignment!==e&&(this._horizontalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"verticalAlignment",get:function(){return this._verticalAlignment},set:function(e){this._verticalAlignment!==e&&(this._verticalAlignment=e,this._setDirtyFlagTrue(14))}},{key:"enableWrapping",get:function(){return this._enableWrapping},set:function(e){this._enableWrapping!==e&&(this._enableWrapping=e,this._setDirtyFlagTrue(14))}},{key:"overflowMode",get:function(){return this._overflowMode},set:function(e){this._overflowMode!==e&&(this._overflowMode=e,this._setDirtyFlagTrue(14))}},{key:"maskInteraction",get:function(){return this._maskInteraction},set:function(e){this._maskInteraction!==e&&(this._maskInteraction=e,this._setDirtyFlagTrue(16))}},{key:"maskLayer",get:function(){return this._maskLayer},set:function(e){this._maskLayer=e}},{key:"bounds",get:function(){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}}]),ay);hz._charRenderDataPool=new hU(hN,50),hz._tempVec30=new lS,hz._tempVec31=new lS,lW([lj],hz.prototype,"_subFont",void 0),lW([lK],hz.prototype,"_charRenderDatas",void 0),lW([lK],hz.prototype,"_dirtyFlag",void 0),lW([lY],hz.prototype,"_color",void 0),lW([lj],hz.prototype,"_text",void 0),lW([lj],hz.prototype,"_width",void 0),lW([lj],hz.prototype,"_height",void 0),lW([lK],hz.prototype,"_localBounds",void 0),lW([lj],hz.prototype,"_font",void 0),lW([lj],hz.prototype,"_fontSize",void 0),lW([lj],hz.prototype,"_fontStyle",void 0),lW([lj],hz.prototype,"_lineSpacing",void 0),lW([lj],hz.prototype,"_horizontalAlignment",void 0),lW([lj],hz.prototype,"_verticalAlignment",void 0),lW([lj],hz.prototype,"_enableWrapping",void 0),lW([lj],hz.prototype,"_overflowMode",void 0),lW([lj],hz.prototype,"_maskInteraction",void 0),lW([lj],hz.prototype,"_maskLayer",void 0),(aT=s1||(s1={}))[aT.SubFont=1]="SubFont",aT[aT.LocalPositionBounds=2]="LocalPositionBounds",aT[aT.WorldPosition=4]="WorldPosition",aT[aT.WorldBounds=8]="WorldBounds",aT[aT.MaskInteraction=16]="MaskInteraction",aT[aT.Position=14]="Position",aT[aT.Font=15]="Font";var hk=((aC=(aS=function(){}).prototype).initialize=function(e){for(var t=e.component,n=e.property.split("."),r=n.length-1,a=0;a<r;a++)t=t[n[a]];this._mounted=t,this._propertyName=n[r]},aC.getTargetValue=function(){return this._mounted[this._propertyName]},aC.setTargetValue=function(e){this._mounted[this._propertyName]=e},aS),hG=function(){function e(t,n,r,a){this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.updateMark=0,this.target=t,this.type=n,this.property=r,this.component=t.getComponent(n),this.cureType=a;var i=e.getAssemblerType(n,r);this._assembler=new i,this._assembler.initialize(this),a._isReferenceType&&(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){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){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._isReferenceType?(this.cureType._copyValue(this.baseEvaluateData.value,e),e):this.baseEvaluateData.value},t.saveDefaultValue=function(){this.cureType._isReferenceType?this.cureType._copyValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue()},t.saveFixedPoseValue=function(){this.cureType._isReferenceType?this.cureType._copyValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t.applyValue=function(e,t,n){var r=this.cureType;if(n){if(r._isReferenceType)r._additiveValue(e,t,this.referenceTargetValue);else{var a=this._assembler,i=a.getTargetValue(),o=r._additiveValue(e,t,i);a.setTargetValue(o)}}else if(1===t)r._isReferenceType?r._copyValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(r._isReferenceType){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._isReferenceType?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:hk},e}();hG._assemblerMap=new Map;var hH=((aw=(aA=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aw.getTargetValue=function(){return this._transform.position},aw.setTargetValue=function(e){this._transform.position=e},aA);hG.registerAssembler(cy,"position",hH);var hW=((ab=(aE=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},ab.getTargetValue=function(){return this._transform.rotationQuaternion},ab.setTargetValue=function(e){this._transform.rotationQuaternion=e},aE);hG.registerAssembler(cy,"rotationQuaternion",hW);var hX=((aF=(aM=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},aF.getTargetValue=function(){return this._transform.scale},aF.setTargetValue=function(e){this._transform.scale=e},aM);hG.registerAssembler(cy,"scale",hX);var hK=((aP=(aR=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(ud)},aP.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},aP.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},aR);hG.registerAssembler(ud,"blendShapeWeights",hK);var hj=((aD=(aL=function(){this.crossCurveMark=0}).prototype).initFinalValue=function(){var e=this.curveOwner,t=e.cureType,n=e.defaultValue;t._isReferenceType?t._copyValue(n,this.finalValue):this.finalValue=n},aD.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},aL),hq=((aI=(aB=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new hG(e,this.type,this.property,t);return t._initializeOwner(n),n.saveDefaultValue(),n},aI._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new hj;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},aI._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},aB),hY=function(){},hQ=(lk(aV=function(e){var t;return(t=lJ.call(this,null)||this).name=e,t._curveBindings=[],t._length=0,t._events=[],t},lJ),(aO=aV.prototype).addEvent=function(e,t,n){if("string"==typeof e){var r=new hY;r.functionName=e,r.time=t,r.parameter=n,this._events.push(r)}else this._events.push(e);this._events.sort(function(e,t){return e.time-t.time})},aO.clearEvents=function(){this._events.length=0},aO.addCurveBinding=function(e,t,n,r){var a=new hq;a.relativePath=e,a.type=t,a.property=n,a.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(a)},aO.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},aO._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._getTempCurveOwner(i),s=o.evaluateValue(a.curve,t,!1);o.applyValue(s,1,!1)}}},lU(aV,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),aV);e.InterpolationType=void 0,(aN=e.InterpolationType||(e.InterpolationType={}))[aN.Linear=0]="Linear",aN[aN.CubicSpine=1]="CubicSpine",aN[aN.Step=2]="Step",aN[aN.Hermite=3]="Hermite";var hJ=((az=(aU=function(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var t=this.constructor;this._interpolation=t._isInterpolationType?e.InterpolationType.Linear:e.InterpolationType.Step,this._type=t}).prototype).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)}},az.evaluate=function(e){return this._evaluate(e,this._evaluateData)},az.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>length&&(n=a.time)}this._length=n},az._evaluate=function(t,n){var r,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=n.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(n.curKeyframeIndex=s,-1===s)r=this._type._copyValue(i[0].value,n.value);else if(l===a)r=this._type._copyValue(i[s].value,n.value);else{var c=i[s],u=i[l],h=c.time,d=u.time-h,_=(t-h)/d;switch(o){case e.InterpolationType.Linear:r=this._type._lerpValue(c.value,u.value,_,n.value);break;case e.InterpolationType.Step:r=this._type._copyValue(c.value,n.value);break;case e.InterpolationType.CubicSpine:case e.InterpolationType.Hermite:r=this._type._hermiteInterpolationValue(c,u,_,d,n.value)}}return n.value=r,r},az._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},lU(aU,[{key:"interpolation",get:function(){return this._interpolation},set:function(t){this._type._isInterpolationType||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}}]),aU);e.AnimationArrayCurve=(lk(ak=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=[],e},hJ),ak._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},ak._initializeLayerOwner=function(e){e.finalValue=[]},ak._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},ak._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},ak._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},ak._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},ak._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},ak._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,g=s.length;p<g;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=h*s[p]+d*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},(s2=ak)._isReferenceType=!0,s2._isInterpolationType=!0,s2),e.AnimationArrayCurve=lW([cj()],e.AnimationArrayCurve),e.AnimationBoolCurve=(lk(aG=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=!1,e},hJ),aG._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},aG._initializeLayerOwner=function(e){e.finalValue=!1},aG._lerpValue=function(e,t){return t},aG._subtractValue=function(e,t,n){return e},aG._getZeroValue=function(){return!1},aG._additiveValue=function(e,t,n){return e},aG._copyValue=function(e){return e},aG._hermiteInterpolationValue=function(e){return e.value},(s3=aG)._isReferenceType=!1,s3._isInterpolationType=!1,s3),e.AnimationBoolCurve=lW([cj()],e.AnimationBoolCurve),e.AnimationColorCurve=(lk(aH=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=new lB,e},hJ),aH._initializeOwner=function(e){e.defaultValue=new lB,e.fixedPoseValue=new lB,e.baseEvaluateData.value=new lB,e.crossEvaluateData.value=new lB},aH._initializeLayerOwner=function(e){e.finalValue=new lB},aH._lerpValue=function(e,t,n,r){return lB.lerp(e,t,n,r),r},aH._subtractValue=function(e,t,n){return lB.subtract(e,t,n),n},aH._getZeroValue=function(e){return e.set(0,0,0,0),e},aH._additiveValue=function(e,t,n){return lB.scale(e,t,e),lB.add(n,e,n),n},aH._copyValue=function(e,t){return t.copyFrom(e),t},aH._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?a.r=h*i.r+d*p*r+_*g*r+f*s.r:a.r=i.r,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?a.g=h*i.g+d*p*r+_*g*r+f*s.g:a.g=i.g,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?a.b=h*i.b+d*p*r+_*g*r+f*s.b:a.b=i.b,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?a.a=h*i.a+d*p*r+_*g*r+f*s.a:a.a=i.a,a},(s4=aH)._isReferenceType=!0,s4._isInterpolationType=!0,s4),e.AnimationColorCurve=lW([cj()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(lk(aW=function(){return hJ.apply(this,arguments)},hJ),aW.prototype.addKey=function(e){hJ.prototype.addKey.call(this,e);var t=this._evaluateData;if(!t.value||t.value.length!==e.value.length){var n=e.value.length;t.value=new Float32Array(n)}},aW._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)},aW._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},aW._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},aW._subtractValue=function(e,t,n){for(var r=0,a=e.length;r<a;r++)n[r]=e[r]-t[r];return n},aW._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},aW._additiveValue=function(e,t,n){for(var r=0,a=n.length;r<a;++r)n[r]+=e[r]*t;return n},aW._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},aW._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=0,g=s.length;p<g;++p)Number.isFinite(i[p])&&Number.isFinite(o[p])?a[p]=h*s[p]+d*i[p]*r+_*o[p]*r+f*l[p]:a[p]=e.value[p];return a},(s5=aW)._isReferenceType=!0,s5._isInterpolationType=!0,s5),e.AnimationFloatArrayCurve=lW([cj()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(lk(aX=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=0,e},hJ),aX._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},aX._initializeLayerOwner=function(e){e.finalValue=0},aX._lerpValue=function(e,t,n){return e+(t-e)*n},aX._additiveValue=function(e,t,n){return n+e*t},aX._subtractValue=function(e,t){return e-t},aX._getZeroValue=function(){return 0},aX._copyValue=function(e){return e},aX._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},(s8=aX)._isReferenceType=!1,s8._isInterpolationType=!0,s8),e.AnimationFloatCurve=lW([cj()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(lk(aK=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=new lF,e},hJ),aK._initializeOwner=function(e){e.defaultValue=new lF,e.fixedPoseValue=new lF,e.baseEvaluateData.value=new lF,e.crossEvaluateData.value=new lF},aK._initializeLayerOwner=function(e){e.finalValue=new lF},aK._lerpValue=function(e,t,n,r){return lF.slerp(e,t,n,r),r},aK._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},aK._subtractValue=function(t,n,r){var a=e.AnimationQuaternionCurve._tempConjugateQuat;return lF.conjugate(n,a),lF.multiply(a,t,r),r},aK._getZeroValue=function(e){return e.set(0,0,0,1),e},aK._copyValue=function(e,t){return t.copyFrom(e),t},aK._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?a.x=h*i.x+d*p*r+_*g*r+f*s.x:a.x=i.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?a.y=h*i.y+d*p*r+_*g*r+f*s.y:a.y=i.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?a.z=h*i.z+d*p*r+_*g*r+f*s.z:a.z=i.z,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?a.w=h*i.w+d*p*r+_*g*r+f*s.w:a.w=i.w,a},(s6=aK)._isInterpolationType=!0,s6._isReferenceType=!0,s6._tempConjugateQuat=new lF,s6),e.AnimationQuaternionCurve=lW([cj()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(lk(aj=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=new lL,e},hJ),aj._initializeOwner=function(e){e.defaultValue=new lL,e.fixedPoseValue=new lL,e.baseEvaluateData.value=new lL,e.crossEvaluateData.value=new lL},aj._initializeLayerOwner=function(e){e.finalValue=new lL},aj._lerpValue=function(e,t,n,r){return lL.lerp(e,t,n,r),r},aj._additiveValue=function(e,t,n){return lL.scale(e,t,e),lL.add(n,e,n),n},aj._subtractValue=function(e,t,n){return lL.subtract(e,t,n),n},aj._getZeroValue=function(e){return e.set(0,0),e},aj._copyValue=function(e,t){return t.copyFrom(e),t},aj._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?a.x=h*i.x+d*p*r+_*g*r+f*s.x:a.x=i.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?a.y=h*i.y+d*p*r+_*g*r+f*s.y:a.y=i.y,a},(s7=aj)._isReferenceType=!0,s7._isInterpolationType=!0,s7),e.AnimationVector2Curve=lW([cj()],e.AnimationVector2Curve),e.AnimationVector3Curve=(lk(aq=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=new lS,e},hJ),aq._initializeOwner=function(e){e.defaultValue=new lS,e.fixedPoseValue=new lS,e.baseEvaluateData.value=new lS,e.crossEvaluateData.value=new lS},aq._initializeLayerOwner=function(e){e.finalValue=new lS},aq._lerpValue=function(e,t,n,r){return lS.lerp(e,t,n,r),r},aq._relativeBaseValue=function(e,t){return lS.subtract(t,e,t),t},aq._additiveValue=function(e,t,n){return lS.scale(e,t,e),lS.add(n,e,n),n},aq._subtractValue=function(e,t,n){return lS.subtract(e,t,n),n},aq._getZeroValue=function(e){return e.set(0,0,0),e},aq._copyValue=function(e,t){return t.copyFrom(e),t},aq._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?a.x=h*i.x+d*p*r+_*g*r+f*s.x:a.x=i.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?a.y=h*i.y+d*p*r+_*g*r+f*s.y:a.y=i.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?a.z=h*i.z+d*p*r+_*g*r+f*s.z:a.z=i.z,a},(s9=aq)._isReferenceType=!0,s9._isInterpolationType=!0,s9),e.AnimationVector3Curve=lW([cj()],e.AnimationVector3Curve),e.AnimationVector4Curve=(lk(aY=function(){var e;return(e=hJ.call(this)||this)._evaluateData.value=new lD,e},hJ),aY._initializeOwner=function(e){e.defaultValue=new lD,e.fixedPoseValue=new lD,e.baseEvaluateData.value=new lD,e.crossEvaluateData.value=new lD},aY._initializeLayerOwner=function(e){e.finalValue=new lD},aY._lerpValue=function(e,t,n,r){return lD.lerp(e,t,n,r),r},aY._additiveValue=function(e,t,n){return lD.scale(e,t,e),lD.add(n,e,n),n},aY._subtractValue=function(e,t,n){return lD.subtract(e,t,n),n},aY._getZeroValue=function(e){return e.set(0,0,0,0),e},aY._copyValue=function(e,t){return t.copyFrom(e),t},aY._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,h=2*u-3*c+1,d=u-2*c+n,_=u-c,f=-2*u+3*c,p=o.x,g=l.x;return Number.isFinite(p)&&Number.isFinite(g)?a.x=h*i.x+d*p*r+_*g*r+f*s.x:a.x=i.x,p=o.y,g=l.y,Number.isFinite(p)&&Number.isFinite(g)?a.y=h*i.y+d*p*r+_*g*r+f*s.y:a.y=i.y,p=o.z,g=l.z,Number.isFinite(p)&&Number.isFinite(g)?a.z=h*i.z+d*p*r+_*g*r+f*s.z:a.z=i.z,p=o.w,g=l.w,Number.isFinite(p)&&Number.isFinite(g)?a.w=h*i.w+d*p*r+_*g*r+f*s.w:a.w=i.w,a},(le=aY)._isReferenceType=!0,le._isInterpolationType=!0,le),e.AnimationVector4Curve=lW([cj()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(aQ=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[aQ.None=0]="None",aQ[aQ.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(aJ=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[aJ.Override=0]="Override",aJ[aJ.Additive=1]="Additive",(aZ=lt||(lt={}))[aZ.UnStarted=0]="UnStarted",aZ[aZ.Playing=1]="Playing",aZ[aZ.Finished=2]="Finished",(a$=ln||(ln={}))[a$.Standby=0]="Standby",a$[a$.Playing=1]="Playing",a$[a$.CrossFading=2]="CrossFading",a$[a$.FixedCrossFading=3]="FixedCrossFading",a$[a$.Finished=4]="Finished";var hZ=((a0=function(){this.handlers=[]}).prototype.dispose=function(){},a0),h$=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(a1=e.WrapMode||(e.WrapMode={}))[a1.Once=0]="Once",a1[a1.Loop=1]="Loop";var h0=((a3=(a2=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=lt.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},a3.update=function(t){var n=this.state,r=this.frameTime,a=n._getDuration();this.playState=lt.Playing,n.wrapMode===e.WrapMode.Loop?r=a?r%a:0:Math.abs(r)>a&&(r=r<0?-a:a,this.playState=lt.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=a),this.clipTime=r+n.clipStartTime*n.clip.length)},a2),h1=((a4=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new h0,this.destPlayData=new h0,this.layerState=ln.Standby,this.crossCurveMark=0,this.manuallyTransition=new h$,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},a4),h2=function(){this.curveLayerOwner=[],this.eventHandlers=[]},h3=(lk(a5=function(t){var n;return(n=cc.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new cS(hZ),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},cc),(a8=a5.prototype).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,o=a.layerIndex;if(i){if(!i.clip){l8.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,i,s,o);this._preparePlay(s,i),s.layerState=ln.Playing,s.srcPlayData.reset(i,l,i._getDuration()*n)}},a8.crossFade=function(e,t,n,r){void 0===n&&(n=-1),void 0===r&&(r=0),(null==(a=this._controllerUpdateFlag)?void 0:a.flag)&&this._reset();var a,i=this._getAnimatorStateInfo(e,n),o=i.state,s=i.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=r,l.destinationState=o,this._crossFadeByTransition(l,n)},a8.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){r=!1;for(var n,r,a=this._controlledRenderers,i=0,o=a.length;i<o;i++)if(!a[i].isCulled){r=!0;break}}else r=!0;var s=this._animatorController;if(s){if(null==(n=this._controllerUpdateFlag)?void 0:n.flag){this._checkAutoPlay();return}t*=this.speed,this._updateMark++;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==ln.Standby&&this._updateLayer(l,0===l,t,r)}},a8.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},a8.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},a8._onEnable=function(){this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},a8._onEnableInScene=function(){this.scene._componentsManager.addOnUpdateAnimations(this)},a8._onDisableInScene=function(){this.scene._componentsManager.removeOnUpdateAnimations(this)},a8._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={},this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},a8._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},a8._getAnimatorStateData=function(e,t,n,r){var a=n.animatorStateDataMap,i=a[e];return i||(i=new h2,a[e]=i,this._saveAnimatorStateData(t,i,n,r),this._saveAnimatorEventHandlers(t,i)),i},a8._saveAnimatorStateData=function(e,t,n,r){for(var a=this.entity,i=this._curveOwnerPool,o=t.curveLayerOwner,s=e.clip._curveBindings,l=n.curveOwnerPool,c=s.length-1;c>=0;c--){var u=s[c],h=""===u.relativePath?a:a.findByPath(u.relativePath);if(h){var d,_,f,p,g=u.property,m=h.instanceId,v=(_=(d=i)[m]||(d[m]=Object.create(null)))[g]||(_[g]=u._createCurveOwner(h)),y=(p=(f=l)[m]||(f[m]=Object.create(null)))[g]||(p[g]=u._createCurveLayerOwner(v));o[c]=y}else o[c]=null,l8.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},a8._saveAnimatorEventHandlers=function(e,t){var n=this._animationEventHandlerPool,r=[];this._entity.getComponents(hi,r);var a=r.length,i=t.eventHandlers,o=e.clip.events;i.length=0;for(var s=0,l=o.length;s<l;s++){var c=o[s],u=n.getFromPool(),h=c.functionName,d=u.handlers;u.event=c,d.length=0;for(var _=a-1;_>=0;_--){var f=r[_][h];f&&d.push(f)}i.push(u)}},a8._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},a8._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},a8._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},a8._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},a8._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)},a8._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))}},a8._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)}}}},a8._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new h1),t},a8._updateLayer=function(t,n,r,a){var i=this._animatorController.layers[t],o=i.blendingMode,s=i.weight,l=this._animatorLayersData[t],c=l.srcPlayData,u=l.destPlayData,h=l.crossFadeTransition,d=o===e.AnimatorLayerBlendingMode.Additive;switch(n&&(s=1),l.layerState!==ln.FixedCrossFading&&this._checkTransition(c,h,t),l.layerState){case ln.Playing:this._updatePlayingState(c,l,t,s,r,d,a);break;case ln.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,r,d,a);break;case ln.CrossFading:this._updateCrossFade(c,u,l,t,s,r,d,a);break;case ln.Finished:this._updateFinishedState(c,s,d,a)}},a8._updatePlayingState=function(e,t,n,r,a,i,o){var s=e.stateData,l=s.curveLayerOwner,c=s.eventHandlers,u=e.state,h=e.playState,d=e.clipTime,_=u.clip._curveBindings;e.update(this.speed<0);var f=e.clipTime,p=e.playState,g=p===lt.Finished;if(o||g)for(var m=_.length-1;m>=0;m--){var v=l[m],y=null==v?void 0:v.curveOwner;if(y){var x=_[m].curve;if(x.keys.length){this._checkRevertOwner(y,i);var T=y.evaluateValue(x,f,i);o&&y.applyValue(T,r,i),g&&v.saveFinalValue()}}}e.frameTime+=u.speed*a,p===lt.Finished&&(t.layerState=ln.Finished),c.length&&this._fireAnimationEvents(e,c,d,f),h===lt.UnStarted&&this._callAnimatorScriptOnEnter(u,n),p===lt.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n)},a8._updateCrossFade=function(e,t,n,r,a,i,o,s){var l=n.crossLayerOwnerCollection,c=e.state.clip._curveBindings,u=e.state,h=e.stateData,d=e.playState,_=h.eventHandlers,f=t.state,p=t.stateData,g=t.playState,m=p.eventHandlers,v=f.clip._curveBindings,y=e.clipTime,x=t.clipTime,T=f._getDuration()*n.crossFadeTransition.duration,S=Math.abs(t.frameTime)/T;(S>=1||0===T)&&(S=1),e.update(this.speed<0),t.update(this.speed<0);var C=e.clipTime,A=e.playState,w=t.clipTime,E=t.playState,b=t.playState===lt.Finished;if(s||b)for(var M=l.length-1;M>=0;M--){var F=l[M],R=null==F?void 0:F.curveOwner;if(R){var P=F.crossSrcCurveIndex,L=F.crossDestCurveIndex;this._checkRevertOwner(R,o);var D=R.evaluateCrossFadeValue(P>=0?c[P].curve:null,L>=0?v[L].curve:null,C,w,S,o);s&&R.applyValue(D,a,o),b&&F.saveFinalValue()}}this._updateCrossFadeData(n,S,i,!1),_.length&&this._fireAnimationEvents(e,_,y,C),m.length&&this._fireAnimationEvents(t,m,x,w),d===lt.UnStarted&&this._callAnimatorScriptOnEnter(u,r),1===S||A===lt.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),g===lt.UnStarted&&this._callAnimatorScriptOnEnter(f,r),E===lt.Finished?this._callAnimatorScriptOnExit(f,r):this._callAnimatorScriptOnUpdate(f,r)},a8._updateCrossFadeFromPose=function(e,t,n,r,a,i,o){var s=t.crossLayerOwnerCollection,l=e.state,c=e.stateData,u=e.playState,h=c.eventHandlers,d=l.clip._curveBindings,_=e.clipTime,f=l._getDuration()*t.crossFadeTransition.duration,p=Math.abs(e.frameTime)/f;(p>=1||0===f)&&(p=1),e.update(this.speed<0);var g=e.playState;this._updateCrossFadeData(t,p,a,!0);var m=e.clipTime,v=g===lt.Finished;if(o||v)for(var y=s.length-1;y>=0;y--){var x=s[y],T=null==x?void 0:x.curveOwner;if(T){var S=x.crossDestCurveIndex;this._checkRevertOwner(T,i);var C=x.curveOwner.crossFadeFromPoseAndApplyValue(S>=0?d[S].curve:null,m,p,i);o&&T.applyValue(C,r,i),v&&x.saveFinalValue()}}h.length&&this._fireAnimationEvents(e,h,_,m),u===lt.UnStarted&&this._callAnimatorScriptOnEnter(l,n),g===lt.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n)},a8._updateFinishedState=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))}},a8._updateCrossFadeData=function(e,t,n,r){var a=e.destPlayData;a.frameTime+=a.state.speed*n,1===t?(a.playState===lt.Finished?e.layerState=ln.Finished:e.layerState=ln.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},a8._preparePlay=function(e,t){if(e.layerState===ln.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()},a8._checkTransition=function(e,t,n){for(var r=e.state,a=e.clipTime,i=r.transitions,o=r._getDuration(),s=0,l=i.length;s<l;++s){var c=i[s];o*c.exitTime<=a&&t!==c&&this._crossFadeByTransition(c,n)}},a8._crossFadeByTransition=function(e,t){var n=e.destinationState.name,r=this._getAnimatorStateInfo(n,t),a=r.state,i=r.layerIndex;if(a){if(!a.clip){l8.warn("The state named "+n+" has no AnimationClip data.");return}var o=this._getAnimatorLayerData(i),s=o.layerState,l=o.destPlayData,c=this._getAnimatorStateData(n,a,o,i),u=a._getDuration()*e.offset;switch(l.reset(a,c,u),s){case ln.Standby:case ln.Finished:o.layerState=ln.FixedCrossFading,this._clearCrossData(o),this._prepareStandbyCrossFading(o);break;case ln.Playing:o.layerState=ln.CrossFading,this._clearCrossData(o),this._prepareCrossFading(o);break;case ln.CrossFading:o.layerState=ln.FixedCrossFading,this._prepareFixedPoseCrossFading(o);break;case ln.FixedCrossFading:this._prepareFixedPoseCrossFading(o)}o.crossFadeTransition=e}},a8._fireAnimationEvents=function(e,t,n,r){var a=e.state,i=a.clip.length;this.speed>=0?r<n?(this._fireSubAnimationEvents(e,t,n,a.clipEndTime*i),e.currentEventIndex=0,this._fireSubAnimationEvents(e,t,a.clipStartTime*i,r)):this._fireSubAnimationEvents(e,t,n,r):r>n?(this._fireBackwardSubAnimationEvents(e,t,n,a.clipStartTime*i),e.currentEventIndex=t.length-1,this._fireBackwardSubAnimationEvents(e,t,a.clipEndTime*i,r)):this._fireBackwardSubAnimationEvents(e,t,n,r)},a8._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 h=u.length-1;h>=0;h--)u[h](c);e.currentEventIndex=Math.min(a+1,i-1)}}},a8._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)}}},a8._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,a=n.length;r<a;r++)n[r].onStateEnter(this,e,t)},a8._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,a=n.length;r<a;r++)n[r].onStateUpdate(this,e,t)},a8._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,a=n.length;r<a;r++)n[r].onStateExit(this,e,t)},a8._checkAutoPlay=function(){for(var e=this._animatorController.layers,t=0,n=e.length;t<n;++t){var r=e[t].stateMachine;(null==r?void 0:r.defaultState)&&this.play(r.defaultState.name,t)}},a8._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},lU(a5,[{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)}}]),a5);lW([lj],h3.prototype,"speed",void 0),lW([lK],h3.prototype,"_controllerUpdateFlag",void 0),lW([lK],h3.prototype,"_updateMark",void 0),lW([lK],h3.prototype,"_animatorLayersData",void 0),lW([lK],h3.prototype,"_curveOwnerPool",void 0),lW([lK],h3.prototype,"_animationEventHandlerPool",void 0),lW([lK],h3.prototype,"_tempAnimatorStateInfo",void 0),lW([lK],h3.prototype,"_controlledRenderers",void 0);var h4=((a7=(a6=function(){this._updateFlagManager=new cv,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},a7.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},a7.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},a7.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},a7._registerChangeFlag=function(){return this._updateFlagManager.createFlag(cm)},lU(a6,[{key:"layers",get:function(){return this._layers}}]),a6),h5=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},h8=((ie=(a9=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},ie.onStateUpdate=function(e,t,n){},ie.onStateExit=function(e,t,n){},ie.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},a9),h6=((ir=(it=function(t){this.name=t,this.speed=1,this.wrapMode=e.WrapMode.Loop,this._onStateEnterScripts=[],this._onStateUpdateScripts=[],this._onStateExitScripts=[],this._clipStartTime=0,this._clipEndTime=1,this._transitions=[]}).prototype).addTransition=function(e){this._transitions.push(e)},ir.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},ir.addStateMachineScript=function(e){var t=new e;t._state=this;var n=h8.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},ir.clearTransitions=function(){this._transitions.length=0},ir._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},ir._removeStateMachineScript=function(e){var t=h8.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)}},lU(it,[{key:"transitions",get:function(){return this._transitions}},{key:"clip",get:function(){return this._clip},set:function(e){this._clip=e,this._clipEndTime=Math.min(this._clipEndTime,1)}},{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)}}]),it),h7=((ii=(ia=function(){this.states=[],this._statesMap={}}).prototype).addState=function(e){var t=this.findStateByName(e);return t?console.warn("The state named "+e+" has existed."):(t=new h6(e),this.states.push(t),this._statesMap[e]=t),t},ii.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},ii.findStateByName=function(e){return this._statesMap[e]},ii.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},ia);e.AnimatorConditionMode=void 0,(io=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[io.If=0]="If",io[io.IfNot=1]="IfNot",io[io.Greater=2]="Greater",io[io.Less=3]="Less",io[io.Equals=4]="Equals",io[io.NotEquals=5]="NotEquals";var h9=function(){},de=function(t){function n(r){var a;return(a=t.call(this,r,cH.find("skybox"))||this)._textureDecodeRGBM=!1,a._tintColor=new lB(1,1,1,1),a.renderState.rasterState.cullMode=e.CullMode.Off,a.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,a.shaderData.setFloat(n._rotationProp,0),a.shaderData.setFloat(n._exposureProp,1),a.shaderData.setColor(n._tintColorProp,a._tintColor),a}return lk(n,t),n.prototype.clone=function(){var e=new n(this._engine);return this.cloneTo(e),e},lU(n,[{key:"textureDecodeRGBM",get:function(){return this._textureDecodeRGBM},set:function(e){this._textureDecodeRGBM=e,e?this.shaderData.enableMacro(n._decodeSkyRGBMMacro):this.shaderData.disableMacro(n._decodeSkyRGBMMacro)}},{key:"texture",get:function(){return this.shaderData.getTexture(n._textureCubeProp)},set:function(e){this.shaderData.setTexture(n._textureCubeProp,e)}},{key:"rotation",get:function(){return this.shaderData.getFloat(n._rotationProp)},set:function(e){this.shaderData.setFloat(n._rotationProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(n._exposureProp)},set:function(e){this.shaderData.setFloat(n._exposureProp,e)}},{key:"tintColor",get:function(){return this._tintColor},set:function(e){this._tintColor!=e&&this._tintColor.copyFrom(e)}}]),n}(uZ);de._tintColorProp=cs.getByName("material_TintColor"),de._textureCubeProp=cs.getByName("material_CubeTexture"),de._rotationProp=cs.getByName("material_Rotation"),de._exposureProp=cs.getByName("material_Exposure"),de._decodeSkyRGBMMacro=cw.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(is=e.SunMode||(e.SunMode={}))[is.None=0]="None",is[is.Simple=1]="Simple",is[is.HighQuality=2]="HighQuality";var dt=(lk(il=function(t){var n;return(n=uZ.call(this,t,cH.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new lB(.5,.5,.5,1),n.groundTint=new lB(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n},uZ),il.prototype.clone=function(){var e=new il(this._engine);return this.cloneTo(e),e},lU(il,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(il._sunSimpleMacro),t.enableMacro(il._sunHighQualityMacro);break;case 1:t.disableMacro(il._sunHighQualityMacro),t.enableMacro(il._sunSimpleMacro);break;case 0:t.disableMacro(il._sunHighQualityMacro),t.disableMacro(il._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(il._sunSizeProp)},set:function(e){this.shaderData.setFloat(il._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(il._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(il._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(il._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(il._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(il._skyTintProp)},set:function(e){this.shaderData.setColor(il._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(il._groundTintProp)},set:function(e){this.shaderData.setColor(il._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(il._exposureProp)},set:function(e){this.shaderData.setFloat(il._exposureProp,Math.min(Math.max(0,e),8))}}]),il);dt._sunSizeProp=cs.getByName("material_SunSize"),dt._sunSizeConvergenceProp=cs.getByName("material_SunSizeConvergence"),dt._atmosphereThicknessProp=cs.getByName("material_AtmosphereThickness"),dt._skyTintProp=cs.getByName("material_SkyTint"),dt._groundTintProp=cs.getByName("material_GroundTint"),dt._exposureProp=cs.getByName("material_Exposure"),dt._sunHighQualityMacro=cw.getByName("MATERIAL_SUN_HIGH_QUALITY"),dt._sunSimpleMacro=cw.getByName("MATERIAL_SUN_SIMPLE"),(ic=lr||(lr={}))[ic.Position=1]="Position",ic[ic.Velocity=2]="Velocity",ic[ic.Acceleration=4]="Acceleration",ic[ic.Color=8]="Color",ic[ic.Alpha=16]="Alpha",ic[ic.Size=32]="Size",ic[ic.StartAngle=64]="StartAngle",ic[ic.StartTime=128]="StartTime",ic[ic.LifeTime=256]="LifeTime",ic[ic.RotateVelocity=512]="RotateVelocity",ic[ic.Scale=1024]="Scale",ic[ic.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(iu=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[iu.Transparent=0]="Transparent",iu[iu.Additive=1]="Additive";var dn=(lk(ih=function(e){var t;return(t=c6.call(this,e)||this)._maxCount=1e3,t._position=new lS,t._positionRandomness=new lS,t._velocity=new lS,t._velocityRandomness=new lS,t._acceleration=new lS,t._accelerationRandomness=new lS,t._color=new lB(1,1,1,1),t._colorRandomness=0,t._size=1,t._sizeRandomness=0,t._alpha=1,t._alphaRandomness=0,t._startAngle=0,t._startAngleRandomness=0,t._rotateVelocity=0,t._rotateVelocityRandomness=0,t._lifetime=5,t._startTimeRandomness=0,t._scale=1,t._isOnce=!1,t._onceTime=0,t._time=0,t._isInit=!1,t._isStart=!1,t._updateDirtyFlag=4294967295,t._isRotateToVelocity=!1,t._isUseOriginColor=!1,t._isScaleByLifetime=!1,t._is2d=!0,t._isFadeIn=!1,t._isFadeOut=!1,t._playOnEnable=!0,t._blendMode=0,t._onColorChanged=t._onColorChanged.bind(lO(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},c6),(id=ih.prototype).update=function(e){if(this._isInit&&this._isStart){if(this._isOnce&&this._time>this._onceTime)return this.stop();this._updateDirtyFlag&&(this._updateBuffer(),this._updateDirtyFlag=0),this._time+=e,this.shaderData.setFloat("u_time",this._time)}},id._onEnable=function(){c6.prototype._onEnable.call(this),this._playOnEnable&&this.start()},id.start=function(){this._isStart=!0,this._time=0},id.stop=function(){this._isStart=!1},id._createMaterial=function(){var t=new uZ(this.engine,cH.find("particle-shader")),n=t.renderState,r=n.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,r.sourceAlphaBlendFactor=e.BlendFactor.One,r.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.depthState.writeEnabled=!1,t.renderState.renderQueueType=e.RenderQueueType.Transparent,this.isUseOriginColor=!0,this.is2d=!0,this.isFadeOut=!0,t},id._createMesh=function(){var t=new c8(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,a=new Float32Array(r),i=null,o=!1;if(n>ih._uint16VertexLimit){if(this.engine._hardwareRenderer.canIUse(e.GLCapabilityType.elementIndexUint))o=!0,i=new Uint32Array(6*this._maxCount);else throw Error("The vertex count is over limit.")}else i=new Uint16Array(6*this._maxCount);for(var s=0,l=0;s<this._maxCount;++s){var c=4*s;i[l++]=c,i[l++]=c+1,i[l++]=c+2,i[l++]=c,i[l++]=c+2,i[l++]=c+3}var u=[new cZ("a_position",0,e.VertexElementFormat.Vector3,0),new cZ("a_velocity",12,e.VertexElementFormat.Vector3,0),new cZ("a_acceleration",24,e.VertexElementFormat.Vector3,0),new cZ("a_color",36,e.VertexElementFormat.Vector4,0),new cZ("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new cZ("a_rotation",68,e.VertexElementFormat.Vector2,0),new cZ("a_uv",76,e.VertexElementFormat.Vector3,0),new cZ("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new c$(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new c$(this.engine,e.BufferBindFlag.IndexBuffer,i,e.BufferUsage.Dynamic);t.setVertexBufferBinding(h,96),t.setIndexBufferBinding(d,o?e.IndexFormat.UInt32:e.IndexFormat.UInt16),t.setVertexElements(u),t.addSubMesh(0,i.length),this._vertexBuffer=h,this._vertexStride=24,this._vertices=a;var _=t.bounds,f=Number.MIN_SAFE_INTEGER,p=Number.MAX_SAFE_INTEGER;return _.min.set(f,f,f),_.max.set(p,p,p),t},id._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},id._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,a=ih._getRandom,i=4*e,o=i*r,s=(i+1)*r,l=(i+2)*r,c=(i+3)*r;if(1&t){var u=this._position,h=u.x,d=u.y,_=u.z,f=this._positionArray,p=this._positionRandomness;if(f){if(f.length!==this._maxCount)throw Error("The length of positionArray must be equal to maxCount.");var g=f[e];h+=g.x,d+=g.y,_+=g.z}else h+=a()*p.x,d+=a()*p.y,_+=a()*p.z;n[o]=n[s]=n[l]=n[c]=h,n[o+1]=n[s+1]=n[l+1]=n[c+1]=d,n[o+2]=n[s+2]=n[l+2]=n[c+2]=_}if(2&t){var m=this._velocity,v=this._velocityRandomness;n[o+3]=n[s+3]=n[l+3]=n[c+3]=m.x+a()*v.x,n[o+4]=n[s+4]=n[l+4]=n[c+4]=m.y+a()*v.y,n[o+5]=n[s+5]=n[l+5]=n[c+5]=m.z+a()*v.z}if(4&t){var y=this._acceleration,x=this._accelerationRandomness;n[o+6]=n[s+6]=n[l+6]=n[c+6]=y.x+a()*x.x,n[o+7]=n[s+7]=n[l+7]=n[c+7]=y.y+a()*x.y,n[o+8]=n[s+8]=n[l+8]=n[c+8]=y.z+a()*x.z}if(8&t){var T=this._color,S=this._colorRandomness;n[o+9]=n[s+9]=n[l+9]=n[c+9]=lT.clamp(T.r+a()*S,0,1),n[o+10]=n[s+10]=n[l+10]=n[c+10]=lT.clamp(T.g+a()*S,0,1),n[o+11]=n[s+11]=n[l+11]=n[c+11]=lT.clamp(T.b+a()*S,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[c+12]=lT.clamp(this._alpha+a()*this._alphaRandomness,0,1)),128&t&&(n[o+13]=n[s+13]=n[l+13]=n[c+13]=Math.random()*this._startTimeRandomness),256&t){var C=this._lifetime;n[o+14]=n[s+14]=n[l+14]=n[c+14]=C+a()*C}if((128&t||256&t)&&(this._onceTime=Math.max(this._onceTime,n[o+13]+n[o+14])),32&t){var A=this._size;n[o+15]=n[s+15]=n[l+15]=n[c+15]=Math.max(A+a()*this._sizeRandomness*A*2,0)}1024&t&&(n[o+16]=n[s+16]=n[l+16]=n[c+16]=this._scale),64&t&&(n[o+17]=n[s+17]=n[l+17]=n[c+17]=this._startAngle+a()*Math.PI*this._startAngleRandomness*2),512&t&&(n[o+18]=n[s+18]=n[l+18]=n[c+18]=this._rotateVelocity+a()*this._rotateVelocityRandomness),this._updateSingleUv(e,o,s,l,c)},id._updateSingleUv=function(e,t,n,r,a){var i=this.spriteSheet,o=this.getMaterial().shaderData.getTexture("u_texture"),s=this._vertices;if(o){var l=o.width,c=o.height;if(i){var u=i[e%i.length],h=u.x,d=u.y,_=u.w,f=u.h,p=h/l,g=d/c,m=p+_/l,v=g+f/c,y=f/_;s[t+19]=p,s[t+20]=v,s[t+21]=y,s[n+19]=m,s[n+20]=v,s[n+21]=y,s[r+19]=m,s[r+20]=g,s[r+21]=y,s[a+19]=p,s[a+20]=g,s[a+21]=y}else{var x=c/l;s[t+19]=0,s[t+20]=1,s[t+21]=x,s[n+19]=1,s[n+20]=1,s[n+21]=x,s[r+19]=1,s[r+20]=0,s[r+21]=x,s[a+19]=0,s[a+20]=0,s[a+21]=x}}else s[t+19]=0,s[t+20]=0,s[t+21]=1,s[n+19]=1,s[n+20]=0,s[n+21]=1,s[r+19]=1,s[r+20]=1,s[r+21]=1,s[a+19]=0,s[a+20]=1,s[a+21]=1;s[t+22]=-.5,s[t+23]=-.5,s[n+22]=.5,s[n+23]=-.5,s[r+22]=.5,s[r+23]=.5,s[a+22]=-.5,s[a+23]=.5},id._onColorChanged=function(){this._updateDirtyFlag|=8},ih._getRandom=function(){return Math.random()-.5},lU(ih,[{key:"texture",get:function(){return this.getMaterial().shaderData.getTexture("u_texture")},set:function(e){e?(this.shaderData.enableMacro("particleTexture"),this.getMaterial().shaderData.setTexture("u_texture",e)):this.shaderData.disableMacro("particleTexture")}},{key:"position",get:function(){return this._position},set:function(e){this._updateDirtyFlag|=1,this._position=e}},{key:"positionRandomness",get:function(){return this._positionRandomness},set:function(e){this._updateDirtyFlag|=1,this._positionRandomness=e}},{key:"positionArray",get:function(){return this._positionArray},set:function(e){this._updateDirtyFlag|=1,this._positionArray=e}},{key:"velocity",get:function(){return this._velocity},set:function(e){this._updateDirtyFlag|=2,this._velocity=e}},{key:"velocityRandomness",get:function(){return this._velocityRandomness},set:function(e){this._updateDirtyFlag|=2,this._velocityRandomness=e}},{key:"acceleration",get:function(){return this._acceleration},set:function(e){this._updateDirtyFlag|=4,this._acceleration=e}},{key:"accelerationRandomness",get:function(){return this._accelerationRandomness},set:function(e){this._updateDirtyFlag|=4,this._accelerationRandomness=e}},{key:"color",get:function(){return this._color},set:function(e){this._color.copyFrom(e)}},{key:"colorRandomness",get:function(){return this._colorRandomness},set:function(e){this._updateDirtyFlag|=8,this._colorRandomness=e}},{key:"size",get:function(){return this._size},set:function(e){this._updateDirtyFlag|=32,this._size=e}},{key:"sizeRandomness",get:function(){return this._sizeRandomness},set:function(e){this._updateDirtyFlag|=32,this._sizeRandomness=e}},{key:"alpha",get:function(){return this._alpha},set:function(e){this._updateDirtyFlag|=16,this._alpha=e}},{key:"alphaRandomness",get:function(){return this._alphaRandomness},set:function(e){this._updateDirtyFlag|=16,this._alphaRandomness=e}},{key:"angle",get:function(){return this._startAngle},set:function(e){this._updateDirtyFlag|=64,this._startAngle=e}},{key:"angleRandomness",get:function(){return this._startAngleRandomness},set:function(e){this._updateDirtyFlag|=64,this._startAngleRandomness=e}},{key:"rotateVelocity",get:function(){return this._rotateVelocity},set:function(e){this._updateDirtyFlag|=512,this._rotateVelocity=e}},{key:"rotateVelocityRandomness",get:function(){return this._rotateVelocityRandomness},set:function(e){this._updateDirtyFlag|=512,this._rotateVelocityRandomness=e}},{key:"lifetime",get:function(){return this._lifetime},set:function(e){this._updateDirtyFlag|=256,this._lifetime=e,this._onceTime=0}},{key:"startTimeRandomness",get:function(){return this._startTimeRandomness},set:function(e){this._updateDirtyFlag|=128,this._startTimeRandomness=e,this._onceTime=0}},{key:"scale",get:function(){return this._scale},set:function(e){this._updateDirtyFlag|=1024,this._scale=e}},{key:"maxCount",get:function(){return this._maxCount},set:function(e){this._isStart=!1,this._isInit=!1,this._maxCount=e,this._updateDirtyFlag=4294967295,this.mesh=this._createMesh(),this._updateBuffer(),this._isInit=!0,this.shaderData.setFloat("u_time",0)}},{key:"isOnce",get:function(){return this._isOnce},set:function(e){this._time=0,this.shaderData.setInt("u_once",e?1:0),this._isOnce=e}},{key:"isRotateToVelocity",get:function(){return this._isRotateToVelocity},set:function(e){e?this.shaderData.enableMacro("rotateToVelocity"):this.shaderData.disableMacro("rotateToVelocity"),this._isRotateToVelocity=e}},{key:"isUseOriginColor",get:function(){return this._isUseOriginColor},set:function(e){e?this.shaderData.enableMacro("useOriginColor"):this.shaderData.disableMacro("useOriginColor"),this._isUseOriginColor=e}},{key:"isScaleByLifetime",get:function(){return this._isScaleByLifetime},set:function(e){e?this.shaderData.enableMacro("isScaleByLifetime"):this.shaderData.disableMacro("isScaleByLifetime"),this._isScaleByLifetime=e}},{key:"is2d",get:function(){return this._is2d},set:function(t){t?this.shaderData.enableMacro("is2d"):(this.shaderData.disableMacro("is2d"),this.getMaterial().renderState.rasterState.cullMode=e.CullMode.Off),this._is2d=t}},{key:"isFadeIn",get:function(){return this._isFadeIn},set:function(e){e?this.shaderData.enableMacro("fadeIn"):this.shaderData.disableMacro("fadeIn"),this._isFadeIn=e}},{key:"isFadeOut",get:function(){return this._isFadeOut},set:function(e){e?this.shaderData.enableMacro("fadeOut"):this.shaderData.disableMacro("fadeOut"),this._isFadeOut=e}},{key:"playOnEnable",get:function(){return this._playOnEnable},set:function(e){this._playOnEnable=e,e?this.start():this.stop()}},{key:"blendMode",get:function(){return this._blendMode},set:function(t){var n=this.getMaterial().renderState.blendState.targetBlendState;0===t?(n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.OneMinusSourceAlpha,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha):1===t&&(n.enabled=!0,n.sourceColorBlendFactor=e.BlendFactor.SourceAlpha,n.destinationColorBlendFactor=e.BlendFactor.One,n.sourceAlphaBlendFactor=e.BlendFactor.One,n.destinationAlphaBlendFactor=e.BlendFactor.OneMinusSourceAlpha),this._blendMode=t}}]),ih);dn._uint16VertexLimit=65535,lW([lK],dn.prototype,"_onColorChanged",null),cH.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 dr=(lk(i_=function(t){var n,r=(n=uZ.call(this,t,cH.find("trail"))||this).renderState.blendState.targetBlendState;return r.enabled=!0,r.sourceColorBlendFactor=r.sourceAlphaBlendFactor=e.BlendFactor.SourceAlpha,r.destinationColorBlendFactor=r.destinationAlphaBlendFactor=e.BlendFactor.One,n.renderState.depthState.writeEnabled=!1,n},uZ),i_),da=new lS,di=(lk(ip=function(e,t){(n=c6.call(this,e)||this)._stroke=t.stroke||.2,n._minSeg=t.minSeg||.02,n._lifetime=t.lifetime||1e3,n._maxPointNum=n._lifetime/1e3*e.engine.targetFrameRate,n._points=[],n._pointStates=[],n._strapPoints=[];for(var n,r=0;r<n._maxPointNum;r++)n._points.push(new lS),n._pointStates.push(n._lifetime),n._strapPoints.push(new lS),n._strapPoints.push(new lS);n._curPointNum=0;var a=t.material||new dr(n.engine);return n.setMaterial(a),n.setTexture(t.texture),n._initGeometry(),n},c6),(ig=ip.prototype).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];lS.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++)},ig.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},ig._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),c6.prototype._render.call(this,e)},ig._initGeometry=function(){var t=new c8(this._entity.engine),n=2*this._maxPointNum,r=20*n,a=new Float32Array(r),i=[new cZ("POSITION",0,e.VertexElementFormat.Vector3,0),new cZ("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new c$(this.engine,4*r,e.BufferUsage.Dynamic);t.setVertexBufferBinding(o,20),t.setVertexElements(i),t.addSubMesh(0,n,e.MeshTopology.TriangleStrip),this._vertexBuffer=o,this._vertexStride=20,this._vertices=a,this.mesh=t},ig._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new lS(n[0],n[4],n[8]),a=new lS(n[1],n[5],n[9]),i=new lS(n[2],n[6],n[10]),o=this._stroke;a.scale(o);var s=new lS,l=new lS,c=new lF;lS.transformByQuat(r,c,r),lS.transformByQuat(a,c,a);var u=new lS,h=new lS,d=new lS;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?lS.subtract(p,t[f-1],d):lS.subtract(t[f+1],p,d),this._projectOnPlane(d,i,d),d.normalize();var g=Math.acos(lS.dot(r,d));lS.cross(r,d,h),0>=lS.dot(h,i)&&(g=2*Math.PI-g),lF.rotationAxisAngle(i,g,c),lS.transformByQuat(a,c,u),lS.add(p,u,s),lS.subtract(p,u,l)}var m=2*f*this._vertexStride/4,v=(2*f+1)*this._vertexStride/4;_[m]=s.x,_[m+1]=s.y,_[m+2]=s.z,_[v]=l.x,_[v+1]=l.y,_[v+2]=l.z}},ig._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}}},ig._projectOnVector=function(e,t,n){var r=t.clone();lS.normalize(r,r);var a=lS.dot(e,r);n.x=r.x*a,n.y=r.y*a,n.z=r.z*a},ig._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,da),lS.subtract(e,da,n)},ip),ds=(lk(im=function(){var t;return t=hi.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},hi),(iv=im.prototype).onTextureChange=function(e){},iv.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 l7(this.engine,this.width,this.height,this._isCube?new ct(this.engine,this.width):new l9(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new l7(this.engine,this.width,this.height,this._isCube?new ct(this.engine,this.width):new l9(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},iv.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},iv._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},lU(im,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),im),dl=new lS,dc=new lS,du=new lS,dh=(lk(iy=function(){var e;return e=ds.apply(this,arguments)||this,e.position=new lS(0,0,0),e._isCube=!0,e.oriViewMatrix=new lR,e},ds),(ix=iy.prototype).onBeginRender=function(t){if(this.enabled){ds.prototype.onBeginRender.call(this,t),this._storeCamera(t);for(var n=0;n<6;n++)this._setCamera(n,t),t.render(e.TextureCubeFace.PositiveX+n);this._restoreCamera(t),ds.prototype._reset.call(this)}},ix._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ix._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ix._setCamera=function(e,t){switch(e){case 0:dc.set(0,-1,0),du.set(1,0,0);break;case 1:dc.set(0,-1,0),du.set(-1,0,0);break;case 2:dc.set(0,0,1),du.set(0,1,0);break;case 3:dc.set(0,0,-1),du.set(0,-1,0);break;case 4:dc.set(0,-1,0),du.set(0,0,1);break;case 5:dc.set(0,-1,0),du.set(0,0,-1)}lS.add(this.position,du,dl),lR.lookAt(this.position,dl,dc,t.viewMatrix),t.fieldOfView=90},iy),dd=Object.freeze({__proto__:null,AmbientLight:u7,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:hQ,AnimationClipCurveBinding:hq,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:hJ,AnimationEvent:hY,get AnimationFloatArrayCurve(){return e.AnimationFloatArrayCurve},get AnimationFloatCurve(){return e.AnimationFloatCurve},get AnimationQuaternionCurve(){return e.AnimationQuaternionCurve},get AnimationVector2Curve(){return e.AnimationVector2Curve},get AnimationVector3Curve(){return e.AnimationVector3Curve},get AnimationVector4Curve(){return e.AnimationVector4Curve},Animator:h3,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:h4,AnimatorControllerLayer:h5,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:h6,AnimatorStateMachine:h7,AnimatorStateTransition:h$,AssetPromise:uT,get AssetType(){return e.AssetType},Background:u8,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:hb,Basic2DBatcher:u_,BasicRenderPipeline:hv,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:c5,BlendShapeFrame:c4,BlendState:cN,BlinnPhongMaterial:hM,BoolUpdateFlag:cm,BoxColliderShape:uX,Buffer:c$,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:c8,get BufferUsage(){return e.BufferUsage},BufferUtil:cJ,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:uq,CharacterController:uD,CloneManager:lQ,get Collider(){return e.Collider},ColliderShape:uW,get ColliderShapeUpAxis(){return e.ColliderShapeUpAxis},get CollisionDetectionMode(){return e.CollisionDetectionMode},get ColorSpace(){return e.ColorSpace},get ColorWriteMask(){return e.ColorWriteMask},get CompareFunction(){return e.CompareFunction},Component:cc,ContentRestorer:l$,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:dh,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:cU,get DepthTextureMode(){return e.DepthTextureMode},get DiffuseMode(){return e.DiffuseMode},DirectLight:he,DynamicCollider:uB,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:u4,EngineObject:lJ,Entity:cT,EventDispatcher:co,FixedJoint:uU,get FogMode(){return e.FogMode},Font:ci,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:uz,HitResult:uI,IndexBufferBinding:c0,get IndexFormat(){return e.IndexFormat},InputManager:uJ,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:uG,JointMotor:uH,Keyframe:h9,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:u9,Loader:hE,Logger:l8,Material:uZ,Mesh:c2,MeshRenderer:c6,get MeshTopology(){return e.MeshTopology},ModelMesh:c9,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:hF,PBRMaterial:hR,PBRSpecularMaterial:hP,ParticleRenderer:dn,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsMaterial:uV,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PhysicsScene:uL,get PipelineStage(){return e.PipelineStage},PlaneColliderShape:uj,get Platform(){return e.Platform},PointLight:ht,Pointer:ub,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:uu,Probe:ds,RasterState:cz,ReferResource:lZ,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:hs,RenderQueue:hc,get RenderQueueType(){return e.RenderQueueType},RenderState:cG,get RenderStateDataKey(){return e.RenderStateDataKey},RenderTarget:l7,RenderTargetBlendState:cO,get Renderer(){return e.Renderer},ResourceManager:uS,Scene:ha,SceneManager:ux,Script:hi,get SetDataOptions(){return e.SetDataOptions},Shader:cH,ShaderData:cW,ShaderFactory:cF,ShaderMacro:cw,ShaderMacroCollection:cE,ShaderPass:cI,ShaderProperty:cs,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:cR,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:uh,SkinnedMeshRenderer:ud,Sky:u5,SkyBoxMaterial:de,SkyProceduralMaterial:dt,SphereColliderShape:uK,SpotLight:hn,SpringJoint:uk,Sprite:hB,SpriteAtlas:hD,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:cQ,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:hO,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:h8,StaticCollider:uO,get StencilOperation(){return e.StencilOperation},StencilState:ck,SubMesh:c1,SubShader:cV,get SunMode(){return e.SunMode},SystemInfo:uR,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:hz,TextUtils:cr,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:l6,Texture2D:l9,Texture2DArray:ce,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:ct,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},get TextureUsage(){return e.TextureUsage},get TextureWrapMode(){return e.TextureWrapMode},Time:cl,TrailMaterial:dr,TrailRenderer:di,Transform:cy,UnlitMaterial:hL,Utils:c_,get VertexAttribute(){return e.VertexAttribute},VertexBufferBinding:c3,VertexElement:cZ,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:lj,deepClone:lY,dependentComponents:ch,ignoreClone:lK,request:hS,resourceLoader:uC,shallowClone:lq});function d_(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 df(e,t,n){return t&&d_(e.prototype,t),n&&d_(e,n),e}function dp(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(iT=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[iT.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",iT[iT.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",iT[iT.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",iT[iT.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",iT[iT.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",iT[iT.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",iT[iT.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",iT[iT.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",iT[iT.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",iT[iT.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",iT[iT.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",iT[iT.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",iT[iT.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",iT[iT.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",iT[iT.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",iT[iT.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",iT[iT.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",iT[iT.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",iT[iT.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",iT[iT.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",iT[iT.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",iT[iT.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",iT[iT.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",iT[iT.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",iT[iT.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",iT[iT.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",iT[iT.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",iT[iT.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",iT[iT.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",iT[iT.R11_EAC=37488]="R11_EAC",iT[iT.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",iT[iT.RG11_EAC=37490]="RG11_EAC",iT[iT.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",iT[iT.RGB8_ETC2=37492]="RGB8_ETC2",iT[iT.SRGB8_ETC2=37493]="SRGB8_ETC2",iT[iT.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",iT[iT.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",iT[iT.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",iT[iT.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",iT[iT.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",iT[iT.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",iT[iT.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",iT[iT.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",iT[iT.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",iT[iT.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",iT[iT.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",iT[iT.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT",iT[iT.RGBA_BPTC_UNORM_EXT=36492]="RGBA_BPTC_UNORM_EXT",iT[iT.SRGB_ALPHA_BPTC_UNORM_EXT=36493]="SRGB_ALPHA_BPTC_UNORM_EXT",iT[iT.RGB_BPTC_SIGNED_FLOAT_EXT=36494]="RGB_BPTC_SIGNED_FLOAT_EXT",iT[iT.RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="RGB_BPTC_UNSIGNED_FLOAT_EXT";var dg=((iC=(iS=function(e){this._scale=new lL;var t=e.width,n=e.height;this._webCanvas=e,this._width=t,this._height=n}).prototype).resizeByClientSize=function(e){void 0===e&&(e=window.devicePixelRatio);var t=this._webCanvas;"undefined"!=typeof OffscreenCanvas&&dp(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},iC.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},df(iS,[{key:"width",get:function(){return this._width},set:function(e){this._width!==e&&(this._webCanvas.width=e,this._width=e)}},{key:"height",get:function(){return this._height},set:function(e){this._height!==e&&(this._webCanvas.height=e,this._height=e)}},{key:"scale",get:function(){var e=this._webCanvas;return"undefined"!=typeof OffscreenCanvas&&dp(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&&dp(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),iS);function dm(e,t){return(dm=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function dv(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&&dm(e,t)}var dy=(dv(iA=function(){return u4.apply(this,arguments)},u4),iA.create=function(e){var t=e.canvas,n=new dg("string"==typeof t?document.getElementById(t):t),r=new dP(e.graphicDeviceOptions),a=new iA(n,r,e);return a._initialize(e).then(function(){return a.sceneManager.addScene(new ha(a,"DefaultScene")),a})},df(iA,[{key:"canvas",get:function(){return this._canvas}}]),iA);function dx(){return(dx=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 dT=((iE=(iw=function(t,n,r,a,i){void 0===a&&(a=e.BufferUsage.Static);var o=t.gl,s=o.createBuffer(),l=this._getGLBufferUsage(o,a),c=n===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,r,l),o.bindBuffer(c,null)}).prototype).bind=function(){this._gl.bindBuffer(this._glBindTarget,this._glBuffer)},iE.setData=function(t,n,r,a,i,o){var s=this._gl,l=this._glBindTarget;this.bind(),o===e.SetDataOptions.Discard&&s.bufferData(l,t,this._glBufferUsage);var c=n.BYTES_PER_ELEMENT||1,u=i?c*i:n.byteLength;if(0!==a||u<n.byteLength){var h=void 0!==n.byteOffset;if(this._isWebGL2&&h)s.bufferSubData(l,r,n,a,u/c);else{var d=new Uint8Array(h?n.buffer:n,a*c,u);s.bufferSubData(l,r,d)}}else s.bufferSubData(l,r,n);s.bindBuffer(l,null)},iE.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."},iE.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},iE._getGLBufferUsage=function(t,n){switch(n){case e.BufferUsage.Static:return t.STATIC_DRAW;case e.BufferUsage.Dynamic:return t.DYNAMIC_DRAW;case e.BufferUsage.Stream:return t.STREAM_DRAW}},iw),dS=((iM=(ib=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},iM.canIUseCompressedTextureInternalFormat=function(t){var n=e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,r=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,h=e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,d=e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,_=e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,f=e.GLCompressedTextureInternalFormat.RGB_BPTC_UNSIGNED_FLOAT_EXT;return t>=n&&r<=r||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>=h&&t<=d?this.canIUse(e.GLCapabilityType.s3tc):!!(t>=_)&&!!(t<=f)&&this.canIUse(e.GLCapabilityType.bptc)},iM._init=function(){var t=this.capabilityList,n=this.rhi.isWebGL2,r=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,h=e.GLCapabilityType.multipleSample,d=e.GLCapabilityType.drawBuffers,_=e.GLCapabilityType.astc,f=e.GLCapabilityType.astc_webkit,p=e.GLCapabilityType.etc,g=e.GLCapabilityType.etc_webkit,m=e.GLCapabilityType.etc1,v=e.GLCapabilityType.etc1_webkit,y=e.GLCapabilityType.pvrtc,x=e.GLCapabilityType.pvrtc_webkit,T=e.GLCapabilityType.s3tc,S=e.GLCapabilityType.s3tc_webkit,C=e.GLCapabilityType.bptc,A=e.GLCapabilityType.textureFloat,w=e.GLCapabilityType.textureHalfFloat,E=e.GLCapabilityType.textureFloatLinear,b=e.GLCapabilityType.textureHalfFloatLinear,M=e.GLCapabilityType.WEBGL_colorBufferFloat,F=e.GLCapabilityType.colorBufferFloat,R=e.GLCapabilityType.colorBufferHalfFloat,P=e.GLCapabilityType.textureFilterAnisotropic;t.set(a,n),t.set(i,n||!!r(i)),t.set(o,n||!!r(o)),t.set(s,n||!!r(s)),t.set(l,n||!!r(l)),t.set(c,n||!!r(c)),t.set(u,n||!!r(u)),t.set(h,n),t.set(d,n||!!r(d)),t.set(A,n||!!r(A)),t.set(w,n||!!r(w)),t.set(E,!!r(E)),t.set(b,n||!!r(b)),t.set(F,n&&!!r(F)||!!r(M)),t.set(R,n&&!!r(F)||!!r(R)),t.set(P,!!r(P)),t.set(_,!!(r(_)||r(f))),t.set(p,!!(r(p)||r(g))),t.set(m,!!(r(m)||r(v))),t.set(y,!!(r(y)||r(x))),t.set(T,!!(r(T)||r(S))),t.set(C,!!r(C))},iM._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}},iM._compatibleAllInterface=function(){var t=e.GLCapabilityType.depthTexture,n=e.GLCapabilityType.vertexArrayObject,r=e.GLCapabilityType.instancedArrays,a=e.GLCapabilityType.drawBuffers,i=e.GLCapabilityType.textureFilterAnisotropic,o=e.GLCapabilityType.textureHalfFloat,s=e.GLCapabilityType.colorBufferHalfFloat,l=e.GLCapabilityType.WEBGL_colorBufferFloat;if(!this.rhi.isWebGL2){this._compatibleInterface(t,{UNSIGNED_INT_24_8:"UNSIGNED_INT_24_8_WEBGL"}),this._compatibleInterface(n,{createVertexArray:"createVertexArrayOES",deleteVertexArray:"deleteVertexArrayOES",isVertexArray:"isVertexArrayOES",bindVertexArray:"bindVertexArrayOES"}),this._compatibleInterface(r,{drawArraysInstanced:"drawArraysInstancedANGLE",drawElementsInstanced:"drawElementsInstancedANGLE",vertexAttribDivisor:"vertexAttribDivisorANGLE"}),this._compatibleInterface(a,{MAX_DRAW_BUFFERS:"MAX_DRAW_BUFFERS_WEBGL"});var c={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var u=this.maxDrawBuffers,h=0;h<u;h++)0!=h&&(c["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),c["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(a,dx({drawBuffers:"drawBuffersWEBGL"},c))}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"})},df(ib,[{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,n=this.canIUse(e.GLCapabilityType.multipleSample);this._maxAntiAliasing=n?t.getParameter(t.MAX_SAMPLES):1}return this._maxAntiAliasing}},{key:"rhi",get:function(){return this._rhi}}]),ib),dC=((iF=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]},iF),dA=((iP=(iR=function(t,n){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=n,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._useVao=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var n=this._gl,r=this._primitive,a=this._useVao&&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,h=t.start,d=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(a)n.drawElementsInstanced(u,d,l,h*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,d,l,h*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,h,d,s)}else l8.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(a)n.drawElements(u,d,l,h*c);else{var f=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(u,d,l,h*c),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(u,h,d);a?n.bindVertexArray(null):this._disableAttrib()},iP.destroy=function(){this._useVao&&this._clearVAO()},iP._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 h=i[u.bindingIndex],d=h.buffer,_=h.stride;n!==(t=d._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 l8.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},iP._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},iP._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)},iP._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},iR),dw=((iL=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]},iL),dE=((iB=(iD=function(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()}).prototype).destroy=function(){this._gl.deleteTexture(this._glTexture),this._texture=null,this._glTexture=null,this._formatDetail=null},iB.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},iB.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},iB._bind=function(){this._rhi.bindTexture(this)},iB._init=function(t){var n=this._gl,r=this._isWebGL2,a=this._formatDetail,i=a.internalFormat,o=a.baseFormat,s=a.dataType,l=this._texture,c=l.mipmapCount,u=l.width,h=l.height,d=l.usage,_=l._isDepthTexture;if(this._bind(),r&&!(o===n.LUMINANCE_ALPHA||o===n.ALPHA)&&d!==e.TextureUsage.Dynamic)n.texStorage2D(this._target,c,i,u,h);else if(t)for(var f=0;f<c;f++)for(var p=Math.max(1,u>>f),g=0;g<6;g++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+g,f,i,p,p,0,o,s,null);else if(_)n.texImage2D(this._target,0,i,u,h,0,o,s,null);else for(var m=0;m<c;m++){var v=Math.max(1,u>>m),y=Math.max(1,h>>m);n.texImage2D(this._target,m,i,v,y,0,o,s,null)}},iB._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,l8.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)},iB._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===e.TextureWrapMode.Clamp||iD._isPowerOf2(s)&&iD._isPowerOf2(l)||(l8.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:r.texParameteri(i,n,r.CLAMP_TO_EDGE);break;case e.TextureWrapMode.Repeat:r.texParameteri(i,n,r.REPEAT);break;case e.TextureWrapMode.Mirror:r.texParameteri(i,n,r.MIRRORED_REPEAT)}},iB._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},iD._isPowerOf2=function(e){return(e&e-1)==0},iD._getFormatDetail=function(t,n,r){switch(t){case e.TextureFormat.R8G8B8:return{internalFormat:r?n.RGB8:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R8G8B8A8:return{internalFormat:r?n.RGBA8:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R4G4B4A4:return{internalFormat:r?n.RGBA4:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_4_4_4_4,isCompressed:!1};case e.TextureFormat.R5G5B5A1:return{internalFormat:r?n.RGB5_A1:n.RGBA,baseFormat:n.RGBA,dataType:n.UNSIGNED_SHORT_5_5_5_1,isCompressed:!1};case e.TextureFormat.R5G6B5:return{internalFormat:r?n.RGB565:n.RGB,baseFormat:n.RGB,dataType:n.UNSIGNED_SHORT_5_6_5,isCompressed:!1};case e.TextureFormat.Alpha8:return{internalFormat:n.ALPHA,baseFormat:n.ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.LuminanceAlpha:return{internalFormat:n.LUMINANCE_ALPHA,baseFormat:n.LUMINANCE_ALPHA,dataType:n.UNSIGNED_BYTE,isCompressed:!1};case e.TextureFormat.R16G16B16A16:return{internalFormat:r?n.RGBA16F:n.RGBA,baseFormat:n.RGBA,dataType:n.HALF_FLOAT,isCompressed:!1};case e.TextureFormat.R32G32B32A32:return{internalFormat:r?n.RGBA32F:n.RGBA,baseFormat:n.RGBA,dataType:n.FLOAT,isCompressed:!1};case e.TextureFormat.BC1:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_S3TC_DXT1_EXT,isCompressed:!0};case e.TextureFormat.BC3:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_S3TC_DXT5_EXT,isCompressed:!0};case e.TextureFormat.BC7:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_BPTC_UNORM_EXT,isCompressed:!0};case e.TextureFormat.ETC1_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_ETC1_WEBGL,isCompressed:!0};case e.TextureFormat.ETC2_RGB:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB8_PUNCHTHROUGH_ALPHA1_ETC2,isCompressed:!0};case e.TextureFormat.ETC2_RGBA8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA8_ETC2_EAC,isCompressed:!0};case e.TextureFormat.PVRTC_RGB2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA2:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_2BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGB4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.PVRTC_RGBA4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_PVRTC_4BPPV1_IMG,isCompressed:!0};case e.TextureFormat.ASTC_4x4:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_4X4_KHR,isCompressed:!0};case e.TextureFormat.ASTC_5x5:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_5X5_KHR,isCompressed:!0};case e.TextureFormat.ASTC_6x6:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_6X6_KHR,isCompressed:!0};case e.TextureFormat.ASTC_8x8:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_8X8_KHR,isCompressed:!0};case e.TextureFormat.ASTC_10x10:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_10X10_KHR,isCompressed:!0};case e.TextureFormat.ASTC_12x12:return{internalFormat:e.GLCompressedTextureInternalFormat.RGBA_ASTC_12X12_KHR,isCompressed:!0};case e.TextureFormat.Depth:return{internalFormat:r?n.DEPTH_COMPONENT32F:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:r?n.FLOAT:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.DepthStencil:return{internalFormat:r?n.DEPTH32F_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:r?n.FLOAT_32_UNSIGNED_INT_24_8_REV:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth16:return{internalFormat:r?n.DEPTH_COMPONENT16:n.DEPTH_COMPONENT,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth24Stencil8:return{internalFormat:r?n.DEPTH24_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.TextureFormat.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.TextureFormat.Depth32Stencil8:return{internalFormat:n.DEPTH32F_STENCIL8,baseFormat:n.DEPTH_STENCIL,dataType:n.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},iD._getRenderBufferDepthFormatDetail=function(t,n,r){switch(t){case e.RenderBufferDepthFormat.Depth:return{internalFormat:r?n.DEPTH_COMPONENT32F:n.DEPTH_COMPONENT16,baseFormat:n.DEPTH_COMPONENT,dataType:r?n.FLOAT:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.DepthStencil:return{internalFormat:r?n.DEPTH32F_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:r?n.FLOAT_32_UNSIGNED_INT_24_8_REV:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Stencil:return{internalFormat:n.STENCIL_INDEX8,baseFormat:n.STENCIL_ATTACHMENT,dataType:n.UNSIGNED_BYTE,isCompressed:!1,attachment:n.STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth16:return{internalFormat:n.DEPTH_COMPONENT16,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_SHORT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth24Stencil8:return{internalFormat:r?n.DEPTH24_STENCIL8:n.DEPTH_STENCIL,baseFormat:n.DEPTH_STENCIL,dataType:n.UNSIGNED_INT_24_8,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};case e.RenderBufferDepthFormat.Depth24:return{internalFormat:n.DEPTH_COMPONENT24,baseFormat:n.DEPTH_COMPONENT,dataType:n.UNSIGNED_INT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32:return{internalFormat:n.DEPTH_COMPONENT32F,baseFormat:n.DEPTH_COMPONENT,dataType:n.FLOAT,isCompressed:!1,attachment:n.DEPTH_ATTACHMENT};case e.RenderBufferDepthFormat.Depth32Stencil8:return{internalFormat:n.DEPTH32F_STENCIL8,baseFormat:n.DEPTH_STENCIL,dataType:n.FLOAT_32_UNSIGNED_INT_24_8_REV,isCompressed:!1,attachment:n.DEPTH_STENCIL_ATTACHMENT};default:throw Error("this TextureFormat is not supported in Galacean Engine: "+t)}},iD._supportTextureFormat=function(t,n){switch(t){case e.TextureFormat.R16G16B16A16:if(!n.canIUse(e.GLCapabilityType.textureHalfFloat))return!1;break;case e.TextureFormat.R32G32B32A32:if(!n.canIUse(e.GLCapabilityType.textureFloat))return!1;break;case e.TextureFormat.Depth16:case e.TextureFormat.Depth24Stencil8:case e.TextureFormat.Depth:case e.TextureFormat.DepthStencil:if(!n.canIUse(e.GLCapabilityType.depthTexture))return!1;break;case e.TextureFormat.Depth24:case e.TextureFormat.Depth32:case e.TextureFormat.Depth32Stencil8:return n.isWebGL2}return!0},iD._supportRenderBufferColorFormat=function(t,n){var r=!0;switch(t){case e.TextureFormat.R16G16B16A16:n.canIUse(e.GLCapabilityType.colorBufferHalfFloat)&&n.canIUse(e.GLCapabilityType.textureHalfFloat)||(r=!1);break;case e.TextureFormat.R32G32B32A32:n.canIUse(e.GLCapabilityType.colorBufferFloat)&&n.canIUse(e.GLCapabilityType.textureFloat)||(r=!1)}return r},iD._supportRenderBufferDepthFormat=function(t,n){if(!n.isWebGL2)switch(t){case e.RenderBufferDepthFormat.Depth24:case e.RenderBufferDepthFormat.Depth32:case e.RenderBufferDepthFormat.Depth32Stencil8:return!1}return!0},df(iD,[{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 n=this._gl,r=this._target,a=this._texture._mipmap;switch(this._bind(),t){case e.TextureFilterMode.Point:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(r,n.TEXTURE_MIN_FILTER,a?n.NEAREST_MIPMAP_NEAREST:n.NEAREST);break;case e.TextureFilterMode.Bilinear:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(r,n.TEXTURE_MIN_FILTER,a?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);break;case e.TextureFilterMode.Trilinear:n.texParameteri(r,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(r,n.TEXTURE_MIN_FILTER,a?n.LINEAR_MIPMAP_LINEAR:n.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 n=this._gl;switch(t){case e.TextureDepthCompareFunction.Never:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.NEVER);break;case e.TextureDepthCompareFunction.Less:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.LESS);break;case e.TextureDepthCompareFunction.Equal:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.EQUAL);break;case e.TextureDepthCompareFunction.LessEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.LEQUAL);break;case e.TextureDepthCompareFunction.Greater:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.GREATER);break;case e.TextureDepthCompareFunction.NotEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.NOTEQUAL);break;case e.TextureDepthCompareFunction.GreaterEqual:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.GEQUAL);break;case e.TextureDepthCompareFunction.Always:n.texParameteri(this._target,n.TEXTURE_COMPARE_FUNC,n.ALWAYS)}}}]),iD),db=((iV=(iI=function(t,n){this._MSAAColorRenderBuffers=[],this._curMipLevel=0,this._gl=t.gl,this._isWebGL2=t.isWebGL2,this._target=n;for(var r=n._colorTextures,a=n._depth,i=n.width,o=n.height,s=dp(a,l6),l=0,c=r.length;l<c;l++){var u=r[l]._format;if(!dE._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!dE._supportRenderBufferDepthFormat(a,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[a]+" in RenderTarget");if(r.length>1&&!t.canIUse(e.GLCapabilityType.drawBuffers))throw Error("MRT is not supported");if(r.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(r.length>1&&r.some(function(e){return dp(e,ct)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(l8.warn("MSAA antiAliasing exceeds the limit and is automatically downgraded to:"+h),n._antiAliasing=h),this._frameBuffer=this._gl.createFramebuffer(),this._bindMainFBO(),n.antiAliasing>1&&(this._MSAAFrameBuffer=this._gl.createFramebuffer(),this._bindMSAAFBO())}).prototype).setRenderTargetInfo=function(e,t){var n=this._gl,r=this._target,a=r.depthTexture,i=r.getColorTexture(0),o=t!==this._curMipLevel;if(n.bindFramebuffer(n.FRAMEBUFFER,this._frameBuffer),i){var s=dp(i,ct);(o||s)&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,s?n.TEXTURE_CUBE_MAP_POSITIVE_X+e:n.TEXTURE_2D,i._platformTexture._glTexture,t)}if(a){var l=dp(a,ct);if(o||l){var c=a._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,c._formatDetail.attachment,l?n.TEXTURE_CUBE_MAP_POSITIVE_X+e:n.TEXTURE_2D,c._glTexture,t)}}else if(o){var u=dE._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,u,r.width>>t,r.height>>t)}this._curMipLevel=t,this._activeRenderTarget()},iV.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)}},iV.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},iV._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},iV._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,dp(c,ct)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(a>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(dp(r,l6)&&!dp(r,ct)){var h=r._platformTexture;e.framebufferTexture2D(e.FRAMEBUFFER,h._formatDetail.attachment,e.TEXTURE_2D,h._glTexture,0)}else if(this._target.antiAliasing<=1){var d=dE._getRenderBufferDepthFormatDetail(r,e,t),_=d.internalFormat,f=d.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)},iV._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 h=dp(a,l6)?a._platformTexture._formatDetail:dE._getRenderBufferDepthFormatDetail(a,e,t),d=h.internalFormat,_=h.attachment;e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,d,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,_,e.RENDERBUFFER,n)}this._checkFrameBuffer(),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindRenderbuffer(e.RENDERBUFFER,null)},iV._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.")},iI),dM=(dv(iO=function(t,n){(r=dE.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(!dE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||l||dE._isPowerOf2(o)&&dE._isPowerOf2(s)||(l8.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=dE._getFormatDetail(a,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},dE),(iN=iO.prototype).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,h=l.dataType,d=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),d){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,h,e)},iN.setImageSource=function(t,n,r,a,i,o){var s=this._gl,l=this._formatDetail,c=l.internalFormat,u=l.baseFormat,h=l.dataType;this._bind(),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,+r),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+a),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,n,c,u,h,t):s.texSubImage2D(this._target,n,i||0,o||0,u,h,t)},iN.getPixelBuffer=function(e,t,n,r,a,i){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");dE.prototype._getPixelBuffer.call(this,null,e,t,n,r,a,i)},iO),dF=(dv(iU=function(t,n){r=dE.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(!dE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return r._bind(),r._formatDetail=dE._getFormatDetail(a,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,i,o,s),r},dE),(iz=iU.prototype).setPixelBuffer=function(e,t,n,r,a,i,o,s){var l=this._target,c=this._gl,u=this._formatDetail,h=u.internalFormat,d=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,h,t):c.texSubImage3D(l,n,r,a,e,i,o,s,d,_,t)},iz.setImageSource=function(e,t,n,r,a,i,o){var s,l,c=this._gl,u=this._formatDetail,h=u.baseFormat,d=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,h,d,t)},iz.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)},iU),dR=(dv(ik=function(t,n){(r=dE.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(!dE._supportTextureFormat(a,t))throw Error("Texture format is not supported:"+e.TextureFormat[a]);return!i||s||dE._isPowerOf2(o)||(l8.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=dE._getFormatDetail(a,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},dE),(iG=ik.prototype).setPixelBuffer=function(e,t,n,r,a,i,o){var s=this._gl,l=this._isWebGL2,c=this._formatDetail,u=c.internalFormat,h=c.baseFormat,d=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,h,d,t)},iG.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)},iG.getPixelBuffer=function(e,t,n,r,a,i,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");dE.prototype._getPixelBuffer.call(this,e,t,n,r,a,i,o)},ik);e.WebGLMode=void 0,(iH=e.WebGLMode||(e.WebGLMode={}))[iH.Auto=0]="Auto",iH[iH.WebGL2=1]="WebGL2",iH[iH.WebGL1=2]="WebGL1";var dP=((iX=(iW=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new lD(null,null,null,null),this._lastScissor=new lD(null,null,null,null),this._lastClearColor=new lB(null,null,null,null),this._scissorEnable=!1;var n=dx({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(uR.platform===e.Platform.IPhone||uR.platform===e.Platform.IPad){var r=uR.operatingSystem.match(/(\d+).?(\d+)?.?(\d+)?/);if(r){var a=parseInt(r[1]),i=parseInt(r[2]);15===a&&i>=0&&i<=4&&(n._forceFlush=!0)}}this._options=n,this._onWebGLContextLost=this._onWebGLContextLost.bind(this),this._onWebGLContextRestored=this._onWebGLContextRestored.bind(this)}).prototype).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&&dp(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&&dp(i,OffscreenCanvas)||(r=i.getContext("experimental-webgl",a)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},iX.createPlatformPrimitive=function(e){return new dA(this,e)},iX.createPlatformTexture2D=function(e){return new dM(this,e)},iX.createPlatformTexture2DArray=function(e){return new dF(this,e)},iX.createPlatformTextureCube=function(e){return new dR(this,e)},iX.createPlatformRenderTarget=function(e){return new db(this,e)},iX.createPlatformBuffer=function(t,n,r,a){return void 0===r&&(r=e.BufferUsage.Static),new dT(this,t,n,r,a)},iX.requireExtension=function(e){return this._extensions.requireExtension(e)},iX.canIUse=function(e){return this.capability.canIUse(e)},iX.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},iX.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))},iX.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)}},iX.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},iX.clearRenderTarget=function(t,n,r){var a=this._gl,i=t._lastRenderState,o=i.blendState.targetBlendState,s=i.depthState,l=i.stencilState,c=0;if(n&e.CameraClearFlags.Color){c|=a.COLOR_BUFFER_BIT;var u=this._lastClearColor,h=r.r,d=r.g,_=r.b,f=r.a;r&&(h!==u.r||d!==u.g||_!==u.b||f!==u.a)&&(a.clearColor(h,d,_,f),u.set(h,d,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(a.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}n&e.CameraClearFlags.Depth&&(c|=a.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(a.depthMask(!0),s.writeEnabled=!0)),n&e.CameraClearFlags.Stencil&&(c|=a.STENCIL_BUFFER_BIT,255!==l.writeMask&&(a.stencilMask(255),l.writeMask=255)),a.clear(c)},iX.drawPrimitive=function(e,t,n){e?e._draw(n,t):l8.error("draw primitive failed.")},iX.activeRenderTarget=function(e,t,n){var r,a,i,o=this._gl;e?(null==(i=e._platformRenderTarget)||i._activeRenderTarget(),r=e.width>>n,a=e.height>>n):(o.bindFramebuffer(o.FRAMEBUFFER,null),r=o.drawingBufferWidth,a=o.drawingBufferHeight);var s=r*t.z,l=a*t.w,c=t.x*r,u=a-t.y*a-l;this.viewport(c,u,s,l),this.scissor(c,u,s,l)},iX.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},iX.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)},iX.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},iX.flush=function(){this._gl.flush()},iX.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},iX.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},iX.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)},iX._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new dw(e),this._extensions=new dC(this),this._capability=new dS(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},iX.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},iX._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},iX._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},iX._onWebGLContextRestored=function(e){this._onDeviceRestored()},df(iW,[{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}}]),iW);function dL(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)}}var dD=((ij=(iK=function(e,t){var n=this;this._costs={},this._currentLoad=0,this._callbacks={},this._worker=new Worker(e),this._worker.onmessage=function(e){var t=e.data;switch(t.type){case"decode":n._callbacks[t.id].resolve(t.geometry);break;case"error":n._callbacks[t.id].reject(t);break;default:l8.error('DRACOWorker: Unexpected message, "'+t.type+'"')}},t?this._worker.postMessage({type:"init",decoderConfig:{wasmBinary:t}}):this._worker.postMessage({type:"init",decoderConfig:{}})}).prototype).setCosts=function(e,t){this._costs[e]=t},ij.addCurrentLoad=function(e){this._currentLoad+=e},ij.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},ij.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},ij.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},dL(iK.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),iq&&dL(iK,iq),iK),dB='let decoderPending;\nlet decoderConfig;\n\nonmessage = function(e) {\n const message = e.data;\n\n switch (message.type) {\n case "init":\n decoderConfig = message.decoderConfig;\n decoderPending = new Promise(function(resolve /*, reject*/) {\n decoderConfig.onModuleLoaded = function(draco) {\n // Module is Promise-like. Wrap before resolving to avoid loop.\n resolve({ draco: draco });\n };\n DracoDecoderModule(decoderConfig);\n });\n break;\n\n case "decode":\n const buffer = message.buffer;\n const taskConfig = message.taskConfig;\n decoderPending.then(module => {\n const draco = module.draco;\n const decoder = new draco.Decoder();\n const decoderBuffer = new draco.DecoderBuffer();\n decoderBuffer.Init(new Int8Array(buffer), buffer.byteLength);\n try {\n const geometry = decodeGeometry(draco, decoder, decoderBuffer, taskConfig);\n const buffers = geometry.attributes.map(attr => attr.array.buffer);\n if (geometry.index) buffers.push(geometry.index.array.buffer);\n self.postMessage({ type: "decode", id: message.id, geometry }, buffers);\n } catch (error) {\n console.error(error);\n self.postMessage({ type: "error", id: message.id, error: error.message });\n } finally {\n draco.destroy(decoderBuffer);\n draco.destroy(decoder);\n }\n });\n break;\n }\n};\n\nfunction decodeGeometry(draco, decoder, decoderBuffer, taskConfig) {\n const attributeIDs = taskConfig.attributeIDs;\n const attributeTypes = taskConfig.attributeTypes;\n\n let dracoGeometry;\n let decodingStatus;\n\n const geometryType = decoder.GetEncodedGeometryType(decoderBuffer);\n if (geometryType === draco.TRIANGULAR_MESH) {\n dracoGeometry = new draco.Mesh();\n decodingStatus = decoder.DecodeBufferToMesh(decoderBuffer, dracoGeometry);\n } else {\n throw new Error("DRACODecoder worker: Unexpected geometry type.");\n }\n\n if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {\n throw new Error("DRACODecoder worker: Decoding failed: " + decodingStatus.error_msg());\n }\n\n const geometry = { index: null, attributes: [] };\n\n // Gather all vertex attributes.\n for (let attributeName in attributeIDs) {\n const attributeType = self[attributeTypes[attributeName]];\n\n let attribute;\n let attributeID;\n\n // A Draco file may be created with default vertex attributes, whose attribute IDs\n // are mapped 1:1 from their semantic name (POSITION, NORMAL, ...). Alternatively,\n // a Draco file may contain a custom set of attributes, identified by known unique\n // IDs. glTF files always do the latter, and .drc files typically do the former.\n if (taskConfig.useUniqueIDs) {\n attributeID = attributeIDs[attributeName];\n attribute = decoder.GetAttributeByUniqueId(dracoGeometry, attributeID);\n } else {\n attributeID = decoder.GetAttributeId(dracoGeometry, draco[attributeIDs[attributeName]]);\n if (attributeID === -1) continue;\n attribute = decoder.GetAttribute(dracoGeometry, attributeID);\n }\n geometry.attributes.push(decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute));\n }\n // Add index.\n if (geometryType === draco.TRIANGULAR_MESH) {\n // Generate mesh faces.\n const numFaces = dracoGeometry.num_faces();\n const numIndices = numFaces * 3;\n let dataSize;\n let ptr;\n let index;\n const indexType = self[taskConfig.indexType];\n\n switch (indexType) {\n case Uint16Array:\n dataSize = numIndices * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt16Array(dracoGeometry, dataSize, ptr);\n index = new Uint16Array(draco.HEAPU16.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n case Uint32Array:\n dataSize = numIndices * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetTrianglesUInt32Array(dracoGeometry, dataSize, ptr);\n index = new Uint32Array(draco.HEAPU32.buffer, ptr, numIndices).slice();\n draco._free(ptr);\n break;\n default:\n throw new Error("DRACODecoder: Unexpected index type.");\n }\n geometry.index = { array: index, itemSize: 1 };\n }\n draco.destroy(dracoGeometry);\n return geometry;\n}\n\nfunction decodeAttribute(draco, decoder, dracoGeometry, attributeName, attributeType, attribute) {\n const numComponents = attribute.num_components();\n const numPoints = dracoGeometry.num_points();\n const numValues = numPoints * numComponents;\n let ptr;\n let array;\n let dataSize;\n switch (attributeType) {\n case Float32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_FLOAT32, dataSize, ptr);\n array = new Float32Array(draco.HEAPF32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT8, numValues, ptr);\n array = new Int8Array(draco.HEAP8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT16, dataSize, ptr);\n array = new Int16Array(draco.HEAP16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Int32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_INT32, dataSize, ptr);\n array = new Int32Array(draco.HEAP32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint8Array:\n ptr = draco._malloc(numValues);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT8, numValues, ptr);\n array = new Uint8Array(draco.HEAPU8.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint16Array:\n dataSize = numValues * 2;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT16, dataSize, ptr);\n array = new Uint16Array(draco.HEAPU16.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n case Uint32Array:\n dataSize = numValues * 4;\n ptr = draco._malloc(dataSize);\n decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, attribute, draco.DT_UINT32, dataSize, ptr);\n array = new Uint32Array(draco.HEAPU32.buffer, ptr, numValues).slice();\n draco._free(ptr);\n break;\n\n default:\n throw new Error("DRACODecoder: Unexpected attribute type.");\n }\n\n return {\n name: attributeName,\n array: array,\n itemSize: numComponents\n };\n}\n',dI="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",dV=((iQ=(iY=function(e){if(void 0===e&&(e={type:"wasm",workerLimit:4}),this.pool=[],this.workerLimit=Math.min(navigator.hardwareConcurrency||4,4),this.currentTaskId=1,this.taskCache=new WeakMap,e.workerLimit>this.workerLimit)l8.warn("DRACOWorkerPool: Can not initialize worker pool with limit:"+e.workerLimit);else{var t;this.workerLimit=null!=(t=e.workerLimit)?t:4}this.useJS="object"!=typeof WebAssembly||"js"===e.type,this.loadLibPromise=this.preloadLib()}).prototype).preloadLib=function(){var e=this;return this.loadLibPromise?this.loadLibPromise:new Promise(function(t,n){e.useJS?hS(""+dI+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,dB].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([hS(""+dI+"draco_wasm_wrapper_gltf.js",{type:"text"}),hS(""+dI+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],a=[n,dB].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([a])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},iQ.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new dD(t.workerSourceURL,t.decoderWASMBinary);e.pool.push(n)}else e.pool.sort(function(e,t){return e.currentLoad>t.currentLoad?-1:1});return e.pool[e.pool.length-1]})},iQ.decode=function(e,t){var n,r=this,a=JSON.stringify(t);if(this.taskCache.has(e)){var i=this.taskCache.get(e);if(i.key===a)return i.promise;if(0===e.byteLength)throw Error("DRACODecoder: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}var o=this.currentTaskId++,s=e.byteLength,l=new Promise(function(a,i){r.getWorker().then(function(r){n=r,r.setCosts(o,s),r.addCurrentLoad(s),r.setCallback(o,a,i),r.decode(o,t,e)}).catch(function(e){i(e)})});return l.finally(function(){n&&o&&n.releaseTask(o)}),this.taskCache.set(e,{key:a,promise:l}),l},iY);function dO(){return(dO=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 dN(e,t){return(dN=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function dU(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&&dN(e,t)}function dz(e,t,n,r){var a,i=arguments.length,o=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(a=e[s])&&(o=(i<3?a(o):i>3?a(t,n,o):a(t,n))||o);return i>3&&o&&Object.defineProperty(t,n,o),o}function dk(e,t){var n,r,a,i,o=function(e){return function(t){return s([e,t])}},s=function(o){if(n)throw TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=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++,r=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],r=0}finally{n=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 dG(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 dH(e,t,n){return t&&dG(e.prototype,t),n&&dG(e,n),e}var dW=((iZ=(iJ=function(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._offset=0,this._baseOffset=t}).prototype).nextUint8=function(){var e=this._dataView.getUint8(this._offset);return this._offset+=1,e},iZ.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},iZ.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},iZ.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},iZ.nextInt32Array=function(e){var t=new Int32Array(this.data.buffer,this._offset+this._dataView.byteOffset,e);return this._offset+=4*e,t},iZ.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},iZ.nextFloat32Array=function(e){var t=new Float32Array(this.data.buffer,this._offset+this._dataView.byteOffset,e);return this._offset+=4*e,t},iZ.nextUint32Array=function(e){var t=new Uint32Array(this.data.buffer,this._offset+this._dataView.byteOffset,e);return this._offset+=4*e,t},iZ.nextUint8Array=function(e){var t=new Uint8Array(this.data.buffer,this._offset+this._dataView.byteOffset,e);return this._offset+=e,t},iZ.nextUint64=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e+4294967296*t},iZ.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.data.buffer,this._offset+this._dataView.byteOffset,e);return this._offset+=e,c_.decodeText(t)},iZ.nextImageData=function(e){return new Uint8Array(this.data.buffer,this.data.byteOffset+this._offset)},iZ.nextImagesData=function(e){for(var t=Array(e),n=0;n<e;n++){var r=this._dataView.getUint32(this._offset,this._littleEndian);t[n]=r,this._offset+=4}for(var a=[],i=0;i<e;i++){var o=t[i],s=new Uint8Array(this.data.buffer,this._dataView.byteOffset+this._offset,o);this._offset+=o,a.push(s)}return a},iZ.skip=function(e){return this._offset+=e,this},iZ.scan=function(e,t){void 0===t&&(t=0);for(var n=this._offset,r=0;this._dataView.getUint8(this._offset)!==t&&r<e;)r++,this._offset++;return r<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,r)},dH(iJ,[{key:"position",get:function(){return this._offset}},{key:"offset",get:function(){return this._offset+this._baseOffset}}]),iJ),dX={};function dK(e){return function(t){dX[e]=t}}var dj=((i$=function(){this.totalLength=0,this.version=0,this.type="",this.name="",this.headerLength=0}).decode=function(e){var t=new DataView(e),n=t.getUint32(0,!0),r=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=c_.decodeText(s),c=c_.decodeText(i),u=new i$;return u.totalLength=n,u.name=l,u.type=c,u.version=r,u.headerLength=s.byteLength+i.byteLength+9,u},dH(i$,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),i$);function dq(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new lD(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function dY(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new lS(e[3*r],e[3*r+1],e[3*r+2]);return n}function dQ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new lL(e[2*r],e[2*r+1]);return n}function dJ(e,t,n){return(dJ=!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,n){var r=[null];r.push.apply(r,t);var a=new(Function.bind.apply(e,r));return n&&dN(a,n.prototype),a}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((i0=function(){}).decode=function(e,t){return new Promise(function(n){var r=new c9(e),a=JSON.parse(t.nextStr());a.bounds&&r.bounds.copyFrom(a.bounds);var i=4*Math.ceil(t.offset/4),o=t.data.buffer,s=t.data.byteOffset,l=new Float32Array(o,a.positions.start+i+s,(a.positions.end-a.positions.start)/4),c=l.length/3,u=dY(l,c);if(r.setPositions(u),a.normals){var h=dY(new Float32Array(o,a.normals.start+i+s,(a.normals.end-a.normals.start)/4),c);r.setNormals(h)}if(a.uvs){var d=new Float32Array(o,a.uvs.start+i+s,(a.uvs.end-a.uvs.start)/4);r.setUVs(dQ(d,c))}if(a.uv1){var _=new Float32Array(o,a.uv1.start+i+s,(a.uv1.end-a.uv1.start)/4);r.setUVs(dQ(_,c),1)}if(a.uv2){var f=new Float32Array(o,a.uv2.start+i+s,(a.uv2.end-a.uv2.start)/4);r.setUVs(dQ(f,c),2)}if(a.uv3){var p=new Float32Array(o,a.uv3.start+i+s,(a.uv3.end-a.uv3.start)/4);r.setUVs(dQ(p,c),3)}if(a.uv4){var g=new Float32Array(o,a.uv4.start+i+s,(a.uv4.end-a.uv4.start)/4);r.setUVs(dQ(g,c),4)}if(a.uv5){var m=new Float32Array(o,a.uv5.start+i+s,(a.uv5.end-a.uv5.start)/4);r.setUVs(dQ(m,c),5)}if(a.uv6){var v=new Float32Array(o,a.uv6.start+i+s,(a.uv6.end-a.uv6.start)/4);r.setUVs(dQ(v,c),6)}if(a.uv7){var y=new Float32Array(o,a.uv7.start+i+s,(a.uv7.end-a.uv7.start)/4);r.setUVs(dQ(y,c),7)}if(a.colors){var x=new Float32Array(o,a.colors.start+i+s,(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 lB(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}(x,c))}if(a.boneWeights){var T=new Float32Array(o,a.boneWeights.start+i+s,(a.boneWeights.end-a.boneWeights.start)/4);r.setBoneWeights(dq(T,c))}if(a.boneIndices){var S=new Float32Array(o,a.boneIndices.start+i+s,(a.boneIndices.end-a.boneIndices.start)/4);r.setBoneIndices(dq(S,c))}if(a.blendShapes&&a.blendShapes.forEach(function(e){var t=new c5(e.name);e.frames.forEach(function(e){var n=new Float32Array(o,e.deltaPosition.start+i+s,(e.deltaPosition.end-e.deltaPosition.start)/4),r=n.length/3,a=dY(n,r);e.deltaNormals&&dY(new Float32Array(o,e.deltaNormals.start+i+s,(e.deltaNormals.end-e.deltaNormals.start)/4),r),e.deltaTangents&&dq(new Float32Array(o,e.deltaTangents.start+i+s,(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+s,(a.indices.end-a.indices.start)/2):new Uint32Array(o,a.indices.start+i+s,(a.indices.end-a.indices.start)/4),r.setIndices(C)}a.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},i0),e.MeshDecoder=dz([dK("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((i1=function(){}).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(),h=t.nextUint16(),d=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),g=new l9(e,h,d,u,i);if(g.filterMode=o,g.anisoLevel=s,g.wrapModeU=l,g.wrapModeV=c,_){var m=p[0];if(g.setPixelBuffer(m),i){g.generateMipmaps();for(var v=1;v<f;v++){var y=p[v];g.setPixelBuffer(y,v)}}e.resourceManager._objectPool[a]=g,n(g)}else{var x=new window.Blob([p[0]]),T=new Image;T.onload=function(){g.setImageSource(T);var e=0,t=function(){++e>=f&&n(g)};if(t(),i){var r=function(e){var n=new window.Blob([p[e]]),r=new Image;r.onload=function(){g.setImageSource(r,e),t()},r.src=URL.createObjectURL(n)};g.generateMipmaps();for(var a=1;a<f;a++)r(a)}},T.src=URL.createObjectURL(x)}})},i1),e.Texture2DDecoder=dz([dK("Texture2D")],e.Texture2DDecoder);var dZ=((i2=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},i2.parseEntity=function(e,t){return i2.getEntityByConfig(e,t).then(function(t){t.isActive=null==(n=e.isActive)||n;var n,r=e.position,a=e.rotation,i=e.scale;return r&&t.transform.position.copyFrom(r),a&&t.transform.rotation.copyFrom(a),i&&t.transform.scale.copyFrom(i),t})},i2.getEntityByConfig=function(e,t){var n=e.assetRefId;return n?t.resourceManager.getResourceByRef({refId:n,key:e.key,isClone:e.isClone}).then(function(t){return t.name=e.name,t}):Promise.resolve(new cT(t,e.name))},i2.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,a=dJ(hE.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(a,e,t,n)},i2.parseBasicType=function(e,t,n){void 0===n&&(n=t.resourceManager);var r=this;return Array.isArray(e)?Promise.all(e.map(function(e){return r.parseBasicType(e,t,n)})):"object"!=typeof e||null==e?Promise.resolve(e):this._isClass(e)?this.parseClassObject(e,t,n):this._isRef(e)?n.getResourceByRef(e):Promise.resolve(e)},i2.parsePropsAndMethods=function(e,t,n,r){void 0===r&&(r=n.resourceManager);var a=this,i=[];if(t.methods)for(var o in t.methods)for(var s=t.methods[o],l=0,c=s.length;l<c;l++){var u=s[l],h=this.parseMethod(e,o,u,n,r);i.push(h)}if(t.props){var d=this,_=function(r){var a=t.props[r],o=d.parseBasicType(a,n).then(function(t){return e[r]=t});i.push(o)};for(var f in t.props)_(f)}return Promise.all(i).then(function(){var r=a.customParseComponentHandles[e.constructor.name];return r?r(e,t,n):e})},i2.parseMethod=function(e,t,n,r,a){void 0===a&&(a=r.resourceManager);var i=this;return Promise.all(n.map(function(e){return i.parseBasicType(e,r,a)})).then(function(n){return e[t].apply(e,n)})},i2._isClass=function(e){return void 0!=e.class},i2._isRef=function(e){return void 0!=e.refId},i2);dZ.customParseComponentHandles=new Map;var d$=((i3=function(){}).parseChildren=function(e,t,n){var r=e.get(n).children;if(r&&r.length>0)for(var a=t.get(n),i=0;i<r.length;i++){var o=r[i],s=t.get(o);a.addChild(s),this.parseChildren(e,t,o)}},i3),d0={Transform:cy,Animator:h3,DirectLight:he,Camera:e.Camera,MeshRenderer:c6,ParticleRenderer:dn,PointLight:ht,SpotLight:hn,Script:hi,SpriteMask:cQ,SpriteRenderer:hO,TextRenderer:hz};function d1(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 d2(e,t){if(e){if("string"==typeof e)return d1(e,t);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 d1(e,t)}}function d3(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=d2(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.")}e.InterpolableValueType=void 0,(i4=e.InterpolableValueType||(e.InterpolableValueType={}))[i4.Float=0]="Float",i4[i4.FloatArray=1]="FloatArray",i4[i4.Vector2=2]="Vector2",i4[i4.Vector3=3]="Vector3",i4[i4.Vector4=4]="Vector4",i4[i4.Quaternion=5]="Quaternion",i4[i4.Color=6]="Color",i4[i4.Array=7]="Array",i4[i4.Boolean=8]="Boolean",e.AnimationClipDecoder=((i5=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),a=new hQ(r),i=n.nextUint16(),o=0;o<i;++o){var s=new hY;s.time=n.nextFloat32(),s.functionName=n.nextStr(),s.parameter=JSON.parse(n.nextStr()).val,a.addEvent(s)}for(var l=n.nextUint16(),c=0;c<l;++c){var u=n.nextStr(),h=d0[n.nextStr()],d=n.nextStr(),_=void 0,f=n.nextUint8(),p=n.nextUint16();switch(n.nextStr()){case"AnimationFloatCurve":(_=_||new e.AnimationFloatCurve).interpolation=f;for(var g=0;g<p;++g){var m=new h9;m.time=n.nextFloat32(),m.value=n.nextFloat32(),m.inTangent=n.nextFloat32(),m.outTangent=n.nextFloat32(),_.addKey(m)}break;case"AnimationArrayCurve":(_=_||new e.AnimationArrayCurve).interpolation=f;for(var v=0;v<p;++v){var y=new h9;y.time=n.nextFloat32();var x=n.nextUint16();y.value=Array.from(n.nextFloat32Array(x)),y.inTangent=Array.from(n.nextFloat32Array(x)),y.outTangent=Array.from(n.nextFloat32Array(x)),_.addKey(y)}break;case"AnimationFloatArrayCurve":(_=_||new e.AnimationFloatArrayCurve).interpolation=f;for(var T=0;T<p;++T){var S=new h9;S.time=n.nextFloat32();var C=n.nextUint16();S.value=n.nextFloat32Array(C),S.inTangent=Array.from(n.nextFloat32Array(C)),S.outTangent=Array.from(n.nextFloat32Array(C)),_.addKey(S)}break;case"AnimationVector2Curve":(_=_||new e.AnimationVector2Curve).interpolation=f;for(var A=0;A<p;++A){var w=new h9;w.time=n.nextFloat32(),w.value=new lL(n.nextFloat32(),n.nextFloat32()),w.inTangent=new lL(n.nextFloat32(),n.nextFloat32()),w.outTangent=new lL(n.nextFloat32(),n.nextFloat32()),_.addKey(w)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var E=0;E<p;++E){var b=new h9;b.time=n.nextFloat32(),b.value=new lS(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.inTangent=new lS(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.outTangent=new lS(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(b)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var M=new h9;M.time=n.nextFloat32(),M.value=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M);break;case"AnimationColorCurve":(_=_||new e.AnimationColorCurve).interpolation=f;for(var F=0;F<p;++F){var R=new h9;R.time=n.nextFloat32(),R.value=new lB(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),R.inTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),R.outTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(R)}break;case"AnimationQuaternionCurve":(_=_||new e.AnimationQuaternionCurve).interpolation=f;for(var P=0;P<p;++P){var L=new h9;L.time=n.nextFloat32(),L.value=new lF(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new lD(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}a.addCurveBinding(u,h,d,_)}t(a)})},i5),e.AnimationClipDecoder=dz([dK("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(i8=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",i8.Custom="Custom";var d4=((i6=function(e,t){this.originalData=e,this.scene=t,this.entityMap=new Map,this.components=new Map,this.assets=new Map,this.entityConfigMap=new Map,this.rootIds=[]}).prototype.destroy=function(){this.entityMap.clear(),this.components.clear(),this.assets.clear(),this.entityConfigMap.clear(),this.rootIds.length=0},i6),d5=((i9=(i7=function(e){var t=this;this.context=e,this._engine=this.context.scene.engine,this._organizeEntities=this._organizeEntities.bind(this),this._parseComponents=this._parseComponents.bind(this),this._clearAndResolveScene=this._clearAndResolveScene.bind(this),this.promise=new Promise(function(e,n){t._reject=n,t._resolve=e})}).prototype).start=function(){this._parseEntities().then(this._organizeEntities).then(this._parseComponents).then(this._clearAndResolveScene).then(this._resolve).catch(this._reject)},i9._parseEntities=function(){var e=this.context.originalData.entities,t=this.context.entityConfigMap,n=this.context.entityMap,r=this.context.rootIds,a=this._engine;return Promise.all(e.map(function(e){return t.set(e.id,e),e.parent||r.push(e.id),dZ.parseEntity(e,a)})).then(function(t){for(var r=0,a=t.length;r<a;r++)n.set(e[r].id,t[r]);return t})},i9._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,a=t.scene,i=t.rootIds,o=d3(i);!(e=o()).done;){var s=e.value;d$.parseChildren(n,r,s)}for(var l=i.map(function(e){return r.get(e)}),c=0;c<l.length;c++)a.addRootEntity(l[c])},i9._parseComponents=function(){for(var e=this.context.originalData.entities,t=this.context.entityMap,n=[],r=0,a=e.length;r<a;r++)for(var i=e[r],o=t.get(i.id),s=0;s<i.components.length;s++){var l=i.components[s],c=l.refId?l.refId:l.class,u=void 0;"Animator"===c&&(u=o.getComponent(hE.getClass(c))),u=u||o.addComponent(hE.getClass(c));var h=dZ.parsePropsAndMethods(u,l,o.engine);n.push(h)}return Promise.all(n)},i9._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},i7.parse=function(e,t){var n=new ha(e),r=new d4(t,n),a=new i7(r);return a.start(),a.promise},i7);function d8(e,t){var n=dj.decode(e),r=new dW(new Uint8Array(e),n.headerLength,n.dataLength);return dX[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(dU(oe=function(){return hE.apply(this,arguments)},hE),oe.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,{type:"arraybuffer"}).then(function(e){d8(e,t.engine).then(function(e){r(e)})}).catch(a)})},oe),e.MeshLoader=dz([uC("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(dU(ot=function(){return hE.apply(this,arguments)},hE),ot.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,{type:"arraybuffer"}).then(function(e){d8(e,t.engine).then(function(e){r(e)})}).catch(a)})},ot),e.EditorTextureLoader=dz([uC("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var d6=(dU(on=function(){return hE.apply(this,arguments)},hE),on.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"arraybuffer"})).then(function(e){return d8(e,t.engine).then(r)}).catch(a)})},on);d6=dz([uC(e.AssetType.AnimationClip,["ani"])],d6);var d7=(dU(or=function(){return hE.apply(this,arguments)},hE),or.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"json"})).then(function(e){var n=new h4,a=e.layers,i=[];a.forEach(function(e,r){var a=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new h5(a);if(c.blendingMode=o,c.weight=s,l){var u=l.states,h=c.stateMachine=new h7;u.forEach(function(e,n){var a=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,c=e.clipEndNormalizedTime,u=e.isDefaultState,d=e.clip,_=e.scripts,f=h.addState(a);u&&(h.defaultState=f),f.speed=o,f.wrapMode=s,f.clipStartTime=l,f.clipEndTime=c;var p=JSON.parse(_);null==p||p.forEach(function(e){f.addStateMachineScript(hE.getClass(e))}),d&&i.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),u.forEach(function(e){var t=e.name;e.transitions.forEach(function(e){var n=e.targetStateName,r=e.duration,a=e.offset,i=e.exitTime,o=h.findStateByName(t),s=h.findStateByName(n),l=new h$;l.destinationState=s,l.duration=r,l.exitTime=i,l.offset=a,o.addTransition(l)})})}n.addLayer(c)}),Promise.all(i).then(function(e){e.forEach(function(e){var t=e.layerIndex,r=e.stateIndex,a=e.clip;n.layers[t].stateMachine.states[r].clip=a}),r(n)})}).catch(a)})},or);d7=dz([uC(e.AssetType.AnimatorController,["json"],!1)],d7);var d9=(dU(oa=function(){return hE.apply(this,arguments)},hE),oa.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new uT(function(e){var n=t.slice(13+RegExp.$1.length);e(Uint8Array.from(atob(n),function(e){return e.charCodeAt(0)}).buffer)}):this.request(t,dO({},e,{type:"arraybuffer"}))},oa);d9=dz([uC(e.AssetType.Buffer,["bin","r3bin"],!1)],d9);var _e=(dU(oi=function(){return hE.apply(this,arguments)},hE),oi.prototype.load=function(t,n){var r=this;return new uT(function(a,i){r.request(t.url,{type:"arraybuffer"}).then(function(t){var r=new Float32Array(t,0,27),i=new Uint16Array(t,108,1)[0],o=n.engine,s=new ct(o,i);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var h=i>>u,d=0;d<6;d++){var _=h*h*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+d,f,u)}var p=new u7(o),g=new lV;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,g.copyFromArray(r),p.diffuseSphericalHarmonics=g,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,a(p)}).catch(function(e){i(e)})})},oi);function _t(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 _n(e){return function(){var t=this,n=arguments;return new Promise(function(r,a){var i=e.apply(t,n);function o(e){_t(i,r,a,o,s,"next",e)}function s(e){_t(i,r,a,o,s,"throw",e)}o(void 0)})}}_e=dz([uC(e.AssetType.Env,["env"])],_e);var _r=(dU(oo=function(){return hE.apply(this,arguments)},hE),(os=oo.prototype).load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,{type:"json"}).then(function(e){var i=e.fontName,o=e.fontUrl;o?n._registerFont(i,o).then(function(){r(new ci(t.engine,i))}).catch(function(e){a("load font "+o+" fail")}):r(new ci(t.engine,i))}).catch(function(e){a(e)})})},os._registerFont=function(e,t){return _n(function(){var n;return dk(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]}})})()},oo);_r=dz([uC(e.AssetType.Font,["font"],!1)],_r);var _a=(dU(ol=function(e,t){var n;return(n=lZ.call(this,e)||this).url=t,n},lZ),ol);(oc=la||(la={}))[oc.BYTE=5120]="BYTE",oc[oc.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",oc[oc.SHORT=5122]="SHORT",oc[oc.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",oc[oc.UNSIGNED_INT=5125]="UNSIGNED_INT",oc[oc.FLOAT=5126]="FLOAT",(ou=li||(li={})).SCALAR="SCALAR",ou.VEC2="VEC2",ou.VEC3="VEC3",ou.VEC4="VEC4",ou.MAT2="MAT2",ou.MAT3="MAT3",ou.MAT4="MAT4",(oh=lo||(lo={})).TRANSLATION="translation",oh.ROTATION="rotation",oh.SCALE="scale",oh.WEIGHTS="weights",(od=ls||(ls={})).Linear="LINEAR",od.Step="STEP",od.CubicSpine="CUBICSPLINE",(o_=ll||(ll={})).PERSPECTIVE="perspective",o_.ORTHOGRAPHIC="orthographic",(of=lc||(lc={})).JPEG="image/jpeg",of.PNG="image/png",(op=lu||(lu={})).OPAQUE="OPAQUE",op.MASK="MASK",op.BLEND="BLEND",(og=lh||(lh={}))[og.NEAREST=9728]="NEAREST",og[og.LINEAR=9729]="LINEAR",(om=ld||(ld={}))[om.NEAREST=9728]="NEAREST",om[om.LINEAR=9729]="LINEAR",om[om.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",om[om.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",om[om.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",om[om.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(ov=l_||(l_={}))[ov.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",ov[ov.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",ov[ov.REPEAT=10497]="REPEAT";var _i=((ox=(oy=function(e,t,n){this.glTFResource=e,this.resourceManager=t,this.keepMeshData=n,this.accessorBufferCache={},this._resourceCache=new Map,this.contentRestorer=new _v(e)}).prototype).get=function(e,t){var n=this,r=oy._parsers[e];if(!r)return Promise.resolve(null);var a=this._resourceCache,i=0===e||1===e,o=i||void 0===t?""+e:e+":"+t,s=a.get(o);if(s)return s;if(i)s=r.parse(this);else{var l=this.glTF[_s[e]];l&&(void 0===t||l[t])?void 0===t?s=7===e?l.map(function(t,r){return n.get(e,r)}):Promise.all(l.map(function(t,r){return n.get(e,r)})):(s=r.parse(this,t),this._handleSubAsset(s,e,t)):s=Promise.resolve(null)}return a.set(o,s),s},ox.parse=function(){var e=this;return this.get(0).then(function(t){return e.glTF=t,Promise.all([e.get(1),e.get(4),e.get(5),e.get(6),e.get(8),e.get(9),e.get(2)]).then(function(){return e.resourceManager.addContentRestorer(e.contentRestorer),e.glTFResource})})},ox._handleSubAsset=function(e,t,n){var r,a=this,i=_l[t];if(i){if(7===t)((r=this.glTFResource)[i]||(r[i]=[]))[n]=e;else{var o=this.glTFResource.url;e.then(function(e){if(((r=a.glTFResource)[i]||(r[i]=[]))[n]=e,6===t)for(var r,s,l=0,c=e.length;l<c;l++){var u=e[l];a.resourceManager._onSubAssetSuccess(o+"?q="+i+"["+n+"]["+l+"]",u)}else a.resourceManager._onSubAssetSuccess(o+"?q="+i+"["+n+"]",e),2===t&&(null!=(s=a.glTF.scene)?s:0)===n&&a.resourceManager._onSubAssetSuccess(""+o+"?q=defaultSceneRoot",e)})}}},oy.addParser=function(e,t){this._parsers[e]=t},oy);_i._parsers={};var _o=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}};e.GLTFParserType=void 0,(oT=e.GLTFParserType||(e.GLTFParserType={}))[oT.Schema=0]="Schema",oT[oT.Validator=1]="Validator",oT[oT.Scene=2]="Scene",oT[oT.Buffer=3]="Buffer",oT[oT.Texture=4]="Texture",oT[oT.Material=5]="Material",oT[oT.Mesh=6]="Mesh",oT[oT.Entity=7]="Entity",oT[oT.Skin=8]="Skin",oT[oT.Animation=9]="Animation";var _s=((lf={})[2]="scenes",lf[3]="buffers",lf[4]="textures",lf[5]="materials",lf[6]="meshes",lf[7]="nodes",lf[8]="skins",lf[9]="animations",lf),_l=((lp={})[2]="sceneRoots",lp[4]="textures",lp[5]="materials",lp[6]="meshes",lp[7]="entities",lp[8]="skins",lp[9]="animations",lp);function _c(e){return function(t){var n=new t;_i.addParser(e,n)}}var _u=((oS=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new lL(e[r],e[r+1]);return n},oS.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new lS(e[r],e[r+1],e[r+2]);return n},oS.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new lD(e[r],e[r+1],e[r+2],e[r+3]);return n},oS.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 lB(e[a],e[a+1],e[a+2],1);else for(var i=0;i<n;i+=4)r[i/4]=new lB(e[i],e[i+1],e[i+2],e[i+3]);return r},oS.getAccessorTypeSize=function(e){switch(e){case li.SCALAR:return 1;case li.VEC2:return 2;case li.VEC3:return 3;case li.VEC4:case li.MAT2:return 4;case li.MAT3:return 9;case li.MAT4:return 16}},oS.getComponentType=function(e){switch(e){case la.BYTE:return Int8Array;case la.UNSIGNED_BYTE:return Uint8Array;case la.SHORT:return Int16Array;case la.UNSIGNED_SHORT:return Uint16Array;case la.UNSIGNED_INT:return Uint32Array;case la.FLOAT:return Float32Array}},oS.getNormalizedComponentScale=function(e){switch(e){case la.BYTE:return 1/127;case la.UNSIGNED_BYTE:return 1/255;case la.SHORT:return 1/32767;case la.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},oS.getAccessorBuffer=function(t,n,r){var a=r.componentType,i=n[r.bufferView];return t.get(e.GLTFParserType.Buffer).then(function(e){var o,s,l,c=i.buffer,u=e[c],h=null!=(o=i.byteOffset)?o:0,d=null!=(s=r.byteOffset)?s:0,_=oS.getComponentType(a),f=oS.getAccessorTypeSize(r.type),p=_.BYTES_PER_ELEMENT,g=f*p,m=r.count,v=i.byteStride;if(void 0!==v&&v!==g){var y=Math.floor(d/v),x=r.bufferView+":"+a+":"+y+":"+m,T=t.accessorBufferCache;if(!(l=T[x])){var S=h+y*v,C=m*(v/p),A=new _(u,S,C);T[x]=l=new _o(A,!0,v),l.restoreInfo=new _C(new _A(c,_,S,C))}}else{var w=h+d,E=m*f,b=new _(u,w,E);(l=new _o(b,!1,g)).restoreInfo=new _C(new _A(c,_,w,E))}return r.sparse&&oS.processingSparseData(n,r,e,l),l})},oS.bufferToVector3Array=function(e,t,n,r){for(var a=e.BYTES_PER_ELEMENT,i=n%t/a,o=t/a,s=Array(r),l=0;l<r;l++){var c=i+l*o;s[l]=new lS(e[c],e[c+1],e[c+2])}return s},oS.getAccessorData=function(e,t,n){var r=e.bufferViews,a=r[t.bufferView],i=n[a.buffer],o=t.hasOwnProperty("byteOffset")?t.byteOffset:0,s=a.hasOwnProperty("byteOffset")?a.byteOffset:0,l=o+s,c=oS.getAccessorTypeSize(t.type),u=c*t.count,h=null!=(v=a.byteStride)?v:0,d=oS.getComponentType(t.componentType);if(h){var _=c*d.BYTES_PER_ELEMENT;y=new Uint8Array(t.count*_);for(var f=new Uint8Array(i,s,a.byteLength),p=0;p<t.count;p++)for(var g=0;g<_;g++)y[p*_+g]=f[p*h+o+g]}else y=new Uint8Array(i.slice(l,l+u*d.BYTES_PER_ELEMENT));var m=new d(y.buffer);if(t.sparse)for(var v,y,x,T,S,C,A=t.sparse,w=A.count,E=A.indices,b=A.values,M=r[E.bufferView],F=r[b.bufferView],R=n[M.buffer],P=n[F.buffer],L=(null!=(x=E.byteOffset)?x:0)+(null!=(T=M.byteOffset)?T:0),D=M.byteLength,B=(null!=(S=b.byteOffset)?S:0)+(null!=(C=F.byteOffset)?C:0),I=F.byteLength,V=oS.getComponentType(E.componentType),O=new V(R,L,D/V.BYTES_PER_ELEMENT),N=new d(P,B,I/d.BYTES_PER_ELEMENT),U=0;U<w;U++)for(var z=O[U],k=0;k<c;k++)m[z*c+k]=N[U*c+k];return m},oS.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},oS.processingSparseData=function(e,t,n,r){var a,i,o,s,l=r.restoreInfo,c=oS.getAccessorTypeSize(t.type),u=oS.getComponentType(t.componentType),h=r.data.slice(),d=t.sparse,_=d.count,f=d.indices,p=d.values,g=e[f.bufferView],m=e[p.bufferView],v=g.buffer,y=m.buffer,x=n[v],T=n[y],S=(null!=(a=f.byteOffset)?a:0)+(null!=(i=g.byteOffset)?i:0),C=g.byteLength,A=(null!=(o=p.byteOffset)?o:0)+(null!=(s=m.byteOffset)?s:0),w=m.byteLength;l.typeSize=c,l.sparseCount=_;var E=oS.getComponentType(f.componentType),b=C/E.BYTES_PER_ELEMENT,M=new E(x,S,b);l.sparseIndices=new _A(v,E,S,b);var F=w/u.BYTES_PER_ELEMENT,R=new u(T,A,F);l.sparseValues=new _A(y,u,A,F);for(var P=0;P<_;P++)for(var L=M[P],D=0;D<c;D++)h[L*c+D]=R[P*c+D];r.data=h},oS.getIndexFormat=function(t){switch(t){case la.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case la.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case la.UNSIGNED_INT:return e.IndexFormat.UInt32}},oS.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==la.FLOAT)switch(n){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==la.SHORT)switch(n){case 2:return r?e.VertexElementFormat.NormalizedShort2:e.VertexElementFormat.Short2;case 3:case 4:return r?e.VertexElementFormat.NormalizedShort4:e.VertexElementFormat.Short4}if(t==la.UNSIGNED_SHORT)switch(n){case 2:return r?e.VertexElementFormat.NormalizedUShort2:e.VertexElementFormat.UShort2;case 3:case 4:return r?e.VertexElementFormat.NormalizedUShort4:e.VertexElementFormat.UShort4}if(t==la.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==la.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},oS.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)})},oS.parseGLB=function(e,t){var n={JSON:1313821514,BIN:5130562},r=new DataView(t),a={magic:r.getUint32(0,!0),version:r.getUint32(4,!0),length:r.getUint32(8,!0)};if(1179937895!==a.magic)return console.error("Invalid glb magic number. Expected 0x46546C67, found 0x"+a.magic.toString(16)),null;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(c_.decodeText(s)),c=[],u=20+i,h=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 d=u+8,_=t.slice(d,d+i);c.push(_),h.push(new lL(d,i)),u+=i+8}return{glTF:l,buffers:c}},oS.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)},oS.getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,a=t.wrapS,i=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=ld.NEAREST_MIPMAP_NEAREST,r===lh.NEAREST?o.filterMode=e.TextureFilterMode.Point:n<=ld.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},oS);(oC=lg||(lg={}))[oC.linear=1]="linear",oC[oC.sRGB=2]="sRGB",(oA=lm||(lm={}))[oA.ETC1S=163]="ETC1S",oA[oA.UASTC=166]="UASTC",(ow=lv||(lv={}))[ow.None=0]="None",ow[ow.BasisLZ=1]="BasisLZ",ow[ow.Zstd=2]="Zstd",ow[ow.ZLib=3]="ZLib";var _h=((oE=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,n=e.byteOffset,r=new dW(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(),h=Array(a),d=new dW(e,r.offset,24*a);this.levels=h;for(var _=0;_<a;_++)h[_]={levelData:new Uint8Array(t,n+d.nextUint64(),d.nextUint64()),uncompressedByteLength:d.nextUint64()};var f=new dW(e,i,o),p={vendorId:f.skip(4).nextUint16(),descriptorType:f.nextUint16(),versionNumber:f.nextUint16(),descriptorBlockSize:f.nextUint16(),colorModel:f.nextUint8(),colorPrimaries:f.nextUint8(),transferFunction:f.nextUint8(),flags:f.nextUint8(),texelBlockDimension:[f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8()],bytesPlane:[f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8()],samples:[]};this.dataFormatDescriptor=p;for(var g=(p.descriptorBlockSize/4-6)/4,m=0;m<g;m++){var v={bitOffset:f.nextUint16(),bitLength:f.nextUint8(),channelType:f.nextUint8(),samplePosition:[f.nextUint8(),f.nextUint8(),f.nextUint8(),f.nextUint8()],sampleLower:-1/0,sampleUpper:1/0};64&v.channelType?(v.sampleLower=f.nextInt32(),v.sampleUpper=f.nextInt32()):(v.sampleLower=f.nextUint32(),v.sampleUpper=f.nextUint32()),p.samples[m]=v}for(var y=new dW(e,s,l,!0);y.position<l;){var x=y.nextUint32(),T=y.scan(x),S=c_.decodeText(T),C=y.nextUint8Array(x-T.byteLength-1);this.keyValue[S]=S.match(/^ktx/i)?c_.decodeText(C).replace(/^(.*)\x00$/,"$1"):C;var A=x%4?4-x%4:0;y.skip(A)}if(u<=0)return this;for(var w=new dW(e,c,u,!0),E=w.nextUint16(),b=w.nextUint16(),M=w.nextUint32(),F=w.nextUint32(),R=w.nextUint32(),P=w.nextUint32(),L=Array(a),D=0;D<a;D++)L[D]={imageFlags:w.nextUint32(),rgbSliceByteOffset:w.nextUint32(),rgbSliceByteLength:w.nextUint32(),alphaSliceByteOffset:w.nextUint32(),alphaSliceByteLength:w.nextUint32()};var B=c+w.offset,I=B+M,V=I+F,O=new Uint8Array(t,n+B,M),N=new Uint8Array(t,n+I,F),U=new Uint8Array(t,n+V,R),z=new Uint8Array(t,n+(V+R),P);this.globalData={endpointCount:E,selectorCount:b,imageDescs:L,endpointsData:O,selectorsData:N,tablesData:U,extendedData:z}},dH(oE,[{key:"isSRGB",get:function(){return 2===this.dataFormatDescriptor.transferFunction}},{key:"isUASTC",get:function(){return 166===this.dataFormatDescriptor.colorModel}}]),oE);e.KTX2TargetFormat=void 0,(ob=e.KTX2TargetFormat||(e.KTX2TargetFormat={}))[ob.ASTC=0]="ASTC",ob[ob.BC7=1]="BC7",ob[ob.BC1_BC3=2]="BC1_BC3",ob[ob.PVRTC=3]="PVRTC",ob[ob.ETC=4]="ETC",ob[ob.R8=5]="R8",ob[ob.R8G8=6]="R8G8",ob[ob.R8G8B8A8=7]="R8G8B8A8";var _d=((oF=(oM=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),n=0;n<e;n++)t.push(this._initWorker(n));return Promise.all(t)},oF.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})})},oF.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},oF._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})},oF._getIdleWorkerId=function(){for(var e=0,t=this.limitedCount;e<t;e++)if(!(this._workerStatus&1<<e))return e;return -1},oF._onMessage=function(e,t){var n=t.data.error;n?this._workerItems[e].reject(n):this._workerItems[e].resolve(t.data),this._nextTask(e)},oF._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},oM),__=((oP=(oR=function(e){this.workerLimitCount=e}).prototype).init=function(){return this._initPromise||(this._initPromise=this._initTranscodeWorkerPool()),this._initPromise},oP.destroy=function(){this._transcodeWorkerPool.destroy()},oP._createTranscodePool=function(e,t){return this._transcodeWorkerPool=new _d(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()},oR);function _f(){var e,t,n,r,a,i=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},o=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}},s=function(e,t,n){var r=function(){a.close(),a.delete()},a=new n(new Uint8Array(e));if(!a.isValid())throw r(),Error("Invalid or unsupported .ktx2 file");for(var s=a.getWidth(),l=a.getHeight(),c=a.getLayers()||1,u=a.getLevels(),h=a.getHasAlpha(),d=a.getFaces(),_=o(t,h),f=Array(d),p=0;p<d;p++){for(var g=Array(u),m=0;m<u;m++){for(var v=Array(c),y=void 0,x=void 0,T=0;T<c;T++){var S=a.getImageLevelInfo(m,T,p);y=S.origWidth,x=S.origHeight;var C=new Uint8Array(a.getImageTranscodedSizeInBytes(m,T,0,_));if(!a.transcodeImage(C,m,T,p,_,0,-1,-1))throw r(),Error("transcodeImage failed.");v[T]=C}g[m]={data:i(v),width:y,height:x}}f[p]=g}return r(),{faces:f,width:s,height:l,hasAlpha:h,faceCount:d,format:_}};(e=r||(r={}))[e.ETC1=0]="ETC1",e[e.ETC2=1]="ETC2",e[e.BC1=2]="BC1",e[e.BC3=3]="BC3",e[e.BC4=4]="BC4",e[e.BC5=5]="BC5",e[e.BC7=7]="BC7",e[e.PVRTC1_4_RGB=8]="PVRTC1_4_RGB",e[e.PVRTC1_4_RGBA=9]="PVRTC1_4_RGBA",e[e.ASTC_4x4=10]="ASTC_4x4",e[e.RGBA8=13]="RGBA8",(t=a||(a={}))[t.ASTC=0]="ASTC",t[t.BC7=1]="BC7",t[t.BC1_BC3=2]="BC1_BC3",t[t.PVRTC=3]="PVRTC",t[t.ETC=4]="ETC",t[t.R8=5]="R8",t[t.RG8=6]="RG8",t[t.RGBA8=7]="RGBA8",self.onmessage=function(e){var t,r=e.data;switch(r.type){case"init":(t=r.transcoderWasm,n=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})).then(function(){return self.postMessage("init-completed")}).catch(function(e){return self.postMessage({error:e})});break;case"transcode":n.then(function(e){var t=s(r.buffer,r.format,e);t.type="transcoded",self.postMessage(t)}).catch(function(e){return self.postMessage({error:e})})}}}var _p=(dU(oL=function(e){return __.call(this,e)},__),(oD=oL.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 n=t[0],r=t[1],a=_f.toString(),i=a.substring(a.indexOf("{"),a.lastIndexOf("}")+1),o=URL.createObjectURL(new Blob(["\n "+n+"\n "+i+"\n "],{type:"application/javascript"}));return e._createTranscodePool(o,r)})},oD.transcode=function(e,t){return this._transcodeWorkerPool.postMessage({buffer:e,format:t,type:"transcode"})},oL);function _g(){var e,t,n,r=function(e,t,n,r){var a=(n+3>>2)*(r+3>>2),i=e.memory,o=(16*a+65535>>16)+1-(i.buffer.byteLength>>16);o>0&&i.grow(o);var s=new Uint8Array(i.buffer,65536,16*a);return s.set(t),0===e.transcode(a)?s:null},a=function(e,t,n){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 h=e[s][u],d=h.buffer,_=h.levelHeight,f=h.levelWidth,p=h.uncompressedByteLength;t&&(d=o.decode(d.slice(),p));var g=d.byteLength/a,m=d.byteOffset,v=r(n,new Uint8Array(d.buffer,m+s*g,g),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,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);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,r=e.data;switch(r.type){case"init":(t=r.transcoderWasm,n=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":n.then(function(e){a(r.data,r.needZstd,e).then(function(e){self.postMessage(e)}).catch(function(e){return self.postMessage({error:e})})})}}}var _m=(dU(oB=function(e,t){var n;return(n=__.call(this,e)||this).type=t,n},__),(oI=oB.prototype)._initTranscodeWorkerPool=function(){var e=this;return fetch(oB.transcoderMap[this.type]).then(function(e){return e.arrayBuffer()}).then(function(t){var n=_g.toString(),r=URL.createObjectURL(new Blob([n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))],{type:"application/javascript"}));return e._createTranscodePool(r,t)})},oI.transcode=function(e){for(var t=e.supercompressionScheme===lv.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],h=Math.floor(e.pixelWidth/(1<<c))||1,d=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:h,levelHeight:d,uncompressedByteLength:u.uncompressedByteLength}}o[s]=l}return this._transcodeWorkerPool.postMessage(i).then(function(e){return a.faces=e,a.hasAlpha=!0,a})},oB);_m.transcoderMap=((oV={})[e.KTX2TargetFormat.ASTC]="https://mdn.alipayobjects.com/rms/afts/file/A*0jiKRK6D1-kAAAAAAAAAAAAAARQnAQ/uastc_astc.wasm",oV),e.KTX2Loader=(dU(oO=function(){return hE.apply(this,arguments)},hE),(oN=oO.prototype).initialize=function(t,n){if(n.ktx2Loader){var r=n.ktx2Loader;return this._isKhronosSupported(r.priorityFormats,t)?e.KTX2Loader._getKhronosTranscoder(r.workerCount).init():e.KTX2Loader._getBinomialLLCTranscoder(r.workerCount).init()}},oN.load=function(t,n){return this.request(t.url,{type:"arraybuffer"}).then(function(r){return e.KTX2Loader._parseBuffer(new Uint8Array(r),n.engine,t.params).then(function(t){var n=t.engine,r=t.result,a=t.targetFormat,i=t.params;return e.KTX2Loader._createTextureByBuffer(n,r,a,i)})})},oN._isKhronosSupported=function(t,n){void 0===t&&(t=[e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC,e.KTX2TargetFormat.R8G8B8A8]);var r=[];if(Array.isArray(t[0]))for(var a=0;a<t.length;a++)r.push(e.KTX2Loader._detectSupportedFormat(n._hardwareRenderer,t[a]));else r.push(e.KTX2Loader._detectSupportedFormat(n._hardwareRenderer,t));return r.every(function(e){return _m.transcoderMap[e]})},oO.destroy=function(){this._binomialLLCTranscoder&&this._binomialLLCTranscoder.destroy(),this._khronosTranscoder&&this._khronosTranscoder.destroy(),this._binomialLLCTranscoder=null,this._khronosTranscoder=null,this._isBinomialInit=!1},oO._parseBuffer=function(t,n,r){var a,i=new _h(t),o=null==r?void 0:r.priorityFormats,s=e.KTX2Loader._decideTargetFormat(n,i,o);if(!e.KTX2Loader._isBinomialInit&&_m.transcoderMap[s]&&i.isUASTC){var l=e.KTX2Loader._getKhronosTranscoder();a=l.init().then(function(){return l.transcode(i)})}else{var c=e.KTX2Loader._getBinomialLLCTranscoder();a=c.init().then(function(){return c.transcode(t,s)})}return a.then(function(e){return{engine:n,result:e,targetFormat:s,params:i.keyValue.GalaceanTextureParams}})},oO._createTextureByBuffer=function(t,n,r,a){var i,o=n.width,s=n.height,l=n.faces,c=l.length,u=l[0],h=u.length>1,d=this._getEngineTextureFormat(r,n);if(6!==c){i=new l9(t,o,s,d,h);for(var _=0;_<u.length;_++){var f=u[_].data;i.setPixelBuffer(f,_)}}else{i=new ct(t,s,d,h);for(var p=0;p<l.length;p++)for(var g=l[p],m=0;m<u.length;m++)i.setPixelBuffer(e.TextureCubeFace.PositiveX+p,g[m].data,m)}return a&&(i.wrapModeU=a[0],i.wrapModeV=a[1],i.filterMode=a[2],i.anisoLevel=a[3]),i},oO._decideTargetFormat=function(t,n,r){var a=t._hardwareRenderer,i=this._detectSupportedFormat(a,r);return i!==e.KTX2TargetFormat.PVRTC||lT.isPowerOf2(n.pixelWidth)&&lT.isPowerOf2(n.pixelHeight)&&n.pixelWidth===n.pixelHeight?null===i?(l8.warn("Can't support any compressed texture, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8):i:(l8.warn("PVRTC image need power of 2 and width===height, downgrade to RGBA8"),e.KTX2TargetFormat.R8G8B8A8)},oO._detectSupportedFormat=function(t,n){void 0===n&&(n=[e.KTX2TargetFormat.ASTC,e.KTX2TargetFormat.ETC,e.KTX2TargetFormat.BC7,e.KTX2TargetFormat.BC1_BC3,e.KTX2TargetFormat.PVRTC]);for(var r=0;r<n.length;r++)for(var a=this._supportedMap[n[r]],i=0;i<a.length;i++)if(t.canIUse(a[i]))return n[r];return null},oO._getBinomialLLCTranscoder=function(t){var n;return void 0===t&&(t=4),e.KTX2Loader._isBinomialInit=!0,null!=(n=this._binomialLLCTranscoder)?n:this._binomialLLCTranscoder=new _p(t)},oO._getKhronosTranscoder=function(t){var n;return void 0===t&&(t=4),null!=(n=this._khronosTranscoder)?n:this._khronosTranscoder=new _m(t,e.KTX2TargetFormat.ASTC)},oO._getEngineTextureFormat=function(t,n){var r=n.hasAlpha;switch(t){case e.KTX2TargetFormat.ASTC:return e.TextureFormat.ASTC_4x4;case e.KTX2TargetFormat.ETC:return r?e.TextureFormat.ETC2_RGBA8:e.TextureFormat.ETC2_RGB;case e.KTX2TargetFormat.BC7:return e.TextureFormat.BC7;case e.KTX2TargetFormat.BC1_BC3:return r?e.TextureFormat.BC3:e.TextureFormat.BC1;case e.KTX2TargetFormat.PVRTC:return r?e.TextureFormat.PVRTC_RGBA4:e.TextureFormat.PVRTC_RGB4;case e.KTX2TargetFormat.R8G8B8A8:return e.TextureFormat.R8G8B8A8}},(ly=oO)._isBinomialInit=!1,ly._supportedMap=((oU={})[e.KTX2TargetFormat.ASTC]=[e.GLCapabilityType.astc],oU[e.KTX2TargetFormat.ETC]=[e.GLCapabilityType.etc],oU[e.KTX2TargetFormat.BC7]=[e.GLCapabilityType.bptc],oU[e.KTX2TargetFormat.BC1_BC3]=[e.GLCapabilityType.s3tc],oU[e.KTX2TargetFormat.PVRTC]=[e.GLCapabilityType.pvrtc,e.GLCapabilityType.pvrtc_webkit],oU),ly),e.KTX2Loader=dz([uC(e.AssetType.KTX2,["ktx2"])],e.KTX2Loader);var _v=(dU(oz=function(){var e;return e=l$.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},l$),(ok=oz.prototype).restoreContent=function(){var t=this;return new uT(function(n,r){Promise.all(t.bufferRequests.map(function(e){return hS(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)}}uT.all(t.bufferTextures.map(function(t){var n,r=t.bufferView,i=a[r.buffer],o=new Uint8Array(i,null!=(n=r.byteOffset)?n:0,r.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],n=0;n<t.length;n++)s.setPixelBuffer(t[n].data,n)}):_u.loadImageBuffer(o,t.mimeType).then(function(e){s.setImageSource(e),s.generateMipmaps()})})).then(function(){for(var e,r=d3(t.meshes);!(e=r()).done;){for(var i,o=e.value,s=o.mesh,l=d3(o.vertexBuffers);!(i=l()).done;){var c=i.value,u=t._getBufferData(a,c.data);c.buffer.setData(u)}if(o.indexBuffer){var h=t._getBufferData(a,o.indexBuffer);s.setIndices(h)}for(var d,_=d3(o.blendShapes);!(d=_()).done;){var f=d.value,p=f.blendShape.frames[0],g=f.position,m=t._getBufferData(a,g.buffer);if(p.deltaPositions=_u.bufferToVector3Array(m,g.stride,g.byteOffset,g.count),f.normal){var v=f.normal,y=t._getBufferData(a,v.buffer);p.deltaNormals=_u.bufferToVector3Array(y,v.stride,v.byteOffset,v.count)}if(f.tangent){var x=f.tangent,T=t._getBufferData(a,x.buffer);p.deltaTangents=_u.bufferToVector3Array(T,x.stride,x.byteOffset,x.count)}}s.uploadData(!0)}n(t.resource)}).catch(r)}).catch(r)})},ok._getBufferData=function(e,t){var n=t.main,r=e[n.bufferIndex],a=new n.TypedArray(r,n.byteOffset,n.length),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],h=new c.TypedArray(u,c.byteOffset,c.length),d=t.typeSize,_=0;_<i;_++)for(var f=l[_],p=0;p<d;p++)a[f*d+p]=h[_*d+p];return a},oz),_y=function(e,t){this.url=e,this.config=t},_x=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},_T=function(){this.vertexBuffers=[],this.blendShapes=[]},_S=function(e,t){this.buffer=e,this.data=t},_C=function(e,t,n,r,a){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=a},_A=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},_w=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},_E=function(e,t,n,r){this.buffer=e,this.stride=t,this.byteOffset=n,this.count=r};function _b(e){return function(e){if(Array.isArray(e))return d1(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||d2(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var _M=((oH=(oG=function(){}).prototype).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."},oH.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."},oG);e.GLTFExtensionMode=void 0,(oW=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[oW.CreateAndParse=0]="CreateAndParse",oW[oW.AdditiveParse=1]="AdditiveParse";var _F=((oX=function(){}).executeExtensionsCreateAndParse=function(e,t,n){void 0===e&&(e={});for(var r=arguments.length,a=Array(r>3?r-3:0),i=3;i<r;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=oX._createAndParse.apply(oX,[c,t,u,n].concat(_b(a))))return o}},oX.executeExtensionsAdditiveAndParse=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];for(var s in e){var l=e[s];oX._additiveParse.apply(oX,[s,t,n,l,r].concat(_b(i)))}},oX.hasExtensionParser=function(e){var t;return!!(null==(t=oX._extensionParsers[e])?void 0:t.length)},oX.getExtensionParser=function(e,t){var n=oX._extensionParsers[e],r=null==n?void 0:n.length;if(r)for(var a=r-1;a>=0;--a){var i=n[a];if(i._mode===t)return i}},oX._addExtensionParser=function(e,t){oX._extensionParsers[e]||(oX._extensionParsers[e]=[]),oX._extensionParsers[e].push(t)},oX._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=oX.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,a].concat(_b(o)))},oX._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=oX.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[n,r,a,i].concat(_b(s)))},oX);function _R(e,t){return function(n){var r=new n;r._mode=t,_F._addExtensionParser(e,r)}}function _P(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}_F._extensionParsers={},e.GLTFSchemaParser=(dU(oK=function(){return _F.apply(this,arguments)},_F),(oj=oK.prototype).parse=function(e){var t=e.glTFResource,n=e.contentRestorer,r=t.url,a=n.bufferRequests,i={type:"arraybuffer"},o=this._isGLB(r);return n.isGLB=o,o?hS(r,i).then(function(t){return a.push(new _y(r,i)),_u.parseGLB(e,t)}).then(function(t){var n=t.glTF,r=t.buffers;return e.buffers=r,n}):hS(r,{type:"json"})},oj._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},oK),e.GLTFSchemaParser=dz([_c(e.GLTFParserType.Schema)],e.GLTFSchemaParser),e.GLTFAnimationParser=(dU(oq=function(){return _F.apply(this,arguments)},_F),oq.prototype.parse=function(t,n){var r=t.glTF.animations[n],a=r.name;return Promise.resolve(_F.executeExtensionsCreateAndParse(r.extensions,t,r)||e.GLTFAnimationParser._parseStandardProperty(t,new hQ(void 0===a?"AnimationClip"+n:a),r)).then(function(e){return _F.executeExtensionsAdditiveAndParse(r.extensions,t,e,r),e})},oq._parseStandardProperty=function(t,n,r){for(var a=this,i=t.glTF,o=i.accessors,s=i.bufferViews,l=r.channels,c=r.samplers,u=[],h=t.get(e.GLTFParserType.Entity),d=[],_=0,f=c.length;_<f;_++)!function(n,r){var a=c[n],i=o[a.input],l=o[a.output],h=Promise.all([_u.getAccessorBuffer(t,s,i),_u.getAccessorBuffer(t,s,l)]).then(function(t){var n,r,i=t[0].data,o=t[1].data;if(l.normalized){for(var s=_u.getNormalizedComponentScale(l.componentType),c=new Float32Array(o.length),h=0,d=o.length;h<d;h++)c[h]=o[h]*s;o=c}var _=o.length/i.length;switch(null!=(n=a.interpolation)?n:ls.Linear){case ls.CubicSpine:r=e.InterpolationType.CubicSpine;break;case ls.Step:r=e.InterpolationType.Step;break;case ls.Linear:r=e.InterpolationType.Linear}i[i.length-1],u.push({type:l.type,interpolation:r,input:i,output:o,outputSize:_})});d.push(h)}(_);return Promise.all(d).then(function(){for(var e=0,t=l.length;e<t;e++){for(var r=l[e],i=r.target,o=h[i.node],s="",c=o;c.parent;)s=""===s?""+c.name:c.name+"/"+s,c=c.parent;var d=void 0,_=void 0;switch(i.path){case lo.TRANSLATION:d=cy,_="position";break;case lo.ROTATION:d=cy,_="rotationQuaternion";break;case lo.SCALE:d=cy,_="scale";break;case lo.WEIGHTS:d=ud,_="blendShapeWeights"}var f=a._addCurve(i.path,r,u);n.addCurveBinding(s,d,_,f)}return n})},oq._addCurve=function(t,n,r){var a=r[n.sampler],i=a.input,o=a.output,s=a.outputSize;switch(t){case lo.TRANSLATION:case lo.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=a.interpolation,u=0,h=0,d=i.length;h<d;h++){var _=new h9;_.time=i[h],c===e.InterpolationType.CubicSpine?(_.inTangent=new lS(o[u++],o[u++],o[u++]),_.value=new lS(o[u++],o[u++],o[u++]),_.outTangent=new lS(o[u++],o[u++],o[u++])):_.value=new lS(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case lo.ROTATION:for(var f=new e.AnimationQuaternionCurve,p=f.interpolation=a.interpolation,g=0,m=0,v=i.length;m<v;m++){var y=new h9;y.time=i[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new lD(o[g++],o[g++],o[g++],o[g++]),y.value=new lF(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new lD(o[g++],o[g++],o[g++],o[g++])):y.value=new lF(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case lo.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=a.interpolation;for(var T=0,S=0,C=i.length;S<C;S++){var A=new h9;A.time=i[S],x.interpolation===e.InterpolationType.CubicSpine?(A.inTangent=Array.from(o.subarray(T,T+s)),T+=s,A.value=o.subarray(T,T+s),T+=s,A.outTangent=Array.from(o.subarray(T,T+s)),T+=s):(A.value=o.subarray(T,T+s),T+=s),x.addKey(A)}return x}},oq),e.GLTFAnimationParser=dz([_c(e.GLTFParserType.Animation)],e.GLTFAnimationParser),e.GLTFBufferParser=(dU(oY=function(){return _F.apply(this,arguments)},_F),(oQ=oY.prototype).parse=function(e,t){var n=e.glTF.buffers;return e.buffers?Promise.resolve(e.buffers[t]):this._parseSingleBuffer(e,n[t])},oQ._parseSingleBuffer=function(e,t){var n=e.glTFResource,r=e.contentRestorer,a=n.url,i=r.bufferRequests,o={type:"arraybuffer"},s=c_.resolveAbsoluteUrl(a,t.uri);return i.push(new _y(s,o)),hS(s,o)},oY),e.GLTFBufferParser=dz([_c(e.GLTFParserType.Buffer)],e.GLTFBufferParser),e.GLTFEntityParser=(dU(oJ=function(){return _F.apply(this,arguments)},_F),oJ.prototype.parse=function(t,n){var r=t.glTF.nodes[n],a=t.glTFResource.engine,i=r.matrix,o=r.translation,s=r.rotation,l=r.scale,c=new cT(a,r.name||"_GLTF_ENTITY_"+n),u=c.transform;if(i){var h=u.localMatrix;h.copyFromArray(i),u.localMatrix=h}else o&&u.setPosition(o[0],o[1],o[2]),s&&u.setRotationQuaternion(s[0],s[1],s[2],s[3]),l&&u.setScale(l[0],l[1],l[2]);var d=r.children;if(d)for(var _=0;_<d.length;_++){var f=d[_],p=t.get(e.GLTFParserType.Entity,f);c.addChild(p)}return c},oJ),e.GLTFEntityParser=dz([_c(e.GLTFParserType.Entity)],e.GLTFEntityParser),e.GLTFMaterialParser=(dU(oZ=function(){return _F.apply(this,arguments)},_F),oZ.prototype.parse=function(t,n){var r=t.glTF.materials[n],a=t.glTFResource.engine,i=_F.executeExtensionsCreateAndParse(r.extensions,t,r);return i||((i=new hR(a)).name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,i,r)),Promise.resolve(i).then(function(n){return n||(n=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),_F.executeExtensionsAdditiveAndParse(r.extensions,t,n,r),n})},oZ._getDefaultMaterial=function(t){var n;return(n=e.GLTFMaterialParser)._defaultMaterial||(n._defaultMaterial=new hM(t))},oZ._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&l8.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},oZ._parseStandardProperty=function(t,n,r){var a=r.pbrMetallicRoughness,i=r.normalTexture,o=r.occlusionTexture,s=r.emissiveTexture,l=r.emissiveFactor,c=r.alphaMode,u=r.alphaCutoff,h=r.doubleSided;if(a){var d=a.baseColorFactor,_=a.baseColorTexture,f=a.metallicFactor,p=a.roughnessFactor,g=a.metallicRoughnessTexture;d&&(n.baseColor=new lB(lB.linearToGammaSpace(d[0]),lB.linearToGammaSpace(d[1]),lB.linearToGammaSpace(d[2]),d[3])),_&&t.get(e.GLTFParserType.Texture,_.index).then(function(e){n.baseTexture=e,_F.executeExtensionsAdditiveAndParse(_.extensions,t,n,_)}),n.constructor===hR&&(n.metallic=null!=f?f:1,n.roughness=null!=p?p:1,g&&(e.GLTFMaterialParser._checkOtherTextureTransform(g,"Roughness metallic"),t.get(e.GLTFParserType.Texture,g.index).then(function(e){n.roughnessMetallicTexture=e})))}if(n.constructor===hR||n.constructor===hP){if(s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Emissive"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){n.emissiveTexture=e})),l&&(n.emissiveColor=new lB(lB.linearToGammaSpace(l[0]),lB.linearToGammaSpace(l[1]),lB.linearToGammaSpace(l[2]))),i){var m=i.index,v=i.scale;e.GLTFMaterialParser._checkOtherTextureTransform(i,"Normal"),t.get(e.GLTFParserType.Texture,m).then(function(e){n.normalTexture=e}),void 0!==v&&(n.normalTextureIntensity=v)}if(o){var y=o.index,x=o.strength,T=o.texCoord;e.GLTFMaterialParser._checkOtherTextureTransform(o,"Occlusion"),t.get(e.GLTFParserType.Texture,y).then(function(e){n.occlusionTexture=e}),void 0!==x&&(n.occlusionTextureIntensity=x),T===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:T>e.TextureCoordinate.UV1&&l8.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(h?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,c){case lu.OPAQUE:n.isTransparent=!1;break;case lu.BLEND:n.isTransparent=!0;break;case lu.MASK:n.alphaCutoff=null!=u?u:.5}},oZ),e.GLTFMaterialParser=dz([_c(e.GLTFParserType.Material)],e.GLTFMaterialParser),e.GLTFMeshParser=(dU(o$=function(){return _F.apply(this,arguments)},_F),o$.prototype.parse=function(t,n){for(var r=function(n,r){var l=a.primitives[n];s[n]=new Promise(function(r){var s=_F.executeExtensionsCreateAndParse(l.extensions,t,l,a);if(s)_P(s,c9)?r(s):s.then(function(e){return r(e)});else{var c=new c9(o,a.name||n+""),u=new _T;u.mesh=c,t.contentRestorer.meshes.push(u),e.GLTFMeshParser._parseMeshFromGLTFPrimitive(t,c,u,a,l,i,function(e){return null},function(e,n){var r=l.targets[n][e];if(!r)return null;var a=i.accessors[r];return _u.getAccessorBuffer(t,t.glTF.bufferViews,a)},function(){var n=i.accessors[l.indices];return t.get(e.GLTFParserType.Buffer).then(function(e){return _u.getAccessorData(i,n,e)})},t.keepMeshData).then(r)}})},a=t.glTF.meshes[n],i=t.glTF,o=t.glTFResource.engine,s=[],l=0,c=a.primitives.length;l<c;l++)r(l);return Promise.all(s)},o$._parseMeshFromGLTFPrimitive=function(t,n,r,a,i,o,s,l,c,u){var h,d=function(a){var i=_[f[a]],s=_u.getAccessorBuffer(t,o.bufferViews,i).then(function(t){var o,s,l,c=_u.getAccessorTypeSize(i.type),d=i.count,_=t.data,f=n.instanceId,p=t.vertexBindingInfos,g=i.normalized,m=_u.getElementFormat(i.componentType,c,g);if(g&&(s=_u.getNormalizedComponentScale(i.componentType)),t.interleaved){var T=i.byteOffset||0,S=t.stride;if(l=T%S,void 0===p[f]){o=new cZ(a,l,m,x);var C=t.vertexBuffer;C||(C=new c$(v,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,u),t.vertexBuffer=C,r.vertexBuffers.push(new _S(C,t.restoreInfo))),n.setVertexBufferBinding(C,S,x),p[f]=x++}else o=new cZ(a,l,m,p[f])}else{l=0,o=new cZ(a,l,m,x);var A=t.vertexBuffer;A||(A=new c$(v,e.BufferBindFlag.VertexBuffer,_,e.BufferUsage.Static,u),r.vertexBuffers.push(new _S(A,t.restoreInfo))),n.setVertexBufferBinding(A,t.stride,x),p[f]=x++}if(y.push(o),"POSITION"===a){h=d;var w=n.bounds,E=w.min,b=w.max;if(i.min&&i.max)E.copyFromArray(i.min),b.copyFromArray(i.max);else{var M=e.GLTFMeshParser._tempVector3;E.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),b.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var F=l/_.BYTES_PER_ELEMENT,R=_.length/d,P=0;P<d;P++){var L=F+P*R;M.copyFromArray(_,L),lS.min(E,M,E),lS.max(b,M,b)}}g&&(E.scale(s),b.scale(s))}});T.push(s)},_=o.accessors,f=i.attributes,p=i.targets,g=i.indices,m=i.mode,v=n.engine,y=[],x=0,T=[];for(var S in f)d(S);return Promise.all(T).then(function(){if(n.setVertexElements(y),void 0!==g){var i=o.accessors[g],s=_u.getAccessorBuffer(t,o.bufferViews,i).then(function(e){n.setIndices(e.data),n.addSubMesh(0,i.count,m),r.indexBuffer=e.restoreInfo});T.push(s)}else n.addSubMesh(0,h,m);return p&&T.push(e.GLTFMeshParser._createBlendShape(n,r,a,_,p,l)),Promise.all(T).then(function(){return n.uploadData(!u),Promise.resolve(n)})})},o$._createBlendShape=function(e,t,n,r,a,i){for(var o=function(n,o){var c=s?s[n]:"blendShape"+n,u=Promise.all([i("POSITION",n),i("NORMAL",n),i("TANGENT",n)]).then(function(i){var o,s,l,u,h,d,_,f,p,g=i[0],m=i[1],v=i[2],y=a[n],x=null;g&&(o=r[y.POSITION],x=_u.bufferToVector3Array(g.data,g.stride,null!=(u=o.byteOffset)?u:0,o.count));var T=null;m&&(s=r[y.NORMAL],T=_u.bufferToVector3Array(m.data,m.stride,null!=(h=s.byteOffset)?h:0,s.count));var S=null;v&&(l=r[y.NORMAL],S=_u.bufferToVector3Array(v.data,v.stride,null!=(d=l.byteOffset)?d:0,l.count));var C=new c5(c);C.addFrame(1,x,T,S),e.addBlendShape(C),t.blendShapes.push(new _w(C,new _E(g.restoreInfo,g.stride,null!=(_=o.byteOffset)?_:0,o.count),m?new _E(m.restoreInfo,m.stride,null!=(f=s.byteOffset)?f:0,s.count):null,v?new _E(v.restoreInfo,v.stride,null!=(p=l.byteOffset)?p:0,l.count):null))});l.push(u)},s=n.extras?n.extras.targetNames:null,l=[],c=0,u=a.length;c<u;c++)o(c);return Promise.all(l)},o$._tempVector3=new lS,o$),e.GLTFMeshParser=dz([_c(e.GLTFParserType.Mesh)],e.GLTFMeshParser),e.GLTFSceneParser=(dU(o0=function(){return _F.apply(this,arguments)},_F),(o1=o0.prototype).parse=function(t,n){var r,a=this,i=t.glTF,o=i.scenes,s=i.scene,l=t.glTFResource,c=o[n],u=l.engine,h=(void 0===s?0:s)===n,d=c.nodes;if(1===d.length)r=t.get(e.GLTFParserType.Entity,d[0]);else{r=new cT(u,"GLTF_ROOT");for(var _=0;_<d.length;_++){var f=t.get(e.GLTFParserType.Entity,d[_]);r.addChild(f)}}r._hookResource=l,l._addReferCount(1),h&&(l.defaultSceneRoot=r);for(var p=[],g=0;g<d.length;g++)p.push(this._parseEntityComponent(t,d[g]));return Promise.all(p).then(function(){return h?Promise.all([t.get(e.GLTFParserType.Skin),t.get(e.GLTFParserType.Animation)]).then(function(e){var n=e[0],i=e[1];return(n||i)&&a._createAnimator(t,i),r}):r})},o1._parseEntityComponent=function(t,n){var r,a=this,i=t.glTF,o=t.glTFResource,s=i.nodes[n],l=s.camera,c=s.mesh,u=s.extensions,h=t.get(e.GLTFParserType.Entity,n);return void 0!==l&&this._createCamera(o,i.cameras[l],h),void 0!==c&&(r=this._createRenderer(t,s,h)),Promise.resolve(r).then(function(){var e=[],n=s.children;if(n)for(var r=0;r<n.length;r++)e.push(a._parseEntityComponent(t,n[r]));return _F.executeExtensionsAdditiveAndParse(u,t,h,s),Promise.all(e)})},o1._createCamera=function(t,n,r){var a,i=n.orthographic,o=n.perspective,s=n.type,l=r.addComponent(e.Camera);if(s===ll.ORTHOGRAPHIC){var c=i.xmag,u=i.ymag,h=i.zfar,d=i.znear;l.isOrthographic=!0,void 0!==d&&(l.nearClipPlane=d),void 0!==h&&(l.farClipPlane=h),l.orthographicSize=Math.max(null!=u?u:0,null!=c?c:0)/2}else if(s===ll.PERSPECTIVE){var _=o.aspectRatio,f=o.yfov,p=o.zfar,g=o.znear;void 0!==_&&(l.aspectRatio=_),void 0!==f&&(l.fieldOfView=180*f/Math.PI),void 0!==p&&(l.farClipPlane=p),void 0!==g&&(l.nearClipPlane=g)}(a=t).cameras||(a.cameras=[]),t.cameras.push(l),l.enabled=!1},o1._createRenderer=function(t,n,r){for(var a=function(n){var a=u[n],o=a.material;d.push(Promise.all([t.get(e.GLTFParserType.Mesh,s),void 0!==l&&t.get(e.GLTFParserType.Skin,l),void 0!==o&&t.get(e.GLTFParserType.Material,o)]).then(function(o){var s,l=o[0],c=o[1],u=o[2],d=l[n];if(u||(u=e.GLTFMaterialParser._getDefaultMaterial(t.glTFResource.engine)),c||h){var _=r.addComponent(ud);_.mesh=d,c&&(_.rootBone=c._rootBone,_.bones=c._bones,i._computeLocalBounds(_,d,c._bones,c._rootBone,c.inverseBindMatrices),_.skin=c),h&&(_.blendShapeWeights=new Float32Array(h)),s=_}else(s=r.addComponent(c6)).mesh=d;s.setMaterial(u),d.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(s.enableVertexColor=!0)}),_F.executeExtensionsAdditiveAndParse(a.extensions,t,s,a)}))},i=this,o=t.glTF.meshes,s=n.mesh,l=n.skin,c=o[s],u=c.primitives,h=n.weights||c.weights,d=[],_=0;_<u.length;_++)a(_);return Promise.all(d)},o1._createAnimator=function(e,t){var n=e.glTFResource.defaultSceneRoot.addComponent(h3),r=new h4,a=new h5("layer"),i=new h7;if(r.addLayer(a),n.animatorController=r,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}},o1._computeLocalBounds=function(e,t,n,r,a){var i=n.indexOf(r);if(-1!==i)lA.transform(t.bounds,a[i],e.localBounds);else{var o=new lR(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?(lR.multiplyScalar(o,1/s,o),lA.transform(t.bounds,o,e.localBounds)):e.localBounds.copyFrom(t.bounds)}},o1._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?(lR.add(r,t[c],r),a++):a+=this._computeApproximateBindMatrix(e,t,l,r)}return a},o0),e.GLTFSceneParser=dz([_c(e.GLTFParserType.Scene)],e.GLTFSceneParser),e.GLTFSkinParser=(dU(o2=function(){return _F.apply(this,arguments)},_F),(o3=o2.prototype).parse=function(t,n){var r=this,a=t.glTF,i=a.skins[n],o=i.inverseBindMatrices,s=i.skeleton,l=i.joints,c=i.name,u=l.length,h=new uh(void 0===c?"SKIN_"+n:c);h.inverseBindMatrices.length=u,h._bones.length=u;var d=a.accessors[o];return Promise.resolve(_u.getAccessorBuffer(t,a.bufferViews,d).then(function(n){for(var a=t.get(e.GLTFParserType.Entity),i=n.data,o=0;o<u;o++){var c=new lR;c.copyFromArray(i,16*o),h.inverseBindMatrices[o]=c;var d=a[l[o]];if(h._bones[o]=d,h.joints[o]=d.name,void 0!==s){var _=a[s];h._rootBone=_,h.skeleton=_.name}else{var f=r._findSkeletonRootBone(l,a);if(f)h._rootBone=f,h.skeleton=f.name;else throw"Failed to find skeleton root bone."}}return h}))},o3._findSkeletonRootBone=function(e,t){for(var n,r={},a=d3(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 h=u[c],d=1,_=e.length;d<_;d++)if(c>=(u=r[e[d]]).length||h!==u[c])return l;l=h}},o2),e.GLTFSkinParser=dz([_c(e.GLTFParserType.Skin)],e.GLTFSkinParser),e.GLTFTextureParser=(dU(o4=function(){return _F.apply(this,arguments)},_F),o4.prototype.parse=function(t,n){var r=t.glTF.textures[n],a=t.glTFResource,i=t.glTF,o=a.engine,s=a.url,l=r.sampler,c=r.source,u=r.name,h=r.extensions,d=i.images[void 0===c?0:c],_=d.uri,f=d.bufferView,p=d.mimeType,g=d.name,m=_F.executeExtensionsCreateAndParse(h,t,r);if(!m){var v=void 0!==l,y=void 0!==l&&_u.getSamplerInfo(i.samplers[l]);if(_){var x=_.lastIndexOf("."),T=_.substring(x+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;m=o.resourceManager.load({url:c_.resolveAbsoluteUrl(s,_),type:T,params:{mipmap:null==y?void 0:y.mipmap}}).then(function(e){var t;return(t=e).name||(t.name=u||g||"texture_"+n),v&&_u.parseSampler(e,y),e})}else{var S=i.bufferViews[f];m=t.get(e.GLTFParserType.Buffer).then(function(e){var r=e[S.buffer],a=new Uint8Array(r,S.byteOffset,S.byteLength);return _u.loadImageBuffer(a,p).then(function(e){var r=new l9(o,e.width,e.height,void 0,null==y?void 0:y.mipmap);r.setImageSource(e),r.generateMipmaps(),r.name=u||g||"texture_"+n,v&&_u.parseSampler(r,y);var a=new _x(r,S,p);return t.contentRestorer.bufferTextures.push(a),r})})}}return Promise.resolve(m).then(function(e){return _F.executeExtensionsAdditiveAndParse(h,t,e,r),e})},o4._wrapMap=((o5={})[l_.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,o5[l_.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,o5[l_.REPEAT]=e.TextureWrapMode.Repeat,o5),o4),e.GLTFTextureParser=dz([_c(e.GLTFParserType.Texture)],e.GLTFTextureParser),e.GLTFValidator=(dU(o8=function(){return _F.apply(this,arguments)},_F),o8.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){l8.info("extensionsUsed: ",r);for(var o=0;o<r.length;o++){var s=r[o];_F.hasExtensionParser(s)||l8.warn("Extension "+s+" is not implemented, you can customize this extension in gltf.")}}if(a){l8.info("extensionsRequired: "+a);for(var l=0;l<a.length;l++){var c=a[l];_F.hasExtensionParser(c)||l8.error("GLTF parser has not supported required extension "+c+".")}}return Promise.resolve(null)},o8),e.GLTFValidator=dz([_c(e.GLTFParserType.Validator)],e.GLTFValidator);var _L=(dU(o6=function(){return hE.apply(this,arguments)},hE),o6.prototype.load=function(e,t){var n=e.url,r=e.params,a=new _a(t.engine,n);return new _i(a,t,!!(null==r?void 0:r.keepMeshData)).parse()},o6);_L=dz([uC(e.AssetType.GLTF,["gltf","glb"])],_L);var _D=Math.PI,_B=(dU(o7=function(){return hE.apply(this,arguments)},hE),o7.prototype.load=function(t,n){var r=this;return new uT(function(a,i){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=_B._parseHeader(n),i=r.width,s=r.height,l=r.dataPosition,c=_B._readPixels(n.subarray(l),i,s),u=s>>1,h=_B._convertToCubemap(c,i,s,u),d=new ct(o,u),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),a(d)}).catch(i)})},o7._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)]},o7._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 h=this._temp3Vector3.set(0,0,0).add(t[0]),d=this._temp4Vector3.set(0,0,0).add(t[2]),_=0;_<e;_++){var f=this._temp5Vector3.set(0,0,0).add(d).subtract(h).scale(c).add(h);f.normalize();var p=this._calcProjectionSpherical(f,n,r,a);this._RGBEToLinear(p),this._linearToRGBM(p,5);var g=u*e*4+4*_;i[g]=p.r,i[g+1]=p.g,i[g+2]=p.b,i[g+3]=p.a,h.add(o),d.add(s)}c+=l}return i},o7._calcProjectionSpherical=function(e,t,n,r){for(var a=Math.atan2(e.z,e.x),i=Math.acos(e.y);a<-_D;)a+=2*_D;for(;a>_D;)a-=2*_D;var o=a/_D,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(i/_D*r);l<0?l=0:l>=r&&(l=r-1);var c=(r-l-1)*n*4+4*s,u=t[c],h=t[c+1],d=t[c+2],_=t[c+3];return new lB(u,h,d,_)},o7._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},o7._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}},o7._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(4),c=new Uint8Array(s),u=n;u>0&&o<r;){if(l[0]=e[o++],l[1]=e[o++],l[2]=e[o++],l[3]=e[o++],2!=l[0]||2!=l[1]||(l[2]<<8|l[3])!=t)throw"HDR Bad header format, wrong scan line width";for(var h=0,d=void 0;h<s&&o<r;){var _=(d=e[o++])>128;if(_&&(d-=128),0===d||h+d>s)throw"HDR Bad Format, bad scanline data (run)";if(_)for(var f=e[o++],p=0;p<d;p++)c[h++]=f;else c.set(e.subarray(o,o+d),h),h+=d,o+=d}for(var g=0;g<t;g++){var m=0;a[i]=c[g+m],m+=t,a[i+1]=c[g+m],m+=t,a[i+2]=c[g+m],m+=t,a[i+3]=c[g+m],i+=4}u--}return a},o7._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},o7._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},(lx=o7)._rightBottomBack=new lS(1,-1,-1),lx._rightBottomFront=new lS(1,-1,1),lx._rightUpBack=new lS(1,1,-1),lx._rightUpFront=new lS(1,1,1),lx._leftBottomBack=new lS(-1,-1,-1),lx._leftBottomFront=new lS(-1,-1,1),lx._leftUpBack=new lS(-1,1,-1),lx._leftUpFront=new lS(-1,1,1),lx._faceRight=[lx._rightBottomBack,lx._rightBottomFront,lx._rightUpBack,lx._rightUpFront],lx._faceLeft=[lx._leftBottomFront,lx._leftBottomBack,lx._leftUpFront,lx._leftUpBack],lx._faceUp=[lx._leftBottomFront,lx._rightBottomFront,lx._leftBottomBack,lx._rightBottomBack],lx._faceBottom=[lx._leftUpBack,lx._rightUpBack,lx._leftUpFront,lx._rightUpFront],lx._faceFront=[lx._leftBottomBack,lx._rightBottomBack,lx._leftUpBack,lx._rightUpBack],lx._faceBack=[lx._rightBottomFront,lx._leftBottomFront,lx._rightUpFront,lx._leftUpFront],lx._tempVector3=new lS,lx._temp2Vector3=new lS,lx._temp3Vector3=new lS,lx._temp4Vector3=new lS,lx._temp5Vector3=new lS,lx);_B=dz([uC(e.AssetType.HDR,["hdr"])],_B);var _I=(dU(o9=function(){return hE.apply(this,arguments)},hE),o9.prototype.load=function(e){return this.request(e.url,dO({},e,{type:"json"}))},o9);_I=dz([uC(e.AssetType.JSON,["json"],!1)],_I);var _V={parse:function(t,n,r,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!==n)throw Error("number of faces expected"+n+", but found "+l.numberOfFaces);return r&&(l.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+(3-(l+3)%4)}a=Math.max(1,.5*a),i=Math.max(1,.5*i)}return n}(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 _O(e){var t=_V.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var _N=(dU(se=function(){return hE.apply(this,arguments)},hE),se.prototype.load=function(t,n){var r=this;return new uT(function(a,i){Promise.all(t.urls.map(function(e){return r.request(e,dO({},t,{type:"arraybuffer"}))})).then(function(t){for(var r=function(e){for(var t,n,r,a,i=[],o=0;o<e.length;o++){var s=_V.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}}(t),i=r.width,o=r.mipmapsFaces,s=r.engineFormat,l=o[0].length>1,c=new ct(n.engine,i,s,l),u=0;u<6;u++)for(var h=o[u].length,d=0;d<h;d++){var _=o[u][d],f=_.data,p=_.width,g=_.height;c.setPixelBuffer(e.TextureCubeFace.PositiveX+u,f,d,0,0,p,g)}a(c)}).catch(function(e){i(e)})})},se);_N=dz([uC(e.AssetType.KTXCube,[])],_N);var _U=(dU(st=function(){return hE.apply(this,arguments)},hE),st.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"arraybuffer"})).then(function(e){for(var n=_O(e),a=n.width,i=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new l9(t.engine,a,i,s,l),u=0;u<o.length;u++){var h=o[u],d=h.width,_=h.height,f=h.data;c.setPixelBuffer(f,u,0,0,d,_)}r(c)}).catch(function(e){a(e)})})},st);_U=dz([uC(e.AssetType.KTX,["ktx"])],_U);var _z=(dU(sn=function(){return hE.apply(this,arguments)},hE),sn.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"json"})).then(function(e){var n=function(e){var n=s[e],r=n.type,a=n.value;switch(r){case"Vector2":d.setVector2(e,new lL(a.x,a.y));break;case"Vector3":d.setVector3(e,new lS(a.x,a.y,a.z));break;case"Vector4":d.setVector4(e,new lD(a.x,a.y,a.z,a.w));break;case"Color":d.setColor(e,new lB(a.r,a.g,a.b,a.a));break;case"Float":d.setFloat(e,a);break;case"Texture":h.push(t.getResourceByRef(a).then(function(t){d.setTexture(e,t)}))}},a=t.engine,i=e.name,o=e.shader,s=e.shaderData,l=e.macros,c=e.renderState,u=new uZ(a,cH.find(o));u.name=i;var h=[],d=u.shaderData;for(var _ in s)n(_);for(var f=0,p=l.length;f<p;f++){var g=l[f],m=g.name,v=g.value;void 0==v?d.enableMacro(m):d.enableMacro(m,v)}return function e(t,n,r){if("object"==typeof r)for(var a in r)e(t[n],a,r[a]);else t[n]=r}(u,"renderState",c),Promise.all(h).then(function(){r(u)})}).catch(a)})},sn);_z=dz([uC(e.AssetType.Material,["json"])],_z);var _k=(dU(sr=function(){return hE.apply(this,arguments)},hE),sr.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"arraybuffer"})).then(function(e){return d8(e,t.engine)}).then(function(e){r(e)}).catch(a)})},sr);_k=dz([uC(e.AssetType.Mesh,["mesh"])],_k);var _G=(dU(sa=function(){return hE.apply(this,arguments)},hE),(si=sa.prototype).load=function(e,t){var n=this;return new uT(function(r,a){var i=e.url;n._registerFont(i,i).then(function(){r(new ci(t.engine,i))}).catch(function(e){a("load font "+i+" fail")})})},si._registerFont=function(e,t){return _n(function(){var n;return dk(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]}})})()},sa);_G=dz([uC(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],_G);var _H=(dU(so=function(){var e;return e=hE.apply(this,arguments)||this,e._tempRect=new lI,e._tempVec2=new lL,e._tempVec4=new lD,e},hE),(ss=so.prototype).load=function(t,n){var r=this;return new uT(function(a,i,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var c=r.request(t.url,dO({},t,{type:"json"}));l.push(c),c.then(function(o){var s=o.atlasItems,c=o.mipmap,u=o.anisoLevel,h=o.filterMode,d=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,g=n.engine,m=new hD(g);if(p<0){a(m);return}l.length=0;for(var v=0;v<s.length;v++)!function(a){var o=s[a];if(o.img)l.push(n.load({url:c_.resolveAbsoluteUrl(t.url,o.img),type:e.AssetType.Texture2D,params:{format:f,mipmap:c}}).then(function(e){u&&(e.anisoLevel=u),void 0!==h&&(e.filterMode=h),void 0!==d&&(e.wrapModeU=d),void 0!==_&&(e.wrapModeV=_);for(var t=0;t<o.sprites.length;t++)m._addSprite(r._makeSprite(g,o.sprites[t],e))}).catch(i));else for(var p=0;p<o.sprites.length;p++)m._addSprite(r._makeSprite(g,o.sprites[p]))}(v);uT.all(l).then(function(){a(m)}).catch(i)}).catch(i)})},ss._makeSprite=function(e,t,n){var r=t.region,a=t.atlasRegionOffset,i=t.atlasRegion,o=t.pivot,s=t.border,l=new hB(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 c=1/n.width,u=1/n.height;if(l.atlasRegion.set(i.x*c,i.y*u,i.w*c,i.h*u),a){var h=a.x,d=a.y,_=a.z,f=a.w;l.atlasRegionOffset.set(h*c,d*u,_*c,f*u)}t.atlasRotated&&(l.atlasRotated=!0)}return l},so);_H=dz([uC(e.AssetType.SpriteAtlas,["atlas"],!1)],_H);var _W=(dU(sl=function(){return hE.apply(this,arguments)},hE),sl.prototype.load=function(e,t){var n=this;return new uT(function(r,a){n.request(e.url,dO({},e,{type:"json"})).then(function(e){e.belongToAtlas?t.getResourceByRef(e.belongToAtlas).then(function(t){r(t.getSprite(e.fullPath))}).catch(a):e.texture?t.getResourceByRef(e.texture).then(function(n){r(new hB(t.engine,n,e.region,e.pivot,e.border))}).catch(a):r(new hB(t.engine,null,e.region,e.pivot,e.border))}).catch(a)})},sl);_W=dz([uC(e.AssetType.Sprite,["sprite"],!1)],_W);var _X=(dU(sc=function(e,t,n){var r;return(r=l$.call(this,e)||this).url=t,r.requestConfig=n,r},l$),sc.prototype.restoreContent=function(){var e=this;return hS(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},sc),_K=(dU(su=function(){return hE.apply(this,arguments)},hE),su.prototype.load=function(e,t){var n=this;return new uT(function(r,a){var i=e.url,o=dO({},e,{type:"image"});n.request(i,o).then(function(n){var a=e.params,s=new l9(t.engine,n.width,n.height,null==a?void 0:a.format,null==a?void 0:a.mipmap);if(s.setImageSource(n),s.generateMipmaps(),0!==i.indexOf("data:")){var l=i.lastIndexOf("/");s.name=i.substring(l+1)}t.addContentRestorer(new _X(s,i,o)),r(s)}).catch(function(e){a(e)})})},su);_K=dz([uC(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],_K);var _j=(dU(sh=function(e,t,n){var r;return(r=l$.call(this,e)||this).urls=t,r.requestConfig=n,r},l$),sh.prototype.restoreContent=function(){var t=this;return new uT(function(n,r){Promise.all(t.urls.map(function(e){return hS(e,t.requestConfig)})).then(function(r){for(var a=t.resource,i=0;i<6;i++)a.setImageSource(e.TextureCubeFace.PositiveX+i,r[i],0);a.generateMipmaps(),n(a)}).catch(function(e){r(e)})})},sh),_q=(dU(sd=function(){return hE.apply(this,arguments)},hE),sd.prototype.load=function(t,n){var r=this;return new uT(function(a,i){var o=t.urls,s=dO({},t,{type:"image"});Promise.all(o.map(function(e){return r.request(e,s)})).then(function(t){var r=t[0],i=r.width;if(i!==r.height){console.error("The cube texture must have the same width and height");return}for(var l=new ct(n.engine,i),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),n.addContentRestorer(new _j(l,o,s)),a(l)}).catch(function(e){i(e)})})},sd);_q=dz([uC(e.AssetType.TextureCube,[""])],_q);var _Y=(dU(s_=function(){return hE.apply(this,arguments)},hE),s_.prototype.load=function(t,n){var r=this,a=n.engine;return new uT(function(i,o){r.request(t.url,{type:"json"}).then(function(t){return a.resourceManager.initVirtualResources(t.files),d5.parse(a,t).then(function(r){var a=[],o=t.scene.ambient,s="Custom"===o.specularMode;if(s&&o.customAmbientLight){var l=n.getResourceByRef(o.customAmbientLight).then(function(e){r.ambientLight=e,r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseMode=o.diffuseMode,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor)});a.push(l)}else if(!s&&o.ambientLight){var c=n.getResourceByRef(o.ambientLight).then(function(e){r.ambientLight=e,r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseMode=o.diffuseMode,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor)});a.push(c)}var u=t.scene.background;switch(r.background.mode=u.mode,r.background.mode){case e.BackgroundMode.SolidColor:r.background.solidColor.copyFrom(u.color);break;case e.BackgroundMode.Sky:if(u.skyMesh&&u.skyMaterial){var h=n.getResourceByRef(u.skyMesh).then(function(e){r.background.sky.mesh=e}),d=n.getResourceByRef(u.skyMaterial).then(function(e){r.background.sky.material=e});a.push(h,d)}else l8.warn("Sky background mode requires skyMesh and skyMaterial");break;case e.BackgroundMode.Texture:if(u.texture){var _=n.getResourceByRef(u.texture).then(function(e){r.background.texture=e});a.push(_)}}var f=t.scene.shadow;return f&&(void 0!=f.castShadows&&(r.castShadows=f.castShadows),void 0!=f.shadowResolution&&(r.shadowResolution=f.shadowResolution),void 0!=f.shadowDistance&&(r.shadowDistance=f.shadowDistance),void 0!=f.shadowCascades&&(r.shadowCascades=f.shadowCascades)),Promise.all(a).then(function(){i(r)})})}).catch(o)})},s_);_Y=dz([uC(e.AssetType.Scene,["prefab"],!0)],_Y),dZ.registerCustomParseComponent("TextRenderer",_n(function(e,t,n){var r;return dk(this,function(a){return(r=t.props).font||(e.font=ci.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var _Q=(dU(sf=function(){return _M.apply(this,arguments)},_M),(sp=sf.prototype).createAndParse=function(t,n,r,a){var i=this;this._initialize();var o=t.glTF,s=t.glTFResource.engine,l=o.bufferViews,c=o.accessors,u=n.bufferView,h=n.attributes,d={},_={};for(var f in h)d[f]=h[f];for(var p in r.attributes)if(void 0!==h[p]){var g=c[r.attributes[p]];_[p]=_u.getComponentType(g.componentType).name}var m=c[r.indices],v={attributeIDs:d,attributeTypes:_,useUniqueIDs:!0,indexType:_u.getComponentType(m.componentType).name};return t.get(e.GLTFParserType.Buffer).then(function(e){var n=_u.getBufferViewData(l[u],e);return _Q._decoder.decode(n,v).then(function(e){var n=new c9(s,a.name);return i._parseMeshFromGLTFPrimitiveDraco(n,a,r,o,function(t){for(var n=0;n<e.attributes.length;n++)if(e.attributes[n].name===t)return e.attributes[n].array;return null},function(e,t){throw"BlendShape animation is not supported when using draco."},function(){return e.index.array},t.keepMeshData)})})},sp._initialize=function(){_Q._decoder||(_Q._decoder=new dV)},sp._parseMeshFromGLTFPrimitiveDraco=function(t,n,r,a,i,o,s,l){var c,u=r.attributes,h=r.targets,d=r.indices,_=r.mode,f=a.accessors,p=f[u.POSITION],g=i("POSITION"),m=_u.floatBufferToVector3Array(g);t.setPositions(m);var v=t.bounds;if(c=p.count,p.min&&p.max)v.min.copyFromArray(p.min),v.max.copyFromArray(p.max);else{var y=_Q._tempVector3,x=v.min,T=v.max;x.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),T.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var S=g.length/c,C=0;C<c;C++){var A=C*S;y.copyFromArray(g,A),lS.min(x,y,x),lS.max(T,y,T)}}for(var w in u)if("POSITION"!==w){var E=i(w);switch(w){case"NORMAL":var b=_u.floatBufferToVector3Array(E);t.setNormals(b);break;case"TEXCOORD_0":var M=_u.floatBufferToVector2Array(E);t.setUVs(M,0);break;case"TEXCOORD_1":var F=_u.floatBufferToVector2Array(E);t.setUVs(F,1);break;case"TEXCOORD_2":var R=_u.floatBufferToVector2Array(E);t.setUVs(R,2);break;case"TEXCOORD_3":var P=_u.floatBufferToVector2Array(E);t.setUVs(P,3);break;case"TEXCOORD_4":var L=_u.floatBufferToVector2Array(E);t.setUVs(L,4);break;case"TEXCOORD_5":var D=_u.floatBufferToVector2Array(E);t.setUVs(D,5);break;case"TEXCOORD_6":var B=_u.floatBufferToVector2Array(E);t.setUVs(B,6);break;case"TEXCOORD_7":var I=_u.floatBufferToVector2Array(E);t.setUVs(I,7);break;case"COLOR_0":var V=_u.floatBufferToColorArray(E,f[u.COLOR_0].type===li.VEC3);t.setColors(V);break;case"TANGENT":var O=_u.floatBufferToVector4Array(E);t.setTangents(O);break;case"JOINTS_0":var N=_u.floatBufferToVector4Array(E);t.setBoneIndices(N);break;case"WEIGHTS_0":var U=_u.floatBufferToVector4Array(E);t.setBoneWeights(U)}}if(void 0!==d){var z=a.accessors[d],k=s();t.setIndices(k),t.addSubMesh(0,z.count,_)}else t.addSubMesh(0,c,_);return h&&e.GLTFMeshParser._createBlendShape(t,null,n,f,h,o),t.uploadData(!l),Promise.resolve(t)},sf._tempVector3=new lS,sf);_Q=dz([_R("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],_Q);var _J=(dU(sg=function(){return _M.apply(this,arguments)},_M),sg.prototype.additiveParse=function(e,t,n){var r,a,i=e.glTF.extensions.KHR_lights_punctual.lights[n.light],o=i.color,s=i.intensity,l=i.type,c=i.range,u=i.spot,h=e.glTFResource;if("directional"===l?a=t.addComponent(he):"point"===l?a=t.addComponent(ht):"spot"===l&&(a=t.addComponent(hn)),o&&a.color.set(o[0],o[1],o[2],1),a.intensity=void 0===s?1:s,c&&!_P(a,he)&&(a.distance=c),u&&_P(a,hn)){var d=u.innerConeAngle,_=void 0===d?0:d,f=u.outerConeAngle;a.angle=_,a.penumbra=(void 0===f?Math.PI/4:f)-_}(r=h).lights||(r.lights=[]),h.lights.push(a)},sg);_J=dz([_R("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],_J);var _Z=(dU(sm=function(){return _M.apply(this,arguments)},_M),sm.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(e.GLTFParserType.Texture,i.index).then(function(e){n.clearCoatTexture=e})),s&&(e.GLTFMaterialParser._checkOtherTextureTransform(s,"Clear coat roughness"),t.get(e.GLTFParserType.Texture,s.index).then(function(e){n.clearCoatRoughnessTexture=e})),l&&(e.GLTFMaterialParser._checkOtherTextureTransform(l,"Clear coat normal"),t.get(e.GLTFParserType.Texture,l.index).then(function(e){n.clearCoatNormalTexture=e}))},sm);_Z=dz([_R("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],_Z);var _$=(dU(sv=function(){return _M.apply(this,arguments)},_M),sv.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},sv);_$=dz([_R("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],_$);var _0=(dU(sy=function(){return _M.apply(this,arguments)},_M),sy.prototype.createAndParse=function(t,n,r){var a=t.glTFResource.engine,i=new hP(a),o=n.diffuseFactor,s=n.diffuseTexture,l=n.specularFactor,c=n.glossinessFactor,u=n.specularGlossinessTexture;return o&&(i.baseColor=new lB(lB.linearToGammaSpace(o[0]),lB.linearToGammaSpace(o[1]),lB.linearToGammaSpace(o[2]),o[3])),s&&t.get(e.GLTFParserType.Texture,s.index).then(function(e){i.baseTexture=e,_F.executeExtensionsAdditiveAndParse(s.extensions,t,i,s)}),l&&(i.specularColor=new lB(lB.linearToGammaSpace(l[0]),lB.linearToGammaSpace(l[1]),lB.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=r.name,e.GLTFMaterialParser._parseStandardProperty(t,i,r),i},sy);_0=dz([_R("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],_0);var _1=(dU(sx=function(){return _M.apply(this,arguments)},_M),sx.prototype.createAndParse=function(t,n,r){var a=t.glTFResource.engine,i=new hL(a);return i.name=r.name,e.GLTFMaterialParser._parseStandardProperty(t,i,r),i},sx);_1=dz([_R("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],_1);var _2=(dU(sT=function(){return _M.apply(this,arguments)},_M),sT.prototype.additiveParse=function(t,n,r){var a,i=t.glTF.extensions.KHR_materials_variants.variants,o=t.glTFResource,s=r.mappings;(a=o).extensionsData||(a.extensionsData={});var l=[];o.extensionsData.variants=l;for(var c=0;c<s.length;c++)!function(r){var a=s[r],o=a.material,c=a.variants;t.get(e.GLTFParserType.Material,o).then(function(e){l.push({renderer:n,material:e,variants:c.map(function(e){return i[e].name})})})}(c)},sT);_2=dz([_R("KHR_materials_variants",e.GLTFExtensionMode.AdditiveParse)],_2);var _3=(dU(sS=function(){return _M.apply(this,arguments)},_M),sS);_3=dz([_R("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],_3);var _4=(dU(sC=function(){return _M.apply(this,arguments)},_M),sC.prototype.createAndParse=function(t,n,r){return _n(function(){var a,i,o,s,l,c,u,h,d,_,f,p,g,m,v;return dk(this,function(y){return(a=t.glTF,o=(i=t.glTFResource).engine,s=i.url,l=r.sampler,c=r.name,u=n.source,d=(h=a.images[u]).uri,_=h.bufferView,f=h.mimeType,p=h.name,g=void 0!==l&&_u.getSamplerInfo(a.samplers[l]),d)?(m=d.lastIndexOf("."),[2,o.resourceManager.load({url:c_.resolveAbsoluteUrl(s,d),type:e.AssetType.KTX2}).then(function(e){return e.name||(e.name=c||p||"texture_"+m),void 0!==l&&_u.parseSampler(e,g),e})]):(v=a.bufferViews[_],[2,t.get(e.GLTFParserType.Buffer,v.buffer).then(function(n){var r=new Uint8Array(n,v.byteOffset,v.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&&_u.parseSampler(e,g);var n=new _x(e,v,f);return t.contentRestorer.bufferTextures.push(n),e})})])})})()},sC);_4=dz([_R("KHR_texture_basisu",e.GLTFExtensionMode.CreateAndParse)],_4);var _5=(dU(sA=function(){return _M.apply(this,arguments)},_M),sA.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&&l8.warn("rotation in KHR_texture_transform is not supported now"),o&&l8.warn("texCoord in KHR_texture_transform is not supported now")},sA);_5=dz([_R("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],_5);var _8=(dU(sw=function(){return _M.apply(this,arguments)},_M),sw.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},sw);_8=dz([_R("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],_8);var _6=(dU(sE=function(){return _M.apply(this,arguments)},_M),sE.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new hY;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},sE);_6=dz([_R("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],_6);var _7="1.1.0-alpha.2";for(var _9 in console.log("Galacean engine version: "+_7),dd)hE.registerClass(_9,dd[_9]);e.AmbientLight=u7,e.AnimationClip=hQ,e.AnimationClipCurveBinding=hq,e.AnimationCurve=hJ,e.AnimationEvent=hY,e.Animator=h3,e.AnimatorController=h4,e.AnimatorControllerLayer=h5,e.AnimatorState=h6,e.AnimatorStateMachine=h7,e.AnimatorStateTransition=h$,e.AssetPromise=uT,e.Background=u8,e.BaseMaterial=hb,e.Basic2DBatcher=u_,e.BasicRenderPipeline=hv,e.BlendShape=c5,e.BlendShapeFrame=c4,e.BlendState=cN,e.BlinnPhongMaterial=hM,e.BoolUpdateFlag=cm,e.BoundingBox=lA,e.BoundingFrustum=lb,e.BoundingSphere=lC,e.BoxColliderShape=uX,e.Buffer=c$,e.BufferMesh=c8,e.BufferUtil=cJ,e.CapsuleColliderShape=uq,e.CharacterController=uD,e.CloneManager=lQ,e.ColliderShape=uW,e.CollisionUtil=lw,e.Color=lB,e.Component=cc,e.ComponentMap=d0,e.ContentRestorer=l$,e.CubeProbe=dh,e.DepthState=cU,e.DirectLight=he,e.DynamicCollider=uB,e.Engine=u4,e.EngineObject=lJ,e.Entity=cT,e.EventDispatcher=co,e.FixedJoint=uU,e.Font=ci,e.GLTFExtensionParser=_M,e.GLTFParser=_F,e.GLTFParserContext=_i,e.GLTFResource=_a,e.GLTFUtils=_u,e.HingeJoint=uz,e.HitResult=uI,e.IndexBufferBinding=c0,e.InputManager=uJ,e.JointLimits=uG,e.JointMotor=uH,e.Keyframe=h9,e.Light=u9,e.Loader=hE,e.Logger=l8,e.Material=uZ,e.MathUtil=lT,e.Matrix=lR,e.Matrix3x3=lM,e.Mesh=c2,e.MeshRenderer=c6,e.ModelMesh=c9,e.PBRBaseMaterial=hF,e.PBRMaterial=hR,e.PBRSpecularMaterial=hP,e.ParticleRenderer=dn,e.PhysicsMaterial=uV,e.PhysicsScene=uL,e.Plane=lE,e.PlaneColliderShape=uj,e.PointLight=ht,e.Pointer=ub,e.PrefabParser=d$,e.PrimitiveMesh=uu,e.Probe=ds,e.Quaternion=lF,e.RasterState=cz,e.Ray=lP,e.Rect=lI,e.ReferResource=lZ,e.ReflectionParser=dZ,e.RenderPass=hs,e.RenderQueue=hc,e.RenderState=cG,e.RenderTarget=l7,e.RenderTargetBlendState=cO,e.ResourceManager=uS,e.Scene=ha,e.SceneManager=ux,e.SceneParser=d5,e.Script=hi,e.Shader=cH,e.ShaderData=cW,e.ShaderFactory=cF,e.ShaderMacro=cw,e.ShaderMacroCollection=cE,e.ShaderPass=cI,e.ShaderProperty=cs,e.ShaderTagKey=cR,e.Skin=uh,e.SkinnedMeshRenderer=ud,e.Sky=u5,e.SkyBoxMaterial=de,e.SkyProceduralMaterial=dt,e.SphereColliderShape=uK,e.SphericalHarmonics3=lV,e.SpotLight=hn,e.SpringJoint=uk,e.Sprite=hB,e.SpriteAtlas=hD,e.SpriteMask=cQ,e.SpriteRenderer=hO,e.StateMachineScript=h8,e.StaticCollider=uO,e.StencilState=ck,e.SubMesh=c1,e.SubShader=cV,e.SystemInfo=uR,e.TextRenderer=hz,e.TextUtils=cr,e.Texture=l6,e.Texture2D=l9,e.Texture2DArray=ce,e.TextureCube=ct,e.Time=cl,e.TrailMaterial=dr,e.TrailRenderer=di,e.Transform=cy,e.UnlitMaterial=hL,e.Utils=c_,e.Vector2=lL,e.Vector3=lS,e.Vector4=lD,e.VertexBufferBinding=c3,e.VertexElement=cZ,e.WebCanvas=dg,e.WebGLEngine=dy,e.WebGLGraphicDevice=dP,e.assignmentClone=lj,e.decode=d8,e.deepClone=lY,e.dependentComponents=ch,e.ignoreClone=lK,e.parseSingleKTX=_O,e.registerGLTFExtension=_R,e.registerGLTFParser=_c,e.request=hS,e.resourceLoader=uC,e.shallowClone=lq,e.version=_7,Object.defineProperty(e,"__esModule",{value:!0})});
|