@galacean/engine 1.0.0-beta.13 → 1.0.0-beta.14
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 +25 -36
- 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,(o3=e.ContainmentType||(e.ContainmentType={}))[o3.Disjoint=0]="Disjoint",o3[o3.Contains=1]="Contains",o3[o3.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(o4=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[o4.Back=0]="Back",o4[o4.Front=1]="Front",o4[o4.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(o5=e.FrustumFace||(e.FrustumFace={}))[o5.Near=0]="Near",o5[o5.Far=1]="Far",o5[o5.Left=2]="Left",o5[o5.Right=3]="Right",o5[o5.Bottom=4]="Bottom",o5[o5.Top=5]="Top";var i,a,o,s,l,c,u,h,d,_,f,p,g,m,v,y,x,T,C,S,w,A,E,M,b,R,F,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,ew,eA,eE,eM,eb,eR,eF,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,tw,tA,tE,tM,tb,tR,tF,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,nw,nA,nE,nM,nb,nR,nF,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,rw,rA,rE,rM,rb,rR,rF,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,iw,iA,iE,iM,ib,iR,iF,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,aw,aA,aE,aM,ab,aR,aF,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,ow,oA,oE,oM,ob,oR,oF,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,sw,sA,sE,sM,sb,sR,sF,sP,sL,sD,sI,sB,sN,sV,sO,sU,sz,sk,sG,sH=((o8=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},o8.equals=function(e,t){return Math.abs(e-t)<=o8.zeroTolerance},o8.isPowerOf2=function(e){return(e&e-1)==0},o8.radianToDegree=function(e){return e*o8.radToDegreeFactor},o8.degreeToRadian=function(e){return e*o8.degreeToRadFactor},o8);sH.zeroTolerance=1e-6,sH.radToDegreeFactor=180/Math.PI,sH.degreeToRadFactor=Math.PI/180;var sW=((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 sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.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>sH.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);sW._zero=new sW(0,0,0),sW._one=new sW(1,1,1);var sX=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sW,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)sW.add(e[i],r,r);sW.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sW.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=sW.distance(n,i)},o);sX._tempVec30=new sW;var sK=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sW,this.max=new sW,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sW.add(this.min,this.max,e),sW.scale(e,.5,e),e},c.getExtent=function(e){return sW.subtract(this.max,this.min,e),sW.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 sW;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){sW.subtract(e,t,n.min),sW.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];sW.min(n,o,n),sW.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),sW.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]),sW.subtract(r,i,n.min),sW.add(r,i,n.max)},l.merge=function(e,t,n){return sW.min(e.min,t.min,n.min),sW.max(e.max,t.max,n.max),n},l);sK._tempVec30=new sW,sK._tempVec31=new sW;var sj=((u=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sW.cross(a,o,u._tempVec30),sW.cross(o,i,u._tempVec31),sW.cross(i,a,u._tempVec32);var s=-sW.dot(i,u._tempVec30),l=-sW.dot(a,u._tempVec31),c=-sW.dot(o,u._tempVec32);sW.scale(u._tempVec30,e.distance/s,u._tempVec30),sW.scale(u._tempVec31,t.distance/l,u._tempVec31),sW.scale(u._tempVec32,n.distance/c,u._tempVec32),sW.add(u._tempVec30,u._tempVec31,r),sW.add(r,u._tempVec32,r)},u.distancePlaneAndPoint=function(e,t){return sW.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=sH.zeroTolerance,i=sW.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sW.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=sH.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,w=(a.z-d)*S,A=(o.z-d)*S;if(w>A){var E=w;w=A,A=E}if((_=Math.max(w,_))>(f=Math.min(A,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;sW.subtract(n,i,o);var s=sW.dot(o,r),l=sW.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 sW.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))),sW.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),sW.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)<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.far,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.left,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.right,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.top,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.bottom,n))<sH.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);sj._tempVec30=new sW,sj._tempVec31=new sW,sj._tempVec32=new sW;var sq=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sW,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();sW.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),sY=((f=(_=function(e){void 0===e&&(e=null),this.near=new sq,this.far=new sq,this.left=new sq,this.right=new sq,this.top=new sq,this.bottom=new sq,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 sj.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return sj.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},_),sQ=((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 sH.equals(n[0],r[0])&&sH.equals(n[1],r[1])&&sH.equals(n[2],r[2])&&sH.equals(n[3],r[3])&&sH.equals(n[4],r[4])&&sH.equals(n[5],r[5])&&sH.equals(n[6],r[6])&&sH.equals(n[7],r[7])&&sH.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,w=a*h-s*c,A=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,R=_*v-f*m,F=_*y-p*m,P=f*y-p*v,L=x*P-T*F+C*R+S*b-w*M+A*E;if(!L)return null;L=1/L,r[0]=(c*P-u*F+h*R)*L,r[1]=(u*b-l*P-h*M)*L,r[2]=(l*F-c*b+h*E)*L,r[3]=(o*F-a*P-s*R)*L,r[4]=(i*P-o*b+s*M)*L,r[5]=(a*b-i*F-s*E)*L,r[6]=(m*A-v*w+y*S)*L,r[7]=(v*C-g*A-y*T)*L,r[8]=(g*w-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),sJ=((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<sH.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 sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.equals(e._z,t._z)&&sH.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sW.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>sH.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-sH.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>sH.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)<sH.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);sJ._tempVector3=new sW,sJ._tempQuat1=new sJ;var sZ=((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)<sH.zeroTolerance||Math.abs(x)<sH.zeroTolerance||Math.abs(T)<sH.zeroTolerance)return t.identity(),!1;var C=1/v,S=1/x,w=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*w,a[7]=p*w,a[8]=g*w,sJ.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>sH.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],w=i[2],A=i[3],E=i[4],M=i[5],b=i[6],R=i[7],F=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*w+v*A,a[1]=s*C+h*S+p*w+y*A,a[2]=l*C+d*S+g*w+x*A,a[3]=c*C+_*S+m*w+T*A,a[4]=o*E+u*M+f*b+v*R,a[5]=s*E+h*M+p*b+y*R,a[6]=l*E+d*M+g*b+x*R,a[7]=c*E+_*M+m*b+T*R,a[8]=o*F+u*P+f*L+v*D,a[9]=s*F+h*P+p*L+y*D,a[10]=l*F+d*P+g*L+x*D,a[11]=c*F+_*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 sH.equals(n[0],r[0])&&sH.equals(n[1],r[1])&&sH.equals(n[2],r[2])&&sH.equals(n[3],r[3])&&sH.equals(n[4],r[4])&&sH.equals(n[5],r[5])&&sH.equals(n[6],r[6])&&sH.equals(n[7],r[7])&&sH.equals(n[8],r[8])&&sH.equals(n[9],r[9])&&sH.equals(n[10],r[10])&&sH.equals(n[11],r[11])&&sH.equals(n[12],r[12])&&sH.equals(n[13],r[13])&&sH.equals(n[14],r[14])&&sH.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)<sH.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,w=a*h-s*c,A=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,R=_*v-f*m,F=_*y-p*m,P=f*y-p*v,L=x*P-T*F+C*R+S*b-w*M+A*E;if(!L)return null;L=1/L,r[0]=(c*P-u*F+h*R)*L,r[1]=(o*F-a*P-s*R)*L,r[2]=(m*A-v*w+y*S)*L,r[3]=(f*w-_*A-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*A-y*T)*L,r[7]=(d*A-f*C+p*T)*L,r[8]=(l*F-c*b+h*E)*L,r[9]=(a*b-i*F-s*E)*L,r[10]=(g*w-m*C+y*x)*L,r[11]=(_*C-d*w-p*x)*L,r[12]=(c*M-l*R-u*E)*L,r[13]=(i*R-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;sW.subtract(e,t,s),s.normalize(),sW.cross(n,s,a),a.normalize(),sW.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]=-sW.dot(a,e),i[13]=-sW.dot(o,e),i[14]=-sW.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)<sH.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],w=h[11],A=s*s*o+a,E=l*s*o+c*i,M=c*s*o-l*i,b=s*l*o-c*i,R=l*l*o+a,F=c*l*o+s*i,P=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;d[0]=_*A+m*E+T*M,d[1]=f*A+v*E+C*M,d[2]=p*A+y*E+S*M,d[3]=g*A+x*E+w*M,d[4]=_*b+m*R+T*F,d[5]=f*b+v*R+C*F,d[6]=p*b+y*R+S*F,d[7]=g*b+x*R+w*F,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+w*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);sZ._tempVec30=new sW,sZ._tempVec31=new sW,sZ._tempVec32=new sW,sZ._tempMat30=new sQ,sZ._identity=new sZ(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var s$=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sW,this.direction=new sW,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return sj.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return sj.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return sj.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return sW.scale(this.direction,e,t),t.add(this.origin)},T),s0=((w=(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},w.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},w.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},w.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},w.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},w.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},w.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},w.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},w.normalize=function(){return S.normalize(this,this),this},w.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},w.clone=function(){return new S(this._x,this._y)},w.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},w.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},w.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},w.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 sH.equals(e._x,t._x)&&sH.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>sH.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);s0._zero=new s0(0,0),s0._one=new s0(1,1);var s1=((E=(A=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 A.normalize(this,this),this},E.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new A(this._x,this._y,this._z,this._w)},E.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},E.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},E.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},E.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,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()},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._w=e._w-t._w,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._w=e._w*t._w,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._w=e._w/t._w,n._onValueChanged&&n._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var 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)},A.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},A.equals=function(e,t){return sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.equals(e._z,t._z)&&sH.equals(e._w,t._w)},A.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()},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._w=Math.max(e._w,t._w),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._w=Math.min(e._w,t._w),n._onValueChanged&&n._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>sH.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},A.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()},A.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()},A.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(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);s1._zero=new s1(0,0,0,0),s1._one=new s1(1,1,1,1);var s2=((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 sH.equals(e._r,t._r)&&sH.equals(e._g,t._g)&&sH.equals(e._b,t._b)&&sH.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),s3=((F=(R=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},F.clone=function(){return new R(this.x,this.y,this.width,this.height)},F.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this},R),s4=((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 s5(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s6(e,t,n){return t&&s8(e.prototype,t),n&&s8(e,n),e}function s7(e,t){return(s7=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s9(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&&s7(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 le=((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);le.zeroTolerance=1e-6,le.radToDegreeFactor=180/Math.PI,le.degreeToRadFactor=Math.PI/180;var lt=((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 le.equals(e._r,t._r)&&le.equals(e._g,t._g)&&le.equals(e._b,t._b)&&le.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},s6(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 ln(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 lr(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function li(e,t){ll.registerCloneMode(e,t,o6.Ignore)}function la(e,t){ll.registerCloneMode(e,t,o6.Assignment)}function lo(e,t){ll.registerCloneMode(e,t,o6.Shallow)}function ls(e,t){ll.registerCloneMode(e,t,o6.Deep)}(V=o6||(o6={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var ll=((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(lr(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);ll._subCloneModeMap=new Map,ll._cloneModeMap=new Map,ll._objectType=Object.getPrototypeOf(Object);var lc=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)},s6(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();lc._instanceIdCounter=0,ln([li],lc.prototype,"instanceId",void 0),ln([li],lc.prototype,"_engine",void 0);var lu=(s9(U=function(e){var t;return(t=lc.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(s5(t)),t},lc),(z=U.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(lc.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(){lc.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},s6(U,[{key:"refCount",get:function(){return this._refCount}}]),U),lh=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.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 ld=(s9(q=function(e){var t;return t=lu.call(this,e)||this,e.resourceManager._addGraphicResource(s5(t)),t},lu),q.prototype._onDestroy=function(){lu.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},q),l_=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},lf=console.log.bind(console),lp=console.info.bind(console),lg=console.warn.bind(console),lm=console.error.bind(console),lv={debug:l_,info:l_,warn:l_,error:l_,isEnabled:!1,enable:function(){this.debug=lf,this.info=lp,this.warn=lg,this.error=lm,this.isEnabled=!0},disable:function(){this.debug=l_,this.info=l_,this.warn=l_,this.error=l_,this.isEnabled=!1}},ly=(s9(Y=function(){var e;return e=ld.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},ld),(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(){ld.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},s6(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&&(lv.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(lv.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),lx=(s9(J=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=ld.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=lr(i,Array)?i.slice():[i],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(lr(a,ly)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s5(s)),s},ld),(Z=J.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},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(){ld.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)},s6(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),lT=(s9($=function(t,n,r,i,a,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=e.TextureUsage.Static),(s=ly.call(this,t)||this)._mipmap=a,s._width=n,s._height=r,s._usage=o,s._format=i,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s5(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},ly),(ee=$.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)},ee.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)},ee.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)},ee._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),ly.prototype._rebuild.call(this)},$),lC=(s9(et=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=ly.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(s5(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},ly),(en=et.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)},en.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)},en.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)},en._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),ly.prototype._rebuild.call(this)},s6(et,[{key:"length",get:function(){return this._length}}]),et),lS=(s9(er=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=ly.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(s5(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},ly),(ei=er.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)},ei.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)},ei.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)},ei._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),ly.prototype._rebuild.call(this)},er),lw=(s9(ea=function(e){var t;return(t=lu.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},lu),(eo=ea.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 s0(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},eo.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},eo.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},eo._onDestroy=function(){lu.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},ea);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 lA=((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 i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},ec.measureChar=function(e,t){return ec._measureFontOrChar(t,e)},ec.measureTextWithWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=ec.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=uC._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,w=!1,A=0,E=p.length;A<E;++A){var M=p[A],b=ec._getCharInfo(M,r,n),R=M.charCodeAt(0),F=32===R;if(!F||!w||0!==x.length||0!==g.length){var P=F||R>=19968&&R<=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),w=!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),w=!0,F?(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),w=!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}},ec.measureTextWithoutWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=ec.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=uC._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=ec._getCharInfo(f[v],r,n);p+=x.xAdvance;var T=x.offsetY,C=.5*x.h,S=C+T,w=C-T;g<S&&(g=S),m<w&&(m=w)}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}},ec.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},ec._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=ec.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||ec._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(ec._measureBaseline).width),c=l*ec._heightMultiplier;l=ec._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 s0,new s0,new s0,new s0],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,i,a,o){e.push(r),t.push(i),n.push({ascent:a,descent:o,size:a+o})},ec);lA._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],lA._measureString="|\xc9q\xc5",lA._measureBaseline="M",lA._heightMultiplier=2,lA._baselineMultiplier=1.4,lA._fontSizeInfoCache={},lA._textContext=null;var lE=((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 i=t[n].getCharInfo(e);if(i)return i}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 lw(t),r=new lT(t,256,256);n.texture=r,n.isGCIgnored=r.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return t.resourceManager.addContentRestorer(new(s9(e=function(){return lh.call(this,n)},lh),e.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var r in t){var a=t[r],o=lA.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},eu),lM=(s9(ed=function(e,t){var n;return void 0===t&&(t=""),(n=lu.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},lu),(e_=ed.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new lE(this.engine),r[n]=i),i},e_._onDestroy=function(){lu.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},s6(ed,[{key:"name",get:function(){return this._name}}]),ed),lb=((ep=(ef=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},ep.then=function(e,t){var n=this;return new ef(function(r,i){n._promise.then(e,t).then(r).catch(i)})},ep.catch=function(e){var t=this;return new ef(function(n,r){t._promise.catch(e).then(n).catch(r)})},ep.finally=function(e){return this._promise.finally(e)},ep.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},ef.all=function(e){return new ef(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){lr(e,Promise)||lr(e,ef)?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)})},s6(ef,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),ef);(eg=o7||(o7={})).Pending="pending",eg.Fulfilled="fulfilled",eg.Rejected="rejected",eg.Canceled="canceled";var lR=((ev=(em=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 lb.all(n)},ev.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},ev.getAssetPath=function(e){return this._assetPool[e]},ev.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()}):lG.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},ev.gc=function(){this._gc(!1),this.engine._pendingGC()},ev.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},ev._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},ev._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},ev._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},ev._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},ev._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},ev._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},ev._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},ev._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},ev._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)},ev._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},ev._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:em._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},ev._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 lb(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 lb(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=em._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(lr(f,lb))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)})},ev._gc=function(e){for(var t=lG.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},ev._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},ev._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},ev._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},ev._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===lP&&t.push(""),e.replace(lD,function(e,n,r,i){var a=e;r?a=i.replace(lL,"$1"):n&&(a=n.trim()),t.push(a)}),t},ev.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 lv.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})},ev.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},em._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},em._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},em);function lF(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);lR._addLoader(e,i,t)}}lR._loaders={},lR._extTypeMapping={};var lP=46,lL=/\\(\\)?/g,lD=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lI=((ex=(ey=function(){this._events=Object.create(null),this._eventCount=0,this._dispatchingListeners=[]}).prototype).hasEvent=function(e){return null!=this._events[e]},ex.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ex.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ex.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},ex.on=function(e,t){return this._addEventListener(e,t)},ex.once=function(e,t){return this._addEventListener(e,t,!0)},ex.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},ex.removeEventListener=function(e,t){return this.off(e,t)},ex.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ex._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},ex._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},ey),lB=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},s6(e,[{key:"type",get:function(){return this._type}}]),e}();lB._propertyIdMap=Object.create(null),lB._propertyNameCounter=0,lB._propertyNameMap=Object.create(null);var lN=((eC=(eT=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new s1,this._deltaTimeValue=new s1,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},eC._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},eC._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(eT._elapsedTimeProperty,t),n.set(this._deltaTime,0,0,0),e.setVector4(eT._deltaTimeProperty,n)},s6(eT,[{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}}]),eT);lN._elapsedTimeProperty=lB.getByName("scene_ElapsedTime"),lN._deltaTimeProperty=lB.getByName("scene_DeltaTime"),e.DataType=void 0,(eS=e.DataType||(e.DataType={}))[eS.FLOAT=5126]="FLOAT",eS[eS.FLOAT_VEC2=35664]="FLOAT_VEC2",eS[eS.FLOAT_VEC3=35665]="FLOAT_VEC3",eS[eS.FLOAT_VEC4=35666]="FLOAT_VEC4",eS[eS.INT=5124]="INT",eS[eS.INT_VEC2=35667]="INT_VEC2",eS[eS.INT_VEC3=35668]="INT_VEC3",eS[eS.INT_VEC4=35669]="INT_VEC4",eS[eS.BOOL=35670]="BOOL",eS[eS.BOOL_VEC2=35671]="BOOL_VEC2",eS[eS.BOOL_VEC3=35672]="BOOL_VEC3",eS[eS.BOOL_VEC4=35673]="BOOL_VEC4",eS[eS.FLOAT_MAT2=35674]="FLOAT_MAT2",eS[eS.FLOAT_MAT3=35675]="FLOAT_MAT3",eS[eS.FLOAT_MAT4=35676]="FLOAT_MAT4",eS[eS.FLOAT_ARRAY=35677]="FLOAT_ARRAY",eS[eS.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",eS[eS.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",eS[eS.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",eS[eS.INT_ARRAY=100003]="INT_ARRAY",eS[eS.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",eS[eS.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",eS[eS.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",eS[eS.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",eS[eS.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",eS[eS.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",eS[eS.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",eS[eS.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",eS[eS.SAMPLER_2D=35678]="SAMPLER_2D",eS[eS.SAMPLER_CUBE=35680]="SAMPLER_CUBE",eS[eS.BYTE=5120]="BYTE",eS[eS.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",eS[eS.SHORT=5122]="SHORT",eS[eS.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",eS[eS.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(ew=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",ew.standardDerivatives="OES_standard_derivatives",ew.shaderTextureLod="EXT_shader_texture_lod",ew.elementIndexUint="OES_element_index_uint",ew.depthTexture="WEBGL_depth_texture",ew.drawBuffers="WEBGL_draw_buffers",ew.vertexArrayObject="OES_vertex_array_object",ew.instancedArrays="ANGLE_instanced_arrays",ew.multipleSample="multipleSampleOnlySupportedInWebGL2",ew.textureFloat="OES_texture_float",ew.textureFloatLinear="OES_texture_float_linear",ew.textureHalfFloat="OES_texture_half_float",ew.textureHalfFloatLinear="OES_texture_half_float_linear",ew.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",ew.colorBufferFloat="EXT_color_buffer_float",ew.colorBufferHalfFloat="EXT_color_buffer_half_float",ew.textureFilterAnisotropic="EXT_texture_filter_anisotropic",ew.blendMinMax="EXT_blend_minmax",ew.astc="WEBGL_compressed_texture_astc",ew.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",ew.etc="WEBGL_compressed_texture_etc",ew.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",ew.etc1="WEBGL_compressed_texture_etc1",ew.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",ew.pvrtc="WEBGL_compressed_texture_pvrtc",ew.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",ew.s3tc="WEBGL_compressed_texture_s3tc",ew.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",ew.WEBGL_lose_context="WEBGL_lose_context";var lV=((eE=(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++},eE.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(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},eA),lO=((eb=(eM=function(){this._renderers=new lV,this._onStartScripts=new lV,this._onUpdateScripts=new lV,this._onLateUpdateScripts=new lV,this._onPhysicsUpdateScripts=new lV,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new lV,this._onUpdateRenderers=new lV,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},eb.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},eb.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},eb.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},eb.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},eb.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},eb.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},eb.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},eb.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},eb.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},eb.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},eb.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addDisableScript=function(e){this._disableScripts.push(e)},eb.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},eb.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}},eb.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)}},eb.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)}},eb.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()}},eb.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},eb.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},eb.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}},eb.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)}},eb.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)}},eb.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},eb.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},eb._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},eM),lU=(s9(eR=function(e){var t;return(t=lc.call(this,e.engine)||this)._awoken=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},lc),(eF=eR.prototype)._onAwake=function(){},eF._onEnable=function(){},eF._onDisable=function(){},eF._setActive=function(e){var t=this._entity;e?(!this._awoken&&t._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&t._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(t._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable())},eF._onDestroy=function(){lc.prototype._onDestroy.call(this),this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable()},s6(eR,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,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}}]),eR);ln([li],lU.prototype,"_entity",void 0),ln([li],lU.prototype,"_awoken",void 0),ln([li],lU.prototype,"_phasedActive",void 0),ln([la],lU.prototype,"_enabled",void 0);var lz=((eP=function(){})._addCheck=function(e,t){for(;t!==lU;){var n=eP._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)}},eP._removeCheck=function(e,t){for(;t!==lU;){var n=eP._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)}},eP._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eP._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eP);function lk(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){lz._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return lz._addInvDependency(t,e)})}}lz._invDependenciesMap=new Map,lz._dependenciesMap=new Map,e.DependentMode=void 0,(eL=e.DependentMode||(e.DependentMode={}))[eL.CheckOnly=0]="CheckOnly",eL[eL.AutoAdd=1]="AutoAdd",e.Layer=void 0,(eD=e.Layer||(e.Layer={}))[eD.Layer0=1]="Layer0",eD[eD.Layer1=2]="Layer1",eD[eD.Layer2=4]="Layer2",eD[eD.Layer3=8]="Layer3",eD[eD.Layer4=16]="Layer4",eD[eD.Layer5=32]="Layer5",eD[eD.Layer6=64]="Layer6",eD[eD.Layer7=128]="Layer7",eD[eD.Layer8=256]="Layer8",eD[eD.Layer9=512]="Layer9",eD[eD.Layer10=1024]="Layer10",eD[eD.Layer11=2048]="Layer11",eD[eD.Layer12=4096]="Layer12",eD[eD.Layer13=8192]="Layer13",eD[eD.Layer14=16384]="Layer14",eD[eD.Layer15=32768]="Layer15",eD[eD.Layer16=65536]="Layer16",eD[eD.Layer17=131072]="Layer17",eD[eD.Layer18=262144]="Layer18",eD[eD.Layer19=524288]="Layer19",eD[eD.Layer20=1048576]="Layer20",eD[eD.Layer21=2097152]="Layer21",eD[eD.Layer22=4194304]="Layer22",eD[eD.Layer23=8388608]="Layer23",eD[eD.Layer24=16777216]="Layer24",eD[eD.Layer25=33554432]="Layer25",eD[eD.Layer26=67108864]="Layer26",eD[eD.Layer27=134217728]="Layer27",eD[eD.Layer28=268435456]="Layer28",eD[eD.Layer29=536870912]="Layer29",eD[eD.Layer30=1073741824]="Layer30",eD[eD.Layer31=2147483648]="Layer31",eD[eD.Everything=4294967295]="Everything",eD[eD.Nothing=0]="Nothing";var lG=((eI=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],w=t[n+2],A=t[n+3],E=t[n+4],M=t[n+5],b=t[n+6],R=t[n+7],F=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*w+v*A,r[i+1]=s*C+h*S+p*w+y*A,r[i+2]=l*C+d*S+g*w+x*A,r[i+3]=c*C+_*S+m*w+T*A,r[i+4]=o*E+u*M+f*b+v*R,r[i+5]=s*E+h*M+p*b+y*R,r[i+6]=l*E+d*M+g*b+x*R,r[i+7]=c*E+_*M+m*b+T*R,r[i+8]=o*F+u*P+f*L+v*D,r[i+9]=s*F+h*P+p*L+y*D,r[i+10]=l*F+d*P+g*L+x*D,r[i+11]=c*F+_*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},eI._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},eI.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},eI.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))},eI.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eI.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eI.resolveAbsoluteUrl=function(e,t){return eI.isAbsoluteUrl(t)?t:"."===t.charAt(0)?eI._formatRelativePath(t+t):e.substring(0,e.lastIndexOf("/")+1)+t},eI._stringToPath=function(e){var t=[];return e.charCodeAt(0)===lH&&t.push(""),e.replace(lX,function(e,n,r,i){var a=e;r?a=i.replace(lW,"$1"):n&&(a=n.trim()),t.push(a)}),t},eI._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("/")},eI),lH=46,lW=/\\(\\)?/g,lX=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lK=((eN=(eB=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eN.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eN._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)lG.removeFromArray(e[t]._updateFlags,this)},s9(eV=function(){var e;return e=eB.apply(this,arguments)||this,e.flag=!0,e},eB),eV.prototype.dispatch=function(){this.flag=!0},eV),lj=((eU=(eO=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eU.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eU.removeFlag=function(e){lG.removeFromArray(this._updateFlags,e)&&lG.removeFromArray(e._flagManagers,this)},eU.addListener=function(e){this._listeners.push(e)},eU.removeListener=function(e){lG.removeFromArray(this._listeners,e)},eU.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)},eO),lq=(s9(ez=function(e){var t;return(t=lU.call(this,e)||this)._position=new sW,t._rotation=new sW,t._rotationQuaternion=new sJ,t._scale=new sW(1,1,1),t._worldPosition=new sW,t._worldRotation=new sW,t._worldRotationQuaternion=new sJ,t._lossyWorldScale=new sW(1,1,1),t._localMatrix=new sZ,t._worldMatrix=new sZ,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new lj,t._onPositionChanged=t._onPositionChanged.bind(s5(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(s5(t)),t._onRotationChanged=t._onRotationChanged.bind(s5(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(s5(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(s5(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(s5(t)),t._onScaleChanged=t._onScaleChanged.bind(s5(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},lU),(ek=ez.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},ek.setRotation=function(e,t,n){this._rotation.set(e,t,n)},ek.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},ek.setScale=function(e,t,n){this._scale.set(e,t,n)},ek.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},ek.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},ek.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},ek.translate=function(e,t,n,r){if("number"==typeof e){var i=ez._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},ek.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},ek.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*sH.degreeToRadFactor;sJ.rotationAxisAngle(e,r,ez._tempQuat0),this._rotateByQuat(ez._tempQuat0,n)},ek.lookAt=function(e,t){var n=ez._tempVec30;sW.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=sH.zeroTolerance)){n.scale(1/r);var i=ez._tempVec31;if(t?sW.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=sH.zeroTolerance)){i.scale(1/r);var a=ez._tempVec32;sW.cross(n,i,a);var o=ez._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)}}},ek.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(lK)},ek._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},ek._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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},ek._getScaleMatrix=function(){var e=ez._tempQuat0,t=ez._tempMat30,n=ez._tempMat31,r=ez._tempMat32;return n.copyFromMatrix(this.worldMatrix),sJ.invert(this.worldRotationQuaternion,e),sQ.rotationQuaternion(e,t),sQ.multiply(t,n,r),r},ek._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},ek._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ek._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ek._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ek._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},ek._rotateByQuat=function(e,t){t?sJ.multiply(this.rotationQuaternion,e,this._rotationQuaternion):sJ.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},ek._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=ez._tempVec30;sW.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},ek._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=sH.degreeToRadFactor,a=ez._tempQuat0;sJ.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},ek._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},ek._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(sZ.invert(t.worldMatrix,ez._tempMat41),sW.transformCoordinate(e,ez._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},ek._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},ek._onWorldRotationChanged=function(){var e=this._worldRotation;sJ.rotationEuler(sH.degreeToRadian(e.x),sH.degreeToRadian(e.y),sH.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},ek._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},ek._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=ez._tempQuat0;sJ.invert(t.worldRotationQuaternion,n),sJ.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},ek._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},s6(ez,[{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(sH.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(sH.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,sJ.rotationEuler(sH.degreeToRadian(this._rotation.x),sH.degreeToRadian(this._rotation.y),sH.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):sJ.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?sJ.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):sJ.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)&&(sZ.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?sZ.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?(sZ.invert(t.worldMatrix,ez._tempMat42),sZ.multiply(ez._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 sW),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 sW),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 sW),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),ez);lq._tempQuat0=new sJ,lq._tempVec30=new sW,lq._tempVec31=new sW,lq._tempVec32=new sW,lq._tempMat30=new sQ,lq._tempMat31=new sQ,lq._tempMat32=new sQ,lq._tempMat41=new sZ,lq._tempMat42=new sZ,ln([ls],lq.prototype,"_position",void 0),ln([ls],lq.prototype,"_rotation",void 0),ln([ls],lq.prototype,"_rotationQuaternion",void 0),ln([ls],lq.prototype,"_scale",void 0),ln([ls],lq.prototype,"_worldPosition",void 0),ln([ls],lq.prototype,"_worldRotation",void 0),ln([ls],lq.prototype,"_worldRotationQuaternion",void 0),ln([ls],lq.prototype,"_lossyWorldScale",void 0),ln([ls],lq.prototype,"_localMatrix",void 0),ln([ls],lq.prototype,"_worldMatrix",void 0),ln([li],lq.prototype,"_worldForward",void 0),ln([li],lq.prototype,"_worldRight",void 0),ln([li],lq.prototype,"_worldUp",void 0),ln([li],lq.prototype,"_isParentDirty",void 0),ln([li],lq.prototype,"_parentTransformCache",void 0),ln([li],lq.prototype,"_updateFlagManager",void 0),ln([li],lq.prototype,"_onPositionChanged",null),ln([li],lq.prototype,"_onWorldPositionChanged",null),ln([li],lq.prototype,"_onRotationChanged",null),ln([li],lq.prototype,"_onWorldRotationChanged",null),ln([li],lq.prototype,"_onRotationQuaternionChanged",null),ln([li],lq.prototype,"_onWorldRotationQuaternionChanged",null),ln([li],lq.prototype,"_onScaleChanged",null),(eG=o9||(o9={}))[eG.LocalEuler=1]="LocalEuler",eG[eG.LocalQuat=2]="LocalQuat",eG[eG.WorldPosition=4]="WorldPosition",eG[eG.WorldEuler=8]="WorldEuler",eG[eG.WorldQuat=16]="WorldQuat",eG[eG.WorldScale=32]="WorldScale",eG[eG.LocalMatrix=64]="LocalMatrix",eG[eG.WorldMatrix=128]="WorldMatrix",eG[eG.WmWp=132]="WmWp",eG[eG.WmWeWq=152]="WmWeWq",eG[eG.WmWpWeWq=156]="WmWpWeWq",eG[eG.WmWs=160]="WmWs",eG[eG.WmWpWs=164]="WmWpWs",eG[eG.WmWpWeWqWs=188]="WmWpWeWqWs";var lY=((eH=function(){}).cloneComponent=function(e,t){for(var n=ll.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 o6.Assignment:t[o]=e[o];break;case o6.Shallow:var s=e[o];if(lr(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case o6.Deep:var c=e[o];if(lr(c,Object)){var u=t[o];null==u&&(u=t[o]=c.constructor()),ll.deepCloneObject(c,u)}else t[o]=c}}e._cloneTo&&e._cloneTo(t)},eH),lQ=(s9(eW=function(t,n){var r;return(r=lc.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new lV,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new sZ,r.name=n,r.transform=r.addComponent(lq),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},lc),(eX=eW.prototype).addComponent=function(e){lz._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0),t},eX.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(lr(r,e))return r}},eX.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];lr(a,e)&&t.push(a)}return t},eX.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eX.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=this._scene;t._scene!==r&&eW._traverseSetOwnerScene(t,r),this._isActiveInHierarchy?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive(),t._setTransformDirty()}else t._setParent(this,n)},eX.removeChild=function(e){e._setParent(null)},eX.getChild=function(e){return this._children[e]},eX.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},eX.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=eW._findChildByName(n,a)))return null}return n},eX.createChild=function(e){var t=new eW(this.engine,e);return t.layer=this.layer,t.parent=this,t},eX.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n._parent=null,n._isActiveInHierarchy&&n._processInActive(),eW._traverseSetOwnerScene(n,null)}e.length=0},eX.clone=function(){var e=new eW(this._engine,this.name),t=this._hookResource;t&&(e._hookResource=t,t._addReferCount(1)),e._isActive=this._isActive,e.transform.localMatrix=this.transform.localMatrix;for(var n=this._children,r=0,i=this._children.length;r<i;r++){var a=n[r];e.addChild(a.clone())}for(var o=this._components,s=0,l=o.length;s<l;s++){var c=o[s];if(!lr(c,lq)){var u=e.addComponent(c.constructor);lY.cloneComponent(c,u)}}return e},eX.destroy=function(){if(!this._destroyed){lc.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()}},eX._removeComponent=function(e){lz._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eX._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eX._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eX._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}},eX._processActive=function(){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._engine._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents),this._setActiveComponents(!0)},eX._processInActive=function(){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._engine._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents),this._setActiveComponents(!1)},eX._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++}},eX._setParent=function(e,t){var n=this._parent;if(e!==n){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var r=e._scene;this._scene!==r&&eW._traverseSetOwnerScene(this,r),e._isActiveInHierarchy?!this._isActiveInHierarchy&&this._isActive&&this._processActive():this._isActiveInHierarchy&&this._processInActive()}else this._isActiveInHierarchy&&this._processInActive(),n&&eW._traverseSetOwnerScene(this,null);this._setTransformDirty()}},eX._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];lr(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},eX._setActiveComponents=function(e){for(var t=this._activeChangedComponents,n=0,r=t.length;n<r;++n)t[n]._setActive(e);this._engine._componentsManager.putActiveChangedTempList(t),this._activeChangedComponents=null},eX._setActiveInHierarchy=function(e){this._isActiveInHierarchy=!0;for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];(r.enabled||!r._awoken)&&e.push(r)}for(var i=this._children,a=i.length-1;a>=0;a--){var o=i[a];o.isActive&&o._setActiveInHierarchy(e)}},eX._setInActiveInHierarchy=function(e){this._isActiveInHierarchy=!1;for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];r.enabled&&e.push(r)}for(var i=this._children,a=i.length-1;a>=0;a--){var o=i[a];o.isActive&&o._setInActiveInHierarchy(e)}},eX._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eX._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}}},eX.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(sZ.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eW._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},eW._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=e.childCount-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},s6(eW,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent;((null==t?void 0:t._isActiveInHierarchy)||this._isRoot&&this._scene._isActiveInEngine)&&this._processActive()}else this._isActiveInHierarchy&&this._processInActive()}}},{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)}}]),eW);e.ColorSpace=void 0,(eK=e.ColorSpace||(e.ColorSpace={}))[eK.Linear=0]="Linear",eK[eK.Gamma=1]="Gamma",e.PointerPhase=void 0,(ej=e.PointerPhase||(e.PointerPhase={}))[ej.Down=0]="Down",ej[ej.Move=1]="Move",ej[ej.Stationary=2]="Stationary",ej[ej.Up=3]="Up",ej[ej.Leave=4]="Leave";var lJ=((eY=(eq=function(t){this.phase=e.PointerPhase.Leave,this.position=new s0,this.deltaPosition=new s0,this._events=[],this._upMap=[],this._downMap=[],this._upList=new lV,this._downList=new lV,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}},eY._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},eY._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)}},eY._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}},eq),lZ=((eQ=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?eQ.platform=e.Platform.IPhone:/iPad/i.test(n)?eQ.platform=e.Platform.IPad:/Android/i.test(n)?eQ.platform=e.Platform.Android:/Macintosh/i.test(n)&&(eQ.platform=e.Platform.Mac),eQ.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"}}},s6(eQ,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),eQ);lZ.platform=e.Platform.Unknown,lZ.operatingSystem="",lZ._initialize(),e.Keys=void 0,(eJ=e.Keys||(e.Keys={}))[eJ.Backquote=0]="Backquote",eJ[eJ.Backslash=1]="Backslash",eJ[eJ.Backspace=2]="Backspace",eJ[eJ.BracketLeft=3]="BracketLeft",eJ[eJ.BracketRight=4]="BracketRight",eJ[eJ.Comma=5]="Comma",eJ[eJ.Digit0=6]="Digit0",eJ[eJ.Digit1=7]="Digit1",eJ[eJ.Digit2=8]="Digit2",eJ[eJ.Digit3=9]="Digit3",eJ[eJ.Digit4=10]="Digit4",eJ[eJ.Digit5=11]="Digit5",eJ[eJ.Digit6=12]="Digit6",eJ[eJ.Digit7=13]="Digit7",eJ[eJ.Digit8=14]="Digit8",eJ[eJ.Digit9=15]="Digit9",eJ[eJ.Equal=16]="Equal",eJ[eJ.IntlBackslash=17]="IntlBackslash",eJ[eJ.IntlRo=18]="IntlRo",eJ[eJ.IntlYen=19]="IntlYen",eJ[eJ.KeyA=20]="KeyA",eJ[eJ.KeyB=21]="KeyB",eJ[eJ.KeyC=22]="KeyC",eJ[eJ.KeyD=23]="KeyD",eJ[eJ.KeyE=24]="KeyE",eJ[eJ.KeyF=25]="KeyF",eJ[eJ.KeyG=26]="KeyG",eJ[eJ.KeyH=27]="KeyH",eJ[eJ.KeyI=28]="KeyI",eJ[eJ.KeyJ=29]="KeyJ",eJ[eJ.KeyK=30]="KeyK",eJ[eJ.KeyL=31]="KeyL",eJ[eJ.KeyM=32]="KeyM",eJ[eJ.KeyN=33]="KeyN",eJ[eJ.KeyO=34]="KeyO",eJ[eJ.KeyP=35]="KeyP",eJ[eJ.KeyQ=36]="KeyQ",eJ[eJ.KeyR=37]="KeyR",eJ[eJ.KeyS=38]="KeyS",eJ[eJ.KeyT=39]="KeyT",eJ[eJ.KeyU=40]="KeyU",eJ[eJ.KeyV=41]="KeyV",eJ[eJ.KeyW=42]="KeyW",eJ[eJ.KeyX=43]="KeyX",eJ[eJ.KeyY=44]="KeyY",eJ[eJ.KeyZ=45]="KeyZ",eJ[eJ.Minus=46]="Minus",eJ[eJ.Period=47]="Period",eJ[eJ.Quote=48]="Quote",eJ[eJ.Semicolon=49]="Semicolon",eJ[eJ.Slash=50]="Slash",eJ[eJ.AltLeft=51]="AltLeft",eJ[eJ.AltRight=52]="AltRight",eJ[eJ.CapsLock=53]="CapsLock",eJ[eJ.ContextMenu=54]="ContextMenu",eJ[eJ.ControlLeft=55]="ControlLeft",eJ[eJ.ControlRight=56]="ControlRight",eJ[eJ.Enter=57]="Enter",eJ[eJ.MetaLeft=58]="MetaLeft",eJ[eJ.MetaRight=59]="MetaRight",eJ[eJ.ShiftLeft=60]="ShiftLeft",eJ[eJ.ShiftRight=61]="ShiftRight",eJ[eJ.Space=62]="Space",eJ[eJ.Tab=63]="Tab",eJ[eJ.Convert=64]="Convert",eJ[eJ.KanaMode=65]="KanaMode",eJ[eJ.Lang1=66]="Lang1",eJ[eJ.Lang2=67]="Lang2",eJ[eJ.Lang3=68]="Lang3",eJ[eJ.Lang4=69]="Lang4",eJ[eJ.Lang5=70]="Lang5",eJ[eJ.NonConvert=71]="NonConvert",eJ[eJ.Delete=72]="Delete",eJ[eJ.End=73]="End",eJ[eJ.Help=74]="Help",eJ[eJ.Home=75]="Home",eJ[eJ.Insert=76]="Insert",eJ[eJ.PageDown=77]="PageDown",eJ[eJ.PageUp=78]="PageUp",eJ[eJ.ArrowDown=79]="ArrowDown",eJ[eJ.ArrowLeft=80]="ArrowLeft",eJ[eJ.ArrowRight=81]="ArrowRight",eJ[eJ.ArrowUp=82]="ArrowUp",eJ[eJ.NumLock=83]="NumLock",eJ[eJ.Numpad0=84]="Numpad0",eJ[eJ.Numpad1=85]="Numpad1",eJ[eJ.Numpad2=86]="Numpad2",eJ[eJ.Numpad3=87]="Numpad3",eJ[eJ.Numpad4=88]="Numpad4",eJ[eJ.Numpad5=89]="Numpad5",eJ[eJ.Numpad6=90]="Numpad6",eJ[eJ.Numpad7=91]="Numpad7",eJ[eJ.Numpad8=92]="Numpad8",eJ[eJ.Numpad9=93]="Numpad9",eJ[eJ.NumpadAdd=94]="NumpadAdd",eJ[eJ.NumpadBackspace=95]="NumpadBackspace",eJ[eJ.NumpadClear=96]="NumpadClear",eJ[eJ.NumpadClearEntry=97]="NumpadClearEntry",eJ[eJ.NumpadComma=98]="NumpadComma",eJ[eJ.NumpadDecimal=99]="NumpadDecimal",eJ[eJ.NumpadDivide=100]="NumpadDivide",eJ[eJ.NumpadEnter=101]="NumpadEnter",eJ[eJ.NumpadEqual=102]="NumpadEqual",eJ[eJ.NumpadHash=103]="NumpadHash",eJ[eJ.NumpadMemoryAdd=104]="NumpadMemoryAdd",eJ[eJ.NumpadMemoryClear=105]="NumpadMemoryClear",eJ[eJ.NumpadMemoryRecall=106]="NumpadMemoryRecall",eJ[eJ.NumpadMemoryStore=107]="NumpadMemoryStore",eJ[eJ.NumpadMemorySubtract=108]="NumpadMemorySubtract",eJ[eJ.NumpadMultiply=109]="NumpadMultiply",eJ[eJ.NumpadParenLeft=110]="NumpadParenLeft",eJ[eJ.NumpadParenRight=111]="NumpadParenRight",eJ[eJ.NumpadStar=112]="NumpadStar",eJ[eJ.NumpadSubtract=113]="NumpadSubtract",eJ[eJ.Escape=114]="Escape",eJ[eJ.F1=115]="F1",eJ[eJ.F2=116]="F2",eJ[eJ.F3=117]="F3",eJ[eJ.F4=118]="F4",eJ[eJ.F5=119]="F5",eJ[eJ.F6=120]="F6",eJ[eJ.F7=121]="F7",eJ[eJ.F8=122]="F8",eJ[eJ.F9=123]="F9",eJ[eJ.F10=124]="F10",eJ[eJ.F11=125]="F11",eJ[eJ.F12=126]="F12",eJ[eJ.F13=127]="F13",eJ[eJ.F14=128]="F14",eJ[eJ.F15=129]="F15",eJ[eJ.Fn=130]="Fn",eJ[eJ.FnLock=131]="FnLock",eJ[eJ.PrintScreen=132]="PrintScreen",eJ[eJ.ScrollLock=133]="ScrollLock",eJ[eJ.Pause=134]="Pause",eJ[eJ.BrowserBack=135]="BrowserBack",eJ[eJ.BrowserFavorites=136]="BrowserFavorites",eJ[eJ.BrowserForward=137]="BrowserForward",eJ[eJ.BrowserHome=138]="BrowserHome",eJ[eJ.BrowserRefresh=139]="BrowserRefresh",eJ[eJ.BrowserSearch=140]="BrowserSearch",eJ[eJ.BrowserStop=141]="BrowserStop",eJ[eJ.Eject=142]="Eject",eJ[eJ.LaunchApp1=143]="LaunchApp1",eJ[eJ.LaunchApp2=144]="LaunchApp2",eJ[eJ.LaunchMail=145]="LaunchMail",eJ[eJ.MediaPlayPause=146]="MediaPlayPause",eJ[eJ.MediaSelect=147]="MediaSelect",eJ[eJ.MediaStop=148]="MediaStop",eJ[eJ.MediaTrackNext=149]="MediaTrackNext",eJ[eJ.MediaTrackPrevious=150]="MediaTrackPrevious",eJ[eJ.Power=151]="Power",eJ[eJ.Sleep=152]="Sleep",eJ[eJ.AudioVolumeDown=153]="AudioVolumeDown",eJ[eJ.AudioVolumeMute=154]="AudioVolumeMute",eJ[eJ.AudioVolumeUp=155]="AudioVolumeUp",eJ[eJ.WakeUp=156]="WakeUp",eJ[eJ.Hyper=157]="Hyper",eJ[eJ.Super=158]="Super",eJ[eJ.Turbo=159]="Turbo",eJ[eJ.Abort=160]="Abort",eJ[eJ.Resume=161]="Resume",eJ[eJ.Suspend=162]="Suspend",eJ[eJ.Again=163]="Again",eJ[eJ.Copy=164]="Copy",eJ[eJ.Cut=165]="Cut",eJ[eJ.Find=166]="Find",eJ[eJ.Open=167]="Open",eJ[eJ.Paste=168]="Paste",eJ[eJ.Props=169]="Props",eJ[eJ.Select=170]="Select",eJ[eJ.Undo=171]="Undo",eJ[eJ.Hiragana=172]="Hiragana",eJ[eJ.Katakana=173]="Katakana",eJ[eJ.Unidentified=174]="Unidentified";var l$=((e$=(eZ=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new lV,this._curFrameDownList=new lV,this._curFrameUpList=new lV,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,lZ.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}},e$._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},e$._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)},e$._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap=null,this._nativeEvents=null,this._curFrameHeldDownList=null,this._curFrameDownList=null,this._curFrameUpList=null},e$._onKeyEvent=function(e){this._nativeEvents.push(e)},eZ);e.CameraClearFlags=void 0,(e0=e.CameraClearFlags||(e.CameraClearFlags={}))[e0.None=0]="None",e0[e0.Color=1]="Color",e0[e0.Depth=2]="Depth",e0[e0.Stencil=4]="Stencil",e0[e0.ColorDepth=3]="ColorDepth",e0[e0.ColorStencil=5]="ColorStencil",e0[e0.DepthStencil=6]="DepthStencil",e0[e0.All=7]="All";var l0=function(){this.entity=null,this.distance=0,this.point=new sW,this.normal=new sW},l1=function(){function t(e){var n=this;this._initialized=!1,this._restTime=0,this._colliders=new lV,this._gravity=new sW(0,-9.81,0),this._physicalObjectsMap={},this._onContactEnter=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionEnter(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionEnter(f)}}},this._onContactExit=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionExit(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionExit(f)}}},this._onContactStay=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionStay(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionStay(f)}}},this._onTriggerEnter=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerEnter(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerEnter(r)}},this._onTriggerExit=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerExit(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerExit(r)}},this._onTriggerStay=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerStay(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerStay(r)}},this.fixedTimeStep=1/60,this._engine=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity}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._physicalObjectsMap[e];return t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsManager.raycast(t,s,c):!!this._nativePhysicsManager.raycast(t,s,c,function(e,t,n,r){a.entity=o._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._initialize=function(e){t._nativePhysics=e,this._nativePhysicsManager=t._nativePhysics.createPhysicsManager(this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay),this._initialized=!0},n._update=function(e){var t=this.fixedTimeStep,n=this._nativePhysicsManager,r=this._engine._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._physicalObjectsMap[e.id]=e,this._nativePhysicsManager.addColliderShape(e._nativeShape)},n._removeColliderShape=function(e){delete this._physicalObjectsMap[e.id],this._nativePhysicsManager.removeColliderShape(e._nativeShape)},n._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCollider(e._nativeCollider)},n._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCharacterController(e._nativeCollider)},n._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCollider(e._nativeCollider)},n._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.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._nativePhysicsManager.setGravity(this._gravity)},s6(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}}]),t}();l1._collision=new function(){},e.PhysicsMaterialCombineMode=void 0,(e1=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[e1.Average=0]="Average",e1[e1.Minimum=1]="Minimum",e1[e1.Multiply=2]="Multiply",e1[e1.Maximum=3]="Maximum";var l2=((e2=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=l1._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},s6(e2,[{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))}}]),e2);e.Collider=(s9(e3=function(e){var t;return(t=lU.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lU),(e4=e3.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this.engine.physicsManager._addColliderShape(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape))},e4.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this.engine.physicsManager._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},e4.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++){var r=e[t];this.engine.physicsManager._removeColliderShape(r),r._destroy(),this._nativeCollider.removeShape(r._nativeShape)}e.length=0},e4._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}},e4._onLateUpdate=function(){},e4._onEnable=function(){this.engine.physicsManager._addCollider(this)},e4._onDisable=function(){this.engine.physicsManager._removeCollider(this)},e4._onDestroy=function(){lU.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},s6(e3,[{key:"shapes",get:function(){return this._shapes}}]),e3),ln([li],e.Collider.prototype,"_index",void 0),e.Collider=ln([lk(lq,e.DependentMode.CheckOnly)],e.Collider),e.ControllerNonWalkableMode=void 0,(e5=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[e5.PreventClimbing=0]="PreventClimbing",e5[e5.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var l3=(e8=e.Collider,s9(e6=function(t){var n;return(n=e8.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sW(0,1,0),n._slopeLimit=.707,n._nativeCollider=l1._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(s5(n)),n._upDirection._onValueChanged=n._setUpDirection,n},e8),(e7=e6.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},e7.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";e8.prototype.addShape.call(this,e),this._updateFlag.flag=!0},e7.clearShapes=function(){this._shapes.length>0&&e8.prototype.removeShape.call(this,this._shapes[0])},e7._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}},e7._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},e7._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},e7._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},e7._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},s6(e6,[{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))}}]),e6),l4=function(){function e(){this._isTrigger=!1,this._rotation=new sW,this._position=new sW,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new l2,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)},s6(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}();l4._idGenerator=0;var l5=(s9(e9=function(){var e;return(e=l4.call(this)||this)._size=new sW(1,1,1),e._nativeShape=l1._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(s5(e)),e._size._onValueChanged=e._setSize,e},l4),e9.prototype._setSize=function(){this._nativeShape.setSize(this._size)},s6(e9,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),e9),l8=(s9(te=function(){var e;return(e=l4.call(this)||this)._radius=1,e._nativeShape=l1._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},l4),s6(te,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),te),l6=(s9(tt=function(){var e;return(e=l4.call(this)||this)._nativeShape=l1._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},l4),tt);e.ColliderShapeUpAxis=void 0,(tn=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[tn.X=0]="X",tn[tn.Y=1]="Y",tn[tn.Z=2]="Z";var l7=(s9(tr=function(){var t;return(t=l4.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=l1._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},l4),s6(tr,[{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))}}]),tr);e.Joint=(s9(ti=function(e){var t;return(t=lU.call(this,e)||this)._connectedCollider=new l9,t._collider=new l9,t._force=0,t._torque=0,t._connectedCollider.localPosition=new sW,t},lU),s6(ti,[{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))}}]),ti),e.Joint=ln([lk(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var l9=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},ce=(ta=e.Joint,s9(to=function(){return ta.apply(this,arguments)},ta),to.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createFixedJoint(t.collider._nativeCollider)},to);(ts=se||(se={}))[ts.LimitEnabled=1]="LimitEnabled",ts[ts.DriveEnabled=2]="DriveEnabled",ts[ts.DriveFreeSpin=4]="DriveFreeSpin";var ct=(tl=e.Joint,s9(tc=function(){var e;return e=tl.apply(this,arguments)||this,e._axis=new sW(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},tl),tc.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sW,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createHingeJoint(t.collider._nativeCollider)},s6(tc,[{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&se.LimitEnabled)==se.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=se.LimitEnabled),this._nativeJoint.setHingeJointFlag(se.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&se.DriveEnabled)==se.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=se.DriveEnabled),this._nativeJoint.setHingeJointFlag(se.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(se.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))}}]),tc),cn=(tu=e.Joint,s9(th=function(){var e;return e=tu.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},tu),th.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sW,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createSpringJoint(t.collider._nativeCollider)},s6(th,[{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))}}]),th),cr=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},ci=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(td=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[td.Sides=1]="Sides",td[td.Up=2]="Up",td[td.Down=4]="Down";var ca=(t_=e.Collider,s9(tf=function(e){var t,n=(t=t_.call(this,e)||this).entity.transform;return t._nativeCollider=l1._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},t_),tf),co=(tp=e.Collider,s9(tg=function(e){(t=tp.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sW,t._angularVelocity=new sW,t._mass=1,t._centerOfMass=new sW,t._inertiaTensor=new sW(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=l1._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(s5(t)),t._setAngularVelocity=t._setAngularVelocity.bind(s5(t)),t._setCenterOfMass=t._setCenterOfMass.bind(s5(t)),t._setInertiaTensor=t._setInertiaTensor.bind(s5(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},tp),(tm=tg.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},tm.applyTorque=function(e){this._nativeCollider.addTorque(e)},tm.move=function(e,t){this._nativeCollider.move(e,t)},tm.sleep=function(){this._nativeCollider.sleep()},tm.wakeUp=function(){this._nativeCollider.wakeUp()},tm._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},tm._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},tm._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},tm._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},tm._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},s6(tg,[{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))}}]),tg);e.CollisionDetectionMode=void 0,(tv=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[tv.Discrete=0]="Discrete",tv[tv.Continuous=1]="Continuous",tv[tv.ContinuousDynamic=2]="ContinuousDynamic",tv[tv.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(ty=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[ty.None=0]="None",ty[ty.FreezePositionX=1]="FreezePositionX",ty[ty.FreezePositionY=2]="FreezePositionY",ty[ty.FreezePositionZ=4]="FreezePositionZ",ty[ty.FreezeRotationX=8]="FreezeRotationX",ty[ty.FreezeRotationY=16]="FreezeRotationY",ty[ty.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(tx=e.PointerButton||(e.PointerButton={}))[tx.None=0]="None",tx[tx.Primary=1]="Primary",tx[tx.Secondary=2]="Secondary",tx[tx.Auxiliary=4]="Auxiliary",tx[tx.XButton1=8]="XButton1",tx[tx.XButton2=16]="XButton2",tx[tx.XButton3=32]="XButton3",tx[tx.XButton4=64]="XButton4",tx[tx.XButton5=128]="XButton5",tx[tx.XButton6=256]="XButton6",tx[tx.XButton7=512]="XButton7",tx[tx.XButton8=1024]="XButton8";var cs=[1,4,2,8,16,32,64,128,256,512,1024],cl={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},cc=((tC=(tT=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new lV,this._downList=new lV,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._updatePointerWithPhysics=this._updatePointerWithPhysics.bind(this),this._updatePointerWithoutPhysics=this._updatePointerWithoutPhysics.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._engine.physicsManager._initialized?this._updatePointerWithPhysics:this._updatePointerWithoutPhysics,u=this._htmlCanvas.getBoundingClientRect(),h=this._htmlCanvas,d=h.clientWidth,_=h.clientHeight,f=this._canvas,p=f.width,g=f.height,m=r;m>=0;m--){var v=t[m];v._upList.length=v._downList.length=0,c(l,v,u,d,_,p,g),this._buttons|=v.pressedButtons}},tC._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}},tC._onBlur=function(){if(this._hadListener){var t=this._htmlCanvas,n=this._onPointerEvent;t.removeEventListener("pointerdown",n),t.removeEventListener("pointerup",n),t.removeEventListener("pointerleave",n),t.removeEventListener("pointermove",n),t.removeEventListener("pointercancel",n),this._hadListener=!1,this._downList.length=0,this._upList.length=0;for(var r=this._pointers,i=r.length-1;i>=0;i--)r[i].phase=e.PointerPhase.Leave;r.length=0}},tC._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._pointers.length=0,this._downList.length=0,this._upList.length=0,this._htmlCanvas=null,this._engine=null},tC._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},tC._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},tC._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 lJ(a)),o._uniqueID=e,t.splice(a,0,o),o},tC._pointerRayCast=function(t,n){for(var r=tT._tempPoint,i=tT._tempRay,a=tT._tempHitResult,o=this._engine.sceneManager.activeScene._activeCameras,s=o.length-1;s>=0;s--){var l=o[s];if(l.enabled&&!l.renderTarget){var c=l.viewport,u=c.x,h=c.y,d=c.z,_=c.w;if(t>=u&&n>=h&&t-u<=d&&n-h<=_){if(r.set((t-u)/d,(n-h)/_),this._engine.physicsManager.raycast(l.viewportPointToRay(r,i),Number.MAX_VALUE,l.cullingMask,a))return a.entity;if(l.clearFlags&e.CameraClearFlags.Color)return null}}}},tC._updatePointerWithPhysics=function(t,n,r,i,a,o,s){var l=n._events,c=n.position,u=l.length;if(u>0){var h=this._upList,d=this._upMap,_=this._downList,f=this._downMap,p=l[u-1],g=(p.clientX-r.left)/i,m=(p.clientY-r.top)/a,v=g*o,y=m*s;n.deltaPosition.set(v-c.x,y-c.y),c.set(v,y),n._firePointerDrag();var x=this._pointerRayCast(g,m);n._firePointerExitAndEnter(x);for(var T=0;T<u;T++){var C=l[T],S=C.button;switch(n.button=cs[S]||e.PointerButton.None,n.pressedButtons=C.buttons,C.type){case"pointerdown":_.add(S),f[S]=t,n._downList.add(S),n._downMap[S]=t,n.phase=e.PointerPhase.Down,n._firePointerDown(x);break;case"pointerup":h.add(S),d[S]=t,n._upList.add(S),n._upMap[S]=t,n.phase=e.PointerPhase.Up,n._firePointerUpAndClick(x);break;case"pointermove":n.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":n.phase=e.PointerPhase.Leave,n._firePointerExitAndEnter(null)}}n._events.length=0}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary,n._firePointerDrag(),n._firePointerExitAndEnter(this._pointerRayCast(c.x/o,c.y/s))},tC._updatePointerWithoutPhysics=function(t,n,r,i,a,o,s){var l=n._events,c=l.length;if(c>0){var u=n.position,h=l[c-1],d=(h.clientX-r.left)/i*o,_=(h.clientY-r.top)/a*s;n.deltaPosition.set(d-u.x,_-u.y),u.set(d,_),n.button=cs[h.button]||e.PointerButton.None,n.pressedButtons=h.buttons;for(var f=this._upList,p=this._upMap,g=this._downList,m=this._downMap,v=0;v<c;v++){var y=l[v].button;switch(l[v].type){case"pointerdown":g.add(y),m[y]=t,n._downList.add(y),n._downMap[y]=t,n.phase=e.PointerPhase.Down;break;case"pointerup":f.add(y),p[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}}n._events.length=0}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary},tT);cc._tempRay=new s$,cc._tempPoint=new s0,cc._tempHitResult=new l0;var cu=((tw=(tS=function(e){this._delta=new sW,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}},tw._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},tw._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},tw._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},tw._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},tS),ch=((tE=(tA=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&lr(t,OffscreenCanvas)||(this._wheelManager=new cu(e),this._pointerManager=new cc(e),this._keyboardManager=new l$(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])},tE.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},tE.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},tE.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},tE.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[cl[e]]===this._engine.time.frameCount)},tE.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[cl[e]]===this._engine.time.frameCount)},tE._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},tE._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},tE._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},tE._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},s6(tA,[{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}}]),tA);e.ShadowCascadesMode=void 0,(tM=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tM.NoCascades=1]="NoCascades",tM[tM.TwoCascades=2]="TwoCascades",tM[tM.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(tb=e.ShadowResolution||(e.ShadowResolution={}))[tb.Low=0]="Low",tb[tb.Medium=1]="Medium",tb[tb.High=2]="High",tb[tb.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tR=e.ShadowType||(e.ShadowType={}))[tR.None=0]="None",tR[tR.Hard=1]="Hard",tR[tR.SoftLow=2]="SoftLow",tR[tR.SoftHigh=3]="SoftHigh";var cd=(s9(tF=function(){var t;return t=lU.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 s2(1,1,1,1),t._lightColor=new s2,t},lU),tF.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},s6(tF,[{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 sZ),sZ.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new sZ),sZ.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),tF);cd._maxLight=10,ln([li],cd.prototype,"_lightIndex",void 0);var c_=(s9(tP=function(){var e;return e=cd.apply(this,arguments)||this,e._reverseDirection=new sW,e},cd),(tL=tP.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.direction,s=tP._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]=s2.gammaToLinearSpace(a.r),s.color[r+1]=s2.gammaToLinearSpace(a.g),s.color[r+2]=s2.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},tL._onEnable=function(){this.engine._lightManager._attachDirectLight(this)},tL._onDisable=function(){this.engine._lightManager._detachDirectLight(this)},tP._updateShaderData=function(e){var t=tP._combinedData;e.setIntArray(tP._cullingMaskProperty,t.cullingMask),e.setFloatArray(tP._colorProperty,t.color),e.setFloatArray(tP._directionProperty,t.direction)},s6(tP,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sW.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tP);c_._cullingMaskProperty=lB.getByName("scene_DirectLightCullingMask"),c_._colorProperty=lB.getByName("scene_DirectLightColor"),c_._directionProperty=lB.getByName("scene_DirectLightDirection"),c_._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),direction:new Float32Array(3*cd._maxLight)};var cf=(s9(tD=function(){var e;return e=cd.apply(this,arguments)||this,e.distance=100,e},cd),(tI=tD.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.position,s=tD._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]=s2.gammaToLinearSpace(a.r),s.color[r+1]=s2.gammaToLinearSpace(a.g),s.color[r+2]=s2.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},tI._onEnable=function(){this.engine._lightManager._attachPointLight(this)},tI._onDisable=function(){this.engine._lightManager._detachPointLight(this)},tD._updateShaderData=function(e){var t=tD._combinedData;e.setIntArray(tD._cullingMaskProperty,t.cullingMask),e.setFloatArray(tD._colorProperty,t.color),e.setFloatArray(tD._positionProperty,t.position),e.setFloatArray(tD._distanceProperty,t.distance)},s6(tD,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tD);cf._cullingMaskProperty=lB.getByName("scene_PointLightCullingMask"),cf._colorProperty=lB.getByName("scene_PointLightColor"),cf._positionProperty=lB.getByName("scene_PointLightPosition"),cf._distanceProperty=lB.getByName("scene_PointLightDistance"),cf._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),position:new Float32Array(3*cd._maxLight),distance:new Float32Array(cd._maxLight)};var cp=(s9(tB=function(){var e;return e=cd.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new sW,e._projectMatrix=new sZ,e},cd),(tN=tB.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=tB._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]=s2.gammaToLinearSpace(o.r),c.color[r+1]=s2.gammaToLinearSpace(o.g),c.color[r+2]=s2.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)},tN._onEnable=function(){this.engine._lightManager._attachSpotLight(this)},tN._onDisable=function(){this.engine._lightManager._detachSpotLight(this)},tB._updateShaderData=function(e){var t=tB._combinedData;e.setIntArray(tB._cullingMaskProperty,t.cullingMask),e.setFloatArray(tB._colorProperty,t.color),e.setFloatArray(tB._positionProperty,t.position),e.setFloatArray(tB._directionProperty,t.direction),e.setFloatArray(tB._distanceProperty,t.distance),e.setFloatArray(tB._angleCosProperty,t.angleCos),e.setFloatArray(tB._penumbraCosProperty,t.penumbraCos)},s6(tB,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sW.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 sZ.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),tB);cp._cullingMaskProperty=lB.getByName("scene_SpotLightCullingMask"),cp._colorProperty=lB.getByName("scene_SpotLightColor"),cp._positionProperty=lB.getByName("scene_SpotLightPosition"),cp._directionProperty=lB.getByName("scene_SpotLightDirection"),cp._distanceProperty=lB.getByName("scene_SpotLightDistance"),cp._angleCosProperty=lB.getByName("scene_SpotLightAngleCos"),cp._penumbraCosProperty=lB.getByName("scene_SpotLightPenumbraCos"),cp._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),position:new Float32Array(3*cd._maxLight),direction:new Float32Array(3*cd._maxLight),distance:new Float32Array(cd._maxLight),angleCos:new Float32Array(cd._maxLight),penumbraCos:new Float32Array(cd._maxLight)};var cg=((tO=(tV=function(){this._spotLights=new lV,this._pointLights=new lV,this._directLights=new lV}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},tO._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},tO._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},tO._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._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},tO._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?(c_._updateShaderData(e),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),a?(cf._updateShaderData(e),e.enableMacro("SCENE_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),i?(cp._updateShaderData(e),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},tO._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},tV);(tU=st||(st={}))[tU.Scene=0]="Scene",tU[tU.Camera=1]="Camera",tU[tU.Renderer=2]="Renderer",tU[tU.Material=3]="Material",e.ShaderPropertyType=void 0,(tz=e.ShaderPropertyType||(e.ShaderPropertyType={}))[tz.Float=0]="Float",tz[tz.Int=1]="Int",tz[tz.Vector2=2]="Vector2",tz[tz.Vector3=3]="Vector3",tz[tz.Vector4=4]="Vector4",tz[tz.Matrix=5]="Matrix",tz[tz.Color=6]="Color",tz[tz.Texture=7]="Texture",tz[tz.FloatArray=8]="FloatArray",tz[tz.IntArray=9]="IntArray",tz[tz.TextureArray=10]="TextureArray";var cm=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}();cm._macroMaskMap=[],cm._macroNameIdMap=Object.create(null),cm._macroNameCounter=0,cm._macroCounter=0,cm._macroMap=Object.create(null);var cv=((tG=(tk=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},tG.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}},tG.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]},tG.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}},tG.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}},tG.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},tG.clear=function(){this._length=0},tk.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},tk),cy=((tW=(tH=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new cv,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},tW.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},tW.getInt=function(e){return this.getPropertyValue(e)},tW.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},tW.getFloatArray=function(e){return this.getPropertyValue(e)},tW.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},tW.getIntArray=function(e){return this.getPropertyValue(e)},tW.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},tW.getVector2=function(e){return this.getPropertyValue(e)},tW.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},tW.getVector3=function(e){return this.getPropertyValue(e)},tW.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},tW.getVector4=function(e){return this.getPropertyValue(e)},tW.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},tW.getMatrix=function(e){return this.getPropertyValue(e)},tW.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},tW.getColor=function(e){return this.getPropertyValue(e)},tW.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},tW.getTexture=function(e){return this.getPropertyValue(e)},tW.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)},tW.getTextureArray=function(e){return this.getPropertyValue(e)},tW.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)},tW.getPropertyValue=function(e){return"string"==typeof e&&(e=lB.getByName(e)),this._propertyValueMap[e._uniqueId]},tW.enableMacro=function(e,t){"string"==typeof e&&(e=cm.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}},tW.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=cm._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},tW.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])},tW.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=lB._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},tW.clone=function(){var e=new tH(this._group);return this.cloneTo(e),e},tW.cloneTo=function(e){ll.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,i=Object.keys(n),a=0,o=i.length;a<o;a++){var s=i[a],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(lr(l,ly))r[s]=l,t>0&&l._addReferCount(t);else if(lr(l,Array)||lr(l,Float32Array)||lr(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},tW._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lB.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 "+st[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},tW._getReferCount=function(){return this._refCount},tW._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&lr(r,ly)&&r._addReferCount(e)}},tH);e.RenderQueueType=void 0,(tX=e.RenderQueueType||(e.RenderQueueType={}))[tX.Opaque=0]="Opaque",tX[tX.AlphaTest=1]="AlphaTest",tX[tX.Transparent=2]="Transparent",e.BlendFactor=void 0,(tK=e.BlendFactor||(e.BlendFactor={}))[tK.Zero=0]="Zero",tK[tK.One=1]="One",tK[tK.SourceColor=2]="SourceColor",tK[tK.OneMinusSourceColor=3]="OneMinusSourceColor",tK[tK.DestinationColor=4]="DestinationColor",tK[tK.OneMinusDestinationColor=5]="OneMinusDestinationColor",tK[tK.SourceAlpha=6]="SourceAlpha",tK[tK.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",tK[tK.DestinationAlpha=8]="DestinationAlpha",tK[tK.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",tK[tK.SourceAlphaSaturate=10]="SourceAlphaSaturate",tK[tK.BlendColor=11]="BlendColor",tK[tK.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(tj=e.BlendOperation||(e.BlendOperation={}))[tj.Add=0]="Add",tj[tj.Subtract=1]="Subtract",tj[tj.ReverseSubtract=2]="ReverseSubtract",tj[tj.Min=3]="Min",tj[tj.Max=4]="Max",e.ColorWriteMask=void 0,(tq=e.ColorWriteMask||(e.ColorWriteMask={}))[tq.None=0]="None",tq[tq.Red=1]="Red",tq[tq.Green=2]="Green",tq[tq.Blue=4]="Blue",tq[tq.Alpha=8]="Alpha",tq[tq.All=15]="All";var cx=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},cT=((tQ=(tY=function(){this.targetBlendState=new cx,this.blendColor=new s2(0,0,0,0),this.alphaToCoverage=!1}).prototype)._apply=function(e,t){this._platformApply(e,t.blendState)},tQ._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(tY._getGLBlendFactor(t,c),tY._getGLBlendFactor(t,u),tY._getGLBlendFactor(t,h),tY._getGLBlendFactor(t,d)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=d),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(r.blendEquationSeparate(tY._getGLBlendOperation(t,s),tY._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;s2.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)},tY._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}},tY._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}},tY);e.CompareFunction=void 0,(tJ=e.CompareFunction||(e.CompareFunction={}))[tJ.Never=0]="Never",tJ[tJ.Less=1]="Less",tJ[tJ.Equal=2]="Equal",tJ[tJ.LessEqual=3]="LessEqual",tJ[tJ.Greater=4]="Greater",tJ[tJ.NotEqual=5]="NotEqual",tJ[tJ.GreaterEqual=6]="GreaterEqual",tJ[tJ.Always=7]="Always";var cC=((t$=(tZ=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._apply=function(e,t){this._platformApply(e,t.depthState)},t$._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(tZ._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(n.depthMask(a),t.writeEnabled=a))},tZ._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}},tZ);e.CullMode=void 0,(t0=e.CullMode||(e.CullMode={}))[t0.Off=0]="Off",t0[t0.Front=1]="Front",t0[t0.Back=2]="Back";var cS=((t2=(t1=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)},t2._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)},t1);e.StencilOperation=void 0,(t3=e.StencilOperation||(e.StencilOperation={}))[t3.Keep=0]="Keep",t3[t3.Zero=1]="Zero",t3[t3.Replace=2]="Replace",t3[t3.IncrementSaturate=3]="IncrementSaturate",t3[t3.DecrementSaturate=4]="DecrementSaturate",t3[t3.Invert=5]="Invert",t3[t3.IncrementWrap=6]="IncrementWrap",t3[t3.DecrementWrap=7]="DecrementWrap";var cw=((t5=(t4=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)},t5._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,t4._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(n.stencilFuncSeparate(n.BACK,t4._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,t4._getGLStencilOperation(e,l),t4._getGLStencilOperation(e,c),t4._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(h!==t.failOperationBack||d!==t.zFailOperationBack||_!==t.passOperationBack)&&(n.stencilOpSeparate(n.BACK,t4._getGLStencilOperation(e,h),t4._getGLStencilOperation(e,d),t4._getGLStencilOperation(e,_)),t.failOperationBack=h,t.zFailOperationBack=d,t.passOperationBack=_),f!==t.writeMask&&(n.stencilMask(f),t.writeMask=f)}},t4._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}},t4._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}},t4),cA=((t8=function(){this.blendState=new cT,this.depthState=new cC,this.stencilState=new cw,this.rasterState=new cS,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)},t8),cE=(s9(t6=function(e,t){var n;return(n=lu.call(this,e)||this)._renderStates=[],n._shaderData=new cy(st.Material),n.shader=t,n},lu),(t7=t6.prototype).clone=function(){var e=new t6(this._engine,this.shader);return this.cloneTo(e),e},t7.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),ll.deepCloneObject(this.renderStates,e.renderStates)},t7._addReferCount=function(e){lu.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e)},t7._onDestroy=function(){this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},s6(t6,[{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,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 cA);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t6),cM=((ne=(t9=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},ne.resetPool=function(){this._elementPoolIndex=0},ne.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},t9),cb=function(){},cR=(s9(nt=function(){return cb.apply(this,arguments)},cb),(nn=nt.prototype).set=function(e,t,n,r){this.component=e,this.material=t,this.mesh=n,this.subMesh=r},nn.dispose=function(){this.component=this.material=this.mesh=this.subMesh=null},nt);function cF(){return(cF=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,(nr=e.PipelineStage||(e.PipelineStage={})).ShadowCaster="ShadowCaster",nr.Forward="Forward";var cP=cF({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;}"}),cL=((ni=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},ni.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=cP[t];return void 0===n?(lv.error('Shader slice "'+e.trim()+'" not founded.'),""):ni.parseIncludes(n)})},ni.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},ni.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},ni._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)},ni),cD=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}();cD._nameCounter=0,cD._nameMap=Object.create(null);var cI=((no=(na=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var n="string"==typeof e?cD.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&lv.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},no.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?cD.getByName(e):e)._uniqueId]},no.getTagValue=function(e){return this._tagsMap["string"==typeof e?cD.getByName(e)._uniqueId:e._uniqueId]},na),cB=((nl=(ns=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)},nl.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.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)},nl.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.gammaToLinearSpace(n.g),s2.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)},nl.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.gammaToLinearSpace(n.g),s2.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)},nl.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},nl.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},nl.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},nl.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)},nl.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},nl.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)},nl.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},nl.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)},nl.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},nl.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},nl.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},nl.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},nl.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)}},ns),cN=function(){this.constUniforms=[],this.textureUniforms=[]},cV=function(){function e(t,n,r){this.sceneUniformBlock=new cN,this.cameraUniformBlock=new cN,this.rendererUniformBlock=new cN,this.materialUniformBlock=new cN,this.otherUniformBlock=new cN,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=lB._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 st.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case st.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case st.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case st.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),!lv.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(lv.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),!lv.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 cB(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=lB.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 s0(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sW(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new s1(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 s0(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=c?l.upload3iv:l.upload3i,l.cacheValue=new sW(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new s1(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=lB._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")},s6(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();cV._counter=0;var cO=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 s9(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=[];cm._getNamesByMacros(n,o);var s=cL.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 "+cL.parseIncludes(this._vertexSource),d=" "+l+"\n "+c+"\n "+(a?"":cL.parseExtension(cz._shaderExtension))+"\n "+u+"\n "+s+"\n "+cL.parseIncludes(this._fragmentSource);return a&&(h=cL.convertTo300(h),d=cL.convertTo300(d,!0)),i=new cV(t,h,d),r.cache(i),i},n}(cI);cO._shaderPassCounter=0;var cU=(s9(nc=function(e,t,n){var r;if((r=cI.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},cI),s6(nc,[{key:"passes",get:function(){return this._passes}}]),nc),cz=((nu=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var n=nu._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(cm.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},nu.create=function(e,t,n){var r,i=nu._shaderMap;if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new cO(t,n);r=new nu(e,[new cU("Default",[a])])}else if(t.length>0)r=t[0].constructor===cO?new nu(e,[new cU("Default",t)]):new nu(e,t.slice());else throw"SubShader or ShaderPass count must large than 0.";return i[e]=r,r},nu.find=function(e){return nu._shaderMap[e]},nu.getMacroByName=function(e,t){return cm.getByName(e,t)},nu.getPropertyByName=function(e){return lB.getByName(e)},s6(nu,[{key:"subShaders",get:function(){return this._subShaders}}]),nu);cz._compileMacros=new cv,cz._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],cz._shaderMap=Object.create(null);var ck=((nh=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(nh._viewMatrixProperty,e.viewMatrix),t.setMatrix(nh._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(nh.vpMatrixProperty,e.viewProjectionMatrix)},nh);ck.vpMatrixProperty=lB.getByName("camera_VPMat"),ck.pipelineStageKey=cD.getByName("pipelineStage"),ck._viewMatrixProperty=lB.getByName("camera_ViewMat"),ck._projectionMatrixProperty=lB.getByName("camera_ProjMat");var cG=((n_=(nd=function(){}).prototype).set=function(e,t,n){this.data=e,this.shaderPass=t,this.renderState=n},n_.dispose=function(){this.data=this.shaderPass=this.renderState=null},nd);function cH(){return function(e){}}e.SpriteMaskInteraction=void 0,(nf=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[nf.None=0]="None",nf[nf.VisibleInsideMask=1]="VisibleInsideMask",nf[nf.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(s9(np=function(t){(n=lU.call(this,t)||this)._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new cv,n._bounds=new sK,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._shaderData=new cy(st.Renderer),n._mvMatrix=new sZ,n._mvpMatrix=new sZ,n._mvInvMatrix=new sZ,n._normalMatrix=new sZ,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new s1,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(s5(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lU),(ng=np.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},ng.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},ng.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},ng.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},ng.getMaterials=function(){return this._materials},ng.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))}},ng.update=function(e){},ng._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},ng._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},ng._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sW.subtract(i,r,i),this._distanceForSort=sW.dot(i,n.forward)):this._distanceForSort=sW.distanceSquared(i,r),this._updateShaderData(t),this._render(t),cv.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},ng._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},ng._onDestroy=function(){lU.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},ng._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)},ng._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;sZ.multiply(i.viewMatrix,n,a),sZ.multiply(i.viewProjectionMatrix,n,o),sZ.invert(a,s),sZ.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)},ng._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},ng._updateBounds=function(e){},ng._render=function(e){throw"not implement"},ng._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},ng._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}},ng._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},s6(np,[{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}}]),(sn=np)._tempVector0=new sW,sn._receiveShadowMacro=cm.getByName("RENDERER_IS_RECEIVE_SHADOWS"),sn._localMatrixProperty=lB.getByName("renderer_LocalMat"),sn._worldMatrixProperty=lB.getByName("renderer_ModelMat"),sn._mvMatrixProperty=lB.getByName("renderer_MVMat"),sn._mvpMatrixProperty=lB.getByName("renderer_MVPMat"),sn._mvInvMatrixProperty=lB.getByName("renderer_MVInvMat"),sn._normalMatrixProperty=lB.getByName("renderer_NormalMat"),sn._rendererLayerProperty=lB.getByName("renderer_Layer"),sn),ln([li],e.Renderer.prototype,"_distanceForSort",void 0),ln([li],e.Renderer.prototype,"_onUpdateIndex",void 0),ln([li],e.Renderer.prototype,"_rendererIndex",void 0),ln([li],e.Renderer.prototype,"_globalShaderMacro",void 0),ln([ls],e.Renderer.prototype,"_bounds",void 0),ln([li],e.Renderer.prototype,"_renderFrameCount",void 0),ln([li],e.Renderer.prototype,"_overrideUpdate",void 0),ln([li],e.Renderer.prototype,"_materials",void 0),ln([li],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),ln([ls],e.Renderer.prototype,"_shaderData",void 0),ln([li],e.Renderer.prototype,"_mvMatrix",void 0),ln([li],e.Renderer.prototype,"_mvpMatrix",void 0),ln([li],e.Renderer.prototype,"_mvInvMatrix",void 0),ln([li],e.Renderer.prototype,"_normalMatrix",void 0),ln([li],e.Renderer.prototype,"_materialsInstanced",void 0),ln([li],e.Renderer.prototype,"_priority",void 0),ln([la],e.Renderer.prototype,"_receiveShadows",void 0),ln([li],e.Renderer.prototype,"_rendererLayer",void 0),ln([li],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=ln([lk(lq,e.DependentMode.CheckOnly)],e.Renderer),(nm=sr||(sr={}))[nm.WorldVolume=1]="WorldVolume";var cW=((nv=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 sW),i.push(new s0);t.triangles=cW._rectangleTriangles},nv.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=cW._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])}sK.transform(r._getBounds(),s,e._bounds)},nv.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)},(si=nv)._rectangleTriangles=[0,1,2,2,1,3],si._worldMatrix=new sZ,si);cW=ln([cH()],cW);var cX=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,(ny=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[ny.Layer0=1]="Layer0",ny[ny.Layer1=2]="Layer1",ny[ny.Layer2=4]="Layer2",ny[ny.Layer3=8]="Layer3",ny[ny.Layer4=16]="Layer4",ny[ny.Layer5=32]="Layer5",ny[ny.Layer6=64]="Layer6",ny[ny.Layer7=128]="Layer7",ny[ny.Layer8=256]="Layer8",ny[ny.Layer9=512]="Layer9",ny[ny.Layer10=1024]="Layer10",ny[ny.Layer11=2048]="Layer11",ny[ny.Layer12=4096]="Layer12",ny[ny.Layer13=8192]="Layer13",ny[ny.Layer14=16384]="Layer14",ny[ny.Layer15=32768]="Layer15",ny[ny.Layer16=65536]="Layer16",ny[ny.Layer17=131072]="Layer17",ny[ny.Layer18=262144]="Layer18",ny[ny.Layer19=524288]="Layer19",ny[ny.Layer20=1048576]="Layer20",ny[ny.Layer21=2097152]="Layer21",ny[ny.Layer22=4194304]="Layer22",ny[ny.Layer23=8388608]="Layer23",ny[ny.Layer24=16777216]="Layer24",ny[ny.Layer25=33554432]="Layer25",ny[ny.Layer26=67108864]="Layer26",ny[ny.Layer27=134217728]="Layer27",ny[ny.Layer28=268435456]="Layer28",ny[ny.Layer29=536870912]="Layer29",ny[ny.Layer30=1073741824]="Layer30",ny[ny.Layer31=2147483648]="Layer31",ny[ny.Everything=4294967295]="Everything",(nx=sa||(sa={}))[nx.texture=1]="texture",nx[nx.size=2]="size",nx[nx.atlasRotate=4]="atlasRotate",nx[nx.atlasRegion=8]="atlasRegion",nx[nx.atlasRegionOffset=16]="atlasRegionOffset",nx[nx.region=32]="region",nx[nx.pivot=64]="pivot",nx[nx.border=128]="border";var cK=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 cX(4,[],[]),cW.resetData(s5(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(s5(i)),i}s9(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?cW.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&sr.WorldVolume&&(cW.updatePositions(this),this._dirtyUpdateFlag&=~sr.WorldVolume),2&this._dirtyUpdateFlag&&(cW.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(){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 sa.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case sa.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sr.WorldVolume);break;case sa.region:case sa.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sa.atlasRegion:this._dirtyUpdateFlag|=2;break;case sa.pivot:this._dirtyUpdateFlag|=sr.WorldVolume}},s6(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|=sr.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|=sr.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sr.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sr.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);cK._textureProperty=lB.getByName("renderer_MaskTexture"),cK._alphaCutoffProperty=lB.getByName("renderer_MaskAlphaCutoff"),ln([la],cK.prototype,"influenceLayers",void 0),ln([li],cK.prototype,"_sprite",void 0),ln([li],cK.prototype,"_automaticWidth",void 0),ln([li],cK.prototype,"_automaticHeight",void 0),ln([la],cK.prototype,"_customWidth",void 0),ln([la],cK.prototype,"_customHeight",void 0),ln([la],cK.prototype,"_flipX",void 0),ln([la],cK.prototype,"_flipY",void 0),ln([la],cK.prototype,"_alphaCutoff",void 0),ln([li],cK.prototype,"_onSpriteChange",null),(nT=so||(so={}))[nT.UV=2]="UV",nT[nT.RenderData=3]="RenderData",nT[nT.AutomaticSize=4]="AutomaticSize",nT[nT.All=7]="All",e.VertexElementFormat=void 0,(nC=e.VertexElementFormat||(e.VertexElementFormat={}))[nC.Float=0]="Float",nC[nC.Vector2=1]="Vector2",nC[nC.Vector3=2]="Vector3",nC[nC.Vector4=3]="Vector4",nC[nC.Byte4=4]="Byte4",nC[nC.UByte4=5]="UByte4",nC[nC.NormalizedByte4=6]="NormalizedByte4",nC[nC.NormalizedUByte4=7]="NormalizedUByte4",nC[nC.Short2=8]="Short2",nC[nC.UShort2=9]="UShort2",nC[nC.NormalizedShort2=10]="NormalizedShort2",nC[nC.NormalizedUShort2=11]="NormalizedUShort2",nC[nC.Short4=12]="Short4",nC[nC.UShort4=13]="UShort4",nC[nC.NormalizedShort4=14]="NormalizedShort4",nC[nC.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(nS=e.IndexFormat||(e.IndexFormat={}))[nS.UInt8=0]="UInt8",nS[nS.UInt16=1]="UInt16",nS[nS.UInt32=2]="UInt32";var cj=((nw=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}},nw._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},nw._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}},nw),cq=(s6(nA=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=cj._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}}]),nA);e.BufferUsage=void 0,(nE=e.BufferUsage||(e.BufferUsage={}))[nE.Static=0]="Static",nE[nE.Dynamic=1]="Dynamic",nE[nE.Stream=2]="Stream",e.SetDataOptions=void 0,(nM=e.SetDataOptions||(e.SetDataOptions={}))[nM.None=0]="None",nM[nM.Discard=1]="Discard";var cY=(s9(nb=function(t,n,r,i){if(void 0===i&&(i=e.BufferUsage.Static),(a=ld.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},ld),(nR=nb.prototype).bind=function(){this._platformBuffer.bind()},nR.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)},nR.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},nR._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},nR._onDestroy=function(){ld.prototype._onDestroy.call(this),this._platformBuffer.destroy()},nR.resize=function(e){this._platformBuffer.resize(e),this._byteLength=e},s6(nb,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),nb);e.BufferBindFlag=void 0,(nF=e.BufferBindFlag||(e.BufferBindFlag={}))[nF.VertexBuffer=0]="VertexBuffer",nF[nF.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(nP=e.MeshTopology||(e.MeshTopology={}))[nP.Points=0]="Points",nP[nP.Lines=1]="Lines",nP[nP.LineLoop=2]="LineLoop",nP[nP.LineStrip=3]="LineStrip",nP[nP.Triangles=4]="Triangles",nP[nP.TriangleStrip=5]="TriangleStrip",nP[nP.TriangleFan=6]="TriangleFan";var cQ=(s6(nL=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),nL),cJ=((nD=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(){},nD),cZ=(s9(nI=function(e,t){(n=ld.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new lj,n._bounds=new sK,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(s5(n)),n._onBoundsChanged=n._onBoundsChanged.bind(s5(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},ld),(nB=nI.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new cJ(t,n,r)),this._subMeshes.push(t),t},nB.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},nB.clearSubMesh=function(){this._subMeshes.length=0},nB._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},nB._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nB._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},nB._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},nB._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},nB._addReferCount=function(e){ld.prototype._addReferCount.call(this,e);for(var t,n=this._vertexBufferBindings,r=0,i=n.length;r<i;r++)n[r]._buffer._addReferCount(e);null==(t=this._indexBufferBinding)||t._buffer._addReferCount(e)},nB._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this)},nB._onDestroy=function(){ld.prototype._onDestroy.call(this),this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},nB._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},nB._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))},nB._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},s6(nI,[{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}}]),nI);(nN=ss||(ss={}))[nN.Bounds=1]="Bounds",nN[nN.VertexElements=2]="VertexElements";var c$=(s6(nV=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),nV),c0=((nU=(nO=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 sW(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sW,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(lK))},nU._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},nU._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(nO._blendShapeMacro),this._useTextureMode())e.enableMacro(nO._blendShapeTextureMacro),e.setTexture(nO._blendShapeTextureProperty,this._vertexTexture),e.setVector3(nO._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(nO._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(nO._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(nO._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(nO._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(nO._blendShapeNormalMacro):e.disableMacro(nO._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(nO._blendShapeTangentMacro):e.disableMacro(nO._blendShapeTangentMacro)}else e.disableMacro(nO._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},nU._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},nU._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},nU._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},nU._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},nU._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},nU._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 cq("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new cq("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new cq("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},nU._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))},nU._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},nU._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 cY(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new c$(m,f)),o[d]=m}},nU._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 lC(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)},nU._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 s0),C.set(u+m,v*c);for(var S=g.deltaPositions,w=0;w<e;w++){var A=T+x*w,E=S[w];E&&(i[A]=E.x,i[A+1]=E.y,i[A+2]=E.z)}if(T+=3,this._useBlendNormal){var M=g.deltaNormals;if(M)for(var b=0;b<e;b++){var R=T+x*b,F=M[b];F&&(i[R]=F.x,i[R+1]=F.y,i[R+2]=F.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}}},nU._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)},nU._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},nU._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}},nU._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},nU._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)}}}},nO);c0._blendShapeMacro=cm.getByName("RENDERER_HAS_BLENDSHAPE"),c0._blendShapeTextureMacro=cm.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),c0._blendShapeNormalMacro=cm.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),c0._blendShapeTangentMacro=cm.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),c0._blendShapeWeightsProperty=lB.getByName("renderer_BlendShapeWeights"),c0._blendShapeTextureProperty=lB.getByName("renderer_BlendShapeTexture"),c0._blendShapeTextureInfoProperty=lB.getByName("renderer_BlendShapeTextureInfo"),(nz=sl||(sl={})).Position="POSITION",nz.Normal="NORMAL",nz.Color="COLOR_0",nz.Tangent="TANGENT",nz.BoneWeight="WEIGHTS_0",nz.BoneIndex="JOINTS_0",nz.UV="TEXCOORD_0",nz.UV1="TEXCOORD_1",nz.UV2="TEXCOORD_2",nz.UV3="TEXCOORD_3",nz.UV4="TEXCOORD_4",nz.UV5="TEXCOORD_5",nz.UV6="TEXCOORD_6",nz.UV7="TEXCOORD_7";var c1=(s9(nk=function(e,t){var n;return(n=cZ.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 c0(e,s5(n)),n},cZ),(nG=nk.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}},nG.getPositions=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._positions},nG.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},nG.getNormals=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._normals},nG.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},nG.getColors=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._colors},nG.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},nG.getBoneWeights=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneWeights},nG.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},nG.getBoneIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneIndices},nG.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},nG.getTangents=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._tangents},nG.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]."}},nG.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]."},nG.setIndices=function(t){this._indices!==t&&(this._indices=t,lr(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:lr(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:lr(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},nG.getIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._indices},nG.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[sl.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[sl.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[sl.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[sl.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[sl.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[sl.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[sl.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[sl.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[sl.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[sl.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[sl.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[sl.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[sl.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[sl.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},nG.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 c$(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},nG.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])},nG.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},nG.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},nG.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},nG.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 cY(this._engine,e.BufferBindFlag.VertexBuffer,a,o);this._setVertexBufferBinding(0,new c$(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 cQ(_,this._indicesFormat));else{null==_||_.destroy();var f=new cY(this._engine,e.BufferBindFlag.IndexBuffer,d);this._setIndexBufferBinding(new cQ(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())},nG.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=nk._tempVec0,o=nk._tempVec1,s=nk._tempVec2,l=nk._tempVec3,c=nk._tempVec4,u=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new s1,d[_]=new sW;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];sW.subtract(y,v,a),sW.subtract(x,v,o);var w=C.x-T.x,A=S.x-T.x,E=C.y-T.y,M=S.y-T.y,b=1/(w*M-A*E);sW.scale(a,M*b,s),sW.scale(o,E*b,c),sW.subtract(s,c,s),sW.scale(o,w*b,l),sW.scale(a,A*b,c),sW.subtract(l,c,l);var R=h[p];R.set(R.x+s.x,R.y+s.y,R.z+s.z,1),(R=h[g]).set(R.x+s.x,R.y+s.y,R.z+s.z,1),(R=h[m]).set(R.x+s.x,R.y+s.y,R.z+s.z,1),d[p].add(l),d[g].add(l),d[m].add(l)}for(var F=0;F<i;F++){var P=n[F],L=d[F],D=h[F];s.set(D.x,D.y,D.z),sW.cross(s,L,c);var I=sW.dot(c,P)>0?1:-1;sW.scale(P,sW.dot(s,P),c),sW.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,I)}this.setTangents(h)},nG._onDestroy=function(){cZ.prototype._onDestroy.call(this),this._readable&&this._releaseCache()},nG._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[sl.Position]&&this._insertVertexAttribute(sl.Position),this._normals&&!r[sl.Normal]&&this._insertVertexAttribute(sl.Normal),this._colors&&!r[sl.Color]&&this._insertVertexAttribute(sl.Color),this._boneWeights&&!r[sl.BoneWeight]&&this._insertVertexAttribute(sl.BoneWeight),this._boneIndices&&!r[sl.BoneIndex]&&this._insertVertexAttribute(sl.BoneIndex),this._tangents&&!r[sl.Tangent]&&this._insertVertexAttribute(sl.Tangent),this._uv&&!r[sl.UV]&&this._insertVertexAttribute(sl.UV),this._uv1&&!r[sl.UV1]&&this._insertVertexAttribute(sl.UV1),this._uv2&&!r[sl.UV2]&&this._insertVertexAttribute(sl.UV2),this._uv3&&!r[sl.UV3]&&this._insertVertexAttribute(sl.UV3),this._uv4&&!r[sl.UV4]&&this._insertVertexAttribute(sl.UV4),this._uv5&&!r[sl.UV5]&&this._insertVertexAttribute(sl.UV5),this._uv6&&!r[sl.UV6]&&this._insertVertexAttribute(sl.UV6),this._uv7&&!r[sl.UV7]&&this._insertVertexAttribute(sl.UV7)},nG._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)},nG._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 w=v*S+C,A=i[S];A&&(e[w]=A.x,e[w+1]=A.y,e[w+2]=A.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 R=0;R<n;R++){var F=v*R+C,P=s[R];P&&(e[F]=P.x,e[F+1]=P.y,e[F+2]=P.z,e[F+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},nG._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 cq(e,a,t,0)),this._bufferStrides[0]=a+n},nG._getAttributeFormat=function(t){switch(t){case sl.Position:case sl.Normal:return e.VertexElementFormat.Vector3;case sl.Color:case sl.BoneWeight:return e.VertexElementFormat.Vector4;case sl.BoneIndex:return e.VertexElementFormat.UByte4;case sl.Tangent:return e.VertexElementFormat.Vector4;case sl.UV:case sl.UV1:case sl.UV2:case sl.UV3:case sl.UV4:case sl.UV5:case sl.UV6:case sl.UV7:return e.VertexElementFormat.Vector2}},nG._getAttributeByteLength=function(e){switch(e){case sl.Position:case sl.Normal:return 12;case sl.Color:case sl.BoneWeight:return 16;case sl.BoneIndex:return 4;case sl.Tangent:return 16;case sl.UV:case sl.UV1:case sl.UV2:case sl.UV3:case sl.UV4:case sl.UV5:case sl.UV6:case sl.UV7:return 8}},nG._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()},s6(nk,[{key:"readable",get:function(){return this._readable}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[sl.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}}]),nk);c1._tempVec0=new sW,c1._tempVec1=new sW,c1._tempVec2=new sW,c1._tempVec3=new sW,c1._tempVec4=new sW,(nH=sc||(sc={}))[nH.Position=1]="Position",nH[nH.Normal=2]="Normal",nH[nH.Color=4]="Color",nH[nH.Tangent=8]="Tangent",nH[nH.BoneWeight=16]="BoneWeight",nH[nH.BoneIndex=32]="BoneIndex",nH[nH.UV=64]="UV",nH[nH.UV1=128]="UV1",nH[nH.UV2=256]="UV2",nH[nH.UV3=512]="UV3",nH[nH.UV4=1024]="UV4",nH[nH.UV5=2048]="UV5",nH[nH.UV6=4096]="UV6",nH[nH.UV7=8192]="UV7",nH[nH.All=65535]="All";var c2=(s9(nW=function(e){var t;return(t=lc.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},lc),nW),c3=(nX=e.Renderer,s9(nK=function(e){var t;return(t=nX.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(s5(t)),t},nX),(nj=nK.prototype)._onDestroy=function(){nX.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},nj._cloneTo=function(e){nX.prototype._cloneTo.call(this,e),e.mesh=this._mesh},nj._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sK.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},nj._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(nK._uvMacro),n.disableMacro(nK._uv1Macro),n.disableMacro(nK._normalMacro),n.disableMacro(nK._tangentMacro),n.disableMacro(nK._enableVertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(nK._uvMacro);break;case"TEXCOORD_1":n.enableMacro(nK._uv1Macro);break;case"NORMAL":n.enableMacro(nK._normalMacro);break;case"TANGENT":n.enableMacro(nK._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&n.enableMacro(nK._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 lv.error("mesh is null.")},nj._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},nj._onMeshChanged=function(e){e&ss.Bounds&&(this._dirtyUpdateFlag|=sr.WorldVolume),e&ss.VertexElements&&(this._dirtyUpdateFlag|=2)},s6(nK,[{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)}}]),nK);c3._uvMacro=cm.getByName("RENDERER_HAS_UV"),c3._uv1Macro=cm.getByName("RENDERER_HAS_UV1"),c3._normalMacro=cm.getByName("RENDERER_HAS_NORMAL"),c3._tangentMacro=cm.getByName("RENDERER_HAS_TANGENT"),c3._enableVertexColorMacro=cm.getByName("RENDERER_ENABLE_VERTEXCOLOR"),ln([li],c3.prototype,"_mesh",void 0),ln([li],c3.prototype,"_onMeshChanged",null),(nq=su||(su={}))[nq.VertexElementMacro=2]="VertexElementMacro",nq[nq.All=3]="All";var c4=(s9(nY=function(e){(t=c3.call(this,e)||this)._hasInitSkin=!1,t._jointDataCreateCache=new s0(-1,-1),t._localBounds=new sK,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(s5(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},c3),(nQ=nY.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?lG._floatMatrixMultiply(o.transform.worldMatrix,t[a].elements,0,i,s):i.set(t[a].elements,s),lG._floatMatrixMultiply(n,i,s,i,s)}},nQ._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 lT(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(nY._jointSamplerProperty,this._jointTexture)):lv.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(nY._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)},nQ._onDestroy=function(){var e,t;c3.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._jointEntities&&(this._jointEntities.length=0,this._jointEntities=null)},nQ._cloneTo=function(e){c3.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},nQ._registerEntityTransformListener=function(){},nQ._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sK.transform(t,n,e)}else c3.prototype._updateBounds.call(this,e)},nQ._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)sK.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var c=new sZ(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?(sZ.multiplyScalar(c,1/u,c),sK.transform(this._mesh.bounds,c,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("RENDERER_HAS_SKIN"),t.setInt(nY._jointCountProperty,r)):t.disableMacro("RENDERER_HAS_SKIN")}},nQ._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?(sZ.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},nQ._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},nQ._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)},nQ._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=sr.WorldVolume},s6(nY,[{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|=sr.WorldVolume}}]),nY);c4._jointCountProperty=lB.getByName("renderer_JointCount"),c4._jointSamplerProperty=lB.getByName("renderer_JointSampler"),c4._jointMatrixProperty=lB.getByName("renderer_JointMatrix"),ln([li],c4.prototype,"_hasInitSkin",void 0),ln([li],c4.prototype,"_jointDataCreateCache",void 0),ln([li],c4.prototype,"_blendShapeWeights",void 0),ln([li],c4.prototype,"_maxVertexUniformVectors",void 0),ln([li],c4.prototype,"_rootBone",void 0),ln([li],c4.prototype,"_localBounds",void 0),ln([li],c4.prototype,"_jointMatrices",void 0),ln([li],c4.prototype,"_jointTexture",void 0),ln([li],c4.prototype,"_jointEntities",void 0),ln([li],c4.prototype,"_condensedBlendShapeWeights",void 0),ln([li],c4.prototype,"_onLocalBoundsChanged",null);var c5=(s9(nJ=function(e,t){var n;return(n=lh.call(this,e)||this).primitiveInfo=t,n},lh),nJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:ui._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0);break;case 1:ui._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0);break;case 2:ui._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0);break;case 3:ui._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 4:ui._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0);break;case 5:ui._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 6:ui._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0)}},nJ);(nZ=sh||(sh={}))[nZ.Sphere=0]="Sphere",nZ[nZ.Cuboid=1]="Cuboid",nZ[nZ.Plane=2]="Plane",nZ[nZ.Cylinder=3]="Cylinder",nZ[nZ.Torus=4]="Torus",nZ[nZ.Cone=5]="Cone",nZ[nZ.Capsule=6]="Capsule";var c8=function(e,t){this.type=e,this.noLongerAccessible=t},c6=(s9(n$=function(e,t,n){var r;return(r=c8.call(this,0,n)||this).radius=e,r.segments=t,r},c8),n$),c7=(s9(n0=function(e,t,n,r){var i;return(i=c8.call(this,1,r)||this).width=e,i.height=t,i.depth=n,i},c8),n0),c9=(s9(n1=function(e,t,n,r,i){var a;return(a=c8.call(this,2,i)||this).width=e,a.height=t,a.horizontalSegments=n,a.verticalSegments=r,a},c8),n1),ue=(s9(n2=function(e,t,n,r,i,a){var o;return(o=c8.call(this,3,a)||this).radiusTop=e,o.radiusBottom=t,o.height=n,o.radialSegments=r,o.heightSegments=i,o},c8),n2),ut=(s9(n3=function(e,t,n,r,i,a){var o;return(o=c8.call(this,4,a)||this).radius=e,o.tubeRadius=t,o.radialSegments=n,o.tubularSegments=r,o.arc=i,o},c8),n3),un=(s9(n4=function(e,t,n,r,i){var a;return(a=c8.call(this,5,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},c8),n4),ur=(s9(n5=function(e,t,n,r,i){var a;return(a=c8.call(this,6,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},c8),n5),ui=((n8=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 c1(e);return n8._setSphereData(i,t,n,r,!1),e.resourceManager.addContentRestorer(new c5(i,new c6(t,n,r))),i},n8.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 c1(e);return n8._setCuboidData(a,t,n,r,i,!1),e.resourceManager.addContentRestorer(new c5(a,new c7(t,n,r,i))),a},n8.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 c1(e);return n8._setPlaneData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new c9(t,n,r,i,a))),o},n8.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 c1(e);return n8._setCylinderData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new c5(s,new ue(t,n,r,i,a,o))),s},n8.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 c1(e);return n8._setTorusData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new c5(s,new ut(t,n,r,i,a,o))),s},n8.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 c1(e);return n8._setConeData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new un(t,n,r,i,a))),o},n8.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 c1(e);return n8._setCapsuleData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new ur(t,n,r,i,a))),o},n8._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=n8._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),w=t*Math.sin(y)*T;_[g]=new sW(C,S,w),f[g]=new sW(C,S,w),p[g]=new s0(m,v)}for(var A=0,E=0;E<s;++E){var M=E%n,b=(E*d|0)*a+M,R=b+1,F=b+a,P=F+1;l[A++]=R,l[A++]=b,l[A++]=P,l[A++]=b,l[A++]=F,l[A++]=P}if(!i){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}n8._initialize(e,_,f,p,l,r,i)},n8._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 sW(-o,s,-l),c[1]=new sW(o,s,-l),c[2]=new sW(o,s,l),c[3]=new sW(-o,s,l),u[0]=new sW(0,1,0),u[1]=new sW(0,1,0),u[2]=new sW(0,1,0),u[3]=new sW(0,1,0),h[0]=new s0(0,0),h[1]=new s0(1,0),h[2]=new s0(1,1),h[3]=new s0(0,1),c[4]=new sW(-o,-s,-l),c[5]=new sW(o,-s,-l),c[6]=new sW(o,-s,l),c[7]=new sW(-o,-s,l),u[4]=new sW(0,-1,0),u[5]=new sW(0,-1,0),u[6]=new sW(0,-1,0),u[7]=new sW(0,-1,0),h[4]=new s0(0,1),h[5]=new s0(1,1),h[6]=new s0(1,0),h[7]=new s0(0,0),c[8]=new sW(-o,s,-l),c[9]=new sW(-o,s,l),c[10]=new sW(-o,-s,l),c[11]=new sW(-o,-s,-l),u[8]=new sW(-1,0,0),u[9]=new sW(-1,0,0),u[10]=new sW(-1,0,0),u[11]=new sW(-1,0,0),h[8]=new s0(0,0),h[9]=new s0(1,0),h[10]=new s0(1,1),h[11]=new s0(0,1),c[12]=new sW(o,s,-l),c[13]=new sW(o,s,l),c[14]=new sW(o,-s,l),c[15]=new sW(o,-s,-l),u[12]=new sW(1,0,0),u[13]=new sW(1,0,0),u[14]=new sW(1,0,0),u[15]=new sW(1,0,0),h[12]=new s0(1,0),h[13]=new s0(0,0),h[14]=new s0(0,1),h[15]=new s0(1,1),c[16]=new sW(-o,s,l),c[17]=new sW(o,s,l),c[18]=new sW(o,-s,l),c[19]=new sW(-o,-s,l),u[16]=new sW(0,0,1),u[17]=new sW(0,0,1),u[18]=new sW(0,0,1),u[19]=new sW(0,0,1),h[16]=new s0(0,0),h[17]=new s0(1,0),h[18]=new s0(1,1),h[19]=new s0(0,1),c[20]=new sW(-o,s,-l),c[21]=new sW(o,s,-l),c[22]=new sW(o,-s,-l),c[23]=new sW(-o,-s,-l),u[20]=new sW(0,0,-1),u[21]=new sW(0,0,-1),u[22]=new sW(0,0,-1),u[23]=new sW(0,0,-1),h[20]=new s0(1,0),h[21]=new s0(0,0),h[22]=new s0(0,1),h[23]=new s0(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)}n8._initialize(e,c,u,h,d,i,a)},n8._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=n8._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,w=C*g|0;y[C]=new sW(S*h-c,0,w*d-u),x[C]=new sW(0,1,0),T[C]=new s0(S*m,w*v)}for(var A=0,E=0;E<f;++E){var M=E%r,b=(E*m|0)*s+M,R=b+1,F=b+s,P=F+1;p[A++]=b,p[A++]=F,p[A++]=R,p[A++]=F,p[A++]=P,p[A++]=R}if(!o){var L=e.bounds;L.min.set(-c,0,-u),L.max.set(c,0,u)}n8._initialize(e,y,x,T,p,a,o)},n8._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=n8._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,w=Math.PI,A=2*Math.PI,E=n-t,M=E/r,b=E/a,R=0;R<d;++R){var F=R%l,P=R*m|0,L=F*v,D=P*y,I=w+L*A,B=Math.sin(I),N=Math.cos(I),V=n-P*b,O=V*B,U=P*h-u,z=V*N;x[R]=new sW(O,U,z),T[R]=new sW(B,M,N),C[R]=new s0(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 sW(0,-u,0),T[d]=new sW(0,-1,0),C[d]=new s0(.5,.5),x[d+1]=new sW(0,u,0),T[d+1]=new sW(0,1,0),C[d+1]=new s0(.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 sW($,-u,ee),T[j]=new sW(0,-1,0),C[j++]=new s0($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[j]=new sW($,u,ee),T[j]=new sW(0,1,0),C[j++]=new s0($*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)}n8._initialize(e,x,T,C,g,o,s)},n8._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=n8._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 sW((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var w=t*T,A=t*C;d[f]=new sW(S.x-w,S.y-A,S.z).normalize(),_[f++]=new s0(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,R=(i+1)*(E-1)+M-1,F=(i+1)*(E-1)+M,P=(i+1)*E+M;u[f++]=b,u[f++]=R,u[f++]=P,u[f++]=R,u[f++]=F,u[f++]=P}if(!s){var L=e.bounds,D=t+n;L.min.set(-D,-D,-n),L.max.set(D,D,n)}n8._initialize(e,h,d,_,u,o,s)},n8._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=n8._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,w=t/n,A=0;A<h;++A){var E=A%s,M=A*p|0,b=E*g,R=M*m,F=C+b*S,P=Math.sin(F),L=Math.cos(F),D=t-M*t,I=D*P,B=M*u-c,N=D*L;v[A]=new sW(I,B,N),y[A]=new sW(P,w,L),x[A]=new s0(b,1-R)}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 sW(0,-c,0),y[h]=new sW(0,-1,0),x[h]=new s0(.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 sW(j,-c,q),y[H]=new sW(0,-1,0),x[H++]=new s0(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)}n8._initialize(e,v,y,x,f,a,o)},n8._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=n8._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),w=Array(p),A=0,E=0;E<h;++E){var M=E%s,b=E*m|0,R=M*v,F=b*y,P=x+R*T,L=Math.sin(P),D=Math.cos(P);C[E]=new sW(t*L,b*u-c,t*D),S[E]=new sW(L,0,D),w[E]=new s0(R,1-F)}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[A++]=V,g[A++]=O,g[A++]=N,g[A++]=V,g[A++]=U,g[A++]=O}if(n8._createCapsuleCap(t,n,r,T,h,1,C,S,w,g,A),n8._createCapsuleCap(t,n,r,-T,h+_,-1,C,S,w,g,A+6*f),!o){var z=e.bounds;z.min.set(-t,-t-c,-t),z.max.set(t,t+c,t)}n8._initialize(e,C,S,w,g,a,o)},n8._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)},n8._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},n8._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,w=e*Math.cos(T)*a+d,A=e*Math.sin(x)*C,E=m+i;o[E]=new sW(S,w,A),s[E]=new sW(S,w-d,A),l[E]=new s0(v,y)}for(var M=0;M<f;++M){var b=M%n,R=(M*g|0)*h+b+i,F=R+1,P=R+h,L=P+1;c[u++]=F,c[u++]=R,c[u++]=L,c[u++]=R,c[u++]=P,c[u++]=L}},n8),ua=(s9(n6=function(){return cZ.apply(this,arguments)},cZ),(n7=n6.prototype).setVertexElements=function(e){this._setVertexElements(e)},n7.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 c$(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},n7.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])},n7.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new cQ(e,t))),this._setIndexBufferBinding(n)},s6(n6,[{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}}]),n6),uo=((n9=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new lj,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},s6(n9,[{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)}}]),n9);(re=sd||(sd={}))[re.Position=1]="Position",re[re.Normal=2]="Normal",re[re.Tangent=4]="Tangent",re[re.All=7]="All";var us=((rn=(rt=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new lj,this._dataChangeManager=new lj,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 uo(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},rn.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()},rn._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},rn._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(sd.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},rn._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))},rn._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},s6(rt,[{key:"frames",get:function(){return this._frames}}]),rt),ul=((ri=(rr=function(e){this._subMeshPool=new cM(cJ),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)},ri._initMeshes=function(e){var t=rr.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)},ri.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rr._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},ri.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},ri.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},ri._drawSubElement=function(e,t){var n=e.data.verticesData.vertexCount;this._vertexCount+n>rr.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=n,this._batchedQueue[this._elementCount++]=e},ri._createMesh=function(t,n){var r=rr.MAX_VERTEX_COUNT,i=new ua(t,"BufferMesh"+n);i.isGCIgnored=!0;var a=[],o=this.createVertexElements(a),s=this._vertexBuffers[n]=new cY(t,e.BufferBindFlag.VertexBuffer,4*r*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[n]=new cY(t,e.BufferBindFlag.IndexBuffer,6*r,e.BufferUsage.Dynamic);return l.isGCIgnored=!0,i.setVertexBufferBinding(s,o),i.setIndexBufferBinding(l,e.IndexFormat.UInt16),i.setVertexElements(a),i},ri._updateData=function(e){var t=this._meshes,n=this._flushId;!rr._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)},ri._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},rr);ul._disableBatchTag=cD.getByName("spriteDisableBatching"),ul.MAX_VERTEX_COUNT=4096,ul._canUploadSameBuffer=!0;var uc=(s9(ra=function(){return ul.apply(this,arguments)},ul),(ro=ra.prototype).createVertexElements=function(t){return t[0]=new cq("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},ro.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=cK._textureProperty,s=cK._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},ro.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},ro.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=cz._compileMacros;cv.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)}},ra),uu=((rl=(rs=function(e){this._preMaskLayer=0,this._batcher=new uc(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rl.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t))},rl.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rl.destroy=function(){this._batcher.destroy(),this._batcher=null},rl._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)}}}},rs),uh=(s9(rc=function(){var e;return(e=cb.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},cb),(ru=rc.prototype).set=function(e,t,n){this.component=e,this.material=t,this.verticesData=n},ru.dispose=function(){this.component=this.material=this.verticesData=null},rc),ud=(s9(rh=function(){var e;return(e=cb.call(this)||this).multiRenderData=!1,e},cb),(rd=rh.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},rd.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rh),u_=(s9(r_=function(){var e;return(e=cb.call(this)||this).charsData=[],e.multiRenderData=!0,e},cb),r_.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},r_);e.BackgroundMode=void 0,(rf=e.BackgroundMode||(e.BackgroundMode={}))[rf.SolidColor=0]="SolidColor",rf[rf.Sky=1]="Sky",rf[rf.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(rp=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[rp.AspectFitWidth=0]="AspectFitWidth",rp[rp.AspectFitHeight=1]="AspectFitHeight",rp[rp.Fill=2]="Fill";var uf=((rm=(rg=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},rm._render=function(e){var t=this.material,n=this.mesh;if(!t){lv.warn("The material of sky is not defined.");return}if(!n){lv.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=rg._viewProjMatrix,h=rg._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(sH.degreeToRadian(o)/2);h.elements[0]=m/a,h.elements[5]=m,sZ.multiply(h,u,u);var v=l.getMatrix(ck.vpMatrixProperty);l.setMatrix(ck.vpMatrixProperty,u);var y=cz._compileMacros;cv.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(ck.vpMatrixProperty,v)},s6(rg,[{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}}}]),rg);uf._epsilon=1e-6,uf._viewProjMatrix=new sZ,uf._projectionMatrix=new sZ(1,0,0,0,0,1,0,0,0,0,uf._epsilon-1,-1,0,0,0,0);var up=((ry=(rv=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new s2(.25,.25,.25,1),this.sky=new uf,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()},ry._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},ry._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)}},ry._createPlane=function(e){var t=new c1(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 sW,i[a]=new s0(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},s6(rv,[{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())}}]),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 ug=((rS=(rC=function(){this._diffuseSolidColor=new s2(.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(rC._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(rC._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(rC._specularIntensityProperty,this._specularIntensity),t.setFloatArray(rC._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},rS._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},rS._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(rC._shMacro):t.disableMacro(rC._shMacro)},rS._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(rC._specularTextureProperty,this._specularTexture),e.setFloat(rC._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(rC._specularMacro)):e.disableMacro(rC._specularMacro)},rS._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(rC._decodeRGBMMacro):e.disableMacro(rC._decodeRGBMMacro)},rS._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]},s6(rC,[{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(rC._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(rC._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(rC._specularIntensityProperty,e)}}]),rC);ug._shMacro=cm.getByName("SCENE_USE_SH"),ug._specularMacro=cm.getByName("SCENE_USE_SPECULAR_ENV"),ug._decodeRGBMMacro=cm.getByName("SCENE_IS_DECODE_ENV_RGBM"),ug._diffuseColorProperty=lB.getByName("scene_EnvMapLight.diffuse"),ug._diffuseSHProperty=lB.getByName("scene_EnvSH"),ug._diffuseIntensityProperty=lB.getByName("scene_EnvMapLight.diffuseIntensity"),ug._specularTextureProperty=lB.getByName("scene_EnvSpecularSampler"),ug._specularIntensityProperty=lB.getByName("scene_EnvMapLight.specularIntensity"),ug._mipLevelProperty=lB.getByName("scene_EnvMapLight.mipMapLevel");var um=function(t){function n(r,i){(a=t.call(this,r)||this).castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new sW(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new cv,a._rootEntities=[],a._background=new up(a._engine),a._shaderData=new cy(st.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new s2(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new s1,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new ug,r.sceneManager._allScenes.push(s5(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}s9(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new lQ(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),lQ._traverseSetOwnerScene(t,this)):r||this._addToRootEntityList(n,t),this._isActiveInEngine?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive()},r.removeRootEntity=function(e){e._isRoot&&e._scene==this&&(this._removeFromEntityList(e),e._isRoot=!1,this._isActiveInEngine&&e._isActiveInHierarchy&&e._processInActive(),lQ._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=lQ._findChildByName(i,t[a]));++a);return i}}return null},r.destroy=function(){if(!this._destroyed){this._destroy();var e=this.engine.sceneManager._allScenes;e.splice(e.indexOf(this),1)}},r._attachRenderCamera=function(e){-1===this._activeCameras.indexOf(e)?this._activeCameras.push(e):lv.warn("Camera already attached.")},r._detachRenderCamera=function(e){var t=this._activeCameras.indexOf(e);-1!==t&&this._activeCameras.splice(t,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():r._processInActive())}},r._updateShaderData=function(){var t=this.shaderData,r=this._engine,i=r._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}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"),cv.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._destroy=function(){for(this._isActiveInEngine&&(this._engine.sceneManager.activeScene=null);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this._activeCameras.length=0,this.background.destroy(),this.shaderData._addReferCount(-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)},s6(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){lv.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}(lc);um._fogColorProperty=lB.getByName("scene_FogColor"),um._fogParamsProperty=lB.getByName("scene_FogParams"),um._sunlightColorProperty=lB.getByName("scene_SunlightColor"),um._sunlightDirectionProperty=lB.getByName("scene_SunlightDirection");var uv=((rA=(rw=function(e){this.engine=e,this._allScenes=[]}).prototype).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._activeScene;n.activeScene=e,r&&t&&r.destroy()}),r},rA.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},rA._destroyAllScene=function(){for(var e=this._allScenes,t=0,n=e.length;t<n;t++)e[t]._destroy();e.length=0},s6(rw,[{key:"activeScene",get:function(){return this._activeScene},set:function(e){var t=this._activeScene;t!==e&&(t&&t._processActive(!1),e&&e._processActive(!0),this._activeScene=e)}}]),rw),uy="#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}",ux=((rE=function(){}).init=function(){var t={pipelineStage:e.PipelineStage.ShadowCaster},n={pipelineStage:e.PipelineStage.Forward},r=new cO("#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);cz.create("blinn-phong",[new cO("#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]),cz.create("pbr",[new cO(uy,"#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]),cz.create("pbr-specular",[new cO(uy,"#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]),cz.create("unlit",[new cO("#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]),cz.create("skybox",[new cO("#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)]),cz.create("SkyProcedural",[new cO("#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)]),cz.create("particle-shader",[new cO("#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)]),cz.create("SpriteMask",[new cO("#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)]),cz.create("Sprite",[new cO("#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)]),cz.create("background-texture",[new cO("#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)])},rE),uT=((rb=(rM=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},rb.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rb._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)},rM);ux.init();var uC=function(t){function n(r,i,a){if((o=t.call(this)||this)._lightManager=new cg,o._componentsManager=new lO,o._lastRenderState=new cA,o._renderElementPool=new cM(cG),o._meshRenderDataPool=new cM(cR),o._spriteRenderDataPool=new cM(ud),o._spriteMaskRenderDataPool=new cM(uh),o._textRenderDataPool=new cM(u_),o._renderContext=new ck,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new cv,o._settings={},o._resourceManager=new lR(s5(o)),o._sceneManager=new uv(s5(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new lN,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=i,o._hardwareRenderer.init(r,o._onDeviceLost.bind(s5(o)),o._onDeviceRestored.bind(s5(o))),o.physicsManager=new l1(s5(o)),o._canvas=r,o._sceneManager.activeScene=new um(s5(o),"DefaultScene"),o._spriteMaskManager=new uu(s5(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=lM.createFromOS(s5(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new ch(s5(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var o,s=new lT(s5(o),1,1,e.TextureFormat.Depth16,!1);s.isGCIgnored=!0,o._depthTexture2D=s}else o._macroCollection.enable(n._noDepthTextureMacro);var l=new cE(s5(o),cz.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new lt(1,0,1.01,1)),o._magentaMaterial=l;var c=new cE(s5(o),cz.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}s9(n,t);var r=n.prototype;return r.createEntity=function(e){return new lQ(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._sceneManager._activeScene,r=this._componentsManager;n&&(n._activeCameras.sort(function(e,t){return e.priority-t.priority}),r.callScriptOnStart(),this.physicsManager._initialized&&this.physicsManager._update(t),this.inputManager._update(),r.callScriptOnUpdate(t),r.callAnimationUpdate(t),r.callScriptOnLateUpdate(t),this._render(n)),this._waitingDestroy||r.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._componentsManager.handlingInvalidScripts(),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 uT}return r},r._render=function(e){var t=e._activeCameras,n=this._componentsManager,r=this.time.deltaTime;if(n.callRendererOnUpdate(r),e._updateShaderData(),t.length>0)for(var i=0,a=t.length;i<a;i++){var o=t[i];n.callCameraOnBeginRender(o),o.render(),n.callCameraOnEndRender(o),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else lv.debug("NO active camera.")},r._initMagentaTextures=function(t){var n=new Uint8Array([255,0,255,255]),r=new lT(this,1,1,e.TextureFormat.R8G8B8A8,!1);r.setPixelBuffer(n),r.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s9(o=function(){return lh.call(this,r)},lh),o.prototype.restoreContent=function(){this.resource.setPixelBuffer(n)},o));for(var i=new lS(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(s9(s=function(){return lh.call(this,i)},lh),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 lC(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);c.setPixelBuffer(0,n),c.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s9(l=function(){return lh.call(this,c)},lh),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,n)},l)),this._magentaTexture2DArray=c}},r._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},r._initialize=function(e){var t=this,n=e.physics;return n?n.initialize().then(function(){return t.physicsManager._initialize(n),t}):Promise.resolve(this)},r._createSpriteMaterial=function(){var t=new cE(this,cz.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 cE(this,cz.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 cA,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(),this._componentsManager._gc(),this._lightManager._gc(),this.physicsManager._gc()},s6(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}}]),n}(lI);uC._gammaMacro=cm.getByName("ENGINE_IS_COLORSPACE_GAMMA"),uC._noDepthTextureMacro=cm.getByName("ENGINE_NO_DEPTH_TEXTURE"),uC._pixelsPerUnit=100;var uS=(s9(rR=function(){var e;return e=lU.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},lU),(rF=rR.prototype).onAwake=function(){},rF.onEnable=function(){},rF.onStart=function(){},rF.onUpdate=function(e){},rF.onLateUpdate=function(e){},rF.onBeginRender=function(e){},rF.onEndRender=function(e){},rF.onPhysicsUpdate=function(){},rF.onTriggerEnter=function(e){},rF.onTriggerExit=function(e){},rF.onTriggerStay=function(e){},rF.onCollisionEnter=function(e){},rF.onCollisionExit=function(e){},rF.onCollisionStay=function(e){},rF.onPointerDown=function(e){},rF.onPointerUp=function(e){},rF.onPointerClick=function(e){},rF.onPointerEnter=function(e){},rF.onPointerExit=function(e){},rF.onPointerDrag=function(e){},rF.onDisable=function(){},rF.onDestroy=function(){},rF._onAwake=function(){this.onAwake()},rF._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rR.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)}this.onEnable()},rF._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rF._handlingInValid=function(){var e=this.engine._componentsManager,t=rR.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},rF._onDestroy=function(){lU.prototype._onDestroy.call(this),this._engine._componentsManager.addPendingDestroyScript(this)},rR);ln([li],uS.prototype,"_started",void 0),ln([li],uS.prototype,"_onStartIndex",void 0),ln([li],uS.prototype,"_onUpdateIndex",void 0),ln([li],uS.prototype,"_onLateUpdateIndex",void 0),ln([li],uS.prototype,"_onPhysicsUpdateIndex",void 0),ln([li],uS.prototype,"_onPreRenderIndex",void 0),ln([li],uS.prototype,"_onPostRenderIndex",void 0),ln([li],uS.prototype,"_entityScriptsIndex",void 0),ln([li],uS.prototype,"_waitHandlingInValid",void 0);var uw=(s9(rP=function(){return ul.apply(this,arguments)},ul),(rL=rP.prototype).createVertexElements=function(t){return t[0]=new cq("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new cq("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rL.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPass.getTagValue(ul._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},rL.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rL.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},rL.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=cz._compileMacros;cv.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=h.shaderPass._getShaderProgram(t,p);if(!g.isValid)return;_.shaderData.setTexture(rP._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(_)}},rL.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},rP);uw._textureProperty=lB.getByName("renderer_SpriteTexture");var uA=((rI=(rD=function(e){this.elements=[],this._initSpriteBatcher(e)}).prototype).pushRenderElement=function(e){this.elements.push(e)},rI.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 _=cz._compileMacros,f=d.component,p=d.material.destroyed?r._magentaMaterial:d.material,g=f.shaderData,m=p.shaderData;cv.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)}},rI.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},rI.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rI.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},rI._initSpriteBatcher=function(e){this._spriteBatcher=new uw(e)},rI._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=_)}},rI._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}},rD._compareFromNearToFar=function(e,t){return e.data.component.priority-t.data.component.priority||e.data.component._distanceForSort-t.data.component._distanceForSort},rD._compareFromFarToNear=function(e,t){return e.data.component.priority-t.data.component.priority||t.data.component._distanceForSort-e.data.component._distanceForSort},rD),uE=function(){this.position=new sW,this.isOrthographic=!1,this.viewMatrix=new sZ,this.projectionMatrix=new sZ,this.viewProjectionMatrix=new sZ,this.forward=new sW},uM=function(){this.virtualCamera=new uE,this.cullPlanes=[new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW)],this.splitBoundSphere=new sX(new sW,0)};(rB=s_||(s_={}))[rB.FarBottomLeft=0]="FarBottomLeft",rB[rB.FarTopLeft=1]="FarTopLeft",rB[rB.FarTopRight=2]="FarTopRight",rB[rB.FarBottomRight=3]="FarBottomRight",rB[rB.nearBottomLeft=4]="nearBottomLeft",rB[rB.nearTopLeft=5]="nearTopLeft",rB[rB.nearTopRight=6]="nearTopRight",rB[rB.nearBottomRight=7]="nearBottomRight",rB[rB.unknown=8]="unknown";var ub=((rN=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}},rN.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rN.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},rN.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&rN.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time.frameCount,n._prepareRender(e))},rN.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(sH.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,sW.scale(r,a,_),sW.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},rN.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=rN._frustumCorners,s=rN._backPlaneFaces,l=rN._frustumPlaneNeighbors,c=rN._frustumTwoPlaneCorners,u=rN._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=rN._adjustNearPlane,y=rN._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),sj.intersectionPointThreePlanes(v,g,p,o[7]),sj.intersectionPointThreePlanes(v,m,p,o[6]),sj.intersectionPointThreePlanes(v,m,f,o[5]),sj.intersectionPointThreePlanes(v,g,f,o[4]),sj.intersectionPointThreePlanes(y,g,p,o[3]),sj.intersectionPointThreePlanes(y,m,p,o[2]),sj.intersectionPointThreePlanes(y,m,f,o[1]),sj.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>sW.dot(C.normal,i)&&(h[x].copyFrom(C),s[x]=T,x++)}for(var S=x,w=0;w<x;w++)for(var A=s[w],E=l[A],M=0;M<4;M++){for(var b=E[M],R=!0,F=0;F<x;F++)if(b==s[F]){R=!1;break}if(R){var P=c[A][b],L=o[P[0]],D=o[P[1]];sW.add(L,i,u),sq.fromPoints(L,D,u,h[S++])}}a.cullPlaneCount=S},rN.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-rN.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sW.dot(c,e)*f)*p,m=Math.ceil(sW.dot(c,t)*f)*p,v=sW.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;sW.scale(n,u+i,x),sW.subtract(c,x,x),sZ.lookAt(x,c,e,T),sZ.ortho(-d,d,-d,d,0,2*u+i,C);var S=y.viewProjectionMatrix;sZ.multiply(C,T,S),lG._floatMatrixMultiply(rN._shadowMapCoordMatrix,S.elements,0,s,16*r)},rN.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},rN.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)},rN.applySliceTransform=function(e,t,n,r,i,a){var o=rN._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;lG._floatMatrixMultiply(o,a,d,a,d)},rN);ub._tempMatrix0=new sZ,ub._shadowMapCoordMatrix=new sZ(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),ub._frustumCorners=[new sW,new sW,new sW,new sW,new sW,new sW,new sW,new sW],ub._adjustNearPlane=new sq(new sW),ub._adjustFarPlane=new sq(new sW),ub._backPlaneFaces=[,,,,,],ub._edgePlanePoint2=new sW,ub._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]],ub._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]]],ub.atlasBorderSize=4;var uR=function(){function t(n){this._shadowMapSize=new s1,this._shadowBias=new s0,this._shadowSliceData=new uM,this._lightUp=new sW,this._lightSide=new sW,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sW,this._viewportOffsets=[new s0,new s0,new s0,new s0],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,_=r._componentsManager,f=r._hardwareRenderer,p=i.scene.shadowCascades,g=t._cascadesSplitDistance,m=o.splitBoundSphere,v=t._tempMatrix0,y=v.elements,x=this._lightUp,T=this._lightSide,C=o.virtualCamera.forward,S=r._lightManager._getSunLightIndex();if(-1!==S){var w=i.scene._sunLight,A=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(A);var E=this._getAvailableRenderTarget();f.activeRenderTarget(E,t._viewport,0),this._supportDepthTexture?f.clearRenderTarget(r,e.CameraClearFlags.Depth,null):f.clearRenderTarget(r,e.CameraClearFlags.All,t._clearColor),this._shadowInfos.x=w.shadowStrength,this._shadowInfos.z=S,sZ.rotationQuaternion(w.entity.transform.worldRotationQuaternion,v),T.set(y[0],y[1],y[2]),x.set(y[4],y[5],y[6]),C.set(-y[8],-y[9],-y[10]);var M=t._tempVector;M.copyFrom(i.entity.transform.worldForward);for(var b=this._shadowTileResolution,R=0;R<p;R++){if(ub.getBoundSphereByFrustum(g[R],g[R+1],i,M,o),ub.getDirectionLightShadowCullPlanes(i._frustum,g[R],i.nearClipPlane,C,o),ub.getDirectionalLightMatrices(x,T,C,R,w.shadowNearPlane,b,o,l),p>1){var F=this._shadowMapSize;ub.applySliceTransform(b,F.z,F.w,R,this._viewportOffsets[R],l)}this._updateSingleShadowCasterShaderData(w,o,n);var P=m.center,L=m.radius,D=4*R;s[D]=P.x,s[D+1]=P.y,s[D+2]=P.z,s[D+3]=L*L,u.clear(),h.clear(),d.clear();for(var I=_._renderers,B=I._elements,N=I.length-1;N>=0;--N)ub.shadowCullFrustum(n,w,B[N],o);if(u.elements.length||h.elements.length){u.sort(uA._compareFromNearToFar),h.sort(uA._compareFromNearToFar);var V=a[R],O=V.x,U=V.y;f.setGlobalDepthBias(1,1),f.viewport(O,U,b,b),f.scissor(O+1,U+1,b-2,b-2),r._renderCount++,u.render(i,e.Layer.Everything),h.render(i,e.Layer.Everything),f.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*sH.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 lT(t,i,a,n,!1)).wrapModeV=o.wrapModeU=e.TextureWrapMode.Clamp,t._hardwareRenderer._isWebGL2&&(o.depthCompareFunction=e.TextureDepthCompareFunction.Less),null==s||s._addReferCount(-1),(s=this._supportDepthTexture?this._renderTargets=new lx(t,i,a,null,o):this._renderTargets=new lx(t,i,a,o))._addReferCount(1)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=ub.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=ub.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=ub.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)}var l=this._renderTargets;l&&(l._addReferCount(-1),l.destroy(),this._renderTargets=null);var c=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:c[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;ub.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}();uR._lightShadowBiasProperty=lB.getByName("scene_ShadowBias"),uR._lightDirectionProperty=lB.getByName("scene_LightDirection"),uR._shadowMatricesProperty=lB.getByName("scene_ShadowMatrices"),uR._shadowMapSize=lB.getByName("scene_ShadowMapSize"),uR._shadowInfosProperty=lB.getByName("scene_ShadowInfo"),uR._shadowMapsProperty=lB.getByName("scene_ShadowMap"),uR._shadowSplitSpheresProperty=lB.getByName("scene_ShadowSplitSpheres"),uR._maxCascades=4,uR._cascadesSplitDistance=Array(uR._maxCascades+1),uR._viewport=new s1(0,0,1,1),uR._clearColor=new s2(1,1,1,1),uR._tempVector=new sW,uR._tempMatrix0=new sZ;var uF=0,uP=((rO=(rV=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uF++),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){},rO.preRender=function(e,t,n,r){},rO.postRender=function(e,t,n,r){},rV),uL=((rz=(rU=function(e){this._allSpriteMasks=new lV,this._lastCanvasSize=new s0,this._camera=e;var t=e.engine;this._opaqueQueue=new uA(t),this._alphaTestQueue=new uA(t),this._transparentQueue=new uA(t),this._cascadedShadowCaster=new uR(e),this._renderPassArray=[],this._defaultPass=new uP("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 uP(e,t,n,r,i);this._renderPassArray.push(a)}else lr(e,uP)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},rz.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):lr(e,uP)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},rz.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},rz.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},rz.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=rU._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=rU._forwardPipelineStageTagValue,this._callRender(t),s.sort(uA._compareFromNearToFar),l.sort(uA._compareFromNearToFar),c.sort(uA._compareFromFarToNear);for(var u=0,h=this._renderPassArray.length;u<h;u++)this._drawRenderPass(t,this._renderPassArray[u],a,n,r)},rz._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)},rz.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)},rz.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(ck.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)}}}},rz._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,cz._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},rz._callRender=function(e){for(var t=e.camera.engine,n=t._componentsManager._renderers,r=e.camera,i=n._elements,a=n.length-1;a>=0;--a){var o=i[a];r.cullingMask&o._entity.layer&&(!r.enableFrustumCulling||r._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},s6(rU,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rU);uL._shadowCasterPipelineStageTagValue=e.PipelineStage.ShadowCaster,uL._forwardPipelineStageTagValue=e.PipelineStage.Forward;var uD=function(){};uD.tempVec4=new s1,uD.tempVec3=new sW,uD.tempVec2=new s0,e.Camera=(s9(rk=function(t){(n=lU.call(this,t)||this).priority=0,n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new cv,n._frustum=new sY,n._virtualCamera=new uE,n._replacementShader=null,n._replacementSubShaderTag=null,n._shaderData=new cy(st.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._viewport=new s1(0,0,1,1),n._inverseProjectionMatrix=new sZ,n._lastAspectSize=new s0(0,0),n._invViewProjMat=new sZ;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 uL(s5(n)),n.shaderData._addReferCount(1),n},lU),(rG=rk.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rG.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rG.worldToViewportPoint=function(e,t){var n=uD.tempVec3,r=uD.tempVec4;sW.transformCoordinate(e,this.viewMatrix,n),sW.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},rG.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},rG.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 sW.subtract(i,r,i),i.normalize(),t},rG.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},rG.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},rG.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rG.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rG.screenPointToRay=function(e,t){var n=uD.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rG.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;sZ.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(),cv.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,lv.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rG.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?cD.getByName(t):t},rG.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},rG._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rG._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rG._onDestroy=function(){var e;lU.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},rG._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rG._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uD.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sW.transformCoordinate(a,r,i),i},rG._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rG._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,sZ.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rG._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,sZ.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},s6(rk,[{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()}},{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;sZ.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;sZ.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else sZ.perspective(sH.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}}}]),(sf=rk)._inverseViewMatrixProperty=lB.getByName("camera_ViewInvMat"),sf._cameraPositionProperty=lB.getByName("camera_Position"),sf),ln([ls],e.Camera.prototype,"_frustum",void 0),ln([li],e.Camera.prototype,"_renderPipeline",void 0),ln([li],e.Camera.prototype,"_virtualCamera",void 0),ln([li],e.Camera.prototype,"_frustumViewChangeFlag",void 0),ln([li],e.Camera.prototype,"_transform",void 0),ln([li],e.Camera.prototype,"_isViewMatrixDirty",void 0),ln([li],e.Camera.prototype,"_isInvViewProjDirty",void 0),ln([ls],e.Camera.prototype,"_viewport",void 0),ln([ls],e.Camera.prototype,"_inverseProjectionMatrix",void 0),ln([ls],e.Camera.prototype,"_lastAspectSize",void 0),ln([ls],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=ln([lk(lq,e.DependentMode.CheckOnly)],e.Camera);var uI={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uB=1/0;function uN(e,t){return void 0===t&&(t={}),new lb(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:uB,t.type=null!=(l=t.type)?l:uI[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?uV:uO,_=new uU(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 uV(e,t){return new lb(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 uO(e,t){return new lb(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 uU=((rW=(rH=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()},rW.stop=function(){clearTimeout(this._timeoutId)},rW.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)})},rH),uz=((rX=function(e){this.useCache=e,this.request=uN}).registerClass=function(e,t){this._engineObjects[e]=t},rX.getClass=function(e){return this._engineObjects[e]},rX);uz._engineObjects={},e.AssetType=void 0,(rK=e.AssetType||(e.AssetType={})).Text="Text",rK.JSON="JSON",rK.Buffer="Buffer",rK.Texture2D="Texture2D",rK.TextureCube="TextureCube",rK.Material="Material",rK.Mesh="Mesh",rK.AnimationClip="AnimationClip",rK.AnimatorController="AnimatorController",rK.GLTF="GLTF",rK.KTX="KTX",rK.KTXCube="KTXCube",rK.Sprite="Sprite",rK.SpriteAtlas="SpriteAtlas",rK.Env="Environment",rK.Scene="Scene",rK.HDR="HDR",rK.Font="Font",rK.SourceFont="SourceFont",e.BlendMode=void 0,(rj=e.BlendMode||(e.BlendMode={}))[rj.Normal=0]="Normal",rj[rj.Additive=1]="Additive",e.RenderFace=void 0,(rq=e.RenderFace||(e.RenderFace={}))[rq.Front=0]="Front",rq[rq.Back=1]="Back",rq[rq.Double=2]="Double";var uk=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}s9(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},s6(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 cA),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}(cE);uk._baseTextureMacro=cm.getByName("MATERIAL_HAS_BASETEXTURE"),uk._normalTextureMacro=cm.getByName("MATERIAL_HAS_NORMALTEXTURE"),uk._emissiveTextureMacro=cm.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uk._transparentMacro=cm.getByName("MATERIAL_IS_TRANSPARENT"),uk._baseColorProp=lB.getByName("material_BaseColor"),uk._baseTextureProp=lB.getByName("material_BaseTexture"),uk._tilingOffsetProp=lB.getByName("material_TilingOffset"),uk._normalTextureProp=lB.getByName("material_NormalTexture"),uk._normalIntensityProp=lB.getByName("material_NormalIntensity"),uk._emissiveColorProp=lB.getByName("material_EmissiveColor"),uk._emissiveTextureProp=lB.getByName("material_EmissiveTexture"),uk._alphaCutoffProp=lB.getByName("material_AlphaCutoff"),uk._alphaCutoffMacro=cm.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uG=function(e){function t(n){var r,i=(r=e.call(this,n,cz.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s2(1,1,1,1)),i.setColor(t._specularColorProp,new s2(1,1,1,1)),i.setColor(t._emissiveColorProp,new s2(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new s1(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uk);uG._specularColorProp=lB.getByName("material_SpecularColor"),uG._shininessProp=lB.getByName("material_Shininess"),uG._specularTextureProp=lB.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rY=e.TextureCoordinate||(e.TextureCoordinate={}))[rY.UV0=0]="UV0",rY[rY.UV1=1]="UV1",rY[rY.UV2=2]="UV2",rY[rY.UV3=3]="UV3",rY[rY.UV4=4]="UV4",rY[rY.UV5=5]="UV5",rY[rY.UV6=6]="UV6",rY[rY.UV7=7]="UV7";var uH=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 s2(1,1,1,1)),o.setColor(n._emissiveColorProp,new s2(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new s1(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 s9(n,t),s6(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&&lv.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}(uk);uH._occlusionTextureIntensityProp=lB.getByName("material_OcclusionIntensity"),uH._occlusionTextureCoordProp=lB.getByName("material_OcclusionTextureCoord"),uH._occlusionTextureProp=lB.getByName("material_OcclusionTexture"),uH._clearCoatProp=lB.getByName("material_ClearCoat"),uH._clearCoatTextureProp=lB.getByName("material_ClearCoatTexture"),uH._clearCoatRoughnessProp=lB.getByName("material_ClearCoatRoughness"),uH._clearCoatRoughnessTextureProp=lB.getByName("material_ClearCoatRoughnessTexture"),uH._clearCoatNormalTextureProp=lB.getByName("material_ClearCoatNormalTexture");var uW=function(e){function t(n){var r;return(r=e.call(this,n,cz.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uH);uW._metallicProp=lB.getByName("material_Metal"),uW._roughnessProp=lB.getByName("material_Roughness"),uW._roughnessMetallicTextureProp=lB.getByName("material_RoughnessMetallicTexture"),uW._iorProp=cz.getPropertyByName("material_IOR");var uX=function(e){function t(n){var r;return(r=e.call(this,n,cz.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new s2(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uH);uX._specularColorProp=lB.getByName("material_PBRSpecularColor"),uX._glossinessProp=lB.getByName("material_Glossiness"),uX._specularGlossinessTextureProp=lB.getByName("material_SpecularGlossinessTexture"),uX._specularGlossinessTextureMacro=cm.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uK=function(e){function t(n){var r,i=(r=e.call(this,n,cz.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s2(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new s1(1,1,0,0)),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uk);e.TextHorizontalAlignment=void 0,(rQ=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rQ.Left=0]="Left",rQ[rQ.Center=1]="Center",rQ[rQ.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 uj=(s9(rZ=function(e){var t;return(t=lu.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},lu),(r$=rZ.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},r$.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},r$._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},r$._onDestroy=function(){lu.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},s6(rZ,[{key:"sprites",get:function(){return this._sprites}}]),rZ);e.SpriteDrawMode=void 0,(r0=e.SpriteDrawMode||(e.SpriteDrawMode={}))[r0.Simple=0]="Simple",r0[r0.Sliced=1]="Sliced",r0[r0.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(r1=e.SpriteTileMode||(e.SpriteTileMode={}))[r1.Continuous=0]="Continuous",r1[r1.Adaptive=1]="Adaptive";var uq=(s9(r2=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=lu.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new s0,new s0,new s0,new s0],o._uvs=[new s0,new s0,new s0,new s0],o._bounds=new sK,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new s3(0,0,1,1),o._atlasRegionOffset=new s1(0,0,0,0),o._region=new s3(0,0,1,1),o._pivot=new s0(.5,.5),o._border=new s1(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new lj,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},lu),(r3=r2.prototype).clone=function(){var e=new r2(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},r3._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},r3._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},r3._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},r3._addReferCount=function(e){var t;lu.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},r3._onDestroy=function(){lu.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},r3._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/uC._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},r3._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},r3._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,w=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+w*o)*y+h),e[3].set(d+u-Math.max(s-g,0)*v,Math.max(l-p,0)*y+h),this._dirtyUpdateFlag&=-3},r3._dispatchSpriteChange=function(e){switch(e){case sa.texture:this._dirtyUpdateFlag|=4;break;case sa.atlasRegionOffset:case sa.region:this._dirtyUpdateFlag|=7;break;case sa.atlasRegion:this._dirtyUpdateFlag|=6;break;case sa.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},s6(r2,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(sa.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.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(sa.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(sa.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=sH.clamp(e.x,0,1),n=sH.clamp(e.y,0,1);this._atlasRegion.set(t,n,sH.clamp(e.width,0,1-t),sH.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sa.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=sH.clamp(e.x,0,1),n=sH.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,sH.clamp(e.z,0,1-t),sH.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sa.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=sH.clamp(e.x,0,1),r=sH.clamp(e.y,0,1);t.set(n,r,sH.clamp(e.width,0,1-n),sH.clamp(e.height,0,1-r)),this._dispatchSpriteChange(sa.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(sa.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(sa.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=sH.clamp(e.x,0,1),r=sH.clamp(e.y,0,1);t.set(n,r,sH.clamp(e.z,0,1-n),sH.clamp(e.w,0,1-r)),this._dispatchSpriteChange(sa.border)}}]),r2);(r4=sp||(sp={}))[r4.positions=1]="positions",r4[r4.uvs=2]="uvs",r4[r4.automaticSize=4]="automaticSize",r4[r4.all=7]="all";var uY=((r5=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 sW),r.push(new s0);t.triangles=[]},r5.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,w=x*u.w;if(T+S>r){var A=r/(T+S);t=[y*f*A,T*A,T*A,r-y*(1-m)*A]}else t=[y*f,T,r-S,r-y*(1-m)];if(w+C>i){var E=i/(w+C);n=[x*p*E,C*E,C*E,i-x*(1-v)*E]}else n=[x*p,C,i-w,i-x*(1-v)];var M=e.sprite.pivot,b=M.x,R=M.y,F=e.width*b,P=e.height*R,L=uY._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]-F*D[0]-P*D[4],D[13]=I[13]-F*D[1]-P*D[5],D[14]=I[14]-F*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)},r5.updateUVs=function(e){},r5._worldMatrix=new sZ,r5);uY=ln([cH()],uY);var uQ=((r8=function(){}).resetData=function(e){var t;(t=e._verticesData).triangles||(t.triangles=[])},r8.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,w=t.width*C,A=t.height*S,E=uQ._worldMatrix,M=E.elements,b=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,F=t.flipY?-1:1;n=M[0]=b[0]*R,r=M[1]=b[1]*R,i=M[2]=b[2]*R,a=M[4]=b[4]*F,o=M[5]=b[5]*F,s=M[6]=b[6]*F,M[8]=b[8],M[9]=b[9],M[10]=b[10];for(var P=M[12]=b[12]-w*M[0]-A*M[4],L=M[13]=b[13]-w*M[1]-A*M[5],D=M[14]=b[14]-w*M[2]-A*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 s0(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 sW(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 s0(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 sW(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 s0(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 sW(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 s0(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 sW(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)},r8.updateUVs=function(e){},r8._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(),w=S[0],A=S[1],E=S[2],M=S[3],b=e.width,R=e.height,F=b*p.x,P=b*p.z,L=F+P,D=b-L,I=R*p.w,B=R*p.y,N=I+B,V=R-N;if(L>=t?(h=3,c=0):D>sH.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>sH.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>ul.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*T),a.add(n*y),a.add(n*C),o.add(w.x),o.add(M.x),s.add(w.y),s.add(M.y),lv.warn("The number of vertices exceeds the upper limit("+ul.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,i.add(b*v*l),i.add(F*l),i.add(t-b*(1-T)*l),o.add(w.x),o.add(A.x),o.add(E.x),o.add(M.x);break;case 1:i.add(b*v),i.add(F),i.add(t-P),i.add(t-b*(1-T)),o.add(w.x),o.add(A.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(M.x);break;case 2:l=t/(L+_*D),i.add(b*v*l),i.add(F*l),o.add(w.x),o.add(A.x),o.add(A.x);for(var O=0,U=_-1;O<U;O++)i.add(F+(O+1)*D*l),o.add(E.x),o.add(A.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(R*y*l),a.add(B*l),a.add(n-R*(1-C)*l),s.add(w.y),s.add(A.y),s.add(E.y),s.add(M.y);break;case 1:a.add(R*y),a.add(B),a.add(n-I),a.add(n-R*(1-C)),s.add(w.y),s.add(A.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(R*y*l),a.add(B*l),s.add(w.y),s.add(A.y),s.add(A.y);for(var z=0,k=f-1;z<k;z++)a.add(B+(z+1)*V*l),s.add(E.y),s.add(A.y);a.add(n-I*l),a.add(n-R*(1-C)*l),s.add(E.y),s.add(E.y),s.add(M.y)}},r8._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],w=T[2],A=T[3],E=e.width,M=e.height,b=E*_.x,R=E*_.z,F=b+R,P=E-F,L=M*_.w,D=M*_.y,I=L+D,B=M-I;if(F>=t?(c=3,s=0):P>sH.zeroTolerance?(c=4+(0|(h=(t-F)/P)),s=2):(c=4,s=1),I>=n?(u=3,l=0):B>sH.zeroTolerance?(u=4+(0|(d=(n-I)/B)),l=2):(u=4,l=1),(c-1)*(u-1)*4>ul.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(A.x),o.add(C.y),o.add(A.y),lv.warn("The number of vertices exceeds the upper limit("+ul.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var N=t/F;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(w.x),a.add(A.x);break;case 1:r.add(E*g),r.add(b),r.add(t-R),r.add(t-E*(1-y)),a.add(C.x),a.add(S.x),a.add(NaN),a.add(NaN),a.add(w.x),a.add(A.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(w.x),a.add(S.x);r.add(t-R),r.add(t-E*(1-y)),a.add((w.x-S.x)*(h-V)+S.x),a.add(w.x),a.add(A.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(w.y),o.add(A.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(w.y),o.add(A.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(w.y),o.add(S.y);i.add(n-L),i.add(n-M*(1-x)),o.add((w.y-S.y)*(d-z)+S.y),o.add(w.y),o.add(A.y)}},(sg=r8)._worldMatrix=new sZ,sg._posRow=new lV,sg._posColumn=new lV,sg._uvRow=new lV,sg._uvColumn=new lV,sg);uQ=ln([cH()],uQ),(r6=sm||(sm={}))[r6.Compressed=0]="Compressed",r6[r6.WithoutTiled=1]="WithoutTiled",r6[r6.WithTiled=2]="WithTiled";var uJ=(r7=e.Renderer,s9(r9=function(t){var n;return(n=r7.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new s2(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 cX(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(s5(n)),n},r7),(ie=r9.prototype)._cloneTo=function(e){r7.prototype._cloneTo.call(this,e),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},ie._updateShaderData=function(e){this._updateTransformShaderData(e,sZ._identity)},ie._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},ie._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&sr.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~sr.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)}},ie._onDestroy=function(){r7.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},ie._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},ie._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}},ie._onSpriteChange=function(t){switch(t){case sa.texture:this.shaderData.setTexture(r9._textureProperty,this.sprite.texture);break;case sa.size:var n=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=sr.WorldVolume:n===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sr.WorldVolume);break;case sa.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case sa.region:case sa.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sa.atlasRegion:this._dirtyUpdateFlag|=2;break;case sa.pivot:this._dirtyUpdateFlag|=sr.WorldVolume}},s6(r9,[{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=cW;break;case e.SpriteDrawMode.Sliced:this._assembler=uY;break;case e.SpriteDrawMode.Tiled:this._assembler=uQ}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=sH.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(r9._textureProperty,e.texture)):this.shaderData.setTexture(r9._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|=sr.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|=sr.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sr.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sr.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())}}]),r9);uJ._textureProperty=lB.getByName("renderer_SpriteTexture"),ln([li],uJ.prototype,"_verticesData",void 0),ln([li],uJ.prototype,"_drawMode",void 0),ln([la],uJ.prototype,"_assembler",void 0),ln([la],uJ.prototype,"_tileMode",void 0),ln([la],uJ.prototype,"_tiledAdaptiveThreshold",void 0),ln([ls],uJ.prototype,"_color",void 0),ln([li],uJ.prototype,"_sprite",void 0),ln([li],uJ.prototype,"_automaticWidth",void 0),ln([li],uJ.prototype,"_automaticHeight",void 0),ln([la],uJ.prototype,"_customWidth",void 0),ln([la],uJ.prototype,"_customHeight",void 0),ln([la],uJ.prototype,"_flipX",void 0),ln([la],uJ.prototype,"_flipY",void 0),ln([la],uJ.prototype,"_maskLayer",void 0),ln([la],uJ.prototype,"_maskInteraction",void 0),ln([li],uJ.prototype,"_onSpriteChange",null),(it=sv||(sv={}))[it.UV=2]="UV",it[it.RenderData=3]="RenderData",it[it.AutomaticSize=4]="AutomaticSize",it[it.All=7]="All";var uZ=function e(){this.localPositions=new s1;var t=[new sW,new sW,new sW,new sW];this.renderData=new cX(4,t,null,e.triangles,null)};uZ.triangles=[0,2,1,2,0,3];var u$=((ii=(ir=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},ii.put=function(e){this._elements.push(e)},ir),u0=(ia=e.Renderer,s9(io=function(t){var n;return(n=ia.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new s2(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sK,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},ia),(is=io.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},is._onDestroy=function(){ia.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)io._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},is._cloneTo=function(e){ia.prototype._cloneTo.call(this,e),e.font=this._font,e._subFont=this._subFont},is._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},is._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},is._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},is._updateShaderData=function(e){this._updateTransformShaderData(e,sZ._identity)},is._updateBounds=function(e){sK.transform(this._localBounds,this._entity.transform.worldMatrix,e)},is._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)}},is._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}},is._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=lA.getNativeFontString(e.name,this.fontSize,this.fontStyle)},is._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=io._tempVec31.set(a,o,s),d=io._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];sW.scale(d,g.z-v,T),sW.add(x,T,T);var C=m[2];sW.scale(h,g.w-y,C),sW.add(x,C,m[3]),sW.add(T,C,C)}},is._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=uC._pixelsPerUnit,c=1/l,u=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?lA.measureTextWithWrap(this):lA.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=io._charRenderDataPool,x=.5*m,T=p.length,C=0,S=.5*m-v[0].ascent,w=.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-(w-S)*.5;break;case e.TextVerticalAlignment.Bottom:C=f-.5*d-x-w}for(var A=0,E=-1,M=Number.MAX_SAFE_INTEGER,b=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,F=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=A++]||(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&&(F=Math.max(F,Q)),b=Math.min(b,J),N===B&&(M=Math.min(M,q)),R=Math.max(R,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(R,F,0));var Z=i.length;if(Z>A){for(var $=A;$<Z;++$)y.put(i[$]);i.length=A}u._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},is._onTransformChanged=function(e){ia.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},s6(io,[{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}}]),io);u0._charRenderDataPool=new u$(uZ,50),u0._tempVec30=new sW,u0._tempVec31=new sW,ln([la],u0.prototype,"_subFont",void 0),ln([li],u0.prototype,"_charRenderDatas",void 0),ln([li],u0.prototype,"_dirtyFlag",void 0),ln([ls],u0.prototype,"_color",void 0),ln([la],u0.prototype,"_text",void 0),ln([la],u0.prototype,"_width",void 0),ln([la],u0.prototype,"_height",void 0),ln([li],u0.prototype,"_localBounds",void 0),ln([la],u0.prototype,"_font",void 0),ln([la],u0.prototype,"_fontSize",void 0),ln([la],u0.prototype,"_fontStyle",void 0),ln([la],u0.prototype,"_lineSpacing",void 0),ln([la],u0.prototype,"_horizontalAlignment",void 0),ln([la],u0.prototype,"_verticalAlignment",void 0),ln([la],u0.prototype,"_enableWrapping",void 0),ln([la],u0.prototype,"_overflowMode",void 0),ln([la],u0.prototype,"_maskInteraction",void 0),ln([la],u0.prototype,"_maskLayer",void 0),(il=sy||(sy={}))[il.SubFont=1]="SubFont",il[il.LocalPositionBounds=2]="LocalPositionBounds",il[il.WorldPosition=4]="WorldPosition",il[il.WorldBounds=8]="WorldBounds",il[il.MaskInteraction=16]="MaskInteraction",il[il.Position=14]="Position",il[il.Font=15]="Font";var u1=((iu=(ic=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]},iu.getTargetValue=function(){return this._mounted[this._propertyName]},iu.setTargetValue=function(e){this._mounted[this._propertyName]=e},ic),u2=function(){function e(t,n,r,i){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.evaluateValue=function(e,t,n){return n?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,n,r,i,a){var o=e&&e.keys.length?a?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):a?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?a?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,i)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){var i=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,a=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(i,a,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 i=this._assembler,a=i.getTargetValue(),o=r._additiveValue(e,t,a);i.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 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:u1},e}();u2._assemblerMap=new Map;var u3=((id=(ih=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},id.getTargetValue=function(){return this._transform.position},id.setTargetValue=function(e){this._transform.position=e},ih);u2.registerAssembler(lq,"position",u3);var u4=((ip=(i_=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},ip.getTargetValue=function(){return this._transform.rotationQuaternion},ip.setTargetValue=function(e){this._transform.rotationQuaternion=e},i_);u2.registerAssembler(lq,"rotationQuaternion",u4);var u5=((im=(ig=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},im.getTargetValue=function(){return this._transform.scale},im.setTargetValue=function(e){this._transform.scale=e},ig);u2.registerAssembler(lq,"scale",u5);var u8=((iy=(iv=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(c4)},iy.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},iy.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},iv);u2.registerAssembler(c4,"blendShapeWeights",u8);var u6=((iT=(ix=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},iT.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},ix),u7=((iS=(iC=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new u2(e,this.type,this.property,t);return t._initializeOwner(n),n.saveDefaultValue(),n},iS._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new u6;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},iS._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},iC),u9=function(){},he=(s9(iw=function(e){var t;return(t=lc.call(this,null)||this).name=e,t._curveBindings=[],t._length=0,t._events=[],t},lc),(iA=iw.prototype).addEvent=function(e,t,n){if("string"==typeof e){var r=new u9;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})},iA.clearEvents=function(){this._events.length=0},iA.addCurveBinding=function(e,t,n,r){var i=new u7;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},iA.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iA._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);if(a){var o=i._getTempCurveOwner(a),s=o.evaluateValue(i.curve,t,!1);o.applyValue(s,1,!1)}}},s6(iw,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),iw);e.InterpolationType=void 0,(iE=e.InterpolationType||(e.InterpolationType={}))[iE.Linear=0]="Linear",iE[iE.CubicSpine=1]="CubicSpine",iE[iE.Step=2]="Step",iE[iE.Hermite=3]="Hermite";var ht=((ib=(iM=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)}},ib.evaluate=function(e){return this._evaluate(e,this._evaluateData)},ib.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},ib._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 n.value=r,r},ib._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},s6(iM,[{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}}]),iM);e.AnimationArrayCurve=(s9(iR=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=[],e},ht),iR._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iR._initializeLayerOwner=function(e){e.finalValue=[]},iR._lerpValue=function(e,t,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},iR._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iR._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iR._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iR._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iR._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},(sx=iR)._isReferenceType=!0,sx._isInterpolationType=!0,sx),e.AnimationArrayCurve=ln([cH()],e.AnimationArrayCurve),e.AnimationBoolCurve=(s9(iF=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=!1,e},ht),iF._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},iF._initializeLayerOwner=function(e){e.finalValue=!1},iF._lerpValue=function(e,t){return t},iF._subtractValue=function(e,t,n){return e},iF._getZeroValue=function(){return!1},iF._additiveValue=function(e,t,n){return e},iF._copyValue=function(e){return e},iF._hermiteInterpolationValue=function(e){return e.value},(sT=iF)._isReferenceType=!1,sT._isInterpolationType=!1,sT),e.AnimationBoolCurve=ln([cH()],e.AnimationBoolCurve),e.AnimationColorCurve=(s9(iP=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s2,e},ht),iP._initializeOwner=function(e){e.defaultValue=new s2,e.fixedPoseValue=new s2,e.baseEvaluateData.value=new s2,e.crossEvaluateData.value=new s2},iP._initializeLayerOwner=function(e){e.finalValue=new s2},iP._lerpValue=function(e,t,n,r){return s2.lerp(e,t,n,r),r},iP._subtractValue=function(e,t,n){return s2.subtract(e,t,n),n},iP._getZeroValue=function(e){return e.set(0,0,0,0),e},iP._additiveValue=function(e,t,n){return s2.scale(e,t,e),s2.add(n,e,n),n},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.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},(sC=iP)._isReferenceType=!0,sC._isInterpolationType=!0,sC),e.AnimationColorCurve=ln([cH()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(s9(iL=function(){return ht.apply(this,arguments)},ht),iL.prototype.addKey=function(e){ht.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)}},iL._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},iL._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},iL._lerpValue=function(e,t,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},iL._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iL._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iL._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iL._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iL._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},(sS=iL)._isReferenceType=!0,sS._isInterpolationType=!0,sS),e.AnimationFloatArrayCurve=ln([cH()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(s9(iD=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=0,e},ht),iD._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},iD._initializeLayerOwner=function(e){e.finalValue=0},iD._lerpValue=function(e,t,n){return e+(t-e)*n},iD._additiveValue=function(e,t,n){return n+e*t},iD._subtractValue=function(e,t){return e-t},iD._getZeroValue=function(){return 0},iD._copyValue=function(e){return e},iD._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},(sw=iD)._isReferenceType=!1,sw._isInterpolationType=!0,sw),e.AnimationFloatCurve=ln([cH()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(s9(iI=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new sJ,e},ht),iI._initializeOwner=function(e){e.defaultValue=new sJ,e.fixedPoseValue=new sJ,e.baseEvaluateData.value=new sJ,e.crossEvaluateData.value=new sJ},iI._initializeLayerOwner=function(e){e.finalValue=new sJ},iI._lerpValue=function(e,t,n,r){return sJ.slerp(e,t,n,r),r},iI._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},iI._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return sJ.conjugate(n,i),sJ.multiply(i,t,r),r},iI._getZeroValue=function(e){return e.set(0,0,0,1),e},iI._copyValue=function(e,t){return t.copyFrom(e),t},iI._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},(sA=iI)._isInterpolationType=!0,sA._isReferenceType=!0,sA._tempConjugateQuat=new sJ,sA),e.AnimationQuaternionCurve=ln([cH()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(s9(iB=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s0,e},ht),iB._initializeOwner=function(e){e.defaultValue=new s0,e.fixedPoseValue=new s0,e.baseEvaluateData.value=new s0,e.crossEvaluateData.value=new s0},iB._initializeLayerOwner=function(e){e.finalValue=new s0},iB._lerpValue=function(e,t,n,r){return s0.lerp(e,t,n,r),r},iB._additiveValue=function(e,t,n){return s0.scale(e,t,e),s0.add(n,e,n),n},iB._subtractValue=function(e,t,n){return s0.subtract(e,t,n),n},iB._getZeroValue=function(e){return e.set(0,0),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,i},(sE=iB)._isReferenceType=!0,sE._isInterpolationType=!0,sE),e.AnimationVector2Curve=ln([cH()],e.AnimationVector2Curve),e.AnimationVector3Curve=(s9(iN=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new sW,e},ht),iN._initializeOwner=function(e){e.defaultValue=new sW,e.fixedPoseValue=new sW,e.baseEvaluateData.value=new sW,e.crossEvaluateData.value=new sW},iN._initializeLayerOwner=function(e){e.finalValue=new sW},iN._lerpValue=function(e,t,n,r){return sW.lerp(e,t,n,r),r},iN._relativeBaseValue=function(e,t){return sW.subtract(t,e,t),t},iN._additiveValue=function(e,t,n){return sW.scale(e,t,e),sW.add(n,e,n),n},iN._subtractValue=function(e,t,n){return sW.subtract(e,t,n),n},iN._getZeroValue=function(e){return e.set(0,0,0),e},iN._copyValue=function(e,t){return t.copyFrom(e),t},iN._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},(sM=iN)._isReferenceType=!0,sM._isInterpolationType=!0,sM),e.AnimationVector3Curve=ln([cH()],e.AnimationVector3Curve),e.AnimationVector4Curve=(s9(iV=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s1,e},ht),iV._initializeOwner=function(e){e.defaultValue=new s1,e.fixedPoseValue=new s1,e.baseEvaluateData.value=new s1,e.crossEvaluateData.value=new s1},iV._initializeLayerOwner=function(e){e.finalValue=new s1},iV._lerpValue=function(e,t,n,r){return s1.lerp(e,t,n,r),r},iV._additiveValue=function(e,t,n){return s1.scale(e,t,e),s1.add(n,e,n),n},iV._subtractValue=function(e,t,n){return s1.subtract(e,t,n),n},iV._getZeroValue=function(e){return e.set(0,0,0,0),e},iV._copyValue=function(e,t){return t.copyFrom(e),t},iV._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},(sb=iV)._isReferenceType=!0,sb._isInterpolationType=!0,sb),e.AnimationVector4Curve=ln([cH()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(iO=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[iO.None=0]="None",iO[iO.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iU=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iU.Override=0]="Override",iU[iU.Additive=1]="Additive",(iz=sR||(sR={}))[iz.UnStarted=0]="UnStarted",iz[iz.Playing=1]="Playing",iz[iz.Finished=2]="Finished",(ik=sF||(sF={}))[ik.Standby=0]="Standby",ik[ik.Playing=1]="Playing",ik[ik.CrossFading=2]="CrossFading",ik[ik.FixedCrossFading=3]="FixedCrossFading",ik[ik.Finished=4]="Finished";var hn=((iG=function(){this.handlers=[]}).prototype.dispose=function(){},iG),hr=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(iH=e.WrapMode||(e.WrapMode={}))[iH.Once=0]="Once",iH[iH.Loop=1]="Loop";var hi=((iX=(iW=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=sR.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},iX.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=sR.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=sR.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},iW),ha=((iK=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new hi,this.destPlayData=new hi,this.layerState=sF.Standby,this.crossCurveMark=0,this.manuallyTransition=new hr,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iK),ho=function(){this.curveLayerOwner=[],this.eventHandlers=[]},hs=(s9(ij=function(t){var n;return(n=lU.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._needRevertCurveOwners=[],n._animationEventHandlerPool=new cM(hn),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lU),(iq=ij.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,o=i.layerIndex;if(a){if(!a.clip){console.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(i.layerIndex),l=this._getAnimatorStateData(e,a,s,o);this._preparePlay(s,a),s.layerState=sF.Playing,s.srcPlayData.reset(a,l,a._getDuration()*n)}},iq.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)},iq.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,this._revertCurveOwners();for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==sF.Standby&&this._updateLayer(l,0===l,t,r)}},iq.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},iq.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iq._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iq._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},iq._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._needRevertCurveOwners.length=0,this._curveOwnerPool={},this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},iq._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},iq._getAnimatorStateData=function(e,t,n,r){var i=n.animatorStateDataMap,a=i[e];return a||(a=new ho,i[e]=a,this._saveAnimatorStateData(t,a,n,r),this._saveAnimatorEventHandlers(t,a)),a},iq._saveAnimatorStateData=function(t,n,r,i){for(var a=this.entity,o=this._curveOwnerPool,s=n.curveLayerOwner,l=r.curveOwnerPool,c=t.clip._curveBindings,u=c.length-1;u>=0;u--){var h=c[u],d=""===h.relativePath?a:a.findByPath(h.relativePath);if(d){var _,f,p,g,m=h.property,v=d.instanceId,y=!1,x=this._animatorLayersData[0].curveOwnerPool;this.animatorController.layers[i].blendingMode===e.AnimatorLayerBlendingMode.Additive&&i>0&&!(x[v]&&x[v][m])&&(y=!0);var T=(f=(_=o)[v]||(_[v]=Object.create(null)))[m]||(f[m]=h._createCurveOwner(d));if(y)this._needRevertCurveOwners.push(T);else{var C=this._needRevertCurveOwners.indexOf(T);C>-1&&this._needRevertCurveOwners.splice(C,1)}var S=(g=(p=l)[v]||(p[v]=Object.create(null)))[m]||(g[m]=h._createCurveLayerOwner(T));s[u]=S}else s[u]=null,console.warn("The entity don't have the child entity which path is "+h.relativePath+".")}},iq._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)}},iq._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},iq._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},iq._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},iq._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},iq._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)},iq._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))}},iq._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;t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,r)}}}},iq._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new ha),t},iq._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!==sF.FixedCrossFading&&this._checkTransition(c,h,t),l.layerState){case sF.Playing:this._updatePlayingState(c,l,t,s,r,d,i);break;case sF.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,r,d,i);break;case sF.CrossFading:this._updateCrossFade(c,u,l,t,s,r,d,i);break;case sF.Finished:this._updateFinishedState(c,s,d,i)}},iq._updatePlayingState=function(e,t,n,r,i,a,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===sR.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){var T=y.evaluateValue(x,f,a);o&&y.applyValue(T,r,a),g&&v.saveFinalValue()}}}e.frameTime+=u.speed*i,p===sR.Finished&&(t.layerState=sF.Finished),c.length&&this._fireAnimationEvents(e,c,d,f),h===sR.UnStarted&&this._callAnimatorScriptOnEnter(u,n),p===sR.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n)},iq._updateCrossFade=function(e,t,n,r,i,a,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,C=Math.abs(t.frameTime)/T;(C>=1||0===T)&&(C=1),e.update(this.speed<0),t.update(this.speed<0);var S=e.clipTime,w=e.playState,A=t.clipTime,E=t.playState,M=t.playState===sR.Finished;if(s||M)for(var b=l.length-1;b>=0;b--){var R=l[b],F=null==R?void 0:R.curveOwner;if(F){var P=R.crossSrcCurveIndex,L=R.crossDestCurveIndex,D=F.evaluateCrossFadeValue(P>=0?c[P].curve:null,L>=0?v[L].curve:null,S,A,C,o);s&&F.applyValue(D,i,o),M&&R.saveFinalValue()}}this._updateCrossFadeData(n,C,a,!1),_.length&&this._fireAnimationEvents(e,_,y,S),m.length&&this._fireAnimationEvents(t,m,x,A),d===sR.UnStarted&&this._callAnimatorScriptOnEnter(u,r),1===C||w===sR.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),g===sR.UnStarted&&this._callAnimatorScriptOnEnter(f,r),E===sR.Finished?this._callAnimatorScriptOnExit(f,r):this._callAnimatorScriptOnUpdate(f,r)},iq._updateCrossFadeFromPose=function(e,t,n,r,i,a,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,i,!0);var m=e.clipTime,v=g===sR.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 C=x.crossDestCurveIndex,S=x.curveOwner.crossFadeFromPoseAndApplyValue(C>=0?d[C].curve:null,m,p,a);o&&T.applyValue(S,r,a),v&&x.saveFinalValue()}}h.length&&this._fireAnimationEvents(e,h,_,m),u===sR.UnStarted&&this._callAnimatorScriptOnEnter(l,n),g===sR.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n)},iq._updateFinishedState=function(e,t,n,r){if(r)for(var i=e.stateData.curveLayerOwner,a=e.state.clip._curveBindings,o=a.length-1;o>=0;o--){var s=i[o],l=null==s?void 0:s.curveOwner;l&&l.applyValue(s.finalValue,t,n)}},iq._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===sR.Finished?e.layerState=sF.Finished:e.layerState=sF.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},iq._preparePlay=function(e,t){if(e.layerState===sF.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,i=n.stateData.curveLayerOwner,a=i.length-1;a>=0;a--)(null==(r=i[a])?void 0:r.curveOwner).revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},iq._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)}},iq._crossFadeByTransition=function(e,t){var n=e.destinationState.name,r=this._getAnimatorStateInfo(n,t),i=r.state,a=r.layerIndex;if(i){if(!i.clip){console.warn("The state named "+n+" has no AnimationClip data.");return}var o=this._getAnimatorLayerData(a),s=o.layerState,l=o.destPlayData,c=this._getAnimatorStateData(n,i,o,a),u=i._getDuration()*e.offset;switch(l.reset(i,c,u),s){case sF.Standby:o.layerState=sF.FixedCrossFading,this._clearCrossData(o),this._prepareStandbyCrossFading(o);break;case sF.Playing:case sF.Finished:o.layerState=sF.CrossFading,this._clearCrossData(o),this._prepareCrossFading(o);break;case sF.CrossFading:o.layerState=sF.FixedCrossFading,this._prepareFixedPoseCrossFading(o);break;case sF.FixedCrossFading:this._prepareFixedPoseCrossFading(o)}o.crossFadeTransition=e}},iq._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)},iq._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)}}},iq._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)}}},iq._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},iq._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},iq._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},iq._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)}},iq._revertCurveOwners=function(){for(var e=this._needRevertCurveOwners,t=0,n=e.length;t<n;++t)e[t].revertDefaultValue()},s6(ij,[{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)}}]),ij);ln([la],hs.prototype,"speed",void 0),ln([li],hs.prototype,"_controllerUpdateFlag",void 0),ln([li],hs.prototype,"_animatorLayersData",void 0),ln([li],hs.prototype,"_curveOwnerPool",void 0),ln([li],hs.prototype,"_needRevertCurveOwners",void 0),ln([li],hs.prototype,"_animationEventHandlerPool",void 0),ln([li],hs.prototype,"_tempAnimatorStateInfo",void 0),ln([li],hs.prototype,"_controlledRenderers",void 0);var hl=((iQ=(iY=function(){this._updateFlagManager=new lj,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iQ.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iQ.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iQ.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iQ._registerChangeFlag=function(){return this._updateFlagManager.createFlag(lK)},s6(iY,[{key:"layers",get:function(){return this._layers}}]),iY),hc=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},hu=((iZ=(iJ=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iZ.onStateUpdate=function(e,t,n){},iZ.onStateExit=function(e,t,n){},iZ.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iJ),hh=((i0=(i$=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)},i0.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},i0.addStateMachineScript=function(e){var t=new e;t._state=this;var n=hu.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},i0.clearTransitions=function(){this._transitions.length=0},i0._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},i0._removeStateMachineScript=function(e){var t=hu.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)}},s6(i$,[{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)}}]),i$),hd=((i2=(i1=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 hh(e),this.states.push(t),this._statesMap[e]=t),t},i2.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},i2.findStateByName=function(e){return this._statesMap[e]},i2.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},i1);e.AnimatorConditionMode=void 0,(i3=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[i3.If=0]="If",i3[i3.IfNot=1]="IfNot",i3[i3.Greater=2]="Greater",i3[i3.Less=3]="Less",i3[i3.Equals=4]="Equals",i3[i3.NotEquals=5]="NotEquals";var h_=function(){},hf=function(t){function n(r){var i;return(i=t.call(this,r,cz.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new s2(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 s9(n,t),n.prototype.clone=function(){var e=new n(this._engine);return this.cloneTo(e),e},s6(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}(cE);hf._tintColorProp=lB.getByName("material_TintColor"),hf._textureCubeProp=lB.getByName("material_CubeTexture"),hf._rotationProp=lB.getByName("material_Rotation"),hf._exposureProp=lB.getByName("material_Exposure"),hf._decodeSkyRGBMMacro=cm.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(i4=e.SunMode||(e.SunMode={}))[i4.None=0]="None",i4[i4.Simple=1]="Simple",i4[i4.HighQuality=2]="HighQuality";var hp=(s9(i5=function(t){var n;return(n=cE.call(this,t,cz.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new s2(.5,.5,.5,1),n.groundTint=new s2(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n},cE),i5.prototype.clone=function(){var e=new i5(this._engine);return this.cloneTo(e),e},s6(i5,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(i5._sunSimpleMacro),t.enableMacro(i5._sunHighQualityMacro);break;case 1:t.disableMacro(i5._sunHighQualityMacro),t.enableMacro(i5._sunSimpleMacro);break;case 0:t.disableMacro(i5._sunHighQualityMacro),t.disableMacro(i5._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(i5._sunSizeProp)},set:function(e){this.shaderData.setFloat(i5._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(i5._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(i5._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(i5._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(i5._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(i5._skyTintProp)},set:function(e){this.shaderData.setColor(i5._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(i5._groundTintProp)},set:function(e){this.shaderData.setColor(i5._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(i5._exposureProp)},set:function(e){this.shaderData.setFloat(i5._exposureProp,Math.min(Math.max(0,e),8))}}]),i5);hp._sunSizeProp=lB.getByName("material_SunSize"),hp._sunSizeConvergenceProp=lB.getByName("material_SunSizeConvergence"),hp._atmosphereThicknessProp=lB.getByName("material_AtmosphereThickness"),hp._skyTintProp=lB.getByName("material_SkyTint"),hp._groundTintProp=lB.getByName("material_GroundTint"),hp._exposureProp=lB.getByName("material_Exposure"),hp._sunHighQualityMacro=cm.getByName("MATERIAL_SUN_HIGH_QUALITY"),hp._sunSimpleMacro=cm.getByName("MATERIAL_SUN_SIMPLE"),(i8=sP||(sP={}))[i8.Position=1]="Position",i8[i8.Velocity=2]="Velocity",i8[i8.Acceleration=4]="Acceleration",i8[i8.Color=8]="Color",i8[i8.Alpha=16]="Alpha",i8[i8.Size=32]="Size",i8[i8.StartAngle=64]="StartAngle",i8[i8.StartTime=128]="StartTime",i8[i8.LifeTime=256]="LifeTime",i8[i8.RotateVelocity=512]="RotateVelocity",i8[i8.Scale=1024]="Scale",i8[i8.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(i6=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[i6.Transparent=0]="Transparent",i6[i6.Additive=1]="Additive";var hg=(s9(i7=function(e){var t;return(t=c3.call(this,e)||this)._maxCount=1e3,t._position=new sW,t._positionRandomness=new sW,t._velocity=new sW,t._velocityRandomness=new sW,t._acceleration=new sW,t._accelerationRandomness=new sW,t._color=new s2(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(s5(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},c3),(i9=i7.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)}},i9._onEnable=function(){c3.prototype._onEnable.call(this),this._playOnEnable&&this.start()},i9.start=function(){this._isStart=!0,this._time=0},i9.stop=function(){this._isStart=!1},i9._createMaterial=function(){var t=new cE(this.engine,cz.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},i9._createMesh=function(){var t=new ua(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>i7._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 cq("a_position",0,e.VertexElementFormat.Vector3,0),new cq("a_velocity",12,e.VertexElementFormat.Vector3,0),new cq("a_acceleration",24,e.VertexElementFormat.Vector3,0),new cq("a_color",36,e.VertexElementFormat.Vector4,0),new cq("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new cq("a_rotation",68,e.VertexElementFormat.Vector2,0),new cq("a_uv",76,e.VertexElementFormat.Vector3,0),new cq("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new cY(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new cY(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},i9._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},i9._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=i7._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]=sH.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[c+10]=sH.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[c+11]=sH.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[c+12]=sH.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 w=this._size;n[o+15]=n[s+15]=n[l+15]=n[c+15]=Math.max(w+i()*this._sizeRandomness*w*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)},i9._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},i9._onColorChanged=function(){this._updateDirtyFlag|=8},i7._getRandom=function(){return Math.random()-.5},s6(i7,[{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}}]),i7);hg._uint16VertexLimit=65535,ln([li],hg.prototype,"_onColorChanged",null),cz.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 hm=(s9(ae=function(t){var n,r=(n=cE.call(this,t,cz.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},cE),ae),hv=new sW,hy=(s9(at=function(e,t){(n=c3.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 sW),n._pointStates.push(n._lifetime),n._strapPoints.push(new sW),n._strapPoints.push(new sW);n._curPointNum=0;var i=t.material||new hm(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},c3),(an=at.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];sW.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++)},an.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},an._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),c3.prototype._render.call(this,e)},an._initGeometry=function(){var t=new ua(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new cq("POSITION",0,e.VertexElementFormat.Vector3,0),new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new cY(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},an._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sW(n[0],n[4],n[8]),i=new sW(n[1],n[5],n[9]),a=new sW(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sW,l=new sW,c=new sJ;sW.transformByQuat(r,c,r),sW.transformByQuat(i,c,i);var u=new sW,h=new sW,d=new sW;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?sW.subtract(p,t[f-1],d):sW.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sW.dot(r,d));sW.cross(r,d,h),0>=sW.dot(h,a)&&(g=2*Math.PI-g),sJ.rotationAxisAngle(a,g,c),sW.transformByQuat(i,c,u),sW.add(p,u,s),sW.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}},an._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}}},an._projectOnVector=function(e,t,n){var r=t.clone();sW.normalize(r,r);var i=sW.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},an._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,hv),sW.subtract(e,hv,n)},at),hx=(s9(ar=function(){var t;return t=uS.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uS),(ai=ar.prototype).onTextureChange=function(e){},ai.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 lx(this.engine,this.width,this.height,this._isCube?new lS(this.engine,this.width):new lT(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new lx(this.engine,this.width,this.height,this._isCube?new lS(this.engine,this.width):new lT(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},ai.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},ai._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},s6(ar,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),ar),hT=new sW,hC=new sW,hS=new sW,hw=(s9(aa=function(){var e;return e=hx.apply(this,arguments)||this,e.position=new sW(0,0,0),e._isCube=!0,e.oriViewMatrix=new sZ,e},hx),(ao=aa.prototype).onBeginRender=function(t){if(this.enabled){hx.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),hx.prototype._reset.call(this)}},ao._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ao._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ao._setCamera=function(e,t){switch(e){case 0:hC.set(0,-1,0),hS.set(1,0,0);break;case 1:hC.set(0,-1,0),hS.set(-1,0,0);break;case 2:hC.set(0,0,1),hS.set(0,1,0);break;case 3:hC.set(0,0,-1),hS.set(0,-1,0);break;case 4:hC.set(0,-1,0),hS.set(0,0,1);break;case 5:hC.set(0,-1,0),hS.set(0,0,-1)}sW.add(this.position,hS,hT),sZ.lookAt(this.position,hT,hC,t.viewMatrix),t.fieldOfView=90},aa),hA=Object.freeze({__proto__:null,AmbientLight:ug,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:he,AnimationClipCurveBinding:u7,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:ht,AnimationEvent:u9,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:hs,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hl,AnimatorControllerLayer:hc,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:hh,AnimatorStateMachine:hd,AnimatorStateTransition:hr,AssetPromise:lb,get AssetType(){return e.AssetType},Background:up,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uk,Basic2DBatcher:ul,BasicRenderPipeline:uL,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:us,BlendShapeFrame:uo,BlendState:cT,BlinnPhongMaterial:uG,BoolUpdateFlag:lK,BoxColliderShape:l5,Buffer:cY,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:ua,get BufferUsage(){return e.BufferUsage},BufferUtil:cj,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:l7,CharacterController:l3,CloneManager:ll,get Collider(){return e.Collider},ColliderShape:l4,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:lU,ContentRestorer:lh,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:hw,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:cC,get DiffuseMode(){return e.DiffuseMode},DirectLight:c_,DynamicCollider:co,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:uC,EngineObject:lc,Entity:lQ,EventDispatcher:lI,FixedJoint:ce,get FogMode(){return e.FogMode},Font:lM,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:ct,HitResult:l0,IndexBufferBinding:cQ,get IndexFormat(){return e.IndexFormat},InputManager:ch,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:cr,JointMotor:ci,Keyframe:h_,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:cd,Loader:uz,Logger:lv,Material:cE,Mesh:cZ,MeshRenderer:c3,get MeshTopology(){return e.MeshTopology},ModelMesh:c1,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uH,PBRMaterial:uW,PBRSpecularMaterial:uX,ParticleRenderer:hg,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:l1,PhysicsMaterial:l2,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},get PipelineStage(){return e.PipelineStage},PlaneColliderShape:l6,get Platform(){return e.Platform},PointLight:cf,Pointer:lJ,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:ui,Probe:hx,RasterState:cS,ReferResource:lu,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uP,RenderQueue:uA,get RenderQueueType(){return e.RenderQueueType},RenderState:cA,RenderTarget:lx,RenderTargetBlendState:cx,get Renderer(){return e.Renderer},ResourceManager:lR,Scene:um,SceneManager:uv,Script:uS,get SetDataOptions(){return e.SetDataOptions},Shader:cz,ShaderData:cy,ShaderFactory:cL,ShaderMacro:cm,ShaderMacroCollection:cv,ShaderPass:cO,ShaderProperty:lB,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:cD,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:c2,SkinnedMeshRenderer:c4,Sky:uf,SkyBoxMaterial:hf,SkyProceduralMaterial:hp,SphereColliderShape:l8,SpotLight:cp,SpringJoint:cn,Sprite:uq,SpriteAtlas:uj,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:cK,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:uJ,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:hu,StaticCollider:ca,get StencilOperation(){return e.StencilOperation},StencilState:cw,SubMesh:cJ,SubShader:cU,get SunMode(){return e.SunMode},SystemInfo:lZ,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:u0,TextUtils:lA,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:ly,Texture2D:lT,Texture2DArray:lC,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:lS,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:lN,TrailMaterial:hm,TrailRenderer:hy,Transform:lq,UnlitMaterial:uK,Utils:lG,VertexBufferBinding:c$,VertexElement:cq,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:la,deepClone:ls,dependentComponents:lk,ignoreClone:li,request:uN,resourceLoader:lF,shallowClone:lo});function hE(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 hM(e,t,n){return t&&hE(e.prototype,t),n&&hE(e,n),e}function hb(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(as=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[as.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",as[as.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",as[as.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",as[as.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",as[as.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",as[as.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",as[as.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",as[as.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",as[as.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",as[as.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",as[as.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",as[as.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",as[as.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",as[as.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",as[as.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",as[as.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",as[as.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",as[as.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",as[as.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",as[as.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",as[as.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",as[as.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",as[as.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",as[as.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",as[as.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",as[as.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",as[as.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",as[as.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",as[as.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",as[as.R11_EAC=37488]="R11_EAC",as[as.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",as[as.RG11_EAC=37490]="RG11_EAC",as[as.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",as[as.RGB8_ETC2=37492]="RGB8_ETC2",as[as.SRGB8_ETC2=37493]="SRGB8_ETC2",as[as.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",as[as.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",as[as.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",as[as.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",as[as.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",as[as.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",as[as.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",as[as.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",as[as.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",as[as.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",as[as.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",as[as.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var hR=((ac=(al=function(e){this._scale=new s0;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&&hb(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},ac.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},hM(al,[{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&&hb(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&&hb(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),al);function hF(e,t){return(hF=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hP(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&&hF(e,t)}var hL=(hP(au=function(){return uC.apply(this,arguments)},uC),au.create=function(e){var t=e.canvas,n=new hR("string"==typeof t?document.getElementById(t):t),r=new hW(e.graphicDeviceOptions);return new au(n,r,e)._initialize(e)},hM(au,[{key:"canvas",get:function(){return this._canvas}}]),au);function hD(){return(hD=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 hI=((ad=(ah=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)},ad.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)},ad.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."},ad.resize=function(e){this.bind(),this._gl.bufferData(this._glBindTarget,e,this._glBufferUsage)},ad.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},ad._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}},ah),hB=((af=(a_=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},af.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)},af._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,w=e.GLCapabilityType.textureHalfFloat,A=e.GLCapabilityType.textureFloatLinear,E=e.GLCapabilityType.textureHalfFloatLinear,M=e.GLCapabilityType.WEBGL_colorBufferFloat,b=e.GLCapabilityType.colorBufferFloat,R=e.GLCapabilityType.colorBufferHalfFloat,F=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(w,n||!!r(w)),t.set(A,!!r(A)),t.set(E,n||!!r(E)),t.set(b,n&&!!r(b)||!!r(M)),t.set(R,n&&!!r(b)||!!r(R)),t.set(F,!!r(F)),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)))},af._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}},af._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,hD({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"})},hM(a_,[{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}}]),a_),hN=((ap=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]},ap),hV=((am=(ag=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 lv.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()},am.destroy=function(){this._useVao&&this._clearVAO()},am._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 lv.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},am._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},am._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)},am._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},ag),hO=((av=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]},av),hU=((ax=(ay=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},ax.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},ax.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},ax._bind=function(){this._rhi.bindTexture(this)},ax._init=function(t){var n=this._gl,r=this._isWebGL2,i=this._formatDetail,a=i.internalFormat,o=i.baseFormat,s=i.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,a,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,a,p,p,0,o,s,null);else if(_)n.texImage2D(this._target,0,a,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,a,v,y,0,o,s,null)}},ax._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,lv.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)},ax._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||ay._isPowerOf2(s)&&ay._isPowerOf2(l)||(lv.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)}},ax._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},ay._isPowerOf2=function(e){return(e&e-1)==0},ay._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)}},ay._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)}},ay._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},ay._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},ay._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},hM(ay,[{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)}}}]),ay),hz=((aC=(aT=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=hb(i,ly),l=0,c=r.length;l<c;l++){var u=r[l]._format;if(!hU._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!hU._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 hb(e,lS)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(lv.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=hb(a,lS);(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=hb(i,lS);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=hU._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()},aC.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)}},aC.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},aC._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},aC._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,hb(c,lS)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(hb(r,ly)&&!hb(r,lS)){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=hU._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)},aC._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=hb(i,ly)?i._platformTexture._formatDetail:hU._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)},aC._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.")},aT),hk=(hP(aS=function(t,n){(r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||hU._isPowerOf2(o)&&hU._isPowerOf2(s)||(lv.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=hU._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},hU),(aw=aS.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)},aw.setImageSource=function(t,n,r,i,a,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,+i),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,n,c,u,h,t):s.texSubImage2D(this._target,n,a||0,o||0,u,h,t)},aw.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hU.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},aS),hG=(hP(aA=function(t,n){r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=hU._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},hU),(aE=aA.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)},aE.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)},aE.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)},aA),hH=(hP(aM=function(t,n){(r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||hU._isPowerOf2(o)||(lv.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=hU._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},hU),(ab=aM.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)},ab.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)},ab.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hU.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},aM);e.WebGLMode=void 0,(aR=e.WebGLMode||(e.WebGLMode={}))[aR.Auto=0]="Auto",aR[aR.WebGL2=1]="WebGL2",aR[aR.WebGL1=2]="WebGL1";var hW=((aP=(aF=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new s1(null,null,null,null),this._lastScissor=new s1(null,null,null,null),this._lastClearColor=new s2(null,null,null,null),this._scissorEnable=!1;var n=hD({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(lZ.platform===e.Platform.IPhone||lZ.platform===e.Platform.IPad){var r=lZ.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&&hb(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&&hb(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},aP.createPlatformPrimitive=function(e){return new hV(this,e)},aP.createPlatformTexture2D=function(e){return new hk(this,e)},aP.createPlatformTexture2DArray=function(e){return new hG(this,e)},aP.createPlatformTextureCube=function(e){return new hH(this,e)},aP.createPlatformRenderTarget=function(e){return new hz(this,e)},aP.createPlatformBuffer=function(t,n,r,i){return void 0===r&&(r=e.BufferUsage.Static),new hI(this,t,n,r,i)},aP.requireExtension=function(e){return this._extensions.requireExtension(e)},aP.canIUse=function(e){return this.capability.canIUse(e)},aP.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},aP.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))},aP.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)}},aP.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},aP.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)},aP.drawPrimitive=function(e,t,n){e?e._draw(n,t):lv.error("draw primitive failed.")},aP.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)},aP.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},aP.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)},aP.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},aP.flush=function(){this._gl.flush()},aP.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},aP.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},aP.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)},aP._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new hO(e),this._extensions=new hN(this),this._capability=new hB(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},aP.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},aP._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},aP._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},aP._onWebGLContextRestored=function(e){this._onDeviceRestored()},hM(aF,[{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}}]),aF);function hX(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=((aD=(aL=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:lv.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},aD.addCurrentLoad=function(e){this._currentLoad+=e},aD.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},aD.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},aD.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},hX(aL.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),aI&&hX(aL,aI),aL),hj='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',hq="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",hY=((aN=(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)lv.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?uN(""+hq+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,hj].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uN(""+hq+"draco_wasm_wrapper_gltf.js",{type:"text"}),uN(""+hq+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,hj].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},aN.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]})},aN.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 hQ(){return(hQ=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 hJ(e,t){return(hJ=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hZ(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&&hJ(e,t)}function h$(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 h0(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 h1=(hZ(aV=function(){return uz.apply(this,arguments)},uz),aV.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"json"})).then(function(e){var n=new hl,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hc(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,h=c.stateMachine=new hd;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(uz.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 hr;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)})},aV);h1=h$([lF(e.AssetType.AnimatorController,["json"],!1)],h1);var h2=(hZ(aO=function(){return uz.apply(this,arguments)},uz),aO.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new lb(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,hQ({},e,{type:"arraybuffer"}))},aO);h2=h$([lF(e.AssetType.Buffer,["bin","r3bin"],!1)],h2);var h3=(hZ(aU=function(){return uz.apply(this,arguments)},uz),aU.prototype.load=function(t,n){var r=this;return new lb(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 lS(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 ug,p=new s4;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},aU);function h4(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 h5(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){h4(a,r,i,o,s,"next",e)}function s(e){h4(a,r,i,o,s,"throw",e)}o(void 0)})}}h3=h$([lF(e.AssetType.Env,["env"])],h3);var h8=(hZ(az=function(){return uz.apply(this,arguments)},uz),(ak=az.prototype).load=function(e,t){var n=this;return new lb(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 lM(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new lM(t.engine,a))}).catch(function(e){i(e)})})},ak._registerFont=function(e,t){return h5(function(){var n;return h0(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]}})})()},az);function h6(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 h7(e,t){if(e){if("string"==typeof e)return h6(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 h6(e,t)}}function h9(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=h7(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.")}h8=h$([lF(e.AssetType.Font,["font"],!1)],h8);var de=(hZ(aG=function(){var e;return e=lh.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},lh),(aH=aG.prototype).restoreContent=function(){var e=this;return new lb(function(t,n){Promise.all(e.bufferRequests.map(function(e){return uN(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)}}lb.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 dd.loadImageBuffer(a,e.mimeType).then(function(t){e.texture.setImageSource(t),e.texture.generateMipmaps()})})).then(function(){for(var n,i=h9(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=h9(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,_=h9(o.blendShapes);!(d=_()).done;){var f=d.value,p=f.blendShape.frames[0],g=e._getBufferData(r,f.position);if(p.deltaPositions=dd.floatBufferToVector3Array(g),f.normal){var m=e._getBufferData(r,f.normal);p.deltaNormals=dd.floatBufferToVector3Array(m)}if(f.tangent){var v=e._getBufferData(r,f.tangent);p.deltaTangents=dd.floatBufferToVector3Array(v)}}s.uploadData(!0)}t(e.resource)}).catch(n)}).catch(n)})},aH._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},aG),dt=function(e,t){this.url=e,this.config=t},dn=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},dr=function(){this.vertexBuffers=[],this.blendShapes=[]},di=function(e,t){this.buffer=e,this.data=t},da=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},ds=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},dl=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r};(aW=sL||(sL={}))[aW.BYTE=5120]="BYTE",aW[aW.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",aW[aW.SHORT=5122]="SHORT",aW[aW.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",aW[aW.UNSIGNED_INT=5125]="UNSIGNED_INT",aW[aW.FLOAT=5126]="FLOAT",(aX=sD||(sD={})).SCALAR="SCALAR",aX.VEC2="VEC2",aX.VEC3="VEC3",aX.VEC4="VEC4",aX.MAT2="MAT2",aX.MAT3="MAT3",aX.MAT4="MAT4",(aK=sI||(sI={})).TRANSLATION="translation",aK.ROTATION="rotation",aK.SCALE="scale",aK.WEIGHTS="weights",(aj=sB||(sB={})).Linear="LINEAR",aj.Step="STEP",aj.CubicSpine="CUBICSPLINE",(aq=sN||(sN={})).PERSPECTIVE="perspective",aq.ORTHOGRAPHIC="orthographic",(aY=sV||(sV={})).JPEG="image/jpeg",aY.PNG="image/png",(aQ=sO||(sO={})).OPAQUE="OPAQUE",aQ.MASK="MASK",aQ.BLEND="BLEND",(aJ=sU||(sU={}))[aJ.NEAREST=9728]="NEAREST",aJ[aJ.LINEAR=9729]="LINEAR",(aZ=sz||(sz={}))[aZ.NEAREST=9728]="NEAREST",aZ[aZ.LINEAR=9729]="LINEAR",aZ[aZ.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",aZ[aZ.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",aZ[aZ.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",aZ[aZ.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(a$=sk||(sk={}))[a$.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",a$[a$.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",a$[a$.REPEAT=10497]="REPEAT";var dc=((a0=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new dh,this.materialsPromiseInfo=new dh,this.meshesPromiseInfo=new dh,this.animationClipsPromiseInfo=new dh,this.defaultSceneRootPromiseInfo=new dh,this.masterPromiseInfo=new dh,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 lb(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},a0),du=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},dh=function(){},dd=((a1=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new s0(e[r],e[r+1]);return n},a1.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sW(e[r],e[r+1],e[r+2]);return n},a1.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new s1(e[r],e[r+1],e[r+2],e[r+3]);return n},a1.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 s2(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new s2(e[a],e[a+1],e[a+2],e[a+3]);return r},a1.getAccessorTypeSize=function(e){switch(e){case sD.SCALAR:return 1;case sD.VEC2:return 2;case sD.VEC3:return 3;case sD.VEC4:case sD.MAT2:return 4;case sD.MAT3:return 9;case sD.MAT4:return 16}},a1.getComponentType=function(e){switch(e){case sL.BYTE:return Int8Array;case sL.UNSIGNED_BYTE:return Uint8Array;case sL.SHORT:return Int16Array;case sL.UNSIGNED_SHORT:return Uint16Array;case sL.UNSIGNED_INT:return Uint32Array;case sL.FLOAT:return Float32Array}},a1.getNormalizedComponentScale=function(e){switch(e){case sL.BYTE:return 1/127;case sL.UNSIGNED_BYTE:return 1/255;case sL.SHORT:return 1/32767;case sL.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},a1.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=a1.getComponentType(a),d=a1.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 du(C,!0,g),r.restoreInfo=new da(new ds(s,h,x,T))}}else{var S=c+u,w=p*d,A=new h(l,S,w);(r=new du(A,!1,f)).restoreInfo=new da(new ds(s,h,S,w))}return n.sparse&&a1.processingSparseData(t,n,i,r),r},a1.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=a1.getAccessorTypeSize(t.type),u=c*t.count,h=null!=(v=i.byteStride)?v:0,d=a1.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,w=t.sparse,A=w.count,E=w.indices,M=w.values,b=r[E.bufferView],R=r[M.bufferView],F=n[b.buffer],P=n[R.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=R.byteOffset)?S:0),B=R.byteLength,N=a1.getComponentType(E.componentType),V=new N(F,L,D/N.BYTES_PER_ELEMENT),O=new d(P,I,B/d.BYTES_PER_ELEMENT),U=0;U<A;U++)for(var z=V[U],k=0;k<c;k++)m[z*c+k]=O[U*c+k];return m},a1.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},a1.processingSparseData=function(e,t,n,r){var i,a,o,s,l=r.restoreInfo,c=a1.getAccessorTypeSize(t.type),u=a1.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,w=(null!=(o=p.byteOffset)?o:0)+(null!=(s=m.byteOffset)?s:0),A=m.byteLength;l.typeSize=c,l.sparseCount=_;var E=a1.getComponentType(f.componentType),M=S/E.BYTES_PER_ELEMENT,b=new E(x,C,M);l.sparseIndices=new ds(v,E,C,M);var R=A/u.BYTES_PER_ELEMENT,F=new u(T,w,R);l.sparseValues=new ds(y,u,w,R);for(var P=0;P<_;P++)for(var L=b[P],D=0;D<c;D++)h[L*c+D]=F[P*c+D];r.data=h},a1.getIndexFormat=function(t){switch(t){case sL.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case sL.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case sL.UNSIGNED_INT:return e.IndexFormat.UInt32}},a1.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==sL.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==sL.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==sL.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==sL.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==sL.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},a1.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)})},a1.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(lG.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 s0(d,a)),u+=a+8}return{glTF:l,buffers:c}},a1._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},a1);function d_(e){return function(e){if(Array.isArray(e))return h6(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h7(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 df=((a3=(a2=function(){}).prototype).initialize=function(){},a3.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."},a3.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."},a2);e.GLTFExtensionMode=void 0,(a4=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[a4.CreateAndParse=0]="CreateAndParse",a4[a4.AdditiveParse=1]="AdditiveParse";var dp=((a5=function(){}).executeExtensionsInitialize=function(e){var t=a5._extensionParsers[e],n=null==t?void 0:t.length;if(n)return t[n-1].initialize()},a5.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=a5._createAndParse.apply(a5,[c,t,u,n].concat(d_(i))))return o}},a5.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];a5._additiveParse.apply(a5,[s,t,n,l,r].concat(d_(a)))}},a5.hasExtensionParser=function(e){var t;return!!(null==(t=a5._extensionParsers[e])?void 0:t.length)},a5.getExtensionParser=function(e,t){var n=a5._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}},a5._addExtensionParser=function(e,t){a5._extensionParsers[e]||(a5._extensionParsers[e]=[]),a5._extensionParsers[e].push(t)},a5._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=a5.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,i].concat(d_(o)))},a5._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=a5.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[n,r,i,a].concat(d_(s)))},a5);function dg(e,t){return function(n){var r=new n;r._mode=t,dp._addExtensionParser(e,r)}}dp._extensionParsers={};var dm=(hZ(a8=function(){return dp.apply(this,arguments)},dp),a8.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=dp.executeExtensionsCreateAndParse(l.extensions,e,l);h||(h=new he(u),a8._parseStandardProperty(e,h,l)),o.push(h)}return lb.all(o).then(function(r){n.animations=r;for(var a=0;a<t.animations.length;a++){var o=t.animations[a];dp.executeExtensionsAdditiveAndParse(o.extensions,e,r[a],o)}return i.resolve(r),i.promise})}},a8._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=dd.getAccessorBuffer(t,s,p).data,v=dd.getAccessorBuffer(t,s,g).data;if(g.normalized){for(var y=dd.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,w=null!=(_=f.interpolation)?_:sB.Linear,A=void 0;switch(w){case sB.CubicSpine:A=e.InterpolationType.CubicSpine;break;case sB.Step:A=e.InterpolationType.Step;break;case sB.Linear:A=e.InterpolationType.Linear}m[m.length-1],u.push({type:g.type,interpolation:A,input:m,output:v,outputSize:S})}for(var E=0,M=l.length;E<M;E++){for(var b=l[E],R=b.target,F=a[R.node],P="",L=F;L.parent;)P=""===P?""+L.name:L.name+"/"+P,L=L.parent;var D=void 0,I=void 0;switch(R.path){case sI.TRANSLATION:D=lq,I="position";break;case sI.ROTATION:D=lq,I="rotationQuaternion";break;case sI.SCALE:D=lq,I="scale";break;case sI.WEIGHTS:D=c4,I="blendShapeWeights"}var B=this._addCurve(R.path,b,u);n.addCurveBinding(P,D,I,B)}},a8._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case sI.TRANSLATION:case sI.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,h=0,d=a.length;h<d;h++){var _=new h_;_.time=a[h],c===e.InterpolationType.CubicSpine?(_.inTangent=new sW(o[u++],o[u++],o[u++]),_.value=new sW(o[u++],o[u++],o[u++]),_.outTangent=new sW(o[u++],o[u++],o[u++])):_.value=new sW(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case sI.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 h_;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new s1(o[g++],o[g++],o[g++],o[g++]),y.value=new sJ(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new s1(o[g++],o[g++],o[g++],o[g++])):y.value=new sJ(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case sI.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var T=0,C=0,S=a.length;C<S;C++){var w=new h_;w.time=a[C],x.interpolation===e.InterpolationType.CubicSpine?(w.inTangent=Array.from(o.subarray(T,T+s)),T+=s,w.value=o.subarray(T,T+s),T+=s,w.outTangent=Array.from(o.subarray(T,T+s)),T+=s):(w.value=o.subarray(T,T+s),T+=s),x.addKey(w)}return x}},a8),dv=(hZ(a6=function(){return dp.apply(this,arguments)},dp),(a7=a6.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)?uN(r,a).then(function(t){return i.push(new dt(r,a)),dd.parseGLB(e,t)}).then(function(t){var n=t.glTF,r=t.buffers;e.glTF=n,e.buffers=r}):uN(r,{type:"json"}).then(function(t){return e.glTF=t,Promise.all(t.buffers.map(function(e){var t=lG.resolveAbsoluteUrl(r,e.uri);return i.push(new dt(t,a)),uN(t,a)})).then(function(t){e.buffers=t})})},a7._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},a6),dy=(hZ(a9=function(){return dp.apply(this,arguments)},dp),(oe=a9.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 lQ(r,o.name||""+a9._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)}},oe._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)}}},oe._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 lQ(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],t.defaultSceneRoot._hookResource=t,t._addReferCount(1)}},a9);dy._defaultName="_GLTF_ENTITY_";var dx=(hZ(ot=function(){return dp.apply(this,arguments)},dp),ot.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=dp.executeExtensionsCreateAndParse(s.extensions,e,s);l||((l=new uW(i)).name=s.name,ot._parseStandardProperty(e,l,s)),a.push(l)}return lb.all(a).then(function(i){n.materials=i;for(var a=0;a<t.materials.length;a++){var o=t.materials[a];dp.executeExtensionsAdditiveAndParse(o.extensions,e,i[a],o)}return r.resolve(i),r.promise})}},ot._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&lv.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},ot._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 s2(s2.linearToGammaSpace(_[0]),s2.linearToGammaSpace(_[1]),s2.linearToGammaSpace(_[2]),_[3])),f&&(n.baseTexture=i[f.index],dp.executeExtensionsAdditiveAndParse(f.extensions,t,n,f)),n.constructor===uW&&(n.metallic=null!=p?p:1,n.roughness=null!=g?g:1,m&&(n.roughnessMetallicTexture=i[m.index],ot._checkOtherTextureTransform(m,"Roughness metallic")))}if(n.constructor===uW||n.constructor===uX){if(l&&(n.emissiveTexture=i[l.index],ot._checkOtherTextureTransform(l,"Emissive")),c&&(n.emissiveColor=new s2(s2.linearToGammaSpace(c[0]),s2.linearToGammaSpace(c[1]),s2.linearToGammaSpace(c[2]))),o){var v=o.index,y=o.scale;n.normalTexture=i[v],ot._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],ot._checkOtherTextureTransform(s,"Occlusion"),void 0!==T&&(n.occlusionTextureIntensity=T),C===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:C>e.TextureCoordinate.UV1&&lv.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,u){case sO.OPAQUE:n.isTransparent=!1;break;case sO.BLEND:n.isTransparent=!0;break;case sO.MASK:n.alphaCutoff=null!=h?h:.5}},ot);function dT(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var dC=(hZ(on=function(){return dp.apply(this,arguments)},dp),on.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=dp.executeExtensionsCreateAndParse(a.extensions,e,a,s);if(l)dT(l,c1)?o(l):l.then(function(e){return o(e)});else{var c=new c1(i,s.name||r+""),u=new dr;u.mesh=c,e.contentRestorer.meshes.push(u),on._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 dd.getAccessorBuffer(e,e.glTF.bufferViews,o)},function(){var e=t.accessors[a.indices];return dd.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 lb.all(o).then(function(e){r.meshes=e,a.resolve(e)}).catch(a.reject),a.promise}},on._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 w=p[g[S]],A=dd.getAccessorBuffer(t,o.bufferViews,w),E=dd.getAccessorTypeSize(w.type),M=w.count,b=A.data,R=void 0,F=n.instanceId,P=A.vertexBindingInfos,L=w.normalized,D=dd.getElementFormat(w.componentType,E,L),I=void 0;L&&(I=dd.getNormalizedComponentScale(w.componentType));var B=void 0;if(A.interleaved){var N=w.byteOffset||0,V=A.stride;if(B=N%V,void 0===P[F]){R=new cq(S,B,D,C);var O=A.vertexBuffer;O||((O=new cY(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static)).setData(b),A.vertexBuffer=O,r.vertexBuffers.push(new di(O,A.restoreInfo))),n.setVertexBufferBinding(O,V,C),P[F]=C++}else R=new cq(S,B,D,P[F])}else{B=0,R=new cq(S,B,D,C);var U=new cY(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static);U.setData(b),r.vertexBuffers.push(new di(U,A.restoreInfo)),n.setVertexBufferBinding(U,A.stride,C),P[F]=C++}if(T.push(R),"POSITION"===S){h=M;var z=n.bounds,k=z.min,G=z.max;if(w.min&&w.max){if(k.copyFromArray(w.min),G.copyFromArray(w.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 sW(b[K],b[K+1],b[K+2]);L&&j.scale(I),d[X]=j}}else{var q=on._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),sW.min(k,q,k),sW.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 s1(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 s1(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=dd.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&&on._createBlendShape(n,r,i,m,l),n.uploadData(!u),n._positions=d,n._boneIndices=_,n._boneWeights=f,Promise.resolve(n)},on._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?dd.floatBufferToVector3Array(c.data):null,_=(null==u?void 0:u.data)?dd.floatBufferToVector3Array(null==u?void 0:u.data):null,f=(null==h?void 0:h.data)?dd.floatBufferToVector3Array(null==h?void 0:h.data):null,p=new us(l);p.addFrame(1,d,_,f),e.addBlendShape(p),t.blendShapes.push(new dl(p,c.restoreInfo,null==u?void 0:u.restoreInfo,null==h?void 0:h.restoreInfo))}},on);dC._tempVector3=new sW;var dS=(hZ(or=function(){return dp.apply(this,arguments)},dp),(oi=or.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),dp.executeExtensionsAdditiveAndParse(h,e,d,l)}return t.defaultSceneRoot&&this._createAnimator(e),o.resolve(t.defaultSceneRoot),o.promise}},oi._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===sN.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===sN.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},oi._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(c4);f.mesh=i,void 0!==u&&(f.skin=l[u]),_&&(f.blendShapeWeights=new Float32Array(_)),h=f}else(h=n.addComponent(c3)).mesh=i;var p=r.material,g=(null==s?void 0:s[p])||or._getDefaultMaterial(a);h.setMaterial(g),i.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(h.enableVertexColor=!0)}),dp.executeExtensionsAdditiveAndParse(r.extensions,e,h,r)}(f)},oi._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(hs),a=new hl,o=new hc("layer"),s=new hd;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}}},or._getDefaultMaterial=function(e){return or._defaultMaterial||(or._defaultMaterial=new uG(e)),or._defaultMaterial},or),dw=(hZ(oa=function(){return dp.apply(this,arguments)},dp),(oo=oa.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 c2(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[c],m=dd.getAccessorBuffer(e,n.bufferViews,g).data,v=0;v<f;v++){var y=new sZ;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 w=this._findSkeletonRootBone(h,r);if(w)p.skeleton=w.name;else throw"Failed to find skeleton root bone."}o[s]=p}t.skins=o}},oo._findSkeletonRootBone=function(e,t){for(var n,r={},i=h9(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}},oa),dA=(hZ(os=function(){return dp.apply(this,arguments)},dp),(ol=os.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 lb.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:lG.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 dd.loadImageBuffer(T,p).then(function(e){var r=new lT(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 dn(r,y,p);return t.contentRestorer.bufferTextures.push(a),r})})).then(function(e){r.textures=e,l.resolve(e)}).catch(l.reject),l.promise}},ol._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===sU.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=sz.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=os._wrapMap[a]),o&&(t.wrapModeV=os._wrapMap[o])},os);dA._wrapMap=((oc={})[sk.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,oc[sk.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,oc[sk.REPEAT]=e.TextureWrapMode.Repeat,oc);var dE=(hZ(ou=function(){return dp.apply(this,arguments)},dp),ou.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){lv.info("extensionsUsed: ",r);for(var s=0;s<r.length;s++){var l=r[s];dp.hasExtensionParser(l)||lv.warn("Extension "+l+" is not implemented, you can customize this extension in gltf.")}}if(i){lv.info("extensionsRequired: "+i);for(var c=0;c<i.length;c++){var u=i[c];dp.hasExtensionParser(u)?o.push(dp.executeExtensionsInitialize(u)):lv.error("GLTF parser has not supported required extension "+u+".")}}return lb.all(o).then(null)},ou),dM=((oh=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 lb(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)})},oh);dM.defaultPipeline=new dM(dv,dE,dA,dx,dC,dy,dw,dm,dS);var db=(hZ(od=function(e,t){var n;return(n=lu.call(this,e)||this).url=t,n},lu),od),dR=(hZ(o_=function(){return uz.apply(this,arguments)},uz),o_.prototype.load=function(e,t){var n,r=e.url,i=e.params,a=new dc(r),o=new db(t.engine,r),s=new de(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=h9(t);!(e=n()).done;)e.value.cancel()}),((null==i?void 0:i.pipeline)||dM.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},o_);dR=h$([lF(e.AssetType.GLTF,["gltf","glb"])],dR);var dF=Math.PI,dP=(hZ(of=function(){return uz.apply(this,arguments)},uz),of.prototype.load=function(t,n){var r=this;return new lb(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=dP._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,c=dP._readPixels(n.subarray(l),a,s),u=s>>1,h=dP._convertToCubemap(c,a,s,u),d=new lS(o,u),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},of._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)]},of._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},of._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-dF;)i+=2*dF;for(;i>dF;)i-=2*dF;var o=i/dF,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/dF*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 s2(u,h,d,_)},of._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},of._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}},of._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},of._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},of._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},(sG=of)._rightBottomBack=new sW(1,-1,-1),sG._rightBottomFront=new sW(1,-1,1),sG._rightUpBack=new sW(1,1,-1),sG._rightUpFront=new sW(1,1,1),sG._leftBottomBack=new sW(-1,-1,-1),sG._leftBottomFront=new sW(-1,-1,1),sG._leftUpBack=new sW(-1,1,-1),sG._leftUpFront=new sW(-1,1,1),sG._faceRight=[sG._rightBottomBack,sG._rightBottomFront,sG._rightUpBack,sG._rightUpFront],sG._faceLeft=[sG._leftBottomFront,sG._leftBottomBack,sG._leftUpFront,sG._leftUpBack],sG._faceUp=[sG._leftBottomFront,sG._rightBottomFront,sG._leftBottomBack,sG._rightBottomBack],sG._faceBottom=[sG._leftUpBack,sG._rightUpBack,sG._leftUpFront,sG._rightUpFront],sG._faceFront=[sG._leftBottomBack,sG._rightBottomBack,sG._leftUpBack,sG._rightUpBack],sG._faceBack=[sG._rightBottomFront,sG._leftBottomFront,sG._rightUpFront,sG._leftUpFront],sG._tempVector3=new sW,sG._temp2Vector3=new sW,sG._temp3Vector3=new sW,sG._temp4Vector3=new sW,sG._temp5Vector3=new sW,sG);dP=h$([lF(e.AssetType.HDR,["hdr"])],dP);var dL=(hZ(op=function(){return uz.apply(this,arguments)},uz),op.prototype.load=function(e){return this.request(e.url,hQ({},e,{type:"json"}))},op);dL=h$([lF(e.AssetType.JSON,["json"],!1)],dL);var dD={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 dI(e){var t=dD.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var dB=(hZ(og=function(){return uz.apply(this,arguments)},uz),og.prototype.load=function(t,n){var r=this;return new lb(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,hQ({},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=dD.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 lS(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)})})},og);dB=h$([lF(e.AssetType.KTXCube,[])],dB);var dN=(hZ(om=function(){return uz.apply(this,arguments)},uz),om.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){for(var n=dI(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new lT(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)})})},om);dN=h$([lF(e.AssetType.KTX,["ktx"])],dN);var dV=(hZ(ov=function(){return uz.apply(this,arguments)},uz),ov.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},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 s0(i.x,i.y));break;case"Vector3":d.setVector3(e,new sW(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new s1(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new s2(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 cE(i,cz.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)})},ov);function dO(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 dU(e,t,n){return t&&dO(e.prototype,t),n&&dO(e,n),e}dV=h$([lF(e.AssetType.Material,["json"])],dV);var dz=((ox=(oy=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},ox.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},ox.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},ox.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},ox.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,lG.decodeText(t)},ox.nextImageData=function(e){return this.buffer.slice(this._offset)},ox.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},ox.skip=function(e){return this._offset+=e,this},ox.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)},dU(oy,[{key:"offset",get:function(){return this._offset}}]),oy);dz.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var dk={};function dG(e){return function(t){dk[e]=t}}var dH=((oT=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=lG.decodeText(s),c=lG.decodeText(a),u=new oT;return u.totalLength=n,u.name=l,u.type=c,u.version=r,u.headerLength=s.byteLength+a.byteLength+9,u},dU(oT,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oT);function dW(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new s1(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function dX(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sW(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 s0(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 i=new(Function.bind.apply(e,r));return n&&hJ(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oC=function(){}).decode=function(e,t){return new Promise(function(n){var r=new c1(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=dX(o,s);if(r.setPositions(l),i.normals){var c=dX(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 s2(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(dW(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(dW(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new us(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=dX(r,i);e.deltaNormals&&dX(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&dW(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)})},oC),e.MeshDecoder=h$([dG("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oS=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 lT(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)}})},oS),e.Texture2DDecoder=h$([dG("Texture2D")],e.Texture2DDecoder);var dq=((ow=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},ow.parseEntity=function(e,t){return ow.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})},ow.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 lQ(t,e.name))},ow.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=dj(uz.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},ow.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)},ow.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})},ow.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)})},ow._isClass=function(e){return void 0!=e.class},ow._isRef=function(e){return void 0!=e.refId},ow);dq.customParseComponentHandles=new Map;var dY=((oA=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)}},oA),dQ={Transform:lq,Animator:hs,DirectLight:c_,Camera:e.Camera,MeshRenderer:c3,ParticleRenderer:hg,PointLight:cf,SpotLight:cp,Script:uS,SpriteMask:cK,SpriteRenderer:uJ,TextRenderer:u0};e.InterpolableValueType=void 0,(oE=e.InterpolableValueType||(e.InterpolableValueType={}))[oE.Float=0]="Float",oE[oE.FloatArray=1]="FloatArray",oE[oE.Vector2=2]="Vector2",oE[oE.Vector3=3]="Vector3",oE[oE.Vector4=4]="Vector4",oE[oE.Quaternion=5]="Quaternion",oE[oE.Color=6]="Color",oE[oE.Array=7]="Array",oE[oE.Boolean=8]="Boolean",e.AnimationClipDecoder=((oM=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new he(r),a=n.nextUint16(),o=0;o<a;++o){var s=new u9;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=dQ[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 h_;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 h_;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 h_;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 w=0;w<p;++w){var A=new h_;A.time=n.nextFloat32(),A.value=new s0(n.nextFloat32(),n.nextFloat32()),A.inTangent=new s0(n.nextFloat32(),n.nextFloat32()),A.outTangent=new s0(n.nextFloat32(),n.nextFloat32()),_.addKey(A)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var E=0;E<p;++E){var M=new h_;M.time=n.nextFloat32(),M.value=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var b=new h_;b.time=n.nextFloat32(),b.value=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(b);break;case"AnimationColorCurve":(_=_||new e.AnimationColorCurve).interpolation=f;for(var R=0;R<p;++R){var F=new h_;F.time=n.nextFloat32(),F.value=new s2(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(F)}break;case"AnimationQuaternionCurve":(_=_||new e.AnimationQuaternionCurve).interpolation=f;for(var P=0;P<p;++P){var L=new h_;L.time=n.nextFloat32(),L.value=new sJ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(u,h,d,_)}t(i)})},oM),e.AnimationClipDecoder=h$([dG("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(ob=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",ob.Custom="Custom";var dJ=((oR=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},oR),dZ=((oP=(oF=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)},oP._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),dq.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})},oP._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=h9(a);!(e=o()).done;){var s=e.value;dY.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])},oP._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(uz.getClass(c))),u=u||o.addComponent(uz.getClass(c));var h=dq.parsePropsAndMethods(u,l,o.engine);n.push(h)}return Promise.all(n)},oP._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oF.parse=function(e,t){var n=new um(e),r=new dJ(t,n),i=new oF(r);return i.start(),i.promise},oF);function d$(e,t){var n=dH.decode(e),r=new dz(e,n.headerLength,n.dataLength);return dk[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(hZ(oL=function(){return uz.apply(this,arguments)},uz),oL.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){d$(e,t.engine).then(function(e){r(e)})})})},oL),e.MeshLoader=h$([lF("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(hZ(oD=function(){return uz.apply(this,arguments)},uz),oD.prototype.load=function(e,t){var n=this;return new lb(function(r){n.request(e.url,{type:"arraybuffer"}).then(function(e){d$(e,t.engine).then(function(e){r(e)})})})},oD),e.EditorTextureLoader=h$([lF("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var d0=(hZ(oI=function(){return uz.apply(this,arguments)},uz),oI.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){return d$(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oI);d0=h$([lF(e.AssetType.Mesh,["mesh"])],d0);var d1=(hZ(oB=function(){return uz.apply(this,arguments)},uz),(oN=oB.prototype).load=function(e,t){var n=this;return new lb(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new lM(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},oN._registerFont=function(e,t){return h5(function(){var n;return h0(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);d1=h$([lF(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],d1);var d2=(hZ(oV=function(){var e;return e=uz.apply(this,arguments)||this,e._tempRect=new s3,e._tempVec2=new s0,e._tempVec4=new s1,e},uz),(oO=oV.prototype).load=function(t,n){var r=this;return new lb(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,hQ({},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 uj(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:lG.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);lb.all(l).then(function(){i(m)}).catch(a)}).catch(a)})},oO._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new uq(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},oV);d2=h$([lF(e.AssetType.SpriteAtlas,["atlas"],!1)],d2);var d3=(hZ(oU=function(){return uz.apply(this,arguments)},uz),oU.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},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 uq(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new uq(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},oU);d3=h$([lF(e.AssetType.Sprite,["sprite"],!1)],d3);var d4=(hZ(oz=function(e,t,n){var r;return(r=lh.call(this,e)||this).url=t,r.requestConfig=n,r},lh),oz.prototype.restoreContent=function(){var e=this;return uN(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},oz),d5=(hZ(ok=function(){return uz.apply(this,arguments)},uz),ok.prototype.load=function(e,t){var n=this;return new lb(function(r,i){var a=e.url,o=hQ({},e,{type:"image"});n.request(a,o).then(function(n){var i=e.params,s=new lT(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 d4(s,a,o)),r(s)}).catch(function(e){i(e)})})},ok);d5=h$([lF(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],d5);var d8=(hZ(oG=function(e,t,n){var r;return(r=lh.call(this,e)||this).urls=t,r.requestConfig=n,r},lh),oG.prototype.restoreContent=function(){var t=this;return new lb(function(n,r){Promise.all(t.urls.map(function(e){return uN(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)})})},oG),d6=(hZ(oH=function(){return uz.apply(this,arguments)},uz),oH.prototype.load=function(t,n){var r=this;return new lb(function(i,a){var o=t.urls,s=hQ({},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 lS(n.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),n.addContentRestorer(new d8(l,o,s)),i(l)}).catch(function(e){a(e)})})},oH);d6=h$([lF(e.AssetType.TextureCube,[""])],d6);var d7=(hZ(oW=function(){return uz.apply(this,arguments)},uz),oW.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){return d$(e,t.engine)}).catch(i)})},oW);d7=h$([lF(e.AssetType.AnimationClip,["ani"])],d7);var d9=(hZ(oX=function(){return uz.apply(this,arguments)},uz),oX.prototype.load=function(t,n){var r=this,i=n.engine;return new lb(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),dZ.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 lv.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)})},oX);d9=h$([lF(e.AssetType.Scene,["prefab"],!0)],d9),dq.registerCustomParseComponent("TextRenderer",h5(function(e,t,n){var r;return h0(this,function(i){return(r=t.props).font||(e.font=lM.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var _e=(hZ(oK=function(){return df.apply(this,arguments)},df),(oj=oK.prototype).initialize=function(){_e._decoder||(_e._decoder=new hY)},oj.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]=dd.getComponentType(g.componentType).name}var m=c[n.indices],v=dd.getComponentType(m.componentType).name,y=dd.getBufferViewData(l[u],o);return _e._decoder.decode(y,{attributeIDs:d,attributeTypes:_,useUniqueIDs:!0,indexType:v}).then(function(t){var o=new c1(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)})},oj._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=dd.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=_e._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),sW.min(y,v,y),sW.max(x,v,x)}}for(var w in c)if("POSITION"!==w){var A=i(w);switch(w){case"NORMAL":var E=dd.floatBufferToVector3Array(A);e.setNormals(E);break;case"TEXCOORD_0":var M=dd.floatBufferToVector2Array(A);e.setUVs(M,0);break;case"TEXCOORD_1":var b=dd.floatBufferToVector2Array(A);e.setUVs(b,1);break;case"TEXCOORD_2":var R=dd.floatBufferToVector2Array(A);e.setUVs(R,2);break;case"TEXCOORD_3":var F=dd.floatBufferToVector2Array(A);e.setUVs(F,3);break;case"TEXCOORD_4":var P=dd.floatBufferToVector2Array(A);e.setUVs(P,4);break;case"TEXCOORD_5":var L=dd.floatBufferToVector2Array(A);e.setUVs(L,5);break;case"TEXCOORD_6":var D=dd.floatBufferToVector2Array(A);e.setUVs(D,6);break;case"TEXCOORD_7":var I=dd.floatBufferToVector2Array(A);e.setUVs(I,7);break;case"COLOR_0":var B=dd.floatBufferToColorArray(A,_[c.COLOR_0].type===sD.VEC3);e.setColors(B);break;case"TANGENT":var N=dd.floatBufferToVector4Array(A);e.setTangents(N);break;case"JOINTS_0":var V=dd.floatBufferToVector4Array(A);e.setBoneIndices(V);break;case"WEIGHTS_0":var O=dd.floatBufferToVector4Array(A);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&&dC._createBlendShape(e,null,t,u,a),e.uploadData(!s),Promise.resolve(e)},oK._tempVector3=new sW,oK);_e=h$([dg("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],_e);var _t=(hZ(oq=function(){return df.apply(this,arguments)},df),oq.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(c_):"point"===s?r=t.addComponent(cf):"spot"===s&&(r=t.addComponent(cp)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!dT(r,c_)&&(r.distance=l),c&&dT(r,cp)){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)},oq);_t=h$([dg("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],_t);var _n=(hZ(oY=function(){return df.apply(this,arguments)},df),oY.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],dx._checkOtherTextureTransform(a,"Clear coat")),s&&(t.clearCoatRoughnessTexture=r[s.index],dx._checkOtherTextureTransform(s,"Clear coat roughness")),l&&(t.clearCoatNormalTexture=r[l.index],dx._checkOtherTextureTransform(l,"Clear coat normal"))},oY);_n=h$([dg("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],_n);var _r=(hZ(oQ=function(){return df.apply(this,arguments)},df),oQ.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},oQ);_r=h$([dg("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],_r);var _i=(hZ(oJ=function(){return df.apply(this,arguments)},df),oJ.prototype.createAndParse=function(e,t,n){var r=e.glTFResource,i=r.engine,a=r.textures,o=new uX(i),s=t.diffuseFactor,l=t.diffuseTexture,c=t.specularFactor,u=t.glossinessFactor,h=t.specularGlossinessTexture;return s&&(o.baseColor=new s2(s2.linearToGammaSpace(s[0]),s2.linearToGammaSpace(s[1]),s2.linearToGammaSpace(s[2]),s[3])),l&&(o.baseTexture=a[l.index],dp.executeExtensionsAdditiveAndParse(l.extensions,e,o,l)),c&&(o.specularColor=new s2(s2.linearToGammaSpace(c[0]),s2.linearToGammaSpace(c[1]),s2.linearToGammaSpace(c[2]))),void 0!==u&&(o.glossiness=u),h&&(o.specularGlossinessTexture=a[h.index],dx._checkOtherTextureTransform(h,"Specular glossiness")),o.name=n.name,dx._parseStandardProperty(e,o,n),o},oJ);_i=h$([dg("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],_i);var _a=(hZ(oZ=function(){return df.apply(this,arguments)},df),oZ.prototype.createAndParse=function(e,t,n){var r=e.glTFResource.engine,i=new uK(r);return i.name=n.name,dx._parseStandardProperty(e,i,n),i},oZ);_a=h$([dg("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],_a);var _o=(hZ(o$=function(){return df.apply(this,arguments)},df),o$);_o=h$([dg("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],_o);var _s=(hZ(o0=function(){return df.apply(this,arguments)},df),o0.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&&lv.warn("rotation in KHR_texture_transform is not supported now"),o&&lv.warn("texCoord in KHR_texture_transform is not supported now")},o0);_s=h$([dg("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],_s);var _l=(hZ(o1=function(){return df.apply(this,arguments)},df),o1.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},o1);_l=h$([dg("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],_l);var _c=(hZ(o2=function(){return df.apply(this,arguments)},df),o2.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new u9;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},o2);_c=h$([dg("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],_c);var _u="1.0.0-beta.13";for(var _h in console.log("Galacean engine version: "+_u),hA)uz.registerClass(_h,hA[_h]);e.AmbientLight=ug,e.AnimationClip=he,e.AnimationClipCurveBinding=u7,e.AnimationCurve=ht,e.AnimationEvent=u9,e.Animator=hs,e.AnimatorController=hl,e.AnimatorControllerLayer=hc,e.AnimatorState=hh,e.AnimatorStateMachine=hd,e.AnimatorStateTransition=hr,e.AssetPromise=lb,e.Background=up,e.BaseMaterial=uk,e.Basic2DBatcher=ul,e.BasicRenderPipeline=uL,e.BlendShape=us,e.BlendShapeFrame=uo,e.BlendState=cT,e.BlinnPhongMaterial=uG,e.BoolUpdateFlag=lK,e.BoundingBox=sK,e.BoundingFrustum=sY,e.BoundingSphere=sX,e.BoxColliderShape=l5,e.Buffer=cY,e.BufferMesh=ua,e.BufferUtil=cj,e.CapsuleColliderShape=l7,e.CharacterController=l3,e.CloneManager=ll,e.ColliderShape=l4,e.CollisionUtil=sj,e.Color=s2,e.Component=lU,e.ComponentMap=dQ,e.ContentRestorer=lh,e.CubeProbe=hw,e.DepthState=cC,e.DirectLight=c_,e.DynamicCollider=co,e.Engine=uC,e.EngineObject=lc,e.Entity=lQ,e.EventDispatcher=lI,e.FixedJoint=ce,e.Font=lM,e.GLTFAnimationParser=dm,e.GLTFBufferParser=dv,e.GLTFEntityParser=dy,e.GLTFExtensionParser=df,e.GLTFMaterialParser=dx,e.GLTFMeshParser=dC,e.GLTFParser=dp,e.GLTFParserContext=dc,e.GLTFPipeline=dM,e.GLTFResource=db,e.GLTFSceneParser=dS,e.GLTFSkinParser=dw,e.GLTFTextureParser=dA,e.GLTFUtils=dd,e.GLTFValidator=dE,e.HingeJoint=ct,e.HitResult=l0,e.IndexBufferBinding=cQ,e.InputManager=ch,e.JointLimits=cr,e.JointMotor=ci,e.Keyframe=h_,e.Light=cd,e.Loader=uz,e.Logger=lv,e.Material=cE,e.MathUtil=sH,e.Matrix=sZ,e.Matrix3x3=sQ,e.Mesh=cZ,e.MeshRenderer=c3,e.ModelMesh=c1,e.PBRBaseMaterial=uH,e.PBRMaterial=uW,e.PBRSpecularMaterial=uX,e.ParticleRenderer=hg,e.PhysicsManager=l1,e.PhysicsMaterial=l2,e.Plane=sq,e.PlaneColliderShape=l6,e.PointLight=cf,e.Pointer=lJ,e.PrefabParser=dY,e.PrimitiveMesh=ui,e.Probe=hx,e.Quaternion=sJ,e.RasterState=cS,e.Ray=s$,e.Rect=s3,e.ReferResource=lu,e.ReflectionParser=dq,e.RenderPass=uP,e.RenderQueue=uA,e.RenderState=cA,e.RenderTarget=lx,e.RenderTargetBlendState=cx,e.ResourceManager=lR,e.Scene=um,e.SceneManager=uv,e.SceneParser=dZ,e.Script=uS,e.Shader=cz,e.ShaderData=cy,e.ShaderFactory=cL,e.ShaderMacro=cm,e.ShaderMacroCollection=cv,e.ShaderPass=cO,e.ShaderProperty=lB,e.ShaderTagKey=cD,e.Skin=c2,e.SkinnedMeshRenderer=c4,e.Sky=uf,e.SkyBoxMaterial=hf,e.SkyProceduralMaterial=hp,e.SphereColliderShape=l8,e.SphericalHarmonics3=s4,e.SpotLight=cp,e.SpringJoint=cn,e.Sprite=uq,e.SpriteAtlas=uj,e.SpriteMask=cK,e.SpriteRenderer=uJ,e.StateMachineScript=hu,e.StaticCollider=ca,e.StencilState=cw,e.SubMesh=cJ,e.SubShader=cU,e.SystemInfo=lZ,e.TextRenderer=u0,e.TextUtils=lA,e.Texture=ly,e.Texture2D=lT,e.Texture2DArray=lC,e.TextureCube=lS,e.Time=lN,e.TrailMaterial=hm,e.TrailRenderer=hy,e.Transform=lq,e.UnlitMaterial=uK,e.Utils=lG,e.Vector2=s0,e.Vector3=sW,e.Vector4=s1,e.VertexBufferBinding=c$,e.VertexElement=cq,e.WebCanvas=hR,e.WebGLEngine=hL,e.WebGLGraphicDevice=hW,e.assignmentClone=la,e.decode=d$,e.deepClone=ls,e.dependentComponents=lk,e.ignoreClone=li,e.parseSingleKTX=dI,e.registerGLTFExtension=dg,e.request=uN,e.resourceLoader=lF,e.shallowClone=lo,e.version=_u,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,(o3=e.ContainmentType||(e.ContainmentType={}))[o3.Disjoint=0]="Disjoint",o3[o3.Contains=1]="Contains",o3[o3.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(o4=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[o4.Back=0]="Back",o4[o4.Front=1]="Front",o4[o4.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(o5=e.FrustumFace||(e.FrustumFace={}))[o5.Near=0]="Near",o5[o5.Far=1]="Far",o5[o5.Left=2]="Left",o5[o5.Right=3]="Right",o5[o5.Bottom=4]="Bottom",o5[o5.Top=5]="Top";var i,a,o,s,l,c,u,h,d,_,f,p,g,m,v,y,x,T,C,S,w,A,E,M,b,R,F,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,ew,eA,eE,eM,eb,eR,eF,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,tw,tA,tE,tM,tb,tR,tF,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,nw,nA,nE,nM,nb,nR,nF,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,rw,rA,rE,rM,rb,rR,rF,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,iw,iA,iE,iM,ib,iR,iF,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,aw,aA,aE,aM,ab,aR,aF,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,ow,oA,oE,oM,ob,oR,oF,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,sw,sA,sE,sM,sb,sR,sF,sP,sL,sD,sI,sB,sN,sV,sO,sU,sz,sk,sG,sH=((o8=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},o8.equals=function(e,t){return Math.abs(e-t)<=o8.zeroTolerance},o8.isPowerOf2=function(e){return(e&e-1)==0},o8.radianToDegree=function(e){return e*o8.radToDegreeFactor},o8.degreeToRadian=function(e){return e*o8.degreeToRadFactor},o8);sH.zeroTolerance=1e-6,sH.radToDegreeFactor=180/Math.PI,sH.degreeToRadFactor=Math.PI/180;var sW=((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 sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.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>sH.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);sW._zero=new sW(0,0,0),sW._one=new sW(1,1,1);var sX=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sW,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)sW.add(e[i],r,r);sW.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sW.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=sW.distance(n,i)},o);sX._tempVec30=new sW;var sK=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sW,this.max=new sW,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sW.add(this.min,this.max,e),sW.scale(e,.5,e),e},c.getExtent=function(e){return sW.subtract(this.max,this.min,e),sW.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 sW;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){sW.subtract(e,t,n.min),sW.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];sW.min(n,o,n),sW.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),sW.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]),sW.subtract(r,i,n.min),sW.add(r,i,n.max)},l.merge=function(e,t,n){return sW.min(e.min,t.min,n.min),sW.max(e.max,t.max,n.max),n},l);sK._tempVec30=new sW,sK._tempVec31=new sW;var sj=((u=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sW.cross(a,o,u._tempVec30),sW.cross(o,i,u._tempVec31),sW.cross(i,a,u._tempVec32);var s=-sW.dot(i,u._tempVec30),l=-sW.dot(a,u._tempVec31),c=-sW.dot(o,u._tempVec32);sW.scale(u._tempVec30,e.distance/s,u._tempVec30),sW.scale(u._tempVec31,t.distance/l,u._tempVec31),sW.scale(u._tempVec32,n.distance/c,u._tempVec32),sW.add(u._tempVec30,u._tempVec31,r),sW.add(r,u._tempVec32,r)},u.distancePlaneAndPoint=function(e,t){return sW.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=sH.zeroTolerance,i=sW.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sW.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=sH.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,w=(a.z-d)*S,A=(o.z-d)*S;if(w>A){var E=w;w=A,A=E}if((_=Math.max(w,_))>(f=Math.min(A,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;sW.subtract(n,i,o);var s=sW.dot(o,r),l=sW.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 sW.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))),sW.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),sW.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)<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.far,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.left,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.right,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.top,n))<sH.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.bottom,n))<sH.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);sj._tempVec30=new sW,sj._tempVec31=new sW,sj._tempVec32=new sW;var sq=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sW,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();sW.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),sY=((f=(_=function(e){void 0===e&&(e=null),this.near=new sq,this.far=new sq,this.left=new sq,this.right=new sq,this.top=new sq,this.bottom=new sq,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 sj.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return sj.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},_),sQ=((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 sH.equals(n[0],r[0])&&sH.equals(n[1],r[1])&&sH.equals(n[2],r[2])&&sH.equals(n[3],r[3])&&sH.equals(n[4],r[4])&&sH.equals(n[5],r[5])&&sH.equals(n[6],r[6])&&sH.equals(n[7],r[7])&&sH.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,w=a*h-s*c,A=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,R=_*v-f*m,F=_*y-p*m,P=f*y-p*v,L=x*P-T*F+C*R+S*b-w*M+A*E;if(!L)return null;L=1/L,r[0]=(c*P-u*F+h*R)*L,r[1]=(u*b-l*P-h*M)*L,r[2]=(l*F-c*b+h*E)*L,r[3]=(o*F-a*P-s*R)*L,r[4]=(i*P-o*b+s*M)*L,r[5]=(a*b-i*F-s*E)*L,r[6]=(m*A-v*w+y*S)*L,r[7]=(v*C-g*A-y*T)*L,r[8]=(g*w-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),sJ=((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<sH.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 sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.equals(e._z,t._z)&&sH.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sW.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>sH.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-sH.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>sH.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)<sH.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);sJ._tempVector3=new sW,sJ._tempQuat1=new sJ;var sZ=((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)<sH.zeroTolerance||Math.abs(x)<sH.zeroTolerance||Math.abs(T)<sH.zeroTolerance)return t.identity(),!1;var C=1/v,S=1/x,w=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*w,a[7]=p*w,a[8]=g*w,sJ.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>sH.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],w=i[2],A=i[3],E=i[4],M=i[5],b=i[6],R=i[7],F=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*w+v*A,a[1]=s*C+h*S+p*w+y*A,a[2]=l*C+d*S+g*w+x*A,a[3]=c*C+_*S+m*w+T*A,a[4]=o*E+u*M+f*b+v*R,a[5]=s*E+h*M+p*b+y*R,a[6]=l*E+d*M+g*b+x*R,a[7]=c*E+_*M+m*b+T*R,a[8]=o*F+u*P+f*L+v*D,a[9]=s*F+h*P+p*L+y*D,a[10]=l*F+d*P+g*L+x*D,a[11]=c*F+_*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 sH.equals(n[0],r[0])&&sH.equals(n[1],r[1])&&sH.equals(n[2],r[2])&&sH.equals(n[3],r[3])&&sH.equals(n[4],r[4])&&sH.equals(n[5],r[5])&&sH.equals(n[6],r[6])&&sH.equals(n[7],r[7])&&sH.equals(n[8],r[8])&&sH.equals(n[9],r[9])&&sH.equals(n[10],r[10])&&sH.equals(n[11],r[11])&&sH.equals(n[12],r[12])&&sH.equals(n[13],r[13])&&sH.equals(n[14],r[14])&&sH.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)<sH.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,w=a*h-s*c,A=o*h-s*u,E=d*m-_*g,M=d*v-f*g,b=d*y-p*g,R=_*v-f*m,F=_*y-p*m,P=f*y-p*v,L=x*P-T*F+C*R+S*b-w*M+A*E;if(!L)return null;L=1/L,r[0]=(c*P-u*F+h*R)*L,r[1]=(o*F-a*P-s*R)*L,r[2]=(m*A-v*w+y*S)*L,r[3]=(f*w-_*A-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*A-y*T)*L,r[7]=(d*A-f*C+p*T)*L,r[8]=(l*F-c*b+h*E)*L,r[9]=(a*b-i*F-s*E)*L,r[10]=(g*w-m*C+y*x)*L,r[11]=(_*C-d*w-p*x)*L,r[12]=(c*M-l*R-u*E)*L,r[13]=(i*R-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;sW.subtract(e,t,s),s.normalize(),sW.cross(n,s,a),a.normalize(),sW.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]=-sW.dot(a,e),i[13]=-sW.dot(o,e),i[14]=-sW.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)<sH.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],w=h[11],A=s*s*o+a,E=l*s*o+c*i,M=c*s*o-l*i,b=s*l*o-c*i,R=l*l*o+a,F=c*l*o+s*i,P=s*c*o+l*i,L=l*c*o-s*i,D=c*c*o+a;d[0]=_*A+m*E+T*M,d[1]=f*A+v*E+C*M,d[2]=p*A+y*E+S*M,d[3]=g*A+x*E+w*M,d[4]=_*b+m*R+T*F,d[5]=f*b+v*R+C*F,d[6]=p*b+y*R+S*F,d[7]=g*b+x*R+w*F,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+w*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);sZ._tempVec30=new sW,sZ._tempVec31=new sW,sZ._tempVec32=new sW,sZ._tempMat30=new sQ,sZ._identity=new sZ(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var s$=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sW,this.direction=new sW,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return sj.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return sj.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return sj.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return sW.scale(this.direction,e,t),t.add(this.origin)},T),s0=((w=(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},w.add=function(e){return this._x+=e._x,this._y+=e._y,this._onValueChanged&&this._onValueChanged(),this},w.subtract=function(e){return this._x-=e._x,this._y-=e._y,this._onValueChanged&&this._onValueChanged(),this},w.multiply=function(e){return this._x*=e._x,this._y*=e._y,this._onValueChanged&&this._onValueChanged(),this},w.divide=function(e){return this._x/=e._x,this._y/=e._y,this._onValueChanged&&this._onValueChanged(),this},w.length=function(){var e=this._x,t=this._y;return Math.sqrt(e*e+t*t)},w.lengthSquared=function(){var e=this._x,t=this._y;return e*e+t*t},w.negate=function(){return this._x=-this._x,this._y=-this._y,this._onValueChanged&&this._onValueChanged(),this},w.normalize=function(){return S.normalize(this,this),this},w.scale=function(e){return this._x*=e,this._y*=e,this._onValueChanged&&this._onValueChanged(),this},w.clone=function(){return new S(this._x,this._y)},w.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._onValueChanged&&this._onValueChanged(),this},w.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._onValueChanged&&this._onValueChanged(),this},w.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y},w.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 sH.equals(e._x,t._x)&&sH.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>sH.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);s0._zero=new s0(0,0),s0._one=new s0(1,1);var s1=((E=(A=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 A.normalize(this,this),this},E.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},E.clone=function(){return new A(this._x,this._y,this._z,this._w)},E.copyFrom=function(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onValueChanged&&this._onValueChanged(),this},E.copyFromArray=function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onValueChanged&&this._onValueChanged(),this},E.copyToArray=function(e,t){void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w},E.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},A.add=function(e,t,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()},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._w=e._w-t._w,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._w=e._w*t._w,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._w=e._w/t._w,n._onValueChanged&&n._onValueChanged()},A.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},A.distance=function(e,t){var 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)},A.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},A.equals=function(e,t){return sH.equals(e._x,t._x)&&sH.equals(e._y,t._y)&&sH.equals(e._z,t._z)&&sH.equals(e._w,t._w)},A.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()},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._w=Math.max(e._w,t._w),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._w=Math.min(e._w,t._w),n._onValueChanged&&n._onValueChanged()},A.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},A.normalize=function(e,t){var n=e._x,r=e._y,i=e._z,a=e._w,o=Math.sqrt(n*n+r*r+i*i+a*a);o>sH.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},A.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()},A.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()},A.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(A,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"z",get:function(){return this._z},set:function(e){this._z=e,this._onValueChanged&&this._onValueChanged()}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),A);s1._zero=new s1(0,0,0,0),s1._one=new s1(1,1,1,1);var s2=((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 sH.equals(e._r,t._r)&&sH.equals(e._g,t._g)&&sH.equals(e._b,t._b)&&sH.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),s3=((F=(R=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},F.clone=function(){return new R(this.x,this.y,this.width,this.height)},F.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this},R),s4=((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 s5(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s8(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s6(e,t,n){return t&&s8(e.prototype,t),n&&s8(e,n),e}function s7(e,t){return(s7=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s9(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&&s7(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 le=((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);le.zeroTolerance=1e-6,le.radToDegreeFactor=180/Math.PI,le.degreeToRadFactor=Math.PI/180;var lt=((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 le.equals(e._r,t._r)&&le.equals(e._g,t._g)&&le.equals(e._b,t._b)&&le.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},s6(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 ln(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 lr(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function li(e,t){ll.registerCloneMode(e,t,o6.Ignore)}function la(e,t){ll.registerCloneMode(e,t,o6.Assignment)}function lo(e,t){ll.registerCloneMode(e,t,o6.Shallow)}function ls(e,t){ll.registerCloneMode(e,t,o6.Deep)}(V=o6||(o6={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var ll=((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(lr(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);ll._subCloneModeMap=new Map,ll._cloneModeMap=new Map,ll._objectType=Object.getPrototypeOf(Object);var lc=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)},s6(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();lc._instanceIdCounter=0,ln([li],lc.prototype,"instanceId",void 0),ln([li],lc.prototype,"_engine",void 0);var lu=(s9(U=function(e){var t;return(t=lc.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(s5(t)),t},lc),(z=U.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(lc.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(){lc.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},s6(U,[{key:"refCount",get:function(){return this._refCount}}]),U),lh=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.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 ld=(s9(q=function(e){var t;return t=lu.call(this,e)||this,e.resourceManager._addGraphicResource(s5(t)),t},lu),q.prototype._onDestroy=function(){lu.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},q),l_=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},lf=console.log.bind(console),lp=console.info.bind(console),lg=console.warn.bind(console),lm=console.error.bind(console),lv={debug:l_,info:l_,warn:l_,error:l_,isEnabled:!1,enable:function(){this.debug=lf,this.info=lp,this.warn=lg,this.error=lm,this.isEnabled=!0},disable:function(){this.debug=l_,this.info=l_,this.warn=l_,this.error=l_,this.isEnabled=!1}},ly=(s9(Y=function(){var e;return e=ld.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},ld),(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(){ld.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},s6(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&&(lv.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(lv.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),lx=(s9(J=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=ld.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=lr(i,Array)?i.slice():[i],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(lr(a,ly)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(s5(s)),s},ld),(Z=J.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},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(){ld.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)},s6(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),lT=(s9($=function(t,n,r,i,a,o){var s;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),void 0===o&&(o=e.TextureUsage.Static),(s=ly.call(this,t)||this)._mipmap=a,s._width=n,s._height=r,s._usage=o,s._format=i,s._mipmapCount=s._getMipmapCount(),s._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,s._platformTexture=t._hardwareRenderer.createPlatformTexture2D(s5(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},ly),(ee=$.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)},ee.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)},ee.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)},ee._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2D(this),ly.prototype._rebuild.call(this)},$),lC=(s9(et=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=ly.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(s5(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},ly),(en=et.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)},en.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)},en.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)},en._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTexture2DArray(this),ly.prototype._rebuild.call(this)},s6(et,[{key:"length",get:function(){return this._length}}]),et),lS=(s9(er=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=ly.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(s5(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},ly),(ei=er.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)},ei.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)},ei.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)},ei._rebuild=function(){this._platformTexture=this._engine._hardwareRenderer.createPlatformTextureCube(this),ly.prototype._rebuild.call(this)},er),lw=(s9(ea=function(e){var t;return(t=lu.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},lu),(eo=ea.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 s0(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},eo.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},eo.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},eo._onDestroy=function(){lu.prototype._onDestroy.call(this),this.texture.destroy(),this.texture=null,this._charInfoMap={}},ea);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 lA=((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 i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},ec.measureChar=function(e,t){return ec._measureFontOrChar(t,e)},ec.measureTextWithWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=ec.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=[],s=[],l=[],c=uC._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,w=!1,A=0,E=p.length;A<E;++A){var M=p[A],b=ec._getCharInfo(M,r,n),R=M.charCodeAt(0),F=32===R;if(!F||!w||0!==x.length||0!==g.length){var P=F||R>=19968&&R<=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),w=!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),w=!0,F?(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),w=!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}},ec.measureTextWithoutWrap=function(t){var n=t._subFont,r=n.nativeFontString,i=ec.measureFont(r),a=t.text.split(/(?:\r\n|\r|\n)/),o=a.length,s=[],l=[],c=uC._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=ec._getCharInfo(f[v],r,n);p+=x.xAdvance;var T=x.offsetY,C=.5*x.h,S=C+T,w=C-T;g<S&&(g=S),m<w&&(m=w)}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}},ec.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=ec._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},ec._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=ec.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||ec._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(ec._measureBaseline).width),c=l*ec._heightMultiplier;l=ec._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 s0,new s0,new s0,new s0],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,i,a,o){e.push(r),t.push(i),n.push({ascent:a,descent:o,size:a+o})},ec);lA._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],lA._measureString="|\xc9q\xc5",lA._measureBaseline="M",lA._heightMultiplier=2,lA._baselineMultiplier=1.4,lA._fontSizeInfoCache={},lA._textContext=null;var lE=((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 i=t[n].getCharInfo(e);if(i)return i}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 lw(t),r=new lT(t,256,256);n.texture=r,n.isGCIgnored=r.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return t.resourceManager.addContentRestorer(new(s9(e=function(){return lh.call(this,n)},lh),e.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var r in t){var a=t[r],o=lA.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},eu),lM=(s9(ed=function(e,t){var n;return void 0===t&&(t=""),(n=lu.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},lu),(e_=ed.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new lE(this.engine),r[n]=i),i},e_._onDestroy=function(){lu.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},s6(ed,[{key:"name",get:function(){return this._name}}]),ed),lb=((ep=(ef=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},ep.then=function(e,t){var n=this;return new ef(function(r,i){n._promise.then(e,t).then(r).catch(i)})},ep.catch=function(e){var t=this;return new ef(function(n,r){t._promise.catch(e).then(n).catch(r)})},ep.finally=function(e){return this._promise.finally(e)},ep.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},ef.all=function(e){return new ef(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){lr(e,Promise)||lr(e,ef)?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)})},s6(ef,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),ef);(eg=o7||(o7={})).Pending="pending",eg.Fulfilled="fulfilled",eg.Rejected="rejected",eg.Canceled="canceled";var lR=((ev=(em=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 lb.all(n)},ev.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},ev.getAssetPath=function(e){return this._assetPool[e]},ev.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()}):lG.objectValues(this._loadingPromises).forEach(function(e){e.cancel()})},ev.gc=function(){this._gc(!1),this.engine._pendingGC()},ev.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},ev._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},ev._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},ev._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},ev._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},ev._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},ev._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},ev._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},ev._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},ev._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)},ev._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},ev._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:em._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},ev._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 lb(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 lb(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=em._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(lr(f,lb))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)})},ev._gc=function(e){for(var t=lG.objectValues(this._referResourcePool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},ev._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},ev._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},ev._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},ev._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===lP&&t.push(""),e.replace(lD,function(e,n,r,i){var a=e;r?a=i.replace(lL,"$1"):n&&(a=n.trim()),t.push(a)}),t},ev.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 lv.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})},ev.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},em._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},em._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},em);function lF(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);lR._addLoader(e,i,t)}}lR._loaders={},lR._extTypeMapping={};var lP=46,lL=/\\(\\)?/g,lD=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lI=((ex=(ey=function(){this._events=Object.create(null),this._eventCount=0,this._dispatchingListeners=[]}).prototype).hasEvent=function(e){return null!=this._events[e]},ex.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ex.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ex.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},ex.on=function(e,t){return this._addEventListener(e,t)},ex.once=function(e,t){return this._addEventListener(e,t,!0)},ex.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},ex.removeEventListener=function(e,t){return this.off(e,t)},ex.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ex._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},ex._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},ey),lB=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},s6(e,[{key:"type",get:function(){return this._type}}]),e}();lB._propertyIdMap=Object.create(null),lB._propertyNameCounter=0,lB._propertyNameMap=Object.create(null);var lN=((eC=(eT=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new s1,this._deltaTimeValue=new s1,this.maximumDeltaTime=.333333,this.timeScale=1,this._lastSystemTime=performance.now()/1e3}).prototype)._reset=function(){this._lastSystemTime=performance.now()/1e3},eC._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},eC._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(eT._elapsedTimeProperty,t),n.set(this._deltaTime,0,0,0),e.setVector4(eT._deltaTimeProperty,n)},s6(eT,[{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}}]),eT);lN._elapsedTimeProperty=lB.getByName("scene_ElapsedTime"),lN._deltaTimeProperty=lB.getByName("scene_DeltaTime"),e.DataType=void 0,(eS=e.DataType||(e.DataType={}))[eS.FLOAT=5126]="FLOAT",eS[eS.FLOAT_VEC2=35664]="FLOAT_VEC2",eS[eS.FLOAT_VEC3=35665]="FLOAT_VEC3",eS[eS.FLOAT_VEC4=35666]="FLOAT_VEC4",eS[eS.INT=5124]="INT",eS[eS.INT_VEC2=35667]="INT_VEC2",eS[eS.INT_VEC3=35668]="INT_VEC3",eS[eS.INT_VEC4=35669]="INT_VEC4",eS[eS.BOOL=35670]="BOOL",eS[eS.BOOL_VEC2=35671]="BOOL_VEC2",eS[eS.BOOL_VEC3=35672]="BOOL_VEC3",eS[eS.BOOL_VEC4=35673]="BOOL_VEC4",eS[eS.FLOAT_MAT2=35674]="FLOAT_MAT2",eS[eS.FLOAT_MAT3=35675]="FLOAT_MAT3",eS[eS.FLOAT_MAT4=35676]="FLOAT_MAT4",eS[eS.FLOAT_ARRAY=35677]="FLOAT_ARRAY",eS[eS.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",eS[eS.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",eS[eS.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",eS[eS.INT_ARRAY=100003]="INT_ARRAY",eS[eS.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",eS[eS.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",eS[eS.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",eS[eS.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",eS[eS.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",eS[eS.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",eS[eS.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",eS[eS.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",eS[eS.SAMPLER_2D=35678]="SAMPLER_2D",eS[eS.SAMPLER_CUBE=35680]="SAMPLER_CUBE",eS[eS.BYTE=5120]="BYTE",eS[eS.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",eS[eS.SHORT=5122]="SHORT",eS[eS.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",eS[eS.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(ew=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",ew.standardDerivatives="OES_standard_derivatives",ew.shaderTextureLod="EXT_shader_texture_lod",ew.elementIndexUint="OES_element_index_uint",ew.depthTexture="WEBGL_depth_texture",ew.drawBuffers="WEBGL_draw_buffers",ew.vertexArrayObject="OES_vertex_array_object",ew.instancedArrays="ANGLE_instanced_arrays",ew.multipleSample="multipleSampleOnlySupportedInWebGL2",ew.textureFloat="OES_texture_float",ew.textureFloatLinear="OES_texture_float_linear",ew.textureHalfFloat="OES_texture_half_float",ew.textureHalfFloatLinear="OES_texture_half_float_linear",ew.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",ew.colorBufferFloat="EXT_color_buffer_float",ew.colorBufferHalfFloat="EXT_color_buffer_half_float",ew.textureFilterAnisotropic="EXT_texture_filter_anisotropic",ew.blendMinMax="EXT_blend_minmax",ew.astc="WEBGL_compressed_texture_astc",ew.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",ew.etc="WEBGL_compressed_texture_etc",ew.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",ew.etc1="WEBGL_compressed_texture_etc1",ew.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",ew.pvrtc="WEBGL_compressed_texture_pvrtc",ew.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",ew.s3tc="WEBGL_compressed_texture_s3tc",ew.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",ew.WEBGL_lose_context="WEBGL_lose_context";var lV=((eE=(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++},eE.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(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},eA),lO=((eb=(eM=function(){this._renderers=new lV,this._onStartScripts=new lV,this._onUpdateScripts=new lV,this._onLateUpdateScripts=new lV,this._onPhysicsUpdateScripts=new lV,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new lV,this._onUpdateRenderers=new lV,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},eb.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},eb.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},eb.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},eb.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},eb.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},eb.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},eb.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},eb.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},eb.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},eb.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},eb.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eb.addDisableScript=function(e){this._disableScripts.push(e)},eb.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},eb.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}},eb.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)}},eb.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)}},eb.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()}},eb.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},eb.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},eb.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}},eb.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)}},eb.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)}},eb.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},eb.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},eb._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},eM),lU=(s9(eR=function(e){var t;return(t=lc.call(this,e.engine)||this)._awoken=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},lc),(eF=eR.prototype)._onAwake=function(){},eF._onEnable=function(){},eF._onDisable=function(){},eF._setActive=function(e){var t=this._entity;e?(!this._awoken&&t._isActiveInHierarchy&&(this._awoken=!0,this._onAwake()),!this._phasedActive&&t._isActiveInHierarchy&&this._enabled&&(this._phasedActive=!0,this._onEnable())):this._phasedActive&&!(t._isActiveInHierarchy&&this._enabled)&&(this._phasedActive=!1,this._onDisable())},eF._onDestroy=function(){lc.prototype._onDestroy.call(this),this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable()},s6(eR,[{key:"enabled",get:function(){return this._enabled},set:function(e){e!==this._enabled&&(this._enabled=e,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}}]),eR);ln([li],lU.prototype,"_entity",void 0),ln([li],lU.prototype,"_awoken",void 0),ln([li],lU.prototype,"_phasedActive",void 0),ln([la],lU.prototype,"_enabled",void 0);var lz=((eP=function(){})._addCheck=function(e,t){for(;t!==lU;){var n=eP._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)}},eP._removeCheck=function(e,t){for(;t!==lU;){var n=eP._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)}},eP._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eP._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eP);function lk(e,t){void 0===t&&(t=0);var n=Array.isArray(e)?e:[e];return function(e){lz._dependenciesMap.set(e,{mode:t,components:n}),n.forEach(function(t){return lz._addInvDependency(t,e)})}}lz._invDependenciesMap=new Map,lz._dependenciesMap=new Map,e.DependentMode=void 0,(eL=e.DependentMode||(e.DependentMode={}))[eL.CheckOnly=0]="CheckOnly",eL[eL.AutoAdd=1]="AutoAdd",e.Layer=void 0,(eD=e.Layer||(e.Layer={}))[eD.Layer0=1]="Layer0",eD[eD.Layer1=2]="Layer1",eD[eD.Layer2=4]="Layer2",eD[eD.Layer3=8]="Layer3",eD[eD.Layer4=16]="Layer4",eD[eD.Layer5=32]="Layer5",eD[eD.Layer6=64]="Layer6",eD[eD.Layer7=128]="Layer7",eD[eD.Layer8=256]="Layer8",eD[eD.Layer9=512]="Layer9",eD[eD.Layer10=1024]="Layer10",eD[eD.Layer11=2048]="Layer11",eD[eD.Layer12=4096]="Layer12",eD[eD.Layer13=8192]="Layer13",eD[eD.Layer14=16384]="Layer14",eD[eD.Layer15=32768]="Layer15",eD[eD.Layer16=65536]="Layer16",eD[eD.Layer17=131072]="Layer17",eD[eD.Layer18=262144]="Layer18",eD[eD.Layer19=524288]="Layer19",eD[eD.Layer20=1048576]="Layer20",eD[eD.Layer21=2097152]="Layer21",eD[eD.Layer22=4194304]="Layer22",eD[eD.Layer23=8388608]="Layer23",eD[eD.Layer24=16777216]="Layer24",eD[eD.Layer25=33554432]="Layer25",eD[eD.Layer26=67108864]="Layer26",eD[eD.Layer27=134217728]="Layer27",eD[eD.Layer28=268435456]="Layer28",eD[eD.Layer29=536870912]="Layer29",eD[eD.Layer30=1073741824]="Layer30",eD[eD.Layer31=2147483648]="Layer31",eD[eD.Everything=4294967295]="Everything",eD[eD.Nothing=0]="Nothing";var lG=((eI=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],w=t[n+2],A=t[n+3],E=t[n+4],M=t[n+5],b=t[n+6],R=t[n+7],F=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*w+v*A,r[i+1]=s*C+h*S+p*w+y*A,r[i+2]=l*C+d*S+g*w+x*A,r[i+3]=c*C+_*S+m*w+T*A,r[i+4]=o*E+u*M+f*b+v*R,r[i+5]=s*E+h*M+p*b+y*R,r[i+6]=l*E+d*M+g*b+x*R,r[i+7]=c*E+_*M+m*b+T*R,r[i+8]=o*F+u*P+f*L+v*D,r[i+9]=s*F+h*P+p*L+y*D,r[i+10]=l*F+d*P+g*L+x*D,r[i+11]=c*F+_*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},eI._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},eI.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},eI.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))},eI.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eI.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eI.resolveAbsoluteUrl=function(e,t){return eI.isAbsoluteUrl(t)?t:"."===t.charAt(0)?eI._formatRelativePath(t+t):e.substring(0,e.lastIndexOf("/")+1)+t},eI._stringToPath=function(e){var t=[];return e.charCodeAt(0)===lH&&t.push(""),e.replace(lX,function(e,n,r,i){var a=e;r?a=i.replace(lW,"$1"):n&&(a=n.trim()),t.push(a)}),t},eI._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("/")},eI),lH=46,lW=/\\(\\)?/g,lX=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lK=((eN=(eB=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eN.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eN._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)lG.removeFromArray(e[t]._updateFlags,this)},s9(eV=function(){var e;return e=eB.apply(this,arguments)||this,e.flag=!0,e},eB),eV.prototype.dispatch=function(){this.flag=!0},eV),lj=((eU=(eO=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eU.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eU.removeFlag=function(e){lG.removeFromArray(this._updateFlags,e)&&lG.removeFromArray(e._flagManagers,this)},eU.addListener=function(e){this._listeners.push(e)},eU.removeListener=function(e){lG.removeFromArray(this._listeners,e)},eU.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)},eO),lq=(s9(ez=function(e){var t;return(t=lU.call(this,e)||this)._position=new sW,t._rotation=new sW,t._rotationQuaternion=new sJ,t._scale=new sW(1,1,1),t._worldPosition=new sW,t._worldRotation=new sW,t._worldRotationQuaternion=new sJ,t._lossyWorldScale=new sW(1,1,1),t._localMatrix=new sZ,t._worldMatrix=new sZ,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new lj,t._onPositionChanged=t._onPositionChanged.bind(s5(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(s5(t)),t._onRotationChanged=t._onRotationChanged.bind(s5(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(s5(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(s5(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(s5(t)),t._onScaleChanged=t._onScaleChanged.bind(s5(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},lU),(ek=ez.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},ek.setRotation=function(e,t,n){this._rotation.set(e,t,n)},ek.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},ek.setScale=function(e,t,n){this._scale.set(e,t,n)},ek.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},ek.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},ek.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},ek.translate=function(e,t,n,r){if("number"==typeof e){var i=ez._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},ek.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},ek.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*sH.degreeToRadFactor;sJ.rotationAxisAngle(e,r,ez._tempQuat0),this._rotateByQuat(ez._tempQuat0,n)},ek.lookAt=function(e,t){var n=ez._tempVec30;sW.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=sH.zeroTolerance)){n.scale(1/r);var i=ez._tempVec31;if(t?sW.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=sH.zeroTolerance)){i.scale(1/r);var a=ez._tempVec32;sW.cross(n,i,a);var o=ez._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)}}},ek.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(lK)},ek._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},ek._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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()}},ek._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},ek._getScaleMatrix=function(){var e=ez._tempQuat0,t=ez._tempMat30,n=ez._tempMat31,r=ez._tempMat32;return n.copyFromMatrix(this.worldMatrix),sJ.invert(this.worldRotationQuaternion,e),sQ.rotationQuaternion(e,t),sQ.multiply(t,n,r),r},ek._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},ek._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},ek._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},ek._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},ek._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},ek._rotateByQuat=function(e,t){t?sJ.multiply(this.rotationQuaternion,e,this._rotationQuaternion):sJ.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},ek._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=ez._tempVec30;sW.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},ek._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=sH.degreeToRadFactor,a=ez._tempQuat0;sJ.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},ek._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},ek._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(sZ.invert(t.worldMatrix,ez._tempMat41),sW.transformCoordinate(e,ez._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},ek._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},ek._onWorldRotationChanged=function(){var e=this._worldRotation;sJ.rotationEuler(sH.degreeToRadian(e.x),sH.degreeToRadian(e.y),sH.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},ek._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},ek._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=ez._tempQuat0;sJ.invert(t.worldRotationQuaternion,n),sJ.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},ek._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},s6(ez,[{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(sH.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(sH.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,sJ.rotationEuler(sH.degreeToRadian(this._rotation.x),sH.degreeToRadian(this._rotation.y),sH.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):sJ.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?sJ.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):sJ.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)&&(sZ.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?sZ.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?(sZ.invert(t.worldMatrix,ez._tempMat42),sZ.multiply(ez._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 sW),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 sW),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 sW),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),ez);lq._tempQuat0=new sJ,lq._tempVec30=new sW,lq._tempVec31=new sW,lq._tempVec32=new sW,lq._tempMat30=new sQ,lq._tempMat31=new sQ,lq._tempMat32=new sQ,lq._tempMat41=new sZ,lq._tempMat42=new sZ,ln([ls],lq.prototype,"_position",void 0),ln([ls],lq.prototype,"_rotation",void 0),ln([ls],lq.prototype,"_rotationQuaternion",void 0),ln([ls],lq.prototype,"_scale",void 0),ln([ls],lq.prototype,"_worldPosition",void 0),ln([ls],lq.prototype,"_worldRotation",void 0),ln([ls],lq.prototype,"_worldRotationQuaternion",void 0),ln([ls],lq.prototype,"_lossyWorldScale",void 0),ln([ls],lq.prototype,"_localMatrix",void 0),ln([ls],lq.prototype,"_worldMatrix",void 0),ln([li],lq.prototype,"_worldForward",void 0),ln([li],lq.prototype,"_worldRight",void 0),ln([li],lq.prototype,"_worldUp",void 0),ln([li],lq.prototype,"_isParentDirty",void 0),ln([li],lq.prototype,"_parentTransformCache",void 0),ln([li],lq.prototype,"_updateFlagManager",void 0),ln([li],lq.prototype,"_onPositionChanged",null),ln([li],lq.prototype,"_onWorldPositionChanged",null),ln([li],lq.prototype,"_onRotationChanged",null),ln([li],lq.prototype,"_onWorldRotationChanged",null),ln([li],lq.prototype,"_onRotationQuaternionChanged",null),ln([li],lq.prototype,"_onWorldRotationQuaternionChanged",null),ln([li],lq.prototype,"_onScaleChanged",null),(eG=o9||(o9={}))[eG.LocalEuler=1]="LocalEuler",eG[eG.LocalQuat=2]="LocalQuat",eG[eG.WorldPosition=4]="WorldPosition",eG[eG.WorldEuler=8]="WorldEuler",eG[eG.WorldQuat=16]="WorldQuat",eG[eG.WorldScale=32]="WorldScale",eG[eG.LocalMatrix=64]="LocalMatrix",eG[eG.WorldMatrix=128]="WorldMatrix",eG[eG.WmWp=132]="WmWp",eG[eG.WmWeWq=152]="WmWeWq",eG[eG.WmWpWeWq=156]="WmWpWeWq",eG[eG.WmWs=160]="WmWs",eG[eG.WmWpWs=164]="WmWpWs",eG[eG.WmWpWeWqWs=188]="WmWpWeWqWs";var lY=((eH=function(){}).cloneComponent=function(e,t){for(var n=ll.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 o6.Assignment:t[o]=e[o];break;case o6.Shallow:var s=e[o];if(lr(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case o6.Deep:var c=e[o];if(lr(c,Object)){var u=t[o];null==u&&(u=t[o]=c.constructor()),ll.deepCloneObject(c,u)}else t[o]=c}}e._cloneTo&&e._cloneTo(t)},eH),lQ=(s9(eW=function(t,n){var r;return(r=lc.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new lV,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new sZ,r.name=n,r.transform=r.addComponent(lq),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},lc),(eX=eW.prototype).addComponent=function(e){lz._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0),t},eX.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(lr(r,e))return r}},eX.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];lr(a,e)&&t.push(a)}return t},eX.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eX.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=this._scene;t._scene!==r&&eW._traverseSetOwnerScene(t,r),this._isActiveInHierarchy?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive(),t._setTransformDirty()}else t._setParent(this,n)},eX.removeChild=function(e){e._setParent(null)},eX.getChild=function(e){return this._children[e]},eX.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},eX.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=eW._findChildByName(n,a)))return null}return n},eX.createChild=function(e){var t=new eW(this.engine,e);return t.layer=this.layer,t.parent=this,t},eX.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n._parent=null,n._isActiveInHierarchy&&n._processInActive(),eW._traverseSetOwnerScene(n,null)}e.length=0},eX.clone=function(){var e=new eW(this._engine,this.name),t=this._hookResource;t&&(e._hookResource=t,t._addReferCount(1)),e._isActive=this._isActive,e.transform.localMatrix=this.transform.localMatrix;for(var n=this._children,r=0,i=this._children.length;r<i;r++){var a=n[r];e.addChild(a.clone())}for(var o=this._components,s=0,l=o.length;s<l;s++){var c=o[s];if(!lr(c,lq)){var u=e.addComponent(c.constructor);lY.cloneComponent(c,u)}}return e},eX.destroy=function(){if(!this._destroyed){lc.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()}},eX._removeComponent=function(e){lz._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eX._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eX._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eX._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}},eX._processActive=function(){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._engine._componentsManager.getActiveChangedTempList(),this._setActiveInHierarchy(this._activeChangedComponents),this._setActiveComponents(!0)},eX._processInActive=function(){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._engine._componentsManager.getActiveChangedTempList(),this._setInActiveInHierarchy(this._activeChangedComponents),this._setActiveComponents(!1)},eX._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++}},eX._setParent=function(e,t){var n=this._parent;if(e!==n){if(this._removeFromParent(),this._parent=e,e){e._addToChildrenList(t,this);var r=e._scene;this._scene!==r&&eW._traverseSetOwnerScene(this,r),e._isActiveInHierarchy?!this._isActiveInHierarchy&&this._isActive&&this._processActive():this._isActiveInHierarchy&&this._processInActive()}else this._isActiveInHierarchy&&this._processInActive(),n&&eW._traverseSetOwnerScene(this,null);this._setTransformDirty()}},eX._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];lr(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},eX._setActiveComponents=function(e){for(var t=this._activeChangedComponents,n=0,r=t.length;n<r;++n)t[n]._setActive(e);this._engine._componentsManager.putActiveChangedTempList(t),this._activeChangedComponents=null},eX._setActiveInHierarchy=function(e){this._isActiveInHierarchy=!0;for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];(r.enabled||!r._awoken)&&e.push(r)}for(var i=this._children,a=i.length-1;a>=0;a--){var o=i[a];o.isActive&&o._setActiveInHierarchy(e)}},eX._setInActiveInHierarchy=function(e){this._isActiveInHierarchy=!1;for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];r.enabled&&e.push(r)}for(var i=this._children,a=i.length-1;a>=0;a--){var o=i[a];o.isActive&&o._setInActiveInHierarchy(e)}},eX._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eX._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}}},eX.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(sZ.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eW._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},eW._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=e.childCount-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},s6(eW,[{key:"isActive",get:function(){return this._isActive},set:function(e){if(e!==this._isActive){if(this._isActive=e,e){var t=this._parent;((null==t?void 0:t._isActiveInHierarchy)||this._isRoot&&this._scene._isActiveInEngine)&&this._processActive()}else this._isActiveInHierarchy&&this._processInActive()}}},{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)}}]),eW);e.ColorSpace=void 0,(eK=e.ColorSpace||(e.ColorSpace={}))[eK.Linear=0]="Linear",eK[eK.Gamma=1]="Gamma",e.PointerPhase=void 0,(ej=e.PointerPhase||(e.PointerPhase={}))[ej.Down=0]="Down",ej[ej.Move=1]="Move",ej[ej.Stationary=2]="Stationary",ej[ej.Up=3]="Up",ej[ej.Leave=4]="Leave";var lJ=((eY=(eq=function(t){this.phase=e.PointerPhase.Leave,this.position=new s0,this.deltaPosition=new s0,this._events=[],this._upMap=[],this._downMap=[],this._upList=new lV,this._downList=new lV,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}},eY._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},eY._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)}},eY._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}},eq),lZ=((eQ=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?eQ.platform=e.Platform.IPhone:/iPad/i.test(n)?eQ.platform=e.Platform.IPad:/Android/i.test(n)?eQ.platform=e.Platform.Android:/Macintosh/i.test(n)&&(eQ.platform=e.Platform.Mac),eQ.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"}}},s6(eQ,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),eQ);lZ.platform=e.Platform.Unknown,lZ.operatingSystem="",lZ._initialize(),e.Keys=void 0,(eJ=e.Keys||(e.Keys={}))[eJ.Backquote=0]="Backquote",eJ[eJ.Backslash=1]="Backslash",eJ[eJ.Backspace=2]="Backspace",eJ[eJ.BracketLeft=3]="BracketLeft",eJ[eJ.BracketRight=4]="BracketRight",eJ[eJ.Comma=5]="Comma",eJ[eJ.Digit0=6]="Digit0",eJ[eJ.Digit1=7]="Digit1",eJ[eJ.Digit2=8]="Digit2",eJ[eJ.Digit3=9]="Digit3",eJ[eJ.Digit4=10]="Digit4",eJ[eJ.Digit5=11]="Digit5",eJ[eJ.Digit6=12]="Digit6",eJ[eJ.Digit7=13]="Digit7",eJ[eJ.Digit8=14]="Digit8",eJ[eJ.Digit9=15]="Digit9",eJ[eJ.Equal=16]="Equal",eJ[eJ.IntlBackslash=17]="IntlBackslash",eJ[eJ.IntlRo=18]="IntlRo",eJ[eJ.IntlYen=19]="IntlYen",eJ[eJ.KeyA=20]="KeyA",eJ[eJ.KeyB=21]="KeyB",eJ[eJ.KeyC=22]="KeyC",eJ[eJ.KeyD=23]="KeyD",eJ[eJ.KeyE=24]="KeyE",eJ[eJ.KeyF=25]="KeyF",eJ[eJ.KeyG=26]="KeyG",eJ[eJ.KeyH=27]="KeyH",eJ[eJ.KeyI=28]="KeyI",eJ[eJ.KeyJ=29]="KeyJ",eJ[eJ.KeyK=30]="KeyK",eJ[eJ.KeyL=31]="KeyL",eJ[eJ.KeyM=32]="KeyM",eJ[eJ.KeyN=33]="KeyN",eJ[eJ.KeyO=34]="KeyO",eJ[eJ.KeyP=35]="KeyP",eJ[eJ.KeyQ=36]="KeyQ",eJ[eJ.KeyR=37]="KeyR",eJ[eJ.KeyS=38]="KeyS",eJ[eJ.KeyT=39]="KeyT",eJ[eJ.KeyU=40]="KeyU",eJ[eJ.KeyV=41]="KeyV",eJ[eJ.KeyW=42]="KeyW",eJ[eJ.KeyX=43]="KeyX",eJ[eJ.KeyY=44]="KeyY",eJ[eJ.KeyZ=45]="KeyZ",eJ[eJ.Minus=46]="Minus",eJ[eJ.Period=47]="Period",eJ[eJ.Quote=48]="Quote",eJ[eJ.Semicolon=49]="Semicolon",eJ[eJ.Slash=50]="Slash",eJ[eJ.AltLeft=51]="AltLeft",eJ[eJ.AltRight=52]="AltRight",eJ[eJ.CapsLock=53]="CapsLock",eJ[eJ.ContextMenu=54]="ContextMenu",eJ[eJ.ControlLeft=55]="ControlLeft",eJ[eJ.ControlRight=56]="ControlRight",eJ[eJ.Enter=57]="Enter",eJ[eJ.MetaLeft=58]="MetaLeft",eJ[eJ.MetaRight=59]="MetaRight",eJ[eJ.ShiftLeft=60]="ShiftLeft",eJ[eJ.ShiftRight=61]="ShiftRight",eJ[eJ.Space=62]="Space",eJ[eJ.Tab=63]="Tab",eJ[eJ.Convert=64]="Convert",eJ[eJ.KanaMode=65]="KanaMode",eJ[eJ.Lang1=66]="Lang1",eJ[eJ.Lang2=67]="Lang2",eJ[eJ.Lang3=68]="Lang3",eJ[eJ.Lang4=69]="Lang4",eJ[eJ.Lang5=70]="Lang5",eJ[eJ.NonConvert=71]="NonConvert",eJ[eJ.Delete=72]="Delete",eJ[eJ.End=73]="End",eJ[eJ.Help=74]="Help",eJ[eJ.Home=75]="Home",eJ[eJ.Insert=76]="Insert",eJ[eJ.PageDown=77]="PageDown",eJ[eJ.PageUp=78]="PageUp",eJ[eJ.ArrowDown=79]="ArrowDown",eJ[eJ.ArrowLeft=80]="ArrowLeft",eJ[eJ.ArrowRight=81]="ArrowRight",eJ[eJ.ArrowUp=82]="ArrowUp",eJ[eJ.NumLock=83]="NumLock",eJ[eJ.Numpad0=84]="Numpad0",eJ[eJ.Numpad1=85]="Numpad1",eJ[eJ.Numpad2=86]="Numpad2",eJ[eJ.Numpad3=87]="Numpad3",eJ[eJ.Numpad4=88]="Numpad4",eJ[eJ.Numpad5=89]="Numpad5",eJ[eJ.Numpad6=90]="Numpad6",eJ[eJ.Numpad7=91]="Numpad7",eJ[eJ.Numpad8=92]="Numpad8",eJ[eJ.Numpad9=93]="Numpad9",eJ[eJ.NumpadAdd=94]="NumpadAdd",eJ[eJ.NumpadBackspace=95]="NumpadBackspace",eJ[eJ.NumpadClear=96]="NumpadClear",eJ[eJ.NumpadClearEntry=97]="NumpadClearEntry",eJ[eJ.NumpadComma=98]="NumpadComma",eJ[eJ.NumpadDecimal=99]="NumpadDecimal",eJ[eJ.NumpadDivide=100]="NumpadDivide",eJ[eJ.NumpadEnter=101]="NumpadEnter",eJ[eJ.NumpadEqual=102]="NumpadEqual",eJ[eJ.NumpadHash=103]="NumpadHash",eJ[eJ.NumpadMemoryAdd=104]="NumpadMemoryAdd",eJ[eJ.NumpadMemoryClear=105]="NumpadMemoryClear",eJ[eJ.NumpadMemoryRecall=106]="NumpadMemoryRecall",eJ[eJ.NumpadMemoryStore=107]="NumpadMemoryStore",eJ[eJ.NumpadMemorySubtract=108]="NumpadMemorySubtract",eJ[eJ.NumpadMultiply=109]="NumpadMultiply",eJ[eJ.NumpadParenLeft=110]="NumpadParenLeft",eJ[eJ.NumpadParenRight=111]="NumpadParenRight",eJ[eJ.NumpadStar=112]="NumpadStar",eJ[eJ.NumpadSubtract=113]="NumpadSubtract",eJ[eJ.Escape=114]="Escape",eJ[eJ.F1=115]="F1",eJ[eJ.F2=116]="F2",eJ[eJ.F3=117]="F3",eJ[eJ.F4=118]="F4",eJ[eJ.F5=119]="F5",eJ[eJ.F6=120]="F6",eJ[eJ.F7=121]="F7",eJ[eJ.F8=122]="F8",eJ[eJ.F9=123]="F9",eJ[eJ.F10=124]="F10",eJ[eJ.F11=125]="F11",eJ[eJ.F12=126]="F12",eJ[eJ.F13=127]="F13",eJ[eJ.F14=128]="F14",eJ[eJ.F15=129]="F15",eJ[eJ.Fn=130]="Fn",eJ[eJ.FnLock=131]="FnLock",eJ[eJ.PrintScreen=132]="PrintScreen",eJ[eJ.ScrollLock=133]="ScrollLock",eJ[eJ.Pause=134]="Pause",eJ[eJ.BrowserBack=135]="BrowserBack",eJ[eJ.BrowserFavorites=136]="BrowserFavorites",eJ[eJ.BrowserForward=137]="BrowserForward",eJ[eJ.BrowserHome=138]="BrowserHome",eJ[eJ.BrowserRefresh=139]="BrowserRefresh",eJ[eJ.BrowserSearch=140]="BrowserSearch",eJ[eJ.BrowserStop=141]="BrowserStop",eJ[eJ.Eject=142]="Eject",eJ[eJ.LaunchApp1=143]="LaunchApp1",eJ[eJ.LaunchApp2=144]="LaunchApp2",eJ[eJ.LaunchMail=145]="LaunchMail",eJ[eJ.MediaPlayPause=146]="MediaPlayPause",eJ[eJ.MediaSelect=147]="MediaSelect",eJ[eJ.MediaStop=148]="MediaStop",eJ[eJ.MediaTrackNext=149]="MediaTrackNext",eJ[eJ.MediaTrackPrevious=150]="MediaTrackPrevious",eJ[eJ.Power=151]="Power",eJ[eJ.Sleep=152]="Sleep",eJ[eJ.AudioVolumeDown=153]="AudioVolumeDown",eJ[eJ.AudioVolumeMute=154]="AudioVolumeMute",eJ[eJ.AudioVolumeUp=155]="AudioVolumeUp",eJ[eJ.WakeUp=156]="WakeUp",eJ[eJ.Hyper=157]="Hyper",eJ[eJ.Super=158]="Super",eJ[eJ.Turbo=159]="Turbo",eJ[eJ.Abort=160]="Abort",eJ[eJ.Resume=161]="Resume",eJ[eJ.Suspend=162]="Suspend",eJ[eJ.Again=163]="Again",eJ[eJ.Copy=164]="Copy",eJ[eJ.Cut=165]="Cut",eJ[eJ.Find=166]="Find",eJ[eJ.Open=167]="Open",eJ[eJ.Paste=168]="Paste",eJ[eJ.Props=169]="Props",eJ[eJ.Select=170]="Select",eJ[eJ.Undo=171]="Undo",eJ[eJ.Hiragana=172]="Hiragana",eJ[eJ.Katakana=173]="Katakana",eJ[eJ.Unidentified=174]="Unidentified";var l$=((e$=(eZ=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new lV,this._curFrameDownList=new lV,this._curFrameUpList=new lV,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,lZ.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}},e$._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},e$._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)},e$._destroy=function(){this._hadListener&&(this._htmlCanvas.removeEventListener("keydown",this._onKeyEvent),this._htmlCanvas.removeEventListener("keyup",this._onKeyEvent),this._hadListener=!1),this._curHeldDownKeyToIndexMap=null,this._upKeyToFrameCountMap=null,this._downKeyToFrameCountMap=null,this._nativeEvents=null,this._curFrameHeldDownList=null,this._curFrameDownList=null,this._curFrameUpList=null},e$._onKeyEvent=function(e){this._nativeEvents.push(e)},eZ);e.CameraClearFlags=void 0,(e0=e.CameraClearFlags||(e.CameraClearFlags={}))[e0.None=0]="None",e0[e0.Color=1]="Color",e0[e0.Depth=2]="Depth",e0[e0.Stencil=4]="Stencil",e0[e0.ColorDepth=3]="ColorDepth",e0[e0.ColorStencil=5]="ColorStencil",e0[e0.DepthStencil=6]="DepthStencil",e0[e0.All=7]="All";var l0=function(){this.entity=null,this.distance=0,this.point=new sW,this.normal=new sW},l1=function(){function t(e){var n=this;this._initialized=!1,this._restTime=0,this._colliders=new lV,this._gravity=new sW(0,-9.81,0),this._physicalObjectsMap={},this._onContactEnter=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionEnter(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionEnter(f)}}},this._onContactExit=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionExit(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionExit(f)}}},this._onContactStay=function(e,r){for(var i=n._physicalObjectsMap[e],a=n._physicalObjectsMap[r],o=i.collider.entity._scripts,s=0,l=o.length;s<l;s++){var c=o.get(s);if(!c._waitHandlingInValid){var u=t._collision;u.shape=a,c.onCollisionStay(u)}}o=a.collider.entity._scripts;for(var h=0,d=o.length;h<d;h++){var _=o.get(h);if(!_._waitHandlingInValid){var f=t._collision;f.shape=i,_.onCollisionStay(f)}}},this._onTriggerEnter=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerEnter(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerEnter(r)}},this._onTriggerExit=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerExit(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerExit(r)}},this._onTriggerStay=function(e,t){for(var r=n._physicalObjectsMap[e],i=n._physicalObjectsMap[t],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onTriggerStay(i)}a=i.collider.entity._scripts;for(var c=0,u=a.length;c<u;c++){var h=a.get(c);h._waitHandlingInValid||h.onTriggerStay(r)}},this.fixedTimeStep=1/60,this._engine=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity}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._physicalObjectsMap[e];return t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsManager.raycast(t,s,c):!!this._nativePhysicsManager.raycast(t,s,c,function(e,t,n,r){a.entity=o._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._initialize=function(e){t._nativePhysics=e,this._nativePhysicsManager=t._nativePhysics.createPhysicsManager(this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay),this._initialized=!0},n._update=function(e){var t=this.fixedTimeStep,n=this._nativePhysicsManager,r=this._engine._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._physicalObjectsMap[e.id]=e,this._nativePhysicsManager.addColliderShape(e._nativeShape)},n._removeColliderShape=function(e){delete this._physicalObjectsMap[e.id],this._nativePhysicsManager.removeColliderShape(e._nativeShape)},n._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCollider(e._nativeCollider)},n._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCharacterController(e._nativeCollider)},n._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCollider(e._nativeCollider)},n._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.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._nativePhysicsManager.setGravity(this._gravity)},s6(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}}]),t}();l1._collision=new function(){},e.PhysicsMaterialCombineMode=void 0,(e1=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[e1.Average=0]="Average",e1[e1.Minimum=1]="Minimum",e1[e1.Multiply=2]="Multiply",e1[e1.Maximum=3]="Maximum";var l2=((e2=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=l1._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},s6(e2,[{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))}}]),e2);e.Collider=(s9(e3=function(e){var t;return(t=lU.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lU),(e4=e3.prototype).addShape=function(e){var t=e._collider;t!==this&&(t&&t.removeShape(e),this._shapes.push(e),this.engine.physicsManager._addColliderShape(e),e._collider=this,this._nativeCollider.addShape(e._nativeShape))},e4.removeShape=function(e){var t=this._shapes.indexOf(e);-1!==t&&(this._shapes.splice(t,1),this.engine.physicsManager._removeColliderShape(e),e._collider=null,this._nativeCollider.removeShape(e._nativeShape))},e4.clearShapes=function(){for(var e=this._shapes,t=0,n=e.length;t<n;t++){var r=e[t];this.engine.physicsManager._removeColliderShape(r),r._destroy(),this._nativeCollider.removeShape(r._nativeShape)}e.length=0},e4._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}},e4._onLateUpdate=function(){},e4._onEnable=function(){this.engine.physicsManager._addCollider(this)},e4._onDisable=function(){this.engine.physicsManager._removeCollider(this)},e4._onDestroy=function(){lU.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},s6(e3,[{key:"shapes",get:function(){return this._shapes}}]),e3),ln([li],e.Collider.prototype,"_index",void 0),e.Collider=ln([lk(lq,e.DependentMode.CheckOnly)],e.Collider),e.ControllerNonWalkableMode=void 0,(e5=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[e5.PreventClimbing=0]="PreventClimbing",e5[e5.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var l3=(e8=e.Collider,s9(e6=function(t){var n;return(n=e8.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sW(0,1,0),n._slopeLimit=.707,n._nativeCollider=l1._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(s5(n)),n._upDirection._onValueChanged=n._setUpDirection,n},e8),(e7=e6.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},e7.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";e8.prototype.addShape.call(this,e),this._updateFlag.flag=!0},e7.clearShapes=function(){this._shapes.length>0&&e8.prototype.removeShape.call(this,this._shapes[0])},e7._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}},e7._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},e7._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},e7._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},e7._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},s6(e6,[{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))}}]),e6),l4=function(){function e(){this._isTrigger=!1,this._rotation=new sW,this._position=new sW,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new l2,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)},s6(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}();l4._idGenerator=0;var l5=(s9(e9=function(){var e;return(e=l4.call(this)||this)._size=new sW(1,1,1),e._nativeShape=l1._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(s5(e)),e._size._onValueChanged=e._setSize,e},l4),e9.prototype._setSize=function(){this._nativeShape.setSize(this._size)},s6(e9,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),e9),l8=(s9(te=function(){var e;return(e=l4.call(this)||this)._radius=1,e._nativeShape=l1._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},l4),s6(te,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),te),l6=(s9(tt=function(){var e;return(e=l4.call(this)||this)._nativeShape=l1._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},l4),tt);e.ColliderShapeUpAxis=void 0,(tn=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[tn.X=0]="X",tn[tn.Y=1]="Y",tn[tn.Z=2]="Z";var l7=(s9(tr=function(){var t;return(t=l4.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=l1._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},l4),s6(tr,[{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))}}]),tr);e.Joint=(s9(ti=function(e){var t;return(t=lU.call(this,e)||this)._connectedCollider=new l9,t._collider=new l9,t._force=0,t._torque=0,t._connectedCollider.localPosition=new sW,t},lU),s6(ti,[{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))}}]),ti),e.Joint=ln([lk(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var l9=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},ce=(ta=e.Joint,s9(to=function(){return ta.apply(this,arguments)},ta),to.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createFixedJoint(t.collider._nativeCollider)},to);(ts=se||(se={}))[ts.LimitEnabled=1]="LimitEnabled",ts[ts.DriveEnabled=2]="DriveEnabled",ts[ts.DriveFreeSpin=4]="DriveFreeSpin";var ct=(tl=e.Joint,s9(tc=function(){var e;return e=tl.apply(this,arguments)||this,e._axis=new sW(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},tl),tc.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sW,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createHingeJoint(t.collider._nativeCollider)},s6(tc,[{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&se.LimitEnabled)==se.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=se.LimitEnabled),this._nativeJoint.setHingeJointFlag(se.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&se.DriveEnabled)==se.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=se.DriveEnabled),this._nativeJoint.setHingeJointFlag(se.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(se.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))}}]),tc),cn=(tu=e.Joint,s9(th=function(){var e;return e=tu.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},tu),th.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sW,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=l1._nativePhysics.createSpringJoint(t.collider._nativeCollider)},s6(th,[{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))}}]),th),cr=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},ci=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(td=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[td.Sides=1]="Sides",td[td.Up=2]="Up",td[td.Down=4]="Down";var ca=(t_=e.Collider,s9(tf=function(e){var t,n=(t=t_.call(this,e)||this).entity.transform;return t._nativeCollider=l1._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},t_),tf),co=(tp=e.Collider,s9(tg=function(e){(t=tp.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sW,t._angularVelocity=new sW,t._mass=1,t._centerOfMass=new sW,t._inertiaTensor=new sW(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=l1._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(s5(t)),t._setAngularVelocity=t._setAngularVelocity.bind(s5(t)),t._setCenterOfMass=t._setCenterOfMass.bind(s5(t)),t._setInertiaTensor=t._setInertiaTensor.bind(s5(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},tp),(tm=tg.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},tm.applyTorque=function(e){this._nativeCollider.addTorque(e)},tm.move=function(e,t){this._nativeCollider.move(e,t)},tm.sleep=function(){this._nativeCollider.sleep()},tm.wakeUp=function(){this._nativeCollider.wakeUp()},tm._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},tm._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},tm._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},tm._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},tm._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},s6(tg,[{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))}}]),tg);e.CollisionDetectionMode=void 0,(tv=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[tv.Discrete=0]="Discrete",tv[tv.Continuous=1]="Continuous",tv[tv.ContinuousDynamic=2]="ContinuousDynamic",tv[tv.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(ty=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[ty.None=0]="None",ty[ty.FreezePositionX=1]="FreezePositionX",ty[ty.FreezePositionY=2]="FreezePositionY",ty[ty.FreezePositionZ=4]="FreezePositionZ",ty[ty.FreezeRotationX=8]="FreezeRotationX",ty[ty.FreezeRotationY=16]="FreezeRotationY",ty[ty.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(tx=e.PointerButton||(e.PointerButton={}))[tx.None=0]="None",tx[tx.Primary=1]="Primary",tx[tx.Secondary=2]="Secondary",tx[tx.Auxiliary=4]="Auxiliary",tx[tx.XButton1=8]="XButton1",tx[tx.XButton2=16]="XButton2",tx[tx.XButton3=32]="XButton3",tx[tx.XButton4=64]="XButton4",tx[tx.XButton5=128]="XButton5",tx[tx.XButton6=256]="XButton6",tx[tx.XButton7=512]="XButton7",tx[tx.XButton8=1024]="XButton8";var cs=[1,4,2,8,16,32,64,128,256,512,1024],cl={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},cc=((tC=(tT=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new lV,this._downList=new lV,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._updatePointerWithPhysics=this._updatePointerWithPhysics.bind(this),this._updatePointerWithoutPhysics=this._updatePointerWithoutPhysics.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._engine.physicsManager._initialized?this._updatePointerWithPhysics:this._updatePointerWithoutPhysics,u=this._htmlCanvas.getBoundingClientRect(),h=this._htmlCanvas,d=h.clientWidth,_=h.clientHeight,f=this._canvas,p=f.width,g=f.height,m=r;m>=0;m--){var v=t[m];v._upList.length=v._downList.length=0,c(l,v,u,d,_,p,g),this._buttons|=v.pressedButtons}},tC._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}},tC._onBlur=function(){if(this._hadListener){var t=this._htmlCanvas,n=this._onPointerEvent;t.removeEventListener("pointerdown",n),t.removeEventListener("pointerup",n),t.removeEventListener("pointerleave",n),t.removeEventListener("pointermove",n),t.removeEventListener("pointercancel",n),this._hadListener=!1,this._downList.length=0,this._upList.length=0;for(var r=this._pointers,i=r.length-1;i>=0;i--)r[i].phase=e.PointerPhase.Leave;r.length=0}},tC._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._pointers.length=0,this._downList.length=0,this._upList.length=0,this._htmlCanvas=null,this._engine=null},tC._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},tC._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},tC._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 lJ(a)),o._uniqueID=e,t.splice(a,0,o),o},tC._pointerRayCast=function(t,n){for(var r=tT._tempPoint,i=tT._tempRay,a=tT._tempHitResult,o=this._engine.sceneManager.activeScene._activeCameras,s=o.length-1;s>=0;s--){var l=o[s];if(l.enabled&&!l.renderTarget){var c=l.viewport,u=c.x,h=c.y,d=c.z,_=c.w;if(t>=u&&n>=h&&t-u<=d&&n-h<=_){if(r.set((t-u)/d,(n-h)/_),this._engine.physicsManager.raycast(l.viewportPointToRay(r,i),Number.MAX_VALUE,l.cullingMask,a))return a.entity;if(l.clearFlags&e.CameraClearFlags.Color)return null}}}},tC._updatePointerWithPhysics=function(t,n,r,i,a,o,s){var l=n._events,c=n.position,u=l.length;if(u>0){var h=this._upList,d=this._upMap,_=this._downList,f=this._downMap,p=l[u-1],g=(p.clientX-r.left)/i,m=(p.clientY-r.top)/a,v=g*o,y=m*s;n.deltaPosition.set(v-c.x,y-c.y),c.set(v,y),n._firePointerDrag();var x=this._pointerRayCast(g,m);n._firePointerExitAndEnter(x);for(var T=0;T<u;T++){var C=l[T],S=C.button;switch(n.button=cs[S]||e.PointerButton.None,n.pressedButtons=C.buttons,C.type){case"pointerdown":_.add(S),f[S]=t,n._downList.add(S),n._downMap[S]=t,n.phase=e.PointerPhase.Down,n._firePointerDown(x);break;case"pointerup":h.add(S),d[S]=t,n._upList.add(S),n._upMap[S]=t,n.phase=e.PointerPhase.Up,n._firePointerUpAndClick(x);break;case"pointermove":n.phase=e.PointerPhase.Move;break;case"pointerleave":case"pointercancel":n.phase=e.PointerPhase.Leave,n._firePointerExitAndEnter(null)}}n._events.length=0}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary,n._firePointerDrag(),n._firePointerExitAndEnter(this._pointerRayCast(c.x/o,c.y/s))},tC._updatePointerWithoutPhysics=function(t,n,r,i,a,o,s){var l=n._events,c=l.length;if(c>0){var u=n.position,h=l[c-1],d=(h.clientX-r.left)/i*o,_=(h.clientY-r.top)/a*s;n.deltaPosition.set(d-u.x,_-u.y),u.set(d,_),n.button=cs[h.button]||e.PointerButton.None,n.pressedButtons=h.buttons;for(var f=this._upList,p=this._upMap,g=this._downList,m=this._downMap,v=0;v<c;v++){var y=l[v].button;switch(l[v].type){case"pointerdown":g.add(y),m[y]=t,n._downList.add(y),n._downMap[y]=t,n.phase=e.PointerPhase.Down;break;case"pointerup":f.add(y),p[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}}n._events.length=0}else n.deltaPosition.set(0,0),n.phase=e.PointerPhase.Stationary},tT);cc._tempRay=new s$,cc._tempPoint=new s0,cc._tempHitResult=new l0;var cu=((tw=(tS=function(e){this._delta=new sW,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}},tw._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},tw._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},tw._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},tw._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},tS),ch=((tE=(tA=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&lr(t,OffscreenCanvas)||(this._wheelManager=new cu(e),this._pointerManager=new cc(e),this._keyboardManager=new l$(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])},tE.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},tE.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},tE.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},tE.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[cl[e]]===this._engine.time.frameCount)},tE.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[cl[e]]===this._engine.time.frameCount)},tE._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},tE._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},tE._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},tE._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},s6(tA,[{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}}]),tA);e.ShadowCascadesMode=void 0,(tM=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tM.NoCascades=1]="NoCascades",tM[tM.TwoCascades=2]="TwoCascades",tM[tM.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(tb=e.ShadowResolution||(e.ShadowResolution={}))[tb.Low=0]="Low",tb[tb.Medium=1]="Medium",tb[tb.High=2]="High",tb[tb.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tR=e.ShadowType||(e.ShadowType={}))[tR.None=0]="None",tR[tR.Hard=1]="Hard",tR[tR.SoftLow=2]="SoftLow",tR[tR.SoftHigh=3]="SoftHigh";var cd=(s9(tF=function(){var t;return t=lU.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 s2(1,1,1,1),t._lightColor=new s2,t},lU),tF.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},s6(tF,[{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 sZ),sZ.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new sZ),sZ.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),tF);cd._maxLight=10,ln([li],cd.prototype,"_lightIndex",void 0);var c_=(s9(tP=function(){var e;return e=cd.apply(this,arguments)||this,e._reverseDirection=new sW,e},cd),(tL=tP.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.direction,s=tP._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]=s2.gammaToLinearSpace(a.r),s.color[r+1]=s2.gammaToLinearSpace(a.g),s.color[r+2]=s2.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},tL._onEnable=function(){this.engine._lightManager._attachDirectLight(this)},tL._onDisable=function(){this.engine._lightManager._detachDirectLight(this)},tP._updateShaderData=function(e){var t=tP._combinedData;e.setIntArray(tP._cullingMaskProperty,t.cullingMask),e.setFloatArray(tP._colorProperty,t.color),e.setFloatArray(tP._directionProperty,t.direction)},s6(tP,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sW.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tP);c_._cullingMaskProperty=lB.getByName("scene_DirectLightCullingMask"),c_._colorProperty=lB.getByName("scene_DirectLightColor"),c_._directionProperty=lB.getByName("scene_DirectLightDirection"),c_._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),direction:new Float32Array(3*cd._maxLight)};var cf=(s9(tD=function(){var e;return e=cd.apply(this,arguments)||this,e.distance=100,e},cd),(tI=tD.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.position,s=tD._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]=s2.gammaToLinearSpace(a.r),s.color[r+1]=s2.gammaToLinearSpace(a.g),s.color[r+2]=s2.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},tI._onEnable=function(){this.engine._lightManager._attachPointLight(this)},tI._onDisable=function(){this.engine._lightManager._detachPointLight(this)},tD._updateShaderData=function(e){var t=tD._combinedData;e.setIntArray(tD._cullingMaskProperty,t.cullingMask),e.setFloatArray(tD._colorProperty,t.color),e.setFloatArray(tD._positionProperty,t.position),e.setFloatArray(tD._distanceProperty,t.distance)},s6(tD,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tD);cf._cullingMaskProperty=lB.getByName("scene_PointLightCullingMask"),cf._colorProperty=lB.getByName("scene_PointLightColor"),cf._positionProperty=lB.getByName("scene_PointLightPosition"),cf._distanceProperty=lB.getByName("scene_PointLightDistance"),cf._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),position:new Float32Array(3*cd._maxLight),distance:new Float32Array(cd._maxLight)};var cp=(s9(tB=function(){var e;return e=cd.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new sW,e._projectMatrix=new sZ,e},cd),(tN=tB.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=tB._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]=s2.gammaToLinearSpace(o.r),c.color[r+1]=s2.gammaToLinearSpace(o.g),c.color[r+2]=s2.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)},tN._onEnable=function(){this.engine._lightManager._attachSpotLight(this)},tN._onDisable=function(){this.engine._lightManager._detachSpotLight(this)},tB._updateShaderData=function(e){var t=tB._combinedData;e.setIntArray(tB._cullingMaskProperty,t.cullingMask),e.setFloatArray(tB._colorProperty,t.color),e.setFloatArray(tB._positionProperty,t.position),e.setFloatArray(tB._directionProperty,t.direction),e.setFloatArray(tB._distanceProperty,t.distance),e.setFloatArray(tB._angleCosProperty,t.angleCos),e.setFloatArray(tB._penumbraCosProperty,t.penumbraCos)},s6(tB,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sW.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 sZ.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),tB);cp._cullingMaskProperty=lB.getByName("scene_SpotLightCullingMask"),cp._colorProperty=lB.getByName("scene_SpotLightColor"),cp._positionProperty=lB.getByName("scene_SpotLightPosition"),cp._directionProperty=lB.getByName("scene_SpotLightDirection"),cp._distanceProperty=lB.getByName("scene_SpotLightDistance"),cp._angleCosProperty=lB.getByName("scene_SpotLightAngleCos"),cp._penumbraCosProperty=lB.getByName("scene_SpotLightPenumbraCos"),cp._combinedData={cullingMask:new Int32Array(2*cd._maxLight),color:new Float32Array(3*cd._maxLight),position:new Float32Array(3*cd._maxLight),direction:new Float32Array(3*cd._maxLight),distance:new Float32Array(cd._maxLight),angleCos:new Float32Array(cd._maxLight),penumbraCos:new Float32Array(cd._maxLight)};var cg=((tO=(tV=function(){this._spotLights=new lV,this._pointLights=new lV,this._directLights=new lV}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},tO._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},tO._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},tO._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tO._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},tO._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?(c_._updateShaderData(e),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),a?(cf._updateShaderData(e),e.enableMacro("SCENE_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),i?(cp._updateShaderData(e),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},tO._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},tV);(tU=st||(st={}))[tU.Scene=0]="Scene",tU[tU.Camera=1]="Camera",tU[tU.Renderer=2]="Renderer",tU[tU.Material=3]="Material",e.ShaderPropertyType=void 0,(tz=e.ShaderPropertyType||(e.ShaderPropertyType={}))[tz.Float=0]="Float",tz[tz.Int=1]="Int",tz[tz.Vector2=2]="Vector2",tz[tz.Vector3=3]="Vector3",tz[tz.Vector4=4]="Vector4",tz[tz.Matrix=5]="Matrix",tz[tz.Color=6]="Color",tz[tz.Texture=7]="Texture",tz[tz.FloatArray=8]="FloatArray",tz[tz.IntArray=9]="IntArray",tz[tz.TextureArray=10]="TextureArray";var cm=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}();cm._macroMaskMap=[],cm._macroNameIdMap=Object.create(null),cm._macroNameCounter=0,cm._macroCounter=0,cm._macroMap=Object.create(null);var cv=((tG=(tk=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},tG.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}},tG.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]},tG.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}},tG.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}},tG.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},tG.clear=function(){this._length=0},tk.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},tk),cy=((tW=(tH=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new cv,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},tW.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},tW.getInt=function(e){return this.getPropertyValue(e)},tW.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},tW.getFloatArray=function(e){return this.getPropertyValue(e)},tW.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},tW.getIntArray=function(e){return this.getPropertyValue(e)},tW.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},tW.getVector2=function(e){return this.getPropertyValue(e)},tW.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},tW.getVector3=function(e){return this.getPropertyValue(e)},tW.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},tW.getVector4=function(e){return this.getPropertyValue(e)},tW.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},tW.getMatrix=function(e){return this.getPropertyValue(e)},tW.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},tW.getColor=function(e){return this.getPropertyValue(e)},tW.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},tW.getTexture=function(e){return this.getPropertyValue(e)},tW.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)},tW.getTextureArray=function(e){return this.getPropertyValue(e)},tW.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)},tW.getPropertyValue=function(e){return"string"==typeof e&&(e=lB.getByName(e)),this._propertyValueMap[e._uniqueId]},tW.enableMacro=function(e,t){"string"==typeof e&&(e=cm.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}},tW.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=cm._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},tW.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])},tW.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=lB._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},tW.clone=function(){var e=new tH(this._group);return this.cloneTo(e),e},tW.cloneTo=function(e){ll.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=e._getReferCount(),n=this._propertyValueMap,r=e._propertyValueMap,i=Object.keys(n),a=0,o=i.length;a<o;a++){var s=i[a],l=n[s];if(null!=l){if("number"==typeof l)r[s]=l;else if(lr(l,ly))r[s]=l,t>0&&l._addReferCount(t);else if(lr(l,Array)||lr(l,Float32Array)||lr(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},tW._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lB.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 "+st[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},tW._getReferCount=function(){return this._refCount},tW._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&lr(r,ly)&&r._addReferCount(e)}},tH);e.RenderQueueType=void 0,(tX=e.RenderQueueType||(e.RenderQueueType={}))[tX.Opaque=0]="Opaque",tX[tX.AlphaTest=1]="AlphaTest",tX[tX.Transparent=2]="Transparent",e.BlendFactor=void 0,(tK=e.BlendFactor||(e.BlendFactor={}))[tK.Zero=0]="Zero",tK[tK.One=1]="One",tK[tK.SourceColor=2]="SourceColor",tK[tK.OneMinusSourceColor=3]="OneMinusSourceColor",tK[tK.DestinationColor=4]="DestinationColor",tK[tK.OneMinusDestinationColor=5]="OneMinusDestinationColor",tK[tK.SourceAlpha=6]="SourceAlpha",tK[tK.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",tK[tK.DestinationAlpha=8]="DestinationAlpha",tK[tK.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",tK[tK.SourceAlphaSaturate=10]="SourceAlphaSaturate",tK[tK.BlendColor=11]="BlendColor",tK[tK.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(tj=e.BlendOperation||(e.BlendOperation={}))[tj.Add=0]="Add",tj[tj.Subtract=1]="Subtract",tj[tj.ReverseSubtract=2]="ReverseSubtract",tj[tj.Min=3]="Min",tj[tj.Max=4]="Max",e.ColorWriteMask=void 0,(tq=e.ColorWriteMask||(e.ColorWriteMask={}))[tq.None=0]="None",tq[tq.Red=1]="Red",tq[tq.Green=2]="Green",tq[tq.Blue=4]="Blue",tq[tq.Alpha=8]="Alpha",tq[tq.All=15]="All";var cx=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},cT=((tQ=(tY=function(){this.targetBlendState=new cx,this.blendColor=new s2(0,0,0,0),this.alphaToCoverage=!1}).prototype)._apply=function(e,t){this._platformApply(e,t.blendState)},tQ._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(tY._getGLBlendFactor(t,c),tY._getGLBlendFactor(t,u),tY._getGLBlendFactor(t,h),tY._getGLBlendFactor(t,d)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=d),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(r.blendEquationSeparate(tY._getGLBlendOperation(t,s),tY._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;s2.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)},tY._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}},tY._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}},tY);e.CompareFunction=void 0,(tJ=e.CompareFunction||(e.CompareFunction={}))[tJ.Never=0]="Never",tJ[tJ.Less=1]="Less",tJ[tJ.Equal=2]="Equal",tJ[tJ.LessEqual=3]="LessEqual",tJ[tJ.Greater=4]="Greater",tJ[tJ.NotEqual=5]="NotEqual",tJ[tJ.GreaterEqual=6]="GreaterEqual",tJ[tJ.Always=7]="Always";var cC=((t$=(tZ=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._apply=function(e,t){this._platformApply(e,t.depthState)},t$._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(tZ._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(n.depthMask(a),t.writeEnabled=a))},tZ._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}},tZ);e.CullMode=void 0,(t0=e.CullMode||(e.CullMode={}))[t0.Off=0]="Off",t0[t0.Front=1]="Front",t0[t0.Back=2]="Back";var cS=((t2=(t1=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)},t2._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)},t1);e.StencilOperation=void 0,(t3=e.StencilOperation||(e.StencilOperation={}))[t3.Keep=0]="Keep",t3[t3.Zero=1]="Zero",t3[t3.Replace=2]="Replace",t3[t3.IncrementSaturate=3]="IncrementSaturate",t3[t3.DecrementSaturate=4]="DecrementSaturate",t3[t3.Invert=5]="Invert",t3[t3.IncrementWrap=6]="IncrementWrap",t3[t3.DecrementWrap=7]="DecrementWrap";var cw=((t5=(t4=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)},t5._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,t4._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(n.stencilFuncSeparate(n.BACK,t4._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,t4._getGLStencilOperation(e,l),t4._getGLStencilOperation(e,c),t4._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(h!==t.failOperationBack||d!==t.zFailOperationBack||_!==t.passOperationBack)&&(n.stencilOpSeparate(n.BACK,t4._getGLStencilOperation(e,h),t4._getGLStencilOperation(e,d),t4._getGLStencilOperation(e,_)),t.failOperationBack=h,t.zFailOperationBack=d,t.passOperationBack=_),f!==t.writeMask&&(n.stencilMask(f),t.writeMask=f)}},t4._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}},t4._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}},t4),cA=((t8=function(){this.blendState=new cT,this.depthState=new cC,this.stencilState=new cw,this.rasterState=new cS,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)},t8),cE=(s9(t6=function(e,t){var n;return(n=lu.call(this,e)||this)._renderStates=[],n._shaderData=new cy(st.Material),n.shader=t,n},lu),(t7=t6.prototype).clone=function(){var e=new t6(this._engine,this.shader);return this.cloneTo(e),e},t7.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),ll.deepCloneObject(this.renderStates,e.renderStates)},t7._addReferCount=function(e){lu.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e)},t7._onDestroy=function(){this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},s6(t6,[{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,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 cA);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t6),cM=((ne=(t9=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},ne.resetPool=function(){this._elementPoolIndex=0},ne.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},t9),cb=function(){},cR=(s9(nt=function(){return cb.apply(this,arguments)},cb),(nn=nt.prototype).set=function(e,t,n,r){this.component=e,this.material=t,this.mesh=n,this.subMesh=r},nn.dispose=function(){this.component=this.material=this.mesh=this.subMesh=null},nt);function cF(){return(cF=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,(nr=e.PipelineStage||(e.PipelineStage={})).ShadowCaster="ShadowCaster",nr.Forward="Forward";var cP=cF({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;}"}),cL=((ni=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},ni.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=cP[t];return void 0===n?(lv.error('Shader slice "'+e.trim()+'" not founded.'),""):ni.parseIncludes(n)})},ni.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},ni.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},ni._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)},ni),cD=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}();cD._nameCounter=0,cD._nameMap=Object.create(null);var cI=((no=(na=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var n="string"==typeof e?cD.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&lv.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},no.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?cD.getByName(e):e)._uniqueId]},no.getTagValue=function(e){return this._tagsMap["string"==typeof e?cD.getByName(e)._uniqueId:e._uniqueId]},na),cB=((nl=(ns=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)},nl.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.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)},nl.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.gammaToLinearSpace(n.g),s2.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)},nl.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},nl.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,s2.gammaToLinearSpace(n.r),s2.gammaToLinearSpace(n.g),s2.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)},nl.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},nl.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},nl.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},nl.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)},nl.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},nl.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)},nl.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},nl.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)},nl.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},nl.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},nl.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},nl.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},nl.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)}},ns),cN=function(){this.constUniforms=[],this.textureUniforms=[]},cV=function(){function e(t,n,r){this.sceneUniformBlock=new cN,this.cameraUniformBlock=new cN,this.rendererUniformBlock=new cN,this.materialUniformBlock=new cN,this.otherUniformBlock=new cN,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=lB._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 st.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case st.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case st.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case st.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),!lv.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(lv.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),!lv.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 cB(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=lB.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 s0(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sW(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new s1(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 s0(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=c?l.upload3iv:l.upload3i,l.cacheValue=new sW(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new s1(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=lB._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")},s6(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();cV._counter=0;var cO=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 s9(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=[];cm._getNamesByMacros(n,o);var s=cL.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 "+cL.parseIncludes(this._vertexSource),d=" "+l+"\n "+c+"\n "+(a?"":cL.parseExtension(cz._shaderExtension))+"\n "+u+"\n "+s+"\n "+cL.parseIncludes(this._fragmentSource);return a&&(h=cL.convertTo300(h),d=cL.convertTo300(d,!0)),i=new cV(t,h,d),r.cache(i),i},n}(cI);cO._shaderPassCounter=0;var cU=(s9(nc=function(e,t,n){var r;if((r=cI.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},cI),s6(nc,[{key:"passes",get:function(){return this._passes}}]),nc),cz=((nu=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var n=nu._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(cm.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},nu.create=function(e,t,n){var r,i=nu._shaderMap;if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new cO(t,n);r=new nu(e,[new cU("Default",[a])])}else if(t.length>0)r=t[0].constructor===cO?new nu(e,[new cU("Default",t)]):new nu(e,t.slice());else throw"SubShader or ShaderPass count must large than 0.";return i[e]=r,r},nu.find=function(e){return nu._shaderMap[e]},nu.getMacroByName=function(e,t){return cm.getByName(e,t)},nu.getPropertyByName=function(e){return lB.getByName(e)},s6(nu,[{key:"subShaders",get:function(){return this._subShaders}}]),nu);cz._compileMacros=new cv,cz._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],cz._shaderMap=Object.create(null);var ck=((nh=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(nh._viewMatrixProperty,e.viewMatrix),t.setMatrix(nh._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(nh.vpMatrixProperty,e.viewProjectionMatrix)},nh);ck.vpMatrixProperty=lB.getByName("camera_VPMat"),ck.pipelineStageKey=cD.getByName("pipelineStage"),ck._viewMatrixProperty=lB.getByName("camera_ViewMat"),ck._projectionMatrixProperty=lB.getByName("camera_ProjMat");var cG=((n_=(nd=function(){}).prototype).set=function(e,t,n){this.data=e,this.shaderPass=t,this.renderState=n},n_.dispose=function(){this.data=this.shaderPass=this.renderState=null},nd);function cH(){return function(e){}}e.SpriteMaskInteraction=void 0,(nf=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[nf.None=0]="None",nf[nf.VisibleInsideMask=1]="VisibleInsideMask",nf[nf.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(s9(np=function(t){(n=lU.call(this,t)||this)._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new cv,n._bounds=new sK,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._shaderData=new cy(st.Renderer),n._mvMatrix=new sZ,n._mvpMatrix=new sZ,n._mvInvMatrix=new sZ,n._normalMatrix=new sZ,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new s1,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(s5(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lU),(ng=np.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},ng.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},ng.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},ng.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},ng.getMaterials=function(){return this._materials},ng.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))}},ng.update=function(e){},ng._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},ng._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},ng._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sW.subtract(i,r,i),this._distanceForSort=sW.dot(i,n.forward)):this._distanceForSort=sW.distanceSquared(i,r),this._updateShaderData(t),this._render(t),cv.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},ng._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},ng._onDestroy=function(){lU.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},ng._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)},ng._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;sZ.multiply(i.viewMatrix,n,a),sZ.multiply(i.viewProjectionMatrix,n,o),sZ.invert(a,s),sZ.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)},ng._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},ng._updateBounds=function(e){},ng._render=function(e){throw"not implement"},ng._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},ng._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}},ng._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},s6(np,[{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}}]),(sn=np)._tempVector0=new sW,sn._receiveShadowMacro=cm.getByName("RENDERER_IS_RECEIVE_SHADOWS"),sn._localMatrixProperty=lB.getByName("renderer_LocalMat"),sn._worldMatrixProperty=lB.getByName("renderer_ModelMat"),sn._mvMatrixProperty=lB.getByName("renderer_MVMat"),sn._mvpMatrixProperty=lB.getByName("renderer_MVPMat"),sn._mvInvMatrixProperty=lB.getByName("renderer_MVInvMat"),sn._normalMatrixProperty=lB.getByName("renderer_NormalMat"),sn._rendererLayerProperty=lB.getByName("renderer_Layer"),sn),ln([li],e.Renderer.prototype,"_distanceForSort",void 0),ln([li],e.Renderer.prototype,"_onUpdateIndex",void 0),ln([li],e.Renderer.prototype,"_rendererIndex",void 0),ln([li],e.Renderer.prototype,"_globalShaderMacro",void 0),ln([ls],e.Renderer.prototype,"_bounds",void 0),ln([li],e.Renderer.prototype,"_renderFrameCount",void 0),ln([li],e.Renderer.prototype,"_overrideUpdate",void 0),ln([li],e.Renderer.prototype,"_materials",void 0),ln([li],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),ln([ls],e.Renderer.prototype,"_shaderData",void 0),ln([li],e.Renderer.prototype,"_mvMatrix",void 0),ln([li],e.Renderer.prototype,"_mvpMatrix",void 0),ln([li],e.Renderer.prototype,"_mvInvMatrix",void 0),ln([li],e.Renderer.prototype,"_normalMatrix",void 0),ln([li],e.Renderer.prototype,"_materialsInstanced",void 0),ln([li],e.Renderer.prototype,"_priority",void 0),ln([la],e.Renderer.prototype,"_receiveShadows",void 0),ln([li],e.Renderer.prototype,"_rendererLayer",void 0),ln([li],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=ln([lk(lq,e.DependentMode.CheckOnly)],e.Renderer),(nm=sr||(sr={}))[nm.WorldVolume=1]="WorldVolume";var cW=((nv=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 sW),i.push(new s0);t.triangles=cW._rectangleTriangles},nv.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=cW._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])}sK.transform(r._getBounds(),s,e._bounds)},nv.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)},(si=nv)._rectangleTriangles=[0,1,2,2,1,3],si._worldMatrix=new sZ,si);cW=ln([cH()],cW);var cX=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,(ny=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[ny.Layer0=1]="Layer0",ny[ny.Layer1=2]="Layer1",ny[ny.Layer2=4]="Layer2",ny[ny.Layer3=8]="Layer3",ny[ny.Layer4=16]="Layer4",ny[ny.Layer5=32]="Layer5",ny[ny.Layer6=64]="Layer6",ny[ny.Layer7=128]="Layer7",ny[ny.Layer8=256]="Layer8",ny[ny.Layer9=512]="Layer9",ny[ny.Layer10=1024]="Layer10",ny[ny.Layer11=2048]="Layer11",ny[ny.Layer12=4096]="Layer12",ny[ny.Layer13=8192]="Layer13",ny[ny.Layer14=16384]="Layer14",ny[ny.Layer15=32768]="Layer15",ny[ny.Layer16=65536]="Layer16",ny[ny.Layer17=131072]="Layer17",ny[ny.Layer18=262144]="Layer18",ny[ny.Layer19=524288]="Layer19",ny[ny.Layer20=1048576]="Layer20",ny[ny.Layer21=2097152]="Layer21",ny[ny.Layer22=4194304]="Layer22",ny[ny.Layer23=8388608]="Layer23",ny[ny.Layer24=16777216]="Layer24",ny[ny.Layer25=33554432]="Layer25",ny[ny.Layer26=67108864]="Layer26",ny[ny.Layer27=134217728]="Layer27",ny[ny.Layer28=268435456]="Layer28",ny[ny.Layer29=536870912]="Layer29",ny[ny.Layer30=1073741824]="Layer30",ny[ny.Layer31=2147483648]="Layer31",ny[ny.Everything=4294967295]="Everything",(nx=sa||(sa={}))[nx.texture=1]="texture",nx[nx.size=2]="size",nx[nx.atlasRotate=4]="atlasRotate",nx[nx.atlasRegion=8]="atlasRegion",nx[nx.atlasRegionOffset=16]="atlasRegionOffset",nx[nx.region=32]="region",nx[nx.pivot=64]="pivot",nx[nx.border=128]="border";var cK=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 cX(4,[],[]),cW.resetData(s5(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(s5(i)),i}s9(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?cW.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&sr.WorldVolume&&(cW.updatePositions(this),this._dirtyUpdateFlag&=~sr.WorldVolume),2&this._dirtyUpdateFlag&&(cW.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(){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 sa.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case sa.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sr.WorldVolume);break;case sa.region:case sa.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sa.atlasRegion:this._dirtyUpdateFlag|=2;break;case sa.pivot:this._dirtyUpdateFlag|=sr.WorldVolume}},s6(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|=sr.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|=sr.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sr.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sr.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);cK._textureProperty=lB.getByName("renderer_MaskTexture"),cK._alphaCutoffProperty=lB.getByName("renderer_MaskAlphaCutoff"),ln([la],cK.prototype,"influenceLayers",void 0),ln([li],cK.prototype,"_sprite",void 0),ln([li],cK.prototype,"_automaticWidth",void 0),ln([li],cK.prototype,"_automaticHeight",void 0),ln([la],cK.prototype,"_customWidth",void 0),ln([la],cK.prototype,"_customHeight",void 0),ln([la],cK.prototype,"_flipX",void 0),ln([la],cK.prototype,"_flipY",void 0),ln([la],cK.prototype,"_alphaCutoff",void 0),ln([li],cK.prototype,"_onSpriteChange",null),(nT=so||(so={}))[nT.UV=2]="UV",nT[nT.RenderData=3]="RenderData",nT[nT.AutomaticSize=4]="AutomaticSize",nT[nT.All=7]="All",e.VertexElementFormat=void 0,(nC=e.VertexElementFormat||(e.VertexElementFormat={}))[nC.Float=0]="Float",nC[nC.Vector2=1]="Vector2",nC[nC.Vector3=2]="Vector3",nC[nC.Vector4=3]="Vector4",nC[nC.Byte4=4]="Byte4",nC[nC.UByte4=5]="UByte4",nC[nC.NormalizedByte4=6]="NormalizedByte4",nC[nC.NormalizedUByte4=7]="NormalizedUByte4",nC[nC.Short2=8]="Short2",nC[nC.UShort2=9]="UShort2",nC[nC.NormalizedShort2=10]="NormalizedShort2",nC[nC.NormalizedUShort2=11]="NormalizedUShort2",nC[nC.Short4=12]="Short4",nC[nC.UShort4=13]="UShort4",nC[nC.NormalizedShort4=14]="NormalizedShort4",nC[nC.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(nS=e.IndexFormat||(e.IndexFormat={}))[nS.UInt8=0]="UInt8",nS[nS.UInt16=1]="UInt16",nS[nS.UInt32=2]="UInt32";var cj=((nw=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}},nw._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},nw._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}},nw),cq=(s6(nA=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=cj._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}}]),nA);e.BufferUsage=void 0,(nE=e.BufferUsage||(e.BufferUsage={}))[nE.Static=0]="Static",nE[nE.Dynamic=1]="Dynamic",nE[nE.Stream=2]="Stream",e.SetDataOptions=void 0,(nM=e.SetDataOptions||(e.SetDataOptions={}))[nM.None=0]="None",nM[nM.Discard=1]="Discard";var cY=(s9(nb=function(t,n,r,i){if(void 0===i&&(i=e.BufferUsage.Static),(a=ld.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},ld),(nR=nb.prototype).bind=function(){this._platformBuffer.bind()},nR.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)},nR.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},nR._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},nR._onDestroy=function(){ld.prototype._onDestroy.call(this),this._platformBuffer.destroy()},nR.resize=function(e){this._platformBuffer.resize(e),this._byteLength=e},s6(nb,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),nb);e.BufferBindFlag=void 0,(nF=e.BufferBindFlag||(e.BufferBindFlag={}))[nF.VertexBuffer=0]="VertexBuffer",nF[nF.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(nP=e.MeshTopology||(e.MeshTopology={}))[nP.Points=0]="Points",nP[nP.Lines=1]="Lines",nP[nP.LineLoop=2]="LineLoop",nP[nP.LineStrip=3]="LineStrip",nP[nP.Triangles=4]="Triangles",nP[nP.TriangleStrip=5]="TriangleStrip",nP[nP.TriangleFan=6]="TriangleFan";var cQ=(s6(nL=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),nL),cJ=((nD=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(){},nD),cZ=(s9(nI=function(e,t){(n=ld.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new lj,n._bounds=new sK,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(s5(n)),n._onBoundsChanged=n._onBoundsChanged.bind(s5(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},ld),(nB=nI.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new cJ(t,n,r)),this._subMeshes.push(t),t},nB.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},nB.clearSubMesh=function(){this._subMeshes.length=0},nB._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},nB._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nB._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},nB._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},nB._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},nB._addReferCount=function(e){ld.prototype._addReferCount.call(this,e);for(var t,n=this._vertexBufferBindings,r=0,i=n.length;r<i;r++)n[r]._buffer._addReferCount(e);null==(t=this._indexBufferBinding)||t._buffer._addReferCount(e)},nB._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this)},nB._onDestroy=function(){ld.prototype._onDestroy.call(this),this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},nB._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},nB._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))},nB._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},s6(nI,[{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}}]),nI);(nN=ss||(ss={}))[nN.Bounds=1]="Bounds",nN[nN.VertexElements=2]="VertexElements";var c$=(s6(nV=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),nV),c0=((nU=(nO=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 sW(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sW,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(lK))},nU._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},nU._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(nO._blendShapeMacro),this._useTextureMode())e.enableMacro(nO._blendShapeTextureMacro),e.setTexture(nO._blendShapeTextureProperty,this._vertexTexture),e.setVector3(nO._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(nO._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(nO._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(nO._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(nO._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(nO._blendShapeNormalMacro):e.disableMacro(nO._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(nO._blendShapeTangentMacro):e.disableMacro(nO._blendShapeTangentMacro)}else e.disableMacro(nO._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},nU._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},nU._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},nU._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},nU._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},nU._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},nU._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 cq("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new cq("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new cq("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},nU._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))},nU._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},nU._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 cY(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new c$(m,f)),o[d]=m}},nU._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 lC(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)},nU._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 s0),C.set(u+m,v*c);for(var S=g.deltaPositions,w=0;w<e;w++){var A=T+x*w,E=S[w];E&&(i[A]=E.x,i[A+1]=E.y,i[A+2]=E.z)}if(T+=3,this._useBlendNormal){var M=g.deltaNormals;if(M)for(var b=0;b<e;b++){var R=T+x*b,F=M[b];F&&(i[R]=F.x,i[R+1]=F.y,i[R+2]=F.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}}},nU._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)},nU._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},nU._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}},nU._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},nU._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)}}}},nO);c0._blendShapeMacro=cm.getByName("RENDERER_HAS_BLENDSHAPE"),c0._blendShapeTextureMacro=cm.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),c0._blendShapeNormalMacro=cm.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),c0._blendShapeTangentMacro=cm.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),c0._blendShapeWeightsProperty=lB.getByName("renderer_BlendShapeWeights"),c0._blendShapeTextureProperty=lB.getByName("renderer_BlendShapeTexture"),c0._blendShapeTextureInfoProperty=lB.getByName("renderer_BlendShapeTextureInfo"),(nz=sl||(sl={})).Position="POSITION",nz.Normal="NORMAL",nz.Color="COLOR_0",nz.Tangent="TANGENT",nz.BoneWeight="WEIGHTS_0",nz.BoneIndex="JOINTS_0",nz.UV="TEXCOORD_0",nz.UV1="TEXCOORD_1",nz.UV2="TEXCOORD_2",nz.UV3="TEXCOORD_3",nz.UV4="TEXCOORD_4",nz.UV5="TEXCOORD_5",nz.UV6="TEXCOORD_6",nz.UV7="TEXCOORD_7";var c1=(s9(nk=function(e,t){var n;return(n=cZ.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 c0(e,s5(n)),n},cZ),(nG=nk.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}},nG.getPositions=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._positions},nG.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},nG.getNormals=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._normals},nG.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},nG.getColors=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._colors},nG.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},nG.getBoneWeights=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneWeights},nG.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},nG.getBoneIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneIndices},nG.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},nG.getTangents=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._tangents},nG.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]."}},nG.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]."},nG.setIndices=function(t){this._indices!==t&&(this._indices=t,lr(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:lr(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:lr(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},nG.getIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._indices},nG.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[sl.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[sl.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[sl.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[sl.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[sl.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[sl.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[sl.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[sl.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[sl.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[sl.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[sl.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[sl.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[sl.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[sl.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},nG.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 c$(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},nG.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])},nG.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},nG.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},nG.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},nG.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 cY(this._engine,e.BufferBindFlag.VertexBuffer,a,o);this._setVertexBufferBinding(0,new c$(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 cQ(_,this._indicesFormat));else{null==_||_.destroy();var f=new cY(this._engine,e.BufferBindFlag.IndexBuffer,d);this._setIndexBufferBinding(new cQ(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())},nG.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=nk._tempVec0,o=nk._tempVec1,s=nk._tempVec2,l=nk._tempVec3,c=nk._tempVec4,u=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new s1,d[_]=new sW;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];sW.subtract(y,v,a),sW.subtract(x,v,o);var w=C.x-T.x,A=S.x-T.x,E=C.y-T.y,M=S.y-T.y,b=1/(w*M-A*E);sW.scale(a,M*b,s),sW.scale(o,E*b,c),sW.subtract(s,c,s),sW.scale(o,w*b,l),sW.scale(a,A*b,c),sW.subtract(l,c,l);var R=h[p];R.set(R.x+s.x,R.y+s.y,R.z+s.z,1),(R=h[g]).set(R.x+s.x,R.y+s.y,R.z+s.z,1),(R=h[m]).set(R.x+s.x,R.y+s.y,R.z+s.z,1),d[p].add(l),d[g].add(l),d[m].add(l)}for(var F=0;F<i;F++){var P=n[F],L=d[F],D=h[F];s.set(D.x,D.y,D.z),sW.cross(s,L,c);var I=sW.dot(c,P)>0?1:-1;sW.scale(P,sW.dot(s,P),c),sW.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,I)}this.setTangents(h)},nG._onDestroy=function(){cZ.prototype._onDestroy.call(this),this._readable&&this._releaseCache()},nG._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[sl.Position]&&this._insertVertexAttribute(sl.Position),this._normals&&!r[sl.Normal]&&this._insertVertexAttribute(sl.Normal),this._colors&&!r[sl.Color]&&this._insertVertexAttribute(sl.Color),this._boneWeights&&!r[sl.BoneWeight]&&this._insertVertexAttribute(sl.BoneWeight),this._boneIndices&&!r[sl.BoneIndex]&&this._insertVertexAttribute(sl.BoneIndex),this._tangents&&!r[sl.Tangent]&&this._insertVertexAttribute(sl.Tangent),this._uv&&!r[sl.UV]&&this._insertVertexAttribute(sl.UV),this._uv1&&!r[sl.UV1]&&this._insertVertexAttribute(sl.UV1),this._uv2&&!r[sl.UV2]&&this._insertVertexAttribute(sl.UV2),this._uv3&&!r[sl.UV3]&&this._insertVertexAttribute(sl.UV3),this._uv4&&!r[sl.UV4]&&this._insertVertexAttribute(sl.UV4),this._uv5&&!r[sl.UV5]&&this._insertVertexAttribute(sl.UV5),this._uv6&&!r[sl.UV6]&&this._insertVertexAttribute(sl.UV6),this._uv7&&!r[sl.UV7]&&this._insertVertexAttribute(sl.UV7)},nG._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)},nG._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 w=v*S+C,A=i[S];A&&(e[w]=A.x,e[w+1]=A.y,e[w+2]=A.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 R=0;R<n;R++){var F=v*R+C,P=s[R];P&&(e[F]=P.x,e[F+1]=P.y,e[F+2]=P.z,e[F+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},nG._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 cq(e,a,t,0)),this._bufferStrides[0]=a+n},nG._getAttributeFormat=function(t){switch(t){case sl.Position:case sl.Normal:return e.VertexElementFormat.Vector3;case sl.Color:case sl.BoneWeight:return e.VertexElementFormat.Vector4;case sl.BoneIndex:return e.VertexElementFormat.UByte4;case sl.Tangent:return e.VertexElementFormat.Vector4;case sl.UV:case sl.UV1:case sl.UV2:case sl.UV3:case sl.UV4:case sl.UV5:case sl.UV6:case sl.UV7:return e.VertexElementFormat.Vector2}},nG._getAttributeByteLength=function(e){switch(e){case sl.Position:case sl.Normal:return 12;case sl.Color:case sl.BoneWeight:return 16;case sl.BoneIndex:return 4;case sl.Tangent:return 16;case sl.UV:case sl.UV1:case sl.UV2:case sl.UV3:case sl.UV4:case sl.UV5:case sl.UV6:case sl.UV7:return 8}},nG._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()},s6(nk,[{key:"readable",get:function(){return this._readable}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[sl.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}}]),nk);c1._tempVec0=new sW,c1._tempVec1=new sW,c1._tempVec2=new sW,c1._tempVec3=new sW,c1._tempVec4=new sW,(nH=sc||(sc={}))[nH.Position=1]="Position",nH[nH.Normal=2]="Normal",nH[nH.Color=4]="Color",nH[nH.Tangent=8]="Tangent",nH[nH.BoneWeight=16]="BoneWeight",nH[nH.BoneIndex=32]="BoneIndex",nH[nH.UV=64]="UV",nH[nH.UV1=128]="UV1",nH[nH.UV2=256]="UV2",nH[nH.UV3=512]="UV3",nH[nH.UV4=1024]="UV4",nH[nH.UV5=2048]="UV5",nH[nH.UV6=4096]="UV6",nH[nH.UV7=8192]="UV7",nH[nH.All=65535]="All";var c2=(s9(nW=function(e){var t;return(t=lc.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},lc),nW),c3=(nX=e.Renderer,s9(nK=function(e){var t;return(t=nX.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(s5(t)),t},nX),(nj=nK.prototype)._onDestroy=function(){nX.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},nj._cloneTo=function(e){nX.prototype._cloneTo.call(this,e),e.mesh=this._mesh},nj._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sK.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},nj._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(nK._uvMacro),n.disableMacro(nK._uv1Macro),n.disableMacro(nK._normalMacro),n.disableMacro(nK._tangentMacro),n.disableMacro(nK._enableVertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(nK._uvMacro);break;case"TEXCOORD_1":n.enableMacro(nK._uv1Macro);break;case"NORMAL":n.enableMacro(nK._normalMacro);break;case"TANGENT":n.enableMacro(nK._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&n.enableMacro(nK._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 lv.error("mesh is null.")},nj._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},nj._onMeshChanged=function(e){e&ss.Bounds&&(this._dirtyUpdateFlag|=sr.WorldVolume),e&ss.VertexElements&&(this._dirtyUpdateFlag|=2)},s6(nK,[{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)}}]),nK);c3._uvMacro=cm.getByName("RENDERER_HAS_UV"),c3._uv1Macro=cm.getByName("RENDERER_HAS_UV1"),c3._normalMacro=cm.getByName("RENDERER_HAS_NORMAL"),c3._tangentMacro=cm.getByName("RENDERER_HAS_TANGENT"),c3._enableVertexColorMacro=cm.getByName("RENDERER_ENABLE_VERTEXCOLOR"),ln([li],c3.prototype,"_mesh",void 0),ln([li],c3.prototype,"_onMeshChanged",null),(nq=su||(su={}))[nq.VertexElementMacro=2]="VertexElementMacro",nq[nq.All=3]="All";var c4=(s9(nY=function(e){(t=c3.call(this,e)||this)._hasInitSkin=!1,t._jointDataCreateCache=new s0(-1,-1),t._localBounds=new sK,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(s5(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},c3),(nQ=nY.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?lG._floatMatrixMultiply(o.transform.worldMatrix,t[a].elements,0,i,s):i.set(t[a].elements,s),lG._floatMatrixMultiply(n,i,s,i,s)}},nQ._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 lT(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(nY._jointSamplerProperty,this._jointTexture)):lv.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(nY._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)},nQ._onDestroy=function(){var e,t;c3.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._jointEntities&&(this._jointEntities.length=0,this._jointEntities=null)},nQ._cloneTo=function(e){c3.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},nQ._registerEntityTransformListener=function(){},nQ._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sK.transform(t,n,e)}else c3.prototype._updateBounds.call(this,e)},nQ._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)sK.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var c=new sZ(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?(sZ.multiplyScalar(c,1/u,c),sK.transform(this._mesh.bounds,c,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("RENDERER_HAS_SKIN"),t.setInt(nY._jointCountProperty,r)):t.disableMacro("RENDERER_HAS_SKIN")}},nQ._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?(sZ.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},nQ._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},nQ._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)},nQ._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=sr.WorldVolume},s6(nY,[{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|=sr.WorldVolume}}]),nY);c4._jointCountProperty=lB.getByName("renderer_JointCount"),c4._jointSamplerProperty=lB.getByName("renderer_JointSampler"),c4._jointMatrixProperty=lB.getByName("renderer_JointMatrix"),ln([li],c4.prototype,"_hasInitSkin",void 0),ln([li],c4.prototype,"_jointDataCreateCache",void 0),ln([li],c4.prototype,"_blendShapeWeights",void 0),ln([li],c4.prototype,"_maxVertexUniformVectors",void 0),ln([li],c4.prototype,"_rootBone",void 0),ln([li],c4.prototype,"_localBounds",void 0),ln([li],c4.prototype,"_jointMatrices",void 0),ln([li],c4.prototype,"_jointTexture",void 0),ln([li],c4.prototype,"_jointEntities",void 0),ln([li],c4.prototype,"_condensedBlendShapeWeights",void 0),ln([li],c4.prototype,"_onLocalBoundsChanged",null);var c5=(s9(nJ=function(e,t){var n;return(n=lh.call(this,e)||this).primitiveInfo=t,n},lh),nJ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:ui._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0);break;case 1:ui._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0);break;case 2:ui._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0);break;case 3:ui._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 4:ui._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0);break;case 5:ui._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 6:ui._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0)}},nJ);(nZ=sh||(sh={}))[nZ.Sphere=0]="Sphere",nZ[nZ.Cuboid=1]="Cuboid",nZ[nZ.Plane=2]="Plane",nZ[nZ.Cylinder=3]="Cylinder",nZ[nZ.Torus=4]="Torus",nZ[nZ.Cone=5]="Cone",nZ[nZ.Capsule=6]="Capsule";var c8=function(e,t){this.type=e,this.noLongerAccessible=t},c6=(s9(n$=function(e,t,n){var r;return(r=c8.call(this,0,n)||this).radius=e,r.segments=t,r},c8),n$),c7=(s9(n0=function(e,t,n,r){var i;return(i=c8.call(this,1,r)||this).width=e,i.height=t,i.depth=n,i},c8),n0),c9=(s9(n1=function(e,t,n,r,i){var a;return(a=c8.call(this,2,i)||this).width=e,a.height=t,a.horizontalSegments=n,a.verticalSegments=r,a},c8),n1),ue=(s9(n2=function(e,t,n,r,i,a){var o;return(o=c8.call(this,3,a)||this).radiusTop=e,o.radiusBottom=t,o.height=n,o.radialSegments=r,o.heightSegments=i,o},c8),n2),ut=(s9(n3=function(e,t,n,r,i,a){var o;return(o=c8.call(this,4,a)||this).radius=e,o.tubeRadius=t,o.radialSegments=n,o.tubularSegments=r,o.arc=i,o},c8),n3),un=(s9(n4=function(e,t,n,r,i){var a;return(a=c8.call(this,5,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},c8),n4),ur=(s9(n5=function(e,t,n,r,i){var a;return(a=c8.call(this,6,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},c8),n5),ui=((n8=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 c1(e);return n8._setSphereData(i,t,n,r,!1),e.resourceManager.addContentRestorer(new c5(i,new c6(t,n,r))),i},n8.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 c1(e);return n8._setCuboidData(a,t,n,r,i,!1),e.resourceManager.addContentRestorer(new c5(a,new c7(t,n,r,i))),a},n8.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 c1(e);return n8._setPlaneData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new c9(t,n,r,i,a))),o},n8.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 c1(e);return n8._setCylinderData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new c5(s,new ue(t,n,r,i,a,o))),s},n8.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 c1(e);return n8._setTorusData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new c5(s,new ut(t,n,r,i,a,o))),s},n8.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 c1(e);return n8._setConeData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new un(t,n,r,i,a))),o},n8.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 c1(e);return n8._setCapsuleData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new c5(o,new ur(t,n,r,i,a))),o},n8._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=n8._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),w=t*Math.sin(y)*T;_[g]=new sW(C,S,w),f[g]=new sW(C,S,w),p[g]=new s0(m,v)}for(var A=0,E=0;E<s;++E){var M=E%n,b=(E*d|0)*a+M,R=b+1,F=b+a,P=F+1;l[A++]=R,l[A++]=b,l[A++]=P,l[A++]=b,l[A++]=F,l[A++]=P}if(!i){var L=e.bounds;L.min.set(-t,-t,-t),L.max.set(t,t,t)}n8._initialize(e,_,f,p,l,r,i)},n8._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 sW(-o,s,-l),c[1]=new sW(o,s,-l),c[2]=new sW(o,s,l),c[3]=new sW(-o,s,l),u[0]=new sW(0,1,0),u[1]=new sW(0,1,0),u[2]=new sW(0,1,0),u[3]=new sW(0,1,0),h[0]=new s0(0,0),h[1]=new s0(1,0),h[2]=new s0(1,1),h[3]=new s0(0,1),c[4]=new sW(-o,-s,-l),c[5]=new sW(o,-s,-l),c[6]=new sW(o,-s,l),c[7]=new sW(-o,-s,l),u[4]=new sW(0,-1,0),u[5]=new sW(0,-1,0),u[6]=new sW(0,-1,0),u[7]=new sW(0,-1,0),h[4]=new s0(0,1),h[5]=new s0(1,1),h[6]=new s0(1,0),h[7]=new s0(0,0),c[8]=new sW(-o,s,-l),c[9]=new sW(-o,s,l),c[10]=new sW(-o,-s,l),c[11]=new sW(-o,-s,-l),u[8]=new sW(-1,0,0),u[9]=new sW(-1,0,0),u[10]=new sW(-1,0,0),u[11]=new sW(-1,0,0),h[8]=new s0(0,0),h[9]=new s0(1,0),h[10]=new s0(1,1),h[11]=new s0(0,1),c[12]=new sW(o,s,-l),c[13]=new sW(o,s,l),c[14]=new sW(o,-s,l),c[15]=new sW(o,-s,-l),u[12]=new sW(1,0,0),u[13]=new sW(1,0,0),u[14]=new sW(1,0,0),u[15]=new sW(1,0,0),h[12]=new s0(1,0),h[13]=new s0(0,0),h[14]=new s0(0,1),h[15]=new s0(1,1),c[16]=new sW(-o,s,l),c[17]=new sW(o,s,l),c[18]=new sW(o,-s,l),c[19]=new sW(-o,-s,l),u[16]=new sW(0,0,1),u[17]=new sW(0,0,1),u[18]=new sW(0,0,1),u[19]=new sW(0,0,1),h[16]=new s0(0,0),h[17]=new s0(1,0),h[18]=new s0(1,1),h[19]=new s0(0,1),c[20]=new sW(-o,s,-l),c[21]=new sW(o,s,-l),c[22]=new sW(o,-s,-l),c[23]=new sW(-o,-s,-l),u[20]=new sW(0,0,-1),u[21]=new sW(0,0,-1),u[22]=new sW(0,0,-1),u[23]=new sW(0,0,-1),h[20]=new s0(1,0),h[21]=new s0(0,0),h[22]=new s0(0,1),h[23]=new s0(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)}n8._initialize(e,c,u,h,d,i,a)},n8._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=n8._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,w=C*g|0;y[C]=new sW(S*h-c,0,w*d-u),x[C]=new sW(0,1,0),T[C]=new s0(S*m,w*v)}for(var A=0,E=0;E<f;++E){var M=E%r,b=(E*m|0)*s+M,R=b+1,F=b+s,P=F+1;p[A++]=b,p[A++]=F,p[A++]=R,p[A++]=F,p[A++]=P,p[A++]=R}if(!o){var L=e.bounds;L.min.set(-c,0,-u),L.max.set(c,0,u)}n8._initialize(e,y,x,T,p,a,o)},n8._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=n8._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,w=Math.PI,A=2*Math.PI,E=n-t,M=E/r,b=E/a,R=0;R<d;++R){var F=R%l,P=R*m|0,L=F*v,D=P*y,I=w+L*A,B=Math.sin(I),N=Math.cos(I),V=n-P*b,O=V*B,U=P*h-u,z=V*N;x[R]=new sW(O,U,z),T[R]=new sW(B,M,N),C[R]=new s0(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 sW(0,-u,0),T[d]=new sW(0,-1,0),C[d]=new s0(.5,.5),x[d+1]=new sW(0,u,0),T[d+1]=new sW(0,1,0),C[d+1]=new s0(.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 sW($,-u,ee),T[j]=new sW(0,-1,0),C[j++]=new s0($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[j]=new sW($,u,ee),T[j]=new sW(0,1,0),C[j++]=new s0($*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)}n8._initialize(e,x,T,C,g,o,s)},n8._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=n8._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 sW((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var w=t*T,A=t*C;d[f]=new sW(S.x-w,S.y-A,S.z).normalize(),_[f++]=new s0(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,R=(i+1)*(E-1)+M-1,F=(i+1)*(E-1)+M,P=(i+1)*E+M;u[f++]=b,u[f++]=R,u[f++]=P,u[f++]=R,u[f++]=F,u[f++]=P}if(!s){var L=e.bounds,D=t+n;L.min.set(-D,-D,-n),L.max.set(D,D,n)}n8._initialize(e,h,d,_,u,o,s)},n8._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=n8._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,w=t/n,A=0;A<h;++A){var E=A%s,M=A*p|0,b=E*g,R=M*m,F=C+b*S,P=Math.sin(F),L=Math.cos(F),D=t-M*t,I=D*P,B=M*u-c,N=D*L;v[A]=new sW(I,B,N),y[A]=new sW(P,w,L),x[A]=new s0(b,1-R)}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 sW(0,-c,0),y[h]=new sW(0,-1,0),x[h]=new s0(.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 sW(j,-c,q),y[H]=new sW(0,-1,0),x[H++]=new s0(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)}n8._initialize(e,v,y,x,f,a,o)},n8._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=n8._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),w=Array(p),A=0,E=0;E<h;++E){var M=E%s,b=E*m|0,R=M*v,F=b*y,P=x+R*T,L=Math.sin(P),D=Math.cos(P);C[E]=new sW(t*L,b*u-c,t*D),S[E]=new sW(L,0,D),w[E]=new s0(R,1-F)}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[A++]=V,g[A++]=O,g[A++]=N,g[A++]=V,g[A++]=U,g[A++]=O}if(n8._createCapsuleCap(t,n,r,T,h,1,C,S,w,g,A),n8._createCapsuleCap(t,n,r,-T,h+_,-1,C,S,w,g,A+6*f),!o){var z=e.bounds;z.min.set(-t,-t-c,-t),z.max.set(t,t+c,t)}n8._initialize(e,C,S,w,g,a,o)},n8._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)},n8._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},n8._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,w=e*Math.cos(T)*a+d,A=e*Math.sin(x)*C,E=m+i;o[E]=new sW(S,w,A),s[E]=new sW(S,w-d,A),l[E]=new s0(v,y)}for(var M=0;M<f;++M){var b=M%n,R=(M*g|0)*h+b+i,F=R+1,P=R+h,L=P+1;c[u++]=F,c[u++]=R,c[u++]=L,c[u++]=R,c[u++]=P,c[u++]=L}},n8),ua=(s9(n6=function(){return cZ.apply(this,arguments)},cZ),(n7=n6.prototype).setVertexElements=function(e){this._setVertexElements(e)},n7.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 c$(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},n7.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])},n7.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new cQ(e,t))),this._setIndexBufferBinding(n)},s6(n6,[{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}}]),n6),uo=((n9=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new lj,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},s6(n9,[{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)}}]),n9);(re=sd||(sd={}))[re.Position=1]="Position",re[re.Normal=2]="Normal",re[re.Tangent=4]="Tangent",re[re.All=7]="All";var us=((rn=(rt=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new lj,this._dataChangeManager=new lj,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 uo(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},rn.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()},rn._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},rn._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(sd.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},rn._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))},rn._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},s6(rt,[{key:"frames",get:function(){return this._frames}}]),rt),ul=((ri=(rr=function(e){this._subMeshPool=new cM(cJ),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)},ri._initMeshes=function(e){var t=rr.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)},ri.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!rr._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},ri.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},ri.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},ri._drawSubElement=function(e,t){var n=e.data.verticesData.vertexCount;this._vertexCount+n>rr.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=n,this._batchedQueue[this._elementCount++]=e},ri._createMesh=function(t,n){var r=rr.MAX_VERTEX_COUNT,i=new ua(t,"BufferMesh"+n);i.isGCIgnored=!0;var a=[],o=this.createVertexElements(a),s=this._vertexBuffers[n]=new cY(t,e.BufferBindFlag.VertexBuffer,4*r*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[n]=new cY(t,e.BufferBindFlag.IndexBuffer,6*r,e.BufferUsage.Dynamic);return l.isGCIgnored=!0,i.setVertexBufferBinding(s,o),i.setIndexBufferBinding(l,e.IndexFormat.UInt16),i.setVertexElements(a),i},ri._updateData=function(e){var t=this._meshes,n=this._flushId;!rr._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)},ri._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},rr);ul._disableBatchTag=cD.getByName("spriteDisableBatching"),ul.MAX_VERTEX_COUNT=4096,ul._canUploadSameBuffer=!0;var uc=(s9(ra=function(){return ul.apply(this,arguments)},ul),(ro=ra.prototype).createVertexElements=function(t){return t[0]=new cq("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},ro.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=cK._textureProperty,s=cK._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},ro.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},ro.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=cz._compileMacros;cv.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)}},ra),uu=((rl=(rs=function(e){this._preMaskLayer=0,this._batcher=new uc(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},rl.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t))},rl.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},rl.destroy=function(){this._batcher.destroy(),this._batcher=null},rl._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)}}}},rs),uh=(s9(rc=function(){var e;return(e=cb.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},cb),(ru=rc.prototype).set=function(e,t,n){this.component=e,this.material=t,this.verticesData=n},ru.dispose=function(){this.component=this.material=this.verticesData=null},rc),ud=(s9(rh=function(){var e;return(e=cb.call(this)||this).multiRenderData=!1,e},cb),(rd=rh.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},rd.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},rh),u_=(s9(r_=function(){var e;return(e=cb.call(this)||this).charsData=[],e.multiRenderData=!0,e},cb),r_.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},r_);e.BackgroundMode=void 0,(rf=e.BackgroundMode||(e.BackgroundMode={}))[rf.SolidColor=0]="SolidColor",rf[rf.Sky=1]="Sky",rf[rf.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(rp=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[rp.AspectFitWidth=0]="AspectFitWidth",rp[rp.AspectFitHeight=1]="AspectFitHeight",rp[rp.Fill=2]="Fill";var uf=((rm=(rg=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},rm._render=function(e){var t=this.material,n=this.mesh;if(!t){lv.warn("The material of sky is not defined.");return}if(!n){lv.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=rg._viewProjMatrix,h=rg._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(sH.degreeToRadian(o)/2);h.elements[0]=m/a,h.elements[5]=m,sZ.multiply(h,u,u);var v=l.getMatrix(ck.vpMatrixProperty);l.setMatrix(ck.vpMatrixProperty,u);var y=cz._compileMacros;cv.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(ck.vpMatrixProperty,v)},s6(rg,[{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}}}]),rg);uf._epsilon=1e-6,uf._viewProjMatrix=new sZ,uf._projectionMatrix=new sZ(1,0,0,0,0,1,0,0,0,0,uf._epsilon-1,-1,0,0,0,0);var up=((ry=(rv=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new s2(.25,.25,.25,1),this.sky=new uf,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()},ry._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},ry._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)}},ry._createPlane=function(e){var t=new c1(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 sW,i[a]=new s0(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},s6(rv,[{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())}}]),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 ug=((rS=(rC=function(){this._diffuseSolidColor=new s2(.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(rC._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(rC._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(rC._specularIntensityProperty,this._specularIntensity),t.setFloatArray(rC._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},rS._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},rS._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(rC._shMacro):t.disableMacro(rC._shMacro)},rS._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(rC._specularTextureProperty,this._specularTexture),e.setFloat(rC._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(rC._specularMacro)):e.disableMacro(rC._specularMacro)},rS._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(rC._decodeRGBMMacro):e.disableMacro(rC._decodeRGBMMacro)},rS._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]},s6(rC,[{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(rC._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(rC._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(rC._specularIntensityProperty,e)}}]),rC);ug._shMacro=cm.getByName("SCENE_USE_SH"),ug._specularMacro=cm.getByName("SCENE_USE_SPECULAR_ENV"),ug._decodeRGBMMacro=cm.getByName("SCENE_IS_DECODE_ENV_RGBM"),ug._diffuseColorProperty=lB.getByName("scene_EnvMapLight.diffuse"),ug._diffuseSHProperty=lB.getByName("scene_EnvSH"),ug._diffuseIntensityProperty=lB.getByName("scene_EnvMapLight.diffuseIntensity"),ug._specularTextureProperty=lB.getByName("scene_EnvSpecularSampler"),ug._specularIntensityProperty=lB.getByName("scene_EnvMapLight.specularIntensity"),ug._mipLevelProperty=lB.getByName("scene_EnvMapLight.mipMapLevel");var um=function(t){function n(r,i){(a=t.call(this,r)||this).castShadows=!0,a.shadowResolution=e.ShadowResolution.Medium,a.shadowTwoCascadeSplits=1/3,a.shadowFourCascadeSplits=new sW(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new cv,a._rootEntities=[],a._background=new up(a._engine),a._shaderData=new cy(st.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new s2(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new s1,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new ug,r.sceneManager._allScenes.push(s5(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}s9(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new lQ(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),lQ._traverseSetOwnerScene(t,this)):r||this._addToRootEntityList(n,t),this._isActiveInEngine?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive()},r.removeRootEntity=function(e){e._isRoot&&e._scene==this&&(this._removeFromEntityList(e),e._isRoot=!1,this._isActiveInEngine&&e._isActiveInHierarchy&&e._processInActive(),lQ._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=lQ._findChildByName(i,t[a]));++a);return i}}return null},r.destroy=function(){if(!this._destroyed){this._destroy();var e=this.engine.sceneManager._allScenes;e.splice(e.indexOf(this),1)}},r._attachRenderCamera=function(e){-1===this._activeCameras.indexOf(e)?this._activeCameras.push(e):lv.warn("Camera already attached.")},r._detachRenderCamera=function(e){var t=this._activeCameras.indexOf(e);-1!==t&&this._activeCameras.splice(t,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():r._processInActive())}},r._updateShaderData=function(){var t=this.shaderData,r=this._engine,i=r._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}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"),cv.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._destroy=function(){for(this._isActiveInEngine&&(this._engine.sceneManager.activeScene=null);this.rootEntitiesCount>0;)this._rootEntities[0].destroy();this._activeCameras.length=0,this.background.destroy(),this.shaderData._addReferCount(-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)},s6(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){lv.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}(lc);um._fogColorProperty=lB.getByName("scene_FogColor"),um._fogParamsProperty=lB.getByName("scene_FogParams"),um._sunlightColorProperty=lB.getByName("scene_SunlightColor"),um._sunlightDirectionProperty=lB.getByName("scene_SunlightDirection");var uv=((rA=(rw=function(e){this.engine=e,this._allScenes=[]}).prototype).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._activeScene;n.activeScene=e,r&&t&&r.destroy()}),r},rA.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},rA._destroyAllScene=function(){for(var e=this._allScenes,t=0,n=e.length;t<n;t++)e[t]._destroy();e.length=0},s6(rw,[{key:"activeScene",get:function(){return this._activeScene},set:function(e){var t=this._activeScene;t!==e&&(t&&t._processActive(!1),e&&e._processActive(!0),this._activeScene=e)}}]),rw),uy="#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}",ux=((rE=function(){}).init=function(){var t={pipelineStage:e.PipelineStage.ShadowCaster},n={pipelineStage:e.PipelineStage.Forward},r=new cO("#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);cz.create("blinn-phong",[new cO("#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]),cz.create("pbr",[new cO(uy,"#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]),cz.create("pbr-specular",[new cO(uy,"#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]),cz.create("unlit",[new cO("#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]),cz.create("skybox",[new cO("#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)]),cz.create("SkyProcedural",[new cO("#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)]),cz.create("particle-shader",[new cO("#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)]),cz.create("SpriteMask",[new cO("#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)]),cz.create("Sprite",[new cO("#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)]),cz.create("background-texture",[new cO("#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)])},rE),uT=((rb=(rM=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},rb.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rb._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)},rM);ux.init();var uC=function(t){function n(r,i,a){if((o=t.call(this)||this)._lightManager=new cg,o._componentsManager=new lO,o._lastRenderState=new cA,o._renderElementPool=new cM(cG),o._meshRenderDataPool=new cM(cR),o._spriteRenderDataPool=new cM(ud),o._spriteMaskRenderDataPool=new cM(uh),o._textRenderDataPool=new cM(u_),o._renderContext=new ck,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new cv,o._settings={},o._resourceManager=new lR(s5(o)),o._sceneManager=new uv(s5(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new lN,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waitingDestroy=!1,o._isDeviceLost=!1,o._waitingGC=!1,o._animate=function(){o._vSyncCount?(o._requestId=requestAnimationFrame(o._animate),o._vSyncCounter++%o._vSyncCount==0&&(o.update(),o._vSyncCounter=1)):(o._timeoutId=window.setTimeout(o._animate,o._targetFrameInterval),o.update())},o._hardwareRenderer=i,o._hardwareRenderer.init(r,o._onDeviceLost.bind(s5(o)),o._onDeviceRestored.bind(s5(o))),o.physicsManager=new l1(s5(o)),o._canvas=r,o._sceneManager.activeScene=new um(s5(o),"DefaultScene"),o._spriteMaskManager=new uu(s5(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=lM.createFromOS(s5(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new ch(s5(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var o,s=new lT(s5(o),1,1,e.TextureFormat.Depth16,!1);s.isGCIgnored=!0,o._depthTexture2D=s}else o._macroCollection.enable(n._noDepthTextureMacro);var l=new cE(s5(o),cz.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new lt(1,0,1.01,1)),o._magentaMaterial=l;var c=new cE(s5(o),cz.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}s9(n,t);var r=n.prototype;return r.createEntity=function(e){return new lQ(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._sceneManager._activeScene,r=this._componentsManager;n&&(n._activeCameras.sort(function(e,t){return e.priority-t.priority}),r.callScriptOnStart(),this.physicsManager._initialized&&this.physicsManager._update(t),this.inputManager._update(),r.callScriptOnUpdate(t),r.callAnimationUpdate(t),r.callScriptOnLateUpdate(t),this._render(n)),this._waitingDestroy||r.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._componentsManager.handlingInvalidScripts(),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 uT}return r},r._render=function(e){var t=e._activeCameras,n=this._componentsManager,r=this.time.deltaTime;if(n.callRendererOnUpdate(r),e._updateShaderData(),t.length>0)for(var i=0,a=t.length;i<a;i++){var o=t[i];n.callCameraOnBeginRender(o),o.render(),n.callCameraOnEndRender(o),this._hardwareRenderer._options._forceFlush&&this._hardwareRenderer.flush()}else lv.debug("NO active camera.")},r._initMagentaTextures=function(t){var n=new Uint8Array([255,0,255,255]),r=new lT(this,1,1,e.TextureFormat.R8G8B8A8,!1);r.setPixelBuffer(n),r.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s9(o=function(){return lh.call(this,r)},lh),o.prototype.restoreContent=function(){this.resource.setPixelBuffer(n)},o));for(var i=new lS(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(s9(s=function(){return lh.call(this,i)},lh),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 lC(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);c.setPixelBuffer(0,n),c.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(s9(l=function(){return lh.call(this,c)},lh),l.prototype.restoreContent=function(){this.resource.setPixelBuffer(0,n)},l)),this._magentaTexture2DArray=c}},r._pendingGC=function(){this._frameInProcess?this._waitingGC=!0:this._gc()},r._initialize=function(e){var t=this,n=e.physics;return n?n.initialize().then(function(){return t.physicsManager._initialize(n),t}):Promise.resolve(this)},r._createSpriteMaterial=function(){var t=new cE(this,cz.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 cE(this,cz.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 cA,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(),this._componentsManager._gc(),this._lightManager._gc(),this.physicsManager._gc()},s6(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}}]),n}(lI);uC._gammaMacro=cm.getByName("ENGINE_IS_COLORSPACE_GAMMA"),uC._noDepthTextureMacro=cm.getByName("ENGINE_NO_DEPTH_TEXTURE"),uC._pixelsPerUnit=100;var uS=(s9(rR=function(){var e;return e=lU.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},lU),(rF=rR.prototype).onAwake=function(){},rF.onEnable=function(){},rF.onStart=function(){},rF.onUpdate=function(e){},rF.onLateUpdate=function(e){},rF.onBeginRender=function(e){},rF.onEndRender=function(e){},rF.onPhysicsUpdate=function(){},rF.onTriggerEnter=function(e){},rF.onTriggerExit=function(e){},rF.onTriggerStay=function(e){},rF.onCollisionEnter=function(e){},rF.onCollisionExit=function(e){},rF.onCollisionStay=function(e){},rF.onPointerDown=function(e){},rF.onPointerUp=function(e){},rF.onPointerClick=function(e){},rF.onPointerEnter=function(e){},rF.onPointerExit=function(e){},rF.onPointerDrag=function(e){},rF.onDisable=function(){},rF.onDestroy=function(){},rF._onAwake=function(){this.onAwake()},rF._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rR.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)}this.onEnable()},rF._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rF._handlingInValid=function(){var e=this.engine._componentsManager,t=rR.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},rF._onDestroy=function(){lU.prototype._onDestroy.call(this),this._engine._componentsManager.addPendingDestroyScript(this)},rR);ln([li],uS.prototype,"_started",void 0),ln([li],uS.prototype,"_onStartIndex",void 0),ln([li],uS.prototype,"_onUpdateIndex",void 0),ln([li],uS.prototype,"_onLateUpdateIndex",void 0),ln([li],uS.prototype,"_onPhysicsUpdateIndex",void 0),ln([li],uS.prototype,"_onPreRenderIndex",void 0),ln([li],uS.prototype,"_onPostRenderIndex",void 0),ln([li],uS.prototype,"_entityScriptsIndex",void 0),ln([li],uS.prototype,"_waitHandlingInValid",void 0);var uw=(s9(rP=function(){return ul.apply(this,arguments)},ul),(rL=rP.prototype).createVertexElements=function(t){return t[0]=new cq("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new cq("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rL.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPass.getTagValue(ul._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},rL.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rL.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},rL.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=cz._compileMacros;cv.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=h.shaderPass._getShaderProgram(t,p);if(!g.isValid)return;_.shaderData.setTexture(rP._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(_)}},rL.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},rP);uw._textureProperty=lB.getByName("renderer_SpriteTexture");var uA=((rI=(rD=function(e){this.elements=[],this._initSpriteBatcher(e)}).prototype).pushRenderElement=function(e){this.elements.push(e)},rI.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 _=cz._compileMacros,f=d.component,p=d.material.destroyed?r._magentaMaterial:d.material,g=f.shaderData,m=p.shaderData;cv.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)}},rI.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},rI.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rI.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},rI._initSpriteBatcher=function(e){this._spriteBatcher=new uw(e)},rI._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=_)}},rI._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}},rD._compareFromNearToFar=function(e,t){return e.data.component.priority-t.data.component.priority||e.data.component._distanceForSort-t.data.component._distanceForSort},rD._compareFromFarToNear=function(e,t){return e.data.component.priority-t.data.component.priority||t.data.component._distanceForSort-e.data.component._distanceForSort},rD),uE=function(){this.position=new sW,this.isOrthographic=!1,this.viewMatrix=new sZ,this.projectionMatrix=new sZ,this.viewProjectionMatrix=new sZ,this.forward=new sW},uM=function(){this.virtualCamera=new uE,this.cullPlanes=[new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW),new sq(new sW)],this.splitBoundSphere=new sX(new sW,0)};(rB=s_||(s_={}))[rB.FarBottomLeft=0]="FarBottomLeft",rB[rB.FarTopLeft=1]="FarTopLeft",rB[rB.FarTopRight=2]="FarTopRight",rB[rB.FarBottomRight=3]="FarBottomRight",rB[rB.nearBottomLeft=4]="nearBottomLeft",rB[rB.nearTopLeft=5]="nearTopLeft",rB[rB.nearTopRight=6]="nearTopRight",rB[rB.nearBottomRight=7]="nearBottomRight",rB[rB.unknown=8]="unknown";var ub=((rN=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}},rN.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rN.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},rN.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&rN.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time.frameCount,n._prepareRender(e))},rN.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(sH.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,sW.scale(r,a,_),sW.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},rN.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=rN._frustumCorners,s=rN._backPlaneFaces,l=rN._frustumPlaneNeighbors,c=rN._frustumTwoPlaneCorners,u=rN._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=rN._adjustNearPlane,y=rN._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),sj.intersectionPointThreePlanes(v,g,p,o[7]),sj.intersectionPointThreePlanes(v,m,p,o[6]),sj.intersectionPointThreePlanes(v,m,f,o[5]),sj.intersectionPointThreePlanes(v,g,f,o[4]),sj.intersectionPointThreePlanes(y,g,p,o[3]),sj.intersectionPointThreePlanes(y,m,p,o[2]),sj.intersectionPointThreePlanes(y,m,f,o[1]),sj.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>sW.dot(C.normal,i)&&(h[x].copyFrom(C),s[x]=T,x++)}for(var S=x,w=0;w<x;w++)for(var A=s[w],E=l[A],M=0;M<4;M++){for(var b=E[M],R=!0,F=0;F<x;F++)if(b==s[F]){R=!1;break}if(R){var P=c[A][b],L=o[P[0]],D=o[P[1]];sW.add(L,i,u),sq.fromPoints(L,D,u,h[S++])}}a.cullPlaneCount=S},rN.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-rN.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sW.dot(c,e)*f)*p,m=Math.ceil(sW.dot(c,t)*f)*p,v=sW.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;sW.scale(n,u+i,x),sW.subtract(c,x,x),sZ.lookAt(x,c,e,T),sZ.ortho(-d,d,-d,d,0,2*u+i,C);var S=y.viewProjectionMatrix;sZ.multiply(C,T,S),lG._floatMatrixMultiply(rN._shadowMapCoordMatrix,S.elements,0,s,16*r)},rN.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},rN.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)},rN.applySliceTransform=function(e,t,n,r,i,a){var o=rN._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;lG._floatMatrixMultiply(o,a,d,a,d)},rN);ub._tempMatrix0=new sZ,ub._shadowMapCoordMatrix=new sZ(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),ub._frustumCorners=[new sW,new sW,new sW,new sW,new sW,new sW,new sW,new sW],ub._adjustNearPlane=new sq(new sW),ub._adjustFarPlane=new sq(new sW),ub._backPlaneFaces=[,,,,,],ub._edgePlanePoint2=new sW,ub._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]],ub._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]]],ub.atlasBorderSize=4;var uR=function(){function t(n){this._shadowMapSize=new s1,this._shadowBias=new s0,this._shadowSliceData=new uM,this._lightUp=new sW,this._lightSide=new sW,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sW,this._viewportOffsets=[new s0,new s0,new s0,new s0],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,_=r._componentsManager,f=r._hardwareRenderer,p=i.scene.shadowCascades,g=t._cascadesSplitDistance,m=o.splitBoundSphere,v=t._tempMatrix0,y=v.elements,x=this._lightUp,T=this._lightSide,C=o.virtualCamera.forward,S=r._lightManager._getSunLightIndex();if(-1!==S){var w=i.scene._sunLight,A=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(A);var E=this._getAvailableRenderTarget();f.activeRenderTarget(E,t._viewport,0),this._supportDepthTexture?f.clearRenderTarget(r,e.CameraClearFlags.Depth,null):f.clearRenderTarget(r,e.CameraClearFlags.All,t._clearColor),this._shadowInfos.x=w.shadowStrength,this._shadowInfos.z=S,sZ.rotationQuaternion(w.entity.transform.worldRotationQuaternion,v),T.set(y[0],y[1],y[2]),x.set(y[4],y[5],y[6]),C.set(-y[8],-y[9],-y[10]);var M=t._tempVector;M.copyFrom(i.entity.transform.worldForward);for(var b=this._shadowTileResolution,R=0;R<p;R++){if(ub.getBoundSphereByFrustum(g[R],g[R+1],i,M,o),ub.getDirectionLightShadowCullPlanes(i._frustum,g[R],i.nearClipPlane,C,o),ub.getDirectionalLightMatrices(x,T,C,R,w.shadowNearPlane,b,o,l),p>1){var F=this._shadowMapSize;ub.applySliceTransform(b,F.z,F.w,R,this._viewportOffsets[R],l)}this._updateSingleShadowCasterShaderData(w,o,n);var P=m.center,L=m.radius,D=4*R;s[D]=P.x,s[D+1]=P.y,s[D+2]=P.z,s[D+3]=L*L,u.clear(),h.clear(),d.clear();for(var I=_._renderers,B=I._elements,N=I.length-1;N>=0;--N)ub.shadowCullFrustum(n,w,B[N],o);if(u.elements.length||h.elements.length){u.sort(uA._compareFromNearToFar),h.sort(uA._compareFromNearToFar);var V=a[R],O=V.x,U=V.y;f.setGlobalDepthBias(1,1),f.viewport(O,U,b,b),f.scissor(O+1,U+1,b-2,b-2),r._renderCount++,u.render(i,e.Layer.Everything),h.render(i,e.Layer.Everything),f.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*sH.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 lT(t,i,a,n,!1)).wrapModeV=o.wrapModeU=e.TextureWrapMode.Clamp,t._hardwareRenderer._isWebGL2&&(o.depthCompareFunction=e.TextureDepthCompareFunction.Less),null==s||s._addReferCount(-1),(s=this._supportDepthTexture?this._renderTargets=new lx(t,i,a,null,o):this._renderTargets=new lx(t,i,a,o))._addReferCount(1)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=ub.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=ub.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=ub.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)}var l=this._renderTargets;l&&(l._addReferCount(-1),l.destroy(),this._renderTargets=null);var c=this._viewportOffsets,u=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:c[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:c[0].set(0,0),c[1].set(u,0);break;case e.ShadowCascadesMode.FourCascades:c[0].set(0,0),c[1].set(u,0),c[2].set(0,u),c[3].set(u,u)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;ub.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}();uR._lightShadowBiasProperty=lB.getByName("scene_ShadowBias"),uR._lightDirectionProperty=lB.getByName("scene_LightDirection"),uR._shadowMatricesProperty=lB.getByName("scene_ShadowMatrices"),uR._shadowMapSize=lB.getByName("scene_ShadowMapSize"),uR._shadowInfosProperty=lB.getByName("scene_ShadowInfo"),uR._shadowMapsProperty=lB.getByName("scene_ShadowMap"),uR._shadowSplitSpheresProperty=lB.getByName("scene_ShadowSplitSpheres"),uR._maxCascades=4,uR._cascadesSplitDistance=Array(uR._maxCascades+1),uR._viewport=new s1(0,0,1,1),uR._clearColor=new s2(1,1,1,1),uR._tempVector=new sW,uR._tempMatrix0=new sZ;var uF=0,uP=((rO=(rV=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uF++),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){},rO.preRender=function(e,t,n,r){},rO.postRender=function(e,t,n,r){},rV),uL=((rz=(rU=function(e){this._allSpriteMasks=new lV,this._lastCanvasSize=new s0,this._camera=e;var t=e.engine;this._opaqueQueue=new uA(t),this._alphaTestQueue=new uA(t),this._transparentQueue=new uA(t),this._cascadedShadowCaster=new uR(e),this._renderPassArray=[],this._defaultPass=new uP("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 uP(e,t,n,r,i);this._renderPassArray.push(a)}else lr(e,uP)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},rz.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):lr(e,uP)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},rz.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},rz.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},rz.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=rU._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=rU._forwardPipelineStageTagValue,this._callRender(t),s.sort(uA._compareFromNearToFar),l.sort(uA._compareFromNearToFar),c.sort(uA._compareFromFarToNear);for(var u=0,h=this._renderPassArray.length;u<h;u++)this._drawRenderPass(t,this._renderPassArray[u],a,n,r)},rz._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)},rz.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)},rz.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(ck.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)}}}},rz._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,cz._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},rz._callRender=function(e){for(var t=e.camera.engine,n=t._componentsManager._renderers,r=e.camera,i=n._elements,a=n.length-1;a>=0;--a){var o=i[a];r.cullingMask&o._entity.layer&&(!r.enableFrustumCulling||r._frustum.intersectsBox(o.bounds))&&(o._renderFrameCount=t.time.frameCount,o._prepareRender(e))}},s6(rU,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rU);uL._shadowCasterPipelineStageTagValue=e.PipelineStage.ShadowCaster,uL._forwardPipelineStageTagValue=e.PipelineStage.Forward;var uD=function(){};uD.tempVec4=new s1,uD.tempVec3=new sW,uD.tempVec2=new s0,e.Camera=(s9(rk=function(t){(n=lU.call(this,t)||this).priority=0,n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new cv,n._frustum=new sY,n._virtualCamera=new uE,n._replacementShader=null,n._replacementSubShaderTag=null,n._shaderData=new cy(st.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._viewport=new s1(0,0,1,1),n._inverseProjectionMatrix=new sZ,n._lastAspectSize=new s0(0,0),n._invViewProjMat=new sZ;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 uL(s5(n)),n.shaderData._addReferCount(1),n},lU),(rG=rk.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rG.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rG.worldToViewportPoint=function(e,t){var n=uD.tempVec3,r=uD.tempVec4;sW.transformCoordinate(e,this.viewMatrix,n),sW.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},rG.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},rG.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 sW.subtract(i,r,i),i.normalize(),t},rG.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},rG.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},rG.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rG.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rG.screenPointToRay=function(e,t){var n=uD.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rG.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;sZ.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(),cv.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,lv.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rG.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?cD.getByName(t):t},rG.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},rG._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rG._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rG._onDestroy=function(){var e;lU.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},rG._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rG._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uD.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sW.transformCoordinate(a,r,i),i},rG._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rG._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,sZ.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rG._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,sZ.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},s6(rk,[{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()}},{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;sZ.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;sZ.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else sZ.perspective(sH.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}}}]),(sf=rk)._inverseViewMatrixProperty=lB.getByName("camera_ViewInvMat"),sf._cameraPositionProperty=lB.getByName("camera_Position"),sf),ln([ls],e.Camera.prototype,"_frustum",void 0),ln([li],e.Camera.prototype,"_renderPipeline",void 0),ln([li],e.Camera.prototype,"_virtualCamera",void 0),ln([li],e.Camera.prototype,"_frustumViewChangeFlag",void 0),ln([li],e.Camera.prototype,"_transform",void 0),ln([li],e.Camera.prototype,"_isViewMatrixDirty",void 0),ln([li],e.Camera.prototype,"_isInvViewProjDirty",void 0),ln([ls],e.Camera.prototype,"_viewport",void 0),ln([ls],e.Camera.prototype,"_inverseProjectionMatrix",void 0),ln([ls],e.Camera.prototype,"_lastAspectSize",void 0),ln([ls],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=ln([lk(lq,e.DependentMode.CheckOnly)],e.Camera);var uI={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uB=1/0;function uN(e,t){return void 0===t&&(t={}),new lb(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:uB,t.type=null!=(l=t.type)?l:uI[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?uV:uO,_=new uU(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 uV(e,t){return new lb(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 uO(e,t){return new lb(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 uU=((rW=(rH=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()},rW.stop=function(){clearTimeout(this._timeoutId)},rW.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)})},rH),uz=((rX=function(e){this.useCache=e,this.request=uN}).registerClass=function(e,t){this._engineObjects[e]=t},rX.getClass=function(e){return this._engineObjects[e]},rX);uz._engineObjects={},e.AssetType=void 0,(rK=e.AssetType||(e.AssetType={})).Text="Text",rK.JSON="JSON",rK.Buffer="Buffer",rK.Texture2D="Texture2D",rK.TextureCube="TextureCube",rK.Material="Material",rK.Mesh="Mesh",rK.AnimationClip="AnimationClip",rK.AnimatorController="AnimatorController",rK.GLTF="GLTF",rK.KTX="KTX",rK.KTXCube="KTXCube",rK.Sprite="Sprite",rK.SpriteAtlas="SpriteAtlas",rK.Env="Environment",rK.Scene="Scene",rK.HDR="HDR",rK.Font="Font",rK.SourceFont="SourceFont",e.BlendMode=void 0,(rj=e.BlendMode||(e.BlendMode={}))[rj.Normal=0]="Normal",rj[rj.Additive=1]="Additive",e.RenderFace=void 0,(rq=e.RenderFace||(e.RenderFace={}))[rq.Front=0]="Front",rq[rq.Back=1]="Back",rq[rq.Double=2]="Double";var uk=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}s9(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},s6(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 cA),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}(cE);uk._baseTextureMacro=cm.getByName("MATERIAL_HAS_BASETEXTURE"),uk._normalTextureMacro=cm.getByName("MATERIAL_HAS_NORMALTEXTURE"),uk._emissiveTextureMacro=cm.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uk._transparentMacro=cm.getByName("MATERIAL_IS_TRANSPARENT"),uk._baseColorProp=lB.getByName("material_BaseColor"),uk._baseTextureProp=lB.getByName("material_BaseTexture"),uk._tilingOffsetProp=lB.getByName("material_TilingOffset"),uk._normalTextureProp=lB.getByName("material_NormalTexture"),uk._normalIntensityProp=lB.getByName("material_NormalIntensity"),uk._emissiveColorProp=lB.getByName("material_EmissiveColor"),uk._emissiveTextureProp=lB.getByName("material_EmissiveTexture"),uk._alphaCutoffProp=lB.getByName("material_AlphaCutoff"),uk._alphaCutoffMacro=cm.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uG=function(e){function t(n){var r,i=(r=e.call(this,n,cz.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s2(1,1,1,1)),i.setColor(t._specularColorProp,new s2(1,1,1,1)),i.setColor(t._emissiveColorProp,new s2(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new s1(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uk);uG._specularColorProp=lB.getByName("material_SpecularColor"),uG._shininessProp=lB.getByName("material_Shininess"),uG._specularTextureProp=lB.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(rY=e.TextureCoordinate||(e.TextureCoordinate={}))[rY.UV0=0]="UV0",rY[rY.UV1=1]="UV1",rY[rY.UV2=2]="UV2",rY[rY.UV3=3]="UV3",rY[rY.UV4=4]="UV4",rY[rY.UV5=5]="UV5",rY[rY.UV6=6]="UV6",rY[rY.UV7=7]="UV7";var uH=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 s2(1,1,1,1)),o.setColor(n._emissiveColorProp,new s2(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new s1(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 s9(n,t),s6(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&&lv.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}(uk);uH._occlusionTextureIntensityProp=lB.getByName("material_OcclusionIntensity"),uH._occlusionTextureCoordProp=lB.getByName("material_OcclusionTextureCoord"),uH._occlusionTextureProp=lB.getByName("material_OcclusionTexture"),uH._clearCoatProp=lB.getByName("material_ClearCoat"),uH._clearCoatTextureProp=lB.getByName("material_ClearCoatTexture"),uH._clearCoatRoughnessProp=lB.getByName("material_ClearCoatRoughness"),uH._clearCoatRoughnessTextureProp=lB.getByName("material_ClearCoatRoughnessTexture"),uH._clearCoatNormalTextureProp=lB.getByName("material_ClearCoatNormalTexture");var uW=function(e){function t(n){var r;return(r=e.call(this,n,cz.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uH);uW._metallicProp=lB.getByName("material_Metal"),uW._roughnessProp=lB.getByName("material_Roughness"),uW._roughnessMetallicTextureProp=lB.getByName("material_RoughnessMetallicTexture"),uW._iorProp=cz.getPropertyByName("material_IOR");var uX=function(e){function t(n){var r;return(r=e.call(this,n,cz.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new s2(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uH);uX._specularColorProp=lB.getByName("material_PBRSpecularColor"),uX._glossinessProp=lB.getByName("material_Glossiness"),uX._specularGlossinessTextureProp=lB.getByName("material_SpecularGlossinessTexture"),uX._specularGlossinessTextureMacro=cm.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uK=function(e){function t(n){var r,i=(r=e.call(this,n,cz.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s2(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new s1(1,1,0,0)),r}return s9(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},s6(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}(uk);e.TextHorizontalAlignment=void 0,(rQ=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rQ.Left=0]="Left",rQ[rQ.Center=1]="Center",rQ[rQ.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 uj=(s9(rZ=function(e){var t;return(t=lu.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},lu),(r$=rZ.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},r$.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},r$._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},r$._onDestroy=function(){lu.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},s6(rZ,[{key:"sprites",get:function(){return this._sprites}}]),rZ);e.SpriteDrawMode=void 0,(r0=e.SpriteDrawMode||(e.SpriteDrawMode={}))[r0.Simple=0]="Simple",r0[r0.Sliced=1]="Sliced",r0[r0.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(r1=e.SpriteTileMode||(e.SpriteTileMode={}))[r1.Continuous=0]="Continuous",r1[r1.Adaptive=1]="Adaptive";var uq=(s9(r2=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=lu.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new s0,new s0,new s0,new s0],o._uvs=[new s0,new s0,new s0,new s0],o._bounds=new sK,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new s3(0,0,1,1),o._atlasRegionOffset=new s1(0,0,0,0),o._region=new s3(0,0,1,1),o._pivot=new s0(.5,.5),o._border=new s1(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new lj,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},lu),(r3=r2.prototype).clone=function(){var e=new r2(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},r3._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},r3._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},r3._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},r3._addReferCount=function(e){var t;lu.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},r3._onDestroy=function(){lu.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},r3._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/uC._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},r3._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},r3._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,w=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+w*o)*y+h),e[3].set(d+u-Math.max(s-g,0)*v,Math.max(l-p,0)*y+h),this._dirtyUpdateFlag&=-3},r3._dispatchSpriteChange=function(e){switch(e){case sa.texture:this._dirtyUpdateFlag|=4;break;case sa.atlasRegionOffset:case sa.region:this._dirtyUpdateFlag|=7;break;case sa.atlasRegion:this._dirtyUpdateFlag|=6;break;case sa.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},s6(r2,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(sa.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.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(sa.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(sa.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=sH.clamp(e.x,0,1),n=sH.clamp(e.y,0,1);this._atlasRegion.set(t,n,sH.clamp(e.width,0,1-t),sH.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sa.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=sH.clamp(e.x,0,1),n=sH.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,sH.clamp(e.z,0,1-t),sH.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sa.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=sH.clamp(e.x,0,1),r=sH.clamp(e.y,0,1);t.set(n,r,sH.clamp(e.width,0,1-n),sH.clamp(e.height,0,1-r)),this._dispatchSpriteChange(sa.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sa.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(sa.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(sa.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=sH.clamp(e.x,0,1),r=sH.clamp(e.y,0,1);t.set(n,r,sH.clamp(e.z,0,1-n),sH.clamp(e.w,0,1-r)),this._dispatchSpriteChange(sa.border)}}]),r2);(r4=sp||(sp={}))[r4.positions=1]="positions",r4[r4.uvs=2]="uvs",r4[r4.automaticSize=4]="automaticSize",r4[r4.all=7]="all";var uY=((r5=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 sW),r.push(new s0);t.triangles=[]},r5.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,w=x*u.w;if(T+S>r){var A=r/(T+S);t=[y*f*A,T*A,T*A,r-y*(1-m)*A]}else t=[y*f,T,r-S,r-y*(1-m)];if(w+C>i){var E=i/(w+C);n=[x*p*E,C*E,C*E,i-x*(1-v)*E]}else n=[x*p,C,i-w,i-x*(1-v)];var M=e.sprite.pivot,b=M.x,R=M.y,F=e.width*b,P=e.height*R,L=uY._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]-F*D[0]-P*D[4],D[13]=I[13]-F*D[1]-P*D[5],D[14]=I[14]-F*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)},r5.updateUVs=function(e){},r5._worldMatrix=new sZ,r5);uY=ln([cH()],uY);var uQ=((r8=function(){}).resetData=function(e){var t;(t=e._verticesData).triangles||(t.triangles=[])},r8.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,w=t.width*C,A=t.height*S,E=uQ._worldMatrix,M=E.elements,b=t.entity.transform.worldMatrix.elements,R=t.flipX?-1:1,F=t.flipY?-1:1;n=M[0]=b[0]*R,r=M[1]=b[1]*R,i=M[2]=b[2]*R,a=M[4]=b[4]*F,o=M[5]=b[5]*F,s=M[6]=b[6]*F,M[8]=b[8],M[9]=b[9],M[10]=b[10];for(var P=M[12]=b[12]-w*M[0]-A*M[4],L=M[13]=b[13]-w*M[1]-A*M[5],D=M[14]=b[14]-w*M[2]-A*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 s0(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 sW(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 s0(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 sW(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 s0(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 sW(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 s0(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 sW(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)},r8.updateUVs=function(e){},r8._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(),w=S[0],A=S[1],E=S[2],M=S[3],b=e.width,R=e.height,F=b*p.x,P=b*p.z,L=F+P,D=b-L,I=R*p.w,B=R*p.y,N=I+B,V=R-N;if(L>=t?(h=3,c=0):D>sH.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>sH.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>ul.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*T),a.add(n*y),a.add(n*C),o.add(w.x),o.add(M.x),s.add(w.y),s.add(M.y),lv.warn("The number of vertices exceeds the upper limit("+ul.MAX_VERTEX_COUNT+").");return}switch(c){case 0:l=t/L,i.add(b*v*l),i.add(F*l),i.add(t-b*(1-T)*l),o.add(w.x),o.add(A.x),o.add(E.x),o.add(M.x);break;case 1:i.add(b*v),i.add(F),i.add(t-P),i.add(t-b*(1-T)),o.add(w.x),o.add(A.x),o.add(NaN),o.add(NaN),o.add(E.x),o.add(M.x);break;case 2:l=t/(L+_*D),i.add(b*v*l),i.add(F*l),o.add(w.x),o.add(A.x),o.add(A.x);for(var O=0,U=_-1;O<U;O++)i.add(F+(O+1)*D*l),o.add(E.x),o.add(A.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(R*y*l),a.add(B*l),a.add(n-R*(1-C)*l),s.add(w.y),s.add(A.y),s.add(E.y),s.add(M.y);break;case 1:a.add(R*y),a.add(B),a.add(n-I),a.add(n-R*(1-C)),s.add(w.y),s.add(A.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(R*y*l),a.add(B*l),s.add(w.y),s.add(A.y),s.add(A.y);for(var z=0,k=f-1;z<k;z++)a.add(B+(z+1)*V*l),s.add(E.y),s.add(A.y);a.add(n-I*l),a.add(n-R*(1-C)*l),s.add(E.y),s.add(E.y),s.add(M.y)}},r8._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],w=T[2],A=T[3],E=e.width,M=e.height,b=E*_.x,R=E*_.z,F=b+R,P=E-F,L=M*_.w,D=M*_.y,I=L+D,B=M-I;if(F>=t?(c=3,s=0):P>sH.zeroTolerance?(c=4+(0|(h=(t-F)/P)),s=2):(c=4,s=1),I>=n?(u=3,l=0):B>sH.zeroTolerance?(u=4+(0|(d=(n-I)/B)),l=2):(u=4,l=1),(c-1)*(u-1)*4>ul.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(A.x),o.add(C.y),o.add(A.y),lv.warn("The number of vertices exceeds the upper limit("+ul.MAX_VERTEX_COUNT+").");return}switch(s){case 0:var N=t/F;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(w.x),a.add(A.x);break;case 1:r.add(E*g),r.add(b),r.add(t-R),r.add(t-E*(1-y)),a.add(C.x),a.add(S.x),a.add(NaN),a.add(NaN),a.add(w.x),a.add(A.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(w.x),a.add(S.x);r.add(t-R),r.add(t-E*(1-y)),a.add((w.x-S.x)*(h-V)+S.x),a.add(w.x),a.add(A.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(w.y),o.add(A.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(w.y),o.add(A.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(w.y),o.add(S.y);i.add(n-L),i.add(n-M*(1-x)),o.add((w.y-S.y)*(d-z)+S.y),o.add(w.y),o.add(A.y)}},(sg=r8)._worldMatrix=new sZ,sg._posRow=new lV,sg._posColumn=new lV,sg._uvRow=new lV,sg._uvColumn=new lV,sg);uQ=ln([cH()],uQ),(r6=sm||(sm={}))[r6.Compressed=0]="Compressed",r6[r6.WithoutTiled=1]="WithoutTiled",r6[r6.WithTiled=2]="WithTiled";var uJ=(r7=e.Renderer,s9(r9=function(t){var n;return(n=r7.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new s2(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 cX(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(s5(n)),n},r7),(ie=r9.prototype)._cloneTo=function(e){r7.prototype._cloneTo.call(this,e),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},ie._updateShaderData=function(e){this._updateTransformShaderData(e,sZ._identity)},ie._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},ie._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&sr.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~sr.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)}},ie._onDestroy=function(){r7.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},ie._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},ie._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}},ie._onSpriteChange=function(t){switch(t){case sa.texture:this.shaderData.setTexture(r9._textureProperty,this.sprite.texture);break;case sa.size:var n=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=sr.WorldVolume:n===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=sr.WorldVolume);break;case sa.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case sa.region:case sa.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sa.atlasRegion:this._dirtyUpdateFlag|=2;break;case sa.pivot:this._dirtyUpdateFlag|=sr.WorldVolume}},s6(r9,[{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=cW;break;case e.SpriteDrawMode.Sliced:this._assembler=uY;break;case e.SpriteDrawMode.Tiled:this._assembler=uQ}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=sH.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(r9._textureProperty,e.texture)):this.shaderData.setTexture(r9._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|=sr.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|=sr.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=sr.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=sr.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())}}]),r9);uJ._textureProperty=lB.getByName("renderer_SpriteTexture"),ln([li],uJ.prototype,"_verticesData",void 0),ln([li],uJ.prototype,"_drawMode",void 0),ln([la],uJ.prototype,"_assembler",void 0),ln([la],uJ.prototype,"_tileMode",void 0),ln([la],uJ.prototype,"_tiledAdaptiveThreshold",void 0),ln([ls],uJ.prototype,"_color",void 0),ln([li],uJ.prototype,"_sprite",void 0),ln([li],uJ.prototype,"_automaticWidth",void 0),ln([li],uJ.prototype,"_automaticHeight",void 0),ln([la],uJ.prototype,"_customWidth",void 0),ln([la],uJ.prototype,"_customHeight",void 0),ln([la],uJ.prototype,"_flipX",void 0),ln([la],uJ.prototype,"_flipY",void 0),ln([la],uJ.prototype,"_maskLayer",void 0),ln([la],uJ.prototype,"_maskInteraction",void 0),ln([li],uJ.prototype,"_onSpriteChange",null),(it=sv||(sv={}))[it.UV=2]="UV",it[it.RenderData=3]="RenderData",it[it.AutomaticSize=4]="AutomaticSize",it[it.All=7]="All";var uZ=function e(){this.localPositions=new s1;var t=[new sW,new sW,new sW,new sW];this.renderData=new cX(4,t,null,e.triangles,null)};uZ.triangles=[0,2,1,2,0,3];var u$=((ii=(ir=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},ii.put=function(e){this._elements.push(e)},ir),u0=(ia=e.Renderer,s9(io=function(t){var n;return(n=ia.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new s2(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sK,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},ia),(is=io.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},is._onDestroy=function(){ia.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)io._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},is._cloneTo=function(e){ia.prototype._cloneTo.call(this,e),e.font=this._font,e._subFont=this._subFont},is._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},is._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},is._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},is._updateShaderData=function(e){this._updateTransformShaderData(e,sZ._identity)},is._updateBounds=function(e){sK.transform(this._localBounds,this._entity.transform.worldMatrix,e)},is._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)}},is._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}},is._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=lA.getNativeFontString(e.name,this.fontSize,this.fontStyle)},is._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=io._tempVec31.set(a,o,s),d=io._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];sW.scale(d,g.z-v,T),sW.add(x,T,T);var C=m[2];sW.scale(h,g.w-y,C),sW.add(x,C,m[3]),sW.add(T,C,C)}},is._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=uC._pixelsPerUnit,c=1/l,u=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?lA.measureTextWithWrap(this):lA.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=io._charRenderDataPool,x=.5*m,T=p.length,C=0,S=.5*m-v[0].ascent,w=.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-(w-S)*.5;break;case e.TextVerticalAlignment.Bottom:C=f-.5*d-x-w}for(var A=0,E=-1,M=Number.MAX_SAFE_INTEGER,b=Number.MAX_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,F=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=A++]||(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&&(F=Math.max(F,Q)),b=Math.min(b,J),N===B&&(M=Math.min(M,q)),R=Math.max(R,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(R,F,0));var Z=i.length;if(Z>A){for(var $=A;$<Z;++$)y.put(i[$]);i.length=A}u._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},is._onTransformChanged=function(e){ia.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},s6(io,[{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}}]),io);u0._charRenderDataPool=new u$(uZ,50),u0._tempVec30=new sW,u0._tempVec31=new sW,ln([la],u0.prototype,"_subFont",void 0),ln([li],u0.prototype,"_charRenderDatas",void 0),ln([li],u0.prototype,"_dirtyFlag",void 0),ln([ls],u0.prototype,"_color",void 0),ln([la],u0.prototype,"_text",void 0),ln([la],u0.prototype,"_width",void 0),ln([la],u0.prototype,"_height",void 0),ln([li],u0.prototype,"_localBounds",void 0),ln([la],u0.prototype,"_font",void 0),ln([la],u0.prototype,"_fontSize",void 0),ln([la],u0.prototype,"_fontStyle",void 0),ln([la],u0.prototype,"_lineSpacing",void 0),ln([la],u0.prototype,"_horizontalAlignment",void 0),ln([la],u0.prototype,"_verticalAlignment",void 0),ln([la],u0.prototype,"_enableWrapping",void 0),ln([la],u0.prototype,"_overflowMode",void 0),ln([la],u0.prototype,"_maskInteraction",void 0),ln([la],u0.prototype,"_maskLayer",void 0),(il=sy||(sy={}))[il.SubFont=1]="SubFont",il[il.LocalPositionBounds=2]="LocalPositionBounds",il[il.WorldPosition=4]="WorldPosition",il[il.WorldBounds=8]="WorldBounds",il[il.MaskInteraction=16]="MaskInteraction",il[il.Position=14]="Position",il[il.Font=15]="Font";var u1=((iu=(ic=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]},iu.getTargetValue=function(){return this._mounted[this._propertyName]},iu.setTargetValue=function(e){this._mounted[this._propertyName]=e},ic),u2=function(){function e(t,n,r,i){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=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.evaluateValue=function(e,t,n){return n?e._evaluateAdditive(t,this.baseEvaluateData):e._evaluate(t,this.baseEvaluateData)},t.evaluateCrossFadeValue=function(e,t,n,r,i,a){var o=e&&e.keys.length?a?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):a?this.cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,s=t&&t.keys.length?a?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):a?this.cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;return this._lerpValue(o,s,i)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r){var i=r?this.cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,a=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(i,a,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 i=this._assembler,a=i.getTargetValue(),o=r._additiveValue(e,t,a);i.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 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:u1},e}();u2._assemblerMap=new Map;var u3=((id=(ih=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},id.getTargetValue=function(){return this._transform.position},id.setTargetValue=function(e){this._transform.position=e},ih);u2.registerAssembler(lq,"position",u3);var u4=((ip=(i_=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},ip.getTargetValue=function(){return this._transform.rotationQuaternion},ip.setTargetValue=function(e){this._transform.rotationQuaternion=e},i_);u2.registerAssembler(lq,"rotationQuaternion",u4);var u5=((im=(ig=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},im.getTargetValue=function(){return this._transform.scale},im.setTargetValue=function(e){this._transform.scale=e},ig);u2.registerAssembler(lq,"scale",u5);var u8=((iy=(iv=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(c4)},iy.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},iy.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},iv);u2.registerAssembler(c4,"blendShapeWeights",u8);var u6=((iT=(ix=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},iT.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},ix),u7=((iS=(iC=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new u2(e,this.type,this.property,t);return t._initializeOwner(n),n.saveDefaultValue(),n},iS._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new u6;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},iS._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},iC),u9=function(){},he=(s9(iw=function(e){var t;return(t=lc.call(this,null)||this).name=e,t._curveBindings=[],t._length=0,t._events=[],t},lc),(iA=iw.prototype).addEvent=function(e,t,n){if("string"==typeof e){var r=new u9;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})},iA.clearEvents=function(){this._events.length=0},iA.addCurveBinding=function(e,t,n,r){var i=new u7;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},iA.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iA._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);if(a){var o=i._getTempCurveOwner(a),s=o.evaluateValue(i.curve,t,!1);o.applyValue(s,1,!1)}}},s6(iw,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),iw);e.InterpolationType=void 0,(iE=e.InterpolationType||(e.InterpolationType={}))[iE.Linear=0]="Linear",iE[iE.CubicSpine=1]="CubicSpine",iE[iE.Step=2]="Step",iE[iE.Hermite=3]="Hermite";var ht=((ib=(iM=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)}},ib.evaluate=function(e){return this._evaluate(e,this._evaluateData)},ib.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},ib._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 n.value=r,r},ib._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},s6(iM,[{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}}]),iM);e.AnimationArrayCurve=(s9(iR=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=[],e},ht),iR._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iR._initializeLayerOwner=function(e){e.finalValue=[]},iR._lerpValue=function(e,t,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},iR._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iR._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iR._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iR._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iR._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},(sx=iR)._isReferenceType=!0,sx._isInterpolationType=!0,sx),e.AnimationArrayCurve=ln([cH()],e.AnimationArrayCurve),e.AnimationBoolCurve=(s9(iF=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=!1,e},ht),iF._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},iF._initializeLayerOwner=function(e){e.finalValue=!1},iF._lerpValue=function(e,t){return t},iF._subtractValue=function(e,t,n){return e},iF._getZeroValue=function(){return!1},iF._additiveValue=function(e,t,n){return e},iF._copyValue=function(e){return e},iF._hermiteInterpolationValue=function(e){return e.value},(sT=iF)._isReferenceType=!1,sT._isInterpolationType=!1,sT),e.AnimationBoolCurve=ln([cH()],e.AnimationBoolCurve),e.AnimationColorCurve=(s9(iP=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s2,e},ht),iP._initializeOwner=function(e){e.defaultValue=new s2,e.fixedPoseValue=new s2,e.baseEvaluateData.value=new s2,e.crossEvaluateData.value=new s2},iP._initializeLayerOwner=function(e){e.finalValue=new s2},iP._lerpValue=function(e,t,n,r){return s2.lerp(e,t,n,r),r},iP._subtractValue=function(e,t,n){return s2.subtract(e,t,n),n},iP._getZeroValue=function(e){return e.set(0,0,0,0),e},iP._additiveValue=function(e,t,n){return s2.scale(e,t,e),s2.add(n,e,n),n},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.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},(sC=iP)._isReferenceType=!0,sC._isInterpolationType=!0,sC),e.AnimationColorCurve=ln([cH()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(s9(iL=function(){return ht.apply(this,arguments)},ht),iL.prototype.addKey=function(e){ht.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)}},iL._initializeOwner=function(e){var t=e.referenceTargetValue.length;e.defaultValue=new Float32Array(t),e.fixedPoseValue=new Float32Array(t),e.baseEvaluateData.value=new Float32Array(t),e.crossEvaluateData.value=new Float32Array(t)},iL._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},iL._lerpValue=function(e,t,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},iL._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iL._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iL._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iL._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iL._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},(sS=iL)._isReferenceType=!0,sS._isInterpolationType=!0,sS),e.AnimationFloatArrayCurve=ln([cH()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(s9(iD=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=0,e},ht),iD._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},iD._initializeLayerOwner=function(e){e.finalValue=0},iD._lerpValue=function(e,t,n){return e+(t-e)*n},iD._additiveValue=function(e,t,n){return n+e*t},iD._subtractValue=function(e,t){return e-t},iD._getZeroValue=function(){return 0},iD._copyValue=function(e){return e},iD._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},(sw=iD)._isReferenceType=!1,sw._isInterpolationType=!0,sw),e.AnimationFloatCurve=ln([cH()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(s9(iI=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new sJ,e},ht),iI._initializeOwner=function(e){e.defaultValue=new sJ,e.fixedPoseValue=new sJ,e.baseEvaluateData.value=new sJ,e.crossEvaluateData.value=new sJ},iI._initializeLayerOwner=function(e){e.finalValue=new sJ},iI._lerpValue=function(e,t,n,r){return sJ.slerp(e,t,n,r),r},iI._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},iI._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return sJ.conjugate(n,i),sJ.multiply(i,t,r),r},iI._getZeroValue=function(e){return e.set(0,0,0,1),e},iI._copyValue=function(e,t){return t.copyFrom(e),t},iI._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},(sA=iI)._isInterpolationType=!0,sA._isReferenceType=!0,sA._tempConjugateQuat=new sJ,sA),e.AnimationQuaternionCurve=ln([cH()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(s9(iB=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s0,e},ht),iB._initializeOwner=function(e){e.defaultValue=new s0,e.fixedPoseValue=new s0,e.baseEvaluateData.value=new s0,e.crossEvaluateData.value=new s0},iB._initializeLayerOwner=function(e){e.finalValue=new s0},iB._lerpValue=function(e,t,n,r){return s0.lerp(e,t,n,r),r},iB._additiveValue=function(e,t,n){return s0.scale(e,t,e),s0.add(n,e,n),n},iB._subtractValue=function(e,t,n){return s0.subtract(e,t,n),n},iB._getZeroValue=function(e){return e.set(0,0),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,i},(sE=iB)._isReferenceType=!0,sE._isInterpolationType=!0,sE),e.AnimationVector2Curve=ln([cH()],e.AnimationVector2Curve),e.AnimationVector3Curve=(s9(iN=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new sW,e},ht),iN._initializeOwner=function(e){e.defaultValue=new sW,e.fixedPoseValue=new sW,e.baseEvaluateData.value=new sW,e.crossEvaluateData.value=new sW},iN._initializeLayerOwner=function(e){e.finalValue=new sW},iN._lerpValue=function(e,t,n,r){return sW.lerp(e,t,n,r),r},iN._relativeBaseValue=function(e,t){return sW.subtract(t,e,t),t},iN._additiveValue=function(e,t,n){return sW.scale(e,t,e),sW.add(n,e,n),n},iN._subtractValue=function(e,t,n){return sW.subtract(e,t,n),n},iN._getZeroValue=function(e){return e.set(0,0,0),e},iN._copyValue=function(e,t){return t.copyFrom(e),t},iN._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},(sM=iN)._isReferenceType=!0,sM._isInterpolationType=!0,sM),e.AnimationVector3Curve=ln([cH()],e.AnimationVector3Curve),e.AnimationVector4Curve=(s9(iV=function(){var e;return(e=ht.call(this)||this)._evaluateData.value=new s1,e},ht),iV._initializeOwner=function(e){e.defaultValue=new s1,e.fixedPoseValue=new s1,e.baseEvaluateData.value=new s1,e.crossEvaluateData.value=new s1},iV._initializeLayerOwner=function(e){e.finalValue=new s1},iV._lerpValue=function(e,t,n,r){return s1.lerp(e,t,n,r),r},iV._additiveValue=function(e,t,n){return s1.scale(e,t,e),s1.add(n,e,n),n},iV._subtractValue=function(e,t,n){return s1.subtract(e,t,n),n},iV._getZeroValue=function(e){return e.set(0,0,0,0),e},iV._copyValue=function(e,t){return t.copyFrom(e),t},iV._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},(sb=iV)._isReferenceType=!0,sb._isInterpolationType=!0,sb),e.AnimationVector4Curve=ln([cH()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(iO=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[iO.None=0]="None",iO[iO.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iU=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iU.Override=0]="Override",iU[iU.Additive=1]="Additive",(iz=sR||(sR={}))[iz.UnStarted=0]="UnStarted",iz[iz.Playing=1]="Playing",iz[iz.Finished=2]="Finished",(ik=sF||(sF={}))[ik.Standby=0]="Standby",ik[ik.Playing=1]="Playing",ik[ik.CrossFading=2]="CrossFading",ik[ik.FixedCrossFading=3]="FixedCrossFading",ik[ik.Finished=4]="Finished";var hn=((iG=function(){this.handlers=[]}).prototype.dispose=function(){},iG),hr=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(iH=e.WrapMode||(e.WrapMode={}))[iH.Once=0]="Once",iH[iH.Loop=1]="Loop";var hi=((iX=(iW=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=sR.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},iX.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=sR.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=sR.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},iW),ha=((iK=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new hi,this.destPlayData=new hi,this.layerState=sF.Standby,this.crossCurveMark=0,this.manuallyTransition=new hr,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iK),ho=function(){this.curveLayerOwner=[],this.eventHandlers=[]},hs=(s9(ij=function(t){var n;return(n=lU.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new cM(hn),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lU),(iq=ij.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,o=i.layerIndex;if(a){if(!a.clip){lv.warn("The state named "+e+" has no AnimationClip data.");return}var s=this._getAnimatorLayerData(o),l=this._getAnimatorStateData(e,a,s,o);this._preparePlay(s,a),s.layerState=sF.Playing,s.srcPlayData.reset(a,l,a._getDuration()*n)}},iq.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),o=a.state,s=a.layerIndex,l=this._getAnimatorLayerData(s).manuallyTransition;l.duration=t,l.offset=r,l.destinationState=o,this._crossFadeByTransition(l,n)},iq.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,this._updateMark++;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==sF.Standby&&this._updateLayer(l,0===l,t,r)}},iq.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},iq.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iq._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iq._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},iq._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)},iq._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},iq._getAnimatorStateData=function(e,t,n,r){var i=n.animatorStateDataMap,a=i[e];return a||(a=new ho,i[e]=a,this._saveAnimatorStateData(t,a,n,r),this._saveAnimatorEventHandlers(t,a)),a},iq._saveAnimatorStateData=function(e,t,n,r){for(var i=this.entity,a=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?i:i.findByPath(u.relativePath);if(h){var d,_,f,p,g=u.property,m=h.instanceId,v=(_=(d=a)[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,lv.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},iq._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)}},iq._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},iq._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},iq._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},iq._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},iq._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)},iq._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))}},iq._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;t&&a.saveFixedPoseValue(),i.crossCurveMark=e.crossCurveMark,this._addCrossOwner(e,i,-1,r)}}}},iq._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new ha),t},iq._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!==sF.FixedCrossFading&&this._checkTransition(c,h,t),l.layerState){case sF.Playing:this._updatePlayingState(c,l,t,s,r,d,i);break;case sF.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,r,d,i);break;case sF.CrossFading:this._updateCrossFade(c,u,l,t,s,r,d,i);break;case sF.Finished:this._updateFinishedState(c,s,d,i)}},iq._updatePlayingState=function(e,t,n,r,i,a,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===sR.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,a);var T=y.evaluateValue(x,f,a);o&&y.applyValue(T,r,a),g&&v.saveFinalValue()}}}e.frameTime+=u.speed*i,p===sR.Finished&&(t.layerState=sF.Finished),c.length&&this._fireAnimationEvents(e,c,d,f),h===sR.UnStarted&&this._callAnimatorScriptOnEnter(u,n),p===sR.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n)},iq._updateCrossFade=function(e,t,n,r,i,a,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,C=Math.abs(t.frameTime)/T;(C>=1||0===T)&&(C=1),e.update(this.speed<0),t.update(this.speed<0);var S=e.clipTime,w=e.playState,A=t.clipTime,E=t.playState,M=t.playState===sR.Finished;if(s||M)for(var b=l.length-1;b>=0;b--){var R=l[b],F=null==R?void 0:R.curveOwner;if(F){var P=R.crossSrcCurveIndex,L=R.crossDestCurveIndex;this._checkRevertOwner(F,o);var D=F.evaluateCrossFadeValue(P>=0?c[P].curve:null,L>=0?v[L].curve:null,S,A,C,o);s&&F.applyValue(D,i,o),M&&R.saveFinalValue()}}this._updateCrossFadeData(n,C,a,!1),_.length&&this._fireAnimationEvents(e,_,y,S),m.length&&this._fireAnimationEvents(t,m,x,A),d===sR.UnStarted&&this._callAnimatorScriptOnEnter(u,r),1===C||w===sR.Finished?this._callAnimatorScriptOnExit(u,r):this._callAnimatorScriptOnUpdate(u,r),g===sR.UnStarted&&this._callAnimatorScriptOnEnter(f,r),E===sR.Finished?this._callAnimatorScriptOnExit(f,r):this._callAnimatorScriptOnUpdate(f,r)},iq._updateCrossFadeFromPose=function(e,t,n,r,i,a,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,i,!0);var m=e.clipTime,v=g===sR.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 C=x.crossDestCurveIndex;this._checkRevertOwner(T,a);var S=x.curveOwner.crossFadeFromPoseAndApplyValue(C>=0?d[C].curve:null,m,p,a);o&&T.applyValue(S,r,a),v&&x.saveFinalValue()}}h.length&&this._fireAnimationEvents(e,h,_,m),u===sR.UnStarted&&this._callAnimatorScriptOnEnter(l,n),g===sR.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n)},iq._updateFinishedState=function(e,t,n,r){if(r)for(var i=e.stateData.curveLayerOwner,a=e.state.clip._curveBindings,o=a.length-1;o>=0;o--){var s=i[o],l=null==s?void 0:s.curveOwner;l&&(this._checkRevertOwner(l,n),l.applyValue(s.finalValue,t,n))}},iq._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===sR.Finished?e.layerState=sF.Finished:e.layerState=sF.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},iq._preparePlay=function(e,t){if(e.layerState===sF.Playing){var n=e.srcPlayData;if(n.state!==t)for(var r,i=n.stateData.curveLayerOwner,a=i.length-1;a>=0;a--)null==(r=i[a])||r.curveOwner.revertDefaultValue()}else for(var o=e.crossLayerOwnerCollection,s=o.length-1;s>=0;s--)o[s].curveOwner.revertDefaultValue()},iq._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)}},iq._crossFadeByTransition=function(e,t){var n=e.destinationState.name,r=this._getAnimatorStateInfo(n,t),i=r.state,a=r.layerIndex;if(i){if(!i.clip){lv.warn("The state named "+n+" has no AnimationClip data.");return}var o=this._getAnimatorLayerData(a),s=o.layerState,l=o.destPlayData,c=this._getAnimatorStateData(n,i,o,a),u=i._getDuration()*e.offset;switch(l.reset(i,c,u),s){case sF.Standby:case sF.Finished:o.layerState=sF.FixedCrossFading,this._clearCrossData(o),this._prepareStandbyCrossFading(o);break;case sF.Playing:o.layerState=sF.CrossFading,this._clearCrossData(o),this._prepareCrossFading(o);break;case sF.CrossFading:o.layerState=sF.FixedCrossFading,this._prepareFixedPoseCrossFading(o);break;case sF.FixedCrossFading:this._prepareFixedPoseCrossFading(o)}o.crossFadeTransition=e}},iq._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)},iq._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)}}},iq._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)}}},iq._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},iq._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},iq._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},iq._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)}},iq._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},s6(ij,[{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)}}]),ij);ln([la],hs.prototype,"speed",void 0),ln([li],hs.prototype,"_controllerUpdateFlag",void 0),ln([li],hs.prototype,"_updateMark",void 0),ln([li],hs.prototype,"_animatorLayersData",void 0),ln([li],hs.prototype,"_curveOwnerPool",void 0),ln([li],hs.prototype,"_animationEventHandlerPool",void 0),ln([li],hs.prototype,"_tempAnimatorStateInfo",void 0),ln([li],hs.prototype,"_controlledRenderers",void 0);var hl=((iQ=(iY=function(){this._updateFlagManager=new lj,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iQ.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iQ.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iQ.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iQ._registerChangeFlag=function(){return this._updateFlagManager.createFlag(lK)},s6(iY,[{key:"layers",get:function(){return this._layers}}]),iY),hc=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},hu=((iZ=(iJ=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iZ.onStateUpdate=function(e,t,n){},iZ.onStateExit=function(e,t,n){},iZ.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iJ),hh=((i0=(i$=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)},i0.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},i0.addStateMachineScript=function(e){var t=new e;t._state=this;var n=hu.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},i0.clearTransitions=function(){this._transitions.length=0},i0._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},i0._removeStateMachineScript=function(e){var t=hu.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)}},s6(i$,[{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)}}]),i$),hd=((i2=(i1=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 hh(e),this.states.push(t),this._statesMap[e]=t),t},i2.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},i2.findStateByName=function(e){return this._statesMap[e]},i2.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},i1);e.AnimatorConditionMode=void 0,(i3=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[i3.If=0]="If",i3[i3.IfNot=1]="IfNot",i3[i3.Greater=2]="Greater",i3[i3.Less=3]="Less",i3[i3.Equals=4]="Equals",i3[i3.NotEquals=5]="NotEquals";var h_=function(){},hf=function(t){function n(r){var i;return(i=t.call(this,r,cz.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new s2(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 s9(n,t),n.prototype.clone=function(){var e=new n(this._engine);return this.cloneTo(e),e},s6(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}(cE);hf._tintColorProp=lB.getByName("material_TintColor"),hf._textureCubeProp=lB.getByName("material_CubeTexture"),hf._rotationProp=lB.getByName("material_Rotation"),hf._exposureProp=lB.getByName("material_Exposure"),hf._decodeSkyRGBMMacro=cm.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(i4=e.SunMode||(e.SunMode={}))[i4.None=0]="None",i4[i4.Simple=1]="Simple",i4[i4.HighQuality=2]="HighQuality";var hp=(s9(i5=function(t){var n;return(n=cE.call(this,t,cz.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new s2(.5,.5,.5,1),n.groundTint=new s2(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n},cE),i5.prototype.clone=function(){var e=new i5(this._engine);return this.cloneTo(e),e},s6(i5,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(i5._sunSimpleMacro),t.enableMacro(i5._sunHighQualityMacro);break;case 1:t.disableMacro(i5._sunHighQualityMacro),t.enableMacro(i5._sunSimpleMacro);break;case 0:t.disableMacro(i5._sunHighQualityMacro),t.disableMacro(i5._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(i5._sunSizeProp)},set:function(e){this.shaderData.setFloat(i5._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(i5._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(i5._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(i5._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(i5._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(i5._skyTintProp)},set:function(e){this.shaderData.setColor(i5._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(i5._groundTintProp)},set:function(e){this.shaderData.setColor(i5._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(i5._exposureProp)},set:function(e){this.shaderData.setFloat(i5._exposureProp,Math.min(Math.max(0,e),8))}}]),i5);hp._sunSizeProp=lB.getByName("material_SunSize"),hp._sunSizeConvergenceProp=lB.getByName("material_SunSizeConvergence"),hp._atmosphereThicknessProp=lB.getByName("material_AtmosphereThickness"),hp._skyTintProp=lB.getByName("material_SkyTint"),hp._groundTintProp=lB.getByName("material_GroundTint"),hp._exposureProp=lB.getByName("material_Exposure"),hp._sunHighQualityMacro=cm.getByName("MATERIAL_SUN_HIGH_QUALITY"),hp._sunSimpleMacro=cm.getByName("MATERIAL_SUN_SIMPLE"),(i8=sP||(sP={}))[i8.Position=1]="Position",i8[i8.Velocity=2]="Velocity",i8[i8.Acceleration=4]="Acceleration",i8[i8.Color=8]="Color",i8[i8.Alpha=16]="Alpha",i8[i8.Size=32]="Size",i8[i8.StartAngle=64]="StartAngle",i8[i8.StartTime=128]="StartTime",i8[i8.LifeTime=256]="LifeTime",i8[i8.RotateVelocity=512]="RotateVelocity",i8[i8.Scale=1024]="Scale",i8[i8.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(i6=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[i6.Transparent=0]="Transparent",i6[i6.Additive=1]="Additive";var hg=(s9(i7=function(e){var t;return(t=c3.call(this,e)||this)._maxCount=1e3,t._position=new sW,t._positionRandomness=new sW,t._velocity=new sW,t._velocityRandomness=new sW,t._acceleration=new sW,t._accelerationRandomness=new sW,t._color=new s2(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(s5(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},c3),(i9=i7.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)}},i9._onEnable=function(){c3.prototype._onEnable.call(this),this._playOnEnable&&this.start()},i9.start=function(){this._isStart=!0,this._time=0},i9.stop=function(){this._isStart=!1},i9._createMaterial=function(){var t=new cE(this.engine,cz.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},i9._createMesh=function(){var t=new ua(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>i7._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 cq("a_position",0,e.VertexElementFormat.Vector3,0),new cq("a_velocity",12,e.VertexElementFormat.Vector3,0),new cq("a_acceleration",24,e.VertexElementFormat.Vector3,0),new cq("a_color",36,e.VertexElementFormat.Vector4,0),new cq("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new cq("a_rotation",68,e.VertexElementFormat.Vector2,0),new cq("a_uv",76,e.VertexElementFormat.Vector3,0),new cq("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new cY(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new cY(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},i9._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},i9._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=i7._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]=sH.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[c+10]=sH.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[c+11]=sH.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[c+12]=sH.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 w=this._size;n[o+15]=n[s+15]=n[l+15]=n[c+15]=Math.max(w+i()*this._sizeRandomness*w*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)},i9._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},i9._onColorChanged=function(){this._updateDirtyFlag|=8},i7._getRandom=function(){return Math.random()-.5},s6(i7,[{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}}]),i7);hg._uint16VertexLimit=65535,ln([li],hg.prototype,"_onColorChanged",null),cz.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 hm=(s9(ae=function(t){var n,r=(n=cE.call(this,t,cz.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},cE),ae),hv=new sW,hy=(s9(at=function(e,t){(n=c3.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 sW),n._pointStates.push(n._lifetime),n._strapPoints.push(new sW),n._strapPoints.push(new sW);n._curPointNum=0;var i=t.material||new hm(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},c3),(an=at.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];sW.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++)},an.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},an._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),c3.prototype._render.call(this,e)},an._initGeometry=function(){var t=new ua(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new cq("POSITION",0,e.VertexElementFormat.Vector3,0),new cq("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new cY(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},an._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sW(n[0],n[4],n[8]),i=new sW(n[1],n[5],n[9]),a=new sW(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sW,l=new sW,c=new sJ;sW.transformByQuat(r,c,r),sW.transformByQuat(i,c,i);var u=new sW,h=new sW,d=new sW;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?sW.subtract(p,t[f-1],d):sW.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sW.dot(r,d));sW.cross(r,d,h),0>=sW.dot(h,a)&&(g=2*Math.PI-g),sJ.rotationAxisAngle(a,g,c),sW.transformByQuat(i,c,u),sW.add(p,u,s),sW.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}},an._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}}},an._projectOnVector=function(e,t,n){var r=t.clone();sW.normalize(r,r);var i=sW.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},an._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,hv),sW.subtract(e,hv,n)},at),hx=(s9(ar=function(){var t;return t=uS.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uS),(ai=ar.prototype).onTextureChange=function(e){},ai.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 lx(this.engine,this.width,this.height,this._isCube?new lS(this.engine,this.width):new lT(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new lx(this.engine,this.width,this.height,this._isCube?new lS(this.engine,this.width):new lT(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},ai.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},ai._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},s6(ar,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),ar),hT=new sW,hC=new sW,hS=new sW,hw=(s9(aa=function(){var e;return e=hx.apply(this,arguments)||this,e.position=new sW(0,0,0),e._isCube=!0,e.oriViewMatrix=new sZ,e},hx),(ao=aa.prototype).onBeginRender=function(t){if(this.enabled){hx.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),hx.prototype._reset.call(this)}},ao._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ao._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ao._setCamera=function(e,t){switch(e){case 0:hC.set(0,-1,0),hS.set(1,0,0);break;case 1:hC.set(0,-1,0),hS.set(-1,0,0);break;case 2:hC.set(0,0,1),hS.set(0,1,0);break;case 3:hC.set(0,0,-1),hS.set(0,-1,0);break;case 4:hC.set(0,-1,0),hS.set(0,0,1);break;case 5:hC.set(0,-1,0),hS.set(0,0,-1)}sW.add(this.position,hS,hT),sZ.lookAt(this.position,hT,hC,t.viewMatrix),t.fieldOfView=90},aa),hA=Object.freeze({__proto__:null,AmbientLight:ug,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:he,AnimationClipCurveBinding:u7,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:ht,AnimationEvent:u9,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:hs,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hl,AnimatorControllerLayer:hc,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:hh,AnimatorStateMachine:hd,AnimatorStateTransition:hr,AssetPromise:lb,get AssetType(){return e.AssetType},Background:up,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uk,Basic2DBatcher:ul,BasicRenderPipeline:uL,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:us,BlendShapeFrame:uo,BlendState:cT,BlinnPhongMaterial:uG,BoolUpdateFlag:lK,BoxColliderShape:l5,Buffer:cY,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:ua,get BufferUsage(){return e.BufferUsage},BufferUtil:cj,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:l7,CharacterController:l3,CloneManager:ll,get Collider(){return e.Collider},ColliderShape:l4,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:lU,ContentRestorer:lh,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:hw,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:cC,get DiffuseMode(){return e.DiffuseMode},DirectLight:c_,DynamicCollider:co,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:uC,EngineObject:lc,Entity:lQ,EventDispatcher:lI,FixedJoint:ce,get FogMode(){return e.FogMode},Font:lM,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:ct,HitResult:l0,IndexBufferBinding:cQ,get IndexFormat(){return e.IndexFormat},InputManager:ch,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:cr,JointMotor:ci,Keyframe:h_,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:cd,Loader:uz,Logger:lv,Material:cE,Mesh:cZ,MeshRenderer:c3,get MeshTopology(){return e.MeshTopology},ModelMesh:c1,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uH,PBRMaterial:uW,PBRSpecularMaterial:uX,ParticleRenderer:hg,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:l1,PhysicsMaterial:l2,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},get PipelineStage(){return e.PipelineStage},PlaneColliderShape:l6,get Platform(){return e.Platform},PointLight:cf,Pointer:lJ,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:ui,Probe:hx,RasterState:cS,ReferResource:lu,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uP,RenderQueue:uA,get RenderQueueType(){return e.RenderQueueType},RenderState:cA,RenderTarget:lx,RenderTargetBlendState:cx,get Renderer(){return e.Renderer},ResourceManager:lR,Scene:um,SceneManager:uv,Script:uS,get SetDataOptions(){return e.SetDataOptions},Shader:cz,ShaderData:cy,ShaderFactory:cL,ShaderMacro:cm,ShaderMacroCollection:cv,ShaderPass:cO,ShaderProperty:lB,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:cD,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:c2,SkinnedMeshRenderer:c4,Sky:uf,SkyBoxMaterial:hf,SkyProceduralMaterial:hp,SphereColliderShape:l8,SpotLight:cp,SpringJoint:cn,Sprite:uq,SpriteAtlas:uj,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:cK,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:uJ,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:hu,StaticCollider:ca,get StencilOperation(){return e.StencilOperation},StencilState:cw,SubMesh:cJ,SubShader:cU,get SunMode(){return e.SunMode},SystemInfo:lZ,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:u0,TextUtils:lA,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:ly,Texture2D:lT,Texture2DArray:lC,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:lS,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:lN,TrailMaterial:hm,TrailRenderer:hy,Transform:lq,UnlitMaterial:uK,Utils:lG,VertexBufferBinding:c$,VertexElement:cq,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:la,deepClone:ls,dependentComponents:lk,ignoreClone:li,request:uN,resourceLoader:lF,shallowClone:lo});function hE(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 hM(e,t,n){return t&&hE(e.prototype,t),n&&hE(e,n),e}function hb(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(as=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[as.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",as[as.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",as[as.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",as[as.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",as[as.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",as[as.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",as[as.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",as[as.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",as[as.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",as[as.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",as[as.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",as[as.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",as[as.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",as[as.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",as[as.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",as[as.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",as[as.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",as[as.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",as[as.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",as[as.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",as[as.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",as[as.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",as[as.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",as[as.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",as[as.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",as[as.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",as[as.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",as[as.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",as[as.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",as[as.R11_EAC=37488]="R11_EAC",as[as.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",as[as.RG11_EAC=37490]="RG11_EAC",as[as.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",as[as.RGB8_ETC2=37492]="RGB8_ETC2",as[as.SRGB8_ETC2=37493]="SRGB8_ETC2",as[as.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",as[as.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",as[as.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",as[as.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",as[as.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",as[as.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",as[as.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",as[as.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",as[as.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",as[as.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",as[as.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",as[as.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var hR=((ac=(al=function(e){this._scale=new s0;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&&hb(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},ac.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},hM(al,[{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&&hb(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&&hb(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),al);function hF(e,t){return(hF=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hP(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&&hF(e,t)}var hL=(hP(au=function(){return uC.apply(this,arguments)},uC),au.create=function(e){var t=e.canvas,n=new hR("string"==typeof t?document.getElementById(t):t),r=new hW(e.graphicDeviceOptions);return new au(n,r,e)._initialize(e)},hM(au,[{key:"canvas",get:function(){return this._canvas}}]),au);function hD(){return(hD=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 hI=((ad=(ah=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)},ad.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)},ad.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."},ad.resize=function(e){this.bind(),this._gl.bufferData(this._glBindTarget,e,this._glBufferUsage)},ad.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},ad._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}},ah),hB=((af=(a_=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},af.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)},af._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,w=e.GLCapabilityType.textureHalfFloat,A=e.GLCapabilityType.textureFloatLinear,E=e.GLCapabilityType.textureHalfFloatLinear,M=e.GLCapabilityType.WEBGL_colorBufferFloat,b=e.GLCapabilityType.colorBufferFloat,R=e.GLCapabilityType.colorBufferHalfFloat,F=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(w,n||!!r(w)),t.set(A,!!r(A)),t.set(E,n||!!r(E)),t.set(b,n&&!!r(b)||!!r(M)),t.set(R,n&&!!r(b)||!!r(R)),t.set(F,!!r(F)),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)))},af._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}},af._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,hD({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"})},hM(a_,[{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}}]),a_),hN=((ap=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]},ap),hV=((am=(ag=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 lv.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()},am.destroy=function(){this._useVao&&this._clearVAO()},am._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 lv.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},am._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},am._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)},am._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},ag),hO=((av=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]},av),hU=((ax=(ay=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},ax.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},ax.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},ax._bind=function(){this._rhi.bindTexture(this)},ax._init=function(t){var n=this._gl,r=this._isWebGL2,i=this._formatDetail,a=i.internalFormat,o=i.baseFormat,s=i.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,a,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,a,p,p,0,o,s,null);else if(_)n.texImage2D(this._target,0,a,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,a,v,y,0,o,s,null)}},ax._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,lv.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)},ax._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||ay._isPowerOf2(s)&&ay._isPowerOf2(l)||(lv.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)}},ax._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},ay._isPowerOf2=function(e){return(e&e-1)==0},ay._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)}},ay._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)}},ay._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},ay._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},ay._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},hM(ay,[{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)}}}]),ay),hz=((aC=(aT=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=hb(i,ly),l=0,c=r.length;l<c;l++){var u=r[l]._format;if(!hU._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!hU._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 hb(e,lS)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(lv.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=hb(a,lS);(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=hb(i,lS);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=hU._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()},aC.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)}},aC.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},aC._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},aC._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,hb(c,lS)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(hb(r,ly)&&!hb(r,lS)){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=hU._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)},aC._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=hb(i,ly)?i._platformTexture._formatDetail:hU._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)},aC._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.")},aT),hk=(hP(aS=function(t,n){(r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||hU._isPowerOf2(o)&&hU._isPowerOf2(s)||(lv.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=hU._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},hU),(aw=aS.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)},aw.setImageSource=function(t,n,r,i,a,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,+i),this._texture.usage===e.TextureUsage.Dynamic?s.texImage2D(this._target,n,c,u,h,t):s.texSubImage2D(this._target,n,a||0,o||0,u,h,t)},aw.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hU.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},aS),hG=(hP(aA=function(t,n){r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=hU._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},hU),(aE=aA.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)},aE.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)},aE.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)},aA),hH=(hP(aM=function(t,n){(r=hU.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(!hU._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||hU._isPowerOf2(o)||(lv.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=hU._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},hU),(ab=aM.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)},ab.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)},ab.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hU.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},aM);e.WebGLMode=void 0,(aR=e.WebGLMode||(e.WebGLMode={}))[aR.Auto=0]="Auto",aR[aR.WebGL2=1]="WebGL2",aR[aR.WebGL1=2]="WebGL1";var hW=((aP=(aF=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new s1(null,null,null,null),this._lastScissor=new s1(null,null,null,null),this._lastClearColor=new s2(null,null,null,null),this._scissorEnable=!1;var n=hD({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(lZ.platform===e.Platform.IPhone||lZ.platform===e.Platform.IPad){var r=lZ.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&&hb(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&&hb(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},aP.createPlatformPrimitive=function(e){return new hV(this,e)},aP.createPlatformTexture2D=function(e){return new hk(this,e)},aP.createPlatformTexture2DArray=function(e){return new hG(this,e)},aP.createPlatformTextureCube=function(e){return new hH(this,e)},aP.createPlatformRenderTarget=function(e){return new hz(this,e)},aP.createPlatformBuffer=function(t,n,r,i){return void 0===r&&(r=e.BufferUsage.Static),new hI(this,t,n,r,i)},aP.requireExtension=function(e){return this._extensions.requireExtension(e)},aP.canIUse=function(e){return this.capability.canIUse(e)},aP.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},aP.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))},aP.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)}},aP.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},aP.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)},aP.drawPrimitive=function(e,t,n){e?e._draw(n,t):lv.error("draw primitive failed.")},aP.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)},aP.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},aP.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)},aP.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},aP.flush=function(){this._gl.flush()},aP.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},aP.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},aP.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)},aP._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new hO(e),this._extensions=new hN(this),this._capability=new hB(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},aP.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},aP._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},aP._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},aP._onWebGLContextRestored=function(e){this._onDeviceRestored()},hM(aF,[{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}}]),aF);function hX(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=((aD=(aL=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:lv.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},aD.addCurrentLoad=function(e){this._currentLoad+=e},aD.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},aD.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},aD.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},hX(aL.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),aI&&hX(aL,aI),aL),hj='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',hq="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",hY=((aN=(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)lv.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?uN(""+hq+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,hj].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uN(""+hq+"draco_wasm_wrapper_gltf.js",{type:"text"}),uN(""+hq+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,hj].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},aN.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]})},aN.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 hQ(){return(hQ=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 hJ(e,t){return(hJ=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hZ(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&&hJ(e,t)}function h$(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 h0(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 h1=(hZ(aV=function(){return uz.apply(this,arguments)},uz),aV.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"json"})).then(function(e){var n=new hl,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hc(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,h=c.stateMachine=new hd;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(uz.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 hr;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)})},aV);h1=h$([lF(e.AssetType.AnimatorController,["json"],!1)],h1);var h2=(hZ(aO=function(){return uz.apply(this,arguments)},uz),aO.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new lb(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,hQ({},e,{type:"arraybuffer"}))},aO);h2=h$([lF(e.AssetType.Buffer,["bin","r3bin"],!1)],h2);var h3=(hZ(aU=function(){return uz.apply(this,arguments)},uz),aU.prototype.load=function(t,n){var r=this;return new lb(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 lS(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 ug,p=new s4;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},aU);function h4(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 h5(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){h4(a,r,i,o,s,"next",e)}function s(e){h4(a,r,i,o,s,"throw",e)}o(void 0)})}}h3=h$([lF(e.AssetType.Env,["env"])],h3);var h8=(hZ(az=function(){return uz.apply(this,arguments)},uz),(ak=az.prototype).load=function(e,t){var n=this;return new lb(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 lM(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new lM(t.engine,a))}).catch(function(e){i(e)})})},ak._registerFont=function(e,t){return h5(function(){var n;return h0(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]}})})()},az);function h6(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 h7(e,t){if(e){if("string"==typeof e)return h6(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 h6(e,t)}}function h9(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=h7(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.")}h8=h$([lF(e.AssetType.Font,["font"],!1)],h8);var de=(hZ(aG=function(){var e;return e=lh.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},lh),(aH=aG.prototype).restoreContent=function(){var e=this;return new lb(function(t,n){Promise.all(e.bufferRequests.map(function(e){return uN(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)}}lb.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 dd.loadImageBuffer(a,e.mimeType).then(function(t){e.texture.setImageSource(t),e.texture.generateMipmaps()})})).then(function(){for(var n,i=h9(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=h9(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,_=h9(o.blendShapes);!(d=_()).done;){var f=d.value,p=f.blendShape.frames[0],g=e._getBufferData(r,f.position);if(p.deltaPositions=dd.floatBufferToVector3Array(g),f.normal){var m=e._getBufferData(r,f.normal);p.deltaNormals=dd.floatBufferToVector3Array(m)}if(f.tangent){var v=e._getBufferData(r,f.tangent);p.deltaTangents=dd.floatBufferToVector3Array(v)}}s.uploadData(!0)}t(e.resource)}).catch(n)}).catch(n)})},aH._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},aG),dt=function(e,t){this.url=e,this.config=t},dn=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},dr=function(){this.vertexBuffers=[],this.blendShapes=[]},di=function(e,t){this.buffer=e,this.data=t},da=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},ds=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},dl=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r};(aW=sL||(sL={}))[aW.BYTE=5120]="BYTE",aW[aW.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",aW[aW.SHORT=5122]="SHORT",aW[aW.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",aW[aW.UNSIGNED_INT=5125]="UNSIGNED_INT",aW[aW.FLOAT=5126]="FLOAT",(aX=sD||(sD={})).SCALAR="SCALAR",aX.VEC2="VEC2",aX.VEC3="VEC3",aX.VEC4="VEC4",aX.MAT2="MAT2",aX.MAT3="MAT3",aX.MAT4="MAT4",(aK=sI||(sI={})).TRANSLATION="translation",aK.ROTATION="rotation",aK.SCALE="scale",aK.WEIGHTS="weights",(aj=sB||(sB={})).Linear="LINEAR",aj.Step="STEP",aj.CubicSpine="CUBICSPLINE",(aq=sN||(sN={})).PERSPECTIVE="perspective",aq.ORTHOGRAPHIC="orthographic",(aY=sV||(sV={})).JPEG="image/jpeg",aY.PNG="image/png",(aQ=sO||(sO={})).OPAQUE="OPAQUE",aQ.MASK="MASK",aQ.BLEND="BLEND",(aJ=sU||(sU={}))[aJ.NEAREST=9728]="NEAREST",aJ[aJ.LINEAR=9729]="LINEAR",(aZ=sz||(sz={}))[aZ.NEAREST=9728]="NEAREST",aZ[aZ.LINEAR=9729]="LINEAR",aZ[aZ.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",aZ[aZ.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",aZ[aZ.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",aZ[aZ.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(a$=sk||(sk={}))[a$.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",a$[a$.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",a$[a$.REPEAT=10497]="REPEAT";var dc=((a0=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new dh,this.materialsPromiseInfo=new dh,this.meshesPromiseInfo=new dh,this.animationClipsPromiseInfo=new dh,this.defaultSceneRootPromiseInfo=new dh,this.masterPromiseInfo=new dh,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 lb(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},a0),du=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},dh=function(){},dd=((a1=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new s0(e[r],e[r+1]);return n},a1.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sW(e[r],e[r+1],e[r+2]);return n},a1.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new s1(e[r],e[r+1],e[r+2],e[r+3]);return n},a1.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 s2(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new s2(e[a],e[a+1],e[a+2],e[a+3]);return r},a1.getAccessorTypeSize=function(e){switch(e){case sD.SCALAR:return 1;case sD.VEC2:return 2;case sD.VEC3:return 3;case sD.VEC4:case sD.MAT2:return 4;case sD.MAT3:return 9;case sD.MAT4:return 16}},a1.getComponentType=function(e){switch(e){case sL.BYTE:return Int8Array;case sL.UNSIGNED_BYTE:return Uint8Array;case sL.SHORT:return Int16Array;case sL.UNSIGNED_SHORT:return Uint16Array;case sL.UNSIGNED_INT:return Uint32Array;case sL.FLOAT:return Float32Array}},a1.getNormalizedComponentScale=function(e){switch(e){case sL.BYTE:return 1/127;case sL.UNSIGNED_BYTE:return 1/255;case sL.SHORT:return 1/32767;case sL.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},a1.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=a1.getComponentType(a),d=a1.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 du(C,!0,g),r.restoreInfo=new da(new ds(s,h,x,T))}}else{var S=c+u,w=p*d,A=new h(l,S,w);(r=new du(A,!1,f)).restoreInfo=new da(new ds(s,h,S,w))}return n.sparse&&a1.processingSparseData(t,n,i,r),r},a1.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=a1.getAccessorTypeSize(t.type),u=c*t.count,h=null!=(v=i.byteStride)?v:0,d=a1.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,w=t.sparse,A=w.count,E=w.indices,M=w.values,b=r[E.bufferView],R=r[M.bufferView],F=n[b.buffer],P=n[R.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=R.byteOffset)?S:0),B=R.byteLength,N=a1.getComponentType(E.componentType),V=new N(F,L,D/N.BYTES_PER_ELEMENT),O=new d(P,I,B/d.BYTES_PER_ELEMENT),U=0;U<A;U++)for(var z=V[U],k=0;k<c;k++)m[z*c+k]=O[U*c+k];return m},a1.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},a1.processingSparseData=function(e,t,n,r){var i,a,o,s,l=r.restoreInfo,c=a1.getAccessorTypeSize(t.type),u=a1.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,w=(null!=(o=p.byteOffset)?o:0)+(null!=(s=m.byteOffset)?s:0),A=m.byteLength;l.typeSize=c,l.sparseCount=_;var E=a1.getComponentType(f.componentType),M=S/E.BYTES_PER_ELEMENT,b=new E(x,C,M);l.sparseIndices=new ds(v,E,C,M);var R=A/u.BYTES_PER_ELEMENT,F=new u(T,w,R);l.sparseValues=new ds(y,u,w,R);for(var P=0;P<_;P++)for(var L=b[P],D=0;D<c;D++)h[L*c+D]=F[P*c+D];r.data=h},a1.getIndexFormat=function(t){switch(t){case sL.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case sL.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case sL.UNSIGNED_INT:return e.IndexFormat.UInt32}},a1.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==sL.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==sL.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==sL.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==sL.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==sL.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},a1.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)})},a1.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(lG.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 s0(d,a)),u+=a+8}return{glTF:l,buffers:c}},a1._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},a1);function d_(e){return function(e){if(Array.isArray(e))return h6(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||h7(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 df=((a3=(a2=function(){}).prototype).initialize=function(){},a3.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."},a3.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."},a2);e.GLTFExtensionMode=void 0,(a4=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[a4.CreateAndParse=0]="CreateAndParse",a4[a4.AdditiveParse=1]="AdditiveParse";var dp=((a5=function(){}).executeExtensionsInitialize=function(e){var t=a5._extensionParsers[e],n=null==t?void 0:t.length;if(n)return t[n-1].initialize()},a5.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=a5._createAndParse.apply(a5,[c,t,u,n].concat(d_(i))))return o}},a5.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];a5._additiveParse.apply(a5,[s,t,n,l,r].concat(d_(a)))}},a5.hasExtensionParser=function(e){var t;return!!(null==(t=a5._extensionParsers[e])?void 0:t.length)},a5.getExtensionParser=function(e,t){var n=a5._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}},a5._addExtensionParser=function(e,t){a5._extensionParsers[e]||(a5._extensionParsers[e]=[]),a5._extensionParsers[e].push(t)},a5._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=a5.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,i].concat(d_(o)))},a5._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=a5.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[n,r,i,a].concat(d_(s)))},a5);function dg(e,t){return function(n){var r=new n;r._mode=t,dp._addExtensionParser(e,r)}}dp._extensionParsers={};var dm=(hZ(a8=function(){return dp.apply(this,arguments)},dp),a8.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=dp.executeExtensionsCreateAndParse(l.extensions,e,l);h||(h=new he(u),a8._parseStandardProperty(e,h,l)),o.push(h)}return lb.all(o).then(function(r){n.animations=r;for(var a=0;a<t.animations.length;a++){var o=t.animations[a];dp.executeExtensionsAdditiveAndParse(o.extensions,e,r[a],o)}return i.resolve(r),i.promise})}},a8._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=dd.getAccessorBuffer(t,s,p).data,v=dd.getAccessorBuffer(t,s,g).data;if(g.normalized){for(var y=dd.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,w=null!=(_=f.interpolation)?_:sB.Linear,A=void 0;switch(w){case sB.CubicSpine:A=e.InterpolationType.CubicSpine;break;case sB.Step:A=e.InterpolationType.Step;break;case sB.Linear:A=e.InterpolationType.Linear}m[m.length-1],u.push({type:g.type,interpolation:A,input:m,output:v,outputSize:S})}for(var E=0,M=l.length;E<M;E++){for(var b=l[E],R=b.target,F=a[R.node],P="",L=F;L.parent;)P=""===P?""+L.name:L.name+"/"+P,L=L.parent;var D=void 0,I=void 0;switch(R.path){case sI.TRANSLATION:D=lq,I="position";break;case sI.ROTATION:D=lq,I="rotationQuaternion";break;case sI.SCALE:D=lq,I="scale";break;case sI.WEIGHTS:D=c4,I="blendShapeWeights"}var B=this._addCurve(R.path,b,u);n.addCurveBinding(P,D,I,B)}},a8._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case sI.TRANSLATION:case sI.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,h=0,d=a.length;h<d;h++){var _=new h_;_.time=a[h],c===e.InterpolationType.CubicSpine?(_.inTangent=new sW(o[u++],o[u++],o[u++]),_.value=new sW(o[u++],o[u++],o[u++]),_.outTangent=new sW(o[u++],o[u++],o[u++])):_.value=new sW(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case sI.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 h_;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new s1(o[g++],o[g++],o[g++],o[g++]),y.value=new sJ(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new s1(o[g++],o[g++],o[g++],o[g++])):y.value=new sJ(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case sI.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var T=0,C=0,S=a.length;C<S;C++){var w=new h_;w.time=a[C],x.interpolation===e.InterpolationType.CubicSpine?(w.inTangent=Array.from(o.subarray(T,T+s)),T+=s,w.value=o.subarray(T,T+s),T+=s,w.outTangent=Array.from(o.subarray(T,T+s)),T+=s):(w.value=o.subarray(T,T+s),T+=s),x.addKey(w)}return x}},a8),dv=(hZ(a6=function(){return dp.apply(this,arguments)},dp),(a7=a6.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)?uN(r,a).then(function(t){return i.push(new dt(r,a)),dd.parseGLB(e,t)}).then(function(t){var n=t.glTF,r=t.buffers;e.glTF=n,e.buffers=r}):uN(r,{type:"json"}).then(function(t){return e.glTF=t,Promise.all(t.buffers.map(function(e){var t=lG.resolveAbsoluteUrl(r,e.uri);return i.push(new dt(t,a)),uN(t,a)})).then(function(t){e.buffers=t})})},a7._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},a6),dy=(hZ(a9=function(){return dp.apply(this,arguments)},dp),(oe=a9.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 lQ(r,o.name||""+a9._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)}},oe._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)}}},oe._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 lQ(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],t.defaultSceneRoot._hookResource=t,t._addReferCount(1)}},a9);dy._defaultName="_GLTF_ENTITY_";var dx=(hZ(ot=function(){return dp.apply(this,arguments)},dp),ot.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=dp.executeExtensionsCreateAndParse(s.extensions,e,s);l||((l=new uW(i)).name=s.name,ot._parseStandardProperty(e,l,s)),a.push(l)}return lb.all(a).then(function(i){n.materials=i;for(var a=0;a<t.materials.length;a++){var o=t.materials[a];dp.executeExtensionsAdditiveAndParse(o.extensions,e,i[a],o)}return r.resolve(i),r.promise})}},ot._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&lv.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},ot._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 s2(s2.linearToGammaSpace(_[0]),s2.linearToGammaSpace(_[1]),s2.linearToGammaSpace(_[2]),_[3])),f&&(n.baseTexture=i[f.index],dp.executeExtensionsAdditiveAndParse(f.extensions,t,n,f)),n.constructor===uW&&(n.metallic=null!=p?p:1,n.roughness=null!=g?g:1,m&&(n.roughnessMetallicTexture=i[m.index],ot._checkOtherTextureTransform(m,"Roughness metallic")))}if(n.constructor===uW||n.constructor===uX){if(l&&(n.emissiveTexture=i[l.index],ot._checkOtherTextureTransform(l,"Emissive")),c&&(n.emissiveColor=new s2(s2.linearToGammaSpace(c[0]),s2.linearToGammaSpace(c[1]),s2.linearToGammaSpace(c[2]))),o){var v=o.index,y=o.scale;n.normalTexture=i[v],ot._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],ot._checkOtherTextureTransform(s,"Occlusion"),void 0!==T&&(n.occlusionTextureIntensity=T),C===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:C>e.TextureCoordinate.UV1&&lv.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,u){case sO.OPAQUE:n.isTransparent=!1;break;case sO.BLEND:n.isTransparent=!0;break;case sO.MASK:n.alphaCutoff=null!=h?h:.5}},ot);function dT(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var dC=(hZ(on=function(){return dp.apply(this,arguments)},dp),on.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=dp.executeExtensionsCreateAndParse(a.extensions,e,a,s);if(l)dT(l,c1)?o(l):l.then(function(e){return o(e)});else{var c=new c1(i,s.name||r+""),u=new dr;u.mesh=c,e.contentRestorer.meshes.push(u),on._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 dd.getAccessorBuffer(e,e.glTF.bufferViews,o)},function(){var e=t.accessors[a.indices];return dd.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 lb.all(o).then(function(e){r.meshes=e,a.resolve(e)}).catch(a.reject),a.promise}},on._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 w=p[g[S]],A=dd.getAccessorBuffer(t,o.bufferViews,w),E=dd.getAccessorTypeSize(w.type),M=w.count,b=A.data,R=void 0,F=n.instanceId,P=A.vertexBindingInfos,L=w.normalized,D=dd.getElementFormat(w.componentType,E,L),I=void 0;L&&(I=dd.getNormalizedComponentScale(w.componentType));var B=void 0;if(A.interleaved){var N=w.byteOffset||0,V=A.stride;if(B=N%V,void 0===P[F]){R=new cq(S,B,D,C);var O=A.vertexBuffer;O||((O=new cY(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static)).setData(b),A.vertexBuffer=O,r.vertexBuffers.push(new di(O,A.restoreInfo))),n.setVertexBufferBinding(O,V,C),P[F]=C++}else R=new cq(S,B,D,P[F])}else{B=0,R=new cq(S,B,D,C);var U=new cY(x,e.BufferBindFlag.VertexBuffer,b.byteLength,e.BufferUsage.Static);U.setData(b),r.vertexBuffers.push(new di(U,A.restoreInfo)),n.setVertexBufferBinding(U,A.stride,C),P[F]=C++}if(T.push(R),"POSITION"===S){h=M;var z=n.bounds,k=z.min,G=z.max;if(w.min&&w.max){if(k.copyFromArray(w.min),G.copyFromArray(w.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 sW(b[K],b[K+1],b[K+2]);L&&j.scale(I),d[X]=j}}else{var q=on._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),sW.min(k,q,k),sW.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 s1(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 s1(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=dd.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&&on._createBlendShape(n,r,i,m,l),n.uploadData(!u),n._positions=d,n._boneIndices=_,n._boneWeights=f,Promise.resolve(n)},on._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?dd.floatBufferToVector3Array(c.data):null,_=(null==u?void 0:u.data)?dd.floatBufferToVector3Array(null==u?void 0:u.data):null,f=(null==h?void 0:h.data)?dd.floatBufferToVector3Array(null==h?void 0:h.data):null,p=new us(l);p.addFrame(1,d,_,f),e.addBlendShape(p),t.blendShapes.push(new dl(p,c.restoreInfo,null==u?void 0:u.restoreInfo,null==h?void 0:h.restoreInfo))}},on);dC._tempVector3=new sW;var dS=(hZ(or=function(){return dp.apply(this,arguments)},dp),(oi=or.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),dp.executeExtensionsAdditiveAndParse(h,e,d,l)}return t.defaultSceneRoot&&this._createAnimator(e),o.resolve(t.defaultSceneRoot),o.promise}},oi._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===sN.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===sN.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},oi._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(c4);f.mesh=i,void 0!==u&&(f.skin=l[u]),_&&(f.blendShapeWeights=new Float32Array(_)),h=f}else(h=n.addComponent(c3)).mesh=i;var p=r.material,g=(null==s?void 0:s[p])||or._getDefaultMaterial(a);h.setMaterial(g),i.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(h.enableVertexColor=!0)}),dp.executeExtensionsAdditiveAndParse(r.extensions,e,h,r)}(f)},oi._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(hs),a=new hl,o=new hc("layer"),s=new hd;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}}},or._getDefaultMaterial=function(e){return or._defaultMaterial||(or._defaultMaterial=new uG(e)),or._defaultMaterial},or),dw=(hZ(oa=function(){return dp.apply(this,arguments)},dp),(oo=oa.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 c2(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[c],m=dd.getAccessorBuffer(e,n.bufferViews,g).data,v=0;v<f;v++){var y=new sZ;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 w=this._findSkeletonRootBone(h,r);if(w)p.skeleton=w.name;else throw"Failed to find skeleton root bone."}o[s]=p}t.skins=o}},oo._findSkeletonRootBone=function(e,t){for(var n,r={},i=h9(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}},oa),dA=(hZ(os=function(){return dp.apply(this,arguments)},dp),(ol=os.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 lb.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:lG.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 dd.loadImageBuffer(T,p).then(function(e){var r=new lT(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 dn(r,y,p);return t.contentRestorer.bufferTextures.push(a),r})})).then(function(e){r.textures=e,l.resolve(e)}).catch(l.reject),l.promise}},ol._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===sU.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=sz.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=os._wrapMap[a]),o&&(t.wrapModeV=os._wrapMap[o])},os);dA._wrapMap=((oc={})[sk.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,oc[sk.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,oc[sk.REPEAT]=e.TextureWrapMode.Repeat,oc);var dE=(hZ(ou=function(){return dp.apply(this,arguments)},dp),ou.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){lv.info("extensionsUsed: ",r);for(var s=0;s<r.length;s++){var l=r[s];dp.hasExtensionParser(l)||lv.warn("Extension "+l+" is not implemented, you can customize this extension in gltf.")}}if(i){lv.info("extensionsRequired: "+i);for(var c=0;c<i.length;c++){var u=i[c];dp.hasExtensionParser(u)?o.push(dp.executeExtensionsInitialize(u)):lv.error("GLTF parser has not supported required extension "+u+".")}}return lb.all(o).then(null)},ou),dM=((oh=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 lb(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)})},oh);dM.defaultPipeline=new dM(dv,dE,dA,dx,dC,dy,dw,dm,dS);var db=(hZ(od=function(e,t){var n;return(n=lu.call(this,e)||this).url=t,n},lu),od),dR=(hZ(o_=function(){return uz.apply(this,arguments)},uz),o_.prototype.load=function(e,t){var n,r=e.url,i=e.params,a=new dc(r),o=new db(t.engine,r),s=new de(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=h9(t);!(e=n()).done;)e.value.cancel()}),((null==i?void 0:i.pipeline)||dM.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},o_);dR=h$([lF(e.AssetType.GLTF,["gltf","glb"])],dR);var dF=Math.PI,dP=(hZ(of=function(){return uz.apply(this,arguments)},uz),of.prototype.load=function(t,n){var r=this;return new lb(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=dP._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,c=dP._readPixels(n.subarray(l),a,s),u=s>>1,h=dP._convertToCubemap(c,a,s,u),d=new lS(o,u),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},of._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)]},of._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},of._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-dF;)i+=2*dF;for(;i>dF;)i-=2*dF;var o=i/dF,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/dF*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 s2(u,h,d,_)},of._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},of._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}},of._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},of._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},of._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},(sG=of)._rightBottomBack=new sW(1,-1,-1),sG._rightBottomFront=new sW(1,-1,1),sG._rightUpBack=new sW(1,1,-1),sG._rightUpFront=new sW(1,1,1),sG._leftBottomBack=new sW(-1,-1,-1),sG._leftBottomFront=new sW(-1,-1,1),sG._leftUpBack=new sW(-1,1,-1),sG._leftUpFront=new sW(-1,1,1),sG._faceRight=[sG._rightBottomBack,sG._rightBottomFront,sG._rightUpBack,sG._rightUpFront],sG._faceLeft=[sG._leftBottomFront,sG._leftBottomBack,sG._leftUpFront,sG._leftUpBack],sG._faceUp=[sG._leftBottomFront,sG._rightBottomFront,sG._leftBottomBack,sG._rightBottomBack],sG._faceBottom=[sG._leftUpBack,sG._rightUpBack,sG._leftUpFront,sG._rightUpFront],sG._faceFront=[sG._leftBottomBack,sG._rightBottomBack,sG._leftUpBack,sG._rightUpBack],sG._faceBack=[sG._rightBottomFront,sG._leftBottomFront,sG._rightUpFront,sG._leftUpFront],sG._tempVector3=new sW,sG._temp2Vector3=new sW,sG._temp3Vector3=new sW,sG._temp4Vector3=new sW,sG._temp5Vector3=new sW,sG);dP=h$([lF(e.AssetType.HDR,["hdr"])],dP);var dL=(hZ(op=function(){return uz.apply(this,arguments)},uz),op.prototype.load=function(e){return this.request(e.url,hQ({},e,{type:"json"}))},op);dL=h$([lF(e.AssetType.JSON,["json"],!1)],dL);var dD={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 dI(e){var t=dD.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var dB=(hZ(og=function(){return uz.apply(this,arguments)},uz),og.prototype.load=function(t,n){var r=this;return new lb(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,hQ({},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=dD.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 lS(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)})})},og);dB=h$([lF(e.AssetType.KTXCube,[])],dB);var dN=(hZ(om=function(){return uz.apply(this,arguments)},uz),om.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){for(var n=dI(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new lT(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)})})},om);dN=h$([lF(e.AssetType.KTX,["ktx"])],dN);var dV=(hZ(ov=function(){return uz.apply(this,arguments)},uz),ov.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},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 s0(i.x,i.y));break;case"Vector3":d.setVector3(e,new sW(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new s1(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new s2(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 cE(i,cz.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)})},ov);function dO(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 dU(e,t,n){return t&&dO(e.prototype,t),n&&dO(e,n),e}dV=h$([lF(e.AssetType.Material,["json"])],dV);var dz=((ox=(oy=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},ox.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},ox.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},ox.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},ox.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},ox.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},ox.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,lG.decodeText(t)},ox.nextImageData=function(e){return this.buffer.slice(this._offset)},ox.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},ox.skip=function(e){return this._offset+=e,this},ox.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)},dU(oy,[{key:"offset",get:function(){return this._offset}}]),oy);dz.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var dk={};function dG(e){return function(t){dk[e]=t}}var dH=((oT=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=lG.decodeText(s),c=lG.decodeText(a),u=new oT;return u.totalLength=n,u.name=l,u.type=c,u.version=r,u.headerLength=s.byteLength+a.byteLength+9,u},dU(oT,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oT);function dW(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new s1(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function dX(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sW(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 s0(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 i=new(Function.bind.apply(e,r));return n&&hJ(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((oC=function(){}).decode=function(e,t){return new Promise(function(n){var r=new c1(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=dX(o,s);if(r.setPositions(l),i.normals){var c=dX(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 s2(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(dW(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(dW(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new us(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=dX(r,i);e.deltaNormals&&dX(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&dW(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)})},oC),e.MeshDecoder=h$([dG("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oS=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 lT(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)}})},oS),e.Texture2DDecoder=h$([dG("Texture2D")],e.Texture2DDecoder);var dq=((ow=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},ow.parseEntity=function(e,t){return ow.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})},ow.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 lQ(t,e.name))},ow.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=dj(uz.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},ow.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)},ow.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})},ow.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)})},ow._isClass=function(e){return void 0!=e.class},ow._isRef=function(e){return void 0!=e.refId},ow);dq.customParseComponentHandles=new Map;var dY=((oA=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)}},oA),dQ={Transform:lq,Animator:hs,DirectLight:c_,Camera:e.Camera,MeshRenderer:c3,ParticleRenderer:hg,PointLight:cf,SpotLight:cp,Script:uS,SpriteMask:cK,SpriteRenderer:uJ,TextRenderer:u0};e.InterpolableValueType=void 0,(oE=e.InterpolableValueType||(e.InterpolableValueType={}))[oE.Float=0]="Float",oE[oE.FloatArray=1]="FloatArray",oE[oE.Vector2=2]="Vector2",oE[oE.Vector3=3]="Vector3",oE[oE.Vector4=4]="Vector4",oE[oE.Quaternion=5]="Quaternion",oE[oE.Color=6]="Color",oE[oE.Array=7]="Array",oE[oE.Boolean=8]="Boolean",e.AnimationClipDecoder=((oM=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new he(r),a=n.nextUint16(),o=0;o<a;++o){var s=new u9;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=dQ[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 h_;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 h_;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 h_;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 w=0;w<p;++w){var A=new h_;A.time=n.nextFloat32(),A.value=new s0(n.nextFloat32(),n.nextFloat32()),A.inTangent=new s0(n.nextFloat32(),n.nextFloat32()),A.outTangent=new s0(n.nextFloat32(),n.nextFloat32()),_.addKey(A)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var E=0;E<p;++E){var M=new h_;M.time=n.nextFloat32(),M.value=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sW(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var b=new h_;b.time=n.nextFloat32(),b.value=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(b);break;case"AnimationColorCurve":(_=_||new e.AnimationColorCurve).interpolation=f;for(var R=0;R<p;++R){var F=new h_;F.time=n.nextFloat32(),F.value=new s2(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(F)}break;case"AnimationQuaternionCurve":(_=_||new e.AnimationQuaternionCurve).interpolation=f;for(var P=0;P<p;++P){var L=new h_;L.time=n.nextFloat32(),L.value=new sJ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new s1(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(u,h,d,_)}t(i)})},oM),e.AnimationClipDecoder=h$([dG("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(ob=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",ob.Custom="Custom";var dJ=((oR=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},oR),dZ=((oP=(oF=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)},oP._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),dq.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})},oP._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=h9(a);!(e=o()).done;){var s=e.value;dY.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])},oP._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(uz.getClass(c))),u=u||o.addComponent(uz.getClass(c));var h=dq.parsePropsAndMethods(u,l,o.engine);n.push(h)}return Promise.all(n)},oP._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oF.parse=function(e,t){var n=new um(e),r=new dJ(t,n),i=new oF(r);return i.start(),i.promise},oF);function d$(e,t){var n=dH.decode(e),r=new dz(e,n.headerLength,n.dataLength);return dk[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(hZ(oL=function(){return uz.apply(this,arguments)},uz),oL.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){d$(e,t.engine).then(function(e){r(e)})})})},oL),e.MeshLoader=h$([lF("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(hZ(oD=function(){return uz.apply(this,arguments)},uz),oD.prototype.load=function(e,t){var n=this;return new lb(function(r){n.request(e.url,{type:"arraybuffer"}).then(function(e){d$(e,t.engine).then(function(e){r(e)})})})},oD),e.EditorTextureLoader=h$([lF("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var d0=(hZ(oI=function(){return uz.apply(this,arguments)},uz),oI.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){return d$(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oI);d0=h$([lF(e.AssetType.Mesh,["mesh"])],d0);var d1=(hZ(oB=function(){return uz.apply(this,arguments)},uz),(oN=oB.prototype).load=function(e,t){var n=this;return new lb(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new lM(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},oN._registerFont=function(e,t){return h5(function(){var n;return h0(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);d1=h$([lF(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],d1);var d2=(hZ(oV=function(){var e;return e=uz.apply(this,arguments)||this,e._tempRect=new s3,e._tempVec2=new s0,e._tempVec4=new s1,e},uz),(oO=oV.prototype).load=function(t,n){var r=this;return new lb(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,hQ({},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 uj(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:lG.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);lb.all(l).then(function(){i(m)}).catch(a)}).catch(a)})},oO._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new uq(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},oV);d2=h$([lF(e.AssetType.SpriteAtlas,["atlas"],!1)],d2);var d3=(hZ(oU=function(){return uz.apply(this,arguments)},uz),oU.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},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 uq(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new uq(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},oU);d3=h$([lF(e.AssetType.Sprite,["sprite"],!1)],d3);var d4=(hZ(oz=function(e,t,n){var r;return(r=lh.call(this,e)||this).url=t,r.requestConfig=n,r},lh),oz.prototype.restoreContent=function(){var e=this;return uN(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},oz),d5=(hZ(ok=function(){return uz.apply(this,arguments)},uz),ok.prototype.load=function(e,t){var n=this;return new lb(function(r,i){var a=e.url,o=hQ({},e,{type:"image"});n.request(a,o).then(function(n){var i=e.params,s=new lT(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 d4(s,a,o)),r(s)}).catch(function(e){i(e)})})},ok);d5=h$([lF(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],d5);var d8=(hZ(oG=function(e,t,n){var r;return(r=lh.call(this,e)||this).urls=t,r.requestConfig=n,r},lh),oG.prototype.restoreContent=function(){var t=this;return new lb(function(n,r){Promise.all(t.urls.map(function(e){return uN(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)})})},oG),d6=(hZ(oH=function(){return uz.apply(this,arguments)},uz),oH.prototype.load=function(t,n){var r=this;return new lb(function(i,a){var o=t.urls,s=hQ({},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 lS(n.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),n.addContentRestorer(new d8(l,o,s)),i(l)}).catch(function(e){a(e)})})},oH);d6=h$([lF(e.AssetType.TextureCube,[""])],d6);var d7=(hZ(oW=function(){return uz.apply(this,arguments)},uz),oW.prototype.load=function(e,t){var n=this;return new lb(function(r,i){n.request(e.url,hQ({},e,{type:"arraybuffer"})).then(function(e){return d$(e,t.engine)}).catch(i)})},oW);d7=h$([lF(e.AssetType.AnimationClip,["ani"])],d7);var d9=(hZ(oX=function(){return uz.apply(this,arguments)},uz),oX.prototype.load=function(t,n){var r=this,i=n.engine;return new lb(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),dZ.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 lv.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)})},oX);d9=h$([lF(e.AssetType.Scene,["prefab"],!0)],d9),dq.registerCustomParseComponent("TextRenderer",h5(function(e,t,n){var r;return h0(this,function(i){return(r=t.props).font||(e.font=lM.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var _e=(hZ(oK=function(){return df.apply(this,arguments)},df),(oj=oK.prototype).initialize=function(){_e._decoder||(_e._decoder=new hY)},oj.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]=dd.getComponentType(g.componentType).name}var m=c[n.indices],v=dd.getComponentType(m.componentType).name,y=dd.getBufferViewData(l[u],o);return _e._decoder.decode(y,{attributeIDs:d,attributeTypes:_,useUniqueIDs:!0,indexType:v}).then(function(t){var o=new c1(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)})},oj._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=dd.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=_e._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),sW.min(y,v,y),sW.max(x,v,x)}}for(var w in c)if("POSITION"!==w){var A=i(w);switch(w){case"NORMAL":var E=dd.floatBufferToVector3Array(A);e.setNormals(E);break;case"TEXCOORD_0":var M=dd.floatBufferToVector2Array(A);e.setUVs(M,0);break;case"TEXCOORD_1":var b=dd.floatBufferToVector2Array(A);e.setUVs(b,1);break;case"TEXCOORD_2":var R=dd.floatBufferToVector2Array(A);e.setUVs(R,2);break;case"TEXCOORD_3":var F=dd.floatBufferToVector2Array(A);e.setUVs(F,3);break;case"TEXCOORD_4":var P=dd.floatBufferToVector2Array(A);e.setUVs(P,4);break;case"TEXCOORD_5":var L=dd.floatBufferToVector2Array(A);e.setUVs(L,5);break;case"TEXCOORD_6":var D=dd.floatBufferToVector2Array(A);e.setUVs(D,6);break;case"TEXCOORD_7":var I=dd.floatBufferToVector2Array(A);e.setUVs(I,7);break;case"COLOR_0":var B=dd.floatBufferToColorArray(A,_[c.COLOR_0].type===sD.VEC3);e.setColors(B);break;case"TANGENT":var N=dd.floatBufferToVector4Array(A);e.setTangents(N);break;case"JOINTS_0":var V=dd.floatBufferToVector4Array(A);e.setBoneIndices(V);break;case"WEIGHTS_0":var O=dd.floatBufferToVector4Array(A);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&&dC._createBlendShape(e,null,t,u,a),e.uploadData(!s),Promise.resolve(e)},oK._tempVector3=new sW,oK);_e=h$([dg("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],_e);var _t=(hZ(oq=function(){return df.apply(this,arguments)},df),oq.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(c_):"point"===s?r=t.addComponent(cf):"spot"===s&&(r=t.addComponent(cp)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!dT(r,c_)&&(r.distance=l),c&&dT(r,cp)){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)},oq);_t=h$([dg("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],_t);var _n=(hZ(oY=function(){return df.apply(this,arguments)},df),oY.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],dx._checkOtherTextureTransform(a,"Clear coat")),s&&(t.clearCoatRoughnessTexture=r[s.index],dx._checkOtherTextureTransform(s,"Clear coat roughness")),l&&(t.clearCoatNormalTexture=r[l.index],dx._checkOtherTextureTransform(l,"Clear coat normal"))},oY);_n=h$([dg("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],_n);var _r=(hZ(oQ=function(){return df.apply(this,arguments)},df),oQ.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},oQ);_r=h$([dg("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],_r);var _i=(hZ(oJ=function(){return df.apply(this,arguments)},df),oJ.prototype.createAndParse=function(e,t,n){var r=e.glTFResource,i=r.engine,a=r.textures,o=new uX(i),s=t.diffuseFactor,l=t.diffuseTexture,c=t.specularFactor,u=t.glossinessFactor,h=t.specularGlossinessTexture;return s&&(o.baseColor=new s2(s2.linearToGammaSpace(s[0]),s2.linearToGammaSpace(s[1]),s2.linearToGammaSpace(s[2]),s[3])),l&&(o.baseTexture=a[l.index],dp.executeExtensionsAdditiveAndParse(l.extensions,e,o,l)),c&&(o.specularColor=new s2(s2.linearToGammaSpace(c[0]),s2.linearToGammaSpace(c[1]),s2.linearToGammaSpace(c[2]))),void 0!==u&&(o.glossiness=u),h&&(o.specularGlossinessTexture=a[h.index],dx._checkOtherTextureTransform(h,"Specular glossiness")),o.name=n.name,dx._parseStandardProperty(e,o,n),o},oJ);_i=h$([dg("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],_i);var _a=(hZ(oZ=function(){return df.apply(this,arguments)},df),oZ.prototype.createAndParse=function(e,t,n){var r=e.glTFResource.engine,i=new uK(r);return i.name=n.name,dx._parseStandardProperty(e,i,n),i},oZ);_a=h$([dg("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],_a);var _o=(hZ(o$=function(){return df.apply(this,arguments)},df),o$);_o=h$([dg("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],_o);var _s=(hZ(o0=function(){return df.apply(this,arguments)},df),o0.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&&lv.warn("rotation in KHR_texture_transform is not supported now"),o&&lv.warn("texCoord in KHR_texture_transform is not supported now")},o0);_s=h$([dg("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],_s);var _l=(hZ(o1=function(){return df.apply(this,arguments)},df),o1.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},o1);_l=h$([dg("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],_l);var _c=(hZ(o2=function(){return df.apply(this,arguments)},df),o2.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new u9;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},o2);_c=h$([dg("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],_c);var _u="1.0.0-beta.14";for(var _h in console.log("Galacean engine version: "+_u),hA)uz.registerClass(_h,hA[_h]);e.AmbientLight=ug,e.AnimationClip=he,e.AnimationClipCurveBinding=u7,e.AnimationCurve=ht,e.AnimationEvent=u9,e.Animator=hs,e.AnimatorController=hl,e.AnimatorControllerLayer=hc,e.AnimatorState=hh,e.AnimatorStateMachine=hd,e.AnimatorStateTransition=hr,e.AssetPromise=lb,e.Background=up,e.BaseMaterial=uk,e.Basic2DBatcher=ul,e.BasicRenderPipeline=uL,e.BlendShape=us,e.BlendShapeFrame=uo,e.BlendState=cT,e.BlinnPhongMaterial=uG,e.BoolUpdateFlag=lK,e.BoundingBox=sK,e.BoundingFrustum=sY,e.BoundingSphere=sX,e.BoxColliderShape=l5,e.Buffer=cY,e.BufferMesh=ua,e.BufferUtil=cj,e.CapsuleColliderShape=l7,e.CharacterController=l3,e.CloneManager=ll,e.ColliderShape=l4,e.CollisionUtil=sj,e.Color=s2,e.Component=lU,e.ComponentMap=dQ,e.ContentRestorer=lh,e.CubeProbe=hw,e.DepthState=cC,e.DirectLight=c_,e.DynamicCollider=co,e.Engine=uC,e.EngineObject=lc,e.Entity=lQ,e.EventDispatcher=lI,e.FixedJoint=ce,e.Font=lM,e.GLTFAnimationParser=dm,e.GLTFBufferParser=dv,e.GLTFEntityParser=dy,e.GLTFExtensionParser=df,e.GLTFMaterialParser=dx,e.GLTFMeshParser=dC,e.GLTFParser=dp,e.GLTFParserContext=dc,e.GLTFPipeline=dM,e.GLTFResource=db,e.GLTFSceneParser=dS,e.GLTFSkinParser=dw,e.GLTFTextureParser=dA,e.GLTFUtils=dd,e.GLTFValidator=dE,e.HingeJoint=ct,e.HitResult=l0,e.IndexBufferBinding=cQ,e.InputManager=ch,e.JointLimits=cr,e.JointMotor=ci,e.Keyframe=h_,e.Light=cd,e.Loader=uz,e.Logger=lv,e.Material=cE,e.MathUtil=sH,e.Matrix=sZ,e.Matrix3x3=sQ,e.Mesh=cZ,e.MeshRenderer=c3,e.ModelMesh=c1,e.PBRBaseMaterial=uH,e.PBRMaterial=uW,e.PBRSpecularMaterial=uX,e.ParticleRenderer=hg,e.PhysicsManager=l1,e.PhysicsMaterial=l2,e.Plane=sq,e.PlaneColliderShape=l6,e.PointLight=cf,e.Pointer=lJ,e.PrefabParser=dY,e.PrimitiveMesh=ui,e.Probe=hx,e.Quaternion=sJ,e.RasterState=cS,e.Ray=s$,e.Rect=s3,e.ReferResource=lu,e.ReflectionParser=dq,e.RenderPass=uP,e.RenderQueue=uA,e.RenderState=cA,e.RenderTarget=lx,e.RenderTargetBlendState=cx,e.ResourceManager=lR,e.Scene=um,e.SceneManager=uv,e.SceneParser=dZ,e.Script=uS,e.Shader=cz,e.ShaderData=cy,e.ShaderFactory=cL,e.ShaderMacro=cm,e.ShaderMacroCollection=cv,e.ShaderPass=cO,e.ShaderProperty=lB,e.ShaderTagKey=cD,e.Skin=c2,e.SkinnedMeshRenderer=c4,e.Sky=uf,e.SkyBoxMaterial=hf,e.SkyProceduralMaterial=hp,e.SphereColliderShape=l8,e.SphericalHarmonics3=s4,e.SpotLight=cp,e.SpringJoint=cn,e.Sprite=uq,e.SpriteAtlas=uj,e.SpriteMask=cK,e.SpriteRenderer=uJ,e.StateMachineScript=hu,e.StaticCollider=ca,e.StencilState=cw,e.SubMesh=cJ,e.SubShader=cU,e.SystemInfo=lZ,e.TextRenderer=u0,e.TextUtils=lA,e.Texture=ly,e.Texture2D=lT,e.Texture2DArray=lC,e.TextureCube=lS,e.Time=lN,e.TrailMaterial=hm,e.TrailRenderer=hy,e.Transform=lq,e.UnlitMaterial=uK,e.Utils=lG,e.Vector2=s0,e.Vector3=sW,e.Vector4=s1,e.VertexBufferBinding=c$,e.VertexElement=cq,e.WebCanvas=hR,e.WebGLEngine=hL,e.WebGLGraphicDevice=hW,e.assignmentClone=la,e.decode=d$,e.deepClone=ls,e.dependentComponents=lk,e.ignoreClone=li,e.parseSingleKTX=dI,e.registerGLTFExtension=dg,e.request=uN,e.resourceLoader=lF,e.shallowClone=lo,e.version=_u,Object.defineProperty(e,"__esModule",{value:!0})});
|