@galacean/engine 0.0.0-experimental-0.9-plus.8 → 0.0.0-experimental-double11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,(ob=e.ContainmentType||(e.ContainmentType={}))[ob.Disjoint=0]="Disjoint",ob[ob.Contains=1]="Contains",ob[ob.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(oA=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[oA.Back=0]="Back",oA[oA.Front=1]="Front",oA[oA.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(oM=e.FrustumFace||(e.FrustumFace={}))[oM.Near=0]="Near",oM[oM.Far=1]="Far",oM[oM.Left=2]="Left",oM[oM.Right=3]="Right",oM[oM.Bottom=4]="Bottom",oM[oM.Top=5]="Top";var i,a,o,s,l,u,c,h,d,_,f,p,g,m,v,y,x,T,C,S,w,b,A,M,F,P,E,R,L,B,D,I,O,V,U,z,N,k,G,H,W,X,j,K,q,Y,Q,J,Z,$,ee,et,en,er,ei,ea,eo,es,el,eu,ec,eh,ed,e_,ef,ep,eg,em,ev,ey,ex,eT,eC,eS,ew,eb,eA,eM,eF,eP,eE,eR,eL,eB,eD,eI,eO,eV,eU,ez,eN,ek,eG,eH,eW,eX,ej,eK,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,tu,tc,th,td,t_,tf,tp,tg,tm,tv,ty,tx,tT,tC,tS,tw,tb,tA,tM,tF,tP,tE,tR,tL,tB,tD,tI,tO,tV,tU,tz,tN,tk,tG,tH,tW,tX,tj,tK,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,nu,nc,nh,nd,n_,nf,np,ng,nm,nv,ny,nx,nT,nC,nS,nw,nb,nA,nM,nF,nP,nE,nR,nL,nB,nD,nI,nO,nV,nU,nz,nN,nk,nG,nH,nW,nX,nj,nK,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,ru,rc,rh,rd,r_,rf,rp,rg,rm,rv,ry,rx,rT,rC,rS,rw,rb,rA,rM,rF,rP,rE,rR,rL,rB,rD,rI,rO,rV,rU,rz,rN,rk,rG,rH,rW,rX,rj,rK,rq,rY,rQ,rJ,rZ,r$,r0,r1,r2,r3,r4,r5,r8,r6,r7,r9,ie,it,ir,ii,ia,io,is,il,iu,ic,ih,id,i_,ip,ig,im,iv,iy,ix,iT,iC,iS,iw,ib,iA,iM,iF,iP,iE,iR,iL,iB,iD,iI,iO,iV,iU,iz,iN,ik,iG,iH,iW,iX,ij,iK,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,au,ac,ah,ad,a_,af,ap,ag,am,av,ay,ax,aT,aC,aS,aw,ab,aA,aM,aF,aP,aE,aR,aL,aB,aD,aI,aO,aV,aU,az,aN,ak,aG,aH,aW,aX,aj,aK,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,ou,oc,oh,od,o_,of,op,og,om,ov,oy,ox,oT,oC,oS,ow,ob,oA,oM,oF,oP,oE,oR,oL,oB,oD,oI,oO,oV,oU,oz,oN,ok,oG,oH,oW,oX,oj,oK,oq,oY,oQ,oJ,oZ,o$,o0,o1,o2,o3,o4,o5,o8,o6,o7,o9,se,st,sn,sr,si,sa,so,ss=((oF=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},oF.equals=function(e,t){return Math.abs(e-t)<=oF.zeroTolerance},oF.isPowerOf2=function(e){return(e&e-1)==0},oF.radianToDegree=function(e){return e*oF.radToDegreeFactor},oF.degreeToRadian=function(e){return e*oF.degreeToRadFactor},oF);ss.zeroTolerance=1e-6,ss.radToDegreeFactor=180/Math.PI,ss.degreeToRadFactor=Math.PI/180;var sl=((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 ss.equals(e._x,t._x)&&ss.equals(e._y,t._y)&&ss.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>ss.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,u=t._w,c=u*r+s*a-l*i,h=u*i+l*r-o*a,d=u*a+o*i-s*r,_=-o*r-s*i-l*a;n._x=c*u-_*o-h*l+d*s,n._y=h*u-_*s-d*o+c*l,n._z=d*u-_*l-c*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);sl._zero=new sl(0,0,0),sl._one=new sl(1,1,1);var su=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sl,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)sl.add(e[i],r,r);sl.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sl.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=sl.distance(n,i)},o);su._tempVec30=new sl;var sc=((u=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sl,this.max=new sl,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sl.add(this.min,this.max,e),sl.scale(e,.5,e),e},u.getExtent=function(e){return sl.subtract(this.max,this.min,e),sl.scale(e,.5,e),e},u.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,u=e.length;if(u<8)for(var c=0,h=8-u;c<h;++c)e[u+c]=new sl;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},u.transform=function(e){return l.transform(this,e,this),this},u.clone=function(){return new l(this.min,this.max)},u.copyFrom=function(e){return this.min.copyFrom(e.min),this.max.copyFrom(e.max),this},l.fromCenterAndExtent=function(e,t,n){sl.subtract(e,t,n.min),sl.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];sl.min(n,o,n),sl.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),sl.transformCoordinate(r,t,r);var a=i.x,o=i.y,s=i.z,u=t.elements;i.x=Math.abs(a*u[0])+Math.abs(o*u[4])+Math.abs(s*u[8]),i.y=Math.abs(a*u[1])+Math.abs(o*u[5])+Math.abs(s*u[9]),i.z=Math.abs(a*u[2])+Math.abs(o*u[6])+Math.abs(s*u[10]),sl.subtract(r,i,n.min),sl.add(r,i,n.max)},l.merge=function(e,t,n){return sl.min(e.min,t.min,n.min),sl.max(e.max,t.max,n.max),n},l);sc._tempVec30=new sl,sc._tempVec31=new sl;var sh=((c=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sl.cross(a,o,c._tempVec30),sl.cross(o,i,c._tempVec31),sl.cross(i,a,c._tempVec32);var s=-sl.dot(i,c._tempVec30),l=-sl.dot(a,c._tempVec31),u=-sl.dot(o,c._tempVec32);sl.scale(c._tempVec30,e.distance/s,c._tempVec30),sl.scale(c._tempVec31,t.distance/l,c._tempVec31),sl.scale(c._tempVec32,n.distance/u,c._tempVec32),sl.add(c._tempVec30,c._tempVec31,r),sl.add(r,c._tempVec32,r)},c.distancePlaneAndPoint=function(e,t){return sl.dot(e.normal,t)+e.distance},c.intersectsPlaneAndPoint=function(t,n){var r=c.distancePlaneAndPoint(t,n);return r>0?e.PlaneIntersectionType.Front:r<0?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},c.intersectsPlaneAndBox=function(t,n){var r=n.min,i=n.max,a=t.normal,o=c._tempVec30,s=c._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>c.distancePlaneAndPoint(t,o))?e.PlaneIntersectionType.Back:c.distancePlaneAndPoint(t,s)>0?e.PlaneIntersectionType.Front:e.PlaneIntersectionType.Intersecting},c.intersectsPlaneAndSphere=function(t,n){var r=n.center,i=n.radius,a=c.distancePlaneAndPoint(t,r);return a>i?e.PlaneIntersectionType.Front:a<-i?e.PlaneIntersectionType.Back:e.PlaneIntersectionType.Intersecting},c.intersectsRayAndPlane=function(e,t){var n=t.normal,r=ss.zeroTolerance,i=sl.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sl.dot(n,e.origin),o=(-t.distance-a)/i;if(o<0){if(o<-r)return -1;o=0}return o},c.intersectsRayAndBox=function(e,t){var n=ss.zeroTolerance,r=e.origin,i=e.direction,a=t.min,o=t.max,s=i.x,l=i.y,u=i.z,c=r.x,h=r.y,d=r.z,_=0,f=Number.MAX_VALUE;if(Math.abs(s)<n){if(c<a.x||c>o.x)return -1}else{var p=1/s,g=(a.x-c)*p,m=(o.x-c)*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(u)<n){if(d<a.z||d>o.z)return -1}else{var S=1/u,w=(a.z-d)*S,b=(o.z-d)*S;if(w>b){var A=w;w=b,b=A}if((_=Math.max(w,_))>(f=Math.min(b,f)))return -1}return _},c.intersectsRayAndSphere=function(e,t){var n=e.origin,r=e.direction,i=t.center,a=t.radius,o=c._tempVec30;sl.subtract(n,i,o);var s=sl.dot(o,r),l=sl.dot(o,o)-a*a;if(s>0&&l>0)return -1;var u=s*s-l;if(u<0)return -1;var h=-s-Math.sqrt(u);return h<0&&(h=0),h},c.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)},c.intersectsSphereAndSphere=function(e,t){var n=e.radius+t.radius;return sl.distanceSquared(e.center,t.center)<n*n},c.intersectsSphereAndBox=function(e,t){var n=e.center,r=t.max,i=t.min,a=c._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))),sl.distanceSquared(n,a)<=e.radius*e.radius},c.intersectsFrustumAndBox=function(e,t){for(var n=t.min,r=t.max,i=c._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),sl.dot(s,i)<-o.distance)return!1}return!0},c.frustumContainsBox=function(t,n){for(var r=n.min,i=n.max,a=c._tempVec30,o=c._tempVec31,s=e.ContainmentType.Contains,l=0;l<6;++l){var u=t.getPlane(l),h=u.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),c.intersectsPlaneAndPoint(u,a)===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;c.intersectsPlaneAndPoint(u,o)===e.PlaneIntersectionType.Back&&(s=e.ContainmentType.Intersects)}return s},c.frustumContainsSphere=function(t,n){for(var r=e.ContainmentType.Contains,i=0;i<6;++i){var a=t.getPlane(i),o=c.intersectsPlaneAndSphere(a,n);if(o===e.PlaneIntersectionType.Back)return e.ContainmentType.Disjoint;if(o===e.PlaneIntersectionType.Intersecting){r=e.ContainmentType.Intersects;break}}return r},c);sh._tempVec30=new sl,sh._tempVec31=new sl,sh._tempVec32=new sl;var sd=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sl,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();sl.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,u=t.z-o,c=n.x-i,h=n.y-a,d=n.z-o,_=l*d-u*h,f=u*c-s*d,p=s*h-l*c,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),s_=((f=(_=function(e){void 0===e&&(e=null),this.near=new sd,this.far=new sd,this.left=new sd,this.right=new sd,this.top=new sd,this.bottom=new sd,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],u=t[7],c=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,u+l,_+d),this.near.distance=m+g,this.near.normalize(),this.far.normal.set(a-i,u-l,_-d),this.far.distance=m-g,this.far.normalize(),this.left.normal.set(a+n,u+o,_+c),this.left.distance=m+f,this.left.normalize(),this.right.normal.set(a-n,u-o,_-c),this.right.distance=m-f,this.right.normalize(),this.bottom.normal.set(a+r,u+s,_+h),this.bottom.distance=m+p,this.bottom.normalize(),this.top.normal.set(a-r,u-s,_-h),this.top.distance=m-p,this.top.normalize()},f.intersectsBox=function(e){return sh.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return sh.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},_),sf=((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 u=this.elements;u[0]=e,u[1]=t,u[2]=n,u[3]=r,u[4]=i,u[5]=a,u[6]=o,u[7]=s,u[8]=l}).prototype).set=function(e,t,n,r,i,a,o,s,l){var u=this.elements;return u[0]=e,u[1]=t,u[2]=n,u[3]=r,u[4]=i,u[5]=a,u[6]=o,u[7]=s,u[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],u=e[8];return t*(u*a-o*l)+n*(-u*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],u=r[3],c=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+u*g+d*m,a[1]=s*p+c*g+_*m,a[2]=l*p+h*g+f*m,a[3]=o*v+u*y+d*x,a[4]=s*v+c*y+_*x,a[5]=l*v+h*y+f*x,a[6]=o*T+u*C+d*S,a[7]=s*T+c*C+_*S,a[8]=l*T+h*C+f*S},p.equals=function(e,t){var n=e.elements,r=t.elements;return ss.equals(n[0],r[0])&&ss.equals(n[1],r[1])&&ss.equals(n[2],r[2])&&ss.equals(n[3],r[3])&&ss.equals(n[4],r[4])&&ss.equals(n[5],r[5])&&ss.equals(n[6],r[6])&&ss.equals(n[7],r[7])&&ss.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,u=a+a,c=r*s,h=i*s,d=i*l,_=a*s,f=a*l,p=a*u,g=o*s,m=o*l,v=o*u;n[0]=1-d-p,n[3]=h-v,n[6]=_+m,n[1]=h+v,n[4]=1-c-p,n[7]=f-g,n[2]=_-m,n[5]=f+g,n[8]=1-c-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],u=n[5],c=n[6],h=n[7],d=n[8],_=d*l-u*h,f=-d*s+u*c,p=h*s-l*c,g=i*_+a*f+o*p;g&&(g=1/g,r[0]=_*g,r[1]=(-d*a+o*h)*g,r[2]=(u*a-o*l)*g,r[3]=f*g,r[4]=(d*i-o*c)*g,r[5]=(-u*i+o*s)*g,r[6]=p*g,r[7]=(-h*i+a*c)*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],u=n[5],c=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*u-a*l,T=i*c-o*l,C=i*h-s*l,S=a*c-o*u,w=a*h-s*u,b=o*h-s*c,A=d*m-_*g,M=d*v-f*g,F=d*y-p*g,P=_*v-f*m,E=_*y-p*m,R=f*y-p*v,L=x*R-T*E+C*P+S*F-w*M+b*A;if(!L)return null;L=1/L,r[0]=(u*R-c*E+h*P)*L,r[1]=(c*F-l*R-h*M)*L,r[2]=(l*E-u*F+h*A)*L,r[3]=(o*E-a*R-s*P)*L,r[4]=(i*R-o*F+s*M)*L,r[5]=(a*F-i*E-s*A)*L,r[6]=(m*b-v*w+y*S)*L,r[7]=(v*C-g*b-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],u=r[2],c=r[3],h=r[4],d=r[5],_=r[6],f=r[7],p=r[8];i[0]=o*s+a*c,i[1]=o*l+a*h,i[2]=o*u+a*d,i[3]=o*c-a*s,i[4]=o*h-a*l,i[5]=o*d-a*u,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],u=a[2],c=a[3],h=a[4],d=a[5],_=a[6],f=a[7],p=a[8];o[0]=s,o[1]=l,o[2]=u,o[3]=c,o[4]=h,o[5]=d,o[6]=r*s+i*c+_,o[7]=r*l+i*h+f,o[8]=r*u+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),sp=((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<ss.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,u=t._z,c=t._w;n._x=r*c+o*s+i*u-a*l,n._y=i*c+o*l+a*s-r*u,n._z=a*c+o*u+r*l-i*s,n._w=o*c-r*s-i*l-a*u,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 ss.equals(e._x,t._x)&&ss.equals(e._y,t._y)&&ss.equals(e._z,t._z)&&ss.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sl.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),u=Math.sin(a),c=Math.cos(a),h=Math.sin(o),d=Math.cos(o),_=d*c,f=h*u;r._x=d*u*l+h*c*s,r._y=h*c*l-d*u*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],u=i[4],c=i[5],h=i[6],d=i[7],_=i[8],f=a+u+_;f>0?(n=Math.sqrt(f+1),t._w=.5*n,n=.5/n,t._x=(c-d)*n,t._y=(h-s)*n,t._z=(o-l)*n):a>=u&&a>=_?(r=.5/(n=Math.sqrt(1+a-u-_)),t._x=.5*n,t._y=(o+l)*r,t._z=(s+h)*r,t._w=(c-d)*r):u>_?(r=.5/(n=Math.sqrt(1+u-a-_)),t._x=(l+o)*r,t._y=.5*n,t._z=(d+c)*r,t._w=(h-s)*r):(r=.5/(n=Math.sqrt(1+_-a-u)),t._x=(s+h)*r,t._y=(c+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>ss.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-ss.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>ss.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)<ss.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);sp._tempVector3=new sl,sp._tempQuat1=new sp;var sg=((x=(y=function(e,t,n,r,i,a,o,s,l,u,c,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===u&&(u=0),void 0===c&&(c=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]=u,g[10]=c,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,u,c,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]=u,g[10]=c,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],u=e[8],c=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)*(c*g-d*f)+(t*l-i*a)*(c*p-h*f)+(n*s-r*o)*(u*g-d*_)-(n*l-i*o)*(u*p-h*_)+(r*l-i*s)*(u*f-c*_)},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],u=i[3],c=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*u)?-1:1)*Math.sqrt(o*o+s*s+l*l),x=(0>Math.sign(c*h*d*_)?-1:1)*Math.sqrt(c*c+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)<ss.zeroTolerance||Math.abs(x)<ss.zeroTolerance||Math.abs(T)<ss.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]=c*S,a[4]=h*S,a[5]=d*S,a[6]=f*w,a[7]=p*w,a[8]=g*w,sp.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>ss.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],u=t[9],c=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+u*u+c*c)),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],u=r[3],c=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],b=i[3],A=i[4],M=i[5],F=i[6],P=i[7],E=i[8],R=i[9],L=i[10],B=i[11],D=i[12],I=i[13],O=i[14],V=i[15];a[0]=o*C+c*S+f*w+v*b,a[1]=s*C+h*S+p*w+y*b,a[2]=l*C+d*S+g*w+x*b,a[3]=u*C+_*S+m*w+T*b,a[4]=o*A+c*M+f*F+v*P,a[5]=s*A+h*M+p*F+y*P,a[6]=l*A+d*M+g*F+x*P,a[7]=u*A+_*M+m*F+T*P,a[8]=o*E+c*R+f*L+v*B,a[9]=s*E+h*R+p*L+y*B,a[10]=l*E+d*R+g*L+x*B,a[11]=u*E+_*R+m*L+T*B,a[12]=o*D+c*I+f*O+v*V,a[13]=s*D+h*I+p*O+y*V,a[14]=l*D+d*I+g*O+x*V,a[15]=u*D+_*I+m*O+T*V},y.equals=function(e,t){var n=e.elements,r=t.elements;return ss.equals(n[0],r[0])&&ss.equals(n[1],r[1])&&ss.equals(n[2],r[2])&&ss.equals(n[3],r[3])&&ss.equals(n[4],r[4])&&ss.equals(n[5],r[5])&&ss.equals(n[6],r[6])&&ss.equals(n[7],r[7])&&ss.equals(n[8],r[8])&&ss.equals(n[9],r[9])&&ss.equals(n[10],r[10])&&ss.equals(n[11],r[11])&&ss.equals(n[12],r[12])&&ss.equals(n[13],r[13])&&ss.equals(n[14],r[14])&&ss.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,u=a+a,c=r*s,h=i*s,d=i*l,_=a*s,f=a*l,p=a*u,g=o*s,m=o*l,v=o*u;n[0]=1-d-p,n[1]=h+v,n[2]=_-m,n[3]=0,n[4]=h-v,n[5]=1-c-p,n[6]=f+g,n[7]=0,n[8]=_+m,n[9]=f-g,n[10]=1-c-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,u=e._z,c=Math.sqrt(s*s+l*l+u*u);Math.abs(c)<ss.zeroTolerance||(s*=c=1/c,l*=c,u*=c,r=Math.sin(t),a=1-(i=Math.cos(t)),o[0]=s*s*a+i,o[1]=l*s*a+u*r,o[2]=u*s*a-l*r,o[3]=0,o[4]=s*l*a-u*r,o[5]=l*l*a+i,o[6]=u*l*a+s*r,o[7]=0,o[8]=s*u*a+l*r,o[9]=l*u*a-s*r,o[10]=u*u*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,u=a+a,c=o+o,h=s+s,d=a*u,_=a*c,f=a*h,p=o*c,g=o*h,m=s*h,v=l*u,y=l*c,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],u=n[5],c=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*u-a*l,T=i*c-o*l,C=i*h-s*l,S=a*c-o*u,w=a*h-s*u,b=o*h-s*c,A=d*m-_*g,M=d*v-f*g,F=d*y-p*g,P=_*v-f*m,E=_*y-p*m,R=f*y-p*v,L=x*R-T*E+C*P+S*F-w*M+b*A;if(!L)return null;L=1/L,r[0]=(u*R-c*E+h*P)*L,r[1]=(o*E-a*R-s*P)*L,r[2]=(m*b-v*w+y*S)*L,r[3]=(f*w-_*b-p*S)*L,r[4]=(c*F-l*R-h*M)*L,r[5]=(i*R-o*F+s*M)*L,r[6]=(v*C-g*b-y*T)*L,r[7]=(d*b-f*C+p*T)*L,r[8]=(l*E-u*F+h*A)*L,r[9]=(a*F-i*E-s*A)*L,r[10]=(g*w-m*C+y*x)*L,r[11]=(_*C-d*w-p*x)*L,r[12]=(u*M-l*P-c*A)*L,r[13]=(i*P-a*M+o*A)*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;sl.subtract(e,t,s),s.normalize(),sl.cross(n,s,a),a.normalize(),sl.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]=-sl.dot(a,e),i[13]=-sl.dot(o,e),i[14]=-sl.dot(s,e),i[15]=1},y.ortho=function(e,t,n,r,i,a,o){var s=o.elements,l=1/(e-t),u=1/(n-r),c=1/(i-a);s[0]=-2*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=-2*u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=2*c,s[11]=0,s[12]=(e+t)*l,s[13]=(r+n)*u,s[14]=(a+i)*c,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,u=t._z,c=Math.sqrt(s*s+l*l+u*u);if(!(Math.abs(c)<ss.zeroTolerance)){var h=e.elements,d=r.elements;s*=c=1/c,l*=c,u*=c,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],b=s*s*o+a,A=l*s*o+u*i,M=u*s*o-l*i,F=s*l*o-u*i,P=l*l*o+a,E=u*l*o+s*i,R=s*u*o+l*i,L=l*u*o-s*i,B=u*u*o+a;d[0]=_*b+m*A+T*M,d[1]=f*b+v*A+C*M,d[2]=p*b+y*A+S*M,d[3]=g*b+x*A+w*M,d[4]=_*F+m*P+T*E,d[5]=f*F+v*P+C*E,d[6]=p*F+y*P+S*E,d[7]=g*F+x*P+w*E,d[8]=_*R+m*L+T*B,d[9]=f*R+v*L+C*B,d[10]=p*R+y*L+S*B,d[11]=g*R+x*L+w*B,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],u=r[1],c=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]=u,i[2]=c,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]=u*a+_*o+m*s+r[13],i[14]=c*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],u=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]=u}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);sg._tempVec30=new sl,sg._tempVec31=new sl,sg._tempVec32=new sl,sg._tempMat30=new sf,sg._identity=new sg(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var sm=((C=(T=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sl,this.direction=new sl,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return sh.intersectsRayAndPlane(this,e)},C.intersectSphere=function(e){return sh.intersectsRayAndSphere(this,e)},C.intersectBox=function(e){return sh.intersectsRayAndBox(this,e)},C.getPoint=function(e,t){return sl.scale(this.direction,e,t),t.add(this.origin)},T),sv=((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 ss.equals(e._x,t._x)&&ss.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>ss.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);sv._zero=new sv(0,0),sv._one=new sv(1,1);var sy=((A=(b=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},A.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},A.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},A.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},A.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},A.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)},A.lengthSquared=function(){var e=this._x,t=this._y,n=this._z,r=this._w;return e*e+t*t+n*n+r*r},A.negate=function(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this._w=-this._w,this._onValueChanged&&this._onValueChanged(),this},A.normalize=function(){return b.normalize(this,this),this},A.scale=function(e){return this._x*=e,this._y*=e,this._z*=e,this._w*=e,this._onValueChanged&&this._onValueChanged(),this},A.clone=function(){return new b(this._x,this._y,this._z,this._w)},A.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},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._w=e[t+3],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,e[t+3]=this._w},A.toJSON=function(){return{x:this._x,y:this._y,z:this._z,w:this._w}},b.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()},b.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()},b.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()},b.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()},b.dot=function(e,t){return e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w},b.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)},b.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},b.equals=function(e,t){return ss.equals(e._x,t._x)&&ss.equals(e._y,t._y)&&ss.equals(e._z,t._z)&&ss.equals(e._w,t._w)},b.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()},b.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()},b.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()},b.negate=function(e,t){t._x=-e._x,t._y=-e._y,t._z=-e._z,t._w=-e._w,t._onValueChanged&&t._onValueChanged()},b.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>ss.zeroTolerance&&(o=1/o,t._x=n*o,t._y=r*o,t._z=i*o,t._w=a*o,t._onValueChanged&&t._onValueChanged())},b.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()},b.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()},b.transformByQuat=function(e,t,n){var r=e._x,i=e._y,a=e._z,o=e._w,s=t._x,l=t._y,u=t._z,c=t._w,h=c*r+l*a-u*i,d=c*i+u*r-s*a,_=c*a+s*i-l*r,f=-s*r-l*i-u*a;n._x=h*c-f*s-d*u+_*l,n._y=d*c-f*l-_*s+h*u,n._z=_*c-f*u-h*l+d*s,n._w=o,n._onValueChanged&&n._onValueChanged()},r(b,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"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()}}]),b);sy._zero=new sy(0,0,0,0),sy._one=new sy(1,1,1,1);var sx=((F=(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},F.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},F.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},F.clone=function(){return new M(this._r,this._g,this._b,this._a)},F.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},F.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},F.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},F.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},F.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 ss.equals(e._r,t._r)&&ss.equals(e._g,t._g)&&ss.equals(e._b,t._b)&&ss.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),sT=((E=(P=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},E.clone=function(){return new P(this.x,this.y,this.width,this.height)},E.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this},P),sC=((L=(R=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,u=t.b,c=-.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*u,r[3]+=s*c,r[4]+=l*c,r[5]+=u*c,r[6]+=s*h,r[7]+=l*h,r[8]+=u*h,r[9]+=s*d,r[10]+=l*d,r[11]+=u*d,r[12]+=s*_,r[13]+=l*_,r[14]+=u*_,r[15]+=s*f,r[16]+=l*f,r[17]+=u*f,r[18]+=s*p,r[19]+=l*p,r[20]+=u*p,r[21]+=s*g,r[22]+=l*g,r[23]+=u*g,r[24]+=s*m,r[25]+=l*m,r[26]+=u*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,u=.858086*i*r,c=-.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]*u+n[15]*c+n[18]*h+n[21]*d+n[24]*_,p+=n[13]*u+n[16]*c+n[19]*h+n[22]*d+n[25]*_,g+=n[14]*u+n[17]*c+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 R;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]},R);function sS(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function sw(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function sb(e,t,n){return t&&sw(e.prototype,t),n&&sw(e,n),e}function sA(e,t){return(sA=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function sM(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&&sA(e,t)}e.Platform=void 0,(B=e.Platform||(e.Platform={}))[B.Android=0]="Android",B[B.IPhone=1]="IPhone",B[B.IPad=2]="IPad",B[B.Mac=3]="Mac",B[B.Unknown=4]="Unknown";var sF=((D=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},D.equals=function(e,t){return Math.abs(e-t)<=D.zeroTolerance},D.isPowerOf2=function(e){return(e&e-1)==0},D.radianToDegree=function(e){return e*D.radToDegreeFactor},D.degreeToRadian=function(e){return e*D.degreeToRadFactor},D);sF.zeroTolerance=1e-6,sF.radToDegreeFactor=180/Math.PI,sF.degreeToRadFactor=Math.PI/180;var sP=((O=(I=function(e,t,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===r&&(r=1),this._onValueChanged=null,this._r=e,this._g=t,this._b=n,this._a=r}).prototype).set=function(e,t,n,r){return this._r=e,this._g=t,this._b=n,this._a=r,this._onValueChanged&&this._onValueChanged(),this},O.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},O.scale=function(e){return this._r*=e,this._g*=e,this._b*=e,this._a*=e,this._onValueChanged&&this._onValueChanged(),this},O.clone=function(){return new I(this._r,this._g,this._b,this._a)},O.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},O.toLinear=function(e){return e._r=I.gammaToLinearSpace(this._r),e._g=I.gammaToLinearSpace(this._g),e._b=I.gammaToLinearSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},O.toGamma=function(e){return e._r=I.linearToGammaSpace(this._r),e._g=I.linearToGammaSpace(this._g),e._b=I.linearToGammaSpace(this._b),this._onValueChanged&&this._onValueChanged(),e},O.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},O.toJSON=function(){return{r:this._r,g:this._g,b:this._b,a:this._a}},I.gammaToLinearSpace=function(e){return e<=0?0:e<=.04045?e/12.92:e<1?Math.pow((e+.055)/1.055,2.4):Math.pow(e,2.4)},I.linearToGammaSpace=function(e){return e<=0?0:e<.0031308?12.92*e:e<1?1.055*Math.pow(e,.41666)-.055:Math.pow(e,.41666)},I.equals=function(e,t){return sF.equals(e._r,t._r)&&sF.equals(e._g,t._g)&&sF.equals(e._b,t._b)&&sF.equals(e._a,t._a)},I.add=function(e,t,n){return n._r=e._r+t._r,n._g=e._g+t._g,n._b=e._b+t._b,n._a=e._a+t._a,n._onValueChanged&&n._onValueChanged(),n},I.subtract=function(e,t,n){n._r=e._r-t._r,n._g=e._g-t._g,n._b=e._b-t._b,n._a=e._a-t._a,n._onValueChanged&&n._onValueChanged()},I.scale=function(e,t,n){return n._r=e._r*t,n._g=e._g*t,n._b=e._b*t,n._a=e._a*t,n._onValueChanged&&n._onValueChanged(),n},I.lerp=function(e,t,n,r){var 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},sb(I,[{key:"r",get:function(){return this._r},set:function(e){this._r=e,this._onValueChanged&&this._onValueChanged()}},{key:"g",get:function(){return this._g},set:function(e){this._g=e,this._onValueChanged&&this._onValueChanged()}},{key:"b",get:function(){return this._b},set:function(e){this._b=e,this._onValueChanged&&this._onValueChanged()}},{key:"a",get:function(){return this._a},set:function(e){this._a=e,this._onValueChanged&&this._onValueChanged()}}]),I);function sE(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 sR(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function sL(e,t){sO.registerCloneMode(e,t,oP.Ignore)}function sB(e,t){sO.registerCloneMode(e,t,oP.Assignment)}function sD(e,t){sO.registerCloneMode(e,t,oP.Shallow)}function sI(e,t){sO.registerCloneMode(e,t,oP.Deep)}(V=oP||(oP={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var sO=((U=function(){}).registerCloneMode=function(e,t,n){var r=U._subCloneModeMap.get(e.constructor);r||(r=Object.create(null),U._subCloneModeMap.set(e.constructor,r)),r[t]=n},U.getCloneMode=function(e){var t=U._cloneModeMap.get(e);if(!t){t=Object.create(null),U._cloneModeMap.set(e,t);for(var n=U._objectType,r=U._subCloneModeMap;e!==n;){var i=r.get(e);i&&Object.assign(t,i),e=Object.getPrototypeOf(e)}}return t},U.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++)U._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++)U._deepCloneObjectItem(e,t,i[a])}},U._deepCloneObjectItem=function(e,t,n){var r=e[n];if(sR(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,U.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),U.deepCloneObject(r,s)}}else t[n]=r},U);sO._subCloneModeMap=new Map,sO._cloneModeMap=new Map,sO._objectType=Object.getPrototypeOf(Object);var sV=function(){function e(t){this.instanceId=++e._instanceIdCounter,this._destroyed=!1,this._engine=t}return e.prototype.destroy=function(){var e;this._destroyed||(null==(e=this._engine.resourceManager)||e._deleteAsset(this),this._destroyed=!0)},sb(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();sV._instanceIdCounter=0,sE([sL],sV.prototype,"instanceId",void 0),sE([sL],sV.prototype,"_engine",void 0);var sU=(sM(z=function(e){var t;return(t=sV.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addRefObject(t.instanceId,sS(t)),t},sV),(N=z.prototype).destroy=function(e){if(void 0===e&&(e=!1),this._destroyed)return!0;if(!e&&0!==this._refCount)return!1;var t=this._engine.resourceManager;t&&(sV.prototype.destroy.call(this),t._deleteRefObject(this.instanceId));var n=this._getRefCount();return n>0&&this._addRefCount(-n),this._engine=null,this._onDestroy(),!0},N._getRefCount=function(){return this._refCount},N._addRefCount=function(e){this._refCount+=e},N._addToResourceManager=function(e){this._engine.resourceManager._addAsset(e,this)},sb(z,[{key:"refCount",get:function(){return this._refCount}}]),z);e.RenderBufferDepthFormat=void 0,(k=e.RenderBufferDepthFormat||(e.RenderBufferDepthFormat={}))[k.Depth=0]="Depth",k[k.DepthStencil=1]="DepthStencil",k[k.Stencil=2]="Stencil",k[k.Depth16=3]="Depth16",k[k.Depth24=4]="Depth24",k[k.Depth32=5]="Depth32",k[k.Depth24Stencil8=6]="Depth24Stencil8",k[k.Depth32Stencil8=7]="Depth32Stencil8",e.TextureCubeFace=void 0,(G=e.TextureCubeFace||(e.TextureCubeFace={}))[G.PositiveX=0]="PositiveX",G[G.NegativeX=1]="NegativeX",G[G.PositiveY=2]="PositiveY",G[G.NegativeY=3]="NegativeY",G[G.PositiveZ=4]="PositiveZ",G[G.NegativeZ=5]="NegativeZ",e.TextureDepthCompareFunction=void 0,(H=e.TextureDepthCompareFunction||(e.TextureDepthCompareFunction={}))[H.Never=0]="Never",H[H.Less=1]="Less",H[H.Equal=2]="Equal",H[H.LessEqual=3]="LessEqual",H[H.Greater=4]="Greater",H[H.NotEqual=5]="NotEqual",H[H.GreaterEqual=6]="GreaterEqual",H[H.Always=7]="Always",e.TextureFilterMode=void 0,(W=e.TextureFilterMode||(e.TextureFilterMode={}))[W.Point=0]="Point",W[W.Bilinear=1]="Bilinear",W[W.Trilinear=2]="Trilinear",e.TextureFormat=void 0,(X=e.TextureFormat||(e.TextureFormat={}))[X.R8G8B8=0]="R8G8B8",X[X.R8G8B8A8=1]="R8G8B8A8",X[X.R4G4B4A4=2]="R4G4B4A4",X[X.R5G5B5A1=3]="R5G5B5A1",X[X.R5G6B5=4]="R5G6B5",X[X.Alpha8=5]="Alpha8",X[X.LuminanceAlpha=6]="LuminanceAlpha",X[X.R16G16B16A16=7]="R16G16B16A16",X[X.R32G32B32A32=8]="R32G32B32A32",X[X.DXT1=9]="DXT1",X[X.DXT5=10]="DXT5",X[X.ETC1_RGB=11]="ETC1_RGB",X[X.ETC2_RGB=12]="ETC2_RGB",X[X.ETC2_RGBA5=13]="ETC2_RGBA5",X[X.ETC2_RGBA8=14]="ETC2_RGBA8",X[X.PVRTC_RGB2=15]="PVRTC_RGB2",X[X.PVRTC_RGBA2=16]="PVRTC_RGBA2",X[X.PVRTC_RGB4=17]="PVRTC_RGB4",X[X.PVRTC_RGBA4=18]="PVRTC_RGBA4",X[X.ASTC_4x4=19]="ASTC_4x4",X[X.ASTC_5x5=20]="ASTC_5x5",X[X.ASTC_6x6=21]="ASTC_6x6",X[X.ASTC_8x8=22]="ASTC_8x8",X[X.ASTC_10x10=23]="ASTC_10x10",X[X.ASTC_12x12=24]="ASTC_12x12",X[X.Depth=25]="Depth",X[X.DepthStencil=26]="DepthStencil",X[X.Depth16=27]="Depth16",X[X.Depth24=28]="Depth24",X[X.Depth32=29]="Depth32",X[X.Depth24Stencil8=30]="Depth24Stencil8",X[X.Depth32Stencil8=31]="Depth32Stencil8",e.TextureWrapMode=void 0,(j=e.TextureWrapMode||(e.TextureWrapMode={}))[j.Clamp=0]="Clamp",j[j.Repeat=1]="Repeat",j[j.Mirror=2]="Mirror";var sz=((K=function(e,t,n,r){void 0===t&&(t=null),void 0===n&&(n={}),void 0===r&&(r=!0),this._timeStamp=new Date().getTime(),this._target=t,this.data=n,this._currentTarget=null,this._bubbles=r,this._propagationStopped=!1,this._type=e}).prototype.stopPropagation=function(){this._propagationStopped=!0},sb(K,[{key:"propagationStopped",get:function(){return this._propagationStopped}},{key:"target",get:function(){return this._target},set:function(e){this._target=e}},{key:"timeStamp",get:function(){return this._timeStamp}},{key:"currentTarget",get:function(){return this._currentTarget},set:function(e){this._currentTarget=e}},{key:"bubbles",get:function(){return this._bubbles}},{key:"type",get:function(){return this._type}}]),K),sN=((Y=(q=function(){this._events=Object.create(null),this._eventCount=0,this._dispatchingListeners=[]}).prototype).hasEvent=function(e){return null!=this._events[e]},Y.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},Y.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},Y.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},Y.on=function(e,t){return this.addEventListener(e,t)},Y.once=function(e,t){return this.addEventListener(e,t,!0)},Y.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},Y.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},Y.removeEventListener=function(e,t){return this.off(e,t)},Y.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},Y.trigger=function(e){this.dispatch(e.type,e.data)},Y._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},q),sk=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},sG=console.log.bind(console),sH=console.info.bind(console),sW=console.warn.bind(console),sX=console.error.bind(console),sj={debug:sk,info:sk,warn:sk,error:sk,isEnabled:!1,enable:function(){this.debug=sG,this.info=sH,this.warn=sW,this.error=sX,this.isEnabled=!0},disable:function(){this.debug=sk,this.info=sk,this.warn=sk,this.error=sk,this.isEnabled=!1}},sK=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};sK._macroNameIdMap=Object.create(null),sK._macroNameCounter=0;var sq=((J=(Q=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},J.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}},J.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]},J.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}},J.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}},J.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},J.clear=function(){this._length=0},Q.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},Q);function sY(){return(sY=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.DataType=void 0,(Z=e.DataType||(e.DataType={}))[Z.FLOAT=5126]="FLOAT",Z[Z.FLOAT_VEC2=35664]="FLOAT_VEC2",Z[Z.FLOAT_VEC3=35665]="FLOAT_VEC3",Z[Z.FLOAT_VEC4=35666]="FLOAT_VEC4",Z[Z.INT=5124]="INT",Z[Z.INT_VEC2=35667]="INT_VEC2",Z[Z.INT_VEC3=35668]="INT_VEC3",Z[Z.INT_VEC4=35669]="INT_VEC4",Z[Z.BOOL=35670]="BOOL",Z[Z.BOOL_VEC2=35671]="BOOL_VEC2",Z[Z.BOOL_VEC3=35672]="BOOL_VEC3",Z[Z.BOOL_VEC4=35673]="BOOL_VEC4",Z[Z.FLOAT_MAT2=35674]="FLOAT_MAT2",Z[Z.FLOAT_MAT3=35675]="FLOAT_MAT3",Z[Z.FLOAT_MAT4=35676]="FLOAT_MAT4",Z[Z.FLOAT_ARRAY=35677]="FLOAT_ARRAY",Z[Z.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",Z[Z.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",Z[Z.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",Z[Z.INT_ARRAY=100003]="INT_ARRAY",Z[Z.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",Z[Z.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",Z[Z.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",Z[Z.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",Z[Z.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",Z[Z.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",Z[Z.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",Z[Z.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",Z[Z.SAMPLER_2D=35678]="SAMPLER_2D",Z[Z.SAMPLER_CUBE=35680]="SAMPLER_CUBE",Z[Z.BYTE=5120]="BYTE",Z[Z.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",Z[Z.SHORT=5122]="SHORT",Z[Z.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",Z[Z.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,($=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",$.standardDerivatives="OES_standard_derivatives",$.shaderTextureLod="EXT_shader_texture_lod",$.elementIndexUint="OES_element_index_uint",$.depthTexture="WEBGL_depth_texture",$.drawBuffers="WEBGL_draw_buffers",$.vertexArrayObject="OES_vertex_array_object",$.instancedArrays="ANGLE_instanced_arrays",$.multipleSample="multipleSampleOnlySupportedInWebGL2",$.textureFloat="OES_texture_float",$.textureFloatLinear="OES_texture_float_linear",$.textureHalfFloat="OES_texture_half_float",$.textureHalfFloatLinear="OES_texture_half_float_linear",$.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",$.colorBufferFloat="EXT_color_buffer_float",$.colorBufferHalfFloat="EXT_color_buffer_half_float",$.textureFilterAnisotropic="EXT_texture_filter_anisotropic",$.blendMinMax="EXT_blend_minmax",$.astc="WEBGL_compressed_texture_astc",$.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",$.etc="WEBGL_compressed_texture_etc",$.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",$.etc1="WEBGL_compressed_texture_etc1",$.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",$.pvrtc="WEBGL_compressed_texture_pvrtc",$.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",$.s3tc="WEBGL_compressed_texture_s3tc",$.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc";var sQ=sY({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 O3_HAS_UV\nattribute vec2 TEXCOORD_0;\n#endif\n#ifdef O3_HAS_UV1\nattribute vec2 TEXCOORD_1;\n#endif\n#ifdef O3_HAS_SKIN\nattribute vec4 JOINTS_0;attribute vec4 WEIGHTS_0;\n#ifdef O3_USE_JOINT_TEXTURE\nuniform sampler2D u_jointSampler;uniform float u_jointCount;mat4 getJointMatrix(sampler2D smp,float index){float base=index/u_jointCount;float hf=0.5/u_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 u_jointMatrix[O3_JOINTS_NUM];\n#endif\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\nattribute vec4 COLOR_0;\n#endif\n#include <transform_declare>\n#include <camera_declare>\nuniform vec4 u_tilingOffset;\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nattribute vec3 NORMAL;\n#endif\n#ifdef O3_HAS_TANGENT\nattribute vec4 TANGENT;\n#endif\n#endif\n",transform_declare:"#define GLSLIFY 1\nuniform mat4 u_localMat;uniform mat4 u_modelMat;uniform mat4 u_viewMat;uniform mat4 u_projMat;uniform mat4 u_MVMat;uniform mat4 u_MVPMat;uniform mat4 u_normalMat;",camera_declare:"#define GLSLIFY 1\nuniform vec3 u_cameraPos;",color_share:"#define GLSLIFY 1\n#ifdef O3_HAS_VERTEXCOLOR\nvarying vec4 v_color;\n#endif\n",normal_share:"#define GLSLIFY 1\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nvarying vec3 v_normal;\n#if defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nvarying mat3 v_TBN;\n#endif\n#endif\n#endif\n",uv_share:"#define GLSLIFY 1\nvarying vec2 v_uv;\n#ifdef O3_HAS_UV1\nvarying vec2 v_uv1;\n#endif\n",worldpos_share:"#define GLSLIFY 1\n#ifdef O3_NEED_WORLDPOS\nvarying vec3 v_pos;\n#endif\n",FogVertexDeclaration:"#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;\n#endif\n",FogFragmentDeclaration:"#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvarying vec3 v_positionVS;uniform vec4 oasis_FogColor;uniform vec4 oasis_FogParams;float ComputeFogIntensity(float fogDepth){\n#if OASIS_FOG_MODE == 1\nreturn clamp(fogDepth*oasis_FogParams.x+oasis_FogParams.y,0.0,1.0);\n#elif OASIS_FOG_MODE == 2\nreturn clamp(exp2(-fogDepth*oasis_FogParams.z),0.0,1.0);\n#elif OASIS_FOG_MODE == 3\nfloat factor=fogDepth*oasis_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 OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nvec3 normal=vec3(NORMAL);\n#endif\n#ifdef O3_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=u_MVPMat*position;",color_vert:"#define GLSLIFY 1\n#ifdef O3_HAS_VERTEXCOLOR\nv_color=COLOR_0;\n#endif\n",normal_vert:"#define GLSLIFY 1\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nv_normal=normalize(mat3(u_normalMat)*normal);\n#if defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nvec3 normalW=normalize(mat3(u_normalMat)*normal.xyz);vec3 tangentW=normalize(mat3(u_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 O3_HAS_SKIN\n#ifdef O3_USE_JOINT_TEXTURE\nmat4 skinMatrix=WEIGHTS_0.x*getJointMatrix(u_jointSampler,JOINTS_0.x)+WEIGHTS_0.y*getJointMatrix(u_jointSampler,JOINTS_0.y)+WEIGHTS_0.z*getJointMatrix(u_jointSampler,JOINTS_0.z)+WEIGHTS_0.w*getJointMatrix(u_jointSampler,JOINTS_0.w);\n#else\nmat4 skinMatrix=WEIGHTS_0.x*u_jointMatrix[int(JOINTS_0.x)]+WEIGHTS_0.y*u_jointMatrix[int(JOINTS_0.y)]+WEIGHTS_0.z*u_jointMatrix[int(JOINTS_0.z)]+WEIGHTS_0.w*u_jointMatrix[int(JOINTS_0.w)];\n#endif\nposition=skinMatrix*position;\n#if defined(O3_HAS_NORMAL) && !defined(OMIT_NORMAL)\nmat3 skinNormalMatrix=INVERSE_MAT(mat3(skinMatrix));normal=normal*skinNormalMatrix;\n#if defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\ntangent.xyz=tangent.xyz*skinNormalMatrix;\n#endif\n#endif\n#endif\n",blendShape_input:"#define GLSLIFY 1\n#ifdef OASIS_BLENDSHAPE\n#ifdef OASIS_BLENDSHAPE_TEXTURE\nuniform mediump sampler2DArray u_blendShapeTexture;uniform ivec3 u_blendShapeTextureInfo;uniform float u_blendShapeWeights[OASIS_BLENDSHAPE_COUNT];\n#else\nattribute vec3 POSITION_BS0;attribute vec3 POSITION_BS1;\n#if defined( OASIS_BLENDSHAPE_NORMAL ) && defined( OASIS_BLENDSHAPE_TANGENT )\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;uniform float u_blendShapeWeights[2];\n#else\n#if defined( OASIS_BLENDSHAPE_NORMAL ) || defined( OASIS_BLENDSHAPE_TANGENT )\nattribute vec3 POSITION_BS2;attribute vec3 POSITION_BS3;\n#ifdef OASIS_BLENDSHAPE_NORMAL\nattribute vec3 NORMAL_BS0;attribute vec3 NORMAL_BS1;attribute vec3 NORMAL_BS2;attribute vec3 NORMAL_BS3;\n#endif\n#ifdef OASIS_BLENDSHAPE_TANGENT\nattribute vec3 TANGENT_BS0;attribute vec3 TANGENT_BS1;attribute vec3 TANGENT_BS2;attribute vec3 TANGENT_BS3;\n#endif\nuniform float u_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 u_blendShapeWeights[8];\n#endif\n#endif\n#endif\n#ifdef OASIS_BLENDSHAPE_TEXTURE\nvec3 getBlendShapeVertexElement(int blendShapeIndex,int vertexElementIndex){int y=vertexElementIndex/u_blendShapeTextureInfo.y;int x=vertexElementIndex-y*u_blendShapeTextureInfo.y;ivec3 uv=ivec3(x,y,blendShapeIndex);return texelFetch(u_blendShapeTexture,uv,0).xyz;}\n#endif\n#endif\n",blendShape_vert:"#define GLSLIFY 1\n#ifdef OASIS_BLENDSHAPE\n#ifdef OASIS_BLENDSHAPE_TEXTURE\nint vertexOffset=gl_VertexID*u_blendShapeTextureInfo.x;for(int i=0;i<OASIS_BLENDSHAPE_COUNT;i++){int vertexElementOffset=vertexOffset;float weight=u_blendShapeWeights[i];position.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#ifndef OMIT_NORMAL\n#if defined( O3_HAS_NORMAL ) && defined( OASIS_BLENDSHAPE_NORMAL )\nvertexElementOffset+=1;normal+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#if defined( O3_HAS_TANGENT ) && defined(OASIS_BLENDSHAPE_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\nvertexElementOffset+=1;tangent.xyz+=getBlendShapeVertexElement(i,vertexElementOffset)*weight;\n#endif\n#endif\n}\n#else\nposition.xyz+=POSITION_BS0*u_blendShapeWeights[0];position.xyz+=POSITION_BS1*u_blendShapeWeights[1];\n#if defined( OASIS_BLENDSHAPE_NORMAL ) && defined( OASIS_BLENDSHAPE_TANGENT )\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nnormal+=NORMAL_BS0*u_blendShapeWeights[0];normal+=NORMAL_BS1*u_blendShapeWeights[1];\n#endif\n#if defined( O3_HAS_TANGENT ) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\ntangent.xyz+=TANGENT_BS0*u_blendShapeWeights[0];tangent.xyz+=TANGENT_BS1*u_blendShapeWeights[1];\n#endif\n#endif\n#else\n#if defined( OASIS_BLENDSHAPE_NORMAL ) || defined( OASIS_BLENDSHAPE_TANGENT )\n#ifndef OMIT_NORMAL\nposition.xyz+=POSITION_BS2*u_blendShapeWeights[2];position.xyz+=POSITION_BS3*u_blendShapeWeights[3];\n#if defined( OASIS_BLENDSHAPE_NORMAL ) && defined( O3_HAS_NORMAL )\nnormal+=NORMAL_BS0*u_blendShapeWeights[0];normal+=NORMAL_BS1*u_blendShapeWeights[1];normal+=NORMAL_BS2*u_blendShapeWeights[2];normal+=NORMAL_BS3*u_blendShapeWeights[3];\n#endif\n#if defined(OASIS_BLENDSHAPE_TANGENT) && defined( O3_HAS_TANGENT ) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\ntangent.xyz+=TANGENT_BS0*u_blendShapeWeights[0];tangent.xyz+=TANGENT_BS1*u_blendShapeWeights[1];tangent.xyz+=TANGENT_BS2*u_blendShapeWeights[2];tangent.xyz+=TANGENT_BS3*u_blendShapeWeights[3];\n#endif\n#endif\n#else\nposition.xyz+=POSITION_BS2*u_blendShapeWeights[2];position.xyz+=POSITION_BS3*u_blendShapeWeights[3];position.xyz+=POSITION_BS4*u_blendShapeWeights[4];position.xyz+=POSITION_BS5*u_blendShapeWeights[5];position.xyz+=POSITION_BS6*u_blendShapeWeights[6];position.xyz+=POSITION_BS7*u_blendShapeWeights[7];\n#endif\n#endif\n#endif\n#endif\n",uv_vert:"#define GLSLIFY 1\n#ifdef O3_HAS_UV\nv_uv=TEXCOORD_0;\n#else\nv_uv=vec2(0.,0.);\n#endif\n#ifdef O3_HAS_UV1\nv_uv1=TEXCOORD_1;\n#endif\n#ifdef O3_NEED_TILINGOFFSET\nv_uv=v_uv*u_tilingOffset.xy+u_tilingOffset.zw;\n#endif\n",worldpos_vert:"#define GLSLIFY 1\n#ifdef O3_NEED_WORLDPOS\nvec4 temp_pos=u_modelMat*position;v_pos=temp_pos.xyz/temp_pos.w;\n#endif\n",FogVertex:"#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nvec4 positionVS=u_MVMat*position;v_positionVS=positionVS.xyz/positionVS.w;\n#endif\n",light_frag_define:"#define GLSLIFY 1\n#ifdef O3_DIRECT_LIGHT_COUNT\nstruct DirectLight{vec3 color;vec3 direction;};uniform ivec2 u_directLightCullingMask[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightColor[O3_DIRECT_LIGHT_COUNT];uniform vec3 u_directLightDirection[O3_DIRECT_LIGHT_COUNT];\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nstruct PointLight{vec3 color;vec3 position;float distance;};uniform ivec2 u_pointLightCullingMask[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightColor[O3_POINT_LIGHT_COUNT];uniform vec3 u_pointLightPosition[O3_POINT_LIGHT_COUNT];uniform float u_pointLightDistance[O3_POINT_LIGHT_COUNT];\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nstruct SpotLight{vec3 color;vec3 position;vec3 direction;float distance;float angleCos;float penumbraCos;};uniform ivec2 u_spotLightCullingMask[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightColor[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightPosition[O3_SPOT_LIGHT_COUNT];uniform vec3 u_spotLightDirection[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightDistance[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightAngleCos[O3_SPOT_LIGHT_COUNT];uniform float u_spotLightPenumbraCos[O3_SPOT_LIGHT_COUNT];\n#endif\nstruct EnvMapLight{vec3 diffuse;float mipMapLevel;float diffuseIntensity;float specularIntensity;};uniform EnvMapLight u_envMapLight;uniform ivec4 oasis_RendererLayer;\n#ifdef O3_USE_SH\nuniform vec3 u_env_sh[9];\n#endif\n#ifdef O3_USE_SPECULAR_ENV\nuniform samplerCube u_env_specularSampler;\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 u_emissiveColor;uniform vec4 u_baseColor;uniform vec4 u_specularColor;uniform float u_shininess;uniform float u_normalIntensity;uniform float u_alphaCutoff;\n#ifdef EMISSIVETEXTURE\nuniform sampler2D u_emissiveTexture;\n#endif\n#ifdef BASETEXTURE\nuniform sampler2D u_baseTexture;\n#endif\n#ifdef O3_SPECULAR_TEXTURE\nuniform sampler2D u_specularTexture;\n#endif\n#ifdef NORMALTEXTURE\nuniform sampler2D u_normalTexture;\n#endif\n",FogFragment:"#define GLSLIFY 1\n#if OASIS_FOG_MODE != 0\nfloat fogIntensity=ComputeFogIntensity(length(v_positionVS));gl_FragColor.rgb=mix(oasis_FogColor.rgb,gl_FragColor.rgb,fogIntensity);\n#endif\n",begin_mobile_frag:"#define GLSLIFY 1\nvec4 ambient=vec4(0.0);vec4 emission=u_emissiveColor;vec4 diffuse=u_baseColor;vec4 specular=u_specularColor;\n#ifdef EMISSIVETEXTURE\nvec4 emissiveTextureColor=texture2D(u_emissiveTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nemissiveTextureColor=gammaToLinear(emissiveTextureColor);\n#endif\nemission*=emissiveTextureColor;\n#endif\n#ifdef BASETEXTURE\nvec4 diffuseTextureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\ndiffuseTextureColor=gammaToLinear(diffuseTextureColor);\n#endif\ndiffuse*=diffuseTextureColor;\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\ndiffuse*=v_color;\n#endif\n#ifdef O3_SPECULAR_TEXTURE\nvec4 specularTextureColor=texture2D(u_specularTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nspecularTextureColor=gammaToLinear(specularTextureColor);\n#endif\nspecular*=specularTextureColor;\n#endif\nambient=vec4(u_envMapLight.diffuse*u_envMapLight.diffuseIntensity,1.0)*diffuse;",begin_viewdir_frag:"#define GLSLIFY 1\n#ifdef O3_NEED_WORLDPOS\nvec3 V=normalize(u_cameraPos-v_pos);\n#endif\n",mobile_blinnphong_frag:"#define GLSLIFY 1\n#ifdef NORMALTEXTURE\nmat3 tbn=getTBN(gl_FrontFacing);vec3 N=getNormalByNormalTexture(tbn,u_normalTexture,u_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 O3_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef OASIS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(u_shadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<O3_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_directLightCullingMask[i]))continue;directionalLight.color=u_directLightColor[i];\n#ifdef OASIS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=u_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),u_shininess);lightSpecular+=directionalLight.color*s;}\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<O3_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_pointLightCullingMask[i]))continue;pointLight.color=u_pointLightColor[i];pointLight.position=u_pointLightPosition[i];pointLight.distance=u_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),u_shininess)*decay;lightSpecular+=pointLight.color*s;}\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<O3_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_spotLightCullingMask[i]))continue;spotLight.color=u_spotLightColor[i];spotLight.position=u_spotLightPosition[i];spotLight.direction=u_spotLightDirection[i];spotLight.distance=u_spotLightDistance[i];spotLight.angleCos=u_spotLightAngleCos[i];spotLight.penumbraCos=u_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),u_shininess)*decayTotal;lightSpecular+=spotLight.color*s;}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef ALPHA_CUTOFF\nif(diffuse.a<u_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 u_shadowMatrices[CASCADED_COUNT+1];uniform vec4 u_shadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-u_shadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-u_shadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-u_shadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-u_shadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<u_shadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<u_shadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<u_shadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<u_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 CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=u_shadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=u_shadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=u_shadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=u_shadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=u_shadowMatrices[3];}else{shadowMatrix=u_shadowMatrices[4];}\n#endif\n#if CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=u_shadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=u_shadowMatrices[1];}else{shadowMatrix=u_shadowMatrices[2];}\n#endif\n#if CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=u_shadowMatrices[0];}else{shadowMatrix=u_shadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SHADOW_TYPE) && defined(OASIS_RECEIVE_SHADOWS)\n#define OASIS_CALCULATE_SHADOWS\n#endif\n#ifdef OASIS_CALCULATE_SHADOWS\n#if CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec3 u_shadowInfo;uniform vec4 u_shadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow u_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 u_shadowMap;\n#ifdef OASIS_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 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 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 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 SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(u_shadowMap,shadowCoord);\n#endif\n#if SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(u_shadowMap,shadowCoord,u_shadowMapSize);\n#endif\n#if SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(u_shadowMap,shadowCoord,u_shadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,u_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(SHADOW_TYPE) && defined(OASIS_RECEIVE_SHADOWS)\n#define OASIS_CALCULATE_SHADOWS\n#endif\n#ifdef OASIS_CALCULATE_SHADOWS\n#if CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef OASIS_CALCULATE_SHADOWS\n#if CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\nuniform float u_alphaCutoff;uniform vec4 u_baseColor;uniform float u_metal;uniform float u_roughness;uniform vec3 u_PBRSpecularColor;uniform float u_glossiness;uniform vec3 u_emissiveColor;\n#ifdef CLEARCOAT\nuniform float u_clearCoat;uniform float u_clearCoatRoughness;\n#endif\nuniform float u_normalIntensity;uniform float u_occlusionIntensity;uniform float u_occlusionTextureCoord;\n#ifdef BASETEXTURE\nuniform sampler2D u_baseTexture;\n#endif\n#ifdef NORMALTEXTURE\nuniform sampler2D u_normalTexture;\n#endif\n#ifdef EMISSIVETEXTURE\nuniform sampler2D u_emissiveTexture;\n#endif\n#ifdef ROUGHNESSMETALLICTEXTURE\nuniform sampler2D u_roughnessMetallicTexture;\n#endif\n#ifdef SPECULARGLOSSINESSTEXTURE\nuniform sampler2D u_specularGlossinessTexture;\n#endif\n#ifdef OCCLUSIONTEXTURE\nuniform sampler2D u_occlusionTexture;\n#endif\n#ifdef HAS_CLEARCOATTEXTURE\nuniform sampler2D u_clearCoatTexture;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSTEXTURE\nuniform sampler2D u_clearCoatRoughnessTexture;\n#endif\n#ifdef HAS_CLEARCOATNORMALTEXTURE\nuniform sampler2D u_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 CLEARCOAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef CLEARCOAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};uniform float material_IOR;",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(u_cameraPos-v_pos);\n#if defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,u_normalTexture,u_normalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef CLEARCOAT\n#ifdef HAS_CLEARCOATNORMALTEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,u_clearCoatNormalTexture,u_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=u_baseColor;float metal=u_metal;float roughness=u_roughness;vec3 specularColor=u_PBRSpecularColor;float glossiness=u_glossiness;float alphaCutoff=u_alphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef BASETEXTURE\nvec4 baseTextureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef O3_HAS_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef ROUGHNESSMETALLICTEXTURE\nvec4 metalRoughMapColor=texture2D(u_roughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef SPECULARGLOSSINESSTEXTURE\nvec4 specularGlossinessColor=texture2D(u_specularGlossinessTexture,v_uv);\n#ifndef OASIS_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 CLEARCOAT\nmaterial.clearCoat=u_clearCoat;material.clearCoatRoughness=u_clearCoatRoughness;\n#ifdef HAS_CLEARCOATTEXTURE\nmaterial.clearCoat*=texture2D(u_clearCoatTexture,v_uv).r;\n#endif\n#ifdef HAS_CLEARCOATROUGHNESSTEXTURE\nmaterial.clearCoatRoughness*=texture2D(u_clearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef OASIS_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 CLEARCOAT\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 O3_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 O3_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 O3_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 O3_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef OASIS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();int sunIndex=int(u_shadowInfo.z);\n#endif\nDirectLight directionalLight;for(int i=0;i<O3_DIRECT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_directLightCullingMask[i]))continue;directionalLight.color=u_directLightColor[i];\n#ifdef OASIS_CALCULATE_SHADOWS\nif(i==sunIndex){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=u_directLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}\n#endif\n#ifdef O3_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<O3_POINT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_pointLightCullingMask[i]))continue;pointLight.color=u_pointLightColor[i];pointLight.position=u_pointLightPosition[i];pointLight.distance=u_pointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}\n#endif\n#ifdef O3_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<O3_SPOT_LIGHT_COUNT;i++){if(isRendererCulledByLight(oasis_RendererLayer.xy,u_spotLightCullingMask[i]))continue;spotLight.color=u_spotLightColor[i];spotLight.position=u_spotLightPosition[i];spotLight.direction=u_spotLightDirection[i];spotLight.distance=u_spotLightDistance[i];spotLight.angleCos=u_spotLightAngleCos[i];spotLight.penumbraCos=u_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 O3_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(u_env_specularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(u_env_specularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef O3_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef OASIS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef OASIS_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 O3_USE_SH\nvec3 irradiance=getLightProbeIrradiance(u_env_sh,geometry.normal);\n#ifdef OASIS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=u_envMapLight.diffuseIntensity;\n#else\nvec3 irradiance=u_envMapLight.diffuse*u_envMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(u_envMapLight.mipMapLevel),u_envMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef CLEARCOAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(u_envMapLight.mipMapLevel),u_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 OCCLUSIONTEXTURE\nvec2 aoUV=v_uv;\n#ifdef O3_HAS_UV1\nif(u_occlusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(u_occlusionTexture,aoUV).r-1.0)*u_occlusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef O3_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=u_emissiveColor;\n#ifdef EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(u_emissiveTexture,v_uv);\n#ifndef OASIS_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 O3_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(O3_HAS_NORMAL) && defined(O3_HAS_TANGENT) && ( defined(NORMALTEXTURE) || defined(HAS_CLEARCOATNORMALTEXTURE) )\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;}"}),sJ=((ee=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},ee.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=sQ[t];return void 0===n?(sj.error('Shader slice "'+e.trim()+'" not founded.'),""):ee.parseIncludes(n)})},ee.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},ee.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},ee._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)},ee);(et=oE||(oE={}))[et.Scene=0]="Scene",et[et.Camera=1]="Camera",et[et.Renderer=2]="Renderer",et[et.Material=3]="Material",e.ColorSpace=void 0,(en=e.ColorSpace||(e.ColorSpace={}))[en.Linear=0]="Linear",en[en.Gamma=1]="Gamma";var sZ=((ei=(er=function(e){this.textureUseComporeMode=!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)},ei.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},ei.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,sx.gammaToLinearSpace(n.r),sx.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)},ei.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},ei.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,sx.gammaToLinearSpace(n.r),sx.gammaToLinearSpace(n.g),sx.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)},ei.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},ei.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,sx.gammaToLinearSpace(n.r),sx.gammaToLinearSpace(n.g),sx.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)},ei.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},ei.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},ei.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},ei.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)},ei.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},ei.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)},ei.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},ei.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)},ei.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},ei.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},ei.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},ei.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseComporeMode)},ei.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.textureUseComporeMode)}},er),s$=function(){this.constUniforms=[],this.textureUniforms=[]},s0=function(){function e(t,n,r){this.sceneUniformBlock=new s$,this.cameraUniformBlock=new s$,this.rendererUniformBlock=new s$,this.materialUniformBlock=new s$,this.otherUniformBlock=new s$,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._currentBind!==this&&(this._gl.useProgram(this._glProgram),e._currentBind=this,!0)},t.destroy=function(){var e=this._gl;this._vertexShader&&e.deleteShader(this._vertexShader),this._fragmentShader&&e.deleteShader(this._fragmentShader),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=s3._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 oE.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case oE.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case oE.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case oE.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(n.attachShader(a,r),n.attachShader(a,i),n.linkProgram(a),n.validateProgram(a),n.isContextLost())?(sj.error("Context lost while linking program."),n.deleteShader(r),n.deleteShader(i),null):sj.isEnabled&&!n.getProgramParameter(a,n.LINK_STATUS)?(sj.error("Could not link WebGL program. \n"+n.getProgramInfoLog(a)),n.deleteProgram(a),null):(this._vertexShader=r,this._fragmentShader=i,a)},t._createShader=function(t,n){var r=this._gl,i=r.createShader(t);return i?(r.shaderSource(i,n),r.compileShader(i),r.isContextLost())?(console.warn("Context lost while compiling shader."),r.deleteShader(i),null):sj.isEnabled&&!r.getShaderParameter(i,r.COMPILE_STATUS)?(console.warn("Could not compile WebGL shader.\n"+r.getShaderInfoLog(i),e._addLineNum(n)),r.deleteShader(i),null):i:(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 sZ(e._engine),u=!1,c=!1;a.indexOf("[0]")>0&&(a=a.substr(0,a.length-3),u=!0);var h=t.getUniformLocation(n,a);switch(l.name=a,l.propertyId=s3.getPropertyByName(a)._uniqueId,l.location=h,s){case t.FLOAT:u?l.applyFunc=l.upload1fv:(l.applyFunc=l.upload1f,l.cacheValue=0);break;case t.FLOAT_VEC2:u?l.applyFunc=l.upload2fv:(l.applyFunc=l.upload2f,l.cacheValue=new sv(0,0));break;case t.FLOAT_VEC3:u?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sl(0,0,0));break;case t.FLOAT_VEC4:u?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new sy(0,0,0,0));break;case t.BOOL:case t.INT:u?l.applyFunc=l.upload1iv:(l.applyFunc=l.upload1i,l.cacheValue=0);break;case t.BOOL_VEC2:case t.INT_VEC2:u?l.applyFunc=l.upload2iv:(l.applyFunc=l.upload2i,l.cacheValue=new sv(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=u?l.upload3iv:l.upload3i,l.cacheValue=new sl(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:u?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new sy(0,0,0));break;case t.FLOAT_MAT4:l.applyFunc=u?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.textureUseComporeMode=!0}if(c=!0,u){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=s3._getShaderPropertyGroup(a);e._groupingUniform(l,m,c)}),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")},sb(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();s0._counter=0;var s1=function(){function t(e,n){this._shaderPassId=0,this._shaderPassId=t._shaderPassCounter++,this._vertexSource=e,this._fragmentSource=n}return t.prototype._getShaderProgram=function(t,n){var r=t._getShaderProgramPool(this),i=r.get(n);if(i)return i;var a=t._hardwareRenderer.isWebGL2,o=[];s3._getNamesByMacros(n,o);var s=sJ.parseCustomMacros(o),l=a?"#version 300 es":"#version 100",u=a?"#define GRAPHICS_API_WEBGL2":"#define GRAPHICS_API_WEBGL1",c="\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)&&(c+="#define HAS_TEX_LOD\n"),t._hardwareRenderer.canIUse(e.GLCapabilityType.standardDerivatives)&&(c+="#define HAS_DERIVATIVES\n");var h=sJ.parseIncludes(" "+l+"\n "+u+"\n "+s+"\n "+this._vertexSource),d=sJ.parseIncludes(" "+l+"\n "+u+"\n "+(a?"":sJ.parseExtension(s3._shaderExtension))+"\n "+c+"\n "+s+"\n "+this._fragmentSource);return a&&(h=sJ.convertTo300(h),d=sJ.convertTo300(d,!0)),i=new s0(t,h,d),r.cache(i),i},t}();s1._shaderPassCounter=0;var s2=function(){function e(t){this.name=t,this._uniqueId=e._propertyNameCounter++}return sb(e,[{key:"type",get:function(){return this._type}}]),e}();s2._propertyNameCounter=0;var s3=((ea=function(e,t,n){if(this._passes=[],this.name=e,"string"==typeof t)this._passes.push(new s1(t,n));else{var r=t.length;if(r<1)throw"Shader pass count must large than 0.";for(var i=0;i<r;i++)this._passes.push(t[i])}}).prototype.compileVariant=function(e,t){var n=ea._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(ea.getMacroByName(t[r]));for(var a=!0,o=this._passes,s=0,l=o.length;s<l;s++)a&&(a=o[s]._getShaderProgram(e,n).isValid);return a},ea.create=function(e,t,n){var r=ea._shaderMap;if(r[e])throw'Shader named "'+e+'" already exists.';return r[e]=new ea(e,t,n)},ea.find=function(e){return ea._shaderMap[e]},ea.getMacroByName=function(e,t){var n=t?e+" "+t:e,r=ea._macroMap[n];if(!r){var i=ea._macroMaskMap,a=ea._macroCounter,o=Math.floor(a/32),s=a%32;r=new sK(e,t,o,1<<s),ea._macroMap[n]=r,o==i.length&&(i.length++,i[o]=Array(32)),i[o][s]=n,ea._macroCounter++}return r},ea.getPropertyByName=function(e){var t=ea._propertyNameMap;if(null!=t[e])return t[e];var n=new s2(e);return t[e]=n,ea._propertyIdMap[n._uniqueId]=n,n},ea._getShaderPropertyGroup=function(e){var t=ea._propertyNameMap[e];return null==t?void 0:t._group},ea._getNamesByMacros=function(e,t){var n=ea._macroMaskMap,r=e._mask;t.length=0;for(var i=0,a=e._length;i<a;i++)for(var o=n[i],s=r[i],l=s<0?32:Math.floor(Math.log2(s))+1,u=0;u<l;u++)s&1<<u&&t.push(o[u])},sb(ea,[{key:"passes",get:function(){return this._passes}}]),ea);s3._compileMacros=new sq,s3._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],s3._propertyIdMap=Object.create(null),s3._shaderMap=Object.create(null),s3._propertyNameMap=Object.create(null),s3._macroMaskMap=[],s3._macroCounter=0,s3._macroMap=Object.create(null);var s4=((es=(eo=function(){this._frameCount=0,this._elapsedTimeValue=new sy,this._clock=performance||Date,this._timeScale=1,this._deltaTime=1e-4;var e=this._clock.now();this._startTime=e,this._lastTickTime=e}).prototype).reset=function(){this._lastTickTime=this._clock.now()},es.tick=function(){var e=this.nowTime;this._deltaTime=(e-this._lastTickTime)*this._timeScale,this._lastTickTime=e,this._frameCount++},es._updateSceneShaderData=function(e){var t=this._elapsedTimeValue,n=this._lastTickTime/1e3;t.set(n,Math.sin(n),Math.cos(n),0),e.setVector4(eo._elapsedTimeProperty,t)},sb(eo,[{key:"frameCount",get:function(){return this._frameCount}},{key:"nowTime",get:function(){return this._clock.now()}},{key:"deltaTime",get:function(){return this._deltaTime}},{key:"timeScale",get:function(){return this._timeScale},set:function(e){this._timeScale=e}},{key:"unscaledDeltaTime",get:function(){return this._deltaTime/this._timeScale}},{key:"timeSinceStartup",get:function(){return this.nowTime-this._startTime}}]),eo);s4._elapsedTimeProperty=s3.getPropertyByName("scene_ElapsedTime");var s5={isArray:"isArray"in Array?Array.isArray:function(e){return"[object Array]"===toString.call(e)},isArrayLike:function(e){return!!e&&"number"==typeof e.length&&"function"!=typeof e},clone:function(e){if("object"!=typeof e||null===e)return e;if(s5.isArrayLike(e)){t=e.slice();for(var t,n=0,r=e.length;n<r;n++)t[n]=s5.clone(e[n])}else for(var i in t={},e)e.hasOwnProperty(i)&&(t[i]=s5.clone(e[i]));return t},downloadBlob:function(e,t){void 0===t&&(t="");var n=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=n,r.download=t,r.addEventListener("click",function(){r.parentElement&&r.parentElement.removeChild(r)}),r.click(),window.URL.revokeObjectURL(n)}};function s8(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}function s6(e){return Object.keys(e).map(function(t){return e[t]})}var s7=(sM(el=function(){var e;return e=sU.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},sU),(eu=el.prototype).generateMipmaps=function(){this._mipmap&&this._platformTexture.generateMipmaps()},eu._setUseDepthCompareMode=function(e){this._useDepthCompareMode!==e&&(this._platformTexture.setUseDepthCompareMode(e),this._useDepthCompareMode=e)},eu._onDestroy=function(){this._platformTexture.destroy(),this._platformTexture=null},eu._getMaxMiplevel=function(e){return Math.floor(Math.log2(e))},eu._getMipmapCount=function(){return this._mipmap?Math.floor(Math.log2(Math.max(this._width,this._height)))+1:1},sb(el,[{key:"format",get:function(){return this._format}},{key:"width",get:function(){return this._width}},{key:"height",get:function(){return this._height}},{key:"wrapModeU",get:function(){return this._wrapModeU},set:function(e){e!==this._wrapModeU&&(this._wrapModeU=e,this._platformTexture.wrapModeU=e)}},{key:"wrapModeV",get:function(){return this._wrapModeV},set:function(e){e!==this._wrapModeV&&(this._wrapModeV=e,this._platformTexture.wrapModeV=e)}},{key:"mipmapCount",get:function(){return this._mipmapCount}},{key:"filterMode",get:function(){return this._filterMode},set:function(e){e!==this._filterMode&&(this._filterMode=e,this._platformTexture.filterMode=e)}},{key:"anisoLevel",get:function(){return this._anisoLevel},set:function(e){var t=this._engine._hardwareRenderer.capability.maxAnisoLevel;e>t&&(sj.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(sj.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)}}]),el),s9=(sM(ec=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=sV.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=sR(i,Array)?i.slice():[i],u=0,c=l.length;u<c;u++){var h=l[u];if(h._isDepthTexture)throw"Render texture can't use depth format.";h._addRefCount(1)}s._colorTextures=l}else s._colorTextures=[];if(sR(a,s7)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addRefCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(sS(s)),s},sV),(eh=ec.prototype).getColorTexture=function(e){return void 0===e&&(e=0),this._colorTextures[e]},eh.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()}},eh.destroy=function(){this._platformRenderTarget.destroy();for(var e,t=this._colorTextures,n=0,r=t.length;n<r;n++)t[n]._addRefCount(-1);t.length=0,null==(e=this._depthTexture)||e._addRefCount(-1),this._depthTexture=null,this._depth=null},eh._setRenderTargetInfo=function(e,t){this._platformRenderTarget.setRenderTargetInfo(e,t)},eh._blitRenderTarget=function(){this._platformRenderTarget.blitRenderTarget()},sb(ec,[{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}}]),ec),le=(sM(ed=function(t,n,r,i,a){var o;return void 0===i&&(i=e.TextureFormat.R8G8B8A8),void 0===a&&(a=!0),(o=s7.call(this,t)||this)._mipmap=a,o._width=n,o._height=r,o._format=i,o._mipmapCount=o._getMipmapCount(),o._isDepthTexture=i==e.TextureFormat.Depth||i==e.TextureFormat.DepthStencil||i==e.TextureFormat.Depth16||i==e.TextureFormat.Depth24||i==e.TextureFormat.Depth32||i==e.TextureFormat.Depth24Stencil8||i==e.TextureFormat.Depth32Stencil8,o._platformTexture=t._hardwareRenderer.createPlatformTexture2D(sS(o)),o.filterMode=e.TextureFilterMode.Bilinear,o.wrapModeU=o.wrapModeV=e.TextureWrapMode.Repeat,o},s7),(e_=ed.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)},e_.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)},e_.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)},ed),lt=(sM(ef=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=s7.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(sS(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},s7),(ep=ef.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)},ep.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)},ep.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)},sb(ef,[{key:"length",get:function(){return this._length}}]),ef),ln=(sM(eg=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=s7.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(sS(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},s7),(em=eg.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)},em.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)},em.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)},eg),lr=(sM(ev=function(e){var t;return(t=sU.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},sU),(ey=ev.prototype)._onDestroy=function(){this._texture.destroy(),this._texture=null,this._charInfoMap={}},ey.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 u=this._curY+l;if(u>this._nextY&&(this._nextY=u),u>=o)return!1;t>0&&n>0&&r&&(a.setPixelBuffer(r,0,this._curX,this._curY,t,n),a.generateMipmaps());var c=1/o,h=this._curX,d=this._curY,_=h*c,f=(h+t)*c,p=d*c,g=(d+n)*c;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},ey.addCharInfo=function(e,t){this._charInfoMap[e.charCodeAt(0)]=t},ey.getCharInfo=function(e){return this._charInfoMap[e.charCodeAt(0)]},sb(ev,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture=e}}]),ev),li=((eT=(ex=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},eT._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},eT._addCharInfo=function(e,t){var n=this._lastIndex;t.index=n,this._fontAtlases[n].addCharInfo(e,t)},eT._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},eT._getTextureByIndex=function(e){var t=this._fontAtlases[e];return t?t.texture:null},eT._getLastIndex=function(){return this._lastIndex},eT._createFontAtlas=function(){var e=this._engine,t=new lr(e),n=new le(e,256,256);return t.texture=n,t.isGCIgnored=n.isGCIgnored=!0,this._fontAtlases.push(t),t},ex),la=(sM(eC=function(e,t){var n;return void 0===t&&(t=""),(n=sU.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},sU),(eS=eC.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new li(this.engine),r[n]=i),i},eS._onDestroy=function(){var e=this._subFontMap;for(var t in e)e[t].destroy();this._subFontMap=null,delete eC._fontMap[this._name]},eC.createFromOS=function(e,t){if(t){var n=eC._fontMap,r=n[t];return r||(r=new eC(e,t),n[t]=r),r}return null},sb(eC,[{key:"name",get:function(){return this._name}}]),eC);la._fontMap={};var lo=((eb=(ew=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},eb.then=function(e,t){var n=this;return new ew(function(r,i){n._promise.then(e,t).then(r).catch(i)})},eb.catch=function(e){var t=this;return new ew(function(n,r){t._promise.catch(e).then(n).catch(r)})},eb.finally=function(e){return this._promise.finally(e)},eb.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},ew.all=function(e){return new ew(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){sR(e,Promise)||sR(e,ew)?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 u=0;u<o;u++)a(e[u],u)})},sb(ew,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),ew);(eA=oR||(oR={})).Pending="pending",eA.Fulfilled="fulfilled",eA.Rejected="rejected",eA.Canceled="canceled";var ls=((eF=(eM=function(e){this.engine=e,this.retryCount=1,this.retryInterval=0,this.timeout=1/0,this._assetPool=Object.create(null),this._assetUrlPool=Object.create(null),this._refObjectPool=Object.create(null),this._loadingPromises={},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 lo.all(n)},eF.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},eF.getAssetPath=function(e){return this._assetPool[e]},eF.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()}):s6(this._loadingPromises).forEach(function(e){e.cancel()})},eF.gc=function(){this._gc(!1);var e=this.engine;e._renderElementPool.garbageCollection(),e._spriteElementPool.garbageCollection(),e._spriteMaskElementPool.garbageCollection(),e._textElementPool.garbageCollection();var t=e._componentsManager,n=e._lightManager;t._renderers.garbageCollection(),t._onStartScripts.garbageCollection(),t._onUpdateScripts.garbageCollection(),t._onLateUpdateScripts.garbageCollection(),t._onPhysicsUpdateScripts.garbageCollection(),t._onUpdateAnimations.garbageCollection(),t._onUpdateRenderers.garbageCollection(),n._spotLights.garbageCollection(),n._pointLights.garbageCollection(),n._directLights.garbageCollection()},eF._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},eF._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},eF._addRefObject=function(e,t){this._refObjectPool[e]=t},eF._deleteRefObject=function(e){delete this._refObjectPool[e]},eF._destroy=function(){this.cancelNotLoaded(),this._gc(!0),this._assetPool=null,this._assetUrlPool=null,this._refObjectPool=null},eF._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},eF._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):[],u=this._assetUrlPool[o];if(u)return new lo(function(e){e(t._getResolveResource(u,l))});var c=o;s&&(c+="?q="+l.shift());var h=this._loadingPromises,d=h[c];if(d)return new lo(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(sR(f,lo))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[c].then(function(e){return t._getResolveResource(e,l)})},eF._gc=function(e){for(var t=s6(this._refObjectPool),n=0,r=t.length;n<r;n++)(!t[n].isGCIgnored||e)&&t[n].destroy()},eF._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},eF._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},eF._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},eF._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===lu&&t.push(""),e.replace(lh,function(e,n,r,i){var a=e;r?a=i.replace(lc,"$1"):n&&(a=n.trim()),t.push(a)}),t},eF.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 sj.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})},eF.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 ll(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);ls._addLoader(e,i,t)}}ls._loaders={},ls._extTypeMapping={};var lu=46,lc=/\\(\\)?/g,lh=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),ld=((eE=(eP=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},eP),l_=((eL=(eR=function(){this._renderers=new ld,this._onStartScripts=new ld,this._onUpdateScripts=new ld,this._onLateUpdateScripts=new ld,this._onPhysicsUpdateScripts=new ld,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new ld,this._onUpdateRenderers=new ld,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},eL.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},eL.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},eL.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},eL.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},eL.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eL.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},eL.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},eL.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},eL.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},eL.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},eL.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eL.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},eL.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},eL.addDisableScript=function(e){this._disableScripts.push(e)},eL.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},eL.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}},eL.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)}},eL.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)}},eL.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()}},eL.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n)t[n].update(e)},eL.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},eL.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}},eL.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)}},eL.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)}},eL.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},eL.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},eR),lf=((eB=function(){}).cloneComponent=function(e,t){for(var n=sO.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 oP.Assignment:t[o]=e[o];break;case oP.Shallow:var s=e[o];if(sR(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case oP.Deep:var u=e[o];if(sR(u,Object)){var c=t[o];null==c&&(c=t[o]=u.constructor()),sO.deepCloneObject(u,c)}else t[o]=u}}e._cloneTo&&e._cloneTo(t)},eB),lp=((eD=function(){})._register=function(e,t){this._addDependency(e,t,this._dependenciesMap),this._addDependency(t,e,this._invDependenciesMap)},eD._addCheck=function(e,t){var n=eD._dependenciesMap.get(t);if(n)for(var r=0,i=n.length;r<i;r++){var a=n[r];e.getComponent(a)||e.addComponent(a)}},eD._removeCheck=function(e,t){var n=eD._invDependenciesMap.get(t);if(n){for(var r=0,i=n.length;r<i;r++)if(e.getComponent(n[r]))throw"you should remove "+n[r]+" before adding "+t}},eD._addDependency=function(e,t,n){var r=n.get(e);r||(r=[],n.set(e,r)),-1===r.indexOf(t)&&r.push(t)},eD);function lg(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){t.forEach(function(t){return lp._register(e,t)})}}lp._dependenciesMap=new Map,lp._invDependenciesMap=new Map,e.Layer=void 0,(eI=e.Layer||(e.Layer={}))[eI.Layer0=1]="Layer0",eI[eI.Layer1=2]="Layer1",eI[eI.Layer2=4]="Layer2",eI[eI.Layer3=8]="Layer3",eI[eI.Layer4=16]="Layer4",eI[eI.Layer5=32]="Layer5",eI[eI.Layer6=64]="Layer6",eI[eI.Layer7=128]="Layer7",eI[eI.Layer8=256]="Layer8",eI[eI.Layer9=512]="Layer9",eI[eI.Layer10=1024]="Layer10",eI[eI.Layer11=2048]="Layer11",eI[eI.Layer12=4096]="Layer12",eI[eI.Layer13=8192]="Layer13",eI[eI.Layer14=16384]="Layer14",eI[eI.Layer15=32768]="Layer15",eI[eI.Layer16=65536]="Layer16",eI[eI.Layer17=131072]="Layer17",eI[eI.Layer18=262144]="Layer18",eI[eI.Layer19=524288]="Layer19",eI[eI.Layer20=1048576]="Layer20",eI[eI.Layer21=2097152]="Layer21",eI[eI.Layer22=4194304]="Layer22",eI[eI.Layer23=8388608]="Layer23",eI[eI.Layer24=16777216]="Layer24",eI[eI.Layer25=33554432]="Layer25",eI[eI.Layer26=67108864]="Layer26",eI[eI.Layer27=134217728]="Layer27",eI[eI.Layer28=268435456]="Layer28",eI[eI.Layer29=536870912]="Layer29",eI[eI.Layer30=1073741824]="Layer30",eI[eI.Layer31=2147483648]="Layer31",eI[eI.Everything=4294967295]="Everything",eI[eI.Nothing=0]="Nothing";var lm=((eV=(eO=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eV.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eV._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)s8(e[t]._updateFlags,this)},sM(eU=function(){var e;return e=eO.apply(this,arguments)||this,e.flag=!0,e},eO),eU.prototype.dispatch=function(){this.flag=!0},eU),lv=(sM(ez=function(e){var t;return(t=sV.call(this,e.engine)||this)._awoken=!1,t._destroyed=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},sV),(eN=ez.prototype).destroy=function(){this._destroyed||(this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable(),this._destroyed=!0,this._onDestroy())},eN._onAwake=function(){},eN._onEnable=function(){},eN._onDisable=function(){},eN._onDestroy=function(){},eN._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())},sb(ez,[{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:"destroyed",get:function(){return this._destroyed}},{key:"entity",get:function(){return this._entity}},{key:"scene",get:function(){return this._entity.scene}}]),ez);sE([sL],lv.prototype,"_entity",void 0),sE([sL],lv.prototype,"_awoken",void 0),sE([sL],lv.prototype,"_destroyed",void 0),sE([sL],lv.prototype,"_phasedActive",void 0),sE([sB],lv.prototype,"_enabled",void 0);var ly=((eG=(ek=function(){this._updateFlags=[],this._listensers=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eG.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eG.removeFlag=function(e){s8(this._updateFlags,e)&&s8(e._flagManagers,this)},eG.addListener=function(e){this._listensers.push(e)},eG.removeListener=function(e){s8(this._listensers,e)},eG.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._listensers,a=i.length-1;a>=0;a--)i[a](e,t)},ek),lx=(sM(eH=function(e){var t;return(t=lv.call(this,e)||this)._position=new sl,t._rotation=new sl,t._rotationQuaternion=new sp,t._scale=new sl(1,1,1),t._worldPosition=new sl,t._worldRotation=new sl,t._worldRotationQuaternion=new sp,t._lossyWorldScale=new sl(1,1,1),t._localMatrix=new sg,t._worldMatrix=new sg,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new ly,t._onPositionChanged=t._onPositionChanged.bind(sS(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(sS(t)),t._onRotationChanged=t._onRotationChanged.bind(sS(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(sS(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(sS(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(sS(t)),t._onScaleChanged=t._onScaleChanged.bind(sS(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},lv),(eW=eH.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eW.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eW.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eW.setScale=function(e,t,n){this._scale.set(e,t,n)},eW.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eW.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eW.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eW.getWorldForward=function(e){var t=this.worldMatrix.elements;return e.set(-t[8],-t[9],-t[10]),e.normalize()},eW.getWorldRight=function(e){var t=this.worldMatrix.elements;return e.set(t[0],t[1],t[2]),e.normalize()},eW.getWorldUp=function(e){var t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()},eW.translate=function(e,t,n,r){if("number"==typeof e){var i=eH._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},eW.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eW.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*ss.degreeToRadFactor;sp.rotationAxisAngle(e,r,eH._tempQuat0),this._rotateByQuat(eH._tempQuat0,n)},eW.lookAt=function(e,t){var n=eH._tempVec30;sl.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=ss.zeroTolerance)){n.scale(1/r);var i=eH._tempVec31;if(t?sl.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=ss.zeroTolerance)){i.scale(1/r);var a=eH._tempVec32;sl.cross(n,i,a);var o=eH._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)}}},eW.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(lm)},eW._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eW._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eW._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()}},eW._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()}},eW._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()}},eW._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()}},eW._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()}},eW._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()}},eW._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},eW._getScaleMatrix=function(){var e=eH._tempQuat0,t=eH._tempMat30,n=eH._tempMat31,r=eH._tempMat32;return n.copyFromMatrix(this.worldMatrix),sp.invert(this.worldRotationQuaternion,e),sf.rotationQuaternion(e,t),sf.multiply(t,n,r),r},eW._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eW._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eW._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eW._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eW._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eW._rotateByQuat=function(e,t){t?sp.multiply(this.rotationQuaternion,e,this._rotationQuaternion):sp.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eW._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eH._tempVec30;sl.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eW._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=ss.degreeToRadFactor,a=eH._tempQuat0;sp.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},eW._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eW._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(sg.invert(t.worldMatrix,eH._tempMat41),sl.transformCoordinate(e,eH._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eW._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eW._onWorldRotationChanged=function(){var e=this._worldRotation;sp.rotationEuler(ss.degreeToRadian(e.x),ss.degreeToRadian(e.y),ss.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eW._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eW._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eH._tempQuat0;sp.invert(t.worldRotationQuaternion,n),sp.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eW._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},sb(eH,[{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(ss.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(ss.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,sp.rotationEuler(ss.degreeToRadian(this._rotation.x),ss.degreeToRadian(this._rotation.y),ss.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):sp.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?sp.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):sp.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)&&(sg.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?sg.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?(sg.invert(t.worldMatrix,eH._tempMat42),sg.multiply(eH._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}}]),eH);lx._tempQuat0=new sp,lx._tempVec30=new sl,lx._tempVec31=new sl,lx._tempVec32=new sl,lx._tempMat30=new sf,lx._tempMat31=new sf,lx._tempMat32=new sf,lx._tempMat41=new sg,lx._tempMat42=new sg,sE([sI],lx.prototype,"_position",void 0),sE([sI],lx.prototype,"_rotation",void 0),sE([sI],lx.prototype,"_rotationQuaternion",void 0),sE([sI],lx.prototype,"_scale",void 0),sE([sI],lx.prototype,"_worldPosition",void 0),sE([sI],lx.prototype,"_worldRotation",void 0),sE([sI],lx.prototype,"_worldRotationQuaternion",void 0),sE([sI],lx.prototype,"_lossyWorldScale",void 0),sE([sI],lx.prototype,"_localMatrix",void 0),sE([sI],lx.prototype,"_worldMatrix",void 0),sE([sL],lx.prototype,"_isParentDirty",void 0),sE([sL],lx.prototype,"_parentTransformCache",void 0),sE([sL],lx.prototype,"_updateFlagManager",void 0),sE([sL],lx.prototype,"_onPositionChanged",null),sE([sL],lx.prototype,"_onWorldPositionChanged",null),sE([sL],lx.prototype,"_onRotationChanged",null),sE([sL],lx.prototype,"_onWorldRotationChanged",null),sE([sL],lx.prototype,"_onRotationQuaternionChanged",null),sE([sL],lx.prototype,"_onWorldRotationQuaternionChanged",null),sE([sL],lx.prototype,"_onScaleChanged",null),(eX=oL||(oL={}))[eX.LocalEuler=1]="LocalEuler",eX[eX.LocalQuat=2]="LocalQuat",eX[eX.WorldPosition=4]="WorldPosition",eX[eX.WorldEuler=8]="WorldEuler",eX[eX.WorldQuat=16]="WorldQuat",eX[eX.WorldScale=32]="WorldScale",eX[eX.LocalMatrix=64]="LocalMatrix",eX[eX.WorldMatrix=128]="WorldMatrix",eX[eX.WmWp=132]="WmWp",eX[eX.WmWeWq=152]="WmWeWq",eX[eX.WmWpWeWq=156]="WmWpWeWq",eX[eX.WmWs=160]="WmWs",eX[eX.WmWpWs=164]="WmWpWs",eX[eX.WmWpWeWqWs=188]="WmWpWeWqWs";var lT=(sM(ej=function(t,n){var r;return(r=sV.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new ld,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new sg,r.name=n,r.transform=r.addComponent(lx),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},sV),(eK=ej.prototype).addComponent=function(e){lp._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0),t},eK.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(sR(r,e))return r}},eK.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];sR(a,e)&&t.push(a)}return t},eK.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},eK.addChild=function(e,t){var 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&&ej._traverseSetOwnerScene(t,r),this._isActiveInHierarchy?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive(),t._setTransformDirty()}else t._setParent(this,n)},eK.removeChild=function(e){e._setParent(null)},eK.getChild=function(e){return this._children[e]},eK.findByName=function(e){if(e===this.name)return this;for(var t=this._children,n=0,r=t.length;n<r;n++){var i=t[n].findByName(e);if(i)return i}return null},eK.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=ej._findChildByName(n,a)))return null}return n},eK.createChild=function(e){var t=new ej(this.engine,e);return t.layer=this.layer,t.parent=this,t},eK.clearChildren=function(){for(var e=this._children,t=e.length-1;t>=0;t--){var n=e[t];n._parent=null,n._isActiveInHierarchy&&n._processInActive(),ej._traverseSetOwnerScene(n,null)}e.length=0},eK.clone=function(){var e=new ej(this._engine,this.name),t=this._hookResource;t&&(e._hookResource=t,t._addRefCount(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 u=o[s];if(!sR(u,lx)){var c=e.addComponent(u.constructor);lf.cloneComponent(u,c)}}return e},eK.destroy=function(){if(!this._destroyed){sV.prototype.destroy.call(this),this._hookResource&&(this._hookResource._addRefCount(-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()}},eK._removeComponent=function(e){lp._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},eK._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},eK._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},eK._removeFromParent=function(){var e=this._parent;if(null!=e){var t=e._children,n=this._siblingIndex;t.splice(n,1);for(var r=t.length;n<r;n++)t[n]._siblingIndex--;this._parent=null,this._siblingIndex=-1}},eK._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)},eK._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)},eK._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++}},eK._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&&ej._traverseSetOwnerScene(this,r),e._isActiveInHierarchy?!this._isActiveInHierarchy&&this._isActive&&this._processActive():this._isActiveInHierarchy&&this._processInActive()}else this._isActiveInHierarchy&&this._processInActive(),n&&ej._traverseSetOwnerScene(this,null);this._setTransformDirty()}},eK._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];sR(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},eK._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},eK._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)}},eK._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)}},eK._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},eK._setSiblingIndex=function(e,t){if((t=Math.min(t,e.length-1))<0)throw"Sibling index "+t+" should large than 0";if(this._siblingIndex!==t){var 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}}},eK.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(sg.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},ej._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},ej._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=e.childCount-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},sb(ej,[{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)}}]),ej);e.PointerPhase=void 0,(eq=e.PointerPhase||(e.PointerPhase={}))[eq.Down=0]="Down",eq[eq.Move=1]="Move",eq[eq.Stationary=2]="Stationary",eq[eq.Up=3]="Up",eq[eq.Leave=4]="Leave";var lC=((eQ=(eY=function(t){this.phase=e.PointerPhase.Leave,this.position=new sv,this.deltaPosition=new sv,this._events=[],this._upMap=[],this._downMap=[],this._upList=new ld,this._downList=new ld,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}},eQ._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},eQ._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)}},eQ._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}},eY),lS=((eJ=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?eJ.platform=e.Platform.IPhone:/iPad/i.test(n)?eJ.platform=e.Platform.IPad:/Android/i.test(n)?eJ.platform=e.Platform.Android:/Macintosh/i.test(n)&&(eJ.platform=e.Platform.Mac),eJ.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"}}},sb(eJ,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),eJ);lS.platform=e.Platform.Unknown,lS.operatingSystem="",lS._initialize(),e.Keys=void 0,(eZ=e.Keys||(e.Keys={}))[eZ.Backquote=0]="Backquote",eZ[eZ.Backslash=1]="Backslash",eZ[eZ.Backspace=2]="Backspace",eZ[eZ.BracketLeft=3]="BracketLeft",eZ[eZ.BracketRight=4]="BracketRight",eZ[eZ.Comma=5]="Comma",eZ[eZ.Digit0=6]="Digit0",eZ[eZ.Digit1=7]="Digit1",eZ[eZ.Digit2=8]="Digit2",eZ[eZ.Digit3=9]="Digit3",eZ[eZ.Digit4=10]="Digit4",eZ[eZ.Digit5=11]="Digit5",eZ[eZ.Digit6=12]="Digit6",eZ[eZ.Digit7=13]="Digit7",eZ[eZ.Digit8=14]="Digit8",eZ[eZ.Digit9=15]="Digit9",eZ[eZ.Equal=16]="Equal",eZ[eZ.IntlBackslash=17]="IntlBackslash",eZ[eZ.IntlRo=18]="IntlRo",eZ[eZ.IntlYen=19]="IntlYen",eZ[eZ.KeyA=20]="KeyA",eZ[eZ.KeyB=21]="KeyB",eZ[eZ.KeyC=22]="KeyC",eZ[eZ.KeyD=23]="KeyD",eZ[eZ.KeyE=24]="KeyE",eZ[eZ.KeyF=25]="KeyF",eZ[eZ.KeyG=26]="KeyG",eZ[eZ.KeyH=27]="KeyH",eZ[eZ.KeyI=28]="KeyI",eZ[eZ.KeyJ=29]="KeyJ",eZ[eZ.KeyK=30]="KeyK",eZ[eZ.KeyL=31]="KeyL",eZ[eZ.KeyM=32]="KeyM",eZ[eZ.KeyN=33]="KeyN",eZ[eZ.KeyO=34]="KeyO",eZ[eZ.KeyP=35]="KeyP",eZ[eZ.KeyQ=36]="KeyQ",eZ[eZ.KeyR=37]="KeyR",eZ[eZ.KeyS=38]="KeyS",eZ[eZ.KeyT=39]="KeyT",eZ[eZ.KeyU=40]="KeyU",eZ[eZ.KeyV=41]="KeyV",eZ[eZ.KeyW=42]="KeyW",eZ[eZ.KeyX=43]="KeyX",eZ[eZ.KeyY=44]="KeyY",eZ[eZ.KeyZ=45]="KeyZ",eZ[eZ.Minus=46]="Minus",eZ[eZ.Period=47]="Period",eZ[eZ.Quote=48]="Quote",eZ[eZ.Semicolon=49]="Semicolon",eZ[eZ.Slash=50]="Slash",eZ[eZ.AltLeft=51]="AltLeft",eZ[eZ.AltRight=52]="AltRight",eZ[eZ.CapsLock=53]="CapsLock",eZ[eZ.ContextMenu=54]="ContextMenu",eZ[eZ.ControlLeft=55]="ControlLeft",eZ[eZ.ControlRight=56]="ControlRight",eZ[eZ.Enter=57]="Enter",eZ[eZ.MetaLeft=58]="MetaLeft",eZ[eZ.MetaRight=59]="MetaRight",eZ[eZ.ShiftLeft=60]="ShiftLeft",eZ[eZ.ShiftRight=61]="ShiftRight",eZ[eZ.Space=62]="Space",eZ[eZ.Tab=63]="Tab",eZ[eZ.Convert=64]="Convert",eZ[eZ.KanaMode=65]="KanaMode",eZ[eZ.Lang1=66]="Lang1",eZ[eZ.Lang2=67]="Lang2",eZ[eZ.Lang3=68]="Lang3",eZ[eZ.Lang4=69]="Lang4",eZ[eZ.Lang5=70]="Lang5",eZ[eZ.NonConvert=71]="NonConvert",eZ[eZ.Delete=72]="Delete",eZ[eZ.End=73]="End",eZ[eZ.Help=74]="Help",eZ[eZ.Home=75]="Home",eZ[eZ.Insert=76]="Insert",eZ[eZ.PageDown=77]="PageDown",eZ[eZ.PageUp=78]="PageUp",eZ[eZ.ArrowDown=79]="ArrowDown",eZ[eZ.ArrowLeft=80]="ArrowLeft",eZ[eZ.ArrowRight=81]="ArrowRight",eZ[eZ.ArrowUp=82]="ArrowUp",eZ[eZ.NumLock=83]="NumLock",eZ[eZ.Numpad0=84]="Numpad0",eZ[eZ.Numpad1=85]="Numpad1",eZ[eZ.Numpad2=86]="Numpad2",eZ[eZ.Numpad3=87]="Numpad3",eZ[eZ.Numpad4=88]="Numpad4",eZ[eZ.Numpad5=89]="Numpad5",eZ[eZ.Numpad6=90]="Numpad6",eZ[eZ.Numpad7=91]="Numpad7",eZ[eZ.Numpad8=92]="Numpad8",eZ[eZ.Numpad9=93]="Numpad9",eZ[eZ.NumpadAdd=94]="NumpadAdd",eZ[eZ.NumpadBackspace=95]="NumpadBackspace",eZ[eZ.NumpadClear=96]="NumpadClear",eZ[eZ.NumpadClearEntry=97]="NumpadClearEntry",eZ[eZ.NumpadComma=98]="NumpadComma",eZ[eZ.NumpadDecimal=99]="NumpadDecimal",eZ[eZ.NumpadDivide=100]="NumpadDivide",eZ[eZ.NumpadEnter=101]="NumpadEnter",eZ[eZ.NumpadEqual=102]="NumpadEqual",eZ[eZ.NumpadHash=103]="NumpadHash",eZ[eZ.NumpadMemoryAdd=104]="NumpadMemoryAdd",eZ[eZ.NumpadMemoryClear=105]="NumpadMemoryClear",eZ[eZ.NumpadMemoryRecall=106]="NumpadMemoryRecall",eZ[eZ.NumpadMemoryStore=107]="NumpadMemoryStore",eZ[eZ.NumpadMemorySubtract=108]="NumpadMemorySubtract",eZ[eZ.NumpadMultiply=109]="NumpadMultiply",eZ[eZ.NumpadParenLeft=110]="NumpadParenLeft",eZ[eZ.NumpadParenRight=111]="NumpadParenRight",eZ[eZ.NumpadStar=112]="NumpadStar",eZ[eZ.NumpadSubtract=113]="NumpadSubtract",eZ[eZ.Escape=114]="Escape",eZ[eZ.F1=115]="F1",eZ[eZ.F2=116]="F2",eZ[eZ.F3=117]="F3",eZ[eZ.F4=118]="F4",eZ[eZ.F5=119]="F5",eZ[eZ.F6=120]="F6",eZ[eZ.F7=121]="F7",eZ[eZ.F8=122]="F8",eZ[eZ.F9=123]="F9",eZ[eZ.F10=124]="F10",eZ[eZ.F11=125]="F11",eZ[eZ.F12=126]="F12",eZ[eZ.F13=127]="F13",eZ[eZ.F14=128]="F14",eZ[eZ.F15=129]="F15",eZ[eZ.Fn=130]="Fn",eZ[eZ.FnLock=131]="FnLock",eZ[eZ.PrintScreen=132]="PrintScreen",eZ[eZ.ScrollLock=133]="ScrollLock",eZ[eZ.Pause=134]="Pause",eZ[eZ.BrowserBack=135]="BrowserBack",eZ[eZ.BrowserFavorites=136]="BrowserFavorites",eZ[eZ.BrowserForward=137]="BrowserForward",eZ[eZ.BrowserHome=138]="BrowserHome",eZ[eZ.BrowserRefresh=139]="BrowserRefresh",eZ[eZ.BrowserSearch=140]="BrowserSearch",eZ[eZ.BrowserStop=141]="BrowserStop",eZ[eZ.Eject=142]="Eject",eZ[eZ.LaunchApp1=143]="LaunchApp1",eZ[eZ.LaunchApp2=144]="LaunchApp2",eZ[eZ.LaunchMail=145]="LaunchMail",eZ[eZ.MediaPlayPause=146]="MediaPlayPause",eZ[eZ.MediaSelect=147]="MediaSelect",eZ[eZ.MediaStop=148]="MediaStop",eZ[eZ.MediaTrackNext=149]="MediaTrackNext",eZ[eZ.MediaTrackPrevious=150]="MediaTrackPrevious",eZ[eZ.Power=151]="Power",eZ[eZ.Sleep=152]="Sleep",eZ[eZ.AudioVolumeDown=153]="AudioVolumeDown",eZ[eZ.AudioVolumeMute=154]="AudioVolumeMute",eZ[eZ.AudioVolumeUp=155]="AudioVolumeUp",eZ[eZ.WakeUp=156]="WakeUp",eZ[eZ.Hyper=157]="Hyper",eZ[eZ.Super=158]="Super",eZ[eZ.Turbo=159]="Turbo",eZ[eZ.Abort=160]="Abort",eZ[eZ.Resume=161]="Resume",eZ[eZ.Suspend=162]="Suspend",eZ[eZ.Again=163]="Again",eZ[eZ.Copy=164]="Copy",eZ[eZ.Cut=165]="Cut",eZ[eZ.Find=166]="Find",eZ[eZ.Open=167]="Open",eZ[eZ.Paste=168]="Paste",eZ[eZ.Props=169]="Props",eZ[eZ.Select=170]="Select",eZ[eZ.Undo=171]="Undo",eZ[eZ.Hiragana=172]="Hiragana",eZ[eZ.Katakana=173]="Katakana",eZ[eZ.Unidentified=174]="Unidentified";var lw=((e0=(e$=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new ld,this._curFrameDownList=new ld,this._curFrameUpList=new ld,this._nativeEvents=[],this._hadListener=!1,this._htmlCanvas=e,e.tabIndex=e.tabIndex,this._onKeyEvent=this._onKeyEvent.bind(this),e.addEventListener("keydown",this._onKeyEvent),e.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0}).prototype)._update=function(t){var n=this._nativeEvents,r=this._curFrameDownList,i=this._curFrameUpList;if(r.length=0,i.length=0,n.length>0){for(var a=this._curHeldDownKeyToIndexMap,o=this._curFrameHeldDownList,s=this._downKeyToFrameCountMap,l=this._upKeyToFrameCountMap,u=0,c=n.length;u<c;u++){var h=n[u],d=e.Keys[h.code];switch(h.type){case"keydown":null==a[d]&&(r.add(d),o.add(d),a[d]=o.length-1,s[d]=t);break;case"keyup":var _=a[d];if(null!=_){a[d]=null;var f=o.deleteByIndex(_);f&&(a[f]=_)}if(i.add(d),l[d]=t,lS.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}}}n.length=0}},e0._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},e0._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)},e0._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},e0._onKeyEvent=function(e){this._nativeEvents.push(e)},e$);e.CameraClearFlags=void 0,(e1=e.CameraClearFlags||(e.CameraClearFlags={}))[e1.None=0]="None",e1[e1.Color=1]="Color",e1[e1.Depth=2]="Depth",e1[e1.Stencil=4]="Stencil",e1[e1.ColorDepth=3]="ColorDepth",e1[e1.ColorStencil=5]="ColorStencil",e1[e1.DepthStencil=6]="DepthStencil",e1[e1.All=7]="All";var lb=function(){this.entity=null,this.distance=0,this.point=new sl,this.normal=new sl},lA=((e3=(e2=function(e){var t=this;this._initialized=!1,this._restTime=0,this._colliders=new ld,this._gravity=new sl(0,-9.81,0),this._physicalObjectsMap={},this._onContactEnter=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onCollisionEnter(i)}a=i.collider.entity._scripts;for(var u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onCollisionEnter(r)}},this._onContactExit=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onCollisionExit(i)}a=i.collider.entity._scripts;for(var u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onCollisionExit(r)}},this._onContactStay=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],a=r.collider.entity._scripts,o=0,s=a.length;o<s;o++){var l=a.get(o);l._waitHandlingInValid||l.onCollisionStay(i)}a=i.collider.entity._scripts;for(var u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onCollisionStay(r)}},this._onTriggerEnter=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],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 u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onTriggerEnter(r)}},this._onTriggerExit=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],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 u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onTriggerExit(r)}},this._onTriggerStay=function(e,n){for(var r=t._physicalObjectsMap[e],i=t._physicalObjectsMap[n],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 u=0,c=a.length;u<c;u++){var h=a.get(u);h._waitHandlingInValid||h.onTriggerStay(r)}},this.fixedTimeStep=1/60,this.maxAllowedTimeStep=1/3,this._engine=e,this._setGravity=this._setGravity.bind(this),this._gravity._onValueChanged=this._setGravity}).prototype).initialize=function(e){this._initialized||(e2._nativePhysics=e,this._nativePhysicsManager=e2._nativePhysics.createPhysicsManager(this._onContactEnter,this._onContactExit,this._onContactStay,this._onTriggerEnter,this._onTriggerExit,this._onTriggerStay),this._initialized=!0)},e3.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 u=function(e){var t=o._physicalObjectsMap[e];return t.collider.entity.layer&l&&t.isSceneQuery};return void 0==a?this._nativePhysicsManager.raycast(t,s,u):!!this._nativePhysicsManager.raycast(t,s,u,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)},e3._update=function(e){var t=this.fixedTimeStep,n=this._nativePhysicsManager,r=this._engine._componentsManager,i=Math.min(this.maxAllowedTimeStep,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()},e3._addColliderShape=function(e){this._physicalObjectsMap[e.id]=e,this._nativePhysicsManager.addColliderShape(e._nativeShape)},e3._removeColliderShape=function(e){delete this._physicalObjectsMap[e.id],this._nativePhysicsManager.removeColliderShape(e._nativeShape)},e3._addCollider=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCollider(e._nativeCollider)},e3._addCharacterController=function(e){-1===e._index&&(e._index=this._colliders.length,this._colliders.add(e)),this._nativePhysicsManager.addCharacterController(e._nativeCollider)},e3._removeCollider=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCollider(e._nativeCollider)},e3._removeCharacterController=function(e){var t=this._colliders.deleteByIndex(e._index);t&&(t._index=e._index),e._index=-1,this._nativePhysicsManager.removeCharacterController(e._nativeCollider)},e3._callColliderOnUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onUpdate()},e3._callColliderOnLateUpdate=function(){for(var e=this._colliders._elements,t=this._colliders.length-1;t>=0;--t)e[t]._onLateUpdate()},e3._setGravity=function(){this._nativePhysicsManager.setGravity(this._gravity)},sb(e2,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"maxSumTimeStep",get:function(){return this.maxAllowedTimeStep},set:function(e){this.maxAllowedTimeStep=e}}]),e2);e.PhysicsMaterialCombineMode=void 0,(e4=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[e4.Average=0]="Average",e4[e4.Minimum=1]="Minimum",e4[e4.Multiply=2]="Multiply",e4[e4.Maximum=3]="Maximum";var lM=((e5=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=lA._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},sb(e5,[{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))}}]),e5);e.Collider=(sM(e8=function(e){var t;return(t=lv.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lv),(e6=e8.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))},e6.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))},e6.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},e6._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}},e6._onLateUpdate=function(){},e6._onEnable=function(){this.engine.physicsManager._addCollider(this)},e6._onDisable=function(){this.engine.physicsManager._removeCollider(this)},e6._onDestroy=function(){this.clearShapes(),this._nativeCollider.destroy()},sb(e8,[{key:"shapes",get:function(){return this._shapes}}]),e8),sE([sL],e.Collider.prototype,"_index",void 0),e.Collider=sE([lg(lx)],e.Collider),e.ControllerNonWalkableMode=void 0,(e7=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[e7.PreventClimbing=0]="PreventClimbing",e7[e7.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var lF=(e9=e.Collider,sM(te=function(t){var n;return(n=e9.call(this,t)||this)._index=-1,n._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sl(0,1,0),n._slopeLimit=.707,n._nativeCollider=lA._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(sS(n)),n._upDirection._onValueChanged=n._setUpDirection,n},e9),(tt=te.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},tt.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";e9.prototype.addShape.call(this,e),this._updateFlag.flag=!0},tt.clearShapes=function(){this._shapes.length>0&&e9.prototype.removeShape.call(this,this._shapes[0])},tt._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}},tt._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},tt._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},tt._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},tt._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},sb(te,[{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))}}]),te),lP=function(){function e(){this._isTrigger=!1,this._rotation=new sl,this._position=new sl,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new lM,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)},sb(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}();lP._idGenerator=0;var lE=(sM(tn=function(){var e;return(e=lP.call(this)||this)._size=new sl(1,1,1),e._nativeShape=lA._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(sS(e)),e._size._onValueChanged=e._setSize,e},lP),tn.prototype._setSize=function(){this._nativeShape.setSize(this._size)},sb(tn,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),tn),lR=(sM(tr=function(){var e;return(e=lP.call(this)||this)._radius=1,e._nativeShape=lA._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},lP),sb(tr,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),tr),lL=(sM(ti=function(){var e;return(e=lP.call(this)||this)._nativeShape=lA._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},lP),ti);e.ColliderShapeUpAxis=void 0,(ta=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[ta.X=0]="X",ta[ta.Y=1]="Y",ta[ta.Z=2]="Z";var lB=(sM(to=function(){var t;return(t=lP.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=lA._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},lP),sb(to,[{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))}}]),to);e.Joint=(sM(ts=function(e){var t;return(t=lv.call(this,e)||this)._connectedCollider=new lD,t._collider=new lD,t._force=0,t._torque=0,t._connectedCollider.localPosition=new sl,t},lv),sb(ts,[{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))}}]),ts),e.Joint=sE([lg(e.Collider)],e.Joint);var lD=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},lI=(tl=e.Joint,sM(tu=function(){return tl.apply(this,arguments)},tl),tu.prototype._onAwake=function(){var t=this._collider;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lA._nativePhysics.createFixedJoint(t.collider._nativeCollider)},tu);(tc=oB||(oB={}))[tc.LimitEnabled=1]="LimitEnabled",tc[tc.DriveEnabled=2]="DriveEnabled",tc[tc.DriveFreeSpin=4]="DriveFreeSpin";var lO=(th=e.Joint,sM(td=function(){var e;return e=th.apply(this,arguments)||this,e._axis=new sl(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},th),td.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sl,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lA._nativePhysics.createHingeJoint(t.collider._nativeCollider)},sb(td,[{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&oB.LimitEnabled)==oB.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=oB.LimitEnabled),this._nativeJoint.setHingeJointFlag(oB.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&oB.DriveEnabled)==oB.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=oB.DriveEnabled),this._nativeJoint.setHingeJointFlag(oB.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(oB.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))}}]),td),lV=(t_=e.Joint,sM(tf=function(){var e;return e=t_.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},t_),tf.prototype._onAwake=function(){var t=this._collider;t.localPosition=new sl,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=lA._nativePhysics.createSpringJoint(t.collider._nativeCollider)},sb(tf,[{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))}}]),tf),lU=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},lz=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(tp=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[tp.Sides=1]="Sides",tp[tp.Up=2]="Up",tp[tp.Down=4]="Down";var lN=(tg=e.Collider,sM(tm=function(e){var t,n=(t=tg.call(this,e)||this).entity.transform;return t._nativeCollider=lA._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},tg),tm),lk=(tv=e.Collider,sM(ty=function(e){(t=tv.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sl,t._angularVelocity=new sl,t._mass=1,t._centerOfMass=new sl,t._inertiaTensor=new sl(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=lA._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(sS(t)),t._setAngularVelocity=t._setAngularVelocity.bind(sS(t)),t._setCenterOfMass=t._setCenterOfMass.bind(sS(t)),t._setInertiaTensor=t._setInertiaTensor.bind(sS(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},tv),(tx=ty.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},tx.applyTorque=function(e){this._nativeCollider.addTorque(e)},tx.move=function(e,t){this._nativeCollider.move(e,t)},tx.sleep=function(){this._nativeCollider.sleep()},tx.wakeUp=function(){this._nativeCollider.wakeUp()},tx._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},tx._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},tx._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},tx._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},tx._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},sb(ty,[{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))}}]),ty);e.CollisionDetectionMode=void 0,(tT=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[tT.Discrete=0]="Discrete",tT[tT.Continuous=1]="Continuous",tT[tT.ContinuousDynamic=2]="ContinuousDynamic",tT[tT.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(tC=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[tC.None=0]="None",tC[tC.FreezePositionX=1]="FreezePositionX",tC[tC.FreezePositionY=2]="FreezePositionY",tC[tC.FreezePositionZ=4]="FreezePositionZ",tC[tC.FreezeRotationX=8]="FreezeRotationX",tC[tC.FreezeRotationY=16]="FreezeRotationY",tC[tC.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(tS=e.PointerButton||(e.PointerButton={}))[tS.None=0]="None",tS[tS.Primary=1]="Primary",tS[tS.Secondary=2]="Secondary",tS[tS.Auxiliary=4]="Auxiliary",tS[tS.XButton1=8]="XButton1",tS[tS.XButton2=16]="XButton2",tS[tS.XButton3=32]="XButton3",tS[tS.XButton4=64]="XButton4",tS[tS.XButton5=128]="XButton5",tS[tS.XButton6=256]="XButton6",tS[tS.XButton7=512]="XButton7",tS[tS.XButton8=1024]="XButton8";var lG=[1,4,2,8,16,32,64,128,256,512,1024],lH={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},lW=((tb=(tw=function(t,n){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new ld,this._downList=new ld,this._nativeEvents=[],this._hadListener=!1,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(t){var n=this._pointers,r=this._nativeEvents,i=n.length-1;if(i>=0)for(var a=i;a>=0;a--)n[a].phase===e.PointerPhase.Leave&&n.splice(a,1);if((i=r.length-1)>=0){for(var o=0;o<=i;o++){var s,l=r[o];null==(s=this._getPointer(l.pointerId))||s._events.push(l)}r.length=0}if(this._upList.length=this._downList.length=0,this._buttons=e.PointerButton.None,(i=n.length-1)>=0)for(var u=this._engine.physicsManager._initialized?this._updatePointerWithPhysics:this._updatePointerWithoutPhysics,c=this._htmlCanvas.getBoundingClientRect(),h=this._htmlCanvas,d=h.clientWidth,_=h.clientHeight,f=this._canvas,p=f.width,g=f.height,m=i;m>=0;m--){var v=n[m];v._upList.length=v._downList.length=0,u(t,v,c,d,_,p,g),this._buttons|=v.pressedButtons}},tb._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}},tb._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}},tb._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},tb._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},tb._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},tb._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 lC(a)),o._uniqueID=e,t.splice(a,0,o),o},tb._pointerRayCast=function(t,n){for(var r=tw._tempPoint,i=tw._tempRay,a=tw._tempHitResult,o=this._engine.sceneManager.activeScene._activeCameras,s=o.length-1;s>=0;s--){var l=o[s];if(l.enabled&&!l.renderTarget){var u=l.viewport,c=u.x,h=u.y,d=u.z,_=u.w;if(t>=c&&n>=h&&t-c<=d&&n-h<=_){if(r.set((t-c)/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}}}},tb._updatePointerWithPhysics=function(t,n,r,i,a,o,s){var l=n._events,u=n.position,c=l.length;if(c>0){var h=this._upList,d=this._upMap,_=this._downList,f=this._downMap,p=l[c-1],g=(p.clientX-r.left)/i,m=(p.clientY-r.top)/a,v=g*o,y=m*s;n.deltaPosition.set(v-u.x,y-u.y),u.set(v,y),n._firePointerDrag();var x=this._pointerRayCast(g,m);n._firePointerExitAndEnter(x);for(var T=0;T<c;T++){var C=l[T],S=C.button;switch(n.button=lG[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(u.x/o,u.y/s))},tb._updatePointerWithoutPhysics=function(t,n,r,i,a,o,s){var l=n._events,u=l.length;if(u>0){var c=n.position,h=l[u-1],d=(h.clientX-r.left)/i*o,_=(h.clientY-r.top)/a*s;n.deltaPosition.set(d-c.x,_-c.y),c.set(d,_),n.button=lG[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<u;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},tw);lW._tempRay=new sm,lW._tempPoint=new sv,lW._tempHitResult=new lb;var lX=((tM=(tA=function(e){this._delta=new sl,this._nativeEvents=[],this._onWheelEvent=this._onWheelEvent.bind(this),e.addEventListener("wheel",this._onWheelEvent),this._canvas=e,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}},tM._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},tM._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},tM._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},tM._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},tA),lj=((tP=(tF=function(e){this._initialized=!1,this._curFrameCount=0;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&sR(t,OffscreenCanvas)||(this._wheelManager=new lX(t),this._pointerManager=new lW(e,t),this._keyboardManager=new lw(t),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])},tP.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._curFrameCount)},tP.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._curFrameCount)},tP.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},tP.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[lH[e]]===this._curFrameCount)},tP.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[lH[e]]===this._curFrameCount)},tP._update=function(){this._initialized&&(++this._curFrameCount,this._wheelManager._update(),this._pointerManager._update(this._curFrameCount),this._keyboardManager._update(this._curFrameCount))},tP._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},tP._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},tP._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},sb(tF,[{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}}]),tF);e.ShadowCascadesMode=void 0,(tE=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[tE.NoCascades=1]="NoCascades",tE[tE.TwoCascades=2]="TwoCascades",tE[tE.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(tR=e.ShadowResolution||(e.ShadowResolution={}))[tR.Low=0]="Low",tR[tR.Medium=1]="Medium",tR[tR.High=2]="High",tR[tR.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(tL=e.ShadowType||(e.ShadowType={}))[tL.None=0]="None",tL[tL.Hard=1]="Hard",tL[tL.SoftLow=2]="SoftLow",tL[tL.SoftHigh=3]="SoftHigh",e.RenderQueueType=void 0,(tB=e.RenderQueueType||(e.RenderQueueType={}))[tB.Opaque=0]="Opaque",tB[tB.AlphaTest=1]="AlphaTest",tB[tB.Transparent=2]="Transparent",e.BlendFactor=void 0,(tD=e.BlendFactor||(e.BlendFactor={}))[tD.Zero=0]="Zero",tD[tD.One=1]="One",tD[tD.SourceColor=2]="SourceColor",tD[tD.OneMinusSourceColor=3]="OneMinusSourceColor",tD[tD.DestinationColor=4]="DestinationColor",tD[tD.OneMinusDestinationColor=5]="OneMinusDestinationColor",tD[tD.SourceAlpha=6]="SourceAlpha",tD[tD.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",tD[tD.DestinationAlpha=8]="DestinationAlpha",tD[tD.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",tD[tD.SourceAlphaSaturate=10]="SourceAlphaSaturate",tD[tD.BlendColor=11]="BlendColor",tD[tD.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(tI=e.BlendOperation||(e.BlendOperation={}))[tI.Add=0]="Add",tI[tI.Subtract=1]="Subtract",tI[tI.ReverseSubtract=2]="ReverseSubtract",tI[tI.Min=3]="Min",tI[tI.Max=4]="Max",e.ColorWriteMask=void 0,(tO=e.ColorWriteMask||(e.ColorWriteMask={}))[tO.None=0]="None",tO[tO.Red=1]="Red",tO[tO.Green=2]="Green",tO[tO.Blue=4]="Blue",tO[tO.Alpha=8]="Alpha",tO[tO.All=15]="All",e.CompareFunction=void 0,(tV=e.CompareFunction||(e.CompareFunction={}))[tV.Never=0]="Never",tV[tV.Less=1]="Less",tV[tV.Equal=2]="Equal",tV[tV.LessEqual=3]="LessEqual",tV[tV.Greater=4]="Greater",tV[tV.NotEqual=5]="NotEqual",tV[tV.GreaterEqual=6]="GreaterEqual",tV[tV.Always=7]="Always",e.CullMode=void 0,(tU=e.CullMode||(e.CullMode={}))[tU.Off=0]="Off",tU[tU.Front=1]="Front",tU[tU.Back=2]="Back",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",e.StencilOperation=void 0,(tN=e.StencilOperation||(e.StencilOperation={}))[tN.Keep=0]="Keep",tN[tN.Zero=1]="Zero",tN[tN.Replace=2]="Replace",tN[tN.IncrementSaturate=3]="IncrementSaturate",tN[tN.DecrementSaturate=4]="DecrementSaturate",tN[tN.Invert=5]="Invert",tN[tN.IncrementWrap=6]="IncrementWrap",tN[tN.DecrementWrap=7]="DecrementWrap";var lK=((tG=(tk=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new sq,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},tG.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},tG.getInt=function(e){return this.getPropertyValue(e)},tG.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},tG.getFloatArray=function(e){return this.getPropertyValue(e)},tG.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},tG.getIntArray=function(e){return this.getPropertyValue(e)},tG.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},tG.getVector2=function(e){return this.getPropertyValue(e)},tG.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},tG.getVector3=function(e){return this.getPropertyValue(e)},tG.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},tG.getVector4=function(e){return this.getPropertyValue(e)},tG.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},tG.getMatrix=function(e){return this.getPropertyValue(e)},tG.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},tG.getColor=function(e){return this.getPropertyValue(e)},tG.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},tG.getTexture=function(e){return this.getPropertyValue(e)},tG.setTexture=function(t,n){if(this._getRefCount()>0){var r=this.getPropertyValue(t);r&&r._addRefCount(-1),n&&n._addRefCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.Texture,n)},tG.getTextureArray=function(e){return this.getPropertyValue(e)},tG.setTextureArray=function(t,n){if(this._getRefCount()>0){var r=this.getPropertyValue(t);if(r)for(var i=0,a=r.length;i<a;i++)r[i]._addRefCount(-1);if(n)for(var o=0,s=n.length;o<s;o++)n[o]._addRefCount(1)}this._setPropertyValue(t,e.ShaderPropertyType.TextureArray,n)},tG.getPropertyValue=function(e){return"string"==typeof e&&(e=s3.getPropertyByName(e)),this._propertyValueMap[e._uniqueId]},tG.enableMacro=function(e,t){"string"==typeof e&&(e=s3.getMacroByName(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}},tG.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=sK._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},tG.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])},tG.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=s3._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},tG.clone=function(){var e=new tk(this._group);return this.cloneTo(e),e},tG.cloneTo=function(e){sO.deepCloneObject(this._macroCollection,e._macroCollection),Object.assign(e._macroMap,this._macroMap);for(var t=e._getRefCount(),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(sR(l,s7))r[s]=l,t>0&&l._addRefCount(t);else if(sR(l,Array)||sR(l,Float32Array)||sR(l,Int32Array))r[s]=l.slice();else{var u=r[s];u?u.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},tG._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=s3.getPropertyByName(t)),t._group!==this._group){if(void 0===t._group)t._group=this._group;else throw"Shader property "+t.name+" has been used as "+oE[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},tG._getRefCount=function(){return this._refCount},tG._addRefCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&sR(r,s7)&&r._addRefCount(e)}},tk),lq=(sM(tH=function(){var t;return t=lv.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 sx(1,1,1,1),t._lightColor=new sx,t},lv),tH.prototype._getLightColor=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},sb(tH,[{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 sg),sg.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new sg),sg.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),tH);lq._maxLight=10,sE([sL],lq.prototype,"_lightIndex",void 0);var lY=(sM(tW=function(){var e;return e=lq.apply(this,arguments)||this,e._forward=new sl,e._reverseDirection=new sl,e},lq),(tX=tW.prototype)._appendData=function(e){var t=2*e,n=3*e,r=3*e,i=this._getLightColor(),a=this.direction,o=tW._combinedData,s=this.cullingMask;o.cullingMask[t]=65535&s,o.cullingMask[t+1]=s>>>16&65535,o.color[n]=i.r,o.color[n+1]=i.g,o.color[n+2]=i.b,o.direction[r]=a.x,o.direction[r+1]=a.y,o.direction[r+2]=a.z},tX._onEnable=function(){this.engine._lightManager._attachDirectLight(this)},tX._onDisable=function(){this.engine._lightManager._detachDirectLight(this)},tW._updateShaderData=function(e){var t=tW._combinedData;e.setIntArray(tW._cullingMaskProperty,t.cullingMask),e.setFloatArray(tW._colorProperty,t.color),e.setFloatArray(tW._directionProperty,t.direction)},sb(tW,[{key:"direction",get:function(){return this.entity.transform.getWorldForward(this._forward),this._forward}},{key:"reverseDirection",get:function(){return sl.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tW);lY._cullingMaskProperty=s3.getPropertyByName("u_directLightCullingMask"),lY._colorProperty=s3.getPropertyByName("u_directLightColor"),lY._directionProperty=s3.getPropertyByName("u_directLightDirection"),lY._combinedData={cullingMask:new Int32Array(2*lq._maxLight),color:new Float32Array(3*lq._maxLight),direction:new Float32Array(3*lq._maxLight)};var lQ=(sM(tj=function(){var e;return e=lq.apply(this,arguments)||this,e.distance=100,e},lq),(tK=tj.prototype)._appendData=function(e){var t=2*e,n=3*e,r=3*e,i=this._getLightColor(),a=this.position,o=tj._combinedData,s=this.cullingMask;o.cullingMask[t]=65535&s,o.cullingMask[t+1]=s>>>16&65535,o.color[n]=i.r,o.color[n+1]=i.g,o.color[n+2]=i.b,o.position[r]=a.x,o.position[r+1]=a.y,o.position[r+2]=a.z,o.distance[e]=this.distance},tK._onEnable=function(){this.engine._lightManager._attachPointLight(this)},tK._onDisable=function(){this.engine._lightManager._detachPointLight(this)},tj._updateShaderData=function(e){var t=tj._combinedData;e.setIntArray(tj._cullingMaskProperty,t.cullingMask),e.setFloatArray(tj._colorProperty,t.color),e.setFloatArray(tj._positionProperty,t.position),e.setFloatArray(tj._distanceProperty,t.distance)},sb(tj,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),tj);lQ._cullingMaskProperty=s3.getPropertyByName("u_pointLightCullingMask"),lQ._colorProperty=s3.getPropertyByName("u_pointLightColor"),lQ._positionProperty=s3.getPropertyByName("u_pointLightPosition"),lQ._distanceProperty=s3.getPropertyByName("u_pointLightDistance"),lQ._combinedData={cullingMask:new Int32Array(2*lq._maxLight),color:new Float32Array(3*lq._maxLight),position:new Float32Array(3*lq._maxLight),distance:new Float32Array(lq._maxLight)};var lJ=(sM(tq=function(){var e;return e=lq.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._forward=new sl,e._inverseDirection=new sl,e._projectMatrix=new sg,e},lq),(tY=tq.prototype)._appendData=function(e){var t=2*e,n=3*e,r=3*e,i=3*e,a=this._getLightColor(),o=this.position,s=this.direction,l=tq._combinedData,u=this.cullingMask;l.cullingMask[t]=65535&u,l.cullingMask[t+1]=u>>>16&65535,l.color[n]=a.r,l.color[n+1]=a.g,l.color[n+2]=a.b,l.position[r]=o.x,l.position[r+1]=o.y,l.position[r+2]=o.z,l.direction[i]=s.x,l.direction[i+1]=s.y,l.direction[i+2]=s.z,l.distance[e]=this.distance,l.angleCos[e]=Math.cos(this.angle),l.penumbraCos[e]=Math.cos(this.angle+this.penumbra)},tY._onEnable=function(){this.engine._lightManager._attachSpotLight(this)},tY._onDisable=function(){this.engine._lightManager._detachSpotLight(this)},tq._updateShaderData=function(e){var t=tq._combinedData;e.setIntArray(tq._cullingMaskProperty,t.cullingMask),e.setFloatArray(tq._colorProperty,t.color),e.setFloatArray(tq._positionProperty,t.position),e.setFloatArray(tq._directionProperty,t.direction),e.setFloatArray(tq._distanceProperty,t.distance),e.setFloatArray(tq._angleCosProperty,t.angleCos),e.setFloatArray(tq._penumbraCosProperty,t.penumbraCos)},sb(tq,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.getWorldForward(this._forward),this._forward}},{key:"reverseDirection",get:function(){return sl.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 sg.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),tq);lJ._cullingMaskProperty=s3.getPropertyByName("u_spotLightCullingMask"),lJ._colorProperty=s3.getPropertyByName("u_spotLightColor"),lJ._positionProperty=s3.getPropertyByName("u_spotLightPosition"),lJ._directionProperty=s3.getPropertyByName("u_spotLightDirection"),lJ._distanceProperty=s3.getPropertyByName("u_spotLightDistance"),lJ._angleCosProperty=s3.getPropertyByName("u_spotLightAngleCos"),lJ._penumbraCosProperty=s3.getPropertyByName("u_spotLightPenumbraCos"),lJ._combinedData={cullingMask:new Int32Array(2*lq._maxLight),color:new Float32Array(3*lq._maxLight),position:new Float32Array(3*lq._maxLight),direction:new Float32Array(3*lq._maxLight),distance:new Float32Array(lq._maxLight),angleCos:new Float32Array(lq._maxLight),penumbraCos:new Float32Array(lq._maxLight)};var lZ=((tJ=(tQ=function(){this._spotLights=new ld,this._pointLights=new ld,this._directLights=new ld}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},tJ._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tJ._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},tJ._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tJ._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},tJ._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},tJ._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},tJ._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 u=0;u<o;u++)r.get(u)._appendData(u);o?(lY._updateShaderData(e),e.enableMacro("O3_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("O3_DIRECT_LIGHT_COUNT"),a?(lQ._updateShaderData(e),e.enableMacro("O3_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("O3_POINT_LIGHT_COUNT"),i?(lJ._updateShaderData(e),e.enableMacro("O3_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("O3_SPOT_LIGHT_COUNT")},tQ),l$=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},l0=((t$=(tZ=function(){this.targetBlendState=new l$,this.blendColor=new sx(0,0,0,0),this.alphaToCoverage=!1}).prototype)._apply=function(e,t){this._platformApply(e,t.blendState)},t$._platformApply=function(t,n){var r=t.gl,i=n.targetBlendState,a=this.targetBlendState,o=a.enabled,s=a.colorBlendOperation,l=a.alphaBlendOperation,u=a.sourceColorBlendFactor,c=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){(u!==i.sourceColorBlendFactor||c!==i.destinationColorBlendFactor||h!==i.sourceAlphaBlendFactor||d!==i.destinationAlphaBlendFactor)&&(r.blendFuncSeparate(tZ._getGLBlendFactor(t,u),tZ._getGLBlendFactor(t,c),tZ._getGLBlendFactor(t,h),tZ._getGLBlendFactor(t,d)),i.sourceColorBlendFactor=u,i.destinationColorBlendFactor=c,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=d),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(r.blendEquationSeparate(tZ._getGLBlendOperation(t,s),tZ._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;sx.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)},tZ._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}},tZ._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}},tZ),l1=((t1=(t0=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._apply=function(e,t){this._platformApply(e,t.depthState)},t1._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(t0._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(n.depthMask(a),t.writeEnabled=a))},t0._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}},t0),l2=((t3=(t2=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)},t3._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)},t2),l3=((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,u=this.zFailOperationFront,c=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||u!==t.zFailOperationFront||c!==t.passOperationFront)&&(n.stencilOpSeparate(n.FRONT,t4._getGLStencilOperation(e,l),t4._getGLStencilOperation(e,u),t4._getGLStencilOperation(e,c)),t.failOperationFront=l,t.zFailOperationFront=u,t.passOperationFront=c),(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),l4=((t8=function(){this.blendState=new l0,this.depthState=new l1,this.stencilState=new l3,this.rasterState=new l2,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),l5=(sM(t6=function(e,t){var n;return(n=sU.call(this,e)||this)._renderStates=[],n._shaderData=new lK(oE.Material),n.shader=t,n},sU),(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),sO.deepCloneObject(this.renderStates,e.renderStates)},t7._addRefCount=function(e){sU.prototype._addRefCount.call(this,e),this.shaderData._addRefCount(e)},t7._preRender=function(e){},t7._onDestroy=function(){this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},sb(t6,[{key:"shaderData",get:function(){return this._shaderData}},{key:"shader",get:function(){return this._shader},set:function(e){this._shader=e;var t=this._renderStates,n=t.length,r=e.passes.length;if(n<r)for(var i=n;i<r;i++)t.push(new l4);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),t6),l8=((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),l6=function(){},l7=(sM(nt=function(){return l6.apply(this,arguments)},l6),(nn=nt.prototype).setValue=function(e,t,n,r,i,a){this.component=e,this.mesh=t,this.subMesh=n,this.material=r,this.renderState=i,this.shaderPass=a},nn.dispose=function(){this.component=this.mesh=this.subMesh=this.material=this.renderState=this.shaderPass=null},nt),l9=((nr=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(nr._viewMatrixProperty,e.viewMatrix),t.setMatrix(nr._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(nr._vpMatrixProperty,e.viewProjectionMatrix)},nr);l9._vpMatrixProperty=s3.getPropertyByName("u_VPMat"),l9._viewMatrixProperty=s3.getPropertyByName("u_viewMat"),l9._projectionMatrixProperty=s3.getPropertyByName("u_projMat");var ue=(sM(ni=function(){var e;return(e=l6.call(this)||this).multiRenderData=!1,e},l6),(na=ni.prototype).setValue=function(e,t,n,r,i,a){this.component=e,this.renderData=t,this.material=n,this.texture=r,this.renderState=i,this.shaderPass=a},na.dispose=function(){this.component=this.renderData=this.material=this.texture=this.renderState=this.shaderPass=null},ni),ut=(sM(no=function(){var e;return(e=l6.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},l6),(ns=no.prototype).setValue=function(e,t,n){this.component=e,this.renderData=t,this.material=n},ns.dispose=function(){this.component=this.renderData=this.material=null},no);function un(){return function(e){}}e.SpriteMaskInteraction=void 0,(nl=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[nl.None=0]="None",nl[nl.VisibleInsideMask=1]="VisibleInsideMask",nl[nl.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(sM(nu=function(t){(n=lv.call(this,t)||this)._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new sq,n._bounds=new sc,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._shaderData=new lK(oE.Renderer),n._mvMatrix=new sg,n._mvpMatrix=new sg,n._mvInvMatrix=new sg,n._normalMatrix=new sg,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new sy,n.castShadows=!0;var n,r=e.Renderer.prototype,i=n.shaderData;return n._overrideUpdate=n.update!==r.update,i._addRefCount(1),n._onTransformChanged=n._onTransformChanged.bind(sS(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lv),(nc=nu.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},nc.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},nc.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},nc.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},nc.getMaterials=function(){return this._materials},nc.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._addRefCount(-1)}n.length!==t&&(n.length=t),0!==r.length&&(r.length=0);for(var s=0;s<t;s++){var l=n[s],u=e[s];l!==u&&(n[s]=u,l&&l._addRefCount(-1),u&&u._addRefCount(1))}},nc.update=function(e){},nc._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},nc._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},nc._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sl.subtract(i,r,i),this._distanceForSort=sl.dot(i,n.forward)):this._distanceForSort=sl.distanceSquared(i,r),this._updateShaderData(t),this._render(t),sq.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},nc._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},nc._onDestroy=function(){this.entity.transform._updateFlagManager.removeListener(this._onTransformChanged),this.shaderData._addRefCount(-1);for(var e,t=this._materials,n=0,r=t.length;n<r;n++)null==(e=t[n])||e._addRefCount(-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},nc._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)},nc._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;sg.multiply(i.viewMatrix,n,a),sg.multiply(i.viewProjectionMatrix,n,o),sg.invert(a,s),sg.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)},nc._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},nc._updateBounds=function(e){},nc._render=function(e){throw"not implement"},nc._createInstanceMaterial=function(e,t){var n=e.clone();return n.name=n.name+"(Instance)",e._addRefCount(-1),n._addRefCount(1),this._materialsInstanced[t]=!0,this._materials[t]=n,n},nc._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._addRefCount(-1),t&&t._addRefCount(1),n[e]=t}},nc._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},sb(nu,[{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}}]),(oD=nu)._tempVector0=new sl,oD._receiveShadowMacro=s3.getMacroByName("OASIS_RECEIVE_SHADOWS"),oD._localMatrixProperty=s3.getPropertyByName("u_localMat"),oD._worldMatrixProperty=s3.getPropertyByName("u_modelMat"),oD._mvMatrixProperty=s3.getPropertyByName("u_MVMat"),oD._mvpMatrixProperty=s3.getPropertyByName("u_MVPMat"),oD._mvInvMatrixProperty=s3.getPropertyByName("u_MVInvMat"),oD._normalMatrixProperty=s3.getPropertyByName("u_normalMat"),oD._rendererLayerProperty=s3.getPropertyByName("oasis_RendererLayer"),oD),sE([sL],e.Renderer.prototype,"_distanceForSort",void 0),sE([sL],e.Renderer.prototype,"_onUpdateIndex",void 0),sE([sL],e.Renderer.prototype,"_rendererIndex",void 0),sE([sL],e.Renderer.prototype,"_globalShaderMacro",void 0),sE([sI],e.Renderer.prototype,"_bounds",void 0),sE([sL],e.Renderer.prototype,"_renderFrameCount",void 0),sE([sL],e.Renderer.prototype,"_overrideUpdate",void 0),sE([sL],e.Renderer.prototype,"_materials",void 0),sE([sL],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),sE([sI],e.Renderer.prototype,"_shaderData",void 0),sE([sL],e.Renderer.prototype,"_mvMatrix",void 0),sE([sL],e.Renderer.prototype,"_mvpMatrix",void 0),sE([sL],e.Renderer.prototype,"_mvInvMatrix",void 0),sE([sL],e.Renderer.prototype,"_normalMatrix",void 0),sE([sL],e.Renderer.prototype,"_materialsInstanced",void 0),sE([sL],e.Renderer.prototype,"_priority",void 0),sE([sB],e.Renderer.prototype,"_receiveShadows",void 0),sE([sL],e.Renderer.prototype,"_rendererLayer",void 0),sE([sL],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=sE([lg(lx)],e.Renderer),(nh=oI||(oI={}))[nh.WorldVolume=1]="WorldVolume";var ur=((nd=function(){}).resetData=function(e){var t=e._renderData,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 sl),i.push(new sv);t.triangles=ur._rectangleTriangles},nd.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=ur._worldMatrix,l=s.elements,u=e.entity.transform.worldMatrix.elements,c=e.flipX?-t:t,h=e.flipY?-n:n;l[0]=u[0]*c,l[1]=u[1]*c,l[2]=u[2]*c,l[4]=u[4]*h,l[5]=u[5]*h,l[6]=u[6]*h,l[8]=u[8],l[9]=u[9],l[10]=u[10],l[12]=u[12]-a*l[0]-o*l[4],l[13]=u[13]-a*l[1]-o*l[5],l[14]=u[14]-a*l[2]-o*l[6];for(var d=r._getPositions(),_=e._renderData.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])}sc.transform(r._getBounds(),s,e._bounds)},nd.updateUVs=function(e){var t=e.sprite._getUVs(),n=e._renderData.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)},(oO=nd)._rectangleTriangles=[0,1,2,2,1,3],oO._worldMatrix=new sg,oO);ur=sE([un()],ur);var ui=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,(n_=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[n_.Layer0=1]="Layer0",n_[n_.Layer1=2]="Layer1",n_[n_.Layer2=4]="Layer2",n_[n_.Layer3=8]="Layer3",n_[n_.Layer4=16]="Layer4",n_[n_.Layer5=32]="Layer5",n_[n_.Layer6=64]="Layer6",n_[n_.Layer7=128]="Layer7",n_[n_.Layer8=256]="Layer8",n_[n_.Layer9=512]="Layer9",n_[n_.Layer10=1024]="Layer10",n_[n_.Layer11=2048]="Layer11",n_[n_.Layer12=4096]="Layer12",n_[n_.Layer13=8192]="Layer13",n_[n_.Layer14=16384]="Layer14",n_[n_.Layer15=32768]="Layer15",n_[n_.Layer16=65536]="Layer16",n_[n_.Layer17=131072]="Layer17",n_[n_.Layer18=262144]="Layer18",n_[n_.Layer19=524288]="Layer19",n_[n_.Layer20=1048576]="Layer20",n_[n_.Layer21=2097152]="Layer21",n_[n_.Layer22=4194304]="Layer22",n_[n_.Layer23=8388608]="Layer23",n_[n_.Layer24=16777216]="Layer24",n_[n_.Layer25=33554432]="Layer25",n_[n_.Layer26=67108864]="Layer26",n_[n_.Layer27=134217728]="Layer27",n_[n_.Layer28=268435456]="Layer28",n_[n_.Layer29=536870912]="Layer29",n_[n_.Layer30=1073741824]="Layer30",n_[n_.Layer31=2147483648]="Layer31",n_[n_.Everything=4294967295]="Everything",(nf=oV||(oV={}))[nf.texture=1]="texture",nf[nf.size=2]="size",nf[nf.atlasRotate=4]="atlasRotate",nf[nf.atlasRegion=8]="atlasRegion",nf[nf.atlasRegionOffset=16]="atlasRegionOffset",nf[nf.region=32]="region",nf[nf.pivot=64]="pivot",nf[nf.border=128]="border";var ua=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._renderData=new ui(4,[],[]),ur.resetData(sS(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(sS(i)),i}sM(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?ur.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&oI.WorldVolume&&(ur.updatePositions(this),this._dirtyUpdateFlag&=~oI.WorldVolume),2&this._dirtyUpdateFlag&&(ur.updateUVs(this),this._dirtyUpdateFlag&=-3);var t,n=this._engine._spriteMaskElementPool.getFromPool();n.setValue(this,this._renderData,this.getMaterial()),e.camera._renderPipeline._allSpriteMasks.add(this),this._maskElement=n}},r._onDestroy=function(){t.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addRefCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._sprite=null,this._renderData=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 oV.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case oV.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=oI.WorldVolume);break;case oV.region:case oV.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oV.atlasRegion:this._dirtyUpdateFlag|=2;break;case oV.pivot:this._dirtyUpdateFlag|=oI.WorldVolume}},sb(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|=oI.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|=oI.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oI.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oI.WorldVolume)}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addRefCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addRefCount(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);ua._textureProperty=s3.getPropertyByName("u_maskTexture"),ua._alphaCutoffProperty=s3.getPropertyByName("u_maskAlphaCutoff"),sE([sB],ua.prototype,"influenceLayers",void 0),sE([sL],ua.prototype,"_sprite",void 0),sE([sL],ua.prototype,"_automaticWidth",void 0),sE([sL],ua.prototype,"_automaticHeight",void 0),sE([sB],ua.prototype,"_customWidth",void 0),sE([sB],ua.prototype,"_customHeight",void 0),sE([sB],ua.prototype,"_flipX",void 0),sE([sB],ua.prototype,"_flipY",void 0),sE([sB],ua.prototype,"_alphaCutoff",void 0),sE([sL],ua.prototype,"_onSpriteChange",null),(np=oU||(oU={}))[np.UV=2]="UV",np[np.RenderData=3]="RenderData",np[np.AutomaticSize=4]="AutomaticSize",np[np.All=7]="All",e.VertexElementFormat=void 0,(ng=e.VertexElementFormat||(e.VertexElementFormat={}))[ng.Float=0]="Float",ng[ng.Vector2=1]="Vector2",ng[ng.Vector3=2]="Vector3",ng[ng.Vector4=3]="Vector4",ng[ng.Byte4=4]="Byte4",ng[ng.UByte4=5]="UByte4",ng[ng.NormalizedByte4=6]="NormalizedByte4",ng[ng.NormalizedUByte4=7]="NormalizedUByte4",ng[ng.Short2=8]="Short2",ng[ng.UShort2=9]="UShort2",ng[ng.NormalizedShort2=10]="NormalizedShort2",ng[ng.NormalizedUShort2=11]="NormalizedUShort2",ng[ng.Short4=12]="Short4",ng[ng.UShort4=13]="UShort4",ng[ng.NormalizedShort4=14]="NormalizedShort4",ng[ng.NormalizedUShort4=15]="NormalizedUShort4",e.BufferUsage=void 0,(nm=e.BufferUsage||(e.BufferUsage={}))[nm.Static=0]="Static",nm[nm.Dynamic=1]="Dynamic",nm[nm.Stream=2]="Stream",e.IndexFormat=void 0,(nv=e.IndexFormat||(e.IndexFormat={}))[nv.UInt8=0]="UInt8",nv[nv.UInt16=1]="UInt16",nv[nv.UInt32=2]="UInt32";var uo=((ny=function(){})._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}},ny._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}},ny._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},ny._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}},ny),us=(sb(nx=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=uo._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}}]),nx);e.BufferBindFlag=void 0,(nT=e.BufferBindFlag||(e.BufferBindFlag={}))[nT.VertexBuffer=0]="VertexBuffer",nT[nT.IndexBuffer=1]="IndexBuffer",e.SetDataOptions=void 0,(nC=e.SetDataOptions||(e.SetDataOptions={}))[nC.None=0]="None",nC[nC.Discard=1]="Discard";var ul=(sM(nS=function(t,n,r,i){void 0===i&&(i=e.BufferUsage.Static),(a=sU.call(this,t)||this)._engine=t,a._type=n,a._bufferUsage=i;var a,o=t._hardwareRenderer,s=o.gl,l=uo._getGLBufferUsage(s,i),u=n===e.BufferBindFlag.VertexBuffer?s.ARRAY_BUFFER:s.ELEMENT_ARRAY_BUFFER;return a._nativeBuffer=s.createBuffer(),a._hardwareRenderer=o,a._glBufferUsage=l,a._glBindTarget=u,a.bind(),"number"==typeof r?(a._byteLength=r,s.bufferData(u,r,l)):(a._byteLength=r.byteLength,s.bufferData(u,r,l)),s.bindBuffer(u,null),a},sU),(nw=nS.prototype).bind=function(){this._hardwareRenderer.gl.bindBuffer(this._glBindTarget,this._nativeBuffer)},nw.setData=function(t,n,r,i,a){void 0===n&&(n=0),void 0===r&&(r=0),void 0===a&&(a=e.SetDataOptions.None);var o=this._hardwareRenderer.gl,s=this._hardwareRenderer.isWebGL2,l=this._glBindTarget;this.bind(),a===e.SetDataOptions.Discard&&o.bufferData(l,this._byteLength,this._glBufferUsage);var u=t.BYTES_PER_ELEMENT||1,c=i?u*i:t.byteLength;if(0!==r||c<t.byteLength){var h=void 0!==t.byteOffset;if(s&&h)o.bufferSubData(l,n,t,r,c/u);else{var d=new Uint8Array(h?t.buffer:t,r*u,c);o.bufferSubData(l,n,d)}}else o.bufferSubData(l,n,t);o.bindBuffer(l,null)},nw.getData=function(e,t,n,r){if(void 0===t&&(t=0),void 0===n&&(n=0),this._hardwareRenderer.isWebGL2){var i=this._hardwareRenderer.gl;this.bind(),i.getBufferSubData(this._glBindTarget,t,e,n,r)}else throw"Buffer is write-only on WebGL1.0 platforms."},nw._onDestroy=function(){this._hardwareRenderer.gl.deleteBuffer(this._nativeBuffer),this._nativeBuffer=null,this._hardwareRenderer=null},nw.resize=function(e){this.bind(),this._hardwareRenderer.gl.bufferData(this._glBindTarget,e,this._glBufferUsage),this._byteLength=e},sb(nS,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),nS);e.MeshTopology=void 0,(nb=e.MeshTopology||(e.MeshTopology={}))[nb.Points=0]="Points",nb[nb.Lines=1]="Lines",nb[nb.LineLoop=2]="LineLoop",nb[nb.LineStrip=3]="LineStrip",nb[nb.Triangles=4]="Triangles",nb[nb.TriangleStrip=5]="TriangleStrip",nb[nb.TriangleFan=6]="TriangleFan";var uu=(sb(nA=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),nA),uc=((nM=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(){},nM),uh=(sM(nF=function(e,t){(n=sU.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new ly,n._bounds=new sc,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(sS(n)),n._onBoundsChanged=n._onBoundsChanged.bind(sS(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},sU),(nP=nF.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new uc(t,n,r)),this._subMeshes.push(t),t},nP.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},nP.clearSubMesh=function(){this._subMeshes.length=0},nP._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},nP._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},nP._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},nP._setVertexBufferBinding=function(e,t){var n,r=this._getRefCount();r>0&&(null==(n=this._vertexBufferBindings[e])||n._buffer._addRefCount(-r),null==t||t._buffer._addRefCount(r)),this._vertexBufferBindings[e]=t,this._bufferStructChanged=!0},nP._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},nP._addRefCount=function(e){sU.prototype._addRefCount.call(this,e);for(var t,n=this._vertexBufferBindings,r=0,i=n.length;r<i;r++)n[r]._buffer._addRefCount(e);null==(t=this._indexBufferBinding)||t._buffer._addRefCount(e)},nP._onDestroy=function(){this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._updateFlagManager=null,this._platformPrimitive.destroy()},nP._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},nP._setIndexBufferBinding=function(e){var t=this._indexBufferBinding,n=this._getRefCount();n>0&&(null==t||t.buffer._addRefCount(-n),null==e||e.buffer._addRefCount(n)),e?(this._indexBufferBinding=e,this._glIndexType=uo._getGLIndexType(e.format),this._glIndexByteCount=uo._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},nP._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},sb(nF,[{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}}]),nF);(nE=oz||(oz={}))[nE.Bounds=1]="Bounds",nE[nE.VertexElements=2]="VertexElements";var ud=(sb(nR=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),nR),u_=((nB=(nL=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 sl(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sl,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._createSubDataDirtyFlag())},nB._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},nB._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(nL._blendShapeMacro),this._useTextureMode())e.enableMacro(nL._blendShapeTextureMacro),e.setTexture(nL._blendShapeTextureProperty,this._vertexTexture),e.setVector3(nL._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(nL._blendShapeWeightsProperty,t.blendShapeWeights),e.enableMacro("OASIS_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(nL._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(nL._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(nL._blendShapeTextureMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(nL._blendShapeNormalMacro):e.disableMacro(nL._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(nL._blendShapeTangentMacro):e.disableMacro(nL._blendShapeTangentMacro)}else e.disableMacro(nL._blendShapeMacro),e.disableMacro("OASIS_BLENDSHAPE_COUNT")},nB._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},nB._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},nB._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},nB._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},nB._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},nB._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 us("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new us("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new us("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},nB._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))},nB._releaseMemoryCache=function(){for(var e=this._blendShapes,t=e.length,n=Array(t),r=0;r<t;r++)n[r]=e[r].name;this._blendShapeNames=n;for(var i=0,a=e.length;i<a;i++)e[i]._layoutChangeManager.removeListener(this._updateLayoutChange);for(var o=this._subDataDirtyFlags,s=0,l=o.length;s<l;s++)o[s].destroy();this._subDataDirtyFlags=null,this._blendShapes=null,this._vertices=null},nB._createVertexBuffers=function(t,n){var r=this._engine,i=this._modelMesh,a=this._blendShapeCount,o=this._vertexBuffers,s=3*this._vertexElementCount,l=4*s,u=Math.floor(255/l),c=Math.ceil(a/u);o.length=c,this._vertices=new Float32Array(s*t*Math.min(u,a)),this._maxCountSingleVertexBuffer=u,this._storeInVertexBufferInfo.length=a;for(var h=this._bufferBindingOffset,d=0;d<c;d++){var _=c-1,f=(d===_?a-_*u:u)*l,p=f*t,g=n?e.BufferUsage.Static:e.BufferUsage.Dynamic,m=new ul(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new ud(m,f)),o[d]=m}},nB._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 lt(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)},nB._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,u=4*l,c=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 sv),C.set(c+m,v*u);for(var S=g.deltaPositions,w=0;w<e;w++){var b=T+x*w,A=S[w];A&&(i[b]=A.x,i[b+1]=A.y,i[b+2]=A.z)}if(T+=3,this._useBlendNormal){var M=g.deltaNormals;if(M)for(var F=0;F<e;F++){var P=T+x*F,E=M[F];E&&(i[P]=E.x,i[P+1]=E.y,i[P+2]=E.z)}T+=3}if(this._useBlendTangent){var R=g.deltaTangents;if(R)for(var L=0;L<e;L++){var B=T+x*L,D=R[L];D&&(i[B]=D.x,i[B+1]=D.y,i[B+2]=D.z)}T+=3}(v===r-1||h===d-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},nB._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],u=r.width*r.height*4;if(t||l.flag){var c=n[o].frames,h=c.length,d=c[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*u,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)},nB._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},nB._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 u=e[++i];s+=12,u.bindingIndex=o,u.offset=s}if(this._useBlendTangent){var c=e[++i];s+=12,c.bindingIndex=o,c.offset=s}},nB._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},nB._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 u=e[s];if(s<r)this._attributeModeUpdateVertexElement(i,a,s,s),t[s]=u,u<o&&(o=u,n=s);else if(u>o){this._attributeModeUpdateVertexElement(i,a,s,n),t[n]=u,o=Number.POSITIVE_INFINITY;for(var c=0;c<r;c++){var h=t[c];h<o&&(o=h,n=c)}}}},nL);u_._blendShapeMacro=s3.getMacroByName("OASIS_BLENDSHAPE"),u_._blendShapeTextureMacro=s3.getMacroByName("OASIS_BLENDSHAPE_TEXTURE"),u_._blendShapeNormalMacro=s3.getMacroByName("OASIS_BLENDSHAPE_NORMAL"),u_._blendShapeTangentMacro=s3.getMacroByName("OASIS_BLENDSHAPE_TANGENT"),u_._blendShapeWeightsProperty=s3.getPropertyByName("u_blendShapeWeights"),u_._blendShapeTextureProperty=s3.getPropertyByName("u_blendShapeTexture"),u_._blendShapeTextureInfoProperty=s3.getPropertyByName("u_blendShapeTextureInfo"),(nD=oN||(oN={})).Position="POSITION",nD.Normal="NORMAL",nD.Color="COLOR_0",nD.Tangent="TANGENT",nD.BoneWeight="WEIGHTS_0",nD.BoneIndex="JOINTS_0",nD.UV="TEXCOORD_0",nD.UV1="TEXCOORD_1",nD.UV2="TEXCOORD_2",nD.UV3="TEXCOORD_3",nD.UV4="TEXCOORD_4",nD.UV5="TEXCOORD_5",nD.UV6="TEXCOORD_6",nD.UV7="TEXCOORD_7";var uf=(sM(nI=function(e,t){var n;return(n=uh.call(this,e)||this)._vertexCount=0,n._accessible=!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 u_(e,sS(n)),n},uh),(nO=nI.prototype).setPositions=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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}},nO.getPositions=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._positions},nO.setNormals=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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},nO.getNormals=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._normals},nO.setColors=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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},nO.getColors=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._colors},nO.setBoneWeights=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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},nO.getBoneWeights=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneWeights},nO.setBoneIndices=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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},nO.getBoneIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._boneIndices},nO.setTangents=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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},nO.getTangents=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._tangents},nO.setUVs=function(e,t){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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]."}},nO.getUVs=function(e){if(!this._accessible)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]."},nO.setIndices=function(t){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._indices!==t&&(this._indices=t,sR(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:sR(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:sR(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},nO.getIndices=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._indices},nO.setVertexElements=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";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[oN.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[oN.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[oN.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[oN.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[oN.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[oN.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[oN.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[oN.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[oN.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[oN.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[oN.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[oN.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[oN.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[oN.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},nO.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 ud(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},nO.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])},nO.addBlendShape=function(e){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._addBlendShape(e)},nO.clearBlendShapes=function(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._blendShapeManager._clearBlendShapes()},nO.getBlendShapeName=function(e){return this._accessible?this._blendShapeManager._blendShapes[e].name:this._blendShapeManager._blendShapeNames[e]},nO.uploadData=function(t){if(!this._accessible)throw"Not allowed to access data while accessible is false.";this._updateVertexElements();var n,r,i=null==(n=this._vertexBufferBindings[0])?void 0:n._buffer;if(this._vertexCountChanged){this._vertexBufferUpdateFlag=65535,null==i||i.destroy();var a=this._bufferStrides[0]/4,o=a*this.vertexCount,s=new Float32Array(o);this._verticesFloat32=s,this._verticesUint8=new Uint8Array(s.buffer),this._updateVertices(s);var l=t?e.BufferUsage.Static:e.BufferUsage.Dynamic,u=new ul(this._engine,e.BufferBindFlag.VertexBuffer,s,l);this._setVertexBufferBinding(0,new ud(u,4*a)),this._vertexCountChanged=!1}else if(65535&this._vertexBufferUpdateFlag){var c=this._verticesFloat32;this._updateVertices(c),i.setData(c)}var h=this._indices,d=null==(r=this._indexBufferBinding)?void 0:r._buffer;if(h){if(d&&h.byteLength==d.byteLength)this._indicesChangeFlag&&(d.setData(h),this._indexBufferBinding._format!==this._indicesFormat&&this._setIndexBufferBinding(new uu(d,this._indicesFormat)),this._indicesChangeFlag=!1);else{null==d||d.destroy();var _=new ul(this._engine,e.BufferBindFlag.IndexBuffer,h);this._setIndexBufferBinding(new uu(_,this._indicesFormat)),this._indicesChangeFlag=!1}}else d&&(d.destroy(),this._setIndexBufferBinding(null));var f=this._blendShapeManager;f._blendShapeCount>0&&f._update(this._vertexCountChanged,t),t&&(this._accessible=!1,this._releaseCache())},nO.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=nI._tempVec0,o=nI._tempVec1,s=nI._tempVec2,l=nI._tempVec3,u=nI._tempVec4,c=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new sy,d[_]=new sl;for(var f=0;f<c;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];sl.subtract(y,v,a),sl.subtract(x,v,o);var w=C.x-T.x,b=S.x-T.x,A=C.y-T.y,M=S.y-T.y,F=1/(w*M-b*A);sl.scale(a,M*F,s),sl.scale(o,A*F,u),sl.subtract(s,u,s),sl.scale(o,w*F,l),sl.scale(a,b*F,u),sl.subtract(l,u,l);var P=h[p];P.set(P.x+s.x,P.y+s.y,P.z+s.z,1),(P=h[g]).set(P.x+s.x,P.y+s.y,P.z+s.z,1),(P=h[m]).set(P.x+s.x,P.y+s.y,P.z+s.z,1),d[p].add(l),d[g].add(l),d[m].add(l)}for(var E=0;E<i;E++){var R=n[E],L=d[E],B=h[E];s.set(B.x,B.y,B.z),sl.cross(s,L,u);var D=sl.dot(u,R)>0?1:-1;sl.scale(R,sl.dot(s,R),u),sl.subtract(s,u,s),s.normalize(),B.set(s.x,s.y,s.z,D)}this.setTangents(h)},nO._onDestroy=function(){uh.prototype._onDestroy.call(this),this._accessible&&this._releaseCache()},nO._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[oN.Position]&&this._insertVertexAttribute(oN.Position),this._normals&&!r[oN.Normal]&&this._insertVertexAttribute(oN.Normal),this._colors&&!r[oN.Color]&&this._insertVertexAttribute(oN.Color),this._boneWeights&&!r[oN.BoneWeight]&&this._insertVertexAttribute(oN.BoneWeight),this._boneIndices&&!r[oN.BoneIndex]&&this._insertVertexAttribute(oN.BoneIndex),this._tangents&&!r[oN.Tangent]&&this._insertVertexAttribute(oN.Tangent),this._uv&&!r[oN.UV]&&this._insertVertexAttribute(oN.UV),this._uv1&&!r[oN.UV1]&&this._insertVertexAttribute(oN.UV1),this._uv2&&!r[oN.UV2]&&this._insertVertexAttribute(oN.UV2),this._uv3&&!r[oN.UV3]&&this._insertVertexAttribute(oN.UV3),this._uv4&&!r[oN.UV4]&&this._insertVertexAttribute(oN.UV4),this._uv5&&!r[oN.UV5]&&this._insertVertexAttribute(oN.UV5),this._uv6&&!r[oN.UV6]&&this._insertVertexAttribute(oN.UV6),this._uv7&&!r[oN.UV7]&&this._insertVertexAttribute(oN.UV7)},nO._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)},nO._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,u=this._tangents,c=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,b=i[S];b&&(e[w]=b.x,e[w+1]=b.y,e[w+2]=b.z)}C+=3}if(a){if(4&o)for(var A=0;A<n;A++){var M=v*A+C,F=a[A];F&&(e[M]=F.r,e[M+1]=F.g,e[M+2]=F.b,e[M+3]=F.a)}C+=4}if(s){if(16&o)for(var P=0;P<n;P++){var E=v*P+C,R=s[P];R&&(e[E]=R.x,e[E+1]=R.y,e[E+2]=R.z,e[E+3]=R.w)}C+=4}if(l){if(32&o)for(var L=this._verticesUint8,B=0;B<n;B++){var D=v*B+C,I=l[B];if(I){var O=4*D;L[O]=I.x,L[O+1]=I.y,L[O+2]=I.z,L[O+3]=I.w}}C+=1}if(u){if(8&o)for(var V=0;V<n;V++){var U=v*V+C,z=u[V];z&&(e[U]=z.x,e[U+1]=z.y,e[U+2]=z.z,e[U+3]=z.w)}C+=4}if(c){if(64&o)for(var N=0;N<n;N++){var k=v*N+C,G=c[N];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 j=0;j<n;j++){var K=v*j+C,q=d[j];q&&(e[K]=q.x,e[K+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,eu=m[es];eu&&(e[el]=eu.x,e[el+1]=eu.y)}C+=2}this._vertexBufferUpdateFlag=0},nO._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 us(e,a,t,0)),this._bufferStrides[0]=a+n},nO._getAttributeFormat=function(t){switch(t){case oN.Position:case oN.Normal:return e.VertexElementFormat.Vector3;case oN.Color:case oN.BoneWeight:return e.VertexElementFormat.Vector4;case oN.BoneIndex:return e.VertexElementFormat.UByte4;case oN.Tangent:return e.VertexElementFormat.Vector4;case oN.UV:case oN.UV1:case oN.UV2:case oN.UV3:case oN.UV4:case oN.UV5:case oN.UV6:case oN.UV7:return e.VertexElementFormat.Vector2}},nO._getAttributeByteLength=function(e){switch(e){case oN.Position:case oN.Normal:return 12;case oN.Color:case oN.BoneWeight:return 16;case oN.BoneIndex:return 4;case oN.Tangent:return 16;case oN.UV:case oN.UV1:case oN.UV2:case oN.UV3:case oN.UV4:case oN.UV5:case oN.UV6:case oN.UV7:return 8}},nO._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()},sb(nI,[{key:"accessible",get:function(){return this._accessible}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[oN.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(){if(!this._accessible)throw"Not allowed to access data while accessible is false.";return this._blendShapeManager._blendShapes}},{key:"blendShapeCount",get:function(){return this._blendShapeManager._blendShapeCount}}]),nI);uf._tempVec0=new sl,uf._tempVec1=new sl,uf._tempVec2=new sl,uf._tempVec3=new sl,uf._tempVec4=new sl,(nV=ok||(ok={}))[nV.Position=1]="Position",nV[nV.Normal=2]="Normal",nV[nV.Color=4]="Color",nV[nV.Tangent=8]="Tangent",nV[nV.BoneWeight=16]="BoneWeight",nV[nV.BoneIndex=32]="BoneIndex",nV[nV.UV=64]="UV",nV[nV.UV1=128]="UV1",nV[nV.UV2=256]="UV2",nV[nV.UV3=512]="UV3",nV[nV.UV4=1024]="UV4",nV[nV.UV5=2048]="UV5",nV[nV.UV6=4096]="UV6",nV[nV.UV7=8192]="UV7",nV[nV.All=65535]="All";var up=(sM(nU=function(e){var t;return(t=sV.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},sV),nU),ug=(nz=e.Renderer,sM(nN=function(e){var t;return(t=nz.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(sS(t)),t},nz),(nk=nN.prototype)._onDestroy=function(){nz.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addRefCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},nk._cloneTo=function(e){nz.prototype._cloneTo.call(this,e),e.mesh=this._mesh},nk._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sc.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},nk._render=function(e){var t=this._mesh;if(t){if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(nN._uvMacro),n.disableMacro(nN._uv1Macro),n.disableMacro(nN._normalMacro),n.disableMacro(nN._tangentMacro),n.disableMacro(nN._vertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(nN._uvMacro);break;case"TEXCOORD_1":n.enableMacro(nN._uv1Macro);break;case"NORMAL":n.enableMacro(nN._normalMacro);break;case"TANGENT":n.enableMacro(nN._tangentMacro);break;case"COLOR_0":this.enableVertexColor&&n.enableMacro(nN._vertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=t.subMeshes,s=e.camera._renderPipeline,l=this._engine._renderElementPool,u=0,c=o.length;u<c;u++){var h=this._materials[u];if(h)for(var d=h.renderStates,_=h.shader.passes,f=0,p=_.length;f<p;f++){var g=l.getFromPool();g.setValue(this,t,o[u],h,d[f],_[f]),s.pushPrimitive(g)}}}else sj.error("mesh is null.")},nk._setMesh=function(e){var t=this._mesh;t&&(t._addRefCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addRefCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},nk._onMeshChanged=function(e){e&oz.Bounds&&(this._dirtyUpdateFlag|=oI.WorldVolume),e&oz.VertexElements&&(this._dirtyUpdateFlag|=2)},sb(nN,[{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)}}]),nN);ug._uvMacro=s3.getMacroByName("O3_HAS_UV"),ug._uv1Macro=s3.getMacroByName("O3_HAS_UV1"),ug._normalMacro=s3.getMacroByName("O3_HAS_NORMAL"),ug._tangentMacro=s3.getMacroByName("O3_HAS_TANGENT"),ug._vertexColorMacro=s3.getMacroByName("O3_HAS_VERTEXCOLOR"),sE([sL],ug.prototype,"_mesh",void 0),sE([sL],ug.prototype,"_onMeshChanged",null),(nG=oG||(oG={}))[nG.VertexElementMacro=2]="VertexElementMacro",nG[nG.All=3]="All";var um=((nH=function(){})._floatMatrixMultiply=function(e,t,n,r,i){var a=e.elements,o=a[0],s=a[1],l=a[2],u=a[3],c=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],b=t[n+3],A=t[n+4],M=t[n+5],F=t[n+6],P=t[n+7],E=t[n+8],R=t[n+9],L=t[n+10],B=t[n+11],D=t[n+12],I=t[n+13],O=t[n+14],V=t[n+15];r[i]=o*C+c*S+f*w+v*b,r[i+1]=s*C+h*S+p*w+y*b,r[i+2]=l*C+d*S+g*w+x*b,r[i+3]=u*C+_*S+m*w+T*b,r[i+4]=o*A+c*M+f*F+v*P,r[i+5]=s*A+h*M+p*F+y*P,r[i+6]=l*A+d*M+g*F+x*P,r[i+7]=u*A+_*M+m*F+T*P,r[i+8]=o*E+c*R+f*L+v*B,r[i+9]=s*E+h*R+p*L+y*B,r[i+10]=l*E+d*R+g*L+x*B,r[i+11]=u*E+_*R+m*L+T*B,r[i+12]=o*D+c*I+f*O+v*V,r[i+13]=s*D+h*I+p*O+y*V,r[i+14]=l*D+d*I+g*O+x*V,r[i+15]=u*D+_*I+m*O+T*V},nH._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},nH._stringToPath=function(e){var t=[];return e.charCodeAt(0)===uv&&t.push(""),e.replace(ux,function(e,n,r,i){var a=e;r?a=i.replace(uy,"$1"):n&&(a=n.trim()),t.push(a)}),t},nH),uv=46,uy=/\\(\\)?/g,ux=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),uT=(sM(nW=function(e){(t=ug.call(this,e)||this)._supportSkinning=!1,t._hasInitSkin=!1,t._jointDataCreateCache=new sv(-1,-1),t._localBounds=new sc,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(sS(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},ug),(nX=nW.prototype).update=function(){if(this._hasInitSkin||(this._initSkin(),this._hasInitSkin=!0),this._supportSkinning)for(var e=this._skin.inverseBindMatrices,t=this._rootBone.getInvModelMatrix(),n=this._jointEntities,r=this._jointMatrices,i=n.length-1;i>=0;i--){var a=n[i],o=16*i;a?um._floatMatrixMultiply(a.transform.worldMatrix,e[i].elements,0,r,o):r.set(e[i].elements,o),um._floatMatrixMultiply(t,r,o,r,o)}},nX._updateShaderData=function(t){var n=this.entity,r=this.shaderData,i=this.mesh._blendShapeManager;i._updateShaderData(r,this);var a=this._skin;if(a){var o=i._uniformOccupiesCount,s=a.joints.length,l=this._jointDataCreateCache,u=s!==l.x;if(u||o!==l.y){var c,h=Math.ceil((this._maxVertexUniformVectors-(44+o))/4);if(s>h){var d,_,f=this.engine;f._hardwareRenderer.canIUseMoreJoints?(u&&(null==(d=this._jointTexture)||d.destroy(),this._jointTexture=new le(f,4,s,e.TextureFormat.R32G32B32A32,!1),this._jointTexture.filterMode=e.TextureFilterMode.Point,this._jointTexture.isGCIgnored=!0),r.disableMacro("O3_JOINTS_NUM"),r.enableMacro("O3_USE_JOINT_TEXTURE"),r.setTexture(nW._jointSamplerProperty,this._jointTexture),this._supportSkinning=!0):(this._supportSkinning=!1,null==(_=this._jointTexture)||_.destroy(),r.disableMacro("O3_HAS_SKIN"),sj.warn("component's joints count("+s+") greater than device's MAX_VERTEX_UNIFORM_VECTORS number "+this._maxVertexUniformVectors+", and don't support jointTexture in this device. suggest joint count less than "+h+".",this))}else this._supportSkinning=!0,null==(c=this._jointTexture)||c.destroy(),r.disableMacro("O3_USE_JOINT_TEXTURE"),r.enableMacro("O3_JOINTS_NUM",h.toString()),r.setFloatArray(nW._jointMatrixProperty,this._jointMatrices);l.set(s,o)}this._jointTexture&&this._jointTexture.setPixelBuffer(this._jointMatrices)}var p=this._supportSkinning&&this._rootBone?this._rootBone.transform.worldMatrix:n.transform.worldMatrix;this._updateTransformShaderData(t,p);var g=n.layer;this._rendererLayer.set(65535&g,g>>>16&65535,0,0)},nX._onDestroy=function(){var e,t;ug.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)},nX._cloneTo=function(e){ug.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},nX._registerEntityTransformListener=function(){},nX._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sc.transform(t,n,e)}else ug.prototype._updateBounds.call(this,e)},nX._initSkin=function(){if(this.entity.engine._hardwareRenderer){var e=this._skin,t=this.shaderData;if(!e){t.disableMacro("O3_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)sc.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var u=new sg(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),c=this._computeApproximateBindMatrix(i,e.inverseBindMatrices,s,u);0!==c?(sg.multiplyScalar(u,1/c,u),sc.transform(this._mesh.bounds,u,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("O3_HAS_SKIN"),t.setInt(nW._jointCountProperty,r)):t.disableMacro("O3_HAS_SKIN")}},nX._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],u=e.indexOf(l);-1!==u?(sg.add(r,t[u],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},nX._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},nX._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)},nX._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=oI.WorldVolume},sb(nW,[{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|=oI.WorldVolume}}]),nW);uT._tempMatrix=new sg,uT._jointCountProperty=s3.getPropertyByName("u_jointCount"),uT._jointSamplerProperty=s3.getPropertyByName("u_jointSampler"),uT._jointMatrixProperty=s3.getPropertyByName("u_jointMatrix"),sE([sL],uT.prototype,"_supportSkinning",void 0),sE([sL],uT.prototype,"_hasInitSkin",void 0),sE([sL],uT.prototype,"_jointDataCreateCache",void 0),sE([sL],uT.prototype,"_blendShapeWeights",void 0),sE([sL],uT.prototype,"_maxVertexUniformVectors",void 0),sE([sL],uT.prototype,"_rootBone",void 0),sE([sL],uT.prototype,"_localBounds",void 0),sE([sL],uT.prototype,"_jointMatrices",void 0),sE([sL],uT.prototype,"_jointTexture",void 0),sE([sL],uT.prototype,"_jointEntities",void 0),sE([sL],uT.prototype,"_condensedBlendShapeWeights",void 0),sE([sL],uT.prototype,"_onLocalBoundsChanged",null);var uC=((nj=function(){}).createSphere=function(e,t,n,r){void 0===t&&(t=.5),void 0===n&&(n=18),void 0===r&&(r=!0);for(var i=new uf(e),a=(n=Math.max(2,Math.floor(n)))+1,o=a*a,s=n*n,l=nj._generateIndices(e,o,6*s),u=Math.PI,c=2*u,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*c,x=v*u,T=Math.sin(x),C=-t*Math.cos(y)*T,S=t*Math.cos(x),w=t*Math.sin(y)*T;_[g]=new sl(C,S,w),f[g]=new sl(C,S,w),p[g]=new sv(m,v)}for(var b=0,A=0;A<s;++A){var M=A%n,F=(A*d|0)*a+M,P=F+1,E=F+a,R=E+1;l[b++]=P,l[b++]=F,l[b++]=R,l[b++]=F,l[b++]=E,l[b++]=R}var L=i.bounds;return L.min.set(-t,-t,-t),L.max.set(t,t,t),nj._initialize(i,_,f,p,l,r),i},nj.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 uf(e),o=t/2,s=n/2,l=r/2,u=Array(24),c=Array(24),h=Array(24);u[0]=new sl(-o,s,-l),u[1]=new sl(o,s,-l),u[2]=new sl(o,s,l),u[3]=new sl(-o,s,l),c[0]=new sl(0,1,0),c[1]=new sl(0,1,0),c[2]=new sl(0,1,0),c[3]=new sl(0,1,0),h[0]=new sv(0,0),h[1]=new sv(1,0),h[2]=new sv(1,1),h[3]=new sv(0,1),u[4]=new sl(-o,-s,-l),u[5]=new sl(o,-s,-l),u[6]=new sl(o,-s,l),u[7]=new sl(-o,-s,l),c[4]=new sl(0,-1,0),c[5]=new sl(0,-1,0),c[6]=new sl(0,-1,0),c[7]=new sl(0,-1,0),h[4]=new sv(0,1),h[5]=new sv(1,1),h[6]=new sv(1,0),h[7]=new sv(0,0),u[8]=new sl(-o,s,-l),u[9]=new sl(-o,s,l),u[10]=new sl(-o,-s,l),u[11]=new sl(-o,-s,-l),c[8]=new sl(-1,0,0),c[9]=new sl(-1,0,0),c[10]=new sl(-1,0,0),c[11]=new sl(-1,0,0),h[8]=new sv(0,0),h[9]=new sv(1,0),h[10]=new sv(1,1),h[11]=new sv(0,1),u[12]=new sl(o,s,-l),u[13]=new sl(o,s,l),u[14]=new sl(o,-s,l),u[15]=new sl(o,-s,-l),c[12]=new sl(1,0,0),c[13]=new sl(1,0,0),c[14]=new sl(1,0,0),c[15]=new sl(1,0,0),h[12]=new sv(1,0),h[13]=new sv(0,0),h[14]=new sv(0,1),h[15]=new sv(1,1),u[16]=new sl(-o,s,l),u[17]=new sl(o,s,l),u[18]=new sl(o,-s,l),u[19]=new sl(-o,-s,l),c[16]=new sl(0,0,1),c[17]=new sl(0,0,1),c[18]=new sl(0,0,1),c[19]=new sl(0,0,1),h[16]=new sv(0,0),h[17]=new sv(1,0),h[18]=new sv(1,1),h[19]=new sv(0,1),u[20]=new sl(-o,s,-l),u[21]=new sl(o,s,-l),u[22]=new sl(o,-s,-l),u[23]=new sl(-o,-s,-l),c[20]=new sl(0,0,-1),c[21]=new sl(0,0,-1),c[22]=new sl(0,0,-1),c[23]=new sl(0,0,-1),h[20]=new sv(1,0),h[21]=new sv(0,0),h[22]=new sv(0,1),h[23]=new sv(1,1);var d=new Uint16Array(36);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;var _=a.bounds;return _.min.set(-o,-s,-l),_.max.set(o,s,l),nj._initialize(a,u,c,h,d,i),a},nj.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);for(var o=new uf(e),s=(r=Math.max(1,Math.floor(r)))+1,l=(i=Math.max(1,Math.floor(i)))+1,u=t/2,c=n/2,h=t/r,d=n/i,_=s*l,f=i*r,p=nj._generateIndices(e,_,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 sl(S*h-u,0,w*d-c),x[C]=new sl(0,1,0),T[C]=new sv(S*m,w*v)}for(var b=0,A=0;A<f;++A){var M=A%r,F=(A*m|0)*s+M,P=F+1,E=F+s,R=E+1;p[b++]=F,p[b++]=E,p[b++]=P,p[b++]=E,p[b++]=R,p[b++]=P}var L=o.bounds;return L.min.set(-u,0,-c),L.max.set(u,0,c),nj._initialize(o,y,x,T,p,a),o},nj.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);for(var s=new uf(e),l=(i=Math.floor(i))+1,u=(a=Math.floor(a))+1,c=.5*r,h=r/a,d=l*u,_=i*a,f=2*i,p=d+2+f,g=nj._generateIndices(e,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,b=2*Math.PI,A=n-t,M=A/r,F=A/a,P=0;P<d;++P){var E=P%l,R=P*m|0,L=E*v,B=R*y,D=w+L*b,I=Math.sin(D),O=Math.cos(D),V=n-R*F,U=V*I,z=R*h-c,N=V*O;x[P]=new sl(U,z,N),T[P]=new sl(I,M,O),C[P]=new sv(L,1-B)}for(var k=0;k<_;++k){var G=k%i,H=(k*v|0)*l+G,W=H+1,X=H+l,j=X+1;g[S++]=W,g[S++]=X,g[S++]=H,g[S++]=W,g[S++]=j,g[S++]=X}x[d]=new sl(0,-c,0),T[d]=new sl(0,-1,0),C[d]=new sv(.5,.5),x[d+1]=new sl(0,c,0),T[d+1]=new sl(0,1,0),C[d+1]=new sv(.5,.5);for(var K=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[K]=new sl($,-c,ee),T[K]=new sl(0,-1,0),C[K++]=new sv($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[K]=new sl($,c,ee),T[K]=new sl(0,1,0),C[K++]=new sv($*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}var el=s.bounds,eu=Math.max(t,n);return el.min.set(-eu,-c,-eu),el.max.set(eu,c,eu),nj._initialize(s,x,T,C,g,o),s},nj.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 uf(e),l=((r=Math.floor(r))+1)*((i=Math.floor(i))+1),u=r*i,c=nj._generateIndices(e,l,6*u),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 sl((t+n*y)*T,(t+n*y)*C,n*x);h[f]=S;var w=t*T,b=t*C;d[f]=new sl(S.x-w,S.y-b,S.z).normalize(),_[f++]=new sv(g/i,p/r)}f=0;for(var A=1;A<=r;A++)for(var M=1;M<=i;M++){var F=(i+1)*A+M-1,P=(i+1)*(A-1)+M-1,E=(i+1)*(A-1)+M,R=(i+1)*A+M;c[f++]=F,c[f++]=P,c[f++]=R,c[f++]=P,c[f++]=E,c[f++]=R}var L=s.bounds,B=t+n;return L.min.set(-B,-B,-n),L.max.set(B,B,n),nj._initialize(s,h,d,_,c,o),s},nj.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);for(var o=new uf(e),s=(r=Math.floor(r))+1,l=(i=Math.floor(i))+1,u=.5*n,c=n/i,h=s*l,d=r*i,_=h+1+r,f=nj._generateIndices(e,_,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,b=0;b<h;++b){var A=b%s,M=b*p|0,F=A*g,P=M*m,E=C+F*S,R=Math.sin(E),L=Math.cos(E),B=t-M*t,D=B*R,I=M*c-u,O=B*L;v[b]=new sl(D,I,O),y[b]=new sl(R,w,L),x[b]=new sv(F,1-P)}for(var V=0;V<d;++V){var U=V%r,z=(V*g|0)*s+U,N=z+1,k=z+s,G=k+1;f[T++]=N,f[T++]=k,f[T++]=z,f[T++]=N,f[T++]=G,f[T++]=k}v[h]=new sl(0,-u,0),y[h]=new sl(0,-1,0),x[h]=new sv(.5,.5);for(var H=h+1,W=1/(2*t),X=0;X<r;++X){var j=v[X],K=j.x,q=j.z;v[H]=new sl(K,-u,q),y[H]=new sl(0,-1,0),x[H++]=new sv(K*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}var $=o.bounds;return $.min.set(-t,-u,-t),$.max.set(t,u,t),nj._initialize(o,v,y,x,f,a),o},nj.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);for(var o=new uf(e),s=(r=Math.max(2,Math.floor(r)))+1,l=(i=Math.floor(i))+1,u=.5*n,c=n/i,h=s*l,d=r*i,_=s*s,f=r*r,p=h+2*_,g=nj._generateIndices(e,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),b=0,A=0;A<h;++A){var M=A%s,F=A*m|0,P=M*v,E=F*y,R=x+P*T,L=Math.sin(R),B=Math.cos(R);C[A]=new sl(t*L,F*c-u,t*B),S[A]=new sl(L,0,B),w[A]=new sv(P,1-E)}for(var D=0;D<d;++D){var I=D%r,O=(D*v|0)*s+I,V=O+1,U=O+s,z=U+1;g[b++]=V,g[b++]=U,g[b++]=O,g[b++]=V,g[b++]=z,g[b++]=U}nj._createCapsuleCap(t,n,r,T,h,1,C,S,w,g,b),nj._createCapsuleCap(t,n,r,-T,h+_,-1,C,S,w,g,b+6*f);var N=o.bounds;return N.min.set(-t,-t-u,-t),N.max.set(t,t+u,t),nj._initialize(o,C,S,w,g,a),o},nj._initialize=function(e,t,n,r,i,a){e.setPositions(t),e.setNormals(n),e.setUVs(r),e.setIndices(i),e.calculateTangents(),e.uploadData(a),e.addSubMesh(0,i.length)},nj._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},nj._createCapsuleCap=function(e,t,n,r,i,a,o,s,l,u,c){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,b=e*Math.sin(x)*C,A=m+i;o[A]=new sl(S,w,b),s[A]=new sl(S,w-d,b),l[A]=new sv(v,y)}for(var M=0;M<f;++M){var F=M%n,P=(M*g|0)*h+F+i,E=P+1,R=P+h,L=R+1;u[c++]=E,u[c++]=P,u[c++]=L,u[c++]=P,u[c++]=R,u[c++]=L}},nj),uS=(sM(nK=function(){return uh.apply(this,arguments)},uh),(nq=nK.prototype).setVertexElements=function(e){this._setVertexElements(e)},nq.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 ud(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},nq.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])},nq.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new uu(e,t))),this._setIndexBufferBinding(n)},sb(nK,[{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}}]),nK),uw=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),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},ub=((nQ=(nY=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new ly,this._dataChangeManager=new ly,this._frames=[],this.name=e}).prototype).addFrame=function(e,t,n,r){if("number"==typeof e){var i=new uw(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},nQ.clearFrames=function(){this._frames.length=0,this._updateUseNormalAndTangent(!0,!0),this._dataChangeManager.dispatch()},nQ._addDataDirtyFlag=function(e){this._dataChangeManager.addFlag(e)},nQ._createSubDataDirtyFlag=function(){return this._dataChangeManager.createFlag(lm)},nQ._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._updateUseNormalAndTangent(!!e.deltaNormals,!!e.deltaTangents),this._dataChangeManager.dispatch()},nQ._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))},sb(nY,[{key:"frames",get:function(){return this._frames}}]),nY),uA=function(){function t(e){this._subMeshPool=new l8(uc),this._batchedQueue=[],this._meshes=[],this._meshCount=1,this._vertexBuffers=[],this._indiceBuffers=[],this._flushId=0,this._vertexCount=0,this._elementCount=0,this._engine=e;var n=t.MAX_VERTEX_COUNT;this._vertices=new Float32Array(9*n),this._indices=new Uint16Array(3*n);for(var r=this._meshes,i=this._meshCount,a=0;a<i;a++)r[a]=this._createMesh(e,a)}var n=t.prototype;return n.drawElement=function(e,t,n){if(e.multiRenderData)for(var r=e.charElements,i=0,a=r.length;i<a;++i)this._drawSubElement(r[i],t,n);else this._drawSubElement(e,t,n)},n._drawSubElement=function(e,n,r){var i=e.renderData.vertexCount;this._vertexCount+i>t.MAX_VERTEX_COUNT&&this.flush(n,r),this._vertexCount+=i,this._batchedQueue[this._elementCount++]=e},n.flush=function(e,n){var r=this._batchedQueue;0!==r.length&&(this._updateData(this._engine),this.drawBatches(e,n),!t._canUploadSameBuffer&&this._flushId++,r.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},n.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},n.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},n._createMesh=function(n,r){var i=t.MAX_VERTEX_COUNT,a=new uS(n,"BufferMesh"+r);a.isGCIgnored=!0;var o=[],s=this.createVertexElements(o),l=this._vertexBuffers[r]=new ul(n,e.BufferBindFlag.VertexBuffer,4*i*s,e.BufferUsage.Dynamic);l.isGCIgnored=!0;var u=this._indiceBuffers[r]=new ul(n,e.BufferBindFlag.IndexBuffer,6*i,e.BufferUsage.Dynamic);return u.isGCIgnored=!0,a.setVertexBufferBinding(l,s),a.setIndexBufferBinding(u,e.IndexFormat.UInt16),a.setVertexElements(o),a},n._updateData=function(e){var n=this._meshes,r=this._flushId;!t._canUploadSameBuffer&&this._meshCount<=r&&(this._meshCount++,n[r]=this._createMesh(e,r));var i=this._batchedQueue,a=this._vertices,o=this._indices,s=n[r];s.clearSubMesh();for(var l=0,u=0,c=0,h=0,d=0,_=0,f=null,p=0,g=i.length;p<g;p++){var m=i[p];l=this.updateVertices(m,a,l);for(var v=m.renderData.triangles,y=v.length,x=0;x<y;x++)o[u++]=v[x]+d;d+=m.renderData.vertexCount,null===f?h+=y:this.canBatch(f,m)?h+=y:(s.addSubMesh(this._getSubMeshFromPool(c,h)),c+=h,h=y,i[_++]=f),f=m}s.addSubMesh(this._getSubMeshFromPool(c,h)),i[_]=f,this._vertexBuffers[r].setData(a,0,0,l),this._indiceBuffers[r].setData(o,0,0,u)},n._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},t}();uA.MAX_VERTEX_COUNT=4096,uA._canUploadSameBuffer=!0;var uM=(sM(nJ=function(){return uA.apply(this,arguments)},uA),(nZ=nJ.prototype).createVertexElements=function(t){return t[0]=new us("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new us("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},nZ.canBatch=function(e,t){if(e.isAdd!==t.isAdd)return!1;var n=e.component.shaderData,r=t.component.shaderData,i=ua._textureProperty,a=ua._alphaCutoffProperty;return n.getTexture(i)===r.getTexture(i)&&n.getTexture(a)===r.getTexture(a)},nZ.updateVertices=function(e,t,n){for(var r=e.renderData,i=r.positions,a=r.uvs,o=r.vertexCount,s=0;s<o;s++){var l=i[s],u=a[s];t[n++]=l.x,t[n++]=l.y,t[n++]=l.z,t[n++]=u.x,t[n++]=u.y}return n},nZ.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,u=a.length;l<u;l++){var c=a[l],h=r[l];if(!c||!h)return;var d=h.component,_=h.material,f=s3._compileMacros;sq.unionCollection(d._globalShaderMacro,_.shaderData._macroCollection,f);var p=_.renderState.stencilState,g=h.isAdd?e.StencilOperation.IncrementSaturate:e.StencilOperation.DecrementSaturate;p.passOperationFront=g,p.passOperationBack=g;var m=_.shader.passes[0]._getShaderProgram(n,f);if(!m.isValid)return;m.bind(),m.groupingOtherUniformBlock(),m.uploadAll(m.sceneUniformBlock,o),m.uploadAll(m.cameraUniformBlock,s),m.uploadAll(m.rendererUniformBlock,d.shaderData),m.uploadAll(m.materialUniformBlock,_.shaderData),_.renderState._apply(n,!1),n._hardwareRenderer.drawPrimitive(i,c,m)}},nJ),uF=((n0=(n$=function(e){this._preMaskLayer=0,this._batcher=new uM(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},n0.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t,null))},n0.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},n0.destroy=function(){this._batcher.destroy(),this._batcher=null},n0._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,u=0,c=i.length;u<c;u++){var h=l[u],d=h.influenceLayers;if(!(d&a)){if(d&o){var _=h._maskElement;_.isAdd=!0,this._batcher.drawElement(_,e,null);continue}if(d&s){var f=h._maskElement;f.isAdd=!1,this._batcher.drawElement(f,e,null)}}}},n$),uP=(sM(n1=function(){var e;return(e=l6.call(this)||this).charElements=[],e.multiRenderData=!0,e},l6),n1.prototype.dispose=function(){this.component=this.material=this.renderState=this.shaderPass=null,this.charElements.length=0},n1);e.BackgroundMode=void 0,(n2=e.BackgroundMode||(e.BackgroundMode={}))[n2.SolidColor=0]="SolidColor",n2[n2.Sky=1]="Sky",n2[n2.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(n3=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[n3.AspectFitWidth=0]="AspectFitWidth",n3[n3.AspectFitHeight=1]="AspectFitHeight",n3[n3.Fill=2]="Fill";var uE=((n5=(n4=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},n5._render=function(e){var t=this.material,n=this.mesh;if(!t){sj.warn("The material of sky is not defined.");return}if(!n){sj.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,u=n4._viewProjMatrix,c=n4._projectionMatrix,h=i._hardwareRenderer,d=t.shaderData,_=t.shader,f=t.renderState;u.copyFrom(s);var p=u.elements;p[12]=p[13]=p[14]=0;var g=1/Math.tan(ss.degreeToRadian(o)/2);c.elements[0]=g/a,c.elements[5]=g,sg.multiply(c,u,u);var m=l.getMatrix(l9._vpMatrixProperty);l.setMatrix(l9._vpMatrixProperty,u);var v=s3._compileMacros;sq.unionCollection(e.camera._globalShaderMacro,d._macroCollection,v);var y=_.passes[0]._getShaderProgram(i,v);y.bind(),y.groupingOtherUniformBlock(),y.uploadAll(y.cameraUniformBlock,l),y.uploadAll(y.materialUniformBlock,d),y.uploadUnGroupTextures(),f._apply(i,!1),h.drawPrimitive(n,n.subMesh,y),l.setMatrix(l9._vpMatrixProperty,m)},sb(n4,[{key:"material",get:function(){return this._material},set:function(e){if(this._material!==e){var t;null==e||e._addRefCount(1),null==(t=this._material)||t._addRefCount(-1),this._material=e}}},{key:"mesh",get:function(){return this._mesh},set:function(e){if(this._mesh!==e){var t;null==e||e._addRefCount(1),null==(t=this._mesh)||t._addRefCount(-1),this._mesh=e}}}]),n4);uE._epsilon=1e-6,uE._viewProjMatrix=new sg,uE._projectionMatrix=new sg(1,0,0,0,0,1,0,0,0,0,uE._epsilon-1,-1,0,0,0,0);var uR=((n6=(n8=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new sx(.25,.25,.25,1),this.sky=new uE,this._textureFillMode=e.BackgroundTextureFillMode.AspectFitHeight,this._texture=null,this._initMesh(t)}).prototype).destroy=function(){this._mesh._addRefCount(-1),this._mesh=null,this.texture=null,this.solidColor=null,this.sky.destroy()},n6._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addRefCount(1)},n6._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)}},n6._createPlane=function(e){var t=new uf(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 sl,i[a]=new sv(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},sb(n8,[{key:"texture",get:function(){return this._texture},set:function(e){if(this._texture!==e){var t;null==e||e._addRefCount(1),null==(t=this._texture)||t._addRefCount(-1),this._texture=e,this._engine._backgroundTextureMaterial.shaderData.setTexture("u_baseTexture",e)}}},{key:"textureFillMode",get:function(){return this._textureFillMode},set:function(e){e!==this._textureFillMode&&(this._textureFillMode=e,this._resizeBackgroundTexture())}}]),n8);e.FogMode=void 0,(n7=e.FogMode||(e.FogMode={}))[n7.None=0]="None",n7[n7.Linear=1]="Linear",n7[n7.Exponential=2]="Exponential",n7[n7.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(n9=e.DiffuseMode||(e.DiffuseMode={}))[n9.SolidColor=0]="SolidColor",n9[n9.SphericalHarmonics=1]="SphericalHarmonics";var uL=((rt=(re=function(){this._diffuseSolidColor=new sx(.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(re._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(re._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(re._specularIntensityProperty,this._specularIntensity),t.setFloatArray(re._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},rt._removeFromScene=function(e){var t=this._scenes,n=t.indexOf(e);t.splice(n,1)},rt._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(re._shMacro):t.disableMacro(re._shMacro)},rt._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(re._specularTextureProperty,this._specularTexture),e.setFloat(re._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(re._specularMacro)):e.disableMacro(re._specularMacro)},rt._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(re._decodeRGBMMacro):e.disableMacro(re._decodeRGBMMacro)},rt._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]},sb(re,[{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(re._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(re._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(re._specularIntensityProperty,e)}}]),re);uL._shMacro=s3.getMacroByName("O3_USE_SH"),uL._specularMacro=s3.getMacroByName("O3_USE_SPECULAR_ENV"),uL._decodeRGBMMacro=s3.getMacroByName("O3_DECODE_ENV_RGBM"),uL._diffuseColorProperty=s3.getPropertyByName("u_envMapLight.diffuse"),uL._diffuseSHProperty=s3.getPropertyByName("u_env_sh"),uL._diffuseIntensityProperty=s3.getPropertyByName("u_envMapLight.diffuseIntensity"),uL._specularTextureProperty=s3.getPropertyByName("u_env_specularSampler"),uL._specularIntensityProperty=s3.getPropertyByName("u_envMapLight.specularIntensity"),uL._mipLevelProperty=s3.getPropertyByName("u_envMapLight.mipMapLevel");var uB=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 sl(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new sq,a._rootEntities=[],a._background=new uR(a._engine),a._shaderData=new lK(oE.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new sx(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new sy,a._sunlightVector3=new sl,a.name=i||"";var a,o=a.shaderData;return o._addRefCount(1),a.ambientLight=new uL,r.sceneManager._allScenes.push(sS(a)),o.enableMacro("OASIS_FOG_MODE",a._fogMode.toString()),o.enableMacro("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}sM(n,t);var r=n.prototype;return r.createRootEntity=function(e){var t=new lT(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),lT._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(),lT._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=lT._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):sj.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),s=o.color,l=o.intensity;this._sunlightVector3.set(s.r*l,s.g*l,s.b*l),t.setVector3(n._sunlightColorProperty,this._sunlightVector3),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("SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SHADOW_TYPE"),sq.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._addRefCount(-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)},sb(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("CASCADED_COUNT",e.toString()),this._shadowCascades=e)}},{key:"ambientLight",get:function(){return this._ambientLight},set:function(e){if(!e){sj.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("OASIS_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}(sV);uB._fogColorProperty=s3.getPropertyByName("oasis_FogColor"),uB._fogParamsProperty=s3.getPropertyByName("oasis_FogParams"),uB._sunlightColorProperty=s3.getPropertyByName("galacean_SunlightColor"),uB._sunlightDirectionProperty=s3.getPropertyByName("galacean_SunlightDirection");var uD=((rr=(rn=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},rr.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},rr._destroyAllScene=function(){for(var e=this._allScenes,t=0,n=e.length;t<n;t++)e[t]._destroy();e.length=0},sb(rn,[{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)}}]),rn),uI="#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <uv_share>\n#include <color_share>\n#include <normal_share>\n#include <worldpos_share>\n#include <ShadowVertexDeclaration>\n#include <FogVertexDeclaration>\nvoid main(){\n#include <begin_position_vert>\n#include <begin_normal_vert>\n#include <blendShape_vert>\n#include <skinning_vert>\n#include <uv_vert>\n#include <color_vert>\n#include <normal_vert>\n#include <worldpos_vert>\n#include <position_vert>\n#include <ShadowVertex>\n#include <FogVertex>\n}",uO=((ri=function(){}).init=function(){s3.create("blinn-phong","#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 OASIS_TRANSPARENT\ngl_FragColor.a=diffuse.a;\n#else\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),s3.create("pbr",uI,"#define GLSLIFY 1\n#define IS_METALLIC_WORKFLOW\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),s3.create("pbr-specular",uI,"#define GLSLIFY 1\n#include <common>\n#include <camera_declare>\n#include <FogFragmentDeclaration>\n#include <uv_share>\n#include <normal_share>\n#include <color_share>\n#include <worldpos_share>\n#include <light_frag_define>\n#include <pbr_frag_define>\n#include <pbr_helper>\nvoid main(){\n#include <pbr_frag>\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),s3.create("unlit","#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 u_baseColor;uniform float u_alphaCutoff;\n#ifdef BASETEXTURE\nuniform sampler2D u_baseTexture;\n#endif\nvoid main(){vec4 baseColor=u_baseColor;\n#ifdef BASETEXTURE\nvec4 textureColor=texture2D(u_baseTexture,v_uv);\n#ifndef OASIS_COLORSPACE_GAMMA\ntextureColor=gammaToLinear(textureColor);\n#endif\nbaseColor*=textureColor;\n#endif\n#ifdef ALPHA_CUTOFF\nif(baseColor.a<u_alphaCutoff){discard;}\n#endif\ngl_FragColor=baseColor;\n#ifndef OASIS_TRANSPARENT\ngl_FragColor.a=1.0;\n#endif\n#include <FogFragment>\n#ifndef OASIS_COLORSPACE_GAMMA\ngl_FragColor=linearToGamma(gl_FragColor);\n#endif\n}"),s3.create("shadow-map","#define GLSLIFY 1\n#include <common>\n#include <common_vert>\n#include <blendShape_input>\n#include <normal_share>\nuniform mat4 u_VPMat;uniform vec2 u_shadowBias;uniform vec3 u_lightDirection;vec3 applyShadowBias(vec3 positionWS){positionWS-=u_lightDirection*u_shadowBias.x;return positionWS;}vec3 applyShadowNormalBias(vec3 positionWS,vec3 normalWS){float invNdotL=1.0-clamp(dot(-u_lightDirection,normalWS),0.0,1.0);float scale=invNdotL*u_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=u_modelMat*position;positionWS.xyz=applyShadowBias(positionWS.xyz);\n#ifndef OMIT_NORMAL\n#ifdef O3_HAS_NORMAL\nvec3 normalWS=normalize(mat3(u_normalMat)*normal);positionWS.xyz=applyShadowNormalBias(positionWS.xyz,normalWS);\n#endif\n#endif\nvec4 positionCS=u_VPMat*positionWS;positionCS.z=max(positionCS.z,-1.0);gl_Position=positionCS;}","#define GLSLIFY 1\n#ifdef OASIS_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 OASIS_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}"),s3.create("skybox","#define GLSLIFY 1\n#include <common_vert>\nuniform mat4 u_VPMat;varying vec3 v_cubeUV;void main(){v_cubeUV=vec3(-POSITION.x,POSITION.yz);gl_Position=u_VPMat*vec4(POSITION,1.0);}","#define GLSLIFY 1\n#include <common>\nuniform samplerCube u_cube;varying vec3 v_cubeUV;uniform vec4 u_cubeDecodeParam;void main(){vec4 textureColor=textureCube(u_cube,v_cubeUV);if(u_cubeDecodeParam.x>0.0){textureColor=RGBMToLinear(textureColor,u_cubeDecodeParam.y);textureColor=linearToGamma(textureColor);}gl_FragColor=textureColor;}"),s3.create("particle-shader","#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 u_MVPMat;varying vec4 v_color;varying float v_lifeLeft;varying vec2 v_uv;\n#ifdef is2d\nuniform mat4 u_viewInvMat;uniform mat4 u_projMat;uniform mat4 u_viewMat;uniform mat4 u_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=u_viewInvMat[0].xyz;vec3 basisZ=u_viewInvMat[1].xyz;vec3 localPosition=vec3(basisX*rotatedPoint.x+basisZ*rotatedPoint.y)*scale+position;gl_Position=u_projMat*u_viewMat*vec4(localPosition+u_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=u_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}"),s3.create("SpriteMask","#define GLSLIFY 1\nuniform mat4 u_VPMat;attribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;void main(){gl_Position=u_VPMat*vec4(POSITION,1.0);v_uv=TEXCOORD_0;}","#define GLSLIFY 1\nuniform sampler2D u_maskTexture;uniform float u_maskAlphaCutoff;varying vec2 v_uv;void main(){vec4 color=texture2D(u_maskTexture,v_uv);if(color.a<u_maskAlphaCutoff){discard;}gl_FragColor=color;}"),s3.create("Sprite","#define GLSLIFY 1\n#ifdef USE_MODEL_MATRIX\nuniform mat4 u_MVPMat;\n#else\nuniform mat4 u_VPMat;\n#endif\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;attribute vec4 COLOR_0;varying vec2 v_uv;varying vec4 v_color;void main(){\n#ifdef USE_MODEL_MATRIX\ngl_Position=u_MVPMat*vec4(POSITION,1.0);\n#else\ngl_Position=u_VPMat*vec4(POSITION,1.0);\n#endif\nv_uv=TEXCOORD_0;v_color=COLOR_0;}","#define GLSLIFY 1\n#ifdef USE_CUSTOM_TEXTURE\nuniform sampler2D u_cusTomTexture;\n#else\nuniform sampler2D u_spriteTexture;\n#endif\nvarying vec2 v_uv;varying vec4 v_color;void main(){\n#ifdef USE_CUSTOM_TEXTURE\nvec4 baseColor=texture2D(u_cusTomTexture,v_uv);\n#else\nvec4 baseColor=texture2D(u_spriteTexture,v_uv);\n#endif\ngl_FragColor=baseColor*v_color;}"),s3.create("background-texture","#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 u_baseTexture;varying vec2 v_uv;void main(){gl_FragColor=texture2D(u_baseTexture,v_uv);}")},ri),uV=((ro=(ra=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 u=i<a?0:r[a],c=t[u];return c||(this._lastQueryKey=u,this._lastQueryMap=t),c},ro.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},ro._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 u in e)this._resizeCacheMapHierarchy(e[u],++t,n)},ra);uO.init();var uU=function(t){function n(r,i,a){(o=t.call(this)||this)._lightManager=new lZ,o._componentsManager=new l_,o._lastRenderState=new l4,o._renderElementPool=new l8(l7),o._spriteElementPool=new l8(ue),o._spriteMaskElementPool=new l8(ut),o._textElementPool=new l8(uP),o._renderContext=new l9,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._macroCollection=new sq,o._settings={},o._resourceManager=new ls(sS(o)),o._sceneManager=new uD(sS(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new s4,o._isPaused=!0,o._vSyncCounter=1,o._targetFrameInterval=1e3/60,o._destroyed=!1,o._frameInProcess=!1,o._waittingDestroy=!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.physicsManager=new lA(sS(o)),o._canvas=r,o._sceneManager.activeScene=new uB(sS(o),"DefaultScene"),o._spriteMaskManager=new uF(sS(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=la.createFromOS(sS(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new lj(sS(o));var o,s=new Uint8Array([255,0,255,255]),l=new le(sS(o),1,1,e.TextureFormat.R8G8B8A8,!1);l.setPixelBuffer(s),l.isGCIgnored=!0;var u=new ln(sS(o),1,e.TextureFormat.R8G8B8A8,!1);if(u.setPixelBuffer(e.TextureCubeFace.PositiveX,s),u.setPixelBuffer(e.TextureCubeFace.NegativeX,s),u.setPixelBuffer(e.TextureCubeFace.PositiveY,s),u.setPixelBuffer(e.TextureCubeFace.NegativeY,s),u.setPixelBuffer(e.TextureCubeFace.PositiveZ,s),u.setPixelBuffer(e.TextureCubeFace.NegativeZ,s),u.isGCIgnored=!0,i.canIUse(e.GLCapabilityType.depthTexture)){var c=new le(sS(o),1,1,e.TextureFormat.Depth16,!1);c.isGCIgnored=!0,o._depthTexture2D=c}else o._macroCollection.enable(n._noDepthTextureMacro);if(o._magentaTexture2D=l,o._magentaTextureCube=u,i.isWebGL2){var h=new lt(sS(o),1,1,1,e.TextureFormat.R8G8B8A8,!1);h.setPixelBuffer(0,s),h.isGCIgnored=!0,o._magentaTexture2DArray=h}var d=new l5(sS(o),s3.find("unlit"));d.isGCIgnored=!0,d.shaderData.setColor("u_baseColor",new sP(1,0,1.01,1)),o._magentaMaterial=d;var _=new l5(sS(o),s3.find("background-texture"));_.isGCIgnored=!0,_.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,o._backgroundTextureMaterial=_;var f=o._settings,p=(null==a?void 0:a.colorSpace)||e.ColorSpace.Linear;return p===e.ColorSpace.Gamma&&o._macroCollection.enable(n._gammaMacro),f.colorSpace=p,o}sM(n,t);var r=n.prototype;return r.createEntity=function(e){return new lT(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(){var e=this._time;e.tick();var t=e.deltaTime;this._frameInProcess=!0,this._renderElementPool.resetPool(),this._spriteElementPool.resetPool(),this._spriteMaskElementPool.resetPool(),this._textElementPool.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/1e3),this.inputManager._update(),r.callScriptOnUpdate(t),r.callAnimationUpdate(t),r.callScriptOnLateUpdate(t),this._render(n)),this._waittingDestroy||r.handlingInvalidScripts(),this._waittingDestroy&&this._destroy(),this._frameInProcess=!1},r.run=function(){this.resume(),this.trigger(new sz("run",this))},r._destroy=function(){this._sceneManager._destroyAllScene(),this._componentsManager.handlingInvalidScripts(),this._resourceManager._destroy(),this._magentaTexture2D.destroy(!0),this._magentaTextureCube.destroy(!0),this._textDefaultFont.destroy(!0),this.inputManager._destroy(),this.trigger(new sz("shutdown",this)),this.pause(),this._animate=null,this._sceneManager=null,this._resourceManager=null,this._canvas=null,this._time=null,this._spriteMaskManager.destroy(),this.removeAllEventListeners(),this._waittingDestroy=!1,this._destroyed=!0},r.destroy=function(){this._destroyed||(this._frameInProcess?this._waittingDestroy=!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 uV}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 sj.debug("NO active camera.")},r._createSpriteMaterial=function(){var t=new l5(this,s3.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 l5(this,s3.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},sb(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}(sN);uU._gammaMacro=s3.getMacroByName("OASIS_COLORSPACE_GAMMA"),uU._noDepthTextureMacro=s3.getMacroByName("OASIS_NO_DEPTH_TEXTURE"),uU._pixelsPerUnit=100;var uz=(sM(rs=function(){var e;return e=lv.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},lv),(rl=rs.prototype).onAwake=function(){},rl.onEnable=function(){},rl.onStart=function(){},rl.onUpdate=function(e){},rl.onLateUpdate=function(e){},rl.onBeginRender=function(e){},rl.onEndRender=function(e){},rl.onPhysicsUpdate=function(){},rl.onTriggerEnter=function(e){},rl.onTriggerExit=function(e){},rl.onTriggerStay=function(e){},rl.onCollisionEnter=function(e){},rl.onCollisionExit=function(e){},rl.onCollisionStay=function(e){},rl.onPointerDown=function(e){},rl.onPointerUp=function(e){},rl.onPointerClick=function(e){},rl.onPointerEnter=function(e){},rl.onPointerExit=function(e){},rl.onPointerDrag=function(e){},rl.onDisable=function(){},rl.onDestroy=function(){},rl._onAwake=function(){this.onAwake()},rl._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rs.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()},rl._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rl._onDestroy=function(){this._engine._componentsManager.addPendingDestroyScript(this)},rl._handlingInValid=function(){var e=this.engine._componentsManager,t=rs.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},rs);sE([sL],uz.prototype,"_started",void 0),sE([sL],uz.prototype,"_onStartIndex",void 0),sE([sL],uz.prototype,"_onUpdateIndex",void 0),sE([sL],uz.prototype,"_onLateUpdateIndex",void 0),sE([sL],uz.prototype,"_onPhysicsUpdateIndex",void 0),sE([sL],uz.prototype,"_onPreRenderIndex",void 0),sE([sL],uz.prototype,"_onPostRenderIndex",void 0),sE([sL],uz.prototype,"_entityScriptsIndex",void 0),sE([sL],uz.prototype,"_waitHandlingInValid",void 0);var uN=(sM(ru=function(){return uA.apply(this,arguments)},uA),(rc=ru.prototype).createVertexElements=function(t){return t[0]=new us("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new us("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new us("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rc.canBatch=function(e,t){if(!this._engine._canSpriteBatch)return!1;var n=e.component,r=t.component;return!!this.checkBatchWithMask(n,r)&&e.texture===t.texture&&e.material===t.material},rc.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rc.updateVertices=function(e,t,n){for(var r=e.renderData,i=r.positions,a=r.uvs,o=r.color,s=r.vertexCount,l=0;l<s;l++){var u=i[l],c=a[l];t[n++]=u.x,t[n++]=u.y,t[n++]=u.z,t[n++]=c.x,t[n++]=c.y,t[n++]=o.r,t[n++]=o.g,t[n++]=o.b,t[n++]=o.a}return n},rc.drawBatches=function(e,t){for(var n=this._engine,r=this._batchedQueue,i=this._meshes[this._flushId],a=i.subMeshes,o=n._spriteMaskManager,s=e.scene.shaderData,l=e.shaderData,u=0,c=a.length;u<c;u++){var h=a[u],d=r[u];if(!h||!d)return;var _=d.component,f=d.material;o.preRender(e,_);var p=s3._compileMacros;sq.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p),(t||f)._preRender(d);var g=d.shaderPass._getShaderProgram(n,p);if(!g.isValid)return;_.shaderData.setTexture(ru._textureProperty,d.texture),g.bind(),g.groupingOtherUniformBlock(),g.uploadAll(g.sceneUniformBlock,s),g.uploadAll(g.cameraUniformBlock,l),g.uploadAll(g.rendererUniformBlock,_.shaderData),g.uploadAll(g.materialUniformBlock,f.shaderData),d.renderState._apply(n,!1),n._hardwareRenderer.drawPrimitive(i,h,g),o.postRender(_)}},rc.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},ru);uN._textureProperty=s3.getPropertyByName("u_spriteTexture");var uk=((rd=(rh=function(e){this.items=[],this._spriteBatcher=new uN(e)}).prototype).pushPrimitive=function(e){this.items.push(e)},rd.render=function(e,t,n,r){var i=this.items;if(0!==i.length){for(var a=e.engine,o=e.scene,s=a._renderCount,l=a._hardwareRenderer,u=o.shaderData,c=e.shaderData,h=0,d=i.length;h<d;h++){var _=i[h];if(_.component.entity.layer&n){if(_.mesh){this._spriteBatcher.flush(e,t);var f=s3._compileMacros,p=_.component,g=_.material.destroyed?a._magentaMaterial:_.material,m=p.shaderData,v=g.shaderData;(t||g)._preRender(_),sq.unionCollection(p._globalShaderMacro,v._macroCollection,f);var y=((null==r?void 0:r.passes[0])||(null==t?void 0:t.shader.passes[0])||_.shaderPass)._getShaderProgram(a,f);if(!y.isValid)continue;var x=y.bind();s!==y._uploadRenderCount?(y.groupingOtherUniformBlock(),y.uploadAll(y.sceneUniformBlock,u),y.uploadAll(y.cameraUniformBlock,c),y.uploadAll(y.rendererUniformBlock,m),y.uploadAll(y.materialUniformBlock,v),y.uploadUnGroupTextures(),y._uploadScene=o,y._uploadCamera=e,y._uploadRenderer=p,y._uploadMaterial=g,y._uploadRenderCount=s):(y._uploadScene!==o?(y.uploadAll(y.sceneUniformBlock,u),y._uploadScene=o):x&&y.uploadTextures(y.sceneUniformBlock,u),y._uploadCamera!==e?(y.uploadAll(y.cameraUniformBlock,c),y._uploadCamera=e):x&&y.uploadTextures(y.cameraUniformBlock,c),y._uploadRenderer!==p?(y.uploadAll(y.rendererUniformBlock,m),y._uploadRenderer=p):x&&y.uploadTextures(y.rendererUniformBlock,m),y._uploadMaterial!==g?(y.uploadAll(y.materialUniformBlock,v),y._uploadMaterial=g):x&&y.uploadTextures(y.materialUniformBlock,v),x&&y.uploadUnGroupTextures()),_.renderState._apply(a,p.entity.transform._isFrontFaceInvert()),l.drawPrimitive(_.mesh,_.subMesh,y)}else this._spriteBatcher.drawElement(_,e,t)}}this._spriteBatcher.flush(e,t)}},rd.clear=function(){this.items.length=0,this._spriteBatcher.clear()},rd.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rd.sort=function(e){this._quickSort(this.items,0,this.items.length,e)},rd._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 u=a;a=s,s=o,o=u}else if(r(o,s)>0){var c=o;o=s,s=c}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=_)}},rd._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}},rh._compareFromNearToFar=function(e,t){return e.component.priority-t.component.priority||e.component._distanceForSort-t.component._distanceForSort},rh._compareFromFarToNear=function(e,t){return e.component.priority-t.component.priority||t.component._distanceForSort-e.component._distanceForSort},rh),uG=function(){this.position=new sl,this.isOrthographic=!1,this.viewMatrix=new sg,this.projectionMatrix=new sg,this.viewProjectionMatrix=new sg,this.forward=new sl},uH=function(){this.virtualCamera=new uG,this.cullPlanes=[new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl),new sd(new sl)],this.splitBoundSphere=new su(new sl,0)};(r_=oH||(oH={}))[r_.FarBottomLeft=0]="FarBottomLeft",r_[r_.FarTopLeft=1]="FarTopLeft",r_[r_.FarTopRight=2]="FarTopRight",r_[r_.FarBottomRight=3]="FarBottomRight",r_[r_.nearBottomLeft=4]="nearBottomLeft",r_[r_.nearTopLeft=5]="nearTopLeft",r_[r_.nearTopRight=6]="nearTopRight",r_[r_.nearBottomRight=7]="nearBottomRight",r_[r_.unknown=8]="unknown";var uW=((rf=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}},rf.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rf.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},rf.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&rf.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time._frameCount,n._prepareRender(e))},rf.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,u=Math.sqrt(1+s*s)*Math.tan(ss.degreeToRadian(l)/2),c=u*u,h=t-e,d=t+e;c>h/d?(a=t,o=t*u):(a=.5*d*(1+c),o=.5*Math.sqrt(h*h+2*(t*t+e*e)*c+d*d*c*c));var _=i.splitBoundSphere.center;i.splitBoundSphere.radius=o,sl.scale(r,a,_),sl.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},rf.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=rf._frustumCorners,s=rf._backPlaneFaces,l=rf._frustumPlaneNeighbors,u=rf._frustumTwoPlaneCorners,c=rf._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=rf._adjustNearPlane,y=rf._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),sh.intersectionPointThreePlanes(v,g,p,o[7]),sh.intersectionPointThreePlanes(v,m,p,o[6]),sh.intersectionPointThreePlanes(v,m,f,o[5]),sh.intersectionPointThreePlanes(v,g,f,o[4]),sh.intersectionPointThreePlanes(y,g,p,o[3]),sh.intersectionPointThreePlanes(y,m,p,o[2]),sh.intersectionPointThreePlanes(y,m,f,o[1]),sh.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>sl.dot(C.normal,i)&&(h[x].copyFrom(C),s[x]=T,x++)}for(var S=x,w=0;w<x;w++)for(var b=s[w],A=l[b],M=0;M<4;M++){for(var F=A[M],P=!0,E=0;E<x;E++)if(F==s[E]){P=!1;break}if(P){var R=u[b][F],L=o[R[0]],B=o[R[1]];sl.add(L,i,c),sd.fromPoints(L,B,c,h[S++])}}a.cullPlaneCount=S},rf.getDirectionalLightMatrices=function(e,t,n,r,i,a,o,s){var l=o.splitBoundSphere;o.resolution=a;var u=l.center,c=l.radius,h=a/2,d=c*h/(h-rf.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sl.dot(u,e)*f)*p,m=Math.ceil(sl.dot(u,t)*f)*p,v=sl.dot(u,n);u.x=e.x*g+t.x*m+n.x*v,u.y=e.y*g+t.y*m+n.y*v,u.z=e.z*g+t.z*m+n.z*v;var y=o.virtualCamera,x=y.position,T=y.viewMatrix,C=y.projectionMatrix;sl.scale(n,c+i,x),sl.subtract(u,x,x),sg.lookAt(x,u,e,T),sg.ortho(-d,d,-d,d,0,2*c+i,C);var S=y.viewProjectionMatrix;sg.multiply(C,T,S),um._floatMatrixMultiply(rf._shadowMapCoordMatrix,S.elements,0,s,16*r)},rf.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},rf.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)},rf.applySliceTransform=function(e,t,n,r,i,a){var o=rf._tempMatrix0,s=o.elements,l=1/t,u=1/n,c=i.x*l,h=i.y*u;s[0]=e*l,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=e*u,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=c,s[13]=h,s[14]=0,s[15]=1;var d=16*r;um._floatMatrixMultiply(o,a,d,a,d)},rf);uW._tempMatrix0=new sg,uW._shadowMapCoordMatrix=new sg(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),uW._frustumCorners=[new sl,new sl,new sl,new sl,new sl,new sl,new sl,new sl],uW._adjustNearPlane=new sd(new sl),uW._adjustFarPlane=new sd(new sl),uW._backPlaneFaces=[,,,,,],uW._edgePlanePoint2=new sl,uW._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]],uW._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]]],uW.atlasBorderSize=4;var uX=function(){function t(n){this._shadowMapSize=new sy,this._shadowBias=new sv,this._shadowSliceData=new uH,this._lightUp=new sl,this._lightSide=new sl,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sl,this._viewportOffsets=[new sv,new sv,new sv,new sv],this._camera=n,this._engine=n.engine,this._supportDepthTexture=n.engine._hardwareRenderer.canIUse(e.GLCapabilityType.depthTexture),this._shadowCasterShader=s3.find("shadow-map"),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._shadowCasterShader,o=this._viewportOffsets,s=this._shadowSliceData,l=this._splitBoundSpheres,u=this._shadowMatrices,c=i._renderPipeline,h=c._opaqueQueue,d=c._alphaTestQueue,_=c._transparentQueue,f=r._componentsManager,p=r._hardwareRenderer,g=i.scene.shadowCascades,m=t._cascadesSplitDistance,v=s.splitBoundSphere,y=t._tempMatrix0,x=y.elements,T=this._lightUp,C=this._lightSide,S=s.virtualCamera.forward,w=r._lightManager._getSunLightIndex();if(-1!==w){var b=i.scene._sunLight,A=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(A);var M=this._getAvailableRenderTarget();p.activeRenderTarget(M,t._viewport,0),this._supportDepthTexture?p.clearRenderTarget(r,e.CameraClearFlags.Depth,null):p.clearRenderTarget(r,e.CameraClearFlags.All,t._clearColor),this._shadowInfos.x=b.shadowStrength,this._shadowInfos.z=w,sg.rotationQuaternion(b.entity.transform.worldRotationQuaternion,y),C.set(x[0],x[1],x[2]),T.set(x[4],x[5],x[6]),S.set(-x[8],-x[9],-x[10]),i.entity.transform.getWorldForward(t._tempVector);for(var F=this._shadowTileResolution,P=0;P<g;P++){if(uW.getBoundSphereByFrustum(m[P],m[P+1],i,t._tempVector.normalize(),s),uW.getDirectionLightShadowCullPlanes(i._frustum,m[P],i.nearClipPlane,S,s),uW.getDirectionalLightMatrices(T,C,S,P,b.shadowNearPlane,F,s,u),g>1){var E=this._shadowMapSize;uW.applySliceTransform(F,E.z,E.w,P,this._viewportOffsets[P],u)}this._updateSingleShadowCasterShaderData(b,s,n);var R=v.center,L=v.radius,B=4*P;l[B]=R.x,l[B+1]=R.y,l[B+2]=R.z,l[B+3]=L*L,h.clear(),d.clear(),_.clear();for(var D=f._renderers,I=D._elements,O=D.length-1;O>=0;--O)uW.shadowCullFrustum(n,b,I[O],s);if(h.items.length||d.items.length){h.sort(uk._compareFromNearToFar),d.sort(uk._compareFromNearToFar);var V=o[P],U=V.x,z=V.y;p.setGlobalDepthBias(1,1),p.viewport(U,z,F,F),p.scissor(U+1,z+1,F-2,F-2),r._renderCount++,h.render(i,null,e.Layer.Everything,a),d.render(i,null,e.Layer.Everything,a),p.setGlobalDepthBias(0,0)}}this._existShadowMap=!0}},n._updateReceiversShaderData=function(){var e=this._camera.scene,n=this._splitBoundSpheres,r=this._shadowMatrices,i=e.shadowCascades;if(i>1)for(var a=4*i,o=n.length;a<o;a++)n[a]=0;for(var s=16*i,l=r.length;s<l;s++)r[s]=0;var u=e.shaderData;u.setFloatArray(t._shadowMatricesProperty,this._shadowMatrices),u.setVector3(t._shadowInfosProperty,this._shadowInfos),u.setTexture(t._shadowMapsProperty,this._depthTexture),u.setFloatArray(t._shadowSplitSpheresProperty,this._splitBoundSpheres),u.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,u=l.nearClipPlane,c=l.aspectRatio,h=l.fieldOfView;r[0]=u;var d=n-u,_=Math.tan(.5*ss.degreeToRadian(h)),f=1+_*_*(c*c+1);switch(s){case e.ShadowCascadesMode.NoCascades:r[1]=this._getFarWithRadius(n,f);break;case e.ShadowCascadesMode.TwoCascades:r[1]=this._getFarWithRadius(u+d*a,f),r[2]=this._getFarWithRadius(n,f);break;case e.ShadowCascadesMode.FourCascades:r[1]=this._getFarWithRadius(u+d*o.x,f),r[2]=this._getFarWithRadius(u+d*o.y,f),r[3]=this._getFarWithRadius(u+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 le(t,i,a,n,!1)).wrapModeV=o.wrapModeU=e.TextureWrapMode.Clamp,t._hardwareRenderer._isWebGL2&&(o.depthCompareFunction=e.TextureDepthCompareFunction.Less),s=this._supportDepthTexture?this._renderTargets=new s9(t,i,a,null,o):this._renderTargets=new s9(t,i,a,o)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=uW.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=uW.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=uW.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.destroy(),this._renderTargets=null);var u=this._viewportOffsets,c=this._shadowTileResolution;switch(i){case e.ShadowCascadesMode.NoCascades:u[0].set(0,0);break;case e.ShadowCascadesMode.TwoCascades:u[0].set(0,0),u[1].set(c,0);break;case e.ShadowCascadesMode.FourCascades:u[0].set(0,0),u[1].set(c,0),u[2].set(0,c),u[3].set(c,c)}}},n._updateSingleShadowCasterShaderData=function(e,n,r){var i=n.virtualCamera;uW.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}();uX._lightShadowBiasProperty=s3.getPropertyByName("u_shadowBias"),uX._lightDirectionProperty=s3.getPropertyByName("u_lightDirection"),uX._shadowMatricesProperty=s3.getPropertyByName("u_shadowMatrices"),uX._shadowMapSize=s3.getPropertyByName("u_shadowMapSize"),uX._shadowInfosProperty=s3.getPropertyByName("u_shadowInfo"),uX._shadowMapsProperty=s3.getPropertyByName("u_shadowMap"),uX._shadowSplitSpheresProperty=s3.getPropertyByName("u_shadowSplitSpheres"),uX._maxCascades=4,uX._cascadesSplitDistance=Array(uX._maxCascades+1),uX._viewport=new sy(0,0,1,1),uX._clearColor=new sx(1,1,1,1),uX._tempVector=new sl,uX._tempMatrix0=new sg;var uj=0,uK=((rg=(rp=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uj++),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){},rg.preRender=function(e,t,n,r){},rg.postRender=function(e,t,n,r){},rp),uq=((rv=(rm=function(e){this._allSpriteMasks=new ld,this._lastCanvasSize=new sv,this._camera=e;var t=e.engine;this._opaqueQueue=new uk(t),this._alphaTestQueue=new uk(t),this._transparentQueue=new uk(t),this._cascadedShadowCaster=new uX(e),this._renderPassArray=[],this._defaultPass=new uK("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 uK(e,t,n,r,i);this._renderPassArray.push(a)}else sR(e,uK)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},rv.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):sR(e,uK)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},rv.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},rv.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},rv.render=function(t,n,r){var i,a=this._camera,o=a.scene,s=this._opaqueQueue,l=this._alphaTestQueue,u=this._transparentQueue;a.engine._spriteMaskManager.clear(),o.castShadows&&(null==(i=o._sunLight)?void 0:i.shadowType)!==e.ShadowType.None&&this._cascadedShadowCaster._render(t),s.clear(),l.clear(),u.clear(),this._allSpriteMasks.length=0,t.applyVirtualCamera(a._virtualCamera),this._callRender(t),s.sort(uk._compareFromNearToFar),l.sort(uk._compareFromNearToFar),u.sort(uk._compareFromFarToNear);for(var c=0,h=this._renderPassArray.length;c<h;c++)this._drawRenderPass(t,this._renderPassArray[c],a,n,r)},rv._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,u=r.scene.background,c=l._hardwareRenderer,h=r.renderTarget||n.renderTarget;c.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:u.solidColor;d!==e.CameraClearFlags.None&&c.clearRenderTarget(r.engine,d,_),n.renderOverride?n.render(r,this._opaqueQueue,this._alphaTestQueue,this._transparentQueue):(this._opaqueQueue.render(r,n.replaceMaterial,n.mask,null),this._alphaTestQueue.render(r,n.replaceMaterial,n.mask,null),r.clearFlags&e.CameraClearFlags.Color&&(u.mode===e.BackgroundMode.Sky?u.sky._render(t):u.mode===e.BackgroundMode.Texture&&u.texture&&this._drawBackgroundTexture(l,u)),this._transparentQueue.render(r,n.replaceMaterial,n.mask,null)),null==h||h._blitRenderTarget(),null==h||h.generateMipmaps()}n.postRender(r,this._opaqueQueue,this._alphaTestQueue,this._transparentQueue)},rv.pushPrimitive=function(t){switch(t.renderState.renderQueueType){case e.RenderQueueType.Transparent:this._transparentQueue.pushPrimitive(t);break;case e.RenderQueueType.AlphaTest:this._alphaTestQueue.pushPrimitive(t);break;case e.RenderQueueType.Opaque:this._opaqueQueue.pushPrimitive(t)}},rv._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.passes[0]._getShaderProgram(t,s3._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},rv._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))}},sb(rm,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rm);uq._tempVector0=new sl,uq._tempVector1=new sl;var uY=function(){};uY.tempVec4=new sy,uY.tempVec3=new sl,uY.tempVec2=new sv,e.Camera=(sM(ry=function(t){(n=lv.call(this,t)||this).priority=0,n.enableFrustumCulling=!0,n.clearFlags=e.CameraClearFlags.All,n.cullingMask=e.Layer.Everything,n._globalShaderMacro=new sq,n._frustum=new s_,n._virtualCamera=new uG,n._shaderData=new lK(oE.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 sy(0,0,1,1),n._inverseProjectionMatrix=new sg,n._lastAspectSize=new sv(0,0),n._invViewProjMat=new sg;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 uq(sS(n)),n.shaderData._addRefCount(1),n},lv),(rx=ry.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rx.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rx.worldToViewportPoint=function(e,t){var n=uY.tempVec3,r=uY.tempVec4;sl.transformCoordinate(e,this.viewMatrix,n),sl.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},rx.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},rx.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 sl.subtract(i,r,i),i.normalize(),t},rx.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},rx.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},rx.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rx.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rx.screenPointToRay=function(e,t){var n=uY.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rx.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;sg.multiply(this.projectionMatrix,this.viewMatrix,r.viewProjectionMatrix),r.position.copyFrom(i.worldPosition),r.isOrthographic&&i.getWorldForward(r.forward),n.camera=this,n.virtualCamera=r,this.enableFrustumCulling&&(this._frustumViewChangeFlag.flag||this._isFrustumProjectDirty)&&(this._frustum.calculateFromMatrix(r.viewProjectionMatrix),this._frustumViewChangeFlag.flag=!1,this._isFrustumProjectDirty=!1),this._updateShaderData(),sq.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,sj.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rx._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rx._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rx._onDestroy=function(){var e;null==(e=this._renderPipeline)||e.destroy(),this._isInvViewProjDirty.destroy(),this._isViewMatrixDirty.destroy(),this.shaderData._addRefCount(-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},rx._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rx._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uY.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sl.transformCoordinate(a,r,i),i},rx._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rx._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,sg.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rx._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,sg.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},sb(ry,[{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;sg.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;sg.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else sg.perspective(ss.degreeToRadian(this._fieldOfView),r,this._nearClipPlane,this._farClipPlane,t);return t},set:function(e){this._virtualCamera.projectionMatrix.copyFrom(e),this._isProjMatSetting=!0,this._projMatChange()}},{key:"enableHDR",get:function(){return console.log("not implementation"),!1},set:function(e){console.log("not implementation")}},{key:"renderTarget",get:function(){return this._renderTarget},set:function(e){this._renderTarget=e}}]),(oW=ry)._inverseViewMatrixProperty=s3.getPropertyByName("u_viewInvMat"),oW._cameraPositionProperty=s3.getPropertyByName("u_cameraPos"),oW),sE([sI],e.Camera.prototype,"_frustum",void 0),sE([sL],e.Camera.prototype,"_renderPipeline",void 0),sE([sL],e.Camera.prototype,"_virtualCamera",void 0),sE([sL],e.Camera.prototype,"_frustumViewChangeFlag",void 0),sE([sL],e.Camera.prototype,"_transform",void 0),sE([sL],e.Camera.prototype,"_isViewMatrixDirty",void 0),sE([sL],e.Camera.prototype,"_isInvViewProjDirty",void 0),sE([sI],e.Camera.prototype,"_viewport",void 0),sE([sI],e.Camera.prototype,"_inverseProjectionMatrix",void 0),sE([sI],e.Camera.prototype,"_lastAspectSize",void 0),sE([sI],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=sE([lg(lx)],e.Camera);var uQ={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uJ=1/0;function uZ(e,t){return void 0===t&&(t={}),new lo(function(n,r,i){var a,o,s,l,u,c=null!=(a=t.retryCount)?a:1,h=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:uJ,t.type=null!=(l=t.type)?l:uQ[e.substring(e.lastIndexOf(".")+1)];var d="image"===t.type?u$:u0,_=new u1(function(){return d(e,t).onProgress(i).then(function(e){n(e),_.stop()}).catch(function(e){return u=e})},c,h);_.start(function(){r(u)})})}function u$(e,t){return new lo(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 u0(e,t){return new lo(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 u1=((rC=(rT=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()},rC.stop=function(){clearTimeout(this._timeoutId)},rC.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)})},rT),u2=((rS=function(e){this.useCache=e,this.request=uZ}).registerClass=function(e,t){this._engineObjects[e]=t},rS.getClass=function(e){return this._engineObjects[e]},rS);u2._engineObjects={},e.AssetType=void 0,(rw=e.AssetType||(e.AssetType={})).Text="text",rw.JSON="json",rw.Buffer="buffer",rw.Texture2D="texture2d",rw.TextureCube="texture-cube",rw.Material="material",rw.Mesh="mesh",rw.AnimationClip="AnimationClip",rw.AnimatorController="AnimatorController",rw.Prefab="prefab",rw.KTX="ktx",rw.KTXCube="ktx-cube",rw.Sprite="sprite",rw.SpriteAtlas="sprite-atlas",rw.Env="environment",rw.Scene="scene",rw.HDR="HDR",rw.Font="font",rw.SourceFont="source-font",e.BlendMode=void 0,(rb=e.BlendMode||(e.BlendMode={}))[rb.Normal=0]="Normal",rb[rb.Additive=1]="Additive",e.RenderFace=void 0,(rA=e.RenderFace||(e.RenderFace={}))[rA.Front=0]="Front",rA[rA.Back=1]="Back",rA[rA.Double=2]="Double";var u3=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}sM(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},sb(n,[{key:"shader",get:function(){return this._shader},set:function(t){this._shader=t;var n=this._renderStates,r=n.length,i=t.passes.length;if(r<i)for(var a=r;a<i;a++)n.push(new l4),this.setBlendMode(a,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}(l5);u3._baseColorProp=s3.getPropertyByName("u_baseColor"),u3._baseTextureProp=s3.getPropertyByName("u_baseTexture"),u3._baseTextureMacro=s3.getMacroByName("BASETEXTURE"),u3._tilingOffsetProp=s3.getPropertyByName("u_tilingOffset"),u3._normalTextureProp=s3.getPropertyByName("u_normalTexture"),u3._normalIntensityProp=s3.getPropertyByName("u_normalIntensity"),u3._normalTextureMacro=s3.getMacroByName("NORMALTEXTURE"),u3._emissiveColorProp=s3.getPropertyByName("u_emissiveColor"),u3._emissiveTextureProp=s3.getPropertyByName("u_emissiveTexture"),u3._emissiveTextureMacro=s3.getMacroByName("EMISSIVETEXTURE"),u3._transparentMacro=s3.getMacroByName("OASIS_TRANSPARENT"),u3._alphaCutoffProp=s3.getPropertyByName("u_alphaCutoff"),u3._alphaCutoffMacro=s3.getMacroByName("ALPHA_CUTOFF");var u4=function(e){function t(n){var r,i=(r=e.call(this,n,s3.find("blinn-phong"))||this).shaderData;return i.enableMacro("O3_NEED_WORLDPOS"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new sx(1,1,1,1)),i.setColor(t._specularColorProp,new sx(1,1,1,1)),i.setColor(t._emissiveColorProp,new sx(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new sy(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return sM(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sb(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("O3_SPECULAR_TEXTURE"):this.shaderData.disableMacro("O3_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}(u3);u4._specularColorProp=s3.getPropertyByName("u_specularColor"),u4._shininessProp=s3.getPropertyByName("u_shininess"),u4._specularTextureProp=s3.getPropertyByName("u_specularTexture"),e.TextureCoordinate=void 0,(rM=e.TextureCoordinate||(e.TextureCoordinate={}))[rM.UV0=0]="UV0",rM[rM.UV1=1]="UV1",rM[rM.UV2=2]="UV2",rM[rM.UV3=3]="UV3",rM[rM.UV4=4]="UV4",rM[rM.UV5=5]="UV5",rM[rM.UV6=6]="UV6",rM[rM.UV7=7]="UV7";var u5=function(t){function n(r,i){var a,o=(a=t.call(this,r,i)||this).shaderData;return o.enableMacro("O3_NEED_WORLDPOS"),o.enableMacro("O3_NEED_TILINGOFFSET"),o.setColor(n._baseColorProp,new sx(1,1,1,1)),o.setColor(n._emissiveColorProp,new sx(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new sy(1,1,0,0)),o.setFloat(n._normalIntensityProp,1),o.setFloat(n._occlusionTextureIntensityProp,1),o.setFloat(n._occlusionTextureCoordProp,e.TextureCoordinate.UV0),o.setFloat(n._clearCoatProp,0),o.setFloat(n._clearCoatRoughnessProp,0),a}return sM(n,t),sb(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("OCCLUSIONTEXTURE"):this.shaderData.disableMacro("OCCLUSIONTEXTURE")}},{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&&sj.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("CLEARCOAT"):this.shaderData.enableMacro("CLEARCOAT")),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("HAS_CLEARCOATTEXTURE"):this.shaderData.disableMacro("HAS_CLEARCOATTEXTURE")}},{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("HAS_CLEARCOATROUGHNESSTEXTURE"):this.shaderData.disableMacro("HAS_CLEARCOATROUGHNESSTEXTURE")}},{key:"clearCoatNormalTexture",get:function(){return this.shaderData.getTexture(n._clearCoatNormalTextureProp)},set:function(e){this.shaderData.setTexture(n._clearCoatNormalTextureProp,e),e?this.shaderData.enableMacro("HAS_CLEARCOATNORMALTEXTURE"):this.shaderData.disableMacro("HAS_CLEARCOATNORMALTEXTURE")}}]),n}(u3);u5._occlusionTextureIntensityProp=s3.getPropertyByName("u_occlusionIntensity"),u5._occlusionTextureCoordProp=s3.getPropertyByName("u_occlusionTextureCoord"),u5._occlusionTextureProp=s3.getPropertyByName("u_occlusionTexture"),u5._clearCoatProp=s3.getPropertyByName("u_clearCoat"),u5._clearCoatTextureProp=s3.getPropertyByName("u_clearCoatTexture"),u5._clearCoatRoughnessProp=s3.getPropertyByName("u_clearCoatRoughness"),u5._clearCoatRoughnessTextureProp=s3.getPropertyByName("u_clearCoatRoughnessTexture"),u5._clearCoatNormalTextureProp=s3.getPropertyByName("u_clearCoatNormalTexture");var u8=function(e){function t(n){var r;return(r=e.call(this,n,s3.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return sM(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sb(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("ROUGHNESSMETALLICTEXTURE"):this.shaderData.disableMacro("ROUGHNESSMETALLICTEXTURE")}}]),t}(u5);u8._metallicProp=s3.getPropertyByName("u_metal"),u8._roughnessProp=s3.getPropertyByName("u_roughness"),u8._roughnessMetallicTextureProp=s3.getPropertyByName("u_roughnessMetallicTexture"),u8._iorProp=s3.getPropertyByName("material_IOR");var u6=function(e){function t(n){var r;return(r=e.call(this,n,s3.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new sx(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return sM(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sb(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}(u5);u6._specularColorProp=s3.getPropertyByName("u_PBRSpecularColor"),u6._glossinessProp=s3.getPropertyByName("u_glossiness"),u6._specularGlossinessTextureProp=s3.getPropertyByName("u_specularGlossinessTexture"),u6._specularGlossinessTextureMacro=s3.getMacroByName("SPECULARGLOSSINESSTEXTURE");var u7=function(e){function t(n){var r,i=(r=e.call(this,n,s3.find("unlit"))||this).shaderData;return i.enableMacro("OMIT_NORMAL"),i.enableMacro("O3_NEED_TILINGOFFSET"),i.setColor(t._baseColorProp,new sx(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new sy(1,1,0,0)),r}return sM(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},sb(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}(u3);e.TextHorizontalAlignment=void 0,(rF=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[rF.Left=0]="Left",rF[rF.Center=1]="Center",rF[rF.Right=2]="Right",e.TextVerticalAlignment=void 0,(rP=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[rP.Top=0]="Top",rP[rP.Center=1]="Center",rP[rP.Bottom=2]="Bottom",e.OverflowMode=void 0,(rE=e.OverflowMode||(e.OverflowMode={}))[rE.Overflow=0]="Overflow",rE[rE.Truncate=1]="Truncate",e.FontStyle=void 0,(rR=e.FontStyle||(e.FontStyle={}))[rR.None=0]="None",rR[rR.Bold=1]="Bold",rR[rR.Italic=2]="Italic";var u9=(sM(rL=function(e){var t;return(t=sU.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},sU),(rB=rL.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},rB.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},rB._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},rB._onDestroy=function(){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},sb(rL,[{key:"sprites",get:function(){return this._sprites}}]),rL);e.SpriteDrawMode=void 0,(rD=e.SpriteDrawMode||(e.SpriteDrawMode={}))[rD.Simple=0]="Simple",rD[rD.Sliced=1]="Sliced";var ce=(sM(rI=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=sU.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new sv,new sv,new sv,new sv],o._uvs=[new sv,new sv,new sv,new sv],o._bounds=new sc,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new sT(0,0,1,1),o._atlasRegionOffset=new sy(0,0,0,0),o._region=new sT(0,0,1,1),o._pivot=new sv(.5,.5),o._border=new sy(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new ly,o._texture=t,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},sU),(rO=rI.prototype).clone=function(){var e=new rI(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},rO._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},rO._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},rO._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},rO._addRefCount=function(e){var t;sU.prototype._addRefCount.call(this,e),null==(t=this._atlas)||t._addRefCount(e)},rO._onDestroy=function(){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},rO._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/uU._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},rO._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,u=1-Math.max(e.y-(1-r-a),0)/a,c=this._positions;c[0].set(o,s),c[1].set(l,s),c[2].set(o,u),c[3].set(l,u);var h=this._bounds,d=h.min,_=h.max;d.set(o,s,0),_.set(l,u,0),this._dirtyUpdateFlag&=-2},rO._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,u=this._atlasRegion,c=u.x,h=u.y,d=u.width,_=u.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+c,_+h-Math.max(i-m,0)*y),e[1].set((r-f+T*a)*v+c,_+h-(i-m+C*o)*y),e[2].set(d+c-(s-g+S*a)*v,(l-p+w*o)*y+h),e[3].set(d+c-Math.max(s-g,0)*v,Math.max(l-p,0)*y+h),this._dirtyUpdateFlag&=-3},rO._dispatchSpriteChange=function(e){switch(e){case oV.texture:this._dirtyUpdateFlag|=4;break;case oV.atlasRegionOffset:case oV.region:this._dirtyUpdateFlag|=7;break;case oV.atlasRegion:this._dirtyUpdateFlag|=6;break;case oV.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},sb(rI,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(oV.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(oV.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(oV.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(oV.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=ss.clamp(e.x,0,1),n=ss.clamp(e.y,0,1);this._atlasRegion.set(t,n,ss.clamp(e.width,0,1-t),ss.clamp(e.height,0,1-n)),this._dispatchSpriteChange(oV.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(oV.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=ss.clamp(e.x,0,1),n=ss.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,ss.clamp(e.z,0,1-t),ss.clamp(e.w,0,1-n)),this._dispatchSpriteChange(oV.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(oV.size)}},{key:"region",get:function(){return this._region},set:function(e){var t=this._region,n=ss.clamp(e.x,0,1),r=ss.clamp(e.y,0,1);t.set(n,r,ss.clamp(e.width,0,1-n),ss.clamp(e.height,0,1-r)),this._dispatchSpriteChange(oV.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(oV.size)}},{key:"pivot",get:function(){return this._pivot},set:function(e){var t=this._pivot;if(t===e)this._dispatchSpriteChange(oV.pivot);else{var n=e.x,r=e.y;(t.x!==n||t.y!==r)&&(t.set(n,r),this._dispatchSpriteChange(oV.pivot))}}},{key:"border",get:function(){return this._border},set:function(e){var t=this._border,n=ss.clamp(e.x,0,1),r=ss.clamp(e.y,0,1);t.set(n,r,ss.clamp(e.z,0,1-n),ss.clamp(e.w,0,1-r)),this._dispatchSpriteChange(oV.border)}}]),rI);(rV=oX||(oX={}))[rV.positions=1]="positions",rV[rV.uvs=2]="uvs",rV[rV.automaticSize=4]="automaticSize",rV[rV.all=7]="all";var ct=((rU=function(){}).resetData=function(e){var t=e._renderData,n=t.positions,r=t.uvs;if(n.length<16)for(var i=n.length;i<16;i++)n.push(new sl),r.push(new sv);t.triangles=[]},rU.updatePositions=function(e){var t,n,r=e.width,i=e.height,a=e.sprite,o=e._renderData,s=o.positions,l=o.uvs,u=o.triangles,c=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*c.x,C=x*c.y,S=y*c.z,w=x*c.w;if(T+S>r){var b=r/(T+S);t=[y*f*b,T*b,T*b,r-y*(1-m)*b]}else t=[y*f,T,r-S,r-y*(1-m)];if(w+C>i){var A=i/(w+C);n=[x*p*A,C*A,C*A,i-x*(1-v)*A]}else n=[x*p,C,i-w,i-x*(1-v)];var M=e.sprite.pivot,F=M.x,P=M.y,E=e.width*F,R=e.height*P,L=ct._worldMatrix,B=L.elements,D=e.entity.transform.worldMatrix.elements,I=e.flipX?-1:1,O=e.flipY?-1:1;B[0]=D[0]*I,B[1]=D[1]*I,B[2]=D[2]*I,B[4]=D[4]*O,B[5]=D[5]*O,B[6]=D[6]*O,B[8]=D[8],B[9]=D[9],B[10]=D[10],B[12]=D[12]-E*B[0]-R*B[4],B[13]=D[13]-E*B[1]-R*B[5],B[14]=D[14]-E*B[2]-R*B[6];for(var V=0,U=0,z=0;z<4;z++){for(var N=t[z],k=h[z].x,G=0;G<4;G++){var H=n[G];s[V].set(B[0]*N+B[4]*H+B[12],B[1]*N+B[5]*H+B[13],B[2]*N+B[6]*H+B[14]),l[V].set(k,h[G].y),++V}++U}for(var W=V/U,X=0,j=0;j<U-1;++j)for(var K=0;K<W-1;++K){var q=j*W+K;u[X++]=q,u[X++]=q+1,u[X++]=q+W,u[X++]=q+1,u[X++]=q+W+1,u[X++]=q+W}e._renderData.vertexCount=U*W,u.length=(U-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)},rU.updateUVs=function(e){},rU._worldMatrix=new sg,rU);ct=sE([un()],ct);var cn=(rz=e.Renderer,sM(rN=function(t){var n;return(n=rz.call(this,t)||this)._color=new sx(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._renderData=new ui(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(sS(n)),n},rz),(rk=rN.prototype)._cloneTo=function(e){rz.prototype._cloneTo.call(this,e),e.sprite=this._sprite,e.drawMode=this._drawMode},rk._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},rk._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&oI.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~oI.WorldVolume),2&this._dirtyUpdateFlag&&(this._assembler.updateUVs(this),this._dirtyUpdateFlag&=-3);for(var t,n=this.getMaterial(),r=n.shader.passes,i=n.renderStates,a=this.sprite.texture,o=0,s=r.length;o<s;o++){var l=this._engine._spriteElementPool.getFromPool();l.setValue(this,this._renderData,n,a,i[o],r[o]),e.camera._renderPipeline.pushPrimitive(l)}}},rk._onDestroy=function(){rz.prototype._onDestroy.call(this);var e=this._sprite;e&&(e._addRefCount(-1),e._updateFlagManager.removeListener(this._onSpriteChange)),this._entity=null,this._color=null,this._sprite=null,this._assembler=null,this._renderData=null},rk._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},rk._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}},rk._onSpriteChange=function(t){switch(t){case oV.texture:this.shaderData.setTexture(rN._textureProperty,this.sprite.texture);break;case oV.size:this._dirtyUpdateFlag|=4,(this._drawMode===e.SpriteDrawMode.Sliced||void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=oI.WorldVolume);break;case oV.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case oV.region:case oV.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case oV.atlasRegion:this._dirtyUpdateFlag|=2;break;case oV.pivot:this._dirtyUpdateFlag|=oI.WorldVolume}},sb(rN,[{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=ur;break;case e.SpriteDrawMode.Sliced:this._assembler=ct}this._assembler.resetData(this),this._dirtyUpdateFlag|=3}}},{key:"sprite",get:function(){return this._sprite},set:function(e){var t=this._sprite;t!==e&&(t&&(t._addRefCount(-1),t._updateFlagManager.removeListener(this._onSpriteChange)),this._dirtyUpdateFlag|=7,e?(e._addRefCount(1),e._updateFlagManager.addListener(this._onSpriteChange),this.shaderData.setTexture(rN._textureProperty,e.texture)):this.shaderData.setTexture(rN._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|=oI.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|=oI.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=oI.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=oI.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())}}]),rN);cn._textureProperty=s3.getPropertyByName("u_spriteTexture"),sE([sL],cn.prototype,"_renderData",void 0),sE([sL],cn.prototype,"_drawMode",void 0),sE([sL],cn.prototype,"_assembler",void 0),sE([sI],cn.prototype,"_color",void 0),sE([sL],cn.prototype,"_sprite",void 0),sE([sL],cn.prototype,"_automaticWidth",void 0),sE([sL],cn.prototype,"_automaticHeight",void 0),sE([sB],cn.prototype,"_customWidth",void 0),sE([sB],cn.prototype,"_customHeight",void 0),sE([sB],cn.prototype,"_flipX",void 0),sE([sB],cn.prototype,"_flipY",void 0),sE([sB],cn.prototype,"_maskLayer",void 0),sE([sB],cn.prototype,"_maskInteraction",void 0),sE([sL],cn.prototype,"_onSpriteChange",null),(rG=oj||(oj={}))[rG.UV=2]="UV",rG[rG.RenderData=3]="RenderData",rG[rG.AutomaticSize=4]="AutomaticSize",rG[rG.All=7]="All";var cr=function e(){this.localPositions=new sy;var t=[new sl,new sl,new sl,new sl];this.renderData=new ui(4,t,null,e.triangles,null)};cr.triangles=[0,2,1,2,0,3];var ci=((rW=(rH=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},rW.put=function(e){this._elements.push(e)},rH),ca=((rX=function(){}).textContext=function(){var e=rX._textContext;if(!e){try{t=new OffscreenCanvas(0,0)}catch(e){t=document.createElement("canvas")}var t,n=t.getContext("2d");e={canvas:t,context:n},rX._textContext=e}return e},rX.measureFont=function(e){var t=rX._fontSizeInfoCache,n=t[e];return n||(n=rX._measureFontOrChar(e),t[e]=n),n},rX.getNativeFontString=function(t,n,r){var i=r&e.FontStyle.Bold?"bold ":"";return r&e.FontStyle.Italic&&(i+="italic "),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rX._genericFontFamilies.indexOf(t)||(t='"'+t+'"'),i+=n+"px "+t},rX.measureChar=function(e,t){return rX._measureFontOrChar(t,e)},rX.measureTextWithWrap=function(t){for(var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rX.getNativeFontString(a,n,r),s=rX.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=[],c=[],h=[],d=uU._pixelsPerUnit,_=s.size+t.lineSpacing*d,f=t.width*d,p=0,g=l.length;p<g;++p){for(var m=l[p],v="",y=0,x=-1,T=-1,C=0,S=m.length;C<S;++C){var w=m[C],b=rX._getCharInfo(w,o,i),A=b.w,M=b.offsetY,F=.5*b.h,P=F+M,E=F-M;y+A>f?0===y?(u.push(w),c.push(A),h.push({ascent:P,descent:E,size:P+E})):(u.push(v),c.push(y),h.push({ascent:x,descent:T,size:x+T}),v=w,y=b.xAdvance,x=P,T=E):(v+=w,y+=b.xAdvance,x<P&&(x=P),T<E&&(T=E))}y>0&&(u.push(v),c.push(y),h.push({ascent:x,descent:T,size:x+T}))}var R=t.height*d;return t.overflowMode===e.OverflowMode.Overflow&&(R=_*u.length),{width:0,height:R,lines:u,lineWidths:c,lineHeight:_,lineMaxSizes:h}},rX.measureTextWithoutWrap=function(t){var n=t.fontSize,r=t.fontStyle,i=t._subFont,a=t.font.name,o=rX.getNativeFontString(a,n,r),s=rX.measureFont(o),l=t.text.split(/(?:\r\n|\r|\n)/),u=l.length,c=[],h=[],d=uU._pixelsPerUnit,_=s.size+t.lineSpacing*d,f=0,p=t.height*d;t.overflowMode===e.OverflowMode.Overflow&&(p=_*u);for(var g=0;g<u;++g){for(var m=l[g],v=0,y=-1,x=-1,T=0,C=m.length;T<C;++T){var S=rX._getCharInfo(m[T],o,i);v+=S.xAdvance;var w=S.offsetY,b=.5*S.h,A=b+w,M=b-w;y<A&&(y=A),x<M&&(x=M)}c[g]=v,h[g]={ascent:y,descent:x,size:y+x},v>f&&(f=v)}return{width:f,height:p,lines:l,lineWidths:c,lineHeight:_,lineMaxSizes:h}},rX.getNativeFontHash=function(t,n,r){var i=r&e.FontStyle.Bold?"bold":"";return r&e.FontStyle.Italic&&(i+="italic"),/([\"\'])[^\'\"]+\1/.test(t)||-1!=rX._genericFontFamilies.indexOf(t)||(t=""+t),i+=n+"px"+t},rX._measureFontOrChar=function(e,t){void 0===t&&(t="");var n,r=rX.textContext(),i=r.canvas,a=r.context;a.font=e;var o=t||rX._measureString,s=Math.max(1,Math.round(a.measureText(o).width)),l=Math.ceil(a.measureText(rX._measureBaseline).width),u=l*rX._heightMultiplier;l=rX._baselineMultiplier*l|0,i.width=s,i.height=u,a.font=e,a.fillStyle="#000",a.clearRect(0,0,s,u),a.textBaseline="middle",a.fillStyle="#fff",a.fillText(o,0,l);for(var c=a.getImageData(0,0,s,u).data,h=c.length,d=-1,_=-1,f=0,p=0,g=0,m=i.width,v=1/m,y=0;y<h;y+=4)0!==c[y+3]?(n=~~(.25*y*v),-1===d&&(d=n),n>_&&(_=n)):c[y]=c[y+1]=c[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(c.buffer,d*C,g*C)}return{x:0,y:0,w:s,h:g,offsetX:0,offsetY:(f-p)*.5,xAdvance:s,uvs:[new sv,new sv,new sv,new sv],ascent:f,descent:p,index:0,data:T}},rX._getCharInfo=function(e,t,n){var r=n._getCharInfo(e);return r||(r=rX.measureChar(e,t),n._uploadCharTexture(r),n._addCharInfo(e,r)),r},rX);ca._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],ca._measureString="|\xc9q\xc5",ca._measureBaseline="M",ca._heightMultiplier=2,ca._baselineMultiplier=1.4,ca._fontSizeInfoCache={},ca._textContext=null;var co=(rj=e.Renderer,sM(rK=function(t){(n=rj.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new sx(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sc,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;var n,r=sS(n).engine;return n._font=r._textDefaultFont,n._font._addRefCount(1),n.setMaterial(r._spriteDefaultMaterial),n},rj),(rq=rK.prototype)._onDestroy=function(){for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)rK._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addRefCount(-1),this._font=null),this._subFont&&(this._subFont=null),rj.prototype._onDestroy.call(this)},rq._cloneTo=function(e){rj.prototype._cloneTo.call(this,e),e.font=this._font,e._subFont=this._subFont},rq._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},rq._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},rq._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},rq._updateBounds=function(e){sc.transform(this._localBounds,this._entity.transform.worldMatrix,e)},rq._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._spriteElementPool,r=this._engine._textElementPool.getFromPool(),i=r.charElements,a=this.getMaterial(),o=this._charRenderDatas,s=o.length,l=a.shader.passes,u=a.renderStates;r.component=this,r.material=a,i.length=s,r.renderState=u[0];for(var c=0;c<s;++c){var h=o[c],d=n.getFromPool();d.setValue(this,h.renderData,a,h.texture,u[0],l[0]),i[c]=d}t.camera._renderPipeline.pushPrimitive(r)}},rq._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}},rq._resetSubFont=function(){this._subFont=this._font._getSubFont(this.fontSize,this.fontStyle)},rq._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],u=e[13],c=e[14],h=rK._tempVec31.set(a,o,s),d=rK._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+u,x.z=v*i+y*s+c;var T=m[1];sl.scale(d,g.z-v,T),sl.add(x,T,T);var C=m[2];sl.scale(h,g.w-y,C),sl.add(x,C,m[3]),sl.add(T,C,C)}},rq._updateLocalData=function(){var t=this.color,n=this.horizontalAlignment,r=this.verticalAlignment,i=this._charRenderDatas,a=this._localBounds,o=a.min,s=a.max;o.set(0,0,0),s.set(0,0,0);var l=uU._pixelsPerUnit,u=1/l,c=this._subFont,h=.5*(this.width*l),d=this.height*l,_=this.enableWrapping?ca.measureTextWithWrap(this):ca.measureTextWithoutWrap(this),f=_.height,p=_.lines,g=_.lineWidths,m=_.lineHeight,v=_.lineMaxSizes,y=rK._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 b=0,A=Number.MAX_SAFE_INTEGER,M=Number.MAX_SAFE_INTEGER,F=Number.MIN_SAFE_INTEGER,P=Number.MIN_SAFE_INTEGER,E=T-1,R=0;R<T;++R){var L=p[R],B=g[R],D=0;switch(n){case e.TextHorizontalAlignment.Left:D=-h;break;case e.TextHorizontalAlignment.Center:D=-(.5*B);break;case e.TextHorizontalAlignment.Right:D=h-B}for(var I=0,O=L.length-1;I<=O;++I){var V=L[I],U=c._getCharInfo(V);if(U.h>0){var z=i[b]||y.get(),N=z.renderData,k=z.localPositions;z.texture=c._getTextureByIndex(U.index),N.color=t,N.uvs=U.uvs;var G=U.w,H=U.ascent,W=U.descent,X=D*u,j=(D+G)*u,K=(C+H)*u,q=(C-W+1)*u;k.set(X,K,j,q),i[b]=z,b++,0===R&&(P=Math.max(P,K)),R===E&&(M=Math.min(M,q)),0===I&&(A=Math.min(A,X)),I===O&&(F=Math.max(F,j))}D+=U.xAdvance}C-=m}o.set(A,M,0),s.set(F,P,0);var Y=i.length;if(Y>b){for(var Q=b;Q<Y;++Q)y.put(i[Q]);i.length=b}c._getLastIndex()>0&&i.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},rq._onTransformChanged=function(e){rj.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},sb(rK,[{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._addRefCount(-1),e&&e._addRefCount(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}}]),rK);co._charRenderDataPool=new ci(cr,50),co._tempVec30=new sl,co._tempVec31=new sl,sE([sB],co.prototype,"_subFont",void 0),sE([sL],co.prototype,"_charRenderDatas",void 0),sE([sL],co.prototype,"_dirtyFlag",void 0),sE([sI],co.prototype,"_color",void 0),sE([sB],co.prototype,"_text",void 0),sE([sB],co.prototype,"_width",void 0),sE([sB],co.prototype,"_height",void 0),sE([sL],co.prototype,"_localBounds",void 0),sE([sB],co.prototype,"_font",void 0),sE([sB],co.prototype,"_fontSize",void 0),sE([sB],co.prototype,"_fontStyle",void 0),sE([sB],co.prototype,"_lineSpacing",void 0),sE([sB],co.prototype,"_horizontalAlignment",void 0),sE([sB],co.prototype,"_verticalAlignment",void 0),sE([sB],co.prototype,"_enableWrapping",void 0),sE([sB],co.prototype,"_overflowMode",void 0),sE([sB],co.prototype,"_maskInteraction",void 0),sE([sB],co.prototype,"_maskLayer",void 0),(rY=oK||(oK={}))[rY.SubFont=1]="SubFont",rY[rY.LocalPositionBounds=2]="LocalPositionBounds",rY[rY.WorldPosition=4]="WorldPosition",rY[rY.WorldBounds=8]="WorldBounds",rY[rY.MaskInteraction=16]="MaskInteraction",rY[rY.Position=14]="Position",rY[rY.Font=15]="Font";var cs=((rJ=(rQ=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]},rJ.getTargetValue=function(){return this._mounted[this._propertyName]},rJ.setTargetValue=function(e){this._mounted[this._propertyName]=e},rQ),cl=function(){function e(t,n,r,i){this.crossCurveMark=0,this.hasSavedDefaultValue=!1,this.baseEvaluateData={curKeyframeIndex:0,value:null},this.crossEvaluateData={curKeyframeIndex:0,value:null},this.target=t,this.type=n,this.property=r,this.component=t.getComponent(n),this._cureType=i;var a=e.getAssemblerType(n,r);this._assembler=new a,this._assembler.initialize(this),i._isReferenceType&&(this.referenceTargetValue=this._assembler.getTargetValue())}var t=e.prototype;return t.evaluateAndApplyValue=function(e,t,n,r){if(e.keys.length){if(r){var i=e._evaluateAdditive(t,this.baseEvaluateData),a=this._cureType;if(a._isReferenceType)a._additiveValue(i,n,this.referenceTargetValue);else{var o=this._assembler,s=o.getTargetValue(),l=a._additiveValue(i,n,s);o.setTargetValue(l)}}else{var u=e._evaluate(t,this.baseEvaluateData);this._applyValue(u,n)}}},t.crossFadeAndApplyValue=function(e,t,n,r,i,a,o){var s=e&&e.keys.length?o?e._evaluateAdditive(n,this.baseEvaluateData):e._evaluate(n,this.baseEvaluateData):o?this._cureType._getZeroValue(this.baseEvaluateData.value):this.defaultValue,l=t&&t.keys.length?o?t._evaluateAdditive(r,this.crossEvaluateData):t._evaluate(r,this.crossEvaluateData):o?this._cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;this._applyCrossValue(s,l,i,a,o)},t.crossFadeFromPoseAndApplyValue=function(e,t,n,r,i){var a=i?this._cureType._subtractValue(this.fixedPoseValue,this.defaultValue,this.baseEvaluateData.value):this.fixedPoseValue,o=e&&e.keys.length?i?e._evaluateAdditive(t,this.crossEvaluateData):e._evaluate(t,this.crossEvaluateData):i?this._cureType._getZeroValue(this.crossEvaluateData.value):this.defaultValue;this._applyCrossValue(a,o,n,r,i)},t.revertDefaultValue=function(){this._assembler.setTargetValue(this.defaultValue)},t.saveDefaultValue=function(){this._cureType._isReferenceType?this._cureType._copyValue(this.referenceTargetValue,this.defaultValue):this.defaultValue=this._assembler.getTargetValue(),this.hasSavedDefaultValue=!0},t.saveFixedPoseValue=function(){this._cureType._isReferenceType?this._cureType._copyValue(this.referenceTargetValue,this.fixedPoseValue):this.fixedPoseValue=this._assembler.getTargetValue()},t._applyValue=function(e,t){if(1===t)this._cureType._isReferenceType?this._cureType._copyValue(e,this.referenceTargetValue):this._assembler.setTargetValue(e);else if(this._cureType._isReferenceType){var n=this.referenceTargetValue;this._cureType._lerpValue(n,e,t,n)}else{var r=this._assembler.getTargetValue(),i=this._cureType._lerpValue(r,e,t);this._assembler.setTargetValue(i)}},t._applyCrossValue=function(e,t,n,r,i){var a;if(this._cureType._isReferenceType?(a=this.baseEvaluateData.value,this._cureType._lerpValue(e,t,n,a)):a=this._cureType._lerpValue(e,t,n),i){if(this._cureType._isReferenceType)this._cureType._additiveValue(a,r,this.referenceTargetValue);else{var o=this._assembler.getTargetValue(),s=this._cureType._additiveValue(a,r,o);this._assembler.setTargetValue(s)}}else this._applyValue(a,r)},e.registerAssembler=function(t,n,r){var i=e._assemblerMap.get(t);i||(i={},e._assemblerMap.set(t,i)),i[n]=r},e.getAssemblerType=function(t,n){var r=e._assemblerMap.get(t),i=r?r[n]:void 0;return null!=i?i:cs},e}();cl._assemblerMap=new Map;var cu=((r$=(rZ=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},r$.getTargetValue=function(){return this._transform.position},r$.setTargetValue=function(e){this._transform.position=e},rZ);cl.registerAssembler(lx,"position",cu);var cc=((r1=(r0=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},r1.getTargetValue=function(){return this._transform.rotationQuaternion},r1.setTargetValue=function(e){this._transform.rotationQuaternion=e},r0);cl.registerAssembler(lx,"rotationQuaternion",cc);var ch=((r3=(r2=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},r3.getTargetValue=function(){return this._transform.scale},r3.setTargetValue=function(e){this._transform.scale=e},r2);cl.registerAssembler(lx,"scale",ch);var cd=((r5=(r4=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(uT)},r5.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},r5.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},r4);cl.registerAssembler(uT,"blendShapeWeights",cd);var c_=((r6=(r8=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new cl(e,this.type,this.property,t);return t._initializeOwner(n),n},r6._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},r8),cf=function(){},cp=((r9=(r7=function(e){this.name=e,this._curveBindings=[],this._length=0,this._events=[]}).prototype).addEvent=function(e,t,n){if("string"==typeof e){var r=new cf;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})},r9.clearEvents=function(){this._events.length=0},r9.addCurveBinding=function(e,t,n,r){var i=new c_;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},r9.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},r9._sampleAnimation=function(e,t){for(var n=this._curveBindings,r=n.length-1;r>=0;r--){var i=n[r],a=e.findByPath(i.relativePath);a&&i._getTempCurveOwner(a).evaluateAndApplyValue(i.curve,t,1,!1)}},sb(r7,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),r7);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 cg=((ir=(it=function(){this.keys=[],this._evaluateData={curKeyframeIndex:0,value:null},this._length=0;var t=this.constructor;this._interpolation=t._isInterpolationType?e.InterpolationType.Linear:e.InterpolationType.Step,this._type=t}).prototype).addKey=function(e){var t=e.time,n=this.keys;if(t>=this._length)n.push(e),this._length=t;else{for(var r=n.length;--r>=0&&t<n[r].time;);n.splice(r+1,0,e)}},ir.evaluate=function(e){return this._evaluate(e,this._evaluateData)},ir.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},ir._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 u=a[s],c=a[l],h=u.time,d=c.time-h,_=(t-h)/d;switch(o){case e.InterpolationType.Linear:r=this._type._lerpValue(u.value,c.value,_,n.value);break;case e.InterpolationType.Step:r=this._type._copyValue(u.value,n.value);break;case e.InterpolationType.CubicSpine:case e.InterpolationType.Hermite:r=this._type._hermiteInterpolationValue(u,c,_,d,n.value)}}return r},ir._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},sb(it,[{key:"interpolation",get:function(){return this._interpolation},set:function(t){this._type._isInterpolationType||t===e.InterpolationType.Step?this._interpolation=t:(this._interpolation=e.InterpolationType.Step,console.warn("The interpolation type must be `InterpolationType.Step`."))}},{key:"length",get:function(){return this._length}}]),it);e.AnimationArrayCurve=(sM(ii=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=[],e},cg),ii._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},ii._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},ii._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},ii._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},ii._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},ii._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},ii._hermiteInterpolationValue=function(e,t,n,r,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(oq=ii)._isReferenceType=!0,oq._isInterpolationType=!0,oq),e.AnimationArrayCurve=sE([un()],e.AnimationArrayCurve),e.AnimationBoolCurve=(sM(ia=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=!1,e},cg),ia._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},ia._lerpValue=function(e,t){return t},ia._subtractValue=function(e,t,n){return e},ia._getZeroValue=function(){return!1},ia._additiveValue=function(e,t,n){return e},ia._copyValue=function(e){return e},ia._hermiteInterpolationValue=function(e){return e.value},(oY=ia)._isReferenceType=!1,oY._isInterpolationType=!1,oY),e.AnimationBoolCurve=sE([un()],e.AnimationBoolCurve),e.AnimationColorCurve=(sM(io=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=new sx,e},cg),io._initializeOwner=function(e){e.defaultValue=new sx,e.fixedPoseValue=new sx,e.baseEvaluateData.value=new sx,e.crossEvaluateData.value=new sx},io._lerpValue=function(e,t,n,r){return sx.lerp(e,t,n,r),r},io._subtractValue=function(e,t,n){return sx.subtract(e,t,n),n},io._getZeroValue=function(e){return e.set(0,0,0,0),e},io._additiveValue=function(e,t,n){return sx.scale(e,t,e),sx.add(n,e,n),n},io._copyValue=function(e,t){return t.copyFrom(e),t},io._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(oQ=io)._isReferenceType=!0,oQ._isInterpolationType=!0,oQ),e.AnimationColorCurve=sE([un()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(sM(is=function(){return cg.apply(this,arguments)},cg),is.prototype.addKey=function(e){cg.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)}},is._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)},is._lerpValue=function(e,t,n,r){for(var i=0,a=r.length;i<a;++i){var o=e[i];r[i]=o+(t[i]-o)*n}return r},is._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},is._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},is._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},is._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},is._hermiteInterpolationValue=function(e,t,n,r,i){for(var a=e.outTangent,o=t.inTangent,s=e.value,l=t.value,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(oJ=is)._isReferenceType=!0,oJ._isInterpolationType=!0,oJ),e.AnimationFloatArrayCurve=sE([un()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(sM(il=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=0,e},cg),il._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},il._lerpValue=function(e,t,n){return e+(t-e)*n},il._additiveValue=function(e,t,n){return n+e*t},il._subtractValue=function(e,t){return e-t},il._getZeroValue=function(){return 0},il._copyValue=function(e){return e},il._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},(oZ=il)._isReferenceType=!1,oZ._isInterpolationType=!0,oZ),e.AnimationFloatCurve=sE([un()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(sM(iu=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=new sp,e},cg),iu._initializeOwner=function(e){e.defaultValue=new sp,e.fixedPoseValue=new sp,e.baseEvaluateData.value=new sp,e.crossEvaluateData.value=new sp},iu._lerpValue=function(e,t,n,r){return sp.slerp(e,t,n,r),r},iu._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},iu._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return sp.conjugate(n,i),sp.multiply(i,t,r),r},iu._getZeroValue=function(e){return e.set(0,0,0,1),e},iu._copyValue=function(e,t){return t.copyFrom(e),t},iu._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(o$=iu)._isInterpolationType=!0,o$._isReferenceType=!0,o$._tempConjugateQuat=new sp,o$),e.AnimationQuaternionCurve=sE([un()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(sM(ic=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=new sv,e},cg),ic._initializeOwner=function(e){e.defaultValue=new sv,e.fixedPoseValue=new sv,e.baseEvaluateData.value=new sv,e.crossEvaluateData.value=new sv},ic._lerpValue=function(e,t,n,r){return sv.lerp(e,t,n,r),r},ic._additiveValue=function(e,t,n){return sv.scale(e,t,e),sv.add(n,e,n),n},ic._subtractValue=function(e,t,n){return sv.subtract(e,t,n),n},ic._getZeroValue=function(e){return e.set(0,0),e},ic._copyValue=function(e,t){return t.copyFrom(e),t},ic._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(o0=ic)._isReferenceType=!0,o0._isInterpolationType=!0,o0),e.AnimationVector2Curve=sE([un()],e.AnimationVector2Curve),e.AnimationVector3Curve=(sM(ih=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=new sl,e},cg),ih._initializeOwner=function(e){e.defaultValue=new sl,e.fixedPoseValue=new sl,e.baseEvaluateData.value=new sl,e.crossEvaluateData.value=new sl},ih._lerpValue=function(e,t,n,r){return sl.lerp(e,t,n,r),r},ih._relativeBaseValue=function(e,t){return sl.subtract(t,e,t),t},ih._additiveValue=function(e,t,n){return sl.scale(e,t,e),sl.add(n,e,n),n},ih._subtractValue=function(e,t,n){return sl.subtract(e,t,n),n},ih._getZeroValue=function(e){return e.set(0,0,0),e},ih._copyValue=function(e,t){return t.copyFrom(e),t},ih._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(o1=ih)._isReferenceType=!0,o1._isInterpolationType=!0,o1),e.AnimationVector3Curve=sE([un()],e.AnimationVector3Curve),e.AnimationVector4Curve=(sM(id=function(){var e;return(e=cg.call(this)||this)._evaluateData.value=new sy,e},cg),id._initializeOwner=function(e){e.defaultValue=new sy,e.fixedPoseValue=new sy,e.baseEvaluateData.value=new sy,e.crossEvaluateData.value=new sy},id._lerpValue=function(e,t,n,r){return sy.lerp(e,t,n,r),r},id._additiveValue=function(e,t,n){return sy.scale(e,t,e),sy.add(n,e,n),n},id._subtractValue=function(e,t,n){return sy.subtract(e,t,n),n},id._getZeroValue=function(e){return e.set(0,0,0,0),e},id._copyValue=function(e,t){return t.copyFrom(e),t},id._hermiteInterpolationValue=function(e,t,n,r,i){var a=e.value,o=e.outTangent,s=t.value,l=t.inTangent,u=n*n,c=u*n,h=2*c-3*u+1,d=c-2*u+n,_=c-u,f=-2*c+3*u,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},(o2=id)._isReferenceType=!0,o2._isInterpolationType=!0,o2),e.AnimationVector4Curve=sE([un()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(i_=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[i_.None=0]="None",i_[i_.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(ip=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[ip.Override=0]="Override",ip[ip.Additive=1]="Additive",(ig=o3||(o3={}))[ig.UnStarted=0]="UnStarted",ig[ig.Playing=1]="Playing",ig[ig.Finished=2]="Finished",(im=o4||(o4={}))[im.Standby=0]="Standby",im[im.Playing=1]="Playing",im[im.CrossFading=2]="CrossFading",im[im.FixedCrossFading=3]="FixedCrossFading";var cm=((iv=function(){this.handlers=[]}).prototype.dispose=function(){this.handlers.length=0},iv),cv=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(iy=e.WrapMode||(e.WrapMode={}))[iy.Once=0]="Once",iy[iy.Loop=1]="Loop";var cy=((iT=(ix=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=o3.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0},iT.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=o3.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=o3.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},ix),cx=((iC=function(){this.animatorStateDataMap={},this.srcPlayData=new cy,this.destPlayData=new cy,this.layerState=o4.Standby,this.crossCurveMark=0,this.manuallyTransition=new cv}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iC),cT=function(){this.curveOwners=[],this.eventHandlers=[]},cC=(sM(iS=function(t){var n;return(n=lv.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._animatorLayersData=[],n._crossOwnerCollection=[],n._animationCurveOwners=[],n._animationEventHandlerPool=new l8(cm),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lv),(iw=iS.prototype).play=function(e,t,n){void 0===t&&(t=-1),void 0===n&&(n=0),(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset();var r,i=this._getAnimatorStateInfo(e,t),a=i.state;if(a){if(!a.clip){console.warn("The state named "+e+" has no AnimationClip data.");return}var o=this._getAnimatorLayerData(i.layerIndex),s=this._getAnimatorStateData(e,a,o);this._preparePlay(o,a,s),o.layerState=o4.Playing,o.srcPlayData.reset(a,s,a._getDuration()*n)}},iw.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)},iw.update=function(t){if(this.cullingMode===e.AnimatorCullingMode.Complete){r=!1;for(var n,r,i=this._controlledRenderers,a=0,o=i.length;a<o;a++)if(!i[a].isCulled){r=!0;break}}else r=!0;var s=this._animatorController;if(s){if(null==(n=this._controllerUpdateFlag)?void 0:n.flag){this._checkAutoPlay();return}t*=this.speed;for(var l=0,u=s.layers.length;l<u;l++)this._getAnimatorLayerData(l).layerState!==o4.Standby&&this._updateLayer(l,0===l,t/1e3,r)}},iw.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},iw.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},iw._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},iw._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},iw._reset=function(){var e=this._animationCurveOwners;for(var t in e){var n=e[t];for(var r in n){var i=n[r];i.hasSavedDefaultValue&&i.revertDefaultValue()}}this._animatorLayersData.length=0,this._crossOwnerCollection.length=0,this._animationCurveOwners.length=0,this._animationEventHandlerPool.resetPool(),this._controllerUpdateFlag&&(this._controllerUpdateFlag.flag=!1)},iw._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},iw._saveDefaultValues=function(e){for(var t,n=e.curveOwners,r=n.length-1;r>=0;r--)null==(t=n[r])||t.saveDefaultValue()},iw._getAnimatorStateData=function(e,t,n){var r=n.animatorStateDataMap,i=r[e];return i||(i=new cT,r[e]=i,this._saveAnimatorStateData(t,i),this._saveAnimatorEventHandlers(t,i)),i},iw._saveAnimatorStateData=function(e,t){for(var n=this.entity,r=this._animationCurveOwners,i=t.curveOwners,a=e.clip._curveBindings,o=a.length-1;o>=0;o--){var s=a[o],l=""===s.relativePath?n:n.findByPath(s.relativePath);if(l){var u=s.property,c=l.instanceId,h=r[c]||(r[c]={});i[o]=h[u]||(h[u]=s._createCurveOwner(l))}else i[o]=null,console.warn("The entity don't have the child entity which path is "+s.relativePath+".")}},iw._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 u=o[s],c=n.getFromPool(),h=u.functionName,d=c.handlers;c.event=u,d.length=0;for(var _=i-1;_>=0;_--){var f=r.get(_)[h];f&&d.push(f)}a.push(c)}},iw._clearCrossData=function(e){e.crossCurveMark++,this._crossOwnerCollection.length=0},iw._addCrossCurveData=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.push(t)},iw._prepareCrossFading=function(e){var t=this._crossOwnerCollection,n=e.crossCurveMark;this._prepareSrcCrossData(t,e.srcPlayData,n,!1),this._prepareDestCrossData(t,e.destPlayData,n,!1)},iw._prepareStandbyCrossFading=function(e){var t=this._crossOwnerCollection,n=e.srcPlayData,r=e.crossCurveMark;n.state&&this._prepareSrcCrossData(t,n,r,!0),this._prepareDestCrossData(t,e.destPlayData,r,!0)},iw._prepareFixedPoseCrossFading=function(e){for(var t=this._crossOwnerCollection,n=t.length-1;n>=0;n--){var r=t[n];r.saveFixedPoseValue(),r.crossDestCurveIndex=-1}this._prepareDestCrossData(t,e.destPlayData,e.crossCurveMark,!0)},iw._prepareSrcCrossData=function(e,t,n,r){for(var i=t.stateData.curveOwners,a=i.length-1;a>=0;a--){var o=i[a];o&&(o.crossCurveMark=n,o.crossCurveDataIndex=e.length,r&&o.saveFixedPoseValue(),this._addCrossCurveData(e,o,a,-1))}},iw._prepareDestCrossData=function(e,t,n,r){for(var i=t.stateData.curveOwners,a=i.length-1;a>=0;a--){var o=i[a];o&&(o.crossCurveMark===n?e[o.crossCurveDataIndex].crossDestCurveIndex=a:(o.saveDefaultValue(),r&&o.saveFixedPoseValue(),o.crossCurveMark=n,o.crossCurveDataIndex=e.length,this._addCrossCurveData(e,o,-1,a)))}},iw._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new cx),t},iw._updateLayer=function(t,n,r,i){var a=this._animatorController.layers[t],o=a.blendingMode,s=a.weight,l=this._animatorLayersData[t],u=l.srcPlayData,c=l.destPlayData,h=l.crossFadeTransition,d=o===e.AnimatorLayerBlendingMode.Additive;switch(n&&(s=1),l.layerState!==o4.FixedCrossFading&&this._checkTransition(u,h,t),l.layerState){case o4.Playing:this._updatePlayingState(u,l,t,s,r,d,i);break;case o4.FixedCrossFading:this._updateCrossFadeFromPose(c,l,t,s,r,d,i);break;case o4.CrossFading:this._updateCrossFade(u,c,l,t,s,r,d,i)}},iw._updatePlayingState=function(e,t,n,r,i,a,o){var s=e.stateData,l=s.curveOwners,u=s.eventHandlers,c=e.state,h=e.playState,d=e.clipTime,_=c.clip._curveBindings;if(e.update(this.speed<0),o){var f=e.clipTime,p=e.playState;u.length&&this._fireAnimationEvents(e,u,d,f);for(var g=_.length-1;g>=0;g--){var m=l[g];null==m||m.evaluateAndApplyValue(_[g].curve,f,r,a)}e.frameTime+=c.speed*i,p===o3.Finished&&(t.layerState=o4.Standby),h===o3.UnStarted&&this._callAnimatorScriptOnEnter(c,n),p===o3.Finished?this._callAnimatorScriptOnExit(c,n):this._callAnimatorScriptOnUpdate(c,n)}},iw._updateCrossFade=function(e,t,n,r,i,a,o,s){var l=this._crossOwnerCollection,u=e.state.clip._curveBindings,c=e.state,h=e.stateData,d=e.playState,_=h.eventHandlers,f=t.state,p=t.stateData,g=t.playState,m=p.eventHandlers,v=f.clip._curveBindings,y=e.clipTime,x=t.clipTime,T=Math.abs(t.frameTime)/(f._getDuration()*n.crossFadeTransition.duration);T>=1&&(T=1),e.update(this.speed<0),t.update(this.speed<0);var C=e.playState,S=t.playState;if(this._updateCrossFadeData(n,T,a,!1),s){var w=e.clipTime,b=t.clipTime;_.length&&this._fireAnimationEvents(e,_,y,w),m.length&&this._fireAnimationEvents(t,m,x,b),d===o3.UnStarted&&this._callAnimatorScriptOnEnter(c,r),1===T||C===o3.Finished?this._callAnimatorScriptOnExit(c,r):this._callAnimatorScriptOnUpdate(c,r),g===o3.UnStarted&&this._callAnimatorScriptOnEnter(f,r),S===o3.Finished?this._callAnimatorScriptOnExit(f,r):this._callAnimatorScriptOnUpdate(f,r);for(var A=l.length-1;A>=0;A--){var M=l[A],F=M.crossSrcCurveIndex,P=M.crossDestCurveIndex;M.crossFadeAndApplyValue(F>=0?u[F].curve:null,P>=0?v[P].curve:null,w,b,T,i,o)}}},iw._updateCrossFadeFromPose=function(e,t,n,r,i,a,o){var s=this._crossOwnerCollection,l=e.state,u=e.stateData,c=e.playState,h=u.eventHandlers,d=l.clip._curveBindings,_=e.clipTime,f=Math.abs(e.frameTime)/(l._getDuration()*t.crossFadeTransition.duration);f>=1&&(f=1),e.update(this.speed<0);var p=e.playState;if(this._updateCrossFadeData(t,f,i,!0),o){var g=e.clipTime;h.length&&this._fireAnimationEvents(e,h,_,g),c===o3.UnStarted&&this._callAnimatorScriptOnEnter(l,n),p===o3.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n);for(var m=s.length-1;m>=0;m--){var v=s[m],y=v.crossDestCurveIndex;v.crossFadeFromPoseAndApplyValue(y>=0?d[y].curve:null,g,f,r,a)}}},iw._updateCrossFadeData=function(e,t,n,r){var i=e.destPlayData;i.frameTime+=i.state.speed*n,1===t?(i.playState===o3.Finished?e.layerState=o4.Standby:e.layerState=o4.Playing,e.switchPlayData(),e.crossFadeTransition=null):r||(e.srcPlayData.frameTime+=e.srcPlayData.state.speed*n)},iw._preparePlay=function(e,t,n){if(e.layerState===o4.Playing){var r=e.srcPlayData;if(r.state!==t){for(var i=r.stateData.curveOwners,a=i.length-1;a>=0;a--){var o=i[a];(null==o?void 0:o.hasSavedDefaultValue)&&o.revertDefaultValue()}this._saveDefaultValues(n)}}else{for(var s=this._crossOwnerCollection,l=s.length-1;l>=0;l--){var u=s[l];u.hasSavedDefaultValue&&u.revertDefaultValue()}this._saveDefaultValues(n)}},iw._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 u=a[s];o*u.exitTime<=i&&t!==u&&this._crossFadeByTransition(u,n)}},iw._crossFadeByTransition=function(e,t){var n=e.destinationState.name,r=this._getAnimatorStateInfo(n,t),i=r.state;if(i){if(!i.clip){console.warn("The state named "+n+" has no AnimationClip data.");return}var a=this._getAnimatorLayerData(r.layerIndex),o=a.layerState,s=a.destPlayData,l=this._getAnimatorStateData(n,i,a),u=i._getDuration()*e.offset;switch(s.reset(i,l,u),o){case o4.Standby:a.layerState=o4.FixedCrossFading,this._clearCrossData(a),this._prepareStandbyCrossFading(a);break;case o4.Playing:a.layerState=o4.CrossFading,this._clearCrossData(a),this._prepareCrossFading(a);break;case o4.CrossFading:a.layerState=o4.FixedCrossFading,this._prepareFixedPoseCrossFading(a);break;case o4.FixedCrossFading:this._prepareFixedPoseCrossFading(a)}a.crossFadeTransition=e}},iw._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)},iw._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,u=s.parameter;if(l>r)break;var c=o.handlers;if(l>=n){for(var h=c.length-1;h>=0;h--)c[h](u);e.currentEventIndex=Math.min(i+1,a-1)}}},iw._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 u=a.handlers,c=u.length-1;c>=0;c--)u[c](l);e.currentEventIndex=Math.max(i-1,0)}}},iw._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},iw._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},iw._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},iw._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)}},sb(iS,[{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)}}]),iS);sE([sB],cC.prototype,"speed",void 0),sE([sL],cC.prototype,"_controllerUpdateFlag",void 0),sE([sL],cC.prototype,"_animatorLayersData",void 0),sE([sL],cC.prototype,"_crossOwnerCollection",void 0),sE([sL],cC.prototype,"_animationCurveOwners",void 0),sE([sL],cC.prototype,"_animationEventHandlerPool",void 0),sE([sL],cC.prototype,"_tempAnimatorStateInfo",void 0),sE([sL],cC.prototype,"_controlledRenderers",void 0);var cS=((iA=(ib=function(){this._updateFlagManager=new ly,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},iA.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},iA.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},iA.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},iA._registerChangeFlag=function(){return this._updateFlagManager.createFlag(lm)},sb(ib,[{key:"layers",get:function(){return this._layers}}]),ib),cw=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},cb=((iF=(iM=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},iF.onStateUpdate=function(e,t,n){},iF.onStateExit=function(e,t,n){},iF.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},iM),cA=((iE=(iP=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)},iE.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},iE.addStateMachineScript=function(e){var t=new e;t._state=this;var n=cb.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},iE.clearTransitions=function(){this._transitions.length=0},iE._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},iE._removeStateMachineScript=function(e){var t=cb.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)}},sb(iP,[{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)}}]),iP),cM=((iL=(iR=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 cA(e),this.states.push(t),this._statesMap[e]=t),t},iL.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},iL.findStateByName=function(e){return this._statesMap[e]},iL.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},iR);e.AnimatorConditionMode=void 0,(iB=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[iB.If=0]="If",iB[iB.IfNot=1]="IfNot",iB[iB.Greater=2]="Greater",iB[iB.Less=3]="Less",iB[iB.Equals=4]="Equals",iB[iB.NotEquals=5]="NotEquals";var cF=function(){},cP=(sM(iD=function(t){var n;return(n=l5.call(this,t,s3.find("skybox"))||this)._decodeParam=new sy(0,5,0,0),n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n.shaderData.setVector4("u_cubeDecodeParam",n._decodeParam),n},l5),sb(iD,[{key:"textureDecodeRGBM",get:function(){return!!this._decodeParam.x},set:function(e){this._decodeParam.x=Number(e)}},{key:"RGBMDecodeFactor",get:function(){return this._decodeParam.y},set:function(e){this._decodeParam.y=e}},{key:"textureCubeMap",get:function(){return this.shaderData.getTexture("u_cube")},set:function(e){this.shaderData.setTexture("u_cube",e)}}]),iD);(iI=o5||(o5={}))[iI.Position=1]="Position",iI[iI.Velocity=2]="Velocity",iI[iI.Acceleration=4]="Acceleration",iI[iI.Color=8]="Color",iI[iI.Alpha=16]="Alpha",iI[iI.Size=32]="Size",iI[iI.StartAngle=64]="StartAngle",iI[iI.StartTime=128]="StartTime",iI[iI.LifeTime=256]="LifeTime",iI[iI.RotateVelocity=512]="RotateVelocity",iI[iI.Scale=1024]="Scale",iI[iI.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(iO=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[iO.Transparent=0]="Transparent",iO[iO.Additive=1]="Additive";var cE=(sM(iV=function(e){var t;return(t=ug.call(this,e)||this)._maxCount=1e3,t._position=new sl,t._positionRandomness=new sl,t._velocity=new sl,t._velocityRandomness=new sl,t._acceleration=new sl,t._accelerationRandomness=new sl,t._color=new sx(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(sS(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},ug),(iU=iV.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/1e3,this.shaderData.setFloat("u_time",this._time)}},iU._onEnable=function(){ug.prototype._onEnable.call(this),this._playOnEnable&&this.start()},iU.start=function(){this._isStart=!0,this._time=0},iU.stop=function(){this._isStart=!1},iU._createMaterial=function(){var t=new l5(this.engine,s3.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},iU._createMesh=function(){var t=new uS(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>iV._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 u=4*s;a[l++]=u,a[l++]=u+1,a[l++]=u+2,a[l++]=u,a[l++]=u+2,a[l++]=u+3}var c=[new us("a_position",0,e.VertexElementFormat.Vector3,0),new us("a_velocity",12,e.VertexElementFormat.Vector3,0),new us("a_acceleration",24,e.VertexElementFormat.Vector3,0),new us("a_color",36,e.VertexElementFormat.Vector4,0),new us("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new us("a_rotation",68,e.VertexElementFormat.Vector2,0),new us("a_uv",76,e.VertexElementFormat.Vector3,0),new us("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new ul(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new ul(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(c),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},iU._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},iU._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=iV._getRandom,a=4*e,o=a*r,s=(a+1)*r,l=(a+2)*r,u=(a+3)*r;if(1&t){var c=this._position,h=c.x,d=c.y,_=c.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[u]=h,n[o+1]=n[s+1]=n[l+1]=n[u+1]=d,n[o+2]=n[s+2]=n[l+2]=n[u+2]=_}if(2&t){var m=this._velocity,v=this._velocityRandomness;n[o+3]=n[s+3]=n[l+3]=n[u+3]=m.x+i()*v.x,n[o+4]=n[s+4]=n[l+4]=n[u+4]=m.y+i()*v.y,n[o+5]=n[s+5]=n[l+5]=n[u+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[u+6]=y.x+i()*x.x,n[o+7]=n[s+7]=n[l+7]=n[u+7]=y.y+i()*x.y,n[o+8]=n[s+8]=n[l+8]=n[u+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[u+9]=ss.clamp(T.r+i()*C,0,1),n[o+10]=n[s+10]=n[l+10]=n[u+10]=ss.clamp(T.g+i()*C,0,1),n[o+11]=n[s+11]=n[l+11]=n[u+11]=ss.clamp(T.b+i()*C,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[u+12]=ss.clamp(this._alpha+i()*this._alphaRandomness,0,1)),128&t&&(n[o+13]=n[s+13]=n[l+13]=n[u+13]=Math.random()*this._startTimeRandomness),256&t){var S=this._lifetime;n[o+14]=n[s+14]=n[l+14]=n[u+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[u+15]=Math.max(w+i()*this._sizeRandomness*w*2,0)}1024&t&&(n[o+16]=n[s+16]=n[l+16]=n[u+16]=this._scale),64&t&&(n[o+17]=n[s+17]=n[l+17]=n[u+17]=this._startAngle+i()*Math.PI*this._startAngleRandomness*2),512&t&&(n[o+18]=n[s+18]=n[l+18]=n[u+18]=this._rotateVelocity+i()*this._rotateVelocityRandomness),this._updateSingleUv(e,o,s,l,u)},iU._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,u=o.height;if(a){var c=a[e%a.length],h=c.x,d=c.y,_=c.w,f=c.h,p=h/l,g=d/u,m=p+_/l,v=g+f/u,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=u/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},iU._onColorChanged=function(){this._updateDirtyFlag|=8},iV._getRandom=function(){return Math.random()-.5},sb(iV,[{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}}]),iV);cE._uint16VertexLimit=65535,sE([sL],cE.prototype,"_onColorChanged",null),s3.create("trail","#define GLSLIFY 1\nattribute vec3 POSITION;attribute vec2 TEXCOORD_0;varying vec2 v_uv;uniform mat4 u_projMat;uniform mat4 u_viewMat;void main(){gl_Position=u_projMat*u_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 cR=(sM(iz=function(t){var n,r=(n=l5.call(this,t,s3.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},l5),iz),cL=new sl,cB=(sM(iN=function(e,t){(n=ug.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 sl),n._pointStates.push(n._lifetime),n._strapPoints.push(new sl),n._strapPoints.push(new sl);n._curPointNum=0;var i=t.material||new cR(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},ug),(ik=iN.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];sl.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++)},ik.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},ik._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),ug.prototype._render.call(this,e)},ik._initGeometry=function(){var t=new uS(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new us("POSITION",0,e.VertexElementFormat.Vector3,0),new us("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new ul(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},ik._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sl(n[0],n[4],n[8]),i=new sl(n[1],n[5],n[9]),a=new sl(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sl,l=new sl,u=new sp;sl.transformByQuat(r,u,r),sl.transformByQuat(i,u,i);var c=new sl,h=new sl,d=new sl;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?sl.subtract(p,t[f-1],d):sl.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sl.dot(r,d));sl.cross(r,d,h),0>=sl.dot(h,a)&&(g=2*Math.PI-g),sp.rotationAxisAngle(a,g,u),sl.transformByQuat(i,u,c),sl.add(p,c,s),sl.subtract(p,c,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}},ik._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}}},ik._projectOnVector=function(e,t,n){var r=t.clone();sl.normalize(r,r);var i=sl.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},ik._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,cL),sl.subtract(e,cL,n)},iN),cD=(sM(iG=function(){var t;return t=uz.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uz),(iH=iG.prototype).onTextureChange=function(e){},iH.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 s9(this.engine,this.width,this.height,this._isCube?new ln(this.engine,this.width):new le(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new s9(this.engine,this.width,this.height,this._isCube?new ln(this.engine,this.width):new le(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},iH.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},iH._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},sb(iG,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),iG),cI=new sl,cO=new sl,cV=new sl,cU=(sM(iW=function(){var e;return e=cD.apply(this,arguments)||this,e.position=new sl(0,0,0),e._isCube=!0,e.oriViewMatrix=new sg,e},cD),(iX=iW.prototype).onBeginRender=function(t){if(this.enabled){cD.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),cD.prototype._reset.call(this)}},iX._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},iX._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},iX._setCamera=function(e,t){switch(e){case 0:cO.set(0,-1,0),cV.set(1,0,0);break;case 1:cO.set(0,-1,0),cV.set(-1,0,0);break;case 2:cO.set(0,0,1),cV.set(0,1,0);break;case 3:cO.set(0,0,-1),cV.set(0,-1,0);break;case 4:cO.set(0,-1,0),cV.set(0,0,1);break;case 5:cO.set(0,-1,0),cV.set(0,0,-1)}sl.add(this.position,cV,cI),sg.lookAt(this.position,cI,cO,t.viewMatrix),t.fieldOfView=90},iW),cz=Object.freeze({__proto__:null,AmbientLight:uL,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:cp,AnimationClipCurveBinding:c_,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:cg,AnimationEvent:cf,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:cC,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:cS,AnimatorControllerLayer:cw,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:cA,AnimatorStateMachine:cM,AnimatorStateTransition:cv,AssetPromise:lo,get AssetType(){return e.AssetType},Background:uR,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:u3,BasicRenderPipeline:uq,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:ub,BlendShapeFrame:uw,BlinnPhongMaterial:u4,BoolUpdateFlag:lm,BoxColliderShape:lE,Buffer:ul,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:uS,get BufferUsage(){return e.BufferUsage},BufferUtil:uo,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:lB,CharacterController:lF,CloneManager:sO,get Collider(){return e.Collider},ColliderShape:lP,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:lv,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:cU,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DiffuseMode(){return e.DiffuseMode},DirectLight:lY,DynamicCollider:lk,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:uU,EngineObject:sV,Entity:lT,Event:sz,EventDispatcher:sN,FixedJoint:lI,get FogMode(){return e.FogMode},Font:la,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:lO,HitResult:lb,IndexBufferBinding:uu,get IndexFormat(){return e.IndexFormat},InputManager:lj,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:lU,JointMotor:lz,Keyframe:cF,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:lq,Loader:u2,Logger:sj,Material:l5,Mesh:uh,MeshRenderElement:l7,MeshRenderer:ug,get MeshTopology(){return e.MeshTopology},ModelMesh:uf,ObjectValues:s6,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:u5,PBRMaterial:u8,PBRSpecularMaterial:u6,ParticleRenderer:cE,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:lA,PhysicsMaterial:lM,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},PlaneColliderShape:lL,get Platform(){return e.Platform},PointLight:lQ,Pointer:lC,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:uC,Probe:cD,RefObject:sU,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uK,RenderQueue:uk,get RenderQueueType(){return e.RenderQueueType},RenderTarget:s9,get Renderer(){return e.Renderer},ResourceManager:ls,Scene:uB,SceneManager:uD,Script:uz,get SetDataOptions(){return e.SetDataOptions},Shader:s3,ShaderData:lK,ShaderFactory:sJ,ShaderPass:s1,ShaderProperty:s2,get ShaderPropertyType(){return e.ShaderPropertyType},get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:up,SkinnedMeshRenderer:uT,Sky:uE,SkyBoxMaterial:cP,SphereColliderShape:lR,SpotLight:lJ,SpringJoint:lV,Sprite:ce,SpriteAtlas:u9,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteElement:ue,SpriteMask:ua,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:cn,StateMachineScript:cb,StaticCollider:lN,get StencilOperation(){return e.StencilOperation},SubMesh:uc,SystemInfo:lS,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:co,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:s7,Texture2D:le,Texture2DArray:lt,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:ln,get TextureCubeFace(){return e.TextureCubeFace},get TextureDepthCompareFunction(){return e.TextureDepthCompareFunction},get TextureFilterMode(){return e.TextureFilterMode},get TextureFormat(){return e.TextureFormat},get TextureWrapMode(){return e.TextureWrapMode},Time:s4,TrailMaterial:cR,TrailRenderer:cB,Transform:lx,UnlitMaterial:u7,Util:s5,VertexBufferBinding:ud,VertexElement:us,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:sB,deepClone:sI,dependentComponents:lg,ignoreClone:sL,request:uZ,resourceLoader:ll,shallowClone:sD});function cN(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 ck(e,t,n){return t&&cN(e.prototype,t),n&&cN(e,n),e}function cG(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(ij=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[ij.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",ij[ij.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",ij[ij.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",ij[ij.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",ij[ij.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",ij[ij.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",ij[ij.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",ij[ij.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",ij[ij.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",ij[ij.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",ij[ij.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",ij[ij.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",ij[ij.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",ij[ij.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",ij[ij.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",ij[ij.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",ij[ij.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",ij[ij.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",ij[ij.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",ij[ij.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",ij[ij.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",ij[ij.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",ij[ij.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",ij[ij.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",ij[ij.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",ij[ij.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",ij[ij.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",ij[ij.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",ij[ij.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",ij[ij.R11_EAC=37488]="R11_EAC",ij[ij.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",ij[ij.RG11_EAC=37490]="RG11_EAC",ij[ij.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",ij[ij.RGB8_ETC2=37492]="RGB8_ETC2",ij[ij.SRGB8_ETC2=37493]="SRGB8_ETC2",ij[ij.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",ij[ij.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",ij[ij.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",ij[ij.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",ij[ij.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",ij[ij.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",ij[ij.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",ij[ij.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",ij[ij.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",ij[ij.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",ij[ij.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",ij[ij.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var cH=((iq=(iK=function(e){this._scale=new sv;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&&cG(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},iq.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},ck(iK,[{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&&cG(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&&cG(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),iK);function cW(e,t){return(cW=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function cX(e,t){if("function"!=typeof t&&null!==t)throw TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&cW(e,t)}function cj(){return(cj=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 cK=((iQ=(iY=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},iQ.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,u=e.GLCompressedTextureInternalFormat.RGB_PVRTC_4BPPV1_IMG,c=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>=u&&t<=c?this.canIUse(e.GLCapabilityType.pvrtc):!!(t>=h)&&!!(t<=d)&&this.canIUse(e.GLCapabilityType.s3tc)},iQ._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,u=e.GLCapabilityType.vertexArrayObject,c=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,b=e.GLCapabilityType.textureFloatLinear,A=e.GLCapabilityType.textureHalfFloatLinear,M=e.GLCapabilityType.WEBGL_colorBufferFloat,F=e.GLCapabilityType.colorBufferFloat,P=e.GLCapabilityType.colorBufferHalfFloat,E=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(u,n||!!r(u)),t.set(c,n||!!r(c)),t.set(h,n),t.set(d,n||!!r(d)),t.set(S,n||!!r(S)),t.set(w,n||!!r(w)),t.set(b,!!r(b)),t.set(A,n||!!r(A)),t.set(F,n&&!!r(F)||!!r(M)),t.set(P,n&&!!r(F)||!!r(P)),t.set(E,!!r(E)),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)))},iQ._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}},iQ._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 u={};if(this.canIUse(e.GLCapabilityType.drawBuffers)){for(var c=this.maxDrawBuffers,h=0;h<c;h++)0!=h&&(u["COLOR_ATTACHMENT"+h]="COLOR_ATTACHMENT"+h+"_WEBGL"),u["DRAW_BUFFER"+h]="DRAW_BUFFER"+h+"_WEBGL";this._compatibleInterface(i,cj({drawBuffers:"drawBuffersWEBGL"},u))}this._compatibleInterface(o,{HALF_FLOAT:"HALF_FLOAT_OES"}),this._compatibleInterface(s,{RGBA16F:"RBGA16F_EXT"}),this._compatibleInterface(l,{RGBA32F:"RBGA32F_EXT"})}this._compatibleInterface(a,{TEXTURE_MAX_ANISOTROPY_EXT:"TEXTURE_MAX_ANISOTROPY_EXT"})},ck(iY,[{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}}]),iY),cq=((iJ=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]},iJ),cY=((i$=(iZ=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,u=r._glIndexByteCount,c=t.topology,h=t.start,d=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)n.drawElementsInstanced(c,d,l,h*u,s);else{var _=o.buffer._nativeBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(c,d,l,h*u,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(c,h,d,s)}else sj.error("ANGLE_instanced_arrays extension is not supported")}else if(o){if(i)n.drawElements(c,d,l,h*u);else{var f=o.buffer._nativeBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f),n.drawElements(c,d,l,h*u),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArrays(c,h,d);i?n.bindVertexArray(null):this._disableAttrib()},i$.destroy=function(){this._useVao&&this._clearVAO()},i$._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 u=o[l];if(-1!==u){var c=s[l];if(c){var h=a[c.bindingIndex],d=h.buffer,_=h.stride;n!==(t=d._nativeBuffer)&&(n=t,r.bindBuffer(r.ARRAY_BUFFER,t)),r.enableVertexAttribArray(u);var f=c._glElementInfo;r.vertexAttribPointer(u,f.size,f.type,f.normalized,_,c.offset),this._canUseInstancedArrays&&r.vertexAttribDivisor(u,c.instanceStepRate),this._attribLocArray.push(u)}else sj.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},i$._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},i$._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._nativeBuffer),this._bindBufferAndAttrib(e),t.bindVertexArray(null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null),this._disableAttrib(),this._vaoMap.set(e.id,n)},i$._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},iZ),cQ=((i0=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]},i0),cJ=((i2=(i1=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},i2.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},i2.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},i2._bind=function(){this._rhi.bindTexture(this)},i2._init=function(e){var t=this._gl,n=this._isWebGL2,r=this._formatDetail,i=r.internalFormat,a=r.baseFormat,o=r.dataType,s=this._texture,l=s.mipmapCount,u=s.width,c=s.height,h=s._isDepthTexture;if(this._bind(),n&&!(a===t.LUMINANCE_ALPHA||a===t.ALPHA))t.texStorage2D(this._target,l,i,u,c);else if(e)for(var d=0;d<l;d++)for(var _=Math.max(1,u>>d),f=0;f<6;f++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+f,d,i,_,_,0,a,o,null);else if(h)t.texImage2D(this._target,0,i,u,c,0,a,o,null);else for(var p=0;p<l;p++){var g=Math.max(1,u>>p),m=Math.max(1,c>>p);t.texImage2D(this._target,p,i,g,m,0,a,o,null)}},i2._getPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,u=l.baseFormat,c=l.dataType;s.bindFramebuffer(s.FRAMEBUFFER,this._getReadFrameBuffer()),a>0&&!this._isWebGL2&&(a=0,sj.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,u,c,o),s.bindFramebuffer(s.FRAMEBUFFER,null)},i2._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||i1._isPowerOf2(s)&&i1._isPowerOf2(l)||(sj.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)}},i2._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},i1._isPowerOf2=function(e){return(e&e-1)==0},i1._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)}},i1._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)}},i1._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},i1._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},i1._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},ck(i1,[{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)}}}]),i1),cZ=((i4=(i3=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=cG(i,s7),l=0,u=r.length;l<u;l++){var c=r[l]._format;if(!cJ._supportRenderBufferColorFormat(c,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[c]+" in RenderTarget")}if(!s&&!cJ._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 cG(e,ln)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(sj.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=cG(a,ln);(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=cG(i,ln);if(o||l){var u=i._platformTexture;n.framebufferTexture2D(n.FRAMEBUFFER,u._formatDetail.attachment,l?n.TEXTURE_CUBE_MAP_POSITIVE_X+e:n.TEXTURE_2D,u._glTexture,t)}}else if(o){var c=cJ._getRenderBufferDepthFormatDetail(r._depth,n,this._isWebGL2).internalFormat;n.bindRenderbuffer(n.RENDERBUFFER,this._depthRenderBuffer),n.renderbufferStorage(n.RENDERBUFFER,c,r.width>>t,r.height>>t)}this._curMipLevel=t,this._activeRenderTarget()},i4.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)}},i4.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},i4._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},i4._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 u=this._target.getColorTexture(l),c=e.COLOR_ATTACHMENT0+l;s[l]=c,cG(u,ln)||e.framebufferTexture2D(e.FRAMEBUFFER,c,e.TEXTURE_2D,u._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(cG(r,s7)&&!cG(r,ln)){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=cJ._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)},i4._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 u=0;u<a;u++){var c=e.createRenderbuffer();this._MSAAColorRenderBuffers[u]=c,this._blitDrawBuffers[u]=e.NONE,e.bindRenderbuffer(e.RENDERBUFFER,c),e.renderbufferStorageMultisample(e.RENDERBUFFER,o,this._target.getColorTexture(u)._platformTexture._formatDetail.internalFormat,s,l),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0+u,e.RENDERBUFFER,c)}if(e.drawBuffers(this._oriDrawBuffers),null!==i){var h=cG(i,s7)?i._platformTexture._formatDetail:cJ._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)},i4._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.")},i3),c$=(cX(i5=function(t,n){(r=cJ.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(!cJ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||cJ._isPowerOf2(o)&&cJ._isPowerOf2(s)||(sj.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=cJ._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},cJ),(i8=i5.prototype).setPixelBuffer=function(e,t,n,r,i,a){void 0===t&&(t=0);var o=this._gl,s=this._isWebGL2,l=this._formatDetail,u=l.internalFormat,c=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,u,e):(o.compressedTexImage2D(this._target,t,u,i,a,0,e),this._compressedMipFilled|=p)}else o.texSubImage2D(this._target,t,n,r,i,a,c,h,e)},i8.setImageSource=function(e,t,n,r,i,a){var o=this._gl,s=this._formatDetail,l=s.baseFormat,u=s.dataType;this._bind(),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,+n),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,+r),o.texSubImage2D(this._target,t,i||0,a||0,l,u,e)},i8.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cJ.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},i5),c0=(cX(i6=function(t,n){r=cJ.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(!cJ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=cJ._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},cJ),(i7=i6.prototype).setPixelBuffer=function(e,t,n,r,i,a,o,s){var l=this._target,u=this._gl,c=this._formatDetail,h=c.internalFormat,d=c.baseFormat,_=c.dataType,f=c.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(),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,0),u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),f?u.compressedTexSubImage3D(l,n,r,i,e,a,o,s,h,t):u.texSubImage3D(l,n,r,i,e,a,o,s,d,_,t)},i7.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,u=l.baseFormat,c=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,u,c,t)},i7.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)},i6),c1=(cX(i9=function(t,n){(r=cJ.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(!cJ._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||cJ._isPowerOf2(o)||(sj.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=cJ._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},cJ),(ae=i9.prototype).setPixelBuffer=function(e,t,n,r,i,a,o){var s=this._gl,l=this._isWebGL2,u=this._formatDetail,c=u.internalFormat,h=u.baseFormat,d=u.dataType,_=u.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,c,t):(s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+e,n,c,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)},ae.setImageSource=function(e,t,n,r,i,a,o){var s=this._gl,l=this._formatDetail,u=l.baseFormat,c=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,u,c,t)},ae.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");cJ.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},i9);e.WebGLMode=void 0,(at=e.WebGLMode||(e.WebGLMode={}))[at.Auto=0]="Auto",at[at.WebGL2=1]="WebGL2",at[at.WebGL1=2]="WebGL1";var c2=((ar=(an=function(t){void 0===t&&(t={}),this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new sy(null,null,null,null),this._lastScissor=new sy(null,null,null,null),this._lastClearColor=new sx(null,null,null,null),this._scissorEnable=!1;var n=cj({webGLMode:0,alpha:!1,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(lS.platform===e.Platform.IPhone||lS.platform===e.Platform.IPad){var r=lS.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}).prototype).init=function(e){var t,n=this._options,r=this._webCanvas=e._webCanvas,i=n.webGLMode;if((0==i||1==i)&&((t=r.getContext("webgl2",n))||"undefined"!=typeof OffscreenCanvas&&cG(r,OffscreenCanvas)||(t=r.getContext("experimental-webgl2",n)),this._isWebGL2=!0,t&&!t.deleteQuery&&(this._isWebGL2=!1)),t||0!=i&&2!=i||((t=r.getContext("webgl",n))||"undefined"!=typeof OffscreenCanvas&&cG(r,OffscreenCanvas)||(t=r.getContext("experimental-webgl",n)),this._isWebGL2=!1),!t)throw Error("Get GL Context FAILED.");this._gl=t,this._activeTextureID=t.TEXTURE0,this._renderStates=new cQ(t),this._extensions=new cq(this),this._capability=new cK(this),t.activeTexture(t.TEXTURE0);var a=t.getExtension("WEBGL_debug_renderer_info");null!=a&&(this._renderer=t.getParameter(a.UNMASKED_RENDERER_WEBGL))},ar.createPlatformPrimitive=function(e){return new cY(this,e)},ar.createPlatformTexture2D=function(e){return new c$(this,e)},ar.createPlatformTexture2DArray=function(e){return new c0(this,e)},ar.createPlatformTextureCube=function(e){return new c1(this,e)},ar.createPlatformRenderTarget=function(e){return new cZ(this,e)},ar.requireExtension=function(e){return this._extensions.requireExtension(e)},ar.canIUse=function(e){return this.capability.canIUse(e)},ar.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},ar.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))},ar.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)}},ar.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},ar.clearRenderTarget=function(t,n,r){var i=this._gl,a=t._lastRenderState,o=a.blendState.targetBlendState,s=a.depthState,l=a.stencilState,u=0;if(n&e.CameraClearFlags.Color){u|=i.COLOR_BUFFER_BIT;var c=this._lastClearColor,h=r.r,d=r.g,_=r.b,f=r.a;r&&(h!==c.r||d!==c.g||_!==c.b||f!==c.a)&&(i.clearColor(h,d,_,f),c.set(h,d,_,f)),o.colorWriteMask!==e.ColorWriteMask.All&&(i.colorMask(!0,!0,!0,!0),o.colorWriteMask=e.ColorWriteMask.All)}n&e.CameraClearFlags.Depth&&(u|=i.DEPTH_BUFFER_BIT,!0!==s.writeEnabled&&(i.depthMask(!0),s.writeEnabled=!0)),n&e.CameraClearFlags.Stencil&&(u|=i.STENCIL_BUFFER_BIT,255!==l.writeMask&&(i.stencilMask(255),l.writeMask=255)),i.clear(u)},ar.drawPrimitive=function(e,t,n){e?e._draw(n,t):sj.error("draw primitive failed.")},ar.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,u=t.x*r,c=i-t.y*i-l;this.viewport(u,c,s,l),this.scissor(u,c,s,l)},ar.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},ar.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)},ar.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},ar.flush=function(){this._gl.flush()},ar.destroy=function(){},ck(an,[{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}}]),an),c3=(cX(ai=function(e,t){var n=new cH("string"==typeof e?document.getElementById(e):e),r=new c2(t);return uU.call(this,n,r)},uU),ck(ai,[{key:"canvas",get:function(){return this._canvas}}]),ai);function c4(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 c5=((ao=(aa=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:sj.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},ao.addCurrentLoad=function(e){this._currentLoad+=e},ao.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},ao.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},ao.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},c4(aa.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),as&&c4(aa,as),aa),c8='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',c6="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",c7=((au=(al=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)sj.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?uZ(""+c6+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,c8].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uZ(""+c6+"draco_wasm_wrapper_gltf.js",{type:"text"}),uZ(""+c6+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,c8].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},au.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new c5(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]})},au.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},al);function c9(){return(c9=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 he(e,t){return(he=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function ht(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&&he(e,t)}function hn(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 hr(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 hi=(ht(ac=function(){return u2.apply(this,arguments)},u2),ac.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"json"})).then(function(e){var n=new cS,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,u=new cw(i);if(u.blendingMode=o,u.weight=s,l){var c=l.states,h=u.stateMachine=new cM;c.forEach(function(e,n){var i=e.name,o=e.speed,s=e.wrapMode,l=e.clipStartNormalizedTime,u=e.clipEndNormalizedTime,c=e.isDefaultState,d=e.clip,_=h.addState(i);c&&(h.defaultState=_),_.speed=o,_.wrapMode=s,_.clipStartTime=l,_.clipEndTime=u,d&&a.push(new Promise(function(e){t.getResourceByRef(d).then(function(t){e({layerIndex:r,stateIndex:n,clip:t})})}))}),c.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 cv;l.destinationState=s,l.duration=r,l.exitTime=a,l.offset=i,o.addTransition(l)})})}n.addLayer(u)}),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)})},ac);hi=hn([ll(e.AssetType.AnimatorController,["json"],!1)],hi);var ha=(ht(ah=function(){return u2.apply(this,arguments)},u2),ah.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new lo(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,c9({},e,{type:"arraybuffer"}))},ah);ha=hn([ll(e.AssetType.Buffer,["bin","r3bin"],!1)],ha);var ho=(ht(ad=function(){return u2.apply(this,arguments)},u2),ad.prototype.load=function(t,n){var r=this;return new lo(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 ln(n.engine,a);o.filterMode=e.TextureFilterMode.Trilinear;for(var s=o.mipmapCount,l=110,u=0;u<s;u++)for(var c=a>>u,h=0;h<6;h++){var d=c*c*4,_=new Uint8Array(t,l,d);l+=d,o.setPixelBuffer(e.TextureCubeFace.PositiveX+h,_,u)}var f=new uL,p=new sC;f.diffuseMode=e.DiffuseMode.SphericalHarmonics,p.copyFromArray(r),f.diffuseSphericalHarmonics=p,f.specularTexture=o,f.specularTextureDecodeRGBM=!0,i(f)}).catch(function(e){a(e)})})},ad);function hs(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 hl(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){hs(a,r,i,o,s,"next",e)}function s(e){hs(a,r,i,o,s,"throw",e)}o(void 0)})}}ho=hn([ll(e.AssetType.Env,["env"])],ho);var hu=(ht(a_=function(){return u2.apply(this,arguments)},u2),(af=a_.prototype).load=function(e,t){var n=this;return new lo(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 la(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new la(t.engine,a))}).catch(function(e){i(e)})})},af._registerFont=function(e,t){return hl(function(){var n;return hr(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]}})})()},a_);function hc(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 hh(e,t){if(e){if("string"==typeof e)return hc(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 hc(e,t)}}function hd(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=hh(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.")}hu=hn([ll(e.AssetType.Font,["font"],!1)],hu),(ap=o8||(o8={}))[ap.BYTE=5120]="BYTE",ap[ap.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",ap[ap.SHORT=5122]="SHORT",ap[ap.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",ap[ap.UNSIGNED_INT=5125]="UNSIGNED_INT",ap[ap.FLOAT=5126]="FLOAT",(ag=o6||(o6={})).SCALAR="SCALAR",ag.VEC2="VEC2",ag.VEC3="VEC3",ag.VEC4="VEC4",ag.MAT2="MAT2",ag.MAT3="MAT3",ag.MAT4="MAT4",(am=o7||(o7={})).TRANSLATION="translation",am.ROTATION="rotation",am.SCALE="scale",am.WEIGHTS="weights",(av=o9||(o9={})).Linear="LINEAR",av.Step="STEP",av.CubicSpine="CUBICSPLINE",(ay=se||(se={})).PERSPECTIVE="perspective",ay.ORTHOGRAPHIC="orthographic",(ax=st||(st={})).JPEG="image/jpeg",ax.PNG="image/png",(aT=sn||(sn={})).OPAQUE="OPAQUE",aT.MASK="MASK",aT.BLEND="BLEND",(aC=sr||(sr={}))[aC.NEAREST=9728]="NEAREST",aC[aC.LINEAR=9729]="LINEAR",(aS=si||(si={}))[aS.NEAREST=9728]="NEAREST",aS[aS.LINEAR=9729]="LINEAR",aS[aS.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",aS[aS.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",aS[aS.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",aS[aS.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(aw=sa||(sa={}))[aw.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",aw[aw.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",aw[aw.REPEAT=10497]="REPEAT";var h_=((ab=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new hp,this.materialsPromiseInfo=new hp,this.meshesPromiseInfo=new hp,this.animationClipsPromiseInfo=new hp,this.defaultSceneRootPromiseInfo=new hp,this.masterPromiseInfo=new hp,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 lo(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},ab),hf=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},hp=function(){},hg=((aA=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new sv(e[r],e[r+1]);return n},aA.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sl(e[r],e[r+1],e[r+2]);return n},aA.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new sy(e[r],e[r+1],e[r+2],e[r+3]);return n},aA.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 sx(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new sx(e[a],e[a+1],e[a+2],e[a+3]);return r},aA.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))},aA.getAccessorTypeSize=function(e){switch(e){case o6.SCALAR:return 1;case o6.VEC2:return 2;case o6.VEC3:return 3;case o6.VEC4:case o6.MAT2:return 4;case o6.MAT3:return 9;case o6.MAT4:return 16}},aA.getComponentType=function(e){switch(e){case o8.BYTE:return Int8Array;case o8.UNSIGNED_BYTE:return Uint8Array;case o8.SHORT:return Int16Array;case o8.UNSIGNED_SHORT:return Uint16Array;case o8.UNSIGNED_INT:return Uint32Array;case o8.FLOAT:return Float32Array}},aA.getNormalizedComponentScale=function(e){switch(e){case o8.BYTE:return 1/127;case o8.UNSIGNED_BYTE:return 1/255;case o8.SHORT:return 1/32767;case o8.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},aA.getAccessorBuffer=function(e,t,n){var r,i=e.buffers,a=t.bufferViews,o=n.componentType,s=a[n.bufferView],l=i[s.buffer],u=s.byteOffset||0,c=n.byteOffset||0,h=aA.getComponentType(o),d=aA.getAccessorTypeSize(n.type),_=h.BYTES_PER_ELEMENT,f=d*_,p=n.count,g=s.byteStride;if(void 0!==g&&g!==f){var m=Math.floor(c/g),v=n.bufferView+":"+o+":"+m+":"+p,y=e.accessorBufferCache;if(!(r=y[v])){var x=new h(l,u+m*g,p*(g/_));y[v]=r=new hf(x,!0,g)}}else{var T=new h(l,u+c,p*d);r=new hf(T,!1,f)}if(n.sparse){var C=aA.processingSparseData(t,n,i,r.data);r=new hf(C,!1,r.stride)}return r},aA.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,u=aA.getAccessorTypeSize(t.type),c=u*t.count,h=null!=(v=i.byteStride)?v:0,d=aA.getComponentType(t.componentType);if(h){var _=u*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+c*d.BYTES_PER_ELEMENT));var m=new d(y.buffer);if(t.sparse)for(var v,y,x,T,C,S,w=t.sparse,b=w.count,A=w.indices,M=w.values,F=r[A.bufferView],P=r[M.bufferView],E=n[F.buffer],R=n[P.buffer],L=(null!=(x=A.byteOffset)?x:0)+(null!=(T=F.byteOffset)?T:0),B=F.byteLength,D=(null!=(C=M.byteOffset)?C:0)+(null!=(S=P.byteOffset)?S:0),I=P.byteLength,O=aA.getComponentType(A.componentType),V=new O(E,L,B/O.BYTES_PER_ELEMENT),U=new d(R,D,I/d.BYTES_PER_ELEMENT),z=0;z<b;z++)for(var N=V[z],k=0;k<u;k++)m[N*u+k]=U[z*u+k];return m},aA.getBufferViewData=function(e,t){var n=e.buffer,r=e.byteOffset,i=void 0===r?0:r,a=e.byteLength;return t[n].slice(i,i+a)},aA.processingSparseData=function(e,t,n,r){for(var i,a,o,s,l=e.bufferViews,u=aA.getAccessorTypeSize(t.type),c=aA.getComponentType(t.componentType),h=r.slice(),d=t.sparse,_=d.count,f=d.indices,p=d.values,g=l[f.bufferView],m=l[p.bufferView],v=n[g.buffer],y=n[m.buffer],x=(null!=(i=f.byteOffset)?i:0)+(null!=(a=g.byteOffset)?a:0),T=g.byteLength,C=(null!=(o=p.byteOffset)?o:0)+(null!=(s=m.byteOffset)?s:0),S=m.byteLength,w=aA.getComponentType(f.componentType),b=new w(v,x,T/w.BYTES_PER_ELEMENT),A=new c(y,C,S/c.BYTES_PER_ELEMENT),M=0;M<_;M++)for(var F=b[M],P=0;P<u;P++)h[F*u+P]=A[M*u+P];return h},aA.getIndexFormat=function(t){switch(t){case o8.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case o8.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case o8.UNSIGNED_INT:return e.IndexFormat.UInt32}},aA.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==o8.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==o8.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==o8.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==o8.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==o8.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},aA.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)})},aA.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},aA.parseRelativeUrl=function(e,t){return aA.isAbsoluteUrl(t)?t:e.substring(0,e.lastIndexOf("/")+1)+aA._formatRelativePath(t)},aA.parseGLB=function(e){var t={JSON:1313821514,BIN:5130562},n=new DataView(e),r={magic:n.getUint32(0,!0),version:n.getUint32(4,!0),length:n.getUint32(8,!0)};if(1179937895!==r.magic)return console.error("Invalid glb magic number. Expected 0x46546C67, found 0x"+r.magic.toString(16)),null;var i=n.getUint32(12,!0),a=n.getUint32(16,!0);if(a!==t.JSON)return console.error("Invalid glb chunk type. Expected 0x4E4F534A, found 0x"+a.toString(16)),null;for(var o=new Uint8Array(e,20,i),s=JSON.parse(aA.decodeText(o)),l=[],u=20+i;u<r.length;){if(i=n.getUint32(u,!0),(a=n.getUint32(u+4,!0))!==t.BIN)return console.error("Invalid glb chunk type. Expected 0x004E4942, found 0x"+a.toString(16)),null;var c=u+8,h=e.slice(c,c+i);l.push(h),u+=i+8}return{gltf:s,buffers:l}},aA._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},aA);function hm(e){return function(e){if(Array.isArray(e))return hc(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||hh(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 hv=((aF=(aM=function(){}).prototype).initialize=function(){},aF.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."},aF.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."},aM);e.GLTFExtensionMode=void 0,(aP=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[aP.CreateAndParse=0]="CreateAndParse",aP[aP.AdditiveParse=1]="AdditiveParse";var hy=((aE=function(){}).executeExtensionsInitialize=function(e){var t=aE._extensionParsers[e],n=null==t?void 0:t.length;if(n)return t[n-1].initialize()},aE.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 u=s[l],c=e[u];if(o=aE._createAndParse.apply(aE,[u,t,c,n].concat(hm(i))))return o}},aE.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];aE._additiveParse.apply(aE,[s,t,n,l,r].concat(hm(a)))}},aE.hasExtensionParser=function(e){var t;return!!(null==(t=aE._extensionParsers[e])?void 0:t.length)},aE.getExtensionParser=function(e,t){var n=aE._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}},aE._addExtensionParser=function(e,t){aE._extensionParsers[e]||(aE._extensionParsers[e]=[]),aE._extensionParsers[e].push(t)},aE._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=aE.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,i].concat(hm(o)))},aE._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 u=aE.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);u&&u.additiveParse.apply(u,[n,r,i,a].concat(hm(s)))},aE);function hx(e,t){return function(n){var r=new n;r._mode=t,hy._addExtensionParser(e,r)}}hy._extensionParsers={};var hT=(ht(aR=function(){return hy.apply(this,arguments)},hy),(aL=aR.prototype).parse=function(t){var n=t.gltf;t.buffers;var r=t.glTFResource,i=r.entities,a=n.animations,o=n.accessors;if(a){for(var s=t.animationClipsPromiseInfo,l=a.length,u=Array(l),c=Array(l),h=0;h<l;h++){for(var d=a[h],_=d.channels,f=d.samplers,p=d.name,g=void 0===p?"AnimationClip"+h:p,m=new cp(g),v=[],y=0,x=f.length;y<x;y++){var T,C=f[y],S=o[C.input],w=o[C.output],b=hg.getAccessorBuffer(t,n,S).data,A=hg.getAccessorBuffer(t,n,w).data;if(w.normalized){for(var M=hg.getNormalizedComponentScale(w.componentType),F=new Float32Array(A.length),P=0,E=A.length;P<E;P++)F[P]=A[P]*M;A=F}var R=A.length/b.length,L=null!=(T=C.interpolation)?T:o9.Linear,B=void 0;switch(L){case o9.CubicSpine:B=e.InterpolationType.CubicSpine;break;case o9.Step:B=e.InterpolationType.Step;break;case o9.Linear:B=e.InterpolationType.Linear}b[b.length-1],v.push({type:w.type,interpolation:B,input:b,output:A,outputSize:R})}for(var D=0,I=_.length;D<I;D++){for(var O=_[D],V=O.target,U=i[V.node],z="",N=U;N.parent;)z=""===z?""+N.name:N.name+"/"+z,N=N.parent;var k=void 0,G=void 0;switch(V.path){case o7.TRANSLATION:k=lx,G="position";break;case o7.ROTATION:k=lx,G="rotationQuaternion";break;case o7.SCALE:k=lx,G="scale";break;case o7.WEIGHTS:k=uT,G="blendShapeWeights"}var H=this._addCurve(V.path,O,v);m.addCurveBinding(z,k,G,H)}u[h]=m,c[h]={name:g,index:h}}return r.animations=u,r._animationsIndices=c,s.resolve(u),s.promise}},aL._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case o7.TRANSLATION:case o7.SCALE:for(var l=new e.AnimationVector3Curve,u=l.interpolation=i.interpolation,c=0,h=0,d=a.length;h<d;h++){var _=new cF;_.time=a[h],u===e.InterpolationType.CubicSpine?(_.inTangent=new sl(o[c++],o[c++],o[c++]),_.value=new sl(o[c++],o[c++],o[c++]),_.outTangent=new sl(o[c++],o[c++],o[c++])):_.value=new sl(o[c++],o[c++],o[c++]),l.addKey(_)}return l;case o7.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 cF;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new sy(o[g++],o[g++],o[g++],o[g++]),y.value=new sp(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new sy(o[g++],o[g++],o[g++],o[g++])):y.value=new sp(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case o7.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 cF;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}},aR),hC=(ht(aB=function(){return hy.apply(this,arguments)},hy),(aD=aB.prototype).parse=function(e){var t=e.glTFResource.url;return this._isGLB(t)?uZ(t,{type:"arraybuffer"}).then(hg.parseGLB).then(function(t){var n=t.gltf,r=t.buffers;e.gltf=n,e.buffers=r}):uZ(t,{type:"json"}).then(function(n){return e.gltf=n,Promise.all(n.buffers.map(function(e){return uZ(hg.parseRelativeUrl(t,e.uri),{type:"arraybuffer"})})).then(function(t){e.buffers=t})})},aD._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},aB),hS=(ht(aI=function(){return hy.apply(this,arguments)},hy),(aO=aI.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,u=o.rotation,c=o.scale,h=new lT(r,o.name||""+aI._defaultName+a),d=h.transform;if(s){var _=d.localMatrix;_.copyFromArray(s),d.localMatrix=_}else l&&d.setPosition(l[0],l[1],l[2]),u&&d.setRotationQuaternion(u[0],u[1],u[2],u[3]),c&&d.setScale(c[0],c[1],c[2]);i[a]=h}t.entities=i,this._buildEntityTree(e,t),this._createSceneRoots(e,t)}},aO._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)}}},aO._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 u=i[l].nodes;if(u){if(1===u.length)s[l]=o[u[0]];else{for(var c=new lT(a,"GLTF_ROOT"),h=0;h<u.length;h++)c.addChild(o[u[h]]);s[l]=c}}}t.sceneRoots=s,t.defaultSceneRoot=s[void 0===r?0:r],t.defaultSceneRoot._hookResource=t,t._addRefCount(1)}},aI);hS._defaultName="_GLTF_ENTITY_";var hw=(ht(aV=function(){return hy.apply(this,arguments)},hy),aV.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=hy.executeExtensionsCreateAndParse(s.extensions,e,s);l||((l=new u8(i)).name=s.name,aV._parseStandardProperty(e,l,s)),a.push(l)}return lo.all(a).then(function(i){n.materials=i;for(var a=0;a<t.materials.length;a++){var o=t.materials[a];hy.executeExtensionsAdditiveAndParse(o.extensions,e,i[a],o)}return r.resolve(i),r.promise})}},aV._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&sj.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},aV._parseStandardProperty=function(t,n,r){var i=t.glTFResource.textures,a=r.pbrMetallicRoughness,o=r.normalTexture,s=r.occlusionTexture,l=r.emissiveTexture,u=r.emissiveFactor,c=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 sx(sx.linearToGammaSpace(_[0]),sx.linearToGammaSpace(_[1]),sx.linearToGammaSpace(_[2]),_[3])),f&&(n.baseTexture=i[f.index],hy.executeExtensionsAdditiveAndParse(f.extensions,t,n,f)),n.constructor===u8&&(n.metallic=null!=p?p:1,n.roughness=null!=g?g:1,m&&(n.roughnessMetallicTexture=i[m.index],aV._checkOtherTextureTransform(m,"Roughness metallic")))}if(n.constructor===u8||n.constructor===u6){if(l&&(n.emissiveTexture=i[l.index],aV._checkOtherTextureTransform(l,"Emissive")),u&&(n.emissiveColor=new sx(sx.linearToGammaSpace(u[0]),sx.linearToGammaSpace(u[1]),sx.linearToGammaSpace(u[2]))),o){var v=o.index,y=o.scale;n.normalTexture=i[v],aV._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],aV._checkOtherTextureTransform(s,"Occlusion"),void 0!==T&&(n.occlusionTextureIntensity=T),C===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:C>e.TextureCoordinate.UV1&&sj.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,c){case sn.OPAQUE:n.isTransparent=!1;break;case sn.BLEND:n.isTransparent=!0;break;case sn.MASK:n.alphaCutoff=null!=h?h:.5}},aV);function hb(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var hA=(ht(aU=function(){return hy.apply(this,arguments)},hy),aU.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=hy.executeExtensionsCreateAndParse(a.extensions,e,a,s);if(l)hb(l,uf)?o(l):l.then(function(e){return o(e)});else{var u=new uf(i,s.name||r+"");aU._parseMeshFromGLTFPrimitive(e,u,s,a,t,function(e){return null},function(e,r){var i=a.targets[r][e];if(!i)return null;var o=t.accessors[i];return hg.getAccessorData(t,o,n)},function(){var e=t.accessors[a.indices];return hg.getAccessorData(t,e,n)},e.keepMeshData).then(o)}})},s=t.meshes[r],l=[],u=0;u<s.primitives.length;u++)a(u);o[r]=Promise.all(l)}(s);return lo.all(o).then(function(e){r.meshes=e,a.resolve(e)}).catch(a.reject),a.promise}},aU._parseMeshFromGLTFPrimitive=function(t,n,r,i,a,o,s,l,u){var c,h,d,_,f=a.accessors;t.buffers;var p=i.attributes,g=i.targets,m=i.indices,v=i.mode,y=n.engine,x=[],T=0;for(var C in u&&(h=Array(c),d=Array(c),_=Array(c)),p){var S=f[p[C]],w=hg.getAccessorBuffer(t,a,S),b=hg.getAccessorTypeSize(S.type),A=S.count,M=w.data,F=void 0,P=n.instanceId,E=w.vertexBindingInfos,R=S.normalized,L=hg.getElementFormat(S.componentType,b,R),B=void 0;R&&(B=hg.getNormalizedComponentScale(S.componentType));var D=void 0;if(w.interleaved){var I=S.byteOffset||0,O=w.stride;if(D=I%O,void 0===E[P]){F=new us(C,D,L,T);var V=w.vertexBuffer;V||((V=new ul(y,e.BufferBindFlag.VertexBuffer,M.byteLength,e.BufferUsage.Static)).setData(M),w.vertexBuffer=V),n.setVertexBufferBinding(V,O,T),E[P]=T++}else F=new us(C,D,L,E[P])}else{D=0,F=new us(C,D,L,T);var U=new ul(y,e.BufferBindFlag.VertexBuffer,M.byteLength,e.BufferUsage.Static);U.setData(M),n.setVertexBufferBinding(U,w.stride,T),E[P]=T++}if(x.push(F),"POSITION"===C){c=A;var z=n.bounds,N=z.min,k=z.max;if(S.min&&S.max){if(N.copyFromArray(S.min),k.copyFromArray(S.max),u)for(var G=D/M.BYTES_PER_ELEMENT,H=M.length/A,W=0;W<A;W++){var X=G+W*H,j=new sl(M[X],M[X+1],M[X+2]);R&&j.scale(B),h[W]=j}}else{var K=aU._tempVector3;N.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),k.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var q=D/M.BYTES_PER_ELEMENT,Y=M.length/A,Q=0;Q<A;Q++){var J=q+Q*Y;if(K.copyFromArray(M,J),sl.min(N,K,N),sl.max(k,K,k),u){var Z=K.clone();R&&Z.scale(B),h[Q]=Z}}}R&&(N.scale(B),k.scale(B))}else if("JOINTS_0"===C&&u)for(var $=D/M.BYTES_PER_ELEMENT,ee=M.length/A,et=0;et<A;et++){var en=$+et*ee,er=new sy(M[en],M[en+1],M[en+2],M[en+3]);R&&er.scale(B),d[et]=er}else if("WEIGHTS_0"===C&&u)for(var ei=D/M.BYTES_PER_ELEMENT,ea=M.length/A,eo=0;eo<A;eo++){var es=ei+eo*ea,el=new sy(M[es],M[es+1],M[es+2],M[es+3]);R&&el.scale(B),_[eo]=el}}if(n.setVertexElements(x),void 0!==m){var eu=a.accessors[m],ec=l();n.setIndices(ec),n.addSubMesh(0,eu.count,v)}else n.addSubMesh(0,c,v);return g&&aU._createBlendShape(n,r,g,s),n.uploadData(!u),n._positions=h,n._boneIndices=d,n._boneWeights=_,Promise.resolve(n)},aU._createBlendShape=function(e,t,n,r){for(var i=t.extras?t.extras.targetNames:null,a=0,o=n.length;a<o;a++){var s=i?i[a]:"blendShape"+a,l=r("POSITION",a),u=r("NORMAL",a),c=r("TANGENT",a),h=l?hg.floatBufferToVector3Array(l):null,d=u?hg.floatBufferToVector3Array(u):null,_=c?hg.floatBufferToVector3Array(c):null,f=new ub(s);f.addFrame(1,h,d,_),e.addBlendShape(f)}},aU);hA._tempVector3=new sl;var hM=(ht(az=function(){return hy.apply(this,arguments)},hy),(aN=az.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],u=l.camera,c=l.mesh,h=l.extensions,d=r[s];void 0!==u&&this._createCamera(t,a[u],d),void 0!==c&&this._createRenderer(e,l,d),hy.executeExtensionsAdditiveAndParse(h,e,d,l)}return t.defaultSceneRoot&&this._createAnimator(e),o.resolve(t.defaultSceneRoot),o.promise}},aN._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===se.ORTHOGRAPHIC){var l=i.xmag,u=i.ymag,c=i.zfar,h=i.znear;s.isOrthographic=!0,void 0!==h&&(s.nearClipPlane=h),void 0!==c&&(s.farClipPlane=c),s.orthographicSize=Math.max(null!=u?u:0,null!=l?l:0)/2}else if(o===se.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},aN._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,u=t.mesh,c=t.skin,h=i[u],d=h.primitives,_=t.weights||h.weights,f=0;f<d.length;f++)!function(t){var r=d[t],i=o[u][t],h=void 0;if(void 0!==c||_){e.hasSkinned=!0;var f=n.addComponent(uT);f.mesh=i,void 0!==c&&(f.skin=l[c]),_&&(f.blendShapeWeights=new Float32Array(_)),h=f}else(h=n.addComponent(ug)).mesh=i;var p=r.material,g=(null==s?void 0:s[p])||az._getDefaultMaterial(a);h.setMaterial(g),i.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(h.enableVertexColor=!0)}),hy.executeExtensionsAdditiveAndParse(r.extensions,e,h,r)}(f)},aN._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(cC),a=new cS,o=new cw("layer"),s=new cM;if(a.addLayer(o),i.animatorController=a,o.stateMachine=s,r)for(var l=0;l<r.length;l++){var u=r[l],c=u.name,h=s.makeUniqueStateName(c);h!==c&&console.warn("AnimatorState name is existed, name: "+c+" reset to "+h),s.addState(h).clip=u}}},az._getDefaultMaterial=function(e){return az._defaultMaterial||(az._defaultMaterial=new u4(e)),az._defaultMaterial},az),hF=(ht(ak=function(){return hy.apply(this,arguments)},hy),(aG=ak.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],u=l.inverseBindMatrices,c=l.skeleton,h=l.joints,d=l.name,_=void 0===d?"SKIN_"+s:d,f=h.length,p=new up(_);p.inverseBindMatrices.length=f;for(var g=n.accessors[u],m=hg.getAccessorBuffer(e,n,g).data,v=0;v<f;v++){var y=new sg;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!==c)p.skeleton=r[c].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}},aG._findSkeletonRootBone=function(e,t){for(var n,r={},i=hd(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,u=0;;u++){var c=r[e[0]];if(u>=c.length)return l;for(var h=c[u],d=1,_=e.length;d<_;d++)if(u>=(c=r[e[d]]).length||h!==c[u])return l;l=h}},ak),hP=(ht(aH=function(){return hy.apply(this,arguments)},hy),(aW=aH.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 lo.all(i.textures.map(function(t,r){var l=t.sampler,u=t.source,c=t.name,h=i.images[void 0===u?0:u],d=h.uri,_=h.bufferView,f=h.mimeType,p=h.name;if(d){var g=d.lastIndexOf("."),m=d.substring(g+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;return o.resourceManager.load({url:hg.parseRelativeUrl(s,d),type:m}).then(function(e){return e.name||(e.name=c||p||"texture_"+g),void 0!==l&&n._parseSampler(e,i.samplers[l]),e})}var v=i.bufferViews[_],y=hg.getBufferViewData(v,a);return hg.loadImageBuffer(y,f).then(function(e){var t=new le(o,e.width,e.height);return t.setImageSource(e),t.generateMipmaps(),t.name=c||p||"texture_"+r,void 0!==l&&n._parseSampler(t,i.samplers[l]),t})})).then(function(e){r.textures=e,l.resolve(e)}).catch(l.reject),l.promise}},aW._parseSampler=function(t,n){var r=n.magFilter,i=n.minFilter,a=n.wrapS,o=n.wrapT;(r||i)&&(r===sr.NEAREST?t.filterMode=e.TextureFilterMode.Point:i<=si.LINEAR_MIPMAP_NEAREST?t.filterMode=e.TextureFilterMode.Bilinear:t.filterMode=e.TextureFilterMode.Trilinear),a&&(t.wrapModeU=aH._wrapMap[a]),o&&(t.wrapModeV=aH._wrapMap[o])},aH);hP._wrapMap=((aX={})[sa.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,aX[sa.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,aX[sa.REPEAT]=e.TextureWrapMode.Repeat,aX);var hE=(ht(aj=function(){return hy.apply(this,arguments)},hy),aj.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){sj.info("extensionsUsed: ",r);for(var s=0;s<r.length;s++){var l=r[s];hy.hasExtensionParser(l)||sj.warn("Extension "+l+" is not implemented, you can customize this extension in gltf.")}}if(i){sj.info("extensionsRequired: "+i);for(var u=0;u<i.length;u++){var c=i[u];hy.hasExtensionParser(c)?o.push(hy.executeExtensionsInitialize(c)):sj.error("GLTF parser has not supported required extension "+c+".")}}return lo.all(o).then(null)},aj),hR=((aK=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 lo(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)})},aK);hR.defaultPipeline=new hR(hC,hE,hP,hw,hA,hS,hF,hT,hM);var hL=(ht(aq=function(e,t){var n;return(n=sU.call(this,e)||this).url=t,n},sU),aq.prototype._onDestroy=function(){},aq),hB=(ht(aY=function(){return u2.apply(this,arguments)},u2),aY.prototype.load=function(e,t){var n,r=e.url,i=e.params,a=new h_(r),o=new hL(t.engine,r),s=a.masterPromiseInfo;return a.glTFResource=o,a.keepMeshData=null!=(n=null==i?void 0:i.keepMeshData)&&n,s.onCancel(function(){for(var e,t=a.chainPromises,n=hd(t);!(e=n()).done;)e.value.cancel()}),((null==i?void 0:i.pipeline)||hR.defaultPipeline)._parse(a).then(s.resolve).catch(function(e){var t="Error loading glTF model from "+r+" .";sj.error(t),s.reject(t),a.defaultSceneRootPromiseInfo.reject(e),a.texturesPromiseInfo.reject(e),a.materialsPromiseInfo.reject(e),a.meshesPromiseInfo.reject(e),a.animationClipsPromiseInfo.reject(e)}),a.promiseMap},aY);hB=hn([ll(e.AssetType.Prefab,["gltf","glb"])],hB);var hD=Math.PI,hI=(ht(aQ=function(){return u2.apply(this,arguments)},u2),aQ.prototype.load=function(t,n){var r=this;return new lo(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=hI._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,u=hI._readPixels(n.subarray(l),a,s),c=s>>1,h=hI._convertToCubemap(u,a,s,c),d=new ln(o,c),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},aQ._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)]},aQ._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,u=0,c=0;c<e;c++){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(u).add(h);f.normalize();var p=this._calcProjectionSpherical(f,n,r,i);this._RGBEToLinear(p),this._linearToRGBM(p,5);var g=c*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)}u+=l}return a},aQ._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,-e.x),a=Math.acos(e.y);i<-hD;)i+=2*hD;for(;i>hD;)i-=2*hD;var o=i/hD,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/hD*r);l<0?l=0:l>=r&&(l=r-1);var u=(r-l-1)*n*4+4*s,c=t[u],h=t[u+1],d=t[u+2],_=t[u+3];return new sx(c,h,d,_)},aQ._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},aQ._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}},aQ._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),u=new Uint8Array(s),c=n;c>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++)u[h++]=f;else u.set(e.subarray(o,o+d),h),h+=d,o+=d}for(var g=0;g<t;g++){var m=0;i[a]=u[g+m],m+=t,i[a+1]=u[g+m],m+=t,i[a+2]=u[g+m],m+=t,i[a+3]=u[g+m],a+=4}c--}return i},aQ._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},aQ._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},(so=aQ)._rightBottomBack=new sl(1,-1,-1),so._rightBottomFront=new sl(1,-1,1),so._rightUpBack=new sl(1,1,-1),so._rightUpFront=new sl(1,1,1),so._leftBottomBack=new sl(-1,-1,-1),so._leftBottomFront=new sl(-1,-1,1),so._leftUpBack=new sl(-1,1,-1),so._leftUpFront=new sl(-1,1,1),so._faceRight=[so._rightBottomBack,so._rightBottomFront,so._rightUpBack,so._rightUpFront],so._faceLeft=[so._leftBottomFront,so._leftBottomBack,so._leftUpFront,so._leftUpBack],so._faceUp=[so._leftBottomFront,so._rightBottomFront,so._leftBottomBack,so._rightBottomBack],so._faceBottom=[so._leftUpBack,so._rightUpBack,so._leftUpFront,so._rightUpFront],so._faceFront=[so._leftBottomBack,so._rightBottomBack,so._leftUpBack,so._rightUpBack],so._faceBack=[so._rightBottomFront,so._leftBottomFront,so._rightUpFront,so._leftUpFront],so._tempVector3=new sl,so._temp2Vector3=new sl,so._temp3Vector3=new sl,so._temp4Vector3=new sl,so._temp5Vector3=new sl,so);hI=hn([ll(e.AssetType.HDR,["hdr"])],hI);var hO=(ht(aJ=function(){return u2.apply(this,arguments)},u2),aJ.prototype.load=function(e){return this.request(e.url,c9({},e,{type:"json"}))},aJ);hO=hn([ll(e.AssetType.JSON,["json"],!1)],hO);var hV={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 u=0;u<e.numberOfFaces;u++){var c=new Uint8Array(e.buffer,r,l);n.push({data:c,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 hU(e){var t=hV.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var hz=(ht(aZ=function(){return u2.apply(this,arguments)},u2),aZ.prototype.load=function(t,n){var r=this;return new lo(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c9({},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=hV.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,u=new ln(n.engine,a,s,l),c=0;c<6;c++)for(var h=o[c].length,d=0;d<h;d++){var _=o[c][d],f=_.data,p=_.width,g=_.height;u.setPixelBuffer(e.TextureCubeFace.PositiveX+c,f,d,0,0,p,g)}i(u)}).catch(function(e){a(e)})})},aZ);hz=hn([ll(e.AssetType.KTXCube,[])],hz);var hN=(ht(a$=function(){return u2.apply(this,arguments)},u2),a$.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"arraybuffer"})).then(function(e){for(var n=hU(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,u=new le(t.engine,i,a,s,l),c=0;c<o.length;c++){var h=o[c],d=h.width,_=h.height,f=h.data;u.setPixelBuffer(f,c,0,0,d,_)}r(u)}).catch(function(e){i(e)})})},a$);hN=hn([ll(e.AssetType.KTX,["ktx"])],hN);var hk=(ht(a0=function(){return u2.apply(this,arguments)},u2),a0.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"json"})).then(function(e){var n,i=function(e){var n=l[e],r=n.type,i=n.value;switch(r){case"Vector2":d.setVector2(e,new sv(i.x,i.y));break;case"Vector3":d.setVector3(e,new sl(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new sy(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new sx(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)}))}},a=t.engine,o=e.name,s=e.shader,l=e.shaderData,u=e.macros,c=e.renderState;switch(s){case"pbr":n=new u8(a);break;case"pbr-specular":n=new u6(a);break;case"unlit":n=new u7(a);break;case"blinn-phong":n=new u4(a);break;case"bake-pbr":n=new u5(a,s3.find("bake-pbr"))}n.name=o;var h=[],d=n.shaderData;for(var _ in l)i(_);for(var f=0,p=u.length;f<p;f++){var g=u[f],m=g.name,v=g.value;void 0==v?d.enableMacro(m):d.enableMacro(m,v)}for(var y in c)n[y]=c[y];return Promise.all(h).then(function(){r(n)})}).catch(i)})},a0);function hG(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 hH(e,t,n){return t&&hG(e.prototype,t),n&&hG(e,n),e}hk=hn([ll(e.AssetType.Material,["json"])],hk);var hW=((a2=(a1=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},a2.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},a2.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},a2.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},a2.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a2.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},a2.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a2.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},a2.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},a2.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},a2.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,hg.decodeText(t)},a2.nextImageData=function(e){return this.buffer.slice(this._offset)},a2.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},a2.skip=function(e){return this._offset+=e,this},a2.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)},hH(a1,[{key:"offset",get:function(){return this._offset}}]),a1);hW.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var hX={};function hj(e){return function(t){hX[e]=t}}var hK=((a3=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=hg.decodeText(s),u=hg.decodeText(a),c=new a3;return c.totalLength=n,c.name=l,c.type=u,c.version=r,c.headerLength=s.byteLength+a.byteLength+9,c},hH(a3,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),a3);function hq(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sy(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function hY(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sl(e[3*r],e[3*r+1],e[3*r+2]);return n}function hQ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sv(e[2*r],e[2*r+1]);return n}function hJ(e,t,n){return(hJ=!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&&he(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((a4=function(){}).decode=function(e,t){return new Promise(function(n){var r=new uf(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=hY(o,s);if(r.setPositions(l),i.normals){var u=hY(new Float32Array(t.buffer,i.normals.start+a,(i.normals.end-i.normals.start)/4),s);r.setNormals(u)}if(i.uvs){var c=new Float32Array(t.buffer,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);r.setUVs(hQ(c,s))}if(i.uv1){var h=new Float32Array(t.buffer,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(hQ(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(hQ(d,s),2)}if(i.uv3){var _=new Float32Array(t.buffer,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(hQ(_,s),3)}if(i.uv4){var f=new Float32Array(t.buffer,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(hQ(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(hQ(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(hQ(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(hQ(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 sx(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(hq(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(hq(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new ub(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=hY(r,i);e.deltaNormals&&hY(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&hq(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)})},a4),e.MeshDecoder=hn([hj("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((a5=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(),u=t.nextUint8(),c=t.nextUint8(),h=t.nextUint16(),d=t.nextUint16(),_=t.nextUint8(),f=t.nextUint8(),p=t.nextImagesData(f),g=new le(e,h,d,c,a);if(g.filterMode=o,g.anisoLevel=s,g.wrapModeU=l,g.wrapModeV=u,_){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)}})},a5),e.Texture2DDecoder=hn([hj("Texture2D")],e.Texture2DDecoder);var hZ=((a8=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},a8.parseEntity=function(e,t){return a8.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})},a8.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 lT(t,e.name))},a8.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=hJ(u2.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},a8.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)},a8.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,u=s.length;l<u;l++){var c=s[l],h=this.parseMethod(e,o,c,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})},a8.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)})},a8._isClass=function(e){return void 0!=e.class},a8._isRef=function(e){return void 0!=e.refId},a8);hZ.customParseComponentHandles=new Map;var h$=((a6=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)}},a6),h0={Transform:lx,Animator:cC,DirectLight:lY,Camera:e.Camera,MeshRenderer:ug,ParticleRenderer:cE,PointLight:lQ,SpotLight:lJ,Script:uz,SpriteMask:ua,SpriteRenderer:cn,TextRenderer:co};e.InterpolableValueType=void 0,(a7=e.InterpolableValueType||(e.InterpolableValueType={}))[a7.Float=0]="Float",a7[a7.FloatArray=1]="FloatArray",a7[a7.Vector2=2]="Vector2",a7[a7.Vector3=3]="Vector3",a7[a7.Vector4=4]="Vector4",a7[a7.Quaternion=5]="Quaternion",a7[a7.Color=6]="Color",a7[a7.Array=7]="Array",a7[a7.Boolean=8]="Boolean",e.AnimationClipDecoder=((a9=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new cp(r),a=n.nextUint16(),o=0;o<a;++o){var s=new cf;s.time=n.nextFloat32(),s.functionName=n.nextStr(),s.parameter=JSON.parse(n.nextStr()).val,i.addEvent(s)}for(var l=n.nextUint16(),u=0;u<l;++u){var c=n.nextStr(),h=h0[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 cF;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 cF;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 cF;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 b=new cF;b.time=n.nextFloat32(),b.value=new sv(n.nextFloat32(),n.nextFloat32()),b.inTangent=new sv(n.nextFloat32(),n.nextFloat32()),b.outTangent=new sv(n.nextFloat32(),n.nextFloat32()),_.addKey(b)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var A=0;A<p;++A){var M=new cF;M.time=n.nextFloat32(),M.value=new sl(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sl(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sl(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var F=new cF;F.time=n.nextFloat32(),F.value=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(F);break;case"AnimationColorCurve":(_=_||new e.AnimationColorCurve).interpolation=f;for(var P=0;P<p;++P){var E=new cF;E.time=n.nextFloat32(),E.value=new sx(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.inTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),E.outTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(E)}break;case"AnimationQuaternionCurve":(_=_||new e.AnimationQuaternionCurve).interpolation=f;for(var R=0;R<p;++R){var L=new cF;L.time=n.nextFloat32(),L.value=new sp(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new sy(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(c,h,d,_)}t(i)})},a9),e.AnimationClipDecoder=hn([hj("AnimationClip")],e.AnimationClipDecoder);var h1=((oe=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},oe),h2=((on=(ot=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)},on._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),hZ.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})},on._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=hd(a);!(e=o()).done;){var s=e.value;h$.parseChildren(n,r,s)}for(var l=a.map(function(e){return r.get(e)}),u=0;u<l.length;u++)i.addRootEntity(l[u])},on._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],u=l.refId?l.refId:l.class,c=void 0;"Animator"===u&&(c=o.getComponent(u2.getClass(u))),c=c||o.addComponent(u2.getClass(u));var h=hZ.parsePropsAndMethods(c,l,o.engine);n.push(h)}return Promise.all(n)},on._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},ot.parse=function(e,t){var n=new uB(e),r=new h1(t,n),i=new ot(r);return i.start(),i.promise},ot);function h3(e,t){var n=hK.decode(e),r=new hW(e,n.headerLength,n.dataLength);return hX[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(ht(or=function(){return u2.apply(this,arguments)},u2),or.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){h3(e,t.engine).then(function(e){r(e)})}).catch(i)})},or),e.MeshLoader=hn([ll("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(ht(oi=function(){return u2.apply(this,arguments)},u2),oi.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){h3(e,t.engine).then(function(e){r(e)})}).catch(i)})},oi),e.EditorTextureLoader=hn([ll("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var h4=(ht(oa=function(){return u2.apply(this,arguments)},u2),oa.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"arraybuffer"})).then(function(e){return h3(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oa);h4=hn([ll(e.AssetType.Mesh,["mesh"])],h4);var h5=(ht(oo=function(){return u2.apply(this,arguments)},u2),(os=oo.prototype).load=function(e,t){var n=this;return new lo(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new la(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},os._registerFont=function(e,t){return hl(function(){var n;return hr(this,function(r){switch(r.label){case 0:return[4,(n=new FontFace(e,"url("+t+")")).load()];case 1:return r.sent(),document.fonts.add(n),[2]}})})()},oo);h5=hn([ll(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],h5);var h8=(ht(ol=function(){var e;return e=u2.apply(this,arguments)||this,e._tempRect=new sT,e._tempVec2=new sv,e._tempVec4=new sy,e},u2),(ou=ol.prototype).load=function(t,n){var r=this;return new lo(function(i,a,o,s){var l=[];s(function(){for(var e=0;e<l.length;e++)l[e].cancel()});var u=r.request(t.url,c9({},t,{type:"json"}));l.push(u),u.then(function(o){var s=o.atlasItems,u=o.mipmap,c=o.anisoLevel,h=o.filterMode,d=o.wrapModeU,_=o.wrapModeV,f=o.format,p=s?s.length:0,g=n.engine,m=new u9(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:hg.parseRelativeUrl(t.url,o.img),type:e.AssetType.Texture2D,params:{format:f,mipmap:u}}).then(function(e){c&&(e.anisoLevel=c),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);lo.all(l).then(function(){i(m)}).catch(a)}).catch(a)})},ou._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new ce(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 u=1/n.width,c=1/n.height;if(l.atlasRegion.set(a.x*u,a.y*c,a.w*u,a.h*c),i){var h=i.x,d=i.y,_=i.z,f=i.w;l.atlasRegionOffset.set(h*u,d*c,_*u,f*c)}t.atlasRotated&&(l.atlasRotated=!0)}return l},ol);h8=hn([ll(e.AssetType.SpriteAtlas,["atlas"],!1)],h8);var h6=(ht(oc=function(){return u2.apply(this,arguments)},u2),oc.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},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 ce(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new ce(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},oc);h6=hn([ll(e.AssetType.Sprite,["sprite"],!1)],h6);var h7=(ht(oh=function(){return u2.apply(this,arguments)},u2),oh.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"image"})).then(function(n){var i,a=null!=(i=e.params)?i:{},o=new le(t.engine,n.width,n.height,a.format,a.mipmap);if(o._platformTexture){if(o.setImageSource(n),o.generateMipmaps(),0!==e.url.indexOf("data:")){var s=e.url.split("/");o.name=s[s.length-1]}r(o)}}).catch(function(e){i(e)})})},oh);h7=hn([ll(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],h7);var h9=(ht(od=function(){return u2.apply(this,arguments)},u2),od.prototype.load=function(t,n){var r=this;return new lo(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,c9({},t,{type:"image"}))})).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}var o=new ln(n.engine,a);if(o._platformTexture){for(var s=0;s<6;s++)o.setImageSource(e.TextureCubeFace.PositiveX+s,t[s],0);o.generateMipmaps(),i(o)}}).catch(function(e){a(e)})})},od);h9=hn([ll(e.AssetType.TextureCube,[""])],h9);var de=(ht(o_=function(){return u2.apply(this,arguments)},u2),o_.prototype.load=function(e,t){var n=this;return new lo(function(r,i){n.request(e.url,c9({},e,{type:"arraybuffer"})).then(function(e){return h3(e,t.engine).then(r)}).catch(i)})},o_);de=hn([ll(e.AssetType.AnimationClip,["ani"])],de);var dt=(ht(of=function(){return u2.apply(this,arguments)},u2),of.prototype.load=function(t,n){var r=this,i=n.engine;return new lo(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),h2.parse(i,t).then(function(r){var o=t.scene.ambient,s=Promise.resolve();o.ambientLight?s=n.getResourceByRef(t.scene.ambient.ambientLight).then(function(e){r.ambientLight=e,r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity}):(r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor));var l=t.scene.background;r.background.mode=l.mode;var u=Promise.resolve();switch(r.background.mode){case e.BackgroundMode.SolidColor:r.background.solidColor.copyFrom(l.color);break;case e.BackgroundMode.Sky:l.sky&&(u=n.getResourceByRef(l.sky).then(function(e){var t=r.background.sky,n=new cP(i);n.textureCubeMap=e.specularTexture,n.textureDecodeRGBM=!0,t.material=n,t.mesh=uC.createCuboid(i,1,1,1)}));break;case e.BackgroundMode.Texture:l.texture&&(u=n.getResourceByRef(l.texture).then(function(e){r.background.texture=e}))}var c=t.scene.shadow;c&&(void 0!=c.castShadows&&(r.castShadows=c.castShadows),void 0!=c.shadowResolution&&(r.shadowResolution=c.shadowResolution),void 0!=c.shadowDistance&&(r.shadowDistance=c.shadowDistance),void 0!=c.shadowCascades&&(r.shadowCascades=c.shadowCascades));var h=t.scene.fog;return h&&(void 0!=h.fogMode&&(r.fogMode=h.fogMode),void 0!=h.fogStart&&(r.fogStart=h.fogStart),void 0!=h.fogEnd&&(r.fogEnd=h.fogEnd),void 0!=h.fogDensity&&(r.fogDensity=h.fogDensity),void 0!=h.fogColor&&r.fogColor.copyFrom(h.fogColor)),Promise.all([s,u]).then(function(){a(r)})})}).catch(o)})},of);dt=hn([ll(e.AssetType.Scene,["prefab"],!0)],dt),hZ.registerCustomParseComponent("TextRenderer",hl(function(e,t,n){var r;return hr(this,function(i){return(r=t.props).font||(e.font=la.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var dn=(ht(op=function(){return hv.apply(this,arguments)},hv),(og=op.prototype).initialize=function(){dn._decoder||(dn._decoder=new c7)},og.createAndParse=function(e,t,n,r){var i=this,a=e.gltf,o=e.buffers,s=e.glTFResource.engine,l=a.bufferViews,u=a.accessors,c=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=u[n.attributes[p]];_[p]=hg.getComponentType(g.componentType).name}var m=u[n.indices],v=hg.getComponentType(m.componentType).name,y=hg.getBufferViewData(l[c],o);return dn._decoder.decode(y,{attributeIDs:d,attributeTypes:_,useUniqueIDs:!0,indexType:v}).then(function(t){var o=new uf(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)})},og._parseMeshFromGLTFPrimitiveDraco=function(e,t,n,r,i,a,o,s){var l,u=n.attributes,c=n.targets,h=n.indices,d=n.mode,_=r.accessors,f=_[u.POSITION],p=i("POSITION"),g=hg.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=dn._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),sl.min(y,v,y),sl.max(x,v,x)}}for(var w in u)if("POSITION"!==w){var b=i(w);switch(w){case"NORMAL":var A=hg.floatBufferToVector3Array(b);e.setNormals(A);break;case"TEXCOORD_0":var M=hg.floatBufferToVector2Array(b);e.setUVs(M,0);break;case"TEXCOORD_1":var F=hg.floatBufferToVector2Array(b);e.setUVs(F,1);break;case"TEXCOORD_2":var P=hg.floatBufferToVector2Array(b);e.setUVs(P,2);break;case"TEXCOORD_3":var E=hg.floatBufferToVector2Array(b);e.setUVs(E,3);break;case"TEXCOORD_4":var R=hg.floatBufferToVector2Array(b);e.setUVs(R,4);break;case"TEXCOORD_5":var L=hg.floatBufferToVector2Array(b);e.setUVs(L,5);break;case"TEXCOORD_6":var B=hg.floatBufferToVector2Array(b);e.setUVs(B,6);break;case"TEXCOORD_7":var D=hg.floatBufferToVector2Array(b);e.setUVs(D,7);break;case"COLOR_0":var I=hg.floatBufferToColorArray(b,_[u.COLOR_0].type===o6.VEC3);e.setColors(I);break;case"TANGENT":var O=hg.floatBufferToVector4Array(b);e.setTangents(O);break;case"JOINTS_0":var V=hg.floatBufferToVector4Array(b);e.setBoneIndices(V);break;case"WEIGHTS_0":var U=hg.floatBufferToVector4Array(b);e.setBoneWeights(U)}}if(void 0!==h){var z=r.accessors[h],N=o();e.setIndices(N),e.addSubMesh(0,z.count,d)}else e.addSubMesh(0,l,d);return c&&hA._createBlendShape(e,t,c,a),e.uploadData(!s),Promise.resolve(e)},op._tempVector3=new sl,op);dn=hn([hx("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],dn);var dr=(ht(om=function(){return hv.apply(this,arguments)},hv),om.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,u=i.spot,c=e.glTFResource;if("directional"===s?r=t.addComponent(lY):"point"===s?r=t.addComponent(lQ):"spot"===s&&(r=t.addComponent(lJ)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!hb(r,lY)&&(r.distance=l),u&&hb(r,lJ)){var h=u.innerConeAngle,d=void 0===h?0:h,_=u.outerConeAngle;r.angle=d,r.penumbra=(void 0===_?Math.PI/4:_)-d}c.lights||(c.lights=[]),c.lights.push(r)},om);dr=hn([hx("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],dr);var di=(ht(ov=function(){return hv.apply(this,arguments)},hv),ov.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],hw._checkOtherTextureTransform(a,"Clear coat")),s&&(t.clearCoatRoughnessTexture=r[s.index],hw._checkOtherTextureTransform(s,"Clear coat roughness")),l&&(t.clearCoatNormalTexture=r[l.index],hw._checkOtherTextureTransform(l,"Clear coat normal"))},ov);di=hn([hx("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],di);var da=(ht(oy=function(){return hv.apply(this,arguments)},hv),oy.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},oy);da=hn([hx("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],da);var ds=(ht(ox=function(){return hv.apply(this,arguments)},hv),ox.prototype.createAndParse=function(e,t,n){var r=e.glTFResource,i=r.engine,a=r.textures,o=new u6(i),s=t.diffuseFactor,l=t.diffuseTexture,u=t.specularFactor,c=t.glossinessFactor,h=t.specularGlossinessTexture;return s&&(o.baseColor=new sx(sx.linearToGammaSpace(s[0]),sx.linearToGammaSpace(s[1]),sx.linearToGammaSpace(s[2]),s[3])),l&&(o.baseTexture=a[l.index],hy.executeExtensionsAdditiveAndParse(l.extensions,e,o,l)),u&&(o.specularColor=new sx(sx.linearToGammaSpace(u[0]),sx.linearToGammaSpace(u[1]),sx.linearToGammaSpace(u[2]))),void 0!==c&&(o.glossiness=c),h&&(o.specularGlossinessTexture=a[h.index],hw._checkOtherTextureTransform(h,"Specular glossiness")),o.name=n.name,hw._parseStandardProperty(e,o,n),o},ox);ds=hn([hx("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],ds);var dl=(ht(oT=function(){return hv.apply(this,arguments)},hv),oT.prototype.createAndParse=function(e,t,n){var r=e.glTFResource.engine,i=new u7(r);return i.name=n.name,hw._parseStandardProperty(e,i,n),i},oT);dl=hn([hx("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],dl);var du=(ht(oC=function(){return hv.apply(this,arguments)},hv),oC);du=hn([hx("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],du);var dc=(ht(oS=function(){return hv.apply(this,arguments)},hv),oS.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&&sj.warn("rotation in KHR_texture_transform is not supported now"),o&&sj.warn("texCoord in KHR_texture_transform is not supported now")},oS);dc=hn([hx("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],dc);var dh=(ht(ow=function(){return hv.apply(this,arguments)},hv),ow.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},ow);dh=hn([hx("OASIS_materials_remap",e.GLTFExtensionMode.CreateAndParse)],dh);var dd="0.0.0-experimental-0.9-plus.8";for(var d_ in console.log("Galacean engine version: "+dd),cz)u2.registerClass(d_,cz[d_]);e.AmbientLight=uL,e.AnimationClip=cp,e.AnimationClipCurveBinding=c_,e.AnimationCurve=cg,e.AnimationEvent=cf,e.Animator=cC,e.AnimatorController=cS,e.AnimatorControllerLayer=cw,e.AnimatorState=cA,e.AnimatorStateMachine=cM,e.AnimatorStateTransition=cv,e.AssetPromise=lo,e.Background=uR,e.BaseMaterial=u3,e.BasicRenderPipeline=uq,e.BlendShape=ub,e.BlendShapeFrame=uw,e.BlinnPhongMaterial=u4,e.BoolUpdateFlag=lm,e.BoundingBox=sc,e.BoundingFrustum=s_,e.BoundingSphere=su,e.BoxColliderShape=lE,e.Buffer=ul,e.BufferMesh=uS,e.BufferUtil=uo,e.CapsuleColliderShape=lB,e.CharacterController=lF,e.CloneManager=sO,e.ColliderShape=lP,e.CollisionUtil=sh,e.Color=sx,e.Component=lv,e.ComponentMap=h0,e.CubeProbe=cU,e.DirectLight=lY,e.DynamicCollider=lk,e.Engine=uU,e.EngineObject=sV,e.Entity=lT,e.Event=sz,e.EventDispatcher=sN,e.FixedJoint=lI,e.Font=la,e.GLTFAnimationParser=hT,e.GLTFBufferParser=hC,e.GLTFEntityParser=hS,e.GLTFExtensionParser=hv,e.GLTFMaterialParser=hw,e.GLTFMeshParser=hA,e.GLTFParser=hy,e.GLTFParserContext=h_,e.GLTFPipeline=hR,e.GLTFResource=hL,e.GLTFSceneParser=hM,e.GLTFSkinParser=hF,e.GLTFTextureParser=hP,e.GLTFUtil=hg,e.GLTFValidator=hE,e.HingeJoint=lO,e.HitResult=lb,e.IndexBufferBinding=uu,e.InputManager=lj,e.JointLimits=lU,e.JointMotor=lz,e.Keyframe=cF,e.Light=lq,e.Loader=u2,e.Logger=sj,e.Material=l5,e.MathUtil=ss,e.Matrix=sg,e.Matrix3x3=sf,e.Mesh=uh,e.MeshRenderElement=l7,e.MeshRenderer=ug,e.ModelMesh=uf,e.ObjectValues=s6,e.PBRBaseMaterial=u5,e.PBRMaterial=u8,e.PBRSpecularMaterial=u6,e.ParticleRenderer=cE,e.PhysicsManager=lA,e.PhysicsMaterial=lM,e.Plane=sd,e.PlaneColliderShape=lL,e.PointLight=lQ,e.Pointer=lC,e.PrefabParser=h$,e.PrimitiveMesh=uC,e.Probe=cD,e.Quaternion=sp,e.Ray=sm,e.Rect=sT,e.RefObject=sU,e.ReflectionParser=hZ,e.RenderPass=uK,e.RenderQueue=uk,e.RenderTarget=s9,e.ResourceManager=ls,e.Scene=uB,e.SceneManager=uD,e.SceneParser=h2,e.Script=uz,e.Shader=s3,e.ShaderData=lK,e.ShaderFactory=sJ,e.ShaderPass=s1,e.ShaderProperty=s2,e.Skin=up,e.SkinnedMeshRenderer=uT,e.Sky=uE,e.SkyBoxMaterial=cP,e.SphereColliderShape=lR,e.SphericalHarmonics3=sC,e.SpotLight=lJ,e.SpringJoint=lV,e.Sprite=ce,e.SpriteAtlas=u9,e.SpriteElement=ue,e.SpriteMask=ua,e.SpriteRenderer=cn,e.StateMachineScript=cb,e.StaticCollider=lN,e.SubMesh=uc,e.SystemInfo=lS,e.TextRenderer=co,e.Texture=s7,e.Texture2D=le,e.Texture2DArray=lt,e.TextureCube=ln,e.Time=s4,e.TrailMaterial=cR,e.TrailRenderer=cB,e.Transform=lx,e.UnlitMaterial=u7,e.Util=s5,e.Vector2=sv,e.Vector3=sl,e.Vector4=sy,e.VertexBufferBinding=ud,e.VertexElement=us,e.WebCanvas=cH,e.WebGLEngine=c3,e.WebGLRenderer=c2,e.assignmentClone=sB,e.decode=h3,e.deepClone=sI,e.dependentComponents=lg,e.ignoreClone=sL,e.parseSingleKTX=hU,e.registerGLTFExtension=hx,e.request=uZ,e.resourceLoader=ll,e.shallowClone=sD,e.version=dd,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,(o9=e.ContainmentType||(e.ContainmentType={}))[o9.Disjoint=0]="Disjoint",o9[o9.Contains=1]="Contains",o9[o9.Intersects=2]="Intersects",e.PlaneIntersectionType=void 0,(se=e.PlaneIntersectionType||(e.PlaneIntersectionType={}))[se.Back=0]="Back",se[se.Front=1]="Front",se[se.Intersecting=2]="Intersecting",e.FrustumFace=void 0,(st=e.FrustumFace||(e.FrustumFace={}))[st.Near=0]="Near",st[st.Far=1]="Far",st[st.Left=2]="Left",st[st.Right=3]="Right",st[st.Bottom=4]="Bottom",st[st.Top=5]="Top";var i,a,o,s,l,c,u,h,d,_,f,p,g,m,v,y,x,C,T,S,w,A,E,M,b,R,F,P,L,D,I,B,N,V,O,U,z,k,G,H,W,X,j,K,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,eC,eT,eS,ew,eA,eE,eM,eb,eR,eF,eP,eL,eD,eI,eB,eN,eV,eO,eU,ez,ek,eG,eH,eW,eX,ej,eK,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,tC,tT,tS,tw,tA,tE,tM,tb,tR,tF,tP,tL,tD,tI,tB,tN,tV,tO,tU,tz,tk,tG,tH,tW,tX,tj,tK,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,nC,nT,nS,nw,nA,nE,nM,nb,nR,nF,nP,nL,nD,nI,nB,nN,nV,nO,nU,nz,nk,nG,nH,nW,nX,nj,nK,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,rC,rT,rS,rw,rA,rE,rM,rb,rR,rF,rP,rL,rD,rI,rB,rN,rV,rO,rU,rz,rk,rG,rH,rW,rX,rj,rK,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,iC,iT,iS,iw,iA,iE,iM,ib,iR,iF,iP,iL,iD,iI,iB,iN,iV,iO,iU,iz,ik,iG,iH,iW,iX,ij,iK,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,aC,aT,aS,aw,aA,aE,aM,ab,aR,aF,aP,aL,aD,aI,aB,aN,aV,aO,aU,az,ak,aG,aH,aW,aX,aj,aK,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,oC,oT,oS,ow,oA,oE,oM,ob,oR,oF,oP,oL,oD,oI,oB,oN,oV,oO,oU,oz,ok,oG,oH,oW,oX,oj,oK,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,sC,sT,sS,sw,sA,sE,sM,sb,sR,sF,sP,sL,sD,sI,sB,sN,sV,sO,sU,sz,sk,sG,sH,sW,sX,sj,sK,sq,sY=((sn=function(){}).clamp=function(e,t,n){return Math.max(t,Math.min(n,e))},sn.equals=function(e,t){return Math.abs(e-t)<=sn.zeroTolerance},sn.isPowerOf2=function(e){return(e&e-1)==0},sn.radianToDegree=function(e){return e*sn.radToDegreeFactor},sn.degreeToRadian=function(e){return e*sn.degreeToRadFactor},sn);sY.zeroTolerance=1e-6,sY.radToDegreeFactor=180/Math.PI,sY.degreeToRadFactor=Math.PI/180;var sQ=((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 sY.equals(e._x,t._x)&&sY.equals(e._y,t._y)&&sY.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>sY.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);sQ._zero=new sQ(0,0,0),sQ._one=new sQ(1,1,1);var sJ=((s=(o=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.center=new sQ,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)sQ.add(e[i],r,r);sQ.scale(r,1/n,t.center);for(var a=0,s=0;s<n;++s){var l=sQ.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=sQ.distance(n,i)},o);sJ._tempVec30=new sQ;var sZ=((c=(l=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.min=new sQ,this.max=new sQ,e&&this.min.copyFrom(e),t&&this.max.copyFrom(t)}).prototype).getCenter=function(e){return sQ.add(this.min,this.max,e),sQ.scale(e,.5,e),e},c.getExtent=function(e){return sQ.subtract(this.max,this.min,e),sQ.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 sQ;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){sQ.subtract(e,t,n.min),sQ.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];sQ.min(n,o,n),sQ.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),sQ.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]),sQ.subtract(r,i,n.min),sQ.add(r,i,n.max)},l.merge=function(e,t,n){return sQ.min(e.min,t.min,n.min),sQ.max(e.max,t.max,n.max),n},l);sZ._tempVec30=new sQ,sZ._tempVec31=new sQ;var s$=((u=function(){}).intersectionPointThreePlanes=function(e,t,n,r){var i=e.normal,a=t.normal,o=n.normal;sQ.cross(a,o,u._tempVec30),sQ.cross(o,i,u._tempVec31),sQ.cross(i,a,u._tempVec32);var s=-sQ.dot(i,u._tempVec30),l=-sQ.dot(a,u._tempVec31),c=-sQ.dot(o,u._tempVec32);sQ.scale(u._tempVec30,e.distance/s,u._tempVec30),sQ.scale(u._tempVec31,t.distance/l,u._tempVec31),sQ.scale(u._tempVec32,n.distance/c,u._tempVec32),sQ.add(u._tempVec30,u._tempVec31,r),sQ.add(r,u._tempVec32,r)},u.distancePlaneAndPoint=function(e,t){return sQ.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=sY.zeroTolerance,i=sQ.dot(n,e.direction);if(Math.abs(i)<r)return -1;var a=sQ.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=sY.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,C=(o.y-h)*y;if(x>C){var T=x;x=C,C=T}if((_=Math.max(x,_))>(f=Math.min(C,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;sQ.subtract(n,i,o);var s=sQ.dot(o,r),l=sQ.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 sQ.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))),sQ.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),sQ.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)<sY.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.far,n))<sY.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.left,n))<sY.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.right,n))<sY.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.top,n))<sY.zeroTolerance?e.ContainmentType.Intersects:r<0?e.ContainmentType.Disjoint:Math.abs(r=u.distancePlaneAndPoint(t.bottom,n))<sY.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);s$._tempVec30=new sQ,s$._tempVec31=new sQ,s$._tempVec32=new sQ;var s0=((d=(h=function(e,t){void 0===e&&(e=null),void 0===t&&(t=0),this.normal=new sQ,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();sQ.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),s1=((f=(_=function(e){void 0===e&&(e=null),this.near=new s0,this.far=new s0,this.left=new s0,this.right=new s0,this.top=new s0,this.bottom=new s0,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 s$.intersectsFrustumAndBox(this,e)},f.intersectsSphere=function(t){return s$.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},_),s2=((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],C=i[6],T=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*C+c*T+d*S,a[7]=s*C+u*T+_*S,a[8]=l*C+h*T+f*S},p.equals=function(e,t){var n=e.elements,r=t.elements;return sY.equals(n[0],r[0])&&sY.equals(n[1],r[1])&&sY.equals(n[2],r[2])&&sY.equals(n[3],r[3])&&sY.equals(n[4],r[4])&&sY.equals(n[5],r[5])&&sY.equals(n[6],r[6])&&sY.equals(n[7],r[7])&&sY.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,C=i*u-o*l,T=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-C*F+T*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*T-g*A-y*C)*L,r[8]=(g*w-m*T+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),s3=((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<sY.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 sY.equals(e._x,t._x)&&sY.equals(e._y,t._y)&&sY.equals(e._z,t._z)&&sY.equals(e._w,t._w)},m.rotationAxisAngle=function(e,t,n){var r=m._tempVector3;sQ.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>sY.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-sY.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>sY.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)<sY.zeroTolerance}},{key:"w",get:function(){return this._w},set:function(e){this._w=e,this._onValueChanged&&this._onValueChanged()}}]),m);s3._tempVector3=new sQ,s3._tempQuat1=new s3;var s4=((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),C=(0>Math.sign(f*p*g*m)?-1:1)*Math.sqrt(f*f+p*p+g*g);if(n.set(v,x,C),Math.abs(v)<sY.zeroTolerance||Math.abs(x)<sY.zeroTolerance||Math.abs(C)<sY.zeroTolerance)return t.identity(),!1;var T=1/v,S=1/x,w=1/C;return a[0]=o*T,a[1]=s*T,a[2]=l*T,a[3]=u*S,a[4]=h*S,a[5]=d*S,a[6]=f*w,a[7]=p*w,a[8]=g*w,s3.rotationMatrix3x3(r,t),!0},x.getRotation=function(e){var t=this.elements,n=t[0]+t[5]+t[10];if(n>sY.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],C=r[15],T=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*T+u*S+f*w+v*A,a[1]=s*T+h*S+p*w+y*A,a[2]=l*T+d*S+g*w+x*A,a[3]=c*T+_*S+m*w+C*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+C*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+C*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+C*V},y.equals=function(e,t){var n=e.elements,r=t.elements;return sY.equals(n[0],r[0])&&sY.equals(n[1],r[1])&&sY.equals(n[2],r[2])&&sY.equals(n[3],r[3])&&sY.equals(n[4],r[4])&&sY.equals(n[5],r[5])&&sY.equals(n[6],r[6])&&sY.equals(n[7],r[7])&&sY.equals(n[8],r[8])&&sY.equals(n[9],r[9])&&sY.equals(n[10],r[10])&&sY.equals(n[11],r[11])&&sY.equals(n[12],r[12])&&sY.equals(n[13],r[13])&&sY.equals(n[14],r[14])&&sY.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)<sY.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,C=e._x,T=e._y,S=e._z;i[0]=(1-(p+m))*C,i[1]=(_+x)*C,i[2]=(f-y)*C,i[3]=0,i[4]=(_-x)*T,i[5]=(1-(d+m))*T,i[6]=(g+v)*T,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,C=i*u-o*l,T=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-C*F+T*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*T-g*A-y*C)*L,r[7]=(d*A-f*T+p*C)*L,r[8]=(l*F-c*b+h*E)*L,r[9]=(a*b-i*F-s*E)*L,r[10]=(g*w-m*T+y*x)*L,r[11]=(_*T-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*C-g*S-v*x)*L,r[15]=(d*S-_*C+f*x)*L},y.lookAt=function(e,t,n,r){var i=r.elements,a=y._tempVec30,o=y._tempVec31,s=y._tempVec32;sQ.subtract(e,t,s),s.normalize(),sQ.cross(n,s,a),a.normalize(),sQ.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]=-sQ.dot(a,e),i[13]=-sQ.dot(o,e),i[14]=-sQ.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)<sY.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],C=h[8],T=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+C*M,d[1]=f*A+v*E+T*M,d[2]=p*A+y*E+S*M,d[3]=g*A+x*E+w*M,d[4]=_*b+m*R+C*F,d[5]=f*b+v*R+T*F,d[6]=p*b+y*R+S*F,d[7]=g*b+x*R+w*F,d[8]=_*P+m*L+C*D,d[9]=f*P+v*L+T*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);s4._tempVec30=new sQ,s4._tempVec31=new sQ,s4._tempVec32=new sQ,s4._tempMat30=new s2,s4._identity=new s4(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);var s5=((T=(C=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),this.origin=new sQ,this.direction=new sQ,e&&this.origin.copyFrom(e),t&&this.direction.copyFrom(t)}).prototype).intersectPlane=function(e){return s$.intersectsRayAndPlane(this,e)},T.intersectSphere=function(e){return s$.intersectsRayAndSphere(this,e)},T.intersectBox=function(e){return s$.intersectsRayAndBox(this,e)},T.getPoint=function(e,t){return sQ.scale(this.direction,e,t),t.add(this.origin)},C),s8=((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 sY.equals(e._x,t._x)&&sY.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>sY.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);s8._zero=new s8(0,0),s8._one=new s8(1,1);var s6=((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 sY.equals(e._x,t._x)&&sY.equals(e._y,t._y)&&sY.equals(e._z,t._z)&&sY.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>sY.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);s6._zero=new s6(0,0,0,0),s6._one=new s6(1,1,1,1);var s7=((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 sY.equals(e._r,t._r)&&sY.equals(e._g,t._g)&&sY.equals(e._b,t._b)&&sY.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),s9=((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._onValueChanged=null,this._x=e,this._y=t,this._width=n,this._height=r}).prototype).set=function(e,t,n,r){return this._x=e,this._y=t,this._width=n,this._height=r,this._onValueChanged&&this._onValueChanged(),this},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._onValueChanged&&this._onValueChanged(),this},r(R,[{key:"x",get:function(){return this._x},set:function(e){this._x=e,this._onValueChanged&&this._onValueChanged()}},{key:"y",get:function(){return this._y},set:function(e){this._y=e,this._onValueChanged&&this._onValueChanged()}},{key:"width",get:function(){return this._width},set:function(e){this._width=e,this._onValueChanged&&this._onValueChanged()}},{key:"height",get:function(){return this._height},set:function(e){this._height=e,this._onValueChanged&&this._onValueChanged()}}]),R),le=((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 lt(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ln(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function lr(e,t,n){return t&&ln(e.prototype,t),n&&ln(e,n),e}function li(e,t){return(li=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function la(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&&li(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 lo=((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);lo.zeroTolerance=1e-6,lo.radToDegreeFactor=180/Math.PI,lo.degreeToRadFactor=Math.PI/180;var ls=((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 lo.equals(e._r,t._r)&&lo.equals(e._g,t._g)&&lo.equals(e._b,t._b)&&lo.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},lr(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 ll(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 lc(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}function lu(e,t){lf.registerCloneMode(e,t,sr.Ignore)}function lh(e,t){lf.registerCloneMode(e,t,sr.Assignment)}function ld(e,t){lf.registerCloneMode(e,t,sr.Shallow)}function l_(e,t){lf.registerCloneMode(e,t,sr.Deep)}(V=sr||(sr={}))[V.Ignore=0]="Ignore",V[V.Assignment=1]="Assignment",V[V.Shallow=2]="Shallow",V[V.Deep=3]="Deep";var lf=((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(lc(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);lf._subCloneModeMap=new Map,lf._cloneModeMap=new Map,lf._objectType=Object.getPrototypeOf(Object);var lp=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)},lr(e,[{key:"engine",get:function(){return this._engine}},{key:"destroyed",get:function(){return this._destroyed}}]),e}();lp._instanceIdCounter=0,ll([lu],lp.prototype,"instanceId",void 0),ll([lu],lp.prototype,"_engine",void 0);var lg=(la(U=function(e){var t;return(t=lp.call(this,e)||this).isGCIgnored=!1,t._refCount=0,e.resourceManager._addReferResource(lt(t)),t},lp),(z=U.prototype).destroy=function(e){return void 0===e&&(e=!1),(!!e||0===this._refCount)&&(lp.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(){lp.prototype._onDestroy.call(this),this._engine.resourceManager._deleteReferResource(this);var e=this._getReferCount();e>0&&this._addReferCount(-e)},lr(U,[{key:"refCount",get:function(){return this._refCount}}]),U),lm=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,(j=e.TextureUsage||(e.TextureUsage={}))[j.Static=0]="Static",j[j.Dynamic=1]="Dynamic",e.TextureWrapMode=void 0,(K=e.TextureWrapMode||(e.TextureWrapMode={}))[K.Clamp=0]="Clamp",K[K.Repeat=1]="Repeat",K[K.Mirror=2]="Mirror";var lv=(la(q=function(e){var t;return t=lg.call(this,e)||this,e.resourceManager._addGraphicResource(lt(t)),t},lg),q.prototype._onDestroy=function(){lg.prototype._onDestroy.call(this),this.engine.resourceManager._deleteGraphicResource(this)},q),ly=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]},lx=console.log.bind(console),lC=console.info.bind(console),lT=console.warn.bind(console),lS=console.error.bind(console),lw={debug:ly,info:ly,warn:ly,error:ly,isEnabled:!1,enable:function(){this.debug=lx,this.info=lC,this.warn=lT,this.error=lS,this.isEnabled=!0},disable:function(){this.debug=ly,this.info=ly,this.warn=ly,this.error=ly,this.isEnabled=!1}},lA=(la(Y=function(){var e;return e=lv.apply(this,arguments)||this,e._isDepthTexture=!1,e._anisoLevel=1,e._useDepthCompareMode=!1,e},lv),(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(){lv.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},lr(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&&(lw.warn("anisoLevel:"+e+", exceeds the limit and is automatically downgraded to:"+t),e=t),e<1&&(lw.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),lE=(la(J=function(t,n,r,i,a,o){if(void 0===a&&(a=e.RenderBufferDepthFormat.Depth),void 0===o&&(o=1),(s=lv.call(this,t)||this)._autoGenerateMipmaps=!0,s._width=n,s._height=r,s._antiAliasing=o,s._depth=a,i){for(var s,l=lc(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(lc(a,lA)){if(!a._isDepthTexture)throw"Depth texture must use depth format.";s._depthTexture=a,s._depthTexture._addReferCount(1)}return s._platformRenderTarget=t._hardwareRenderer.createPlatformRenderTarget(lt(s)),s},lv),(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(){lv.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)},lr(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),lM=(la($=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=lA.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(lt(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},lA),(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),lA.prototype._rebuild.call(this)},$),lb=(la(et=function(t,n,r,i,a,o){var s;return void 0===a&&(a=e.TextureFormat.R8G8B8A8),void 0===o&&(o=!0),(s=lA.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(lt(s)),s.filterMode=e.TextureFilterMode.Bilinear,s.wrapModeU=s.wrapModeV=e.TextureWrapMode.Repeat,s},lA),(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),lA.prototype._rebuild.call(this)},lr(et,[{key:"length",get:function(){return this._length}}]),et),lR=(la(er=function(t,n,r,i){var a;return void 0===r&&(r=e.TextureFormat.R8G8B8A8),void 0===i&&(i=!0),(a=lA.call(this,t)||this)._mipmap=i,a._width=n,a._height=n,a._format=r,a._mipmapCount=a._getMipmapCount(),a._platformTexture=t._hardwareRenderer.createPlatformTextureCube(lt(a)),a.filterMode=e.TextureFilterMode.Bilinear,a.wrapModeU=a.wrapModeV=e.TextureWrapMode.Clamp,a},lA),(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),lA.prototype._rebuild.call(this)},er),lF=(la(ea=function(e){var t;return(t=lg.call(this,e)||this)._charInfoMap={},t._space=1,t._curX=1,t._curY=1,t._nextY=1,t},lg),(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 s8(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(){lg.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 lP=((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=ub._pixelsPerUnit,u=i.size+t.lineSpacing*c,h=t.width*c,d=0;n.nativeFontString=r;for(var _=0,f=a.length;_<f;_++){var p=a[_];if(0===p.length){this._pushLine(o,s,l,"",0,0,0);continue}for(var g="",m=0,v=0,y=0,x="",C=0,T=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&&(C+m>h?(C>0&&this._pushLine(o,s,l,x,C,T,S),d=Math.max(d,C),w=!0,x=g,C=m,T=v,S=y):(x+=g,C+=m,T=Math.max(T,v),S=Math.max(S,y)),g="",m=v=y=0),C+L>h&&C>0?(this._pushLine(o,s,l,x,C,T,S),d=Math.max(d,C),w=!0,F?(x="",C=T=S=0):(x=M,C=b.xAdvance,T=B,S=N)):(x+=M,C+=b.xAdvance,T=Math.max(T,B),S=Math.max(S,N))):m+b.w>h?(C>0&&(this._pushLine(o,s,l,x,C,T,S),d=Math.max(d,C),x="",C=T=S=0),m>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=T=Math.max(v,B),y=S=Math.max(y,N))}}m>0&&(C+m>h?(C>0&&this._pushLine(o,s,l,x,C,T,S),d=Math.max(d,C),C=0,m>0&&this._pushLine(o,s,l,g,m,v,y),d=Math.max(d,m)):(x+=g,C+=m,T=Math.max(T,v),S=Math.max(S,y))),C>0&&(this._pushLine(o,s,l,x,C,T,S),d=Math.max(d,C))}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=[],u=ub._pixelsPerUnit,h=i.size+t.lineSpacing*u,d=0;n.nativeFontString=r;for(var _=0;_<o;++_){for(var f=a[_],p=0,g=0,m=0,v=0,y=f.length;v<y;++v){var x=ec._getCharInfo(f[v],r,n);p+=x.xAdvance;var C=x.offsetY,T=.5*x.h,S=T+C,w=T-C;g<S&&(g=S),m<w&&(m=w)}p>0&&(this._pushLine(s,l,c,f,p,g,m),d=Math.max(d,p))}var A=t.height*u;return t.overflowMode===e.OverflowMode.Overflow&&(A=h*s.length),{width:d,height:A,lines:s,lineWidths:l,lineHeight:h,lineMaxSizes:c}},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 C=null;if(g>0){var T=4*m;C=new Uint8Array(u.buffer,d*T,g*T)}return{char:t,x:0,y:0,w:s,h:g,offsetX:0,offsetY:(f-p)*.5,xAdvance:s,uvs:[new s8,new s8,new s8,new s8],ascent:f,descent:p,index:0,data:C}},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);lP._genericFontFamilies=["serif","sans-serif","monospace","cursive","fantasy","system-ui","math","emoji","fangsong"],lP._measureString="|\xc9q\xc5",lP._measureBaseline="M",lP._heightMultiplier=2,lP._baselineMultiplier=1.4,lP._fontSizeInfoCache={},lP._textContext=null;var lL=((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 lF(t),r=new lM(t,256,256);n.texture=r,n.isGCIgnored=r.isGCIgnored=!0,this._fontAtlases.push(n);var i=this.nativeFontString;return t.resourceManager.addContentRestorer(new(la(e=function(){return lm.call(this,n)},lm),e.prototype.restoreContent=function(){var e=this.resource,t=e._charInfoMap,n=e.texture;for(var r in t){var a=t[r],o=lP.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),lD=(la(ed=function(e,t){var n;return void 0===t&&(t=""),(n=lg.call(this,e)||this)._name="",n._subFontMap={},n._name=t,n},lg),(e_=ed.prototype)._getSubFont=function(e,t){var n=e+"-"+t,r=this._subFontMap,i=r[n];return i||(i=new lL(this.engine),r[n]=i),i},e_._onDestroy=function(){lg.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},lr(ed,[{key:"name",get:function(){return this._name}}]),ed),lI=((ep=(ef=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++},ep.delete=function(e){var t=this._elements.indexOf(e);this.deleteByIndex(t)},ep.set=function(e,t){if(e>=this.length)throw"Index is out of range.";this._elements[e]=t},ep.get=function(e){if(e>=this.length)throw"Index is out of range.";return this._elements[e]},ep.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},ep.garbageCollection=function(){this._elements.length=this.length},ef),lB=((em=(eg=function(){this._renderers=new lI,this._onStartScripts=new lI,this._onUpdateScripts=new lI,this._onLateUpdateScripts=new lI,this._onPhysicsUpdateScripts=new lI,this._disableScripts=[],this._pendingDestroyScripts=[],this._disposeDestroyScripts=[],this._onUpdateAnimations=new lI,this._onUpdateRenderers=new lI,this._componentsContainerPool=[]}).prototype).addRenderer=function(e){e._rendererIndex=this._renderers.length,this._renderers.add(e)},em.removeRenderer=function(e){var t=this._renderers.deleteByIndex(e._rendererIndex);t&&(t._rendererIndex=e._rendererIndex),e._rendererIndex=-1},em.addOnStartScript=function(e){e._onStartIndex=this._onStartScripts.length,this._onStartScripts.add(e)},em.removeOnStartScript=function(e){var t=this._onStartScripts.deleteByIndex(e._onStartIndex);t&&(t._onStartIndex=e._onStartIndex),e._onStartIndex=-1},em.addOnUpdateScript=function(e){e._onUpdateIndex=this._onUpdateScripts.length,this._onUpdateScripts.add(e)},em.removeOnUpdateScript=function(e){var t=this._onUpdateScripts.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},em.addOnLateUpdateScript=function(e){e._onLateUpdateIndex=this._onLateUpdateScripts.length,this._onLateUpdateScripts.add(e)},em.removeOnLateUpdateScript=function(e){var t=this._onLateUpdateScripts.deleteByIndex(e._onLateUpdateIndex);t&&(t._onLateUpdateIndex=e._onLateUpdateIndex),e._onLateUpdateIndex=-1},em.addOnPhysicsUpdateScript=function(e){e._onPhysicsUpdateIndex=this._onPhysicsUpdateScripts.length,this._onPhysicsUpdateScripts.add(e)},em.removeOnPhysicsUpdateScript=function(e){var t=this._onPhysicsUpdateScripts.deleteByIndex(e._onPhysicsUpdateIndex);t&&(t._onPhysicsUpdateIndex=e._onPhysicsUpdateIndex),e._onPhysicsUpdateIndex=-1},em.addOnUpdateAnimations=function(e){e._onUpdateIndex=this._onUpdateAnimations.length,this._onUpdateAnimations.add(e)},em.removeOnUpdateAnimations=function(e){var t=this._onUpdateAnimations.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},em.addOnUpdateRenderers=function(e){e._onUpdateIndex=this._onUpdateRenderers.length,this._onUpdateRenderers.add(e)},em.removeOnUpdateRenderers=function(e){var t=this._onUpdateRenderers.deleteByIndex(e._onUpdateIndex);t&&(t._onUpdateIndex=e._onUpdateIndex),e._onUpdateIndex=-1},em.addDisableScript=function(e){this._disableScripts.push(e)},em.addPendingDestroyScript=function(e){this._pendingDestroyScripts.push(e)},em.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}},em.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)}},em.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)}},em.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()}},em.callAnimationUpdate=function(e){for(var t=this._onUpdateAnimations._elements,n=this._onUpdateAnimations.length-1;n>=0;--n){var r=t[n];r.engine.time.frameCount>r._playFrameCount&&r.update(e)}},em.callRendererOnUpdate=function(e){for(var t=this._onUpdateRenderers._elements,n=this._onUpdateRenderers.length-1;n>=0;--n)t[n].update(e)},em.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}},em.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)}},em.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)}},em.getActiveChangedTempList=function(){return this._componentsContainerPool.length?this._componentsContainerPool.pop():[]},em.putActiveChangedTempList=function(e){e.length=0,this._componentsContainerPool.push(e)},em._gc=function(){this._renderers.garbageCollection(),this._onStartScripts.garbageCollection(),this._onUpdateScripts.garbageCollection(),this._onLateUpdateScripts.garbageCollection(),this._onPhysicsUpdateScripts.garbageCollection(),this._onUpdateAnimations.garbageCollection(),this._onUpdateRenderers.garbageCollection()},eg),lN=((ey=(ev=function(){this._events=Object.create(null),this._eventCount=0}).prototype).hasEvent=function(e){return null!=this._events[e]},ey.eventNames=function(){return 0===this._eventCount?[]:Object.keys(this._events)},ey.listenerCount=function(e){var t=this._events[e];return t?Array.isArray(t)?t.length:1:0},ey.dispatch=function(e,t){if(!this._events[e])return!1;var n=this._events[e];if(Array.isArray(n)){var r=n.length,i=ev._dispatchingListenersPool,a=i.length>0?i.pop():[];a.length=r;for(var o=0;o<r;o++)a[o]=n[o];for(var s=0;s<r;s++){var l=a[s];l.destroyed||(l.once&&this.off(e,l.fn),l.fn(t))}a.length=0,i.push(a)}else n.once&&this.off(e,n.fn),n.fn(t);return!0},ey.on=function(e,t){return this._addEventListener(e,t)},ey.once=function(e,t){return this._addEventListener(e,t,!0)},ey.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},ey.removeEventListener=function(e,t){return this.off(e,t)},ey.removeAllEventListeners=function(e){e?this._events[e]&&this._clearEvent(e):(this._events=Object.create(null),this._eventCount=0)},ey._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},ey._clearEvent=function(e){0==--this._eventCount?this._events=Object.create(null):delete this._events[e]},ev);lN._dispatchingListenersPool=[];var lV=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},lr(e,[{key:"type",get:function(){return this._type}}]),e}();lV._propertyIdMap=Object.create(null),lV._propertyNameCounter=0,lV._propertyNameMap=Object.create(null);var lO=((eC=(ex=function(){this._frameCount=0,this._deltaTime=0,this._actualDeltaTime=0,this._elapsedTime=0,this._actualElapsedTime=0,this._elapsedTimeValue=new s6,this._deltaTimeValue=new s6,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(ex._elapsedTimeProperty,t),n.set(this._deltaTime,0,0,0),e.setVector4(ex._deltaTimeProperty,n)},lr(ex,[{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}}]),ex);lO._elapsedTimeProperty=lV.getByName("scene_ElapsedTime"),lO._deltaTimeProperty=lV.getByName("scene_DeltaTime"),e.DataType=void 0,(eT=e.DataType||(e.DataType={}))[eT.FLOAT=5126]="FLOAT",eT[eT.FLOAT_VEC2=35664]="FLOAT_VEC2",eT[eT.FLOAT_VEC3=35665]="FLOAT_VEC3",eT[eT.FLOAT_VEC4=35666]="FLOAT_VEC4",eT[eT.INT=5124]="INT",eT[eT.INT_VEC2=35667]="INT_VEC2",eT[eT.INT_VEC3=35668]="INT_VEC3",eT[eT.INT_VEC4=35669]="INT_VEC4",eT[eT.BOOL=35670]="BOOL",eT[eT.BOOL_VEC2=35671]="BOOL_VEC2",eT[eT.BOOL_VEC3=35672]="BOOL_VEC3",eT[eT.BOOL_VEC4=35673]="BOOL_VEC4",eT[eT.FLOAT_MAT2=35674]="FLOAT_MAT2",eT[eT.FLOAT_MAT3=35675]="FLOAT_MAT3",eT[eT.FLOAT_MAT4=35676]="FLOAT_MAT4",eT[eT.FLOAT_ARRAY=35677]="FLOAT_ARRAY",eT[eT.FLOAT_VEC2_ARRAY=1e5]="FLOAT_VEC2_ARRAY",eT[eT.FLOAT_VEC3_ARRAY=100001]="FLOAT_VEC3_ARRAY",eT[eT.FLOAT_VEC4_ARRAY=100002]="FLOAT_VEC4_ARRAY",eT[eT.INT_ARRAY=100003]="INT_ARRAY",eT[eT.INT_VEC2_ARRAY=100004]="INT_VEC2_ARRAY",eT[eT.INT_VEC3_ARRAY=100005]="INT_VEC3_ARRAY",eT[eT.INT_VEC4_ARRAY=100006]="INT_VEC4_ARRAY",eT[eT.FLOAT_MAT2_ARRAY=100007]="FLOAT_MAT2_ARRAY",eT[eT.FLOAT_MAT3_ARRAY=100008]="FLOAT_MAT3_ARRAY",eT[eT.FLOAT_MAT4_ARRAY=100009]="FLOAT_MAT4_ARRAY",eT[eT.SAMPLER_2D_ARRAY=100010]="SAMPLER_2D_ARRAY",eT[eT.SAMPLER_CUBE_ARRAY=100011]="SAMPLER_CUBE_ARRAY",eT[eT.SAMPLER_2D=35678]="SAMPLER_2D",eT[eT.SAMPLER_CUBE=35680]="SAMPLER_CUBE",eT[eT.BYTE=5120]="BYTE",eT[eT.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",eT[eT.SHORT=5122]="SHORT",eT[eT.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",eT[eT.UNSIGNED_INT=5125]="UNSIGNED_INT",e.GLCapabilityType=void 0,(eS=e.GLCapabilityType||(e.GLCapabilityType={})).shaderVertexID="shaderVertexID",eS.standardDerivatives="OES_standard_derivatives",eS.shaderTextureLod="EXT_shader_texture_lod",eS.elementIndexUint="OES_element_index_uint",eS.depthTexture="WEBGL_depth_texture",eS.drawBuffers="WEBGL_draw_buffers",eS.vertexArrayObject="OES_vertex_array_object",eS.instancedArrays="ANGLE_instanced_arrays",eS.multipleSample="multipleSampleOnlySupportedInWebGL2",eS.textureFloat="OES_texture_float",eS.textureFloatLinear="OES_texture_float_linear",eS.textureHalfFloat="OES_texture_half_float",eS.textureHalfFloatLinear="OES_texture_half_float_linear",eS.WEBGL_colorBufferFloat="WEBGL_color_buffer_float",eS.colorBufferFloat="EXT_color_buffer_float",eS.colorBufferHalfFloat="EXT_color_buffer_half_float",eS.textureFilterAnisotropic="EXT_texture_filter_anisotropic",eS.blendMinMax="EXT_blend_minmax",eS.astc="WEBGL_compressed_texture_astc",eS.astc_webkit="WEBKIT_WEBGL_compressed_texture_astc",eS.etc="WEBGL_compressed_texture_etc",eS.etc_webkit="WEBKIT_WEBGL_compressed_texture_etc",eS.etc1="WEBGL_compressed_texture_etc1",eS.etc1_webkit="WEBKIT_WEBGL_compressed_texture_etc1",eS.pvrtc="WEBGL_compressed_texture_pvrtc",eS.pvrtc_webkit="WEBKIT_WEBGL_compressed_texture_pvrtc",eS.s3tc="WEBGL_compressed_texture_s3tc",eS.s3tc_webkit="WEBKIT_WEBGL_compressed_texture_s3tc",eS.WEBGL_lose_context="WEBGL_lose_context";var lU=(la(ew=function(e){var t;return(t=lp.call(this,e.engine)||this)._awoken=!1,t._phasedActive=!1,t._enabled=!0,t._entity=e,t},lp),(eA=ew.prototype)._onAwake=function(){},eA._onEnable=function(){},eA._onDisable=function(){},eA._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())},eA._onDestroy=function(){lp.prototype._onDestroy.call(this),this._entity._removeComponent(this),this._entity.isActiveInHierarchy&&this._enabled&&this._onDisable()},lr(ew,[{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}}]),ew);ll([lu],lU.prototype,"_entity",void 0),ll([lu],lU.prototype,"_awoken",void 0),ll([lu],lU.prototype,"_phasedActive",void 0),ll([lh],lU.prototype,"_enabled",void 0);var lz=((eE=function(){})._addCheck=function(e,t){for(;t!==lU;){var n=eE._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)}},eE._removeCheck=function(e,t){for(;t!==lU;){var n=eE._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)}},eE._addDependency=function(e,t,n){var r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eE._addInvDependency=function(e,t){var n=this._invDependenciesMap,r=n.get(e);r?r.includes(t)||r.push(t):n.set(e,[t])},eE);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,(eM=e.DependentMode||(e.DependentMode={}))[eM.CheckOnly=0]="CheckOnly",eM[eM.AutoAdd=1]="AutoAdd",e.Layer=void 0,(eb=e.Layer||(e.Layer={}))[eb.Layer0=1]="Layer0",eb[eb.Layer1=2]="Layer1",eb[eb.Layer2=4]="Layer2",eb[eb.Layer3=8]="Layer3",eb[eb.Layer4=16]="Layer4",eb[eb.Layer5=32]="Layer5",eb[eb.Layer6=64]="Layer6",eb[eb.Layer7=128]="Layer7",eb[eb.Layer8=256]="Layer8",eb[eb.Layer9=512]="Layer9",eb[eb.Layer10=1024]="Layer10",eb[eb.Layer11=2048]="Layer11",eb[eb.Layer12=4096]="Layer12",eb[eb.Layer13=8192]="Layer13",eb[eb.Layer14=16384]="Layer14",eb[eb.Layer15=32768]="Layer15",eb[eb.Layer16=65536]="Layer16",eb[eb.Layer17=131072]="Layer17",eb[eb.Layer18=262144]="Layer18",eb[eb.Layer19=524288]="Layer19",eb[eb.Layer20=1048576]="Layer20",eb[eb.Layer21=2097152]="Layer21",eb[eb.Layer22=4194304]="Layer22",eb[eb.Layer23=8388608]="Layer23",eb[eb.Layer24=16777216]="Layer24",eb[eb.Layer25=33554432]="Layer25",eb[eb.Layer26=67108864]="Layer26",eb[eb.Layer27=134217728]="Layer27",eb[eb.Layer28=268435456]="Layer28",eb[eb.Layer29=536870912]="Layer29",eb[eb.Layer30=1073741824]="Layer30",eb[eb.Layer31=2147483648]="Layer31",eb[eb.Everything=4294967295]="Everything",eb[eb.Nothing=0]="Nothing";var lG=((eR=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],C=a[15],T=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*T+u*S+f*w+v*A,r[i+1]=s*T+h*S+p*w+y*A,r[i+2]=l*T+d*S+g*w+x*A,r[i+3]=c*T+_*S+m*w+C*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+C*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+C*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+C*V},eR._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},eR.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},eR.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))},eR.isAbsoluteUrl=function(e){return/^(?:http|blob|data:|\/)/.test(e)},eR.objectValues=function(e){return Object.keys(e).map(function(t){return e[t]})},eR.resolveAbsoluteUrl=function(e,t){return eR.isAbsoluteUrl(t)?t:"."===t.charAt(0)?eR._formatRelativePath(t+t):e.substring(0,e.lastIndexOf("/")+1)+t},eR._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},eR._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("/")},eR),lH=46,lW=/\\(\\)?/g,lX=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g"),lj=((eP=(eF=function(){this._flagManagers=[]}).prototype).clearFromManagers=function(){this._removeFromManagers(),this._flagManagers.length=0},eP.destroy=function(){this._removeFromManagers(),this._flagManagers=null},eP._removeFromManagers=function(){for(var e=this._flagManagers,t=0,n=e.length;t<n;t++)lG.removeFromArray(e[t]._updateFlags,this)},la(eL=function(){var e;return e=eF.apply(this,arguments)||this,e.flag=!0,e},eF),eL.prototype.dispatch=function(){this.flag=!0},eL),lK=((eI=(eD=function(){this._updateFlags=[],this._listeners=[]}).prototype).createFlag=function(e){var t=new e;return this.addFlag(t),t},eI.addFlag=function(e){this._updateFlags.push(e),e._flagManagers.push(this)},eI.removeFlag=function(e){lG.removeFromArray(this._updateFlags,e)&&lG.removeFromArray(e._flagManagers,this)},eI.addListener=function(e){this._listeners.push(e)},eI.removeListener=function(e){lG.removeFromArray(this._listeners,e)},eI.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)},eD),lq=(la(eB=function(e){var t;return(t=lU.call(this,e)||this)._position=new sQ,t._rotation=new sQ,t._rotationQuaternion=new s3,t._scale=new sQ(1,1,1),t._worldPosition=new sQ,t._worldRotation=new sQ,t._worldRotationQuaternion=new s3,t._lossyWorldScale=new sQ(1,1,1),t._localMatrix=new s4,t._worldMatrix=new s4,t._worldForward=null,t._worldRight=null,t._worldUp=null,t._isParentDirty=!0,t._parentTransformCache=null,t._dirtyFlag=188,t._updateFlagManager=new lK,t._onPositionChanged=t._onPositionChanged.bind(lt(t)),t._onWorldPositionChanged=t._onWorldPositionChanged.bind(lt(t)),t._onRotationChanged=t._onRotationChanged.bind(lt(t)),t._onWorldRotationChanged=t._onWorldRotationChanged.bind(lt(t)),t._onRotationQuaternionChanged=t._onRotationQuaternionChanged.bind(lt(t)),t._onWorldRotationQuaternionChanged=t._onWorldRotationQuaternionChanged.bind(lt(t)),t._onScaleChanged=t._onScaleChanged.bind(lt(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),(eN=eB.prototype).setPosition=function(e,t,n){this._position.set(e,t,n)},eN.setRotation=function(e,t,n){this._rotation.set(e,t,n)},eN.setRotationQuaternion=function(e,t,n,r){this._rotationQuaternion.set(e,t,n,r)},eN.setScale=function(e,t,n){this._scale.set(e,t,n)},eN.setWorldPosition=function(e,t,n){this._worldPosition.set(e,t,n)},eN.setWorldRotation=function(e,t,n){this._worldRotation.set(e,t,n)},eN.setWorldRotationQuaternion=function(e,t,n,r){this._worldRotationQuaternion.set(e,t,n,r)},eN.translate=function(e,t,n,r){if("number"==typeof e){var i=eB._tempVec30;i.set(e,t,n),this._translate(i,r)}else this._translate(e,t)},eN.rotate=function(e,t,n,r){"number"==typeof e?this._rotateXYZ(e,t,n,r):this._rotateXYZ(e.x,e.y,e.z,t)},eN.rotateByAxis=function(e,t,n){void 0===n&&(n=!0);var r=t*sY.degreeToRadFactor;s3.rotationAxisAngle(e,r,eB._tempQuat0),this._rotateByQuat(eB._tempQuat0,n)},eN.lookAt=function(e,t){var n=eB._tempVec30;sQ.subtract(this.worldPosition,e,n);var r=n.length();if(!(r<=sY.zeroTolerance)){n.scale(1/r);var i=eB._tempVec31;if(t?sQ.cross(t,n,i):i.set(n.z,0,-n.x),!((r=i.length())<=sY.zeroTolerance)){i.scale(1/r);var a=eB._tempVec32;sQ.cross(n,i,a);var o=eB._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)}}},eN.registerWorldChangeFlag=function(){return this._updateFlagManager.createFlag(lj)},eN._parentChange=function(){this._isParentDirty=!0,this._updateAllWorldFlag()},eN._isFrontFaceInvert=function(){var e=this.lossyWorldScale,t=e.x<0;return e.y<0&&(t=!t),e.z<0&&(t=!t),t},eN._onDestroy=function(){lU.prototype._onDestroy.call(this),this._worldPosition._onValueChanged=null,this._rotation._onValueChanged=null,this._worldRotation._onValueChanged=null,this._rotationQuaternion._onValueChanged=null,this._worldRotationQuaternion._onValueChanged=null,this._position._onValueChanged=null,this._scale._onValueChanged=null},eN._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()}},eN._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()}},eN._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()}},eN._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()}},eN._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()}},eN._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()}},eN._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},eN._getScaleMatrix=function(){var e=eB._tempQuat0,t=eB._tempMat30,n=eB._tempMat31,r=eB._tempMat32;return n.copyFromMatrix(this.worldMatrix),s3.invert(this.worldRotationQuaternion,e),s2.rotationQuaternion(e,t),s2.multiply(t,n,r),r},eN._isContainDirtyFlags=function(e){return(this._dirtyFlag&e)===e},eN._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},eN._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},eN._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},eN._worldAssociatedChange=function(e){this._dirtyFlag|=e,this._updateFlagManager.dispatch(128)},eN._rotateByQuat=function(e,t){t?s3.multiply(this.rotationQuaternion,e,this._rotationQuaternion):s3.multiply(e,this.worldRotationQuaternion,this._worldRotationQuaternion)},eN._translate=function(e,t){if(void 0===t&&(t=!0),t){var n=eB._tempVec30;sQ.transformByQuat(e,this.worldRotationQuaternion,n),this._worldPosition.add(n)}else this._worldPosition.add(e)},eN._rotateXYZ=function(e,t,n,r){void 0===r&&(r=!0);var i=sY.degreeToRadFactor,a=eB._tempQuat0;s3.rotationEuler(e*i,t*i,n*i,a),this._rotateByQuat(a,r)},eN._onPositionChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldPositionFlag()},eN._onWorldPositionChanged=function(){var e=this._worldPosition,t=this._getParentTransform();t?(s4.invert(t.worldMatrix,eB._tempMat41),sQ.transformCoordinate(e,eB._tempMat41,this._position)):this._position.copyFrom(e),this._setDirtyFlagFalse(4)},eN._onRotationChanged=function(){this._setDirtyFlagTrue(66),this._setDirtyFlagFalse(1),this._updateWorldRotationFlag()},eN._onWorldRotationChanged=function(){var e=this._worldRotation;s3.rotationEuler(sY.degreeToRadian(e.x),sY.degreeToRadian(e.y),sY.degreeToRadian(e.z),this._worldRotationQuaternion),this._setDirtyFlagFalse(8)},eN._onRotationQuaternionChanged=function(){this._setDirtyFlagTrue(65),this._setDirtyFlagFalse(2),this._updateWorldRotationFlag()},eN._onWorldRotationQuaternionChanged=function(){var e=this._worldRotationQuaternion,t=this._getParentTransform();if(t){var n=eB._tempQuat0;s3.invert(t.worldRotationQuaternion,n),s3.multiply(n,e,this._rotationQuaternion)}else this._rotationQuaternion.copyFrom(e);this._setDirtyFlagFalse(16)},eN._onScaleChanged=function(){this._setDirtyFlagTrue(64),this._updateWorldScaleFlag()},lr(eB,[{key:"position",get:function(){return this._position},set:function(e){this._position!==e&&this._position.copyFrom(e)}},{key:"worldPosition",get:function(){var e=this._worldPosition;return this._isContainDirtyFlag(4)&&(e._onValueChanged=null,this._getParentTransform()?this.worldMatrix.getTranslation(e):e.copyFrom(this._position),e._onValueChanged=this._onWorldPositionChanged,this._setDirtyFlagFalse(4)),e},set:function(e){this._worldPosition!==e&&this._worldPosition.copyFrom(e)}},{key:"rotation",get:function(){var e=this._rotation;return this._isContainDirtyFlag(1)&&(e._onValueChanged=null,this._rotationQuaternion.toEuler(e),e.scale(sY.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(sY.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,s3.rotationEuler(sY.degreeToRadian(this._rotation.x),sY.degreeToRadian(this._rotation.y),sY.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):s3.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?s3.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):s3.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)&&(s4.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?s4.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?(s4.invert(t.worldMatrix,eB._tempMat42),s4.multiply(eB._tempMat42,e,this._localMatrix)):this._localMatrix.copyFrom(e),this.localMatrix=this._localMatrix,this._setDirtyFlagFalse(128)}},{key:"worldForward",get:function(){var e=this._worldForward||(this._worldForward=new sQ),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 sQ),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 sQ),t=this.worldMatrix.elements;return e.set(t[4],t[5],t[6]),e.normalize()}}]),eB);lq._tempQuat0=new s3,lq._tempVec30=new sQ,lq._tempVec31=new sQ,lq._tempVec32=new sQ,lq._tempMat30=new s2,lq._tempMat31=new s2,lq._tempMat32=new s2,lq._tempMat41=new s4,lq._tempMat42=new s4,ll([l_],lq.prototype,"_position",void 0),ll([l_],lq.prototype,"_rotation",void 0),ll([l_],lq.prototype,"_rotationQuaternion",void 0),ll([l_],lq.prototype,"_scale",void 0),ll([l_],lq.prototype,"_worldPosition",void 0),ll([l_],lq.prototype,"_worldRotation",void 0),ll([l_],lq.prototype,"_worldRotationQuaternion",void 0),ll([l_],lq.prototype,"_lossyWorldScale",void 0),ll([l_],lq.prototype,"_localMatrix",void 0),ll([l_],lq.prototype,"_worldMatrix",void 0),ll([lu],lq.prototype,"_worldForward",void 0),ll([lu],lq.prototype,"_worldRight",void 0),ll([lu],lq.prototype,"_worldUp",void 0),ll([lu],lq.prototype,"_isParentDirty",void 0),ll([lu],lq.prototype,"_parentTransformCache",void 0),ll([lu],lq.prototype,"_updateFlagManager",void 0),ll([lu],lq.prototype,"_onPositionChanged",null),ll([lu],lq.prototype,"_onWorldPositionChanged",null),ll([lu],lq.prototype,"_onRotationChanged",null),ll([lu],lq.prototype,"_onWorldRotationChanged",null),ll([lu],lq.prototype,"_onRotationQuaternionChanged",null),ll([lu],lq.prototype,"_onWorldRotationQuaternionChanged",null),ll([lu],lq.prototype,"_onScaleChanged",null),(eV=si||(si={}))[eV.LocalEuler=1]="LocalEuler",eV[eV.LocalQuat=2]="LocalQuat",eV[eV.WorldPosition=4]="WorldPosition",eV[eV.WorldEuler=8]="WorldEuler",eV[eV.WorldQuat=16]="WorldQuat",eV[eV.WorldScale=32]="WorldScale",eV[eV.LocalMatrix=64]="LocalMatrix",eV[eV.WorldMatrix=128]="WorldMatrix",eV[eV.WmWp=132]="WmWp",eV[eV.WmWeWq=152]="WmWeWq",eV[eV.WmWpWeWq=156]="WmWpWeWq",eV[eV.WmWs=160]="WmWs",eV[eV.WmWpWs=164]="WmWpWs",eV[eV.WmWpWeWqWs=188]="WmWpWeWqWs";var lY=((eO=function(){}).cloneComponent=function(e,t){for(var n=lf.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 sr.Assignment:t[o]=e[o];break;case sr.Shallow:var s=e[o];if(lc(s,Object)){var l=t[o];null==l&&(l=t[o]=s.constructor()),Object.assign(l,s)}else t[o]=s;break;case sr.Deep:var c=e[o];if(lc(c,Object)){var u=t[o];null==u&&(u=t[o]=c.constructor()),lf.deepCloneObject(c,u)}else t[o]=c}}e._cloneTo&&e._cloneTo(t)},eO),lQ=(la(eU=function(t,n){var r;return(r=lp.call(this,t)||this).layer=e.Layer.Layer0,r._isActiveInHierarchy=!1,r._components=[],r._scripts=new lI,r._children=[],r._isRoot=!1,r._isActive=!0,r._siblingIndex=-1,r._parent=null,r._invModelMatrix=new s4,r.name=n,r.transform=r.addComponent(lq),r._inverseWorldMatFlag=r.transform.registerWorldChangeFlag(),r},lp),(ez=eU.prototype).addComponent=function(e){lz._addCheck(this,e);var t=new e(this);return this._components.push(t),t._setActive(!0),t},ez.getComponent=function(e){for(var t=this._components,n=t.length-1;n>=0;n--){var r=t[n];if(lc(r,e))return r}return null},ez.getComponents=function(e,t){t.length=0;for(var n=this._components,r=0,i=n.length;r<i;r++){var a=n[r];lc(a,e)&&t.push(a)}return t},ez.getComponentsIncludeChildren=function(e,t){return t.length=0,this._getComponentsInChildren(e,t),t},ez.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&&eU._traverseSetOwnerScene(t,r),this._isActiveInHierarchy?!t._isActiveInHierarchy&&t._isActive&&t._processActive():t._isActiveInHierarchy&&t._processInActive(),t._setTransformDirty()}else t._setParent(this,n)},ez.removeChild=function(e){e._setParent(null)},ez.getChild=function(e){return this._children[e]},ez.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},ez.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=eU._findChildByName(n,a)))return null}return n},ez.createChild=function(e){var t=new eU(this.engine,e);return t.layer=this.layer,t.parent=this,t},ez.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(),eU._traverseSetOwnerScene(n,null)}e.length=0},ez.clone=function(){var e=new eU(this._engine,this.name),t=this._hookResource;t&&(e._hookResource=t,t._addReferCount(1)),e.layer=this.layer,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(!lc(c,lq)){var u=e.addComponent(c.constructor);lY.cloneComponent(c,u)}}return e},ez.destroy=function(){if(!this._destroyed){lp.prototype.destroy.call(this),this._hookResource&&(this._hookResource._addReferCount(-1),this._hookResource=null),this.isActive=!1,this._isRoot?this._scene.removeRootEntity(this):this._setParent(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()}},ez._removeComponent=function(e){lz._removeCheck(this,e.constructor);var t=this._components;t.splice(t.indexOf(e),1)},ez._addScript=function(e){e._entityScriptsIndex=this._scripts.length,this._scripts.add(e)},ez._removeScript=function(e){var t=this._scripts.deleteByIndex(e._entityScriptsIndex);t&&(t._entityScriptsIndex=e._entityScriptsIndex),e._entityScriptsIndex=-1},ez._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}},ez._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)},ez._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)},ez._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++}},ez._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&&eU._traverseSetOwnerScene(this,r),e._isActiveInHierarchy?!this._isActiveInHierarchy&&this._isActive&&this._processActive():this._isActiveInHierarchy&&this._processInActive()}else this._isActiveInHierarchy&&this._processInActive(),n&&eU._traverseSetOwnerScene(this,null);this._setTransformDirty()}},ez._getComponentsInChildren=function(e,t){for(var n=this._components.length-1;n>=0;n--){var r=this._components[n];lc(r,e)&&t.push(r)}for(var i=this._children.length-1;i>=0;i--)this._children[i]._getComponentsInChildren(e,t)},ez._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},ez._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)}},ez._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)}},ez._setTransformDirty=function(){if(this.transform)this.transform._parentChange();else for(var e=0,t=this._children.length;e<t;e++)this._children[e]._setTransformDirty()},ez._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}}},ez.getInvModelMatrix=function(){return this._inverseWorldMatFlag.flag&&(s4.invert(this.transform.worldMatrix,this._invModelMatrix),this._inverseWorldMatFlag.flag=!1),this._invModelMatrix},eU._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},eU._traverseSetOwnerScene=function(e,t){e._scene=t;for(var n=e._children,r=e.childCount-1;r>=0;r--)this._traverseSetOwnerScene(n[r],t)},lr(eU,[{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)}}]),eU),lJ=((eG=(ek=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},eG.resetPool=function(){this._elementPoolIndex=0},eG.garbageCollection=function(){for(var e=this._elementPool,t=e.length-1;t>=0;t--)e[t].dispose&&e[t].dispose()},ek),lZ=function(){},l$=(la(eH=function(){return lZ.apply(this,arguments)},lZ),(eW=eH.prototype).set=function(e,t,n,r){this.component=e,this.material=t,this.mesh=n,this.subMesh=r},eW.dispose=function(){this.component=this.material=this.mesh=this.subMesh=null},eH);e.BlendFactor=void 0,(eX=e.BlendFactor||(e.BlendFactor={}))[eX.Zero=0]="Zero",eX[eX.One=1]="One",eX[eX.SourceColor=2]="SourceColor",eX[eX.OneMinusSourceColor=3]="OneMinusSourceColor",eX[eX.DestinationColor=4]="DestinationColor",eX[eX.OneMinusDestinationColor=5]="OneMinusDestinationColor",eX[eX.SourceAlpha=6]="SourceAlpha",eX[eX.OneMinusSourceAlpha=7]="OneMinusSourceAlpha",eX[eX.DestinationAlpha=8]="DestinationAlpha",eX[eX.OneMinusDestinationAlpha=9]="OneMinusDestinationAlpha",eX[eX.SourceAlphaSaturate=10]="SourceAlphaSaturate",eX[eX.BlendColor=11]="BlendColor",eX[eX.OneMinusBlendColor=12]="OneMinusBlendColor",e.BlendOperation=void 0,(ej=e.BlendOperation||(e.BlendOperation={}))[ej.Add=0]="Add",ej[ej.Subtract=1]="Subtract",ej[ej.ReverseSubtract=2]="ReverseSubtract",ej[ej.Min=3]="Min",ej[ej.Max=4]="Max",e.ColorWriteMask=void 0,(eK=e.ColorWriteMask||(e.ColorWriteMask={}))[eK.None=0]="None",eK[eK.Red=1]="Red",eK[eK.Green=2]="Green",eK[eK.Blue=4]="Blue",eK[eK.Alpha=8]="Alpha",eK[eK.All=15]="All",e.CompareFunction=void 0,(eq=e.CompareFunction||(e.CompareFunction={}))[eq.Never=0]="Never",eq[eq.Less=1]="Less",eq[eq.Equal=2]="Equal",eq[eq.LessEqual=3]="LessEqual",eq[eq.Greater=4]="Greater",eq[eq.NotEqual=5]="NotEqual",eq[eq.GreaterEqual=6]="GreaterEqual",eq[eq.Always=7]="Always",e.CullMode=void 0,(eY=e.CullMode||(e.CullMode={}))[eY.Off=0]="Off",eY[eY.Front=1]="Front",eY[eY.Back=2]="Back",e.RenderQueueType=void 0,(eQ=e.RenderQueueType||(e.RenderQueueType={}))[eQ.Opaque=0]="Opaque",eQ[eQ.AlphaTest=1]="AlphaTest",eQ[eQ.Transparent=2]="Transparent",e.ShaderPropertyType=void 0,(eJ=e.ShaderPropertyType||(e.ShaderPropertyType={}))[eJ.Float=0]="Float",eJ[eJ.Int=1]="Int",eJ[eJ.Vector2=2]="Vector2",eJ[eJ.Vector3=3]="Vector3",eJ[eJ.Vector4=4]="Vector4",eJ[eJ.Matrix=5]="Matrix",eJ[eJ.Color=6]="Color",eJ[eJ.Texture=7]="Texture",eJ[eJ.FloatArray=8]="FloatArray",eJ[eJ.IntArray=9]="IntArray",eJ[eJ.TextureArray=10]="TextureArray",e.StencilOperation=void 0,(eZ=e.StencilOperation||(e.StencilOperation={}))[eZ.Keep=0]="Keep",eZ[eZ.Zero=1]="Zero",eZ[eZ.Replace=2]="Replace",eZ[eZ.IncrementSaturate=3]="IncrementSaturate",eZ[eZ.DecrementSaturate=4]="DecrementSaturate",eZ[eZ.Invert=5]="Invert",eZ[eZ.IncrementWrap=6]="IncrementWrap",eZ[eZ.DecrementWrap=7]="DecrementWrap";var l0=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}();l0._macroMaskMap=[],l0._macroNameIdMap=Object.create(null),l0._macroNameCounter=0,l0._macroCounter=0,l0._macroMap=Object.create(null);var l1=((e0=(e$=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},e0.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}},e0.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]},e0.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}},e0.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}},e0.isEnable=function(e){var t=e._maskIndex;return!(t>=this._length)&&(this._mask[t]&e._maskValue)!=0},e0.clear=function(){this._length=0},e$.unionCollection=function(e,t,n){var r,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},e$);function l2(){return(l2=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}e.PipelineStage=void 0,(e1=e.PipelineStage||(e.PipelineStage={})).ShadowCaster="ShadowCaster",e1.Forward="Forward";var l3=l2({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();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];float d=max(dot(N,-directionalLight.direction),0.0);lightDiffuse+=directionalLight.color*d;vec3 halfDir=normalize(V-directionalLight.direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess);lightSpecular+=directionalLight.color*s;}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];vec3 direction=v_pos-pointLight.position;float dist=length(direction);direction/=dist;float decay=clamp(1.0-pow(dist/pointLight.distance,4.0),0.0,1.0);float d=max(dot(N,-direction),0.0)*decay;lightDiffuse+=pointLight.color*d;vec3 halfDir=normalize(V-direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decay;lightSpecular+=pointLight.color*s;}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];vec3 direction=spotLight.position-v_pos;float lightDistance=length(direction);direction/=lightDistance;float angleCos=dot(direction,-spotLight.direction);float decay=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayTotal=decay*spotEffect;float d=max(dot(N,direction),0.0)*decayTotal;lightDiffuse+=spotLight.color*d;vec3 halfDir=normalize(V+direction);float s=pow(clamp(dot(N,halfDir),0.0,1.0),material_Shininess)*decayTotal;lightSpecular+=spotLight.color*s;}}\n#endif\ndiffuse*=vec4(lightDiffuse,1.0);specular*=vec4(lightSpecular,1.0);\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(diffuse.a<material_AlphaCutoff){discard;}\n#endif\n",noise_common:"#define GLSLIFY 1\nvec4 mod289(vec4 x){return x-floor(x*(1.0/289.0))*289.0;}vec3 mod289(vec3 x){return x-floor(x*(1.0/289.0))*289.0;}vec2 mod289(vec2 x){return x-floor(x*(1.0/289.0))*289.0;}float mod289(float x){return x-floor(x*(1.0/289.0))*289.0;}vec4 mod7(vec4 x){return x-floor(x*(1.0/7.0))*7.0;}vec3 mod7(vec3 x){return x-floor(x*(1.0/7.0))*7.0;}vec4 permute(vec4 x){return mod289((34.0*x+1.0)*x);}vec3 permute(vec3 x){return mod289((34.0*x+1.0)*x);}float permute(float x){return mod289(((x*34.0)+1.0)*x);}vec4 taylorInvSqrt(vec4 r){return 1.79284291400159-0.85373472095314*r;}float taylorInvSqrt(float r){return 1.79284291400159-0.85373472095314*r;}vec4 fade(vec4 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec3 fade(vec3 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}vec2 fade(vec2 t){return t*t*t*(t*(t*6.0-15.0)+10.0);}\n#define K 0.142857142857\n#define Ko 0.428571428571\n#define K2 0.020408163265306\n#define Kd2 0.0714285714285\n#define Kz 0.166666666667\n#define Kzo 0.416666666667\n#define jitter 1.0\n#define jitter1 0.8\n",noise_cellular_2D:"#define GLSLIFY 1\nvec2 cellular(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec3 oi=vec3(-1.0,0.0,1.0);vec3 of=vec3(-0.5,0.5,1.5);vec3 px=permute(Pi.x+oi);vec3 p=permute(px.x+Pi.y+oi);vec3 ox=fract(p*K)-Ko;vec3 oy=mod7(floor(p*K))*K-Ko;vec3 dx=Pf.x+0.5+jitter*ox;vec3 dy=Pf.y-of+jitter*oy;vec3 d1=dx*dx+dy*dy;p=permute(px.y+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-0.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d2=dx*dx+dy*dy;p=permute(px.z+Pi.y+oi);ox=fract(p*K)-Ko;oy=mod7(floor(p*K))*K-Ko;dx=Pf.x-1.5+jitter*ox;dy=Pf.y-of+jitter*oy;vec3 d3=dx*dx+dy*dy;vec3 d1a=min(d1,d2);d2=max(d1,d2);d2=min(d2,d3);d1=min(d1a,d2);d2=max(d1a,d2);d1.xy=(d1.x<d1.y)? d1.xy : d1.yx;d1.xz=(d1.x<d1.z)? d1.xz : d1.zx;d1.yz=min(d1.yz,d2.yz);d1.y=min(d1.y,d1.z);d1.y=min(d1.y,d2.x);return sqrt(d1.xy);}",noise_cellular_2x2:"#define GLSLIFY 1\nvec2 cellular2x2(vec2 P){vec2 Pi=mod289(floor(P));vec2 Pf=fract(P);vec4 Pfx=Pf.x+vec4(-0.5,-1.5,-0.5,-1.5);vec4 Pfy=Pf.y+vec4(-0.5,-0.5,-1.5,-1.5);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 ox=mod7(p)*K+Kd2;vec4 oy=mod7(floor(p*K))*K+Kd2;vec4 dx=Pfx+jitter1*ox;vec4 dy=Pfy+jitter1*oy;vec4 d=dx*dx+dy*dy;d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.y=min(d.y,d.z);d.y=min(d.y,d.w);return sqrt(d.xy);}",noise_cellular_2x2x2:"#define GLSLIFY 1\nvec2 cellular2x2x2(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P);vec4 Pfx=Pf.x+vec4(0.0,-1.0,0.0,-1.0);vec4 Pfy=Pf.y+vec4(0.0,0.0,-1.0,-1.0);vec4 p=permute(Pi.x+vec4(0.0,1.0,0.0,1.0));p=permute(p+Pi.y+vec4(0.0,0.0,1.0,1.0));vec4 p1=permute(p+Pi.z);vec4 p2=permute(p+Pi.z+vec4(1.0));vec4 ox1=fract(p1*K)-Ko;vec4 oy1=mod7(floor(p1*K))*K-Ko;vec4 oz1=floor(p1*K2)*Kz-Kzo;vec4 ox2=fract(p2*K)-Ko;vec4 oy2=mod7(floor(p2*K))*K-Ko;vec4 oz2=floor(p2*K2)*Kz-Kzo;vec4 dx1=Pfx+jitter1*ox1;vec4 dy1=Pfy+jitter1*oy1;vec4 dz1=Pf.z+jitter1*oz1;vec4 dx2=Pfx+jitter1*ox2;vec4 dy2=Pfy+jitter1*oy2;vec4 dz2=Pf.z-1.0+jitter1*oz2;vec4 d1=dx1*dx1+dy1*dy1+dz1*dz1;vec4 d2=dx2*dx2+dy2*dy2+dz2*dz2;vec4 d=min(d1,d2);d2=max(d1,d2);d.xy=(d.x<d.y)? d.xy : d.yx;d.xz=(d.x<d.z)? d.xz : d.zx;d.xw=(d.x<d.w)? d.xw : d.wx;d.yzw=min(d.yzw,d2.yzw);d.y=min(d.y,d.z);d.y=min(d.y,d.w);d.y=min(d.y,d2.x);return sqrt(d.xy);}",noise_cellular_3D:"#define GLSLIFY 1\nvec2 cellular(vec3 P){vec3 Pi=mod289(floor(P));vec3 Pf=fract(P)-0.5;vec3 Pfx=Pf.x+vec3(1.0,0.0,-1.0);vec3 Pfy=Pf.y+vec3(1.0,0.0,-1.0);vec3 Pfz=Pf.z+vec3(1.0,0.0,-1.0);vec3 p=permute(Pi.x+vec3(-1.0,0.0,1.0));vec3 p1=permute(p+Pi.y-1.0);vec3 p2=permute(p+Pi.y);vec3 p3=permute(p+Pi.y+1.0);vec3 p11=permute(p1+Pi.z-1.0);vec3 p12=permute(p1+Pi.z);vec3 p13=permute(p1+Pi.z+1.0);vec3 p21=permute(p2+Pi.z-1.0);vec3 p22=permute(p2+Pi.z);vec3 p23=permute(p2+Pi.z+1.0);vec3 p31=permute(p3+Pi.z-1.0);vec3 p32=permute(p3+Pi.z);vec3 p33=permute(p3+Pi.z+1.0);vec3 ox11=fract(p11*K)-Ko;vec3 oy11=mod7(floor(p11*K))*K-Ko;vec3 oz11=floor(p11*K2)*Kz-Kzo;vec3 ox12=fract(p12*K)-Ko;vec3 oy12=mod7(floor(p12*K))*K-Ko;vec3 oz12=floor(p12*K2)*Kz-Kzo;vec3 ox13=fract(p13*K)-Ko;vec3 oy13=mod7(floor(p13*K))*K-Ko;vec3 oz13=floor(p13*K2)*Kz-Kzo;vec3 ox21=fract(p21*K)-Ko;vec3 oy21=mod7(floor(p21*K))*K-Ko;vec3 oz21=floor(p21*K2)*Kz-Kzo;vec3 ox22=fract(p22*K)-Ko;vec3 oy22=mod7(floor(p22*K))*K-Ko;vec3 oz22=floor(p22*K2)*Kz-Kzo;vec3 ox23=fract(p23*K)-Ko;vec3 oy23=mod7(floor(p23*K))*K-Ko;vec3 oz23=floor(p23*K2)*Kz-Kzo;vec3 ox31=fract(p31*K)-Ko;vec3 oy31=mod7(floor(p31*K))*K-Ko;vec3 oz31=floor(p31*K2)*Kz-Kzo;vec3 ox32=fract(p32*K)-Ko;vec3 oy32=mod7(floor(p32*K))*K-Ko;vec3 oz32=floor(p32*K2)*Kz-Kzo;vec3 ox33=fract(p33*K)-Ko;vec3 oy33=mod7(floor(p33*K))*K-Ko;vec3 oz33=floor(p33*K2)*Kz-Kzo;vec3 dx11=Pfx+jitter*ox11;vec3 dy11=Pfy.x+jitter*oy11;vec3 dz11=Pfz.x+jitter*oz11;vec3 dx12=Pfx+jitter*ox12;vec3 dy12=Pfy.x+jitter*oy12;vec3 dz12=Pfz.y+jitter*oz12;vec3 dx13=Pfx+jitter*ox13;vec3 dy13=Pfy.x+jitter*oy13;vec3 dz13=Pfz.z+jitter*oz13;vec3 dx21=Pfx+jitter*ox21;vec3 dy21=Pfy.y+jitter*oy21;vec3 dz21=Pfz.x+jitter*oz21;vec3 dx22=Pfx+jitter*ox22;vec3 dy22=Pfy.y+jitter*oy22;vec3 dz22=Pfz.y+jitter*oz22;vec3 dx23=Pfx+jitter*ox23;vec3 dy23=Pfy.y+jitter*oy23;vec3 dz23=Pfz.z+jitter*oz23;vec3 dx31=Pfx+jitter*ox31;vec3 dy31=Pfy.z+jitter*oy31;vec3 dz31=Pfz.x+jitter*oz31;vec3 dx32=Pfx+jitter*ox32;vec3 dy32=Pfy.z+jitter*oy32;vec3 dz32=Pfz.y+jitter*oz32;vec3 dx33=Pfx+jitter*ox33;vec3 dy33=Pfy.z+jitter*oy33;vec3 dz33=Pfz.z+jitter*oz33;vec3 d11=dx11*dx11+dy11*dy11+dz11*dz11;vec3 d12=dx12*dx12+dy12*dy12+dz12*dz12;vec3 d13=dx13*dx13+dy13*dy13+dz13*dz13;vec3 d21=dx21*dx21+dy21*dy21+dz21*dz21;vec3 d22=dx22*dx22+dy22*dy22+dz22*dz22;vec3 d23=dx23*dx23+dy23*dy23+dz23*dz23;vec3 d31=dx31*dx31+dy31*dy31+dz31*dz31;vec3 d32=dx32*dx32+dy32*dy32+dz32*dz32;vec3 d33=dx33*dx33+dy33*dy33+dz33*dz33;vec3 d1a=min(d11,d12);d12=max(d11,d12);d11=min(d1a,d13);d13=max(d1a,d13);d12=min(d12,d13);vec3 d2a=min(d21,d22);d22=max(d21,d22);d21=min(d2a,d23);d23=max(d2a,d23);d22=min(d22,d23);vec3 d3a=min(d31,d32);d32=max(d31,d32);d31=min(d3a,d33);d33=max(d3a,d33);d32=min(d32,d33);vec3 da=min(d11,d21);d21=max(d11,d21);d11=min(da,d31);d31=max(da,d31);d11.xy=(d11.x<d11.y)? d11.xy : d11.yx;d11.xz=(d11.x<d11.z)? d11.xz : d11.zx;d12=min(d12,d21);d12=min(d12,d22);d12=min(d12,d31);d12=min(d12,d32);d11.yz=min(d11.yz,d12.xy);d11.y=min(d11.y,d12.z);d11.y=min(d11.y,d11.z);return sqrt(d11.xy);}",noise_cellular:"#define GLSLIFY 1\n#include <noise_cellular_2D>\n#include <noise_cellular_3D>\n#include <noise_cellular_2x2>\n#include <noise_cellular_2x2x2>\n",noise_perlin_2D:"#define GLSLIFY 1\nfloat perlin(vec2 P){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}float perlin(vec2 P,vec2 rep){vec4 Pi=floor(P.xyxy)+vec4(0.0,0.0,1.0,1.0);vec4 Pf=fract(P.xyxy)-vec4(0.0,0.0,1.0,1.0);Pi=mod(Pi,rep.xyxy);Pi=mod289(Pi);vec4 ix=Pi.xzxz;vec4 iy=Pi.yyww;vec4 fx=Pf.xzxz;vec4 fy=Pf.yyww;vec4 i=permute(permute(ix)+iy);vec4 gx=fract(i*(1.0/41.0))*2.0-1.0;vec4 gy=abs(gx)-0.5;vec4 tx=floor(gx+0.5);gx=gx-tx;vec2 g00=vec2(gx.x,gy.x);vec2 g10=vec2(gx.y,gy.y);vec2 g01=vec2(gx.z,gy.z);vec2 g11=vec2(gx.w,gy.w);vec4 norm=taylorInvSqrt(vec4(dot(g00,g00),dot(g01,g01),dot(g10,g10),dot(g11,g11)));g00*=norm.x;g01*=norm.y;g10*=norm.z;g11*=norm.w;float n00=dot(g00,vec2(fx.x,fy.x));float n10=dot(g10,vec2(fx.y,fy.y));float n01=dot(g01,vec2(fx.z,fy.z));float n11=dot(g11,vec2(fx.w,fy.w));vec2 fade_xy=fade(Pf.xy);vec2 n_x=mix(vec2(n00,n01),vec2(n10,n11),fade_xy.x);float n_xy=mix(n_x.x,n_x.y,fade_xy.y);return 2.3*n_xy;}",noise_perlin_3D:"#define GLSLIFY 1\nfloat perlin(vec3 P){vec3 Pi0=floor(P);vec3 Pi1=Pi0+vec3(1.0);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}float perlin(vec3 P,vec3 rep){vec3 Pi0=mod(floor(P),rep);vec3 Pi1=mod(Pi0+vec3(1.0),rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec3 Pf0=fract(P);vec3 Pf1=Pf0-vec3(1.0);vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=Pi0.zzzz;vec4 iz1=Pi1.zzzz;vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 gx0=ixy0*(1.0/7.0);vec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;gx0=fract(gx0);vec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);vec4 sz0=step(gz0,vec4(0.0));gx0-=sz0*(step(0.0,gx0)-0.5);gy0-=sz0*(step(0.0,gy0)-0.5);vec4 gx1=ixy1*(1.0/7.0);vec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;gx1=fract(gx1);vec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);vec4 sz1=step(gz1,vec4(0.0));gx1-=sz1*(step(0.0,gx1)-0.5);gy1-=sz1*(step(0.0,gy1)-0.5);vec3 g000=vec3(gx0.x,gy0.x,gz0.x);vec3 g100=vec3(gx0.y,gy0.y,gz0.y);vec3 g010=vec3(gx0.z,gy0.z,gz0.z);vec3 g110=vec3(gx0.w,gy0.w,gz0.w);vec3 g001=vec3(gx1.x,gy1.x,gz1.x);vec3 g101=vec3(gx1.y,gy1.y,gz1.y);vec3 g011=vec3(gx1.z,gy1.z,gz1.z);vec3 g111=vec3(gx1.w,gy1.w,gz1.w);vec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));g000*=norm0.x;g010*=norm0.y;g100*=norm0.z;g110*=norm0.w;vec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));g001*=norm1.x;g011*=norm1.y;g101*=norm1.z;g111*=norm1.w;float n000=dot(g000,Pf0);float n100=dot(g100,vec3(Pf1.x,Pf0.yz));float n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));float n110=dot(g110,vec3(Pf1.xy,Pf0.z));float n001=dot(g001,vec3(Pf0.xy,Pf1.z));float n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));float n011=dot(g011,vec3(Pf0.x,Pf1.yz));float n111=dot(g111,Pf1);vec3 fade_xyz=fade(Pf0);vec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);vec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);float n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);return 2.2*n_xyz;}",noise_perlin_4D:"#define GLSLIFY 1\nfloat perlin(vec4 P){vec4 Pi0=floor(P);vec4 Pi1=Pi0+1.0;Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}float perlin(vec4 P,vec4 rep){vec4 Pi0=mod(floor(P),rep);vec4 Pi1=mod(Pi0+1.0,rep);Pi0=mod289(Pi0);Pi1=mod289(Pi1);vec4 Pf0=fract(P);vec4 Pf1=Pf0-1.0;vec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);vec4 iy=vec4(Pi0.yy,Pi1.yy);vec4 iz0=vec4(Pi0.zzzz);vec4 iz1=vec4(Pi1.zzzz);vec4 iw0=vec4(Pi0.wwww);vec4 iw1=vec4(Pi1.wwww);vec4 ixy=permute(permute(ix)+iy);vec4 ixy0=permute(ixy+iz0);vec4 ixy1=permute(ixy+iz1);vec4 ixy00=permute(ixy0+iw0);vec4 ixy01=permute(ixy0+iw1);vec4 ixy10=permute(ixy1+iw0);vec4 ixy11=permute(ixy1+iw1);vec4 gx00=ixy00*(1.0/7.0);vec4 gy00=floor(gx00)*(1.0/7.0);vec4 gz00=floor(gy00)*(1.0/6.0);gx00=fract(gx00)-0.5;gy00=fract(gy00)-0.5;gz00=fract(gz00)-0.5;vec4 gw00=vec4(0.75)-abs(gx00)-abs(gy00)-abs(gz00);vec4 sw00=step(gw00,vec4(0.0));gx00-=sw00*(step(0.0,gx00)-0.5);gy00-=sw00*(step(0.0,gy00)-0.5);vec4 gx01=ixy01*(1.0/7.0);vec4 gy01=floor(gx01)*(1.0/7.0);vec4 gz01=floor(gy01)*(1.0/6.0);gx01=fract(gx01)-0.5;gy01=fract(gy01)-0.5;gz01=fract(gz01)-0.5;vec4 gw01=vec4(0.75)-abs(gx01)-abs(gy01)-abs(gz01);vec4 sw01=step(gw01,vec4(0.0));gx01-=sw01*(step(0.0,gx01)-0.5);gy01-=sw01*(step(0.0,gy01)-0.5);vec4 gx10=ixy10*(1.0/7.0);vec4 gy10=floor(gx10)*(1.0/7.0);vec4 gz10=floor(gy10)*(1.0/6.0);gx10=fract(gx10)-0.5;gy10=fract(gy10)-0.5;gz10=fract(gz10)-0.5;vec4 gw10=vec4(0.75)-abs(gx10)-abs(gy10)-abs(gz10);vec4 sw10=step(gw10,vec4(0.0));gx10-=sw10*(step(0.0,gx10)-0.5);gy10-=sw10*(step(0.0,gy10)-0.5);vec4 gx11=ixy11*(1.0/7.0);vec4 gy11=floor(gx11)*(1.0/7.0);vec4 gz11=floor(gy11)*(1.0/6.0);gx11=fract(gx11)-0.5;gy11=fract(gy11)-0.5;gz11=fract(gz11)-0.5;vec4 gw11=vec4(0.75)-abs(gx11)-abs(gy11)-abs(gz11);vec4 sw11=step(gw11,vec4(0.0));gx11-=sw11*(step(0.0,gx11)-0.5);gy11-=sw11*(step(0.0,gy11)-0.5);vec4 g0000=vec4(gx00.x,gy00.x,gz00.x,gw00.x);vec4 g1000=vec4(gx00.y,gy00.y,gz00.y,gw00.y);vec4 g0100=vec4(gx00.z,gy00.z,gz00.z,gw00.z);vec4 g1100=vec4(gx00.w,gy00.w,gz00.w,gw00.w);vec4 g0010=vec4(gx10.x,gy10.x,gz10.x,gw10.x);vec4 g1010=vec4(gx10.y,gy10.y,gz10.y,gw10.y);vec4 g0110=vec4(gx10.z,gy10.z,gz10.z,gw10.z);vec4 g1110=vec4(gx10.w,gy10.w,gz10.w,gw10.w);vec4 g0001=vec4(gx01.x,gy01.x,gz01.x,gw01.x);vec4 g1001=vec4(gx01.y,gy01.y,gz01.y,gw01.y);vec4 g0101=vec4(gx01.z,gy01.z,gz01.z,gw01.z);vec4 g1101=vec4(gx01.w,gy01.w,gz01.w,gw01.w);vec4 g0011=vec4(gx11.x,gy11.x,gz11.x,gw11.x);vec4 g1011=vec4(gx11.y,gy11.y,gz11.y,gw11.y);vec4 g0111=vec4(gx11.z,gy11.z,gz11.z,gw11.z);vec4 g1111=vec4(gx11.w,gy11.w,gz11.w,gw11.w);vec4 norm00=taylorInvSqrt(vec4(dot(g0000,g0000),dot(g0100,g0100),dot(g1000,g1000),dot(g1100,g1100)));g0000*=norm00.x;g0100*=norm00.y;g1000*=norm00.z;g1100*=norm00.w;vec4 norm01=taylorInvSqrt(vec4(dot(g0001,g0001),dot(g0101,g0101),dot(g1001,g1001),dot(g1101,g1101)));g0001*=norm01.x;g0101*=norm01.y;g1001*=norm01.z;g1101*=norm01.w;vec4 norm10=taylorInvSqrt(vec4(dot(g0010,g0010),dot(g0110,g0110),dot(g1010,g1010),dot(g1110,g1110)));g0010*=norm10.x;g0110*=norm10.y;g1010*=norm10.z;g1110*=norm10.w;vec4 norm11=taylorInvSqrt(vec4(dot(g0011,g0011),dot(g0111,g0111),dot(g1011,g1011),dot(g1111,g1111)));g0011*=norm11.x;g0111*=norm11.y;g1011*=norm11.z;g1111*=norm11.w;float n0000=dot(g0000,Pf0);float n1000=dot(g1000,vec4(Pf1.x,Pf0.yzw));float n0100=dot(g0100,vec4(Pf0.x,Pf1.y,Pf0.zw));float n1100=dot(g1100,vec4(Pf1.xy,Pf0.zw));float n0010=dot(g0010,vec4(Pf0.xy,Pf1.z,Pf0.w));float n1010=dot(g1010,vec4(Pf1.x,Pf0.y,Pf1.z,Pf0.w));float n0110=dot(g0110,vec4(Pf0.x,Pf1.yz,Pf0.w));float n1110=dot(g1110,vec4(Pf1.xyz,Pf0.w));float n0001=dot(g0001,vec4(Pf0.xyz,Pf1.w));float n1001=dot(g1001,vec4(Pf1.x,Pf0.yz,Pf1.w));float n0101=dot(g0101,vec4(Pf0.x,Pf1.y,Pf0.z,Pf1.w));float n1101=dot(g1101,vec4(Pf1.xy,Pf0.z,Pf1.w));float n0011=dot(g0011,vec4(Pf0.xy,Pf1.zw));float n1011=dot(g1011,vec4(Pf1.x,Pf0.y,Pf1.zw));float n0111=dot(g0111,vec4(Pf0.x,Pf1.yzw));float n1111=dot(g1111,Pf1);vec4 fade_xyzw=fade(Pf0);vec4 n_0w=mix(vec4(n0000,n1000,n0100,n1100),vec4(n0001,n1001,n0101,n1101),fade_xyzw.w);vec4 n_1w=mix(vec4(n0010,n1010,n0110,n1110),vec4(n0011,n1011,n0111,n1111),fade_xyzw.w);vec4 n_zw=mix(n_0w,n_1w,fade_xyzw.z);vec2 n_yzw=mix(n_zw.xy,n_zw.zw,fade_xyzw.y);float n_xyzw=mix(n_yzw.x,n_yzw.y,fade_xyzw.x);return 2.2*n_xyzw;}",noise_perlin:"#define GLSLIFY 1\n#include <noise_perlin_2D>\n#include <noise_perlin_3D>\n#include <noise_perlin_4D>\n",noise_psrd_2D:"#define GLSLIFY 1\nvec2 rgrad2(vec2 p,float rot){float u=permute(permute(p.x)+p.y)*0.0243902439+rot;u=fract(u)*6.28318530718;return vec2(cos(u),sin(u));}vec3 psrdnoise(vec2 pos,vec2 per,float rot){pos.y+=0.01;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 psdnoise(vec2 pos,vec2 per){return psrdnoise(pos,per,0.0);}float psrnoise(vec2 pos,vec2 per,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 xw=mod(vec3(p0.x,p1.x,p2.x),per.x);vec3 yw=mod(vec3(p0.y,p1.y,p2.y),per.y);vec3 iuw=xw+0.5*yw;vec3 ivw=yw;vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float psnoise(vec2 pos,vec2 per){return psrnoise(pos,per,0.0);}vec3 srdnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));vec3 dtdx=-2.0*vec3(d0.x,d1.x,d2.x);vec3 dtdy=-2.0*vec3(d0.y,d1.y,d2.y);if(t.x<0.0){dtdx.x=0.0;dtdy.x=0.0;t.x=0.0;}if(t.y<0.0){dtdx.y=0.0;dtdy.y=0.0;t.y=0.0;}if(t.z<0.0){dtdx.z=0.0;dtdy.z=0.0;t.z=0.0;}vec3 t2=t*t;vec3 t4=t2*t2;vec3 t3=t2*t;float n=dot(t4,w);vec2 dt0=vec2(dtdx.x,dtdy.x)*4.0*t3.x;vec2 dn0=t4.x*g0+dt0*w.x;vec2 dt1=vec2(dtdx.y,dtdy.y)*4.0*t3.y;vec2 dn1=t4.y*g1+dt1*w.y;vec2 dt2=vec2(dtdx.z,dtdy.z)*4.0*t3.z;vec2 dn2=t4.z*g2+dt2*w.z;return 11.0*vec3(n,dn0+dn1+dn2);}vec3 sdnoise(vec2 pos){return srdnoise(pos,0.0);}float srnoise(vec2 pos,float rot){pos.y+=0.001;vec2 uv=vec2(pos.x+pos.y*0.5,pos.y);vec2 i0=floor(uv);vec2 f0=fract(uv);vec2 i1=(f0.x>f0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec2 p0=vec2(i0.x-i0.y*0.5,i0.y);vec2 p1=vec2(p0.x+i1.x-i1.y*0.5,p0.y+i1.y);vec2 p2=vec2(p0.x+0.5,p0.y+1.0);i1=i0+i1;vec2 i2=i0+vec2(1.0,1.0);vec2 d0=pos-p0;vec2 d1=pos-p1;vec2 d2=pos-p2;vec3 x=vec3(p0.x,p1.x,p2.x);vec3 y=vec3(p0.y,p1.y,p2.y);vec3 iuw=x+0.5*y;vec3 ivw=y;iuw=mod289(iuw);ivw=mod289(ivw);vec2 g0=rgrad2(vec2(iuw.x,ivw.x),rot);vec2 g1=rgrad2(vec2(iuw.y,ivw.y),rot);vec2 g2=rgrad2(vec2(iuw.z,ivw.z),rot);vec3 w=vec3(dot(g0,d0),dot(g1,d1),dot(g2,d2));vec3 t=0.8-vec3(dot(d0,d0),dot(d1,d1),dot(d2,d2));t=max(t,0.0);vec3 t2=t*t;vec3 t4=t2*t2;float n=dot(t4,w);return 11.0*n;}float snoise(vec2 pos){return srnoise(pos,0.0);}",noise_simplex_2D:"#define GLSLIFY 1\nfloat simplex(vec2 v){const vec4 C=vec4(0.211324865405187,0.366025403784439,-0.577350269189626,0.024390243902439);vec2 i=floor(v+dot(v,C.yy));vec2 x0=v-i+dot(i,C.xx);vec2 i1;i1=(x0.x>x0.y)? vec2(1.0,0.0): vec2(0.0,1.0);vec4 x12=x0.xyxy+C.xxzz;x12.xy-=i1;i=mod289(i);vec3 p=permute(permute(i.y+vec3(0.0,i1.y,1.0))+i.x+vec3(0.0,i1.x,1.0));vec3 m=max(0.5-vec3(dot(x0,x0),dot(x12.xy,x12.xy),dot(x12.zw,x12.zw)),0.0);m=m*m;m=m*m;vec3 x=2.0*fract(p*C.www)-1.0;vec3 h=abs(x)-0.5;vec3 ox=floor(x+0.5);vec3 a0=x-ox;m*=1.79284291400159-0.85373472095314*(a0*a0+h*h);vec3 g;g.x=a0.x*x0.x+h.x*x0.y;g.yz=a0.yz*x12.xz+h.yz*x12.yw;return 130.0*dot(m,g);}",noise_simplex_3D_grad:"#define GLSLIFY 1\nfloat simplex(vec3 v,out vec3 gradient){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);vec4 m2=m*m;vec4 m4=m2*m2;vec4 pdotx=vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3));vec4 temp=m2*m*pdotx;gradient=-8.0*(temp.x*x0+temp.y*x1+temp.z*x2+temp.w*x3);gradient+=m4.x*p0+m4.y*p1+m4.z*p2+m4.w*p3;gradient*=42.0;return 42.0*dot(m4,pdotx);}",noise_simplex_3D:"#define GLSLIFY 1\nfloat simplex(vec3 v){const vec2 C=vec2(1.0/6.0,1.0/3.0);const vec4 D=vec4(0.0,0.5,1.0,2.0);vec3 i=floor(v+dot(v,C.yyy));vec3 x0=v-i+dot(i,C.xxx);vec3 g=step(x0.yzx,x0.xyz);vec3 l=1.0-g;vec3 i1=min(g.xyz,l.zxy);vec3 i2=max(g.xyz,l.zxy);vec3 x1=x0-i1+C.xxx;vec3 x2=x0-i2+C.yyy;vec3 x3=x0-D.yyy;i=mod289(i);vec4 p=permute(permute(permute(i.z+vec4(0.0,i1.z,i2.z,1.0))+i.y+vec4(0.0,i1.y,i2.y,1.0))+i.x+vec4(0.0,i1.x,i2.x,1.0));float n_=0.142857142857;vec3 ns=n_*D.wyz-D.xzx;vec4 j=p-49.0*floor(p*ns.z*ns.z);vec4 x_=floor(j*ns.z);vec4 y_=floor(j-7.0*x_);vec4 x=x_*ns.x+ns.yyyy;vec4 y=y_*ns.x+ns.yyyy;vec4 h=1.0-abs(x)-abs(y);vec4 b0=vec4(x.xy,y.xy);vec4 b1=vec4(x.zw,y.zw);vec4 s0=floor(b0)*2.0+1.0;vec4 s1=floor(b1)*2.0+1.0;vec4 sh=-step(h,vec4(0.0));vec4 a0=b0.xzyw+s0.xzyw*sh.xxyy;vec4 a1=b1.xzyw+s1.xzyw*sh.zzww;vec3 p0=vec3(a0.xy,h.x);vec3 p1=vec3(a0.zw,h.y);vec3 p2=vec3(a1.xy,h.z);vec3 p3=vec3(a1.zw,h.w);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;vec4 m=max(0.6-vec4(dot(x0,x0),dot(x1,x1),dot(x2,x2),dot(x3,x3)),0.0);m=m*m;return 42.0*dot(m*m,vec4(dot(p0,x0),dot(p1,x1),dot(p2,x2),dot(p3,x3)));}",noise_simplex_4D:"#define GLSLIFY 1\nvec4 grad4(float j,vec4 ip){const vec4 ones=vec4(1.0,1.0,1.0,-1.0);vec4 p,s;p.xyz=floor(fract(vec3(j)*ip.xyz)*7.0)*ip.z-1.0;p.w=1.5-dot(abs(p.xyz),ones.xyz);s=vec4(lessThan(p,vec4(0.0)));p.xyz=p.xyz+(s.xyz*2.0-1.0)*s.www;return p;}\n#define F4 0.309016994374947451\nfloat simplex(vec4 v){const vec4 C=vec4(0.138196601125011,0.276393202250021,0.414589803375032,-0.447213595499958);vec4 i=floor(v+dot(v,vec4(F4)));vec4 x0=v-i+dot(i,C.xxxx);vec4 i0;vec3 isX=step(x0.yzw,x0.xxx);vec3 isYZ=step(x0.zww,x0.yyz);i0.x=isX.x+isX.y+isX.z;i0.yzw=1.0-isX;i0.y+=isYZ.x+isYZ.y;i0.zw+=1.0-isYZ.xy;i0.z+=isYZ.z;i0.w+=1.0-isYZ.z;vec4 i3=clamp(i0,0.0,1.0);vec4 i2=clamp(i0-1.0,0.0,1.0);vec4 i1=clamp(i0-2.0,0.0,1.0);vec4 x1=x0-i1+C.xxxx;vec4 x2=x0-i2+C.yyyy;vec4 x3=x0-i3+C.zzzz;vec4 x4=x0+C.wwww;i=mod289(i);float j0=permute(permute(permute(permute(i.w)+i.z)+i.y)+i.x);vec4 j1=permute(permute(permute(permute(i.w+vec4(i1.w,i2.w,i3.w,1.0))+i.z+vec4(i1.z,i2.z,i3.z,1.0))+i.y+vec4(i1.y,i2.y,i3.y,1.0))+i.x+vec4(i1.x,i2.x,i3.x,1.0));vec4 ip=vec4(1.0/294.0,1.0/49.0,1.0/7.0,0.0);vec4 p0=grad4(j0,ip);vec4 p1=grad4(j1.x,ip);vec4 p2=grad4(j1.y,ip);vec4 p3=grad4(j1.z,ip);vec4 p4=grad4(j1.w,ip);vec4 norm=taylorInvSqrt(vec4(dot(p0,p0),dot(p1,p1),dot(p2,p2),dot(p3,p3)));p0*=norm.x;p1*=norm.y;p2*=norm.z;p3*=norm.w;p4*=taylorInvSqrt(dot(p4,p4));vec3 m0=max(0.6-vec3(dot(x0,x0),dot(x1,x1),dot(x2,x2)),0.0);vec2 m1=max(0.6-vec2(dot(x3,x3),dot(x4,x4)),0.0);m0=m0*m0;m1=m1*m1;return 49.0*(dot(m0*m0,vec3(dot(p0,x0),dot(p1,x1),dot(p2,x2)))+dot(m1*m1,vec2(dot(p3,x3),dot(p4,x4))));}",noise_simplex:"#define GLSLIFY 1\n#include <noise_simplex_2D>\n#include <noise_simplex_3D>\n#include <noise_simplex_3D_grad>\n#include <noise_simplex_4D>\n"},{ShadowCoord:"#define GLSLIFY 1\nuniform mat4 scene_ShadowMatrices[SCENE_SHADOW_CASCADED_COUNT+1];uniform vec4 scene_ShadowSplitSpheres[4];mediump int computeCascadeIndex(vec3 positionWS){vec3 fromCenter0=positionWS-scene_ShadowSplitSpheres[0].xyz;vec3 fromCenter1=positionWS-scene_ShadowSplitSpheres[1].xyz;vec3 fromCenter2=positionWS-scene_ShadowSplitSpheres[2].xyz;vec3 fromCenter3=positionWS-scene_ShadowSplitSpheres[3].xyz;mediump vec4 comparison=vec4(dot(fromCenter0,fromCenter0)<scene_ShadowSplitSpheres[0].w,dot(fromCenter1,fromCenter1)<scene_ShadowSplitSpheres[1].w,dot(fromCenter2,fromCenter2)<scene_ShadowSplitSpheres[2].w,dot(fromCenter3,fromCenter3)<scene_ShadowSplitSpheres[3].w);comparison.yzw=clamp(comparison.yzw-comparison.xyz,0.0,1.0);mediump vec4 indexCoefficient=vec4(4.0,3.0,2.0,1.0);mediump int index=4-int(dot(comparison,indexCoefficient));return index;}vec3 getShadowCoord(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nmediump int cascadeIndex=0;\n#else\nmediump int cascadeIndex=computeCascadeIndex(v_pos);\n#endif\n#ifdef GRAPHICS_API_WEBGL2\nmat4 shadowMatrix=scene_ShadowMatrices[cascadeIndex];\n#else\nmat4 shadowMatrix;\n#if SCENE_SHADOW_CASCADED_COUNT == 4\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else if(cascadeIndex==2){shadowMatrix=scene_ShadowMatrices[2];}else if(cascadeIndex==3){shadowMatrix=scene_ShadowMatrices[3];}else{shadowMatrix=scene_ShadowMatrices[4];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 2\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else if(cascadeIndex==1){shadowMatrix=scene_ShadowMatrices[1];}else{shadowMatrix=scene_ShadowMatrices[2];}\n#endif\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nif(cascadeIndex==0){shadowMatrix=scene_ShadowMatrices[0];}else{shadowMatrix=scene_ShadowMatrices[1];}\n#endif\n#endif\nvec4 shadowCoord=shadowMatrix*vec4(v_pos,1.0);return shadowCoord.xyz;}",ShadowFragmentDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvarying vec3 v_shadowCoord;\n#else\n#include <ShadowCoord>\n#endif\nuniform vec3 scene_ShadowInfo;uniform vec4 scene_ShadowMapSize;\n#ifdef GRAPHICS_API_WEBGL2\nuniform mediump sampler2DShadow scene_ShadowMap;\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) textureLod(textureName, coord3 , 0.0)\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2DShadow shadowMap\n#else\nuniform sampler2D scene_ShadowMap;\n#ifdef ENGINE_NO_DEPTH_TEXTURE\nconst vec4 bitShift=vec4(1.0,1.0/256.0,1.0/(256.0*256.0),1.0/(256.0*256.0*256.0));float unpack(const in vec4 rgbaDepth){return dot(rgbaDepth,bitShift);}\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (unpack(texture2D(textureName, coord3.xy)) < coord3.z ? 0.0 : 1.0)\n#else\n#define SAMPLE_TEXTURE2D_SHADOW(textureName, coord3) (texture2D(textureName, coord3.xy).r < coord3.z ? 0.0 : 1.0)\n#endif\n#define TEXTURE2D_SHADOW_PARAM(shadowMap) mediump sampler2D shadowMap\n#endif\n#if SCENE_SHADOW_TYPE == 2\nfloat sampleShadowMapFiltered4(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowMapSize){float attenuation;vec4 attenuation4;vec2 offset=shadowMapSize.xy/2.0;vec3 shadowCoord0=shadowCoord+vec3(-offset,0.0);vec3 shadowCoord1=shadowCoord+vec3(offset.x,-offset.y,0.0);vec3 shadowCoord2=shadowCoord+vec3(-offset.x,offset.y,0.0);vec3 shadowCoord3=shadowCoord+vec3(offset,0.0);attenuation4.x=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord0);attenuation4.y=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord1);attenuation4.z=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord2);attenuation4.w=SAMPLE_TEXTURE2D_SHADOW(shadowMap,shadowCoord3);attenuation=dot(attenuation4,vec4(0.25));return attenuation;}\n#endif\n#if SCENE_SHADOW_TYPE == 3\n#include <shadow_sample_tent>\nfloat sampleShadowMapFiltered9(TEXTURE2D_SHADOW_PARAM(shadowMap),vec3 shadowCoord,vec4 shadowmapSize){float attenuation;float fetchesWeights[9];vec2 fetchesUV[9];sampleShadowComputeSamplesTent5x5(shadowmapSize,shadowCoord.xy,fetchesWeights,fetchesUV);attenuation=fetchesWeights[0]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[0].xy,shadowCoord.z));attenuation+=fetchesWeights[1]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[1].xy,shadowCoord.z));attenuation+=fetchesWeights[2]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[2].xy,shadowCoord.z));attenuation+=fetchesWeights[3]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[3].xy,shadowCoord.z));attenuation+=fetchesWeights[4]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[4].xy,shadowCoord.z));attenuation+=fetchesWeights[5]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[5].xy,shadowCoord.z));attenuation+=fetchesWeights[6]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[6].xy,shadowCoord.z));attenuation+=fetchesWeights[7]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[7].xy,shadowCoord.z));attenuation+=fetchesWeights[8]*SAMPLE_TEXTURE2D_SHADOW(shadowMap,vec3(fetchesUV[8].xy,shadowCoord.z));return attenuation;}\n#endif\nfloat sampleShadowMap(){\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nvec3 shadowCoord=v_shadowCoord;\n#else\nvec3 shadowCoord=getShadowCoord();\n#endif\nfloat attenuation=1.0;if(shadowCoord.z>0.0&&shadowCoord.z<1.0){\n#if SCENE_SHADOW_TYPE == 1\nattenuation=SAMPLE_TEXTURE2D_SHADOW(scene_ShadowMap,shadowCoord);\n#endif\n#if SCENE_SHADOW_TYPE == 2\nattenuation=sampleShadowMapFiltered4(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\n#if SCENE_SHADOW_TYPE == 3\nattenuation=sampleShadowMapFiltered9(scene_ShadowMap,shadowCoord,scene_ShadowMapSize);\n#endif\nattenuation=mix(1.0,attenuation,scene_ShadowInfo.x);}return attenuation;}\n#endif\n",shadow_sample_tent:"#define GLSLIFY 1\nfloat sampleShadowGetIRTriangleTexelArea(float triangleHeight){return triangleHeight-0.5;}void sampleShadowGetTexelAreasTent3x3(float offset,out vec4 computedArea,out vec4 computedAreaUncut){float a=offset+0.5;float offsetSquaredHalved=a*a*0.5;computedAreaUncut.x=computedArea.x=offsetSquaredHalved-offset;computedAreaUncut.w=computedArea.w=offsetSquaredHalved;computedAreaUncut.y=sampleShadowGetIRTriangleTexelArea(1.5-offset);float clampedOffsetLeft=min(offset,0.0);float areaOfSmallLeftTriangle=clampedOffsetLeft*clampedOffsetLeft;computedArea.y=computedAreaUncut.y-areaOfSmallLeftTriangle;computedAreaUncut.z=sampleShadowGetIRTriangleTexelArea(1.5+offset);float clampedOffsetRight=max(offset,0.0);float areaOfSmallRightTriangle=clampedOffsetRight*clampedOffsetRight;computedArea.z=computedAreaUncut.z-areaOfSmallRightTriangle;}void sampleShadowGetTexelWeightsTent5x5(float offset,out vec3 texelsWeightsA,out vec3 texelsWeightsB){vec4 areaFrom3texelTriangle;vec4 areaUncutFrom3texelTriangle;sampleShadowGetTexelAreasTent3x3(offset,areaFrom3texelTriangle,areaUncutFrom3texelTriangle);texelsWeightsA.x=0.16*(areaFrom3texelTriangle.x);texelsWeightsA.y=0.16*(areaUncutFrom3texelTriangle.y);texelsWeightsA.z=0.16*(areaFrom3texelTriangle.y+1.0);texelsWeightsB.x=0.16*(areaFrom3texelTriangle.z+1.0);texelsWeightsB.y=0.16*(areaUncutFrom3texelTriangle.z);texelsWeightsB.z=0.16*(areaFrom3texelTriangle.w);}void sampleShadowComputeSamplesTent5x5(vec4 shadowMapTextureTexelSize,vec2 coord,out float fetchesWeights[9],out vec2 fetchesUV[9]){vec2 tentCenterInTexelSpace=coord.xy*shadowMapTextureTexelSize.zw;vec2 centerOfFetchesInTexelSpace=floor(tentCenterInTexelSpace+0.5);vec2 offsetFromTentCenterToCenterOfFetches=tentCenterInTexelSpace-centerOfFetchesInTexelSpace;vec3 texelsWeightsUA,texelsWeightsUB;vec3 texelsWeightsVA,texelsWeightsVB;sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.x,texelsWeightsUA,texelsWeightsUB);sampleShadowGetTexelWeightsTent5x5(offsetFromTentCenterToCenterOfFetches.y,texelsWeightsVA,texelsWeightsVB);vec3 fetchesWeightsU=vec3(texelsWeightsUA.xz,texelsWeightsUB.y)+vec3(texelsWeightsUA.y,texelsWeightsUB.xz);vec3 fetchesWeightsV=vec3(texelsWeightsVA.xz,texelsWeightsVB.y)+vec3(texelsWeightsVA.y,texelsWeightsVB.xz);vec3 fetchesOffsetsU=vec3(texelsWeightsUA.y,texelsWeightsUB.xz)/fetchesWeightsU.xyz+vec3(-2.5,-0.5,1.5);vec3 fetchesOffsetsV=vec3(texelsWeightsVA.y,texelsWeightsVB.xz)/fetchesWeightsV.xyz+vec3(-2.5,-0.5,1.5);fetchesOffsetsU*=shadowMapTextureTexelSize.xxx;fetchesOffsetsV*=shadowMapTextureTexelSize.yyy;vec2 bilinearFetchOrigin=centerOfFetchesInTexelSpace*shadowMapTextureTexelSize.xy;fetchesUV[0]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.x);fetchesUV[1]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.x);fetchesUV[2]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.x);fetchesUV[3]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.y);fetchesUV[4]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.y);fetchesUV[5]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.y);fetchesUV[6]=bilinearFetchOrigin+vec2(fetchesOffsetsU.x,fetchesOffsetsV.z);fetchesUV[7]=bilinearFetchOrigin+vec2(fetchesOffsetsU.y,fetchesOffsetsV.z);fetchesUV[8]=bilinearFetchOrigin+vec2(fetchesOffsetsU.z,fetchesOffsetsV.z);fetchesWeights[0]=fetchesWeightsU.x*fetchesWeightsV.x;fetchesWeights[1]=fetchesWeightsU.y*fetchesWeightsV.x;fetchesWeights[2]=fetchesWeightsU.z*fetchesWeightsV.x;fetchesWeights[3]=fetchesWeightsU.x*fetchesWeightsV.y;fetchesWeights[4]=fetchesWeightsU.y*fetchesWeightsV.y;fetchesWeights[5]=fetchesWeightsU.z*fetchesWeightsV.y;fetchesWeights[6]=fetchesWeightsU.x*fetchesWeightsV.z;fetchesWeights[7]=fetchesWeightsU.y*fetchesWeightsV.z;fetchesWeights[8]=fetchesWeightsU.z*fetchesWeightsV.z;}",ShadowVertexDeclaration:"#define GLSLIFY 1\n#if defined(SCENE_SHADOW_TYPE) && defined(RENDERER_IS_RECEIVE_SHADOWS)\n#define SCENE_IS_CALCULATE_SHADOWS\n#endif\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT==1\n#include <ShadowCoord>\nvarying vec3 v_shadowCoord;\n#endif\n#endif\n",ShadowVertex:"#define GLSLIFY 1\n#ifdef SCENE_IS_CALCULATE_SHADOWS\n#if SCENE_SHADOW_CASCADED_COUNT == 1\nv_shadowCoord=getShadowCoord();\n#endif\n#endif\n"},{pbr_frag_define:"#define GLSLIFY 1\nuniform float material_AlphaCutoff;uniform vec4 material_BaseColor;uniform float material_Metal;uniform float material_Roughness;uniform float material_IOR;uniform vec3 material_PBRSpecularColor;uniform float material_Glossiness;uniform vec3 material_EmissiveColor;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nuniform float material_ClearCoat;uniform float material_ClearCoatRoughness;\n#endif\nuniform float material_NormalIntensity;uniform float material_OcclusionIntensity;uniform float material_OcclusionTextureCoord;\n#ifdef MATERIAL_HAS_BASETEXTURE\nuniform sampler2D material_BaseTexture;\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\nuniform sampler2D material_NormalTexture;\n#endif\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nuniform sampler2D material_EmissiveTexture;\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nuniform sampler2D material_RoughnessMetallicTexture;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nuniform sampler2D material_SpecularGlossinessTexture;\n#endif\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nuniform sampler2D material_OcclusionTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nuniform sampler2D material_ClearCoatTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nuniform sampler2D material_ClearCoatRoughnessTexture;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\nuniform sampler2D material_ClearCoatNormalTexture;\n#endif\nstruct ReflectedLight{vec3 directDiffuse;vec3 directSpecular;vec3 indirectDiffuse;vec3 indirectSpecular;};struct Geometry{vec3 position;vec3 normal;vec3 viewDir;float dotNV;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatNormal;float clearCoatDotNV;\n#endif\n};struct Material{vec3 diffuseColor;float roughness;vec3 specularColor;float opacity;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoat;float clearCoatRoughness;\n#endif\n};",pbr_helper:"#define GLSLIFY 1\n#include <normal_get>\nfloat computeSpecularOcclusion(float ambientOcclusion,float roughness,float dotNV){return saturate(pow(dotNV+ambientOcclusion,exp2(-16.0*roughness-1.0))-1.0+ambientOcclusion);}float getAARoughnessFactor(vec3 normal){\n#ifdef HAS_DERIVATIVES\nvec3 dxy=max(abs(dFdx(normal)),abs(dFdy(normal)));return 0.04+max(max(dxy.x,dxy.y),dxy.z);\n#else\nreturn 0.04;\n#endif\n}void initGeometry(out Geometry geometry,bool isFrontFacing){geometry.position=v_pos;geometry.viewDir=normalize(camera_Position-v_pos);\n#if defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE)\nmat3 tbn=getTBN(isFrontFacing);\n#endif\n#ifdef MATERIAL_HAS_NORMALTEXTURE\ngeometry.normal=getNormalByNormalTexture(tbn,material_NormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.normal=getNormal(isFrontFacing);\n#endif\ngeometry.dotNV=saturate(dot(geometry.normal,geometry.viewDir));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\n#ifdef MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE\ngeometry.clearCoatNormal=getNormalByNormalTexture(tbn,material_ClearCoatNormalTexture,material_NormalIntensity,v_uv,isFrontFacing);\n#else\ngeometry.clearCoatNormal=getNormal(isFrontFacing);\n#endif\ngeometry.clearCoatDotNV=saturate(dot(geometry.clearCoatNormal,geometry.viewDir));\n#endif\n}void initMaterial(out Material material,const in Geometry geometry){vec4 baseColor=material_BaseColor;float metal=material_Metal;float roughness=material_Roughness;vec3 specularColor=material_PBRSpecularColor;float glossiness=material_Glossiness;float alphaCutoff=material_AlphaCutoff;float F0=pow2((material_IOR-1.0)/(material_IOR+1.0));\n#ifdef MATERIAL_HAS_BASETEXTURE\nvec4 baseTextureColor=texture2D(material_BaseTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nbaseTextureColor=gammaToLinear(baseTextureColor);\n#endif\nbaseColor*=baseTextureColor;\n#endif\n#ifdef RENDERER_ENABLE_VERTEXCOLOR\nbaseColor*=v_color;\n#endif\n#ifdef MATERIAL_IS_ALPHA_CUTOFF\nif(baseColor.a<alphaCutoff){discard;}\n#endif\n#ifdef MATERIAL_HAS_ROUGHNESS_METALLIC_TEXTURE\nvec4 metalRoughMapColor=texture2D(material_RoughnessMetallicTexture,v_uv);roughness*=metalRoughMapColor.g;metal*=metalRoughMapColor.b;\n#endif\n#ifdef MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE\nvec4 specularGlossinessColor=texture2D(material_SpecularGlossinessTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nspecularGlossinessColor=gammaToLinear(specularGlossinessColor);\n#endif\nspecularColor*=specularGlossinessColor.rgb;glossiness*=specularGlossinessColor.a;\n#endif\n#ifdef IS_METALLIC_WORKFLOW\nmaterial.diffuseColor=baseColor.rgb*(1.0-metal);material.specularColor=mix(vec3(F0),baseColor.rgb,metal);material.roughness=roughness;\n#else\nfloat specularStrength=max(max(specularColor.r,specularColor.g),specularColor.b);material.diffuseColor=baseColor.rgb*(1.0-specularStrength);material.specularColor=specularColor;material.roughness=1.0-glossiness;\n#endif\nmaterial.roughness=max(material.roughness,getAARoughnessFactor(geometry.normal));\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nmaterial.clearCoat=material_ClearCoat;material.clearCoatRoughness=material_ClearCoatRoughness;\n#ifdef MATERIAL_HAS_CLEAR_COAT_TEXTURE\nmaterial.clearCoat*=texture2D(material_ClearCoatTexture,v_uv).r;\n#endif\n#ifdef MATERIAL_HAS_CLEAR_COAT_ROUGHNESS_TEXTURE\nmaterial.clearCoatRoughness*=texture2D(material_ClearCoatRoughnessTexture,v_uv).g;\n#endif\nmaterial.clearCoat=saturate(material.clearCoat);material.clearCoatRoughness=max(material.clearCoatRoughness,getAARoughnessFactor(geometry.clearCoatNormal));\n#endif\n#ifdef MATERIAL_IS_TRANSPARENT\nmaterial.opacity=baseColor.a;\n#else\nmaterial.opacity=1.0;\n#endif\n}\n#include <brdf>\n#include <direct_irradiance_frag_define>\n#include <ibl_frag_define>\n",brdf:"#define GLSLIFY 1\nfloat F_Schlick(float dotLH){return 0.04+0.96*(pow(1.0-dotLH,5.0));}vec3 F_Schlick(vec3 specularColor,float dotLH){float fresnel=exp2((-5.55473*dotLH-6.98316)*dotLH);return(1.0-specularColor)*fresnel+specularColor;}float G_GGX_SmithCorrelated(float alpha,float dotNL,float dotNV){float a2=pow2(alpha);float gv=dotNL*sqrt(a2+(1.0-a2)*pow2(dotNV));float gl=dotNV*sqrt(a2+(1.0-a2)*pow2(dotNL));return 0.5/max(gv+gl,EPSILON);}float D_GGX(float alpha,float dotNH){float a2=pow2(alpha);float denom=pow2(dotNH)*(a2-1.0)+1.0;return RECIPROCAL_PI*a2/pow2(denom);}vec3 BRDF_Specular_GGX(vec3 incidentDirection,vec3 viewDir,vec3 normal,vec3 specularColor,float roughness){float alpha=pow2(roughness);vec3 halfDir=normalize(incidentDirection+viewDir);float dotNL=saturate(dot(normal,incidentDirection));float dotNV=saturate(dot(normal,viewDir));float dotNH=saturate(dot(normal,halfDir));float dotLH=saturate(dot(incidentDirection,halfDir));vec3 F=F_Schlick(specularColor,dotLH);float G=G_GGX_SmithCorrelated(alpha,dotNL,dotNV);float D=D_GGX(alpha,dotNH);return F*(G*D);}vec3 BRDF_Diffuse_Lambert(vec3 diffuseColor){return RECIPROCAL_PI*diffuseColor;}",direct_irradiance_frag_define:"#define GLSLIFY 1\n#include <ShadowFragmentDeclaration>\nvoid addDirectRadiance(vec3 incidentDirection,vec3 color,Geometry geometry,Material material,inout ReflectedLight reflectedLight){float attenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nfloat clearCoatDotNL=saturate(dot(geometry.clearCoatNormal,incidentDirection));vec3 clearCoatIrradiance=clearCoatDotNL*color;reflectedLight.directSpecular+=material.clearCoat*clearCoatIrradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.clearCoatNormal,vec3(0.04),material.clearCoatRoughness);attenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nfloat dotNL=saturate(dot(geometry.normal,incidentDirection));vec3 irradiance=dotNL*color*PI;reflectedLight.directSpecular+=attenuation*irradiance*BRDF_Specular_GGX(incidentDirection,geometry.viewDir,geometry.normal,material.specularColor,material.roughness);reflectedLight.directDiffuse+=attenuation*irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);}\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nvoid addDirectionalDirectLightRadiance(DirectLight directionalLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 color=directionalLight.color;vec3 direction=-directionalLight.direction;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nvoid addPointDirectLightRadiance(PointLight pointLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=pointLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);vec3 color=pointLight.color;color*=clamp(1.0-pow(lightDistance/pointLight.distance,4.0),0.0,1.0);addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nvoid addSpotDirectLightRadiance(SpotLight spotLight,Geometry geometry,Material material,inout ReflectedLight reflectedLight){vec3 lVector=spotLight.position-geometry.position;vec3 direction=normalize(lVector);float lightDistance=length(lVector);float angleCos=dot(direction,-spotLight.direction);float spotEffect=smoothstep(spotLight.penumbraCos,spotLight.angleCos,angleCos);float decayEffect=clamp(1.0-pow(lightDistance/spotLight.distance,4.0),0.0,1.0);vec3 color=spotLight.color;color*=spotEffect*decayEffect;addDirectRadiance(direction,color,geometry,material,reflectedLight);}\n#endif\nvoid addTotalDirectRadiance(Geometry geometry,Material material,inout ReflectedLight reflectedLight){float shadowAttenuation=1.0;\n#ifdef SCENE_DIRECT_LIGHT_COUNT\nshadowAttenuation=1.0;\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nshadowAttenuation*=sampleShadowMap();\n#endif\nDirectLight directionalLight;for(int i=0;i<SCENE_DIRECT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_DirectLightCullingMask[i])){directionalLight.color=scene_DirectLightColor[i];\n#ifdef SCENE_IS_CALCULATE_SHADOWS\nif(i==0){directionalLight.color*=shadowAttenuation;}\n#endif\ndirectionalLight.direction=scene_DirectLightDirection[i];addDirectionalDirectLightRadiance(directionalLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_POINT_LIGHT_COUNT\nPointLight pointLight;for(int i=0;i<SCENE_POINT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_PointLightCullingMask[i])){pointLight.color=scene_PointLightColor[i];pointLight.position=scene_PointLightPosition[i];pointLight.distance=scene_PointLightDistance[i];addPointDirectLightRadiance(pointLight,geometry,material,reflectedLight);}}\n#endif\n#ifdef SCENE_SPOT_LIGHT_COUNT\nSpotLight spotLight;for(int i=0;i<SCENE_SPOT_LIGHT_COUNT;i++){if(!isRendererCulledByLight(renderer_Layer.xy,scene_SpotLightCullingMask[i])){spotLight.color=scene_SpotLightColor[i];spotLight.position=scene_SpotLightPosition[i];spotLight.direction=scene_SpotLightDirection[i];spotLight.distance=scene_SpotLightDistance[i];spotLight.angleCos=scene_SpotLightAngleCos[i];spotLight.penumbraCos=scene_SpotLightPenumbraCos[i];addSpotDirectLightRadiance(spotLight,geometry,material,reflectedLight);}}\n#endif\n}",ibl_frag_define:"#define GLSLIFY 1\nvec3 getLightProbeIrradiance(vec3 sh[9],vec3 normal){normal.x=-normal.x;vec3 result=sh[0]+sh[1]*(normal.y)+sh[2]*(normal.z)+sh[3]*(normal.x)+sh[4]*(normal.y*normal.x)+sh[5]*(normal.y*normal.z)+sh[6]*(3.0*normal.z*normal.z-1.0)+sh[7]*(normal.z*normal.x)+sh[8]*(normal.x*normal.x-normal.y*normal.y);return max(result,vec3(0.0));}vec3 envBRDFApprox(vec3 specularColor,float roughness,float dotNV){const vec4 c0=vec4(-1,-0.0275,-0.572,0.022);const vec4 c1=vec4(1,0.0425,1.04,-0.04);vec4 r=roughness*c0+c1;float a004=min(r.x*r.x,exp2(-9.28*dotNV))*r.x+r.y;vec2 AB=vec2(-1.04,1.04)*a004+r.zw;return specularColor*AB.x+AB.y;}float getSpecularMIPLevel(float roughness,int maxMIPLevel){return roughness*float(maxMIPLevel);}vec3 getLightProbeRadiance(vec3 viewDir,vec3 normal,float roughness,int maxMIPLevel,float specularIntensity){\n#ifndef SCENE_USE_SPECULAR_ENV\nreturn vec3(0);\n#else\nvec3 reflectVec=reflect(-viewDir,normal);reflectVec.x=-reflectVec.x;float specularMIPLevel=getSpecularMIPLevel(roughness,maxMIPLevel);\n#ifdef HAS_TEX_LOD\nvec4 envMapColor=textureCubeLodEXT(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#else\nvec4 envMapColor=textureCube(scene_EnvSpecularSampler,reflectVec,specularMIPLevel);\n#endif\n#ifdef SCENE_IS_DECODE_ENV_RGBM\nenvMapColor.rgb=RGBMToLinear(envMapColor,5.0).rgb;\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=linearToGamma(envMapColor);\n#endif\n#else\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nenvMapColor=gammaToLinear(envMapColor);\n#endif\n#endif\nreturn envMapColor.rgb*specularIntensity;\n#endif\n}",pbr_frag:"#define GLSLIFY 1\nGeometry geometry;Material material;ReflectedLight reflectedLight=ReflectedLight(vec3(0.0),vec3(0.0),vec3(0.0),vec3(0.0));initGeometry(geometry,gl_FrontFacing);initMaterial(material,geometry);addTotalDirectRadiance(geometry,material,reflectedLight);\n#ifdef SCENE_USE_SH\nvec3 irradiance=getLightProbeIrradiance(scene_EnvSH,geometry.normal);\n#ifdef ENGINE_IS_COLORSPACE_GAMMA\nirradiance=linearToGamma(vec4(irradiance,1.0)).rgb;\n#endif\nirradiance*=scene_EnvMapLight.diffuseIntensity;\n#else\nvec3 irradiance=scene_EnvMapLight.diffuse*scene_EnvMapLight.diffuseIntensity;irradiance*=PI;\n#endif\nreflectedLight.indirectDiffuse+=irradiance*BRDF_Diffuse_Lambert(material.diffuseColor);vec3 radiance=getLightProbeRadiance(geometry.viewDir,geometry.normal,material.roughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);float radianceAttenuation=1.0;\n#ifdef MATERIAL_ENABLE_CLEAR_COAT\nvec3 clearCoatRadiance=getLightProbeRadiance(geometry.viewDir,geometry.clearCoatNormal,material.clearCoatRoughness,int(scene_EnvMapLight.mipMapLevel),scene_EnvMapLight.specularIntensity);reflectedLight.indirectSpecular+=clearCoatRadiance*material.clearCoat*envBRDFApprox(vec3(0.04),material.clearCoatRoughness,geometry.clearCoatDotNV);radianceAttenuation-=material.clearCoat*F_Schlick(geometry.clearCoatDotNV);\n#endif\nreflectedLight.indirectSpecular+=radianceAttenuation*radiance*envBRDFApprox(material.specularColor,material.roughness,geometry.dotNV);\n#ifdef MATERIAL_HAS_OCCLUSION_TEXTURE\nvec2 aoUV=v_uv;\n#ifdef RENDERER_HAS_UV1\nif(material_OcclusionTextureCoord==1.0){aoUV=v_uv1;}\n#endif\nfloat ambientOcclusion=(texture2D(material_OcclusionTexture,aoUV).r-1.0)*material_OcclusionIntensity+1.0;reflectedLight.indirectDiffuse*=ambientOcclusion;\n#ifdef SCENE_USE_SPECULAR_ENV\nreflectedLight.indirectSpecular*=computeSpecularOcclusion(ambientOcclusion,material.roughness,geometry.dotNV);\n#endif\n#endif\nvec3 emissiveRadiance=material_EmissiveColor;\n#ifdef MATERIAL_HAS_EMISSIVETEXTURE\nvec4 emissiveColor=texture2D(material_EmissiveTexture,v_uv);\n#ifndef ENGINE_IS_COLORSPACE_GAMMA\nemissiveColor=gammaToLinear(emissiveColor);\n#endif\nemissiveRadiance*=emissiveColor.rgb;\n#endif\nvec3 totalRadiance=reflectedLight.directDiffuse+reflectedLight.indirectDiffuse+reflectedLight.directSpecular+reflectedLight.indirectSpecular+emissiveRadiance;vec4 targetColor=vec4(totalRadiance,material.opacity);gl_FragColor=targetColor;"},{normal_get:"#define GLSLIFY 1\nvec3 getNormal(bool isFrontFacing){\n#ifdef RENDERER_HAS_NORMAL\nvec3 normal=normalize(v_normal);\n#elif defined(HAS_DERIVATIVES)\nvec3 pos_dx=dFdx(v_pos);vec3 pos_dy=dFdy(v_pos);vec3 normal=normalize(cross(pos_dx,pos_dy));\n#else\nvec3 normal=vec3(0,0,1);\n#endif\nnormal*=float(isFrontFacing)*2.0-1.0;return normal;}vec3 getNormalByNormalTexture(mat3 tbn,sampler2D normalTexture,float normalIntensity,vec2 uv,bool isFrontFacing){vec3 normal=texture2D(normalTexture,uv).rgb;normal=normalize(tbn*((2.0*normal-1.0)*vec3(normalIntensity,normalIntensity,1.0)));normal*=float(isFrontFacing)*2.0-1.0;return normal;}mat3 getTBN(bool isFrontFacing){\n#if defined(RENDERER_HAS_NORMAL) && defined(RENDERER_HAS_TANGENT) && ( defined(MATERIAL_HAS_NORMALTEXTURE) || defined(MATERIAL_HAS_CLEAR_COAT_NORMAL_TEXTURE) )\nmat3 tbn=v_TBN;\n#else\nvec3 normal=getNormal(isFrontFacing);vec3 position=v_pos;vec2 uv=isFrontFacing? v_uv:-v_uv;\n#ifdef HAS_DERIVATIVES\nvec3 dp1=dFdx(position);vec3 dp2=dFdy(position);vec2 duv1=dFdx(uv);vec2 duv2=dFdy(uv);vec3 dp2perp=cross(dp2,normal);vec3 dp1perp=cross(normal,dp1);vec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;vec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;float invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));mat3 tbn=mat3(tangent*invmax,binormal*invmax,normal);\n#else\nmat3 tbn=mat3(vec3(0.0),vec3(0.0),normal);\n#endif\n#endif\nreturn tbn;}"}),l4=((e2=function(){}).parseCustomMacros=function(e){return e.map(function(e){return"#define "+e+"\n"}).join("")},e2.parseIncludes=function(e){return e.replace(/^[ \t]*#include +<([\w\d.]+)>/gm,function(e,t){var n=l3[t];return void 0===n?(lw.error('Shader slice "'+e.trim()+'" not founded.'),""):e2.parseIncludes(n)})},e2.parseExtension=function(e){return e.map(function(e){return"#extension "+e+" : enable\n"}).join("")},e2.convertTo300=function(e,t){if(e=(e=(e=(e=e.replace(/\battribute\b/g,"in")).replace(/\bvarying\b/g,t?"in":"out")).replace(/\btexture(2D|Cube)\b/g,"texture")).replace(/\btexture(2D|Cube)LodEXT\b/g,"textureLod"),t){if(/\bgl_FragData\[.+?\]/g.test(e)){var n=(e=e.replace(/\bgl_FragColor\b/g,"gl_FragData[0]")).match(/\bgl_FragData\[.+?\]/g);e=this._replaceMRTShader(e,n)}else e=(e=e.replace(/void\s+?main\s*\(/g,"out vec4 glFragColor;\nvoid main(")).replace(/\bgl_FragColor\b/g,"glFragColor")}return e},e2._replaceMRTShader=function(e,t){for(var n="",r=new Set,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)},e2),l5=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}();l5._nameCounter=0,l5._nameMap=Object.create(null);var l8=((e4=(e3=function(){this._tagsMap=Object.create(null)}).prototype).setTag=function(e,t){var n="string"==typeof e?l5.getByName(e):e,r=this._tagsMap;void 0!==r[n._uniqueId]&&lw.warn('The value of tag named "'+n.name+'" is being replaced.'),r[n._uniqueId]=t},e4.deleteTag=function(e){delete this._tagsMap[("string"==typeof e?l5.getByName(e):e)._uniqueId]},e4.getTagValue=function(e){return this._tagsMap["string"==typeof e?l5.getByName(e)._uniqueId:e._uniqueId]},e3);(e5=sa||(sa={}))[e5.Scene=0]="Scene",e5[e5.Camera=1]="Camera",e5[e5.Renderer=2]="Renderer",e5[e5.Material=3]="Material",e.ColorSpace=void 0,(e8=e.ColorSpace||(e.ColorSpace={}))[e8.Linear=0]="Linear",e8[e8.Gamma=1]="Gamma";var l6=((e7=(e6=function(e){this.textureUseCompareMode=!1;var t=e._hardwareRenderer;this._rhi=t,this._gl=t.gl,this._colorSpace=e.settings.colorSpace}).prototype).upload1f=function(e,t){this.cacheValue!==t&&(this._gl.uniform1f(e.location,t),this.cacheValue=t)},e7.upload1fv=function(e,t){this._gl.uniform1fv(e.location,t)},e7.upload2f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform2f(t.location,s7.gammaToLinearSpace(n.r),s7.gammaToLinearSpace(n.g)):this._gl.uniform2f(t.location,n.r,n.g),r.x=n.r,r.y=n.g):(r.x!==n.x||r.y!==n.y)&&(this._gl.uniform2f(t.location,n.x,n.y),r.x=n.x,r.y=n.y)},e7.upload2fv=function(e,t){this._gl.uniform2fv(e.location,t)},e7.upload3f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform3f(t.location,s7.gammaToLinearSpace(n.r),s7.gammaToLinearSpace(n.g),s7.gammaToLinearSpace(n.b)):this._gl.uniform3f(t.location,n.r,n.g,n.b),r.x=n.r,r.y=n.g,r.z=n.b):(r.x!==n.x||r.y!==n.y||r.z!==n.z)&&(this._gl.uniform3f(t.location,n.x,n.y,n.z),r.x=n.x,r.y=n.y,r.z=n.z)},e7.upload3fv=function(e,t){this._gl.uniform3fv(e.location,t)},e7.upload4f=function(t,n){var r=this.cacheValue;void 0!==n.r?(r.x!==n.r||r.y!==n.g||r.z!==n.b||r.w!==n.a)&&(this._colorSpace===e.ColorSpace.Linear?this._gl.uniform4f(t.location,s7.gammaToLinearSpace(n.r),s7.gammaToLinearSpace(n.g),s7.gammaToLinearSpace(n.b),n.a):this._gl.uniform4f(t.location,n.r,n.g,n.b,n.a),r.x=n.r,r.y=n.g,r.z=n.b,r.w=n.a):(r.x!==n.x||r.y!==n.y||r.z!==n.z||r.w!==n.w)&&(this._gl.uniform4f(t.location,n.x,n.y,n.z,n.w),r.x=n.x,r.y=n.y,r.z=n.z,r.w=n.w)},e7.upload4fv=function(e,t){this._gl.uniform4fv(e.location,t)},e7.upload1i=function(e,t){this.cacheValue!==t&&(this._gl.uniform1i(e.location,t),this.cacheValue=t)},e7.upload1iv=function(e,t){this._gl.uniform1iv(e.location,t)},e7.upload2i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g)&&(this._gl.uniform2i(e.location,t.r,t.g),n.x=t.r,n.y=t.g):(n.x!==t.x||n.y!==t.y)&&(this._gl.uniform2i(e.location,t.x,t.y),n.x=t.x,n.y=t.y)},e7.upload2iv=function(e,t){this._gl.uniform2iv(e.location,t)},e7.upload3i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b)&&(this._gl.uniform3i(e.location,t.r,t.g,t.b),n.x=t.r,n.y=t.g,n.z=t.b):(n.x!==t.x||n.y!==t.y||n.z!==t.z)&&(this._gl.uniform3i(e.location,t.x,t.y,t.z),n.x=t.x,n.y=t.y,n.z=t.z)},e7.upload3iv=function(e,t){this._gl.uniform3iv(e.location,t)},e7.upload4i=function(e,t){var n=this.cacheValue;void 0!==t.r?(n.x!==t.r||n.y!==t.g||n.z!==t.b||n.w!==t.a)&&(this._gl.uniform4i(e.location,t.r,t.g,t.b,t.a),n.x=t.r,n.y=t.g,n.z=t.b,n.w=t.a):(n.x!==t.x||n.y!==t.y||n.z!==t.z||n.w!==t.w)&&(this._gl.uniform4i(e.location,t.x,t.y,t.z,t.w),n.x=t.x,n.y=t.y,n.z=t.z,n.w=t.w)},e7.upload4iv=function(e,t){this._gl.uniform4iv(e.location,t)},e7.uploadMat4=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t.elements)},e7.uploadMat4v=function(e,t){this._gl.uniformMatrix4fv(e.location,!1,t)},e7.uploadTexture=function(e,t){var n=this._rhi;n.activeTexture(e.textureIndex),n.bindTexture(t._platformTexture),t._setUseDepthCompareMode(e.textureUseCompareMode)},e7.uploadTextureArray=function(e,t){for(var n=this._rhi,r=e.textureIndex,i=0;i<t.length;i++){var a=t[i];n.activeTexture(r[i]),n.bindTexture(a._platformTexture),a._setUseDepthCompareMode(e.textureUseCompareMode)}},e6),l7=function(){this.constUniforms=[],this.textureUniforms=[]},l9=function(){function e(t,n,r){this.sceneUniformBlock=new l7,this.cameraUniformBlock=new l7,this.rendererUniformBlock=new l7,this.materialUniformBlock=new l7,this.otherUniformBlock=new l7,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=lV._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 sa.Scene:n?this.sceneUniformBlock.textureUniforms.push(e):this.sceneUniformBlock.constUniforms.push(e);break;case sa.Camera:n?this.cameraUniformBlock.textureUniforms.push(e):this.cameraUniformBlock.constUniforms.push(e);break;case sa.Renderer:n?this.rendererUniformBlock.textureUniforms.push(e):this.rendererUniformBlock.constUniforms.push(e);break;case sa.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),!lw.isEnabled||n.getProgramParameter(a,n.LINK_STATUS)||n.isContextLost())?a:(lw.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),!lw.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 l6(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=lV.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 s8(0,0));break;case t.FLOAT_VEC3:c?l.applyFunc=l.upload3fv:(l.applyFunc=l.upload3f,l.cacheValue=new sQ(0,0,0));break;case t.FLOAT_VEC4:c?l.applyFunc=l.upload4fv:(l.applyFunc=l.upload4f,l.cacheValue=new s6(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 s8(0,0));break;case t.BOOL_VEC3:case t.INT_VEC3:l.applyFunc=c?l.upload3iv:l.upload3i,l.cacheValue=new sQ(0,0,0);break;case t.BOOL_VEC4:case t.INT_VEC4:c?l.applyFunc=l.upload4iv:(l.applyFunc=l.upload4i,l.cacheValue=new s6(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=lV._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")},lr(e,[{key:"isValid",get:function(){return this._isValid}}]),e}();l9._counter=0;var ce=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 la(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=[];l0._getNamesByMacros(n,o);var s=l4.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 "+l4.parseIncludes(this._vertexSource),d=" "+l+"\n "+c+"\n "+(a?"":l4.parseExtension(cn._shaderExtension))+"\n "+u+"\n "+s+"\n "+l4.parseIncludes(this._fragmentSource);return a&&(h=l4.convertTo300(h),d=l4.convertTo300(d,!0)),i=new l9(t,h,d),r.cache(i),i},n}(l8);ce._shaderPassCounter=0;var ct=(la(e9=function(e,t,n){var r;if((r=l8.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},l8),lr(e9,[{key:"passes",get:function(){return this._passes}}]),e9),cn=((te=function(e,t){this.name=e,this.name=e,this._subShaders=t}).prototype.compileVariant=function(e,t){var n=te._compileMacros;n.clear();for(var r=0,i=t.length;r<i;r++)n.enable(l0.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},te.create=function(e,t,n){var r,i=te._shaderMap;if(i[e])throw'Shader named "'+e+'" already exists.';if("string"==typeof t){var a=new ce(t,n);r=new te(e,[new ct("Default",[a])])}else if(t.length>0)r=t[0].constructor===ce?new te(e,[new ct("Default",t)]):new te(e,t.slice());else throw"SubShader or ShaderPass count must large than 0.";return i[e]=r,r},te.find=function(e){return te._shaderMap[e]},te.getMacroByName=function(e,t){return l0.getByName(e,t)},te.getPropertyByName=function(e){return lV.getByName(e)},lr(te,[{key:"subShaders",get:function(){return this._subShaders}}]),te);cn._compileMacros=new l1,cn._shaderExtension=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives","GL_EXT_draw_buffers"],cn._shaderMap=Object.create(null);var cr=((tn=(tt=function(e){this._propertyValueMap=Object.create(null),this._macroCollection=new l1,this._macroMap=Object.create(null),this._refCount=0,this._group=e}).prototype).getFloat=function(e){return this.getPropertyValue(e)},tn.setFloat=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Float,n)},tn.getInt=function(e){return this.getPropertyValue(e)},tn.setInt=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Int,n)},tn.getFloatArray=function(e){return this.getPropertyValue(e)},tn.setFloatArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.FloatArray,n)},tn.getIntArray=function(e){return this.getPropertyValue(e)},tn.setIntArray=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.IntArray,n)},tn.getVector2=function(e){return this.getPropertyValue(e)},tn.setVector2=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector2,n)},tn.getVector3=function(e){return this.getPropertyValue(e)},tn.setVector3=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector3,n)},tn.getVector4=function(e){return this.getPropertyValue(e)},tn.setVector4=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Vector4,n)},tn.getMatrix=function(e){return this.getPropertyValue(e)},tn.setMatrix=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Matrix,n)},tn.getColor=function(e){return this.getPropertyValue(e)},tn.setColor=function(t,n){this._setPropertyValue(t,e.ShaderPropertyType.Color,n)},tn.getTexture=function(e){return this.getPropertyValue(e)},tn.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)},tn.getTextureArray=function(e){return this.getPropertyValue(e)},tn.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)},tn.getPropertyValue=function(e){return"string"==typeof e&&(e=lV.getByName(e)),this._propertyValueMap[e._uniqueId]},tn.enableMacro=function(e,t){"string"==typeof e&&(e=l0.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}},tn.disableMacro=function(e){if("string"==typeof e){if(void 0===(t=l0._macroNameIdMap[e]))return}else t=e._nameId;var t,n=this._macroMap[t];n&&(this._macroCollection.disable(n),delete this._macroMap[t])},tn.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])},tn.getProperties=function(e){e?(e.length=0,t=e):t=[];var t,n=this._propertyValueMap,r=lV._propertyIdMap;for(var i in n)t.push(r[i]);if(!e)return t},tn.clone=function(){var e=new tt(this._group);return this.cloneTo(e),e},tn.cloneTo=function(e){lf.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(lc(l,lA))r[s]=l,t>0&&l._addReferCount(t);else if(lc(l,Array)||lc(l,Float32Array)||lc(l,Int32Array))r[s]=l.slice();else{var c=r[s];c?c.copyFrom(l):r[s]=l.clone()}}else r[s]=l}},tn._setPropertyValue=function(t,n,r){if("string"==typeof t&&(t=lV.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 "+sa[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},tn._getReferCount=function(){return this._refCount},tn._addReferCount=function(e){this._refCount+=e;var t=this._propertyValueMap;for(var n in t){var r=t[n];r&&lc(r,lA)&&r._addReferCount(e)}},tt),ci=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},ca=((ti=(tr=function(){this.targetBlendState=new ci,this.blendColor=new s7(0,0,0,0),this.alphaToCoverage=!1}).prototype)._apply=function(e,t){this._platformApply(e,t.blendState)},ti._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(tr._getGLBlendFactor(t,c),tr._getGLBlendFactor(t,u),tr._getGLBlendFactor(t,h),tr._getGLBlendFactor(t,d)),i.sourceColorBlendFactor=c,i.destinationColorBlendFactor=u,i.sourceAlphaBlendFactor=h,i.destinationAlphaBlendFactor=d),(s!==i.colorBlendOperation||l!==i.alphaBlendOperation)&&(r.blendEquationSeparate(tr._getGLBlendOperation(t,s),tr._getGLBlendOperation(t,l)),i.colorBlendOperation=s,i.alphaBlendOperation=l);var f=this.blendColor;s7.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)},tr._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}},tr._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}},tr),co=((to=(ta=function(){this.enabled=!0,this.writeEnabled=!0,this.compareFunction=e.CompareFunction.Less}).prototype)._apply=function(e,t){this._platformApply(e,t.depthState)},to._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(ta._getGLCompareFunction(e,i)),t.compareFunction=i),a!=t.writeEnabled&&(n.depthMask(a),t.writeEnabled=a))},ta._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}},ta),cs=((tl=(ts=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)},tl._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)},ts),cl=((tu=(tc=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)},tu._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,tc._getGLCompareFunction(e,o),i,a),t.compareFunctionFront=o),(p||s!==t.compareFunctionBack)&&(n.stencilFuncSeparate(n.BACK,tc._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,tc._getGLStencilOperation(e,l),tc._getGLStencilOperation(e,c),tc._getGLStencilOperation(e,u)),t.failOperationFront=l,t.zFailOperationFront=c,t.passOperationFront=u),(h!==t.failOperationBack||d!==t.zFailOperationBack||_!==t.passOperationBack)&&(n.stencilOpSeparate(n.BACK,tc._getGLStencilOperation(e,h),tc._getGLStencilOperation(e,d),tc._getGLStencilOperation(e,_)),t.failOperationBack=h,t.zFailOperationBack=d,t.passOperationBack=_),f!==t.writeMask&&(n.stencilMask(f),t.writeMask=f)}},tc._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}},tc._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}},tc),cc=((th=function(){this.blendState=new ca,this.depthState=new co,this.stencilState=new cl,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)},th),cu=((td=function(){}).prototype.applyVirtualCamera=function(e){this.virtualCamera=e;var t=this.camera.shaderData;t.setMatrix(td._viewMatrixProperty,e.viewMatrix),t.setMatrix(td._projectionMatrixProperty,e.projectionMatrix),t.setMatrix(td.vpMatrixProperty,e.viewProjectionMatrix)},td);cu.vpMatrixProperty=lV.getByName("camera_VPMat"),cu.pipelineStageKey=l5.getByName("pipelineStage"),cu._viewMatrixProperty=lV.getByName("camera_ViewMat"),cu._projectionMatrixProperty=lV.getByName("camera_ProjMat");var ch=((tf=(t_=function(){}).prototype).set=function(e,t,n){this.data=e,this.shaderPass=t,this.renderState=n},tf.dispose=function(){this.data=this.shaderPass=this.renderState=null},t_);function cd(){return function(e){}}e.SpriteMaskInteraction=void 0,(tp=e.SpriteMaskInteraction||(e.SpriteMaskInteraction={}))[tp.None=0]="None",tp[tp.VisibleInsideMask=1]="VisibleInsideMask",tp[tp.VisibleOutsideMask=2]="VisibleOutsideMask",e.Renderer=(la(tg=function(t){(n=lU.call(this,t)||this)._onUpdateIndex=-1,n._rendererIndex=-1,n._globalShaderMacro=new l1,n._bounds=new sZ,n._overrideUpdate=!1,n._materials=[],n._dirtyUpdateFlag=0,n._shaderData=new cr(sa.Renderer),n._mvMatrix=new s4,n._mvpMatrix=new s4,n._mvInvMatrix=new s4,n._normalMatrix=new s4,n._materialsInstanced=[],n._priority=0,n._receiveShadows=!0,n._rendererLayer=new s6,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(lt(n)),n._registerEntityTransformListener(),i.enableMacro(e.Renderer._receiveShadowMacro),i.setVector4(e.Renderer._rendererLayerProperty,n._rendererLayer),n},lU),(tm=tg.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},tm.getMaterial=function(e){return void 0===e&&(e=0),this._materials[e]||null},tm.setMaterial=function(e,t){void 0===t&&(t=null),"number"==typeof e?this._setMaterial(e,t):this._setMaterial(0,e)},tm.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},tm.getMaterials=function(){return this._materials},tm.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))}},tm.update=function(e){},tm._onEnable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.addOnUpdateRenderers(this),e.addRenderer(this)},tm._onDisable=function(){var e=this.engine._componentsManager;this._overrideUpdate&&e.removeOnUpdateRenderers(this),e.removeRenderer(this)},tm._prepareRender=function(t){var n=t.virtualCamera,r=n.position,i=this.bounds.getCenter(e.Renderer._tempVector0);n.isOrthographic?(sQ.subtract(i,r,i),this._distanceForSort=sQ.dot(i,n.forward)):this._distanceForSort=sQ.distanceSquared(i,r),this._updateShaderData(t),this._render(t),l1.unionCollection(t.camera._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro)},tm._cloneTo=function(e){for(var t=this._materials,n=0,r=t.length;n<r;n++)e._setMaterial(n,t[n])},tm._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},tm._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)},tm._updateTransformShaderData=function(t,n){var r=this.shaderData,i=t.virtualCamera,a=this._mvMatrix,o=this._mvpMatrix,s=this._mvInvMatrix,l=this._normalMatrix;s4.multiply(i.viewMatrix,n,a),s4.multiply(i.viewProjectionMatrix,n,o),s4.invert(a,s),s4.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)},tm._registerEntityTransformListener=function(){this.entity.transform._updateFlagManager.addListener(this._onTransformChanged)},tm._updateBounds=function(e){},tm._render=function(e){throw"not implement"},tm._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},tm._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}},tm._onTransformChanged=function(e){this._dirtyUpdateFlag|=1},lr(tg,[{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}}]),(so=tg)._tempVector0=new sQ,so._receiveShadowMacro=l0.getByName("RENDERER_IS_RECEIVE_SHADOWS"),so._localMatrixProperty=lV.getByName("renderer_LocalMat"),so._worldMatrixProperty=lV.getByName("renderer_ModelMat"),so._mvMatrixProperty=lV.getByName("renderer_MVMat"),so._mvpMatrixProperty=lV.getByName("renderer_MVPMat"),so._mvInvMatrixProperty=lV.getByName("renderer_MVInvMat"),so._normalMatrixProperty=lV.getByName("renderer_NormalMat"),so._rendererLayerProperty=lV.getByName("renderer_Layer"),so),ll([lu],e.Renderer.prototype,"_distanceForSort",void 0),ll([lu],e.Renderer.prototype,"_onUpdateIndex",void 0),ll([lu],e.Renderer.prototype,"_rendererIndex",void 0),ll([lu],e.Renderer.prototype,"_globalShaderMacro",void 0),ll([l_],e.Renderer.prototype,"_bounds",void 0),ll([lu],e.Renderer.prototype,"_renderFrameCount",void 0),ll([lu],e.Renderer.prototype,"_overrideUpdate",void 0),ll([lu],e.Renderer.prototype,"_materials",void 0),ll([lu],e.Renderer.prototype,"_dirtyUpdateFlag",void 0),ll([l_],e.Renderer.prototype,"_shaderData",void 0),ll([lu],e.Renderer.prototype,"_mvMatrix",void 0),ll([lu],e.Renderer.prototype,"_mvpMatrix",void 0),ll([lu],e.Renderer.prototype,"_mvInvMatrix",void 0),ll([lu],e.Renderer.prototype,"_normalMatrix",void 0),ll([lu],e.Renderer.prototype,"_materialsInstanced",void 0),ll([lu],e.Renderer.prototype,"_priority",void 0),ll([lh],e.Renderer.prototype,"_receiveShadows",void 0),ll([lu],e.Renderer.prototype,"_rendererLayer",void 0),ll([lu],e.Renderer.prototype,"_onTransformChanged",null),e.Renderer=ll([lk(lq,e.DependentMode.CheckOnly)],e.Renderer),(tv=ss||(ss={}))[tv.WorldVolume=1]="WorldVolume";var c_=((ty=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 sQ),i.push(new s8);t.triangles=c_._rectangleTriangles},ty.updatePositions=function(e){var t=e.width,n=e.height,r=e.sprite,i=r.pivot,a=i.x,o=i.y,s=c_._worldMatrix,l=s.elements,c=e.entity.transform.worldMatrix.elements,u=e.flipX?-t:t,h=e.flipY?-n:n;l[0]=c[0]*u,l[1]=c[1]*u,l[2]=c[2]*u,l[4]=c[4]*h,l[5]=c[5]*h,l[6]=c[6]*h,l[8]=c[8],l[9]=c[9],l[10]=c[10],l[12]=c[12]-a*l[0]-o*l[4],l[13]=c[13]-a*l[1]-o*l[5],l[14]=c[14]-a*l[2]-o*l[6];for(var d=r._getPositions(),_=e._verticesData.positions,f=0;f<4;f++){var p=d[f],g=p.x,m=p.y;_[f].set(l[0]*g+l[4]*m+l[12],l[1]*g+l[5]*m+l[13],l[2]*g+l[6]*m+l[14])}sZ.transform(r._getBounds(),s,e._bounds)},ty.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)},(sl=ty)._rectangleTriangles=[0,1,2,2,1,3],sl._worldMatrix=new s4,sl);c_=ll([cd()],c_);var cf=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,(tx=e.SpriteMaskLayer||(e.SpriteMaskLayer={}))[tx.Layer0=1]="Layer0",tx[tx.Layer1=2]="Layer1",tx[tx.Layer2=4]="Layer2",tx[tx.Layer3=8]="Layer3",tx[tx.Layer4=16]="Layer4",tx[tx.Layer5=32]="Layer5",tx[tx.Layer6=64]="Layer6",tx[tx.Layer7=128]="Layer7",tx[tx.Layer8=256]="Layer8",tx[tx.Layer9=512]="Layer9",tx[tx.Layer10=1024]="Layer10",tx[tx.Layer11=2048]="Layer11",tx[tx.Layer12=4096]="Layer12",tx[tx.Layer13=8192]="Layer13",tx[tx.Layer14=16384]="Layer14",tx[tx.Layer15=32768]="Layer15",tx[tx.Layer16=65536]="Layer16",tx[tx.Layer17=131072]="Layer17",tx[tx.Layer18=262144]="Layer18",tx[tx.Layer19=524288]="Layer19",tx[tx.Layer20=1048576]="Layer20",tx[tx.Layer21=2097152]="Layer21",tx[tx.Layer22=4194304]="Layer22",tx[tx.Layer23=8388608]="Layer23",tx[tx.Layer24=16777216]="Layer24",tx[tx.Layer25=33554432]="Layer25",tx[tx.Layer26=67108864]="Layer26",tx[tx.Layer27=134217728]="Layer27",tx[tx.Layer28=268435456]="Layer28",tx[tx.Layer29=536870912]="Layer29",tx[tx.Layer30=1073741824]="Layer30",tx[tx.Layer31=2147483648]="Layer31",tx[tx.Everything=4294967295]="Everything",(tC=sc||(sc={}))[tC.texture=1]="texture",tC[tC.size=2]="size",tC[tC.atlasRotate=4]="atlasRotate",tC[tC.atlasRegion=8]="atlasRegion",tC[tC.atlasRegionOffset=16]="atlasRegionOffset",tC[tC.region=32]="region",tC[tC.pivot=64]="pivot",tC[tC.border=128]="border";var cp=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 cf(4,[],[]),c_.resetData(lt(i)),i.setMaterial(i._engine._spriteMaskDefaultMaterial),i.shaderData.setFloat(n._alphaCutoffProperty,i._alphaCutoff),i._onSpriteChange=i._onSpriteChange.bind(lt(i)),i}la(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?c_.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&ss.WorldVolume&&(c_.updatePositions(this),this._dirtyUpdateFlag&=~ss.WorldVolume),2&this._dirtyUpdateFlag&&(c_.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 sc.texture:this.shaderData.setTexture(n._textureProperty,this.sprite.texture);break;case sc.size:this._dirtyUpdateFlag|=4,(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ss.WorldVolume);break;case sc.region:case sc.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sc.atlasRegion:this._dirtyUpdateFlag|=2;break;case sc.pivot:this._dirtyUpdateFlag|=ss.WorldVolume}},lr(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|=ss.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|=ss.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ss.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ss.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);cp._textureProperty=lV.getByName("renderer_MaskTexture"),cp._alphaCutoffProperty=lV.getByName("renderer_MaskAlphaCutoff"),ll([lh],cp.prototype,"influenceLayers",void 0),ll([lu],cp.prototype,"_sprite",void 0),ll([lu],cp.prototype,"_automaticWidth",void 0),ll([lu],cp.prototype,"_automaticHeight",void 0),ll([lh],cp.prototype,"_customWidth",void 0),ll([lh],cp.prototype,"_customHeight",void 0),ll([lh],cp.prototype,"_flipX",void 0),ll([lh],cp.prototype,"_flipY",void 0),ll([lh],cp.prototype,"_alphaCutoff",void 0),ll([lu],cp.prototype,"_onSpriteChange",null),(tT=su||(su={}))[tT.UV=2]="UV",tT[tT.RenderData=3]="RenderData",tT[tT.AutomaticSize=4]="AutomaticSize",tT[tT.All=7]="All",e.VertexElementFormat=void 0,(tS=e.VertexElementFormat||(e.VertexElementFormat={}))[tS.Float=0]="Float",tS[tS.Vector2=1]="Vector2",tS[tS.Vector3=2]="Vector3",tS[tS.Vector4=3]="Vector4",tS[tS.Byte4=4]="Byte4",tS[tS.UByte4=5]="UByte4",tS[tS.NormalizedByte4=6]="NormalizedByte4",tS[tS.NormalizedUByte4=7]="NormalizedUByte4",tS[tS.Short2=8]="Short2",tS[tS.UShort2=9]="UShort2",tS[tS.NormalizedShort2=10]="NormalizedShort2",tS[tS.NormalizedUShort2=11]="NormalizedUShort2",tS[tS.Short4=12]="Short4",tS[tS.UShort4=13]="UShort4",tS[tS.NormalizedShort4=14]="NormalizedShort4",tS[tS.NormalizedUShort4=15]="NormalizedUShort4",e.IndexFormat=void 0,(tw=e.IndexFormat||(e.IndexFormat={}))[tw.UInt8=0]="UInt8",tw[tw.UInt16=1]="UInt16",tw[tw.UInt32=2]="UInt32";var cg=((tA=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}},tA._getGLIndexByteCount=function(t){switch(t){case e.IndexFormat.UInt8:return 1;case e.IndexFormat.UInt16:return 2;case e.IndexFormat.UInt32:return 4}},tA._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}},tA),cm=(lr(tE=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=cg._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}}]),tE);e.BufferUsage=void 0,(tM=e.BufferUsage||(e.BufferUsage={}))[tM.Static=0]="Static",tM[tM.Dynamic=1]="Dynamic",tM[tM.Stream=2]="Stream",e.SetDataOptions=void 0,(tb=e.SetDataOptions||(e.SetDataOptions={}))[tb.None=0]="None",tb[tb.Discard=1]="Discard";var cv=(la(tR=function(t,n,r,i){if(void 0===i&&(i=e.BufferUsage.Static),(a=lv.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},lv),(tF=tR.prototype).bind=function(){this._platformBuffer.bind()},tF.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)},tF.getData=function(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),this._platformBuffer.getData(e,t,n,r)},tF._rebuild=function(){var e=this._engine._hardwareRenderer.createPlatformBuffer(this._type,this._byteLength,this._bufferUsage);this._platformBuffer=e},tF._onDestroy=function(){lv.prototype._onDestroy.call(this),this._platformBuffer.destroy()},tF.resize=function(e){this._platformBuffer.resize(e),this._byteLength=e},lr(tR,[{key:"type",get:function(){return this._type}},{key:"byteLength",get:function(){return this._byteLength}},{key:"bufferUsage",get:function(){return this._bufferUsage}}]),tR);e.BufferBindFlag=void 0,(tP=e.BufferBindFlag||(e.BufferBindFlag={}))[tP.VertexBuffer=0]="VertexBuffer",tP[tP.IndexBuffer=1]="IndexBuffer",e.MeshTopology=void 0,(tL=e.MeshTopology||(e.MeshTopology={}))[tL.Points=0]="Points",tL[tL.Lines=1]="Lines",tL[tL.LineLoop=2]="LineLoop",tL[tL.LineStrip=3]="LineStrip",tL[tL.Triangles=4]="Triangles",tL[tL.TriangleStrip=5]="TriangleStrip",tL[tL.TriangleFan=6]="TriangleFan";var cy=(lr(tD=function(e,t){this._buffer=e,this._format=t},[{key:"buffer",get:function(){return this._buffer}},{key:"format",get:function(){return this._format}}]),tD),cx=((tI=function(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=e.MeshTopology.Triangles),this.start=t,this.count=n,this.topology=r}).prototype.dispose=function(){},tI),cC=(la(tB=function(e,t){(n=lv.call(this,e)||this)._vertexElementMap={},n._instanceCount=0,n._vertexBufferBindings=[],n._indexBufferBinding=null,n._vertexElements=[],n._enableVAO=!0,n._updateFlagManager=new lK,n._bounds=new sZ,n._subMeshes=[],n.name=t,n._platformPrimitive=n._engine._hardwareRenderer.createPlatformPrimitive(lt(n)),n._onBoundsChanged=n._onBoundsChanged.bind(lt(n));var n,r=n._bounds;return r.min._onValueChanged=n._onBoundsChanged,r.max._onValueChanged=n._onBoundsChanged,n},lv),(tN=tB.prototype).addSubMesh=function(t,n,r){return void 0===r&&(r=e.MeshTopology.Triangles),"number"==typeof t&&(t=new cx(t,n,r)),this._subMeshes.push(t),t},tN.removeSubMesh=function(e){var t=this._subMeshes,n=t.indexOf(e);-1!==n&&t.splice(n,1)},tN.clearSubMesh=function(){this._subMeshes.length=0},tN._clearVertexElements=function(){this._vertexElements.length=0;var e=this._vertexElementMap;for(var t in e)delete e[t]},tN._addVertexElement=function(e){var t=e.semantic;this._vertexElementMap[t]=e,this._vertexElements.push(e),this._updateFlagManager.dispatch(2),this._bufferStructChanged=!0},tN._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},tN._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},tN._draw=function(e,t){this._platformPrimitive.draw(e,t),this._bufferStructChanged=!1},tN._addReferCount=function(e){lv.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)},tN._rebuild=function(){this._engine._hardwareRenderer.createPlatformPrimitive(this)},tN._onDestroy=function(){lv.prototype._onDestroy.call(this),this._vertexBufferBindings=null,this._indexBufferBinding=null,this._vertexElements=null,this._vertexElementMap=null,this._platformPrimitive.destroy()},tN._setVertexElements=function(e){this._clearVertexElements();for(var t=0,n=e.length;t<n;t++)this._addVertexElement(e[t])},tN._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=cg._getGLIndexType(e.format),this._glIndexByteCount=cg._getGLIndexByteCount(e.format),t&&t._buffer===e._buffer||(this._bufferStructChanged=!0)):(this._indexBufferBinding=null,this._glIndexType=void 0,t&&(this._bufferStructChanged=!0))},tN._onBoundsChanged=function(){this._updateFlagManager.dispatch(1)},lr(tB,[{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}}]),tB);(tV=sh||(sh={}))[tV.Bounds=1]="Bounds",tV[tV.VertexElements=2]="VertexElements";var cT=(lr(tO=function(e,t){this._buffer=e,this._stride=t},[{key:"buffer",get:function(){return this._buffer}},{key:"stride",get:function(){return this._stride}}]),tO),cS=((tz=(tU=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 sQ(0,0,0),this._canUseTextureStoreData=!0,this._dataTextureInfo=new sQ,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(lj))},tz._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},tz._updateShaderData=function(e,t){var n=this._blendShapeCount;if(n>0){if(e.enableMacro(tU._blendShapeMacro),this._useTextureMode())e.enableMacro(tU._blendShapeTextureMacro),e.setTexture(tU._blendShapeTextureProperty,this._vertexTexture),e.setVector3(tU._blendShapeTextureInfoProperty,this._dataTextureInfo),e.setFloatArray(tU._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(tU._blendShapeWeightsProperty,i),this._modelMesh._enableVAO=!1,n=r}else e.setFloatArray(tU._blendShapeWeightsProperty,t.blendShapeWeights),this._modelMesh._enableVAO=!0;e.disableMacro(tU._blendShapeTextureMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT"),this._uniformOccupiesCount=n}this._useBlendNormal?e.enableMacro(tU._blendShapeNormalMacro):e.disableMacro(tU._blendShapeNormalMacro),this._useBlendTangent?e.enableMacro(tU._blendShapeTangentMacro):e.disableMacro(tU._blendShapeTangentMacro)}else e.disableMacro(tU._blendShapeMacro),e.disableMacro("RENDERER_BLENDSHAPE_COUNT")},tz._useTextureMode=function(){return!!this._canUseTextureStoreData&&this._blendShapeCount>this._getVertexBufferModeSupportCount()},tz._layoutOrCountChange=function(){var e=this._lastCreateHostInfo;return e.x!==this._blendShapeCount||!!e.y!==this._useBlendNormal||!!e.z!==this._useBlendTangent},tz._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},tz._needUpdateData=function(){for(var e=this._subDataDirtyFlags,t=0,n=e.length;t<n;t++)if(e[t].flag)return!0;return!1},tz._setAttributeModeOffsetInfo=function(e,t){this._vertexElementOffset=e,this._bufferBindingOffset=t},tz._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 cm("POSITION_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12,this._useBlendNormal&&(t._addVertexElement(new cm("NORMAL_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12),this._useBlendTangent&&(t._addVertexElement(new cm("TANGENT_BS"+i,r,e.VertexElementFormat.Vector3,n)),r+=12)},tz._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))},tz._releaseMemoryCache=function(){for(var e=this._blendShapes,t=0,n=e.length;t<n;t++)e[t]._releaseData();this._vertices=null},tz._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 cv(r,e.BufferBindFlag.VertexBuffer,p,g);i._setVertexBufferBinding(h+d,new cT(m,f)),o[d]=m}},tz._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 lb(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)},tz._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),C=v*l,T=o[h];T||(o[h]=T=new s8),T.set(u+m,v*c);for(var S=g.deltaPositions,w=0;w<e;w++){var A=C+x*w,E=S[w];E&&(i[A]=E.x,i[A+1]=E.y,i[A+2]=E.z)}if(C+=3,this._useBlendNormal){var M=g.deltaNormals;if(M)for(var b=0;b<e;b++){var R=C+x*b,F=M[b];F&&(i[R]=F.x,i[R+1]=F.y,i[R+2]=F.z)}C+=3}if(this._useBlendTangent){var P=g.deltaTangents;if(P)for(var L=0;L<e;L++){var D=C+x*L,I=P[L];I&&(i[D]=I.x,i[D+1]=I.y,i[D+2]=I.z)}C+=3}(v===r-1||h===d-1)&&y.setData(i,0,0,y.byteLength/4),_.flag=!1}}},tz._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)},tz._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},tz._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}},tz._getVertexBufferModeSupportCount=function(){return this._useBlendNormal&&this._useBlendTangent?2:this._useBlendNormal||this._useBlendTangent?4:8},tz._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)}}}},tU);cS._blendShapeMacro=l0.getByName("RENDERER_HAS_BLENDSHAPE"),cS._blendShapeTextureMacro=l0.getByName("RENDERER_BLENDSHAPE_USE_TEXTURE"),cS._blendShapeNormalMacro=l0.getByName("RENDERER_BLENDSHAPE_HAS_NORMAL"),cS._blendShapeTangentMacro=l0.getByName("RENDERER_BLENDSHAPE_HAS_TANGENT"),cS._blendShapeWeightsProperty=lV.getByName("renderer_BlendShapeWeights"),cS._blendShapeTextureProperty=lV.getByName("renderer_BlendShapeTexture"),cS._blendShapeTextureInfoProperty=lV.getByName("renderer_BlendShapeTextureInfo"),(tk=sd||(sd={})).Position="POSITION",tk.Normal="NORMAL",tk.Color="COLOR_0",tk.Tangent="TANGENT",tk.BoneWeight="WEIGHTS_0",tk.BoneIndex="JOINTS_0",tk.UV="TEXCOORD_0",tk.UV1="TEXCOORD_1",tk.UV2="TEXCOORD_2",tk.UV3="TEXCOORD_3",tk.UV4="TEXCOORD_4",tk.UV5="TEXCOORD_5",tk.UV6="TEXCOORD_6",tk.UV7="TEXCOORD_7";var cw=(la(tG=function(e,t){var n;return(n=cC.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 cS(e,lt(n)),n},cC),(tH=tG.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}},tH.getPositions=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._positions},tH.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},tH.getNormals=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._normals},tH.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},tH.getColors=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._colors},tH.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},tH.getBoneWeights=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneWeights},tH.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},tH.getBoneIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._boneIndices},tH.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},tH.getTangents=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._tangents},tH.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]."}},tH.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]."},tH.setIndices=function(t){this._indices!==t&&(this._indices=t,lc(t,Uint8Array)?this._indicesFormat=e.IndexFormat.UInt8:lc(t,Uint16Array)?this._indicesFormat=e.IndexFormat.UInt16:lc(t,Uint32Array)&&(this._indicesFormat=e.IndexFormat.UInt32)),this._indicesChangeFlag=!0},tH.getIndices=function(){if(!this._readable)throw"Not allowed to access data while accessible is false.";return this._indices},tH.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[sd.Position]?this.getPositions()&&(this._vertexBufferUpdateFlag|=1):this.setPositions(null),n[sd.Normal]?this.getNormals()&&(this._vertexBufferUpdateFlag|=2):this.setNormals(null),n[sd.Color]?this.getColors()&&(this._vertexBufferUpdateFlag|=4):this.setColors(null),n[sd.BoneWeight]?this.getBoneWeights()&&(this._vertexBufferUpdateFlag|=16):this.setBoneWeights(null),n[sd.BoneIndex]?this.getBoneIndices()&&(this._vertexBufferUpdateFlag|=32):this.setBoneIndices(null),n[sd.Tangent]?this.getTangents()&&(this._vertexBufferUpdateFlag|=8):this.setTangents(null),n[sd.UV]?this.getUVs(0)&&(this._vertexBufferUpdateFlag|=64):this.setUVs(null,0),n[sd.UV1]?this.getUVs(1)&&(this._vertexBufferUpdateFlag|=128):this.setUVs(null,1),n[sd.UV2]?this.getUVs(2)&&(this._vertexBufferUpdateFlag|=256):this.setUVs(null,2),n[sd.UV3]?this.getUVs(3)&&(this._vertexBufferUpdateFlag|=512):this.setUVs(null,3),n[sd.UV4]?this.getUVs(4)&&(this._vertexBufferUpdateFlag|=1024):this.setUVs(null,4),n[sd.UV5]?this.getUVs(5)&&(this._vertexBufferUpdateFlag|=2048):this.setUVs(null,5),n[sd.UV6]?this.getUVs(6)&&(this._vertexBufferUpdateFlag|=4096):this.setUVs(null,6),n[sd.UV7]?this.getUVs(7)&&(this._vertexBufferUpdateFlag|=8192):this.setUVs(null,7),this._vertexElementsUpdate=!0},tH.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 cT(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r),this._vertexDataUpdateFlag|=1},tH.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])},tH.addBlendShape=function(e){this._blendShapeManager._addBlendShape(e)},tH.clearBlendShapes=function(){this._blendShapeManager._clearBlendShapes()},tH.getBlendShapeName=function(e){return this._blendShapeManager._blendShapes[e].name},tH.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 cv(this._engine,e.BufferBindFlag.VertexBuffer,a,o);this._setVertexBufferBinding(0,new cT(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 cy(_,this._indicesFormat));else{null==_||_.destroy();var f=new cv(this._engine,e.BufferBindFlag.IndexBuffer,d);this._setIndexBufferBinding(new cy(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())},tH.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=tG._tempVec0,o=tG._tempVec1,s=tG._tempVec2,l=tG._tempVec3,c=tG._tempVec4,u=e?e.length/3:t.length/3,h=Array(i),d=Array(i),_=0;_<i;_++)h[_]=new s6,d[_]=new sQ;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],C=r[p],T=r[g],S=r[m];sQ.subtract(y,v,a),sQ.subtract(x,v,o);var w=T.x-C.x,A=S.x-C.x,E=T.y-C.y,M=S.y-C.y,b=1/(w*M-A*E);sQ.scale(a,M*b,s),sQ.scale(o,E*b,c),sQ.subtract(s,c,s),sQ.scale(o,w*b,l),sQ.scale(a,A*b,c),sQ.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),sQ.cross(s,L,c);var I=sQ.dot(c,P)>0?1:-1;sQ.scale(P,sQ.dot(s,P),c),sQ.subtract(s,c,s),s.normalize(),D.set(s.x,s.y,s.z,I)}this.setTangents(h)},tH._onDestroy=function(){cC.prototype._onDestroy.call(this),this._readable&&this._releaseCache()},tH._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[sd.Position]&&this._insertVertexAttribute(sd.Position),this._normals&&!r[sd.Normal]&&this._insertVertexAttribute(sd.Normal),this._colors&&!r[sd.Color]&&this._insertVertexAttribute(sd.Color),this._boneWeights&&!r[sd.BoneWeight]&&this._insertVertexAttribute(sd.BoneWeight),this._boneIndices&&!r[sd.BoneIndex]&&this._insertVertexAttribute(sd.BoneIndex),this._tangents&&!r[sd.Tangent]&&this._insertVertexAttribute(sd.Tangent),this._uv&&!r[sd.UV]&&this._insertVertexAttribute(sd.UV),this._uv1&&!r[sd.UV1]&&this._insertVertexAttribute(sd.UV1),this._uv2&&!r[sd.UV2]&&this._insertVertexAttribute(sd.UV2),this._uv3&&!r[sd.UV3]&&this._insertVertexAttribute(sd.UV3),this._uv4&&!r[sd.UV4]&&this._insertVertexAttribute(sd.UV4),this._uv5&&!r[sd.UV5]&&this._insertVertexAttribute(sd.UV5),this._uv6&&!r[sd.UV6]&&this._insertVertexAttribute(sd.UV6),this._uv7&&!r[sd.UV7]&&this._insertVertexAttribute(sd.UV7)},tH._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)},tH._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,C=r[y];e[x]=C.x,e[x+1]=C.y,e[x+2]=C.z}var T=3;if(i){if(2&o)for(var S=0;S<n;S++){var w=v*S+T,A=i[S];A&&(e[w]=A.x,e[w+1]=A.y,e[w+2]=A.z)}T+=3}if(a){if(4&o)for(var E=0;E<n;E++){var M=v*E+T,b=a[E];b&&(e[M]=b.r,e[M+1]=b.g,e[M+2]=b.b,e[M+3]=b.a)}T+=4}if(s){if(16&o)for(var R=0;R<n;R++){var F=v*R+T,P=s[R];P&&(e[F]=P.x,e[F+1]=P.y,e[F+2]=P.z,e[F+3]=P.w)}T+=4}if(l){if(32&o)for(var L=this._verticesUint8,D=0;D<n;D++){var I=v*D+T,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}}T+=1}if(c){if(8&o)for(var V=0;V<n;V++){var O=v*V+T,U=c[V];U&&(e[O]=U.x,e[O+1]=U.y,e[O+2]=U.z,e[O+3]=U.w)}T+=4}if(u){if(64&o)for(var z=0;z<n;z++){var k=v*z+T,G=u[z];G&&(e[k]=G.x,e[k+1]=G.y)}T+=2}if(h){if(128&o)for(var H=0;H<n;H++){var W=v*H+T,X=h[H];X&&(e[W]=X.x,e[W+1]=X.y)}T+=2}if(d){if(256&o)for(var j=0;j<n;j++){var K=v*j+T,q=d[j];q&&(e[K]=q.x,e[K+1]=q.y)}T+=2}if(_){if(512&o)for(var Y=0;Y<n;Y++){var Q=v*Y+T,J=_[Y];J&&(e[Q]=J.x,e[Q+1]=J.y)}T+=2}if(f){if(1024&o)for(var Z=0;Z<n;Z++){var $=v*Z+T,ee=f[Z];ee&&(e[$]=ee.x,e[$+1]=ee.y)}T+=2}if(p){if(2048&o)for(var et=0;et<n;et++){var en=v*et+T,er=p[et];er&&(e[en]=er.x,e[en+1]=er.y)}T+=2}if(g){if(4096&o)for(var ei=0;ei<n;ei++){var ea=v*ei+T,eo=g[ei];eo&&(e[ea]=eo.x,e[ea+1]=eo.y)}T+=2}if(m){if(8192&o)for(var es=0;es<n;es++){var el=v*es+T,ec=m[es];ec&&(e[el]=ec.x,e[el+1]=ec.y)}T+=2}this._vertexBufferUpdateFlag=0},tH._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 cm(e,a,t,0)),this._bufferStrides[0]=a+n},tH._getAttributeFormat=function(t){switch(t){case sd.Position:case sd.Normal:return e.VertexElementFormat.Vector3;case sd.Color:case sd.BoneWeight:return e.VertexElementFormat.Vector4;case sd.BoneIndex:return e.VertexElementFormat.UByte4;case sd.Tangent:return e.VertexElementFormat.Vector4;case sd.UV:case sd.UV1:case sd.UV2:case sd.UV3:case sd.UV4:case sd.UV5:case sd.UV6:case sd.UV7:return e.VertexElementFormat.Vector2}},tH._getAttributeByteLength=function(e){switch(e){case sd.Position:case sd.Normal:return 12;case sd.Color:case sd.BoneWeight:return 16;case sd.BoneIndex:return 4;case sd.Tangent:return 16;case sd.UV:case sd.UV1:case sd.UV2:case sd.UV3:case sd.UV4:case sd.UV5:case sd.UV6:case sd.UV7:return 8}},tH._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()},lr(tG,[{key:"readable",get:function(){return this._readable}},{key:"vertexCount",get:function(){if(1&this._vertexDataUpdateFlag){var e=0,t=this._vertexElementMap[sd.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}}]),tG);cw._tempVec0=new sQ,cw._tempVec1=new sQ,cw._tempVec2=new sQ,cw._tempVec3=new sQ,cw._tempVec4=new sQ,(tW=s_||(s_={}))[tW.Position=1]="Position",tW[tW.Normal=2]="Normal",tW[tW.Color=4]="Color",tW[tW.Tangent=8]="Tangent",tW[tW.BoneWeight=16]="BoneWeight",tW[tW.BoneIndex=32]="BoneIndex",tW[tW.UV=64]="UV",tW[tW.UV1=128]="UV1",tW[tW.UV2=256]="UV2",tW[tW.UV3=512]="UV3",tW[tW.UV4=1024]="UV4",tW[tW.UV5=2048]="UV5",tW[tW.UV6=4096]="UV6",tW[tW.UV7=8192]="UV7",tW[tW.All=65535]="All";var cA=(la(tX=function(e){var t;return(t=lp.call(this,null)||this).name=e,t.inverseBindMatrices=[],t.joints=[],t.skeleton="none",t},lp),tX),cE=(tj=e.Renderer,la(tK=function(e){var t;return(t=tj.call(this,e)||this)._enableVertexColor=!1,t._onMeshChanged=t._onMeshChanged.bind(lt(t)),t},tj),(tq=tK.prototype)._onDestroy=function(){tj.prototype._onDestroy.call(this);var e=this._mesh;e&&(e.destroyed||e._addReferCount(-1),e._updateFlagManager.removeListener(this._onMeshChanged),this._mesh=null)},tq._prepareRender=function(e){if(!this._mesh){lw.error("mesh is null.");return}tj.prototype._prepareRender.call(this,e)},tq._cloneTo=function(e){tj.prototype._cloneTo.call(this,e),e.mesh=this._mesh},tq._updateBounds=function(e){var t=this._mesh;if(t){var n=t.bounds,r=this._entity.transform.worldMatrix;sZ.transform(n,r,e)}else e.min.set(0,0,0),e.max.set(0,0,0)},tq._render=function(e){var t=this._mesh;if(2&this._dirtyUpdateFlag){var n=this.shaderData,r=t._vertexElements;n.disableMacro(tK._uvMacro),n.disableMacro(tK._uv1Macro),n.disableMacro(tK._normalMacro),n.disableMacro(tK._tangentMacro),n.disableMacro(tK._enableVertexColorMacro);for(var i=0,a=r.length;i<a;i++)switch(r[i].semantic){case"TEXCOORD_0":n.enableMacro(tK._uvMacro);break;case"TEXCOORD_1":n.enableMacro(tK._uv1Macro);break;case"NORMAL":n.enableMacro(tK._normalMacro);break;case"TANGENT":n.enableMacro(tK._tangentMacro);break;case"COLOR_0":this._enableVertexColor&&n.enableMacro(tK._enableVertexColorMacro)}this._dirtyUpdateFlag&=-3}for(var o=this._materials,s=t.subMeshes,l=e.camera._renderPipeline,c=this._engine._meshRenderDataPool,u=0,h=s.length;u<h;u++){var d=o[u];if(d){var _=c.getFromPool();_.set(this,d,t,s[u]),l.pushRenderData(e,_)}}},tq._setMesh=function(e){var t=this._mesh;t&&(t._addReferCount(-1),t._updateFlagManager.removeListener(this._onMeshChanged)),e&&(e._addReferCount(1),e._updateFlagManager.addListener(this._onMeshChanged),this._dirtyUpdateFlag|=3),this._mesh=e},tq._onMeshChanged=function(e){e&sh.Bounds&&(this._dirtyUpdateFlag|=ss.WorldVolume),e&sh.VertexElements&&(this._dirtyUpdateFlag|=2)},lr(tK,[{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)}}]),tK);cE._uvMacro=l0.getByName("RENDERER_HAS_UV"),cE._uv1Macro=l0.getByName("RENDERER_HAS_UV1"),cE._normalMacro=l0.getByName("RENDERER_HAS_NORMAL"),cE._tangentMacro=l0.getByName("RENDERER_HAS_TANGENT"),cE._enableVertexColorMacro=l0.getByName("RENDERER_ENABLE_VERTEXCOLOR"),ll([lu],cE.prototype,"_mesh",void 0),ll([lu],cE.prototype,"_onMeshChanged",null),(tY=sf||(sf={}))[tY.VertexElementMacro=2]="VertexElementMacro",tY[tY.All=3]="All";var cM=(la(tQ=function(e){(t=cE.call(this,e)||this)._hasInitSkin=!1,t._jointDataCreateCache=new s8(-1,-1),t._localBounds=new sZ,t._skin=null;var t,n=t.entity.engine._hardwareRenderer,r=n.renderStates.getParameter(n.gl.MAX_VERTEX_UNIFORM_VECTORS);r=Math.min(r,n._options._maxAllowSkinUniformVectorCount),t._maxVertexUniformVectors=r,t._onLocalBoundsChanged=t._onLocalBoundsChanged.bind(lt(t));var i=t._localBounds;return i.min._onValueChanged=t._onLocalBoundsChanged,i.max._onValueChanged=t._onLocalBoundsChanged,t},cE),(tJ=tQ.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)}},tJ._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 lM(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(tQ._jointSamplerProperty,this._jointTexture)):lw.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(tQ._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)},tJ._onDestroy=function(){var e,t;cE.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)},tJ._cloneTo=function(e){cE.prototype._cloneTo.call(this,e),this._blendShapeWeights&&(e._blendShapeWeights=this._blendShapeWeights.slice())},tJ._registerEntityTransformListener=function(){},tJ._updateBounds=function(e){if(this._rootBone){var t=this._localBounds,n=this._rootBone.transform.worldMatrix;sZ.transform(t,n,e)}else cE.prototype._updateBounds.call(this,e)},tJ._initSkin=function(){if(this.entity.engine._hardwareRenderer){var e=this._skin,t=this.shaderData;if(!e){t.disableMacro("RENDERER_HAS_SKIN");return}for(var n=e.joints,r=n.length,i=Array(r),a=r-1;a>=0;a--)i[a]=this._findByEntityName(this.entity,n[a]);this._jointEntities=i,this._jointMatrices=new Float32Array(16*r);var o=this._rootBone,s=this._findByEntityName(this.entity,e.skeleton);o&&o.transform._updateFlagManager.removeListener(this._onTransformChanged),s.transform._updateFlagManager.addListener(this._onTransformChanged);var l=n.indexOf(e.skeleton);if(-1!==l)sZ.transform(this._mesh.bounds,e.inverseBindMatrices[l],this._localBounds);else{var c=new s4(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?(s4.multiplyScalar(c,1/u,c),sZ.transform(this._mesh.bounds,c,this._localBounds)):this._localBounds.copyFrom(this._mesh.bounds)}this._rootBone=s,r?(t.enableMacro("RENDERER_HAS_SKIN"),t.setInt(tQ._jointCountProperty,r)):t.disableMacro("RENDERER_HAS_SKIN")}},tJ._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?(s4.add(r,t[c],r),i++):i+=this._computeApproximateBindMatrix(e,t,l,r)}return i},tJ._findByEntityName=function(e,t){return e?e.findByName(t)||this._findByEntityName(e.parent,t):null},tJ._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)},tJ._onLocalBoundsChanged=function(){this._dirtyUpdateFlag|=ss.WorldVolume},lr(tQ,[{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|=ss.WorldVolume}}]),tQ);cM._jointCountProperty=lV.getByName("renderer_JointCount"),cM._jointSamplerProperty=lV.getByName("renderer_JointSampler"),cM._jointMatrixProperty=lV.getByName("renderer_JointMatrix"),ll([lu],cM.prototype,"_hasInitSkin",void 0),ll([lu],cM.prototype,"_jointDataCreateCache",void 0),ll([lu],cM.prototype,"_blendShapeWeights",void 0),ll([lu],cM.prototype,"_maxVertexUniformVectors",void 0),ll([lu],cM.prototype,"_rootBone",void 0),ll([lu],cM.prototype,"_localBounds",void 0),ll([lu],cM.prototype,"_jointMatrices",void 0),ll([lu],cM.prototype,"_jointTexture",void 0),ll([lu],cM.prototype,"_jointEntities",void 0),ll([lu],cM.prototype,"_condensedBlendShapeWeights",void 0),ll([lu],cM.prototype,"_onLocalBoundsChanged",null);var cb=(la(tZ=function(e,t){var n;return(n=lm.call(this,e)||this).primitiveInfo=t,n},lm),tZ.prototype.restoreContent=function(){var e=this.primitiveInfo;switch(e.type){case 0:cV._setSphereData(this.resource,e.radius,e.segments,e.noLongerAccessible,!0);break;case 1:cV._setCuboidData(this.resource,e.width,e.height,e.depth,e.noLongerAccessible,!0);break;case 2:cV._setPlaneData(this.resource,e.width,e.height,e.horizontalSegments,e.verticalSegments,e.noLongerAccessible,!0);break;case 3:cV._setCylinderData(this.resource,e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 4:cV._setTorusData(this.resource,e.radius,e.tubeRadius,e.radialSegments,e.tubularSegments,e.arc,e.noLongerAccessible,!0);break;case 5:cV._setConeData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0);break;case 6:cV._setCapsuleData(this.resource,e.radius,e.height,e.radialSegments,e.heightSegments,e.noLongerAccessible,!0)}},tZ);(t$=sp||(sp={}))[t$.Sphere=0]="Sphere",t$[t$.Cuboid=1]="Cuboid",t$[t$.Plane=2]="Plane",t$[t$.Cylinder=3]="Cylinder",t$[t$.Torus=4]="Torus",t$[t$.Cone=5]="Cone",t$[t$.Capsule=6]="Capsule";var cR=function(e,t){this.type=e,this.noLongerAccessible=t},cF=(la(t0=function(e,t,n){var r;return(r=cR.call(this,0,n)||this).radius=e,r.segments=t,r},cR),t0),cP=(la(t1=function(e,t,n,r){var i;return(i=cR.call(this,1,r)||this).width=e,i.height=t,i.depth=n,i},cR),t1),cL=(la(t2=function(e,t,n,r,i){var a;return(a=cR.call(this,2,i)||this).width=e,a.height=t,a.horizontalSegments=n,a.verticalSegments=r,a},cR),t2),cD=(la(t3=function(e,t,n,r,i,a){var o;return(o=cR.call(this,3,a)||this).radiusTop=e,o.radiusBottom=t,o.height=n,o.radialSegments=r,o.heightSegments=i,o},cR),t3),cI=(la(t4=function(e,t,n,r,i,a){var o;return(o=cR.call(this,4,a)||this).radius=e,o.tubeRadius=t,o.radialSegments=n,o.tubularSegments=r,o.arc=i,o},cR),t4),cB=(la(t5=function(e,t,n,r,i){var a;return(a=cR.call(this,5,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},cR),t5),cN=(la(t8=function(e,t,n,r,i){var a;return(a=cR.call(this,6,i)||this).radius=e,a.height=t,a.radialSegments=n,a.heightSegments=r,a},cR),t8),cV=((t6=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 cw(e);return t6._setSphereData(i,t,n,r,!1),e.resourceManager.addContentRestorer(new cb(i,new cF(t,n,r))),i},t6.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 cw(e);return t6._setCuboidData(a,t,n,r,i,!1),e.resourceManager.addContentRestorer(new cb(a,new cP(t,n,r,i))),a},t6.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 cw(e);return t6._setPlaneData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cb(o,new cL(t,n,r,i,a))),o},t6.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 cw(e);return t6._setCylinderData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new cb(s,new cD(t,n,r,i,a,o))),s},t6.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 cw(e);return t6._setTorusData(s,t,n,r,i,a,o,!1),e.resourceManager.addContentRestorer(new cb(s,new cI(t,n,r,i,a,o))),s},t6.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 cw(e);return t6._setConeData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cb(o,new cB(t,n,r,i,a))),o},t6.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 cw(e);return t6._setCapsuleData(o,t,n,r,i,a,!1),e.resourceManager.addContentRestorer(new cb(o,new cN(t,n,r,i,a))),o},t6._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=t6._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,C=Math.sin(x),T=-t*Math.cos(y)*C,S=t*Math.cos(x),w=t*Math.sin(y)*C;_[g]=new sQ(T,S,w),f[g]=new sQ(T,S,w),p[g]=new s8(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)}t6._initialize(e,_,f,p,l,r,i)},t6._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 sQ(-o,s,-l),c[1]=new sQ(o,s,-l),c[2]=new sQ(o,s,l),c[3]=new sQ(-o,s,l),u[0]=new sQ(0,1,0),u[1]=new sQ(0,1,0),u[2]=new sQ(0,1,0),u[3]=new sQ(0,1,0),h[0]=new s8(0,0),h[1]=new s8(1,0),h[2]=new s8(1,1),h[3]=new s8(0,1),c[4]=new sQ(-o,-s,-l),c[5]=new sQ(o,-s,-l),c[6]=new sQ(o,-s,l),c[7]=new sQ(-o,-s,l),u[4]=new sQ(0,-1,0),u[5]=new sQ(0,-1,0),u[6]=new sQ(0,-1,0),u[7]=new sQ(0,-1,0),h[4]=new s8(0,1),h[5]=new s8(1,1),h[6]=new s8(1,0),h[7]=new s8(0,0),c[8]=new sQ(-o,s,-l),c[9]=new sQ(-o,s,l),c[10]=new sQ(-o,-s,l),c[11]=new sQ(-o,-s,-l),u[8]=new sQ(-1,0,0),u[9]=new sQ(-1,0,0),u[10]=new sQ(-1,0,0),u[11]=new sQ(-1,0,0),h[8]=new s8(0,0),h[9]=new s8(1,0),h[10]=new s8(1,1),h[11]=new s8(0,1),c[12]=new sQ(o,s,-l),c[13]=new sQ(o,s,l),c[14]=new sQ(o,-s,l),c[15]=new sQ(o,-s,-l),u[12]=new sQ(1,0,0),u[13]=new sQ(1,0,0),u[14]=new sQ(1,0,0),u[15]=new sQ(1,0,0),h[12]=new s8(1,0),h[13]=new s8(0,0),h[14]=new s8(0,1),h[15]=new s8(1,1),c[16]=new sQ(-o,s,l),c[17]=new sQ(o,s,l),c[18]=new sQ(o,-s,l),c[19]=new sQ(-o,-s,l),u[16]=new sQ(0,0,1),u[17]=new sQ(0,0,1),u[18]=new sQ(0,0,1),u[19]=new sQ(0,0,1),h[16]=new s8(0,0),h[17]=new s8(1,0),h[18]=new s8(1,1),h[19]=new s8(0,1),c[20]=new sQ(-o,s,-l),c[21]=new sQ(o,s,-l),c[22]=new sQ(o,-s,-l),c[23]=new sQ(-o,-s,-l),u[20]=new sQ(0,0,-1),u[21]=new sQ(0,0,-1),u[22]=new sQ(0,0,-1),u[23]=new sQ(0,0,-1),h[20]=new s8(1,0),h[21]=new s8(0,0),h[22]=new s8(0,1),h[23]=new s8(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)}t6._initialize(e,c,u,h,d,i,a)},t6._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=t6._generateIndices(e.engine,_,6*f),g=1/s,m=1/r,v=1/i,y=Array(_),x=Array(_),C=Array(_),T=0;T<_;++T){var S=T%s,w=T*g|0;y[T]=new sQ(S*h-c,0,w*d-u),x[T]=new sQ(0,1,0),C[T]=new s8(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)}t6._initialize(e,y,x,C,p,a,o)},t6._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=t6._generateIndices(e.engine,p,6*_+3*f),m=1/l,v=1/i,y=1/a,x=Array(p),C=Array(p),T=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 sQ(O,U,z),C[R]=new sQ(B,M,N),T[R]=new s8(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,j=X+1;g[S++]=W,g[S++]=X,g[S++]=H,g[S++]=W,g[S++]=j,g[S++]=X}x[d]=new sQ(0,-u,0),C[d]=new sQ(0,-1,0),T[d]=new s8(.5,.5),x[d+1]=new sQ(0,u,0),C[d+1]=new sQ(0,1,0),T[d+1]=new s8(.5,.5);for(var K=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[K]=new sQ($,-u,ee),C[K]=new sQ(0,-1,0),T[K++]=new s8($*Y+.5,.5-ee*Y);var et=x[J+Q];$=et.x,ee=et.z,x[K]=new sQ($,u,ee),C[K]=new sQ(0,1,0),T[K++]=new s8($*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)}t6._initialize(e,x,C,T,g,o,s)},t6._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=t6._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),C=Math.cos(m),T=Math.sin(m),S=new sQ((t+n*y)*C,(t+n*y)*T,n*x);h[f]=S;var w=t*C,A=t*T;d[f]=new sQ(S.x-w,S.y-A,S.z).normalize(),_[f++]=new s8(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)}t6._initialize(e,h,d,_,u,o,s)},t6._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=t6._generateIndices(e.engine,_,6*d+3*r),p=1/s,g=1/r,m=1/i,v=Array(_),y=Array(_),x=Array(_),C=0,T=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=T+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 sQ(I,B,N),y[A]=new sQ(P,w,L),x[A]=new s8(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[C++]=z,f[C++]=k,f[C++]=U,f[C++]=z,f[C++]=G,f[C++]=k}v[h]=new sQ(0,-c,0),y[h]=new sQ(0,-1,0),x[h]=new s8(.5,.5);for(var H=h+1,W=1/(2*t),X=0;X<r;++X){var j=v[X],K=j.x,q=j.z;v[H]=new sQ(K,-c,q),y[H]=new sQ(0,-1,0),x[H++]=new s8(K*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[C++]=h,f[C++]=Y+Z,f[C++]=Y+J}if(!o){var $=e.bounds;$.min.set(-t,-c,-t),$.max.set(t,c,t)}t6._initialize(e,v,y,x,f,a,o)},t6._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=t6._generateIndices(e.engine,p,(d+2*f)*6),m=1/s,v=1/r,y=1/i,x=Math.PI,C=2*Math.PI,T=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*C,L=Math.sin(P),D=Math.cos(P);T[E]=new sQ(t*L,b*u-c,t*D),S[E]=new sQ(L,0,D),w[E]=new s8(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(t6._createCapsuleCap(t,n,r,C,h,1,T,S,w,g,A),t6._createCapsuleCap(t,n,r,-C,h+_,-1,T,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)}t6._initialize(e,T,S,w,g,a,o)},t6._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)},t6._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},t6._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,C=y*Math.PI/2,T=Math.sin(C),S=-e*Math.cos(x)*T,w=e*Math.cos(C)*a+d,A=e*Math.sin(x)*T,E=m+i;o[E]=new sQ(S,w,A),s[E]=new sQ(S,w-d,A),l[E]=new s8(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}},t6),cO=(la(t7=function(){return cC.apply(this,arguments)},cC),(t9=t7.prototype).setVertexElements=function(e){this._setVertexElements(e)},t9.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 cT(e,t));var a=this._vertexBufferBindings;a.length<=n&&(a.length=n+1),this._setVertexBufferBinding(i?t:n,r)},t9.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])},t9.setIndexBufferBinding=function(e,t){var n=e;n&&(void 0!==n.buffer||(n=new cy(e,t))),this._setIndexBufferBinding(n)},lr(t7,[{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}}]),t7),cU=((ne=function(e,t,n,r){if(void 0===n&&(n=null),void 0===r&&(r=null),this._dataChangeManager=new lK,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},lr(ne,[{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)}}]),ne);(nt=sg||(sg={}))[nt.Position=1]="Position",nt[nt.Normal=2]="Normal",nt[nt.Tangent=4]="Tangent",nt[nt.All=7]="All";var cz=((nr=(nn=function(e){this._useBlendShapeNormal=!0,this._useBlendShapeTangent=!0,this._layoutChangeManager=new lK,this._dataChangeManager=new lK,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 cU(e,t,n,r);return this._addFrame(i),i}this._addFrame(e)},nr.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()},nr._releaseData=function(){for(var e=this._frames,t=0,n=e.length;t<n;t++)e[t]._releaseData()},nr._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(sg.All,e),e._dataChangeManager.addListener(this._frameDataChangeListener)},nr._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))},nr._frameDataChangeListener=function(e,t){this._updateUseNormalAndTangent(!!t.deltaNormals,!!t.deltaTangents),this._dataChangeManager.dispatch()},lr(nn,[{key:"frames",get:function(){return this._frames}}]),nn),ck=((na=(ni=function(e){this._subMeshPool=new lJ(cx),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)},na._initMeshes=function(e){var t=ni.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)},na.flush=function(e){var t=this._batchedQueue;0!==t.length&&(this._updateData(this._engine),this.drawBatches(e),!ni._canUploadSameBuffer&&this._flushId++,t.length=0,this._subMeshPool.resetPool(),this._vertexCount=0,this._elementCount=0)},na.clear=function(){this._flushId=0,this._vertexCount=0,this._elementCount=0,this._batchedQueue.length=0},na.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},na._drawSubElement=function(e,t){var n=e.data.verticesData.vertexCount;this._vertexCount+n>ni.MAX_VERTEX_COUNT&&this.flush(t),this._vertexCount+=n,this._batchedQueue[this._elementCount++]=e},na._createMesh=function(t,n){var r=ni.MAX_VERTEX_COUNT,i=new cO(t,"BufferMesh"+n);i.isGCIgnored=!0;var a=[],o=this.createVertexElements(a),s=this._vertexBuffers[n]=new cv(t,e.BufferBindFlag.VertexBuffer,r*o,e.BufferUsage.Dynamic);s.isGCIgnored=!0;var l=this._indiceBuffers[n]=new cv(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},na._updateData=function(e){var t=this._meshes,n=this._flushId;!ni._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)},na._getSubMeshFromPool=function(t,n){var r=this._subMeshPool.getFromPool();return r.start=t,r.count=n,r.topology=e.MeshTopology.Triangles,r},ni);ck._disableBatchTag=l5.getByName("spriteDisableBatching"),ck.MAX_VERTEX_COUNT=4096,ck._canUploadSameBuffer=!0;var cG=(la(no=function(){return ck.apply(this,arguments)},ck),(ns=no.prototype).createVertexElements=function(t){return t[0]=new cm("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cm("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),20},ns.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=cp._textureProperty,s=cp._alphaCutoffProperty;return i.getTexture(o)===a.getTexture(o)&&i.getTexture(s)===a.getTexture(s)},ns.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},ns.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=cn._compileMacros;l1.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)}},no),cH=((nc=(nl=function(e){this._preMaskLayer=0,this._batcher=new cG(e)}).prototype).clear=function(){this._preMaskLayer=0,this._batcher.clear()},nc.preRender=function(t,n){n.maskInteraction!==e.SpriteMaskInteraction.None&&(this._batcher.clear(),this._processMasksDiff(t,n),this._batcher.flush(t))},nc.postRender=function(t){t.maskInteraction!==e.SpriteMaskInteraction.None&&(this._preMaskLayer=t.maskLayer)},nc.destroy=function(){this._batcher.destroy(),this._batcher=null},nc._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)}}}},nl),cW=(la(nu=function(){var e;return(e=lZ.call(this)||this).isAdd=!0,e.multiRenderData=!1,e},lZ),(nh=nu.prototype).set=function(e,t,n){this.component=e,this.material=t,this.verticesData=n},nh.dispose=function(){this.component=this.material=this.verticesData=null},nu),cX=(la(nd=function(){var e;return(e=lZ.call(this)||this).multiRenderData=!1,e},lZ),(n_=nd.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},n_.dispose=function(){this.component=this.material=this.verticesData=this.texture=null},nd),cj=(la(nf=function(){var e;return(e=lZ.call(this)||this).charsData=[],e.multiRenderData=!0,e},lZ),nf.prototype.dispose=function(){this.component=this.material=null,this.charsData.length=0},nf);e.BackgroundMode=void 0,(np=e.BackgroundMode||(e.BackgroundMode={}))[np.SolidColor=0]="SolidColor",np[np.Sky=1]="Sky",np[np.Texture=2]="Texture",e.BackgroundTextureFillMode=void 0,(ng=e.BackgroundTextureFillMode||(e.BackgroundTextureFillMode={}))[ng.AspectFitWidth=0]="AspectFitWidth",ng[ng.AspectFitHeight=1]="AspectFitHeight",ng[ng.Fill=2]="Fill";var cK=((nv=(nm=function(){}).prototype).destroy=function(){this.mesh=null,this.material=null},nv._render=function(e){var t=this.material,n=this.mesh;if(!t){lw.warn("The material of sky is not defined.");return}if(!n){lw.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=nm._viewProjMatrix,h=nm._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(sY.degreeToRadian(o)/2);h.elements[0]=m/a,h.elements[5]=m,s4.multiply(h,u,u);var v=l.getMatrix(cu.vpMatrixProperty);l.setMatrix(cu.vpMatrixProperty,u);var y=cn._compileMacros;l1.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(cu.vpMatrixProperty,v)},lr(nm,[{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}}}]),nm);cK._epsilon=1e-6,cK._viewProjMatrix=new s4,cK._projectionMatrix=new s4(1,0,0,0,0,1,0,0,0,0,cK._epsilon-1,-1,0,0,0,0);var cq=((nx=(ny=function(t){this._engine=t,this.mode=e.BackgroundMode.SolidColor,this.solidColor=new s7(.25,.25,.25,1),this.sky=new cK,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()},nx._initMesh=function(e){this._mesh=this._createPlane(e),this._mesh._addReferCount(1)},nx._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)}},nx._createPlane=function(e){var t=new cw(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 sQ,i[a]=new s8(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},lr(ny,[{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())}}]),ny);e.FogMode=void 0,(nC=e.FogMode||(e.FogMode={}))[nC.None=0]="None",nC[nC.Linear=1]="Linear",nC[nC.Exponential=2]="Exponential",nC[nC.ExponentialSquared=3]="ExponentialSquared",e.DiffuseMode=void 0,(nT=e.DiffuseMode||(e.DiffuseMode={}))[nT.SolidColor=0]="SolidColor",nT[nT.SphericalHarmonics=1]="SphericalHarmonics";var cY=(la(nS=function(t){var n;return(n=lg.call(this,t)||this)._diffuseSolidColor=new s7(.212,.227,.259),n._diffuseIntensity=1,n._specularIntensity=1,n._diffuseMode=e.DiffuseMode.SolidColor,n._shArray=new Float32Array(27),n._scenes=[],n._specularTextureDecodeRGBM=!1,n},lg),(nw=nS.prototype)._addToScene=function(e){this._addReferCount(1),this._scenes.push(e);var t=e.shaderData;t.setColor(nS._diffuseColorProperty,this._diffuseSolidColor),t.setFloat(nS._diffuseIntensityProperty,this._diffuseIntensity),t.setFloat(nS._specularIntensityProperty,this._specularIntensity),t.setFloatArray(nS._diffuseSHProperty,this._shArray),this._setDiffuseMode(t),this._setSpecularTextureDecodeRGBM(t),this._setSpecularTexture(t)},nw._removeFromScene=function(e){this._addReferCount(-1);var t=this._scenes,n=t.indexOf(e);t.splice(n,1);var r=e.shaderData;r.setTexture(nS._specularTextureProperty,null),r.disableMacro(nS._specularMacro)},nw._setDiffuseMode=function(t){this._diffuseMode===e.DiffuseMode.SphericalHarmonics?t.enableMacro(nS._shMacro):t.disableMacro(nS._shMacro)},nw._setSpecularTexture=function(e){this._specularTexture?(e.setTexture(nS._specularTextureProperty,this._specularTexture),e.setFloat(nS._mipLevelProperty,this._specularTexture.mipmapCount-1),e.enableMacro(nS._specularMacro)):e.disableMacro(nS._specularMacro)},nw._setSpecularTextureDecodeRGBM=function(e){this._specularTextureDecodeRGBM?e.enableMacro(nS._decodeRGBMMacro):e.disableMacro(nS._decodeRGBMMacro)},nw._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]},lr(nS,[{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(nS._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(nS._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(nS._specularIntensityProperty,e)}}]),nS);cY._shMacro=l0.getByName("SCENE_USE_SH"),cY._specularMacro=l0.getByName("SCENE_USE_SPECULAR_ENV"),cY._decodeRGBMMacro=l0.getByName("SCENE_IS_DECODE_ENV_RGBM"),cY._diffuseColorProperty=lV.getByName("scene_EnvMapLight.diffuse"),cY._diffuseSHProperty=lV.getByName("scene_EnvSH"),cY._diffuseIntensityProperty=lV.getByName("scene_EnvMapLight.diffuseIntensity"),cY._specularTextureProperty=lV.getByName("scene_EnvSpecularSampler"),cY._specularIntensityProperty=lV.getByName("scene_EnvMapLight.specularIntensity"),cY._mipLevelProperty=lV.getByName("scene_EnvMapLight.mipMapLevel"),e.ShadowCascadesMode=void 0,(nA=e.ShadowCascadesMode||(e.ShadowCascadesMode={}))[nA.NoCascades=1]="NoCascades",nA[nA.TwoCascades=2]="TwoCascades",nA[nA.FourCascades=4]="FourCascades",e.ShadowResolution=void 0,(nE=e.ShadowResolution||(e.ShadowResolution={}))[nE.Low=0]="Low",nE[nE.Medium=1]="Medium",nE[nE.High=2]="High",nE[nE.VeryHigh=3]="VeryHigh",e.ShadowType=void 0,(nM=e.ShadowType||(e.ShadowType={}))[nM.None=0]="None",nM[nM.Hard=1]="Hard",nM[nM.SoftLow=2]="SoftLow",nM[nM.SoftHigh=3]="SoftHigh";var cQ=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 sQ(1/15,.2,7/15),a.shadowDistance=50,a._activeCameras=[],a._isActiveInEngine=!1,a._globalShaderMacro=new l1,a._rootEntities=[],a._background=new cq(a._engine),a._shaderData=new cr(sa.Scene),a._shadowCascades=e.ShadowCascadesMode.NoCascades,a._fogMode=e.FogMode.None,a._fogColor=new s7(.5,.5,.5,1),a._fogStart=0,a._fogEnd=300,a._fogDensity=.01,a._fogParams=new s6,a.name=i||"";var a,o=a.shaderData;return o._addReferCount(1),a.ambientLight=new cY(r),r.sceneManager._allScenes.push(lt(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}la(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){t.prototype.destroy.call(this),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):lw.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;if(r.time._updateSceneShaderData(t),i._updateShaderData(this.shaderData),i._updateSunLightIndex(),i._directLights.length>0){var a=i._directLights.get(0);t.setColor(n._sunlightColorProperty,a._getLightIntensityColor()),t.setVector3(n._sunlightDirectionProperty,a.direction),this._sunLight=a}else this._sunLight=null;this.castShadows&&this._sunLight&&this._sunLight.shadowType!==e.ShadowType.None?t.enableMacro("SCENE_SHADOW_TYPE",this._sunLight.shadowType.toString()):t.disableMacro("SCENE_SHADOW_TYPE"),l1.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._ambientLight&&this._ambientLight._removeFromScene(this),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)},lr(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){lw.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}(lp);cQ._fogColorProperty=lV.getByName("scene_FogColor"),cQ._fogParamsProperty=lV.getByName("scene_FogParams"),cQ._sunlightColorProperty=lV.getByName("scene_SunlightColor"),cQ._sunlightDirectionProperty=lV.getByName("scene_SunlightDirection");var cJ=((nR=(nb=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},nR.mergeScenes=function(e,t){for(var n=e.rootEntities,r=0,i=n.length;r<i;r++)t.addRootEntity(n[r])},nR._destroyAllScene=function(){for(var e=this._allScenes;e[0];)e[0].destroy()},lr(nb,[{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)}}]),nb),cZ=((nP=(nF=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},nP.then=function(e,t){var n=this;return new nF(function(r,i){n._promise.then(e,t).then(r).catch(i)})},nP.catch=function(e){var t=this;return new nF(function(n,r){t._promise.catch(e).then(n).catch(r)})},nP.finally=function(e){return this._promise.finally(e)},nP.cancel=function(){if("pending"===this._state)return this._state="canceled",this._reject("canceled"),this._onCancelHandler&&this._onCancelHandler(),this},nF.all=function(e){return new nF(function(t,n,r){var i=function(e,n){l++,s[e]=n,r(l/o),l===o&&t(s)},a=function(e,t){lc(e,Promise)||lc(e,nF)?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)})},lr(nF,[{key:Symbol.toStringTag,get:function(){return"AssetPromise"}}]),nF);(nL=sm||(sm={})).Pending="pending",nL.Fulfilled="fulfilled",nL.Rejected="rejected",nL.Canceled="canceled";var c$=((nI=(nD=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 cZ.all(n)},nI.getFromCache=function(e){var t;return null!=(t=this._assetUrlPool[e])?t:null},nI.getAssetPath=function(e){return this._assetPool[e]},nI.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()})},nI.gc=function(){this._gc(!1),this.engine._pendingGC()},nI.addContentRestorer=function(e){this._contentRestorerPool[e.resource.instanceId]=e},nI._addAsset=function(e,t){this._assetPool[t.instanceId]=e,this._assetUrlPool[e]=t},nI._deleteAsset=function(e){var t=e.instanceId,n=this._assetPool[t];n&&(delete this._assetPool[t],delete this._assetUrlPool[n])},nI._addReferResource=function(e){this._referResourcePool[e.instanceId]=e},nI._deleteReferResource=function(e){delete this._referResourcePool[e.instanceId]},nI._addGraphicResource=function(e){this._graphicResourcePool[e.instanceId]=e},nI._deleteGraphicResource=function(e){delete this._graphicResourcePool[e.instanceId]},nI._deleteContentRestorer=function(e){delete this._contentRestorerPool[e.instanceId]},nI._restoreGraphicResources=function(){var e=this._graphicResourcePool;for(var t in e)e[t]._rebuild()},nI._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)},nI._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},nI._assignDefaultOptions=function(e){var t,n,r,i,a;if(e.type=null!=(t=e.type)?t:nD._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},nI._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 cZ(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 cZ(function(e,n){d.then(function(n){e(t._getResolveResource(n,l))}).catch(function(e){n(e)})});var _=nD._loaders[n.type];if(!_)throw"loader not found: "+n.type;n.url=o;var f=_.load(n,this);if(lc(f,cZ))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)})},nI._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()},nI._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},nI._parseURL=function(e){var t=e,n=t.indexOf("?");return -1!==n&&(t=t.slice(0,n)),{assetBaseURL:t,queryPath:this._getParameterByName("q",e)}},nI._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},nI._parseQueryPath=function(e){var t=[];return e.charCodeAt(0)===c1&&t.push(""),e.replace(c3,function(e,n,r,i){var a=e;r?a=i.replace(c2,"$1"):n&&(a=n.trim()),t.push(a)}),t},nI.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 lw.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})},nI.initVirtualResources=function(e){var t=this;e.forEach(function(e){t._virtualPathMap[e.virtualPath]=e.path,t._editorResourceConfig[e.id]=e})},nD._addLoader=function(e,t,n){this._loaders[e]=t;for(var r=0,i=n.length;r<i;r++)this._extTypeMapping[n[r]]=e},nD._getTypeByUrl=function(e){var t=e.split("?")[0];return this._extTypeMapping[t.substring(t.lastIndexOf(".")+1)]},nD);function c0(e,t,n){return void 0===n&&(n=!0),function(r){var i=new r(n);c$._addLoader(e,i,t)}}c$._loaders={},c$._extTypeMapping={};var c1=46,c2=/\\(\\)?/g,c3=RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");e.PointerPhase=void 0,(nB=e.PointerPhase||(e.PointerPhase={}))[nB.Down=0]="Down",nB[nB.Move=1]="Move",nB[nB.Stationary=2]="Stationary",nB[nB.Up=3]="Up",nB[nB.Leave=4]="Leave";var c4=((nV=(nN=function(t){this.phase=e.PointerPhase.Leave,this.position=new s8,this.deltaPosition=new s8,this._events=[],this._upMap=[],this._downMap=[],this._upList=new lI,this._downList=new lI,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}},nV._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},nV._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)}},nV._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}},nN),c5=((nO=function(){})._initialize=function(){if("undefined"!=typeof navigator){var t,n=navigator.userAgent;switch(/iPhone/i.test(n)?nO.platform=e.Platform.IPhone:/iPad/i.test(n)?nO.platform=e.Platform.IPad:/Android/i.test(n)?nO.platform=e.Platform.Android:/Macintosh/i.test(n)&&(nO.platform=e.Platform.Mac),nO.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"}}},lr(nO,null,[{key:"devicePixelRatio",get:function(){return window.devicePixelRatio}}]),nO);c5.platform=e.Platform.Unknown,c5.operatingSystem="",c5._initialize(),e.Keys=void 0,(nU=e.Keys||(e.Keys={}))[nU.Backquote=0]="Backquote",nU[nU.Backslash=1]="Backslash",nU[nU.Backspace=2]="Backspace",nU[nU.BracketLeft=3]="BracketLeft",nU[nU.BracketRight=4]="BracketRight",nU[nU.Comma=5]="Comma",nU[nU.Digit0=6]="Digit0",nU[nU.Digit1=7]="Digit1",nU[nU.Digit2=8]="Digit2",nU[nU.Digit3=9]="Digit3",nU[nU.Digit4=10]="Digit4",nU[nU.Digit5=11]="Digit5",nU[nU.Digit6=12]="Digit6",nU[nU.Digit7=13]="Digit7",nU[nU.Digit8=14]="Digit8",nU[nU.Digit9=15]="Digit9",nU[nU.Equal=16]="Equal",nU[nU.IntlBackslash=17]="IntlBackslash",nU[nU.IntlRo=18]="IntlRo",nU[nU.IntlYen=19]="IntlYen",nU[nU.KeyA=20]="KeyA",nU[nU.KeyB=21]="KeyB",nU[nU.KeyC=22]="KeyC",nU[nU.KeyD=23]="KeyD",nU[nU.KeyE=24]="KeyE",nU[nU.KeyF=25]="KeyF",nU[nU.KeyG=26]="KeyG",nU[nU.KeyH=27]="KeyH",nU[nU.KeyI=28]="KeyI",nU[nU.KeyJ=29]="KeyJ",nU[nU.KeyK=30]="KeyK",nU[nU.KeyL=31]="KeyL",nU[nU.KeyM=32]="KeyM",nU[nU.KeyN=33]="KeyN",nU[nU.KeyO=34]="KeyO",nU[nU.KeyP=35]="KeyP",nU[nU.KeyQ=36]="KeyQ",nU[nU.KeyR=37]="KeyR",nU[nU.KeyS=38]="KeyS",nU[nU.KeyT=39]="KeyT",nU[nU.KeyU=40]="KeyU",nU[nU.KeyV=41]="KeyV",nU[nU.KeyW=42]="KeyW",nU[nU.KeyX=43]="KeyX",nU[nU.KeyY=44]="KeyY",nU[nU.KeyZ=45]="KeyZ",nU[nU.Minus=46]="Minus",nU[nU.Period=47]="Period",nU[nU.Quote=48]="Quote",nU[nU.Semicolon=49]="Semicolon",nU[nU.Slash=50]="Slash",nU[nU.AltLeft=51]="AltLeft",nU[nU.AltRight=52]="AltRight",nU[nU.CapsLock=53]="CapsLock",nU[nU.ContextMenu=54]="ContextMenu",nU[nU.ControlLeft=55]="ControlLeft",nU[nU.ControlRight=56]="ControlRight",nU[nU.Enter=57]="Enter",nU[nU.MetaLeft=58]="MetaLeft",nU[nU.MetaRight=59]="MetaRight",nU[nU.ShiftLeft=60]="ShiftLeft",nU[nU.ShiftRight=61]="ShiftRight",nU[nU.Space=62]="Space",nU[nU.Tab=63]="Tab",nU[nU.Convert=64]="Convert",nU[nU.KanaMode=65]="KanaMode",nU[nU.Lang1=66]="Lang1",nU[nU.Lang2=67]="Lang2",nU[nU.Lang3=68]="Lang3",nU[nU.Lang4=69]="Lang4",nU[nU.Lang5=70]="Lang5",nU[nU.NonConvert=71]="NonConvert",nU[nU.Delete=72]="Delete",nU[nU.End=73]="End",nU[nU.Help=74]="Help",nU[nU.Home=75]="Home",nU[nU.Insert=76]="Insert",nU[nU.PageDown=77]="PageDown",nU[nU.PageUp=78]="PageUp",nU[nU.ArrowDown=79]="ArrowDown",nU[nU.ArrowLeft=80]="ArrowLeft",nU[nU.ArrowRight=81]="ArrowRight",nU[nU.ArrowUp=82]="ArrowUp",nU[nU.NumLock=83]="NumLock",nU[nU.Numpad0=84]="Numpad0",nU[nU.Numpad1=85]="Numpad1",nU[nU.Numpad2=86]="Numpad2",nU[nU.Numpad3=87]="Numpad3",nU[nU.Numpad4=88]="Numpad4",nU[nU.Numpad5=89]="Numpad5",nU[nU.Numpad6=90]="Numpad6",nU[nU.Numpad7=91]="Numpad7",nU[nU.Numpad8=92]="Numpad8",nU[nU.Numpad9=93]="Numpad9",nU[nU.NumpadAdd=94]="NumpadAdd",nU[nU.NumpadBackspace=95]="NumpadBackspace",nU[nU.NumpadClear=96]="NumpadClear",nU[nU.NumpadClearEntry=97]="NumpadClearEntry",nU[nU.NumpadComma=98]="NumpadComma",nU[nU.NumpadDecimal=99]="NumpadDecimal",nU[nU.NumpadDivide=100]="NumpadDivide",nU[nU.NumpadEnter=101]="NumpadEnter",nU[nU.NumpadEqual=102]="NumpadEqual",nU[nU.NumpadHash=103]="NumpadHash",nU[nU.NumpadMemoryAdd=104]="NumpadMemoryAdd",nU[nU.NumpadMemoryClear=105]="NumpadMemoryClear",nU[nU.NumpadMemoryRecall=106]="NumpadMemoryRecall",nU[nU.NumpadMemoryStore=107]="NumpadMemoryStore",nU[nU.NumpadMemorySubtract=108]="NumpadMemorySubtract",nU[nU.NumpadMultiply=109]="NumpadMultiply",nU[nU.NumpadParenLeft=110]="NumpadParenLeft",nU[nU.NumpadParenRight=111]="NumpadParenRight",nU[nU.NumpadStar=112]="NumpadStar",nU[nU.NumpadSubtract=113]="NumpadSubtract",nU[nU.Escape=114]="Escape",nU[nU.F1=115]="F1",nU[nU.F2=116]="F2",nU[nU.F3=117]="F3",nU[nU.F4=118]="F4",nU[nU.F5=119]="F5",nU[nU.F6=120]="F6",nU[nU.F7=121]="F7",nU[nU.F8=122]="F8",nU[nU.F9=123]="F9",nU[nU.F10=124]="F10",nU[nU.F11=125]="F11",nU[nU.F12=126]="F12",nU[nU.F13=127]="F13",nU[nU.F14=128]="F14",nU[nU.F15=129]="F15",nU[nU.Fn=130]="Fn",nU[nU.FnLock=131]="FnLock",nU[nU.PrintScreen=132]="PrintScreen",nU[nU.ScrollLock=133]="ScrollLock",nU[nU.Pause=134]="Pause",nU[nU.BrowserBack=135]="BrowserBack",nU[nU.BrowserFavorites=136]="BrowserFavorites",nU[nU.BrowserForward=137]="BrowserForward",nU[nU.BrowserHome=138]="BrowserHome",nU[nU.BrowserRefresh=139]="BrowserRefresh",nU[nU.BrowserSearch=140]="BrowserSearch",nU[nU.BrowserStop=141]="BrowserStop",nU[nU.Eject=142]="Eject",nU[nU.LaunchApp1=143]="LaunchApp1",nU[nU.LaunchApp2=144]="LaunchApp2",nU[nU.LaunchMail=145]="LaunchMail",nU[nU.MediaPlayPause=146]="MediaPlayPause",nU[nU.MediaSelect=147]="MediaSelect",nU[nU.MediaStop=148]="MediaStop",nU[nU.MediaTrackNext=149]="MediaTrackNext",nU[nU.MediaTrackPrevious=150]="MediaTrackPrevious",nU[nU.Power=151]="Power",nU[nU.Sleep=152]="Sleep",nU[nU.AudioVolumeDown=153]="AudioVolumeDown",nU[nU.AudioVolumeMute=154]="AudioVolumeMute",nU[nU.AudioVolumeUp=155]="AudioVolumeUp",nU[nU.WakeUp=156]="WakeUp",nU[nU.Hyper=157]="Hyper",nU[nU.Super=158]="Super",nU[nU.Turbo=159]="Turbo",nU[nU.Abort=160]="Abort",nU[nU.Resume=161]="Resume",nU[nU.Suspend=162]="Suspend",nU[nU.Again=163]="Again",nU[nU.Copy=164]="Copy",nU[nU.Cut=165]="Cut",nU[nU.Find=166]="Find",nU[nU.Open=167]="Open",nU[nU.Paste=168]="Paste",nU[nU.Props=169]="Props",nU[nU.Select=170]="Select",nU[nU.Undo=171]="Undo",nU[nU.Hiragana=172]="Hiragana",nU[nU.Katakana=173]="Katakana",nU[nU.Unidentified=174]="Unidentified";var c8=((nk=(nz=function(e){this._curHeldDownKeyToIndexMap=[],this._upKeyToFrameCountMap=[],this._downKeyToFrameCountMap=[],this._curFrameHeldDownList=new lI,this._curFrameDownList=new lI,this._curFrameUpList=new lI,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,c5.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}},nk._onFocus=function(){this._hadListener||(this._htmlCanvas.addEventListener("keydown",this._onKeyEvent),this._htmlCanvas.addEventListener("keyup",this._onKeyEvent),this._hadListener=!0)},nk._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)},nk._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},nk._onKeyEvent=function(e){this._nativeEvents.push(e)},nz);e.CameraClearFlags=void 0,(nG=e.CameraClearFlags||(e.CameraClearFlags={}))[nG.None=0]="None",nG[nG.Color=1]="Color",nG[nG.Depth=2]="Depth",nG[nG.Stencil=4]="Stencil",nG[nG.ColorDepth=3]="ColorDepth",nG[nG.ColorStencil=5]="ColorStencil",nG[nG.DepthStencil=6]="DepthStencil",nG[nG.All=7]="All";var c6=function(){this.entity=null,this.distance=0,this.point=new sQ,this.normal=new sQ},c7=function(){function t(e){var n=this;this._initialized=!1,this._restTime=0,this._fixedTimeStep=1/60,this._colliders=new lI,this._gravity=new sQ(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._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)},lr(t,[{key:"gravity",get:function(){return this._gravity},set:function(e){var t=this._gravity;t!==e&&t.copyFrom(e)}},{key:"fixedTimeStep",get:function(){return this._fixedTimeStep},set:function(e){this._fixedTimeStep=Math.max(e,sY.zeroTolerance)}}]),t}();c7._collision=new function(){},e.PhysicsMaterialCombineMode=void 0,(nH=e.PhysicsMaterialCombineMode||(e.PhysicsMaterialCombineMode={}))[nH.Average=0]="Average",nH[nH.Minimum=1]="Minimum",nH[nH.Multiply=2]="Multiply",nH[nH.Maximum=3]="Maximum";var c9=((nW=function(){this._bounciness=.1,this._dynamicFriction=.1,this._staticFriction=.1,this._bounceCombine=e.PhysicsMaterialCombineMode.Average,this._frictionCombine=e.PhysicsMaterialCombineMode.Average,this._nativeMaterial=c7._nativePhysics.createPhysicsMaterial(this._staticFriction,this._dynamicFriction,this._bounciness,this._bounceCombine,this._frictionCombine)}).prototype._destroy=function(){this._nativeMaterial.destroy()},lr(nW,[{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))}}]),nW);e.Collider=(la(nX=function(e){var t;return(t=lU.call(this,e)||this)._index=-1,t._shapes=[],t._updateFlag=t.entity.transform.registerWorldChangeFlag(),t},lU),(nj=nX.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))},nj.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))},nj.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},nj._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}},nj._onLateUpdate=function(){},nj._onEnable=function(){this.engine.physicsManager._addCollider(this)},nj._onDisable=function(){this.engine.physicsManager._removeCollider(this)},nj._onDestroy=function(){lU.prototype._onDestroy.call(this),this.clearShapes(),this._nativeCollider.destroy()},nj._cloneTo=function(e){for(var t=this._shapes,n=0,r=t.length;n<r;n++)e.addShape(t[n].clone())},lr(nX,[{key:"shapes",get:function(){return this._shapes}}]),nX),ll([lu],e.Collider.prototype,"_index",void 0),ll([lu],e.Collider.prototype,"_nativeCollider",void 0),ll([lu],e.Collider.prototype,"_updateFlag",void 0),ll([lu],e.Collider.prototype,"_shapes",void 0),e.Collider=ll([lk(lq,e.DependentMode.CheckOnly)],e.Collider),e.ControllerNonWalkableMode=void 0,(nK=e.ControllerNonWalkableMode||(e.ControllerNonWalkableMode={}))[nK.PreventClimbing=0]="PreventClimbing",nK[nK.PreventClimbingAndForceSliding=1]="PreventClimbingAndForceSliding";var ue=(nq=e.Collider,la(nY=function(t){var n;return(n=nq.call(this,t)||this)._stepOffset=.5,n._nonWalkableMode=e.ControllerNonWalkableMode.PreventClimbing,n._upDirection=new sQ(0,1,0),n._slopeLimit=.707,n._nativeCollider=c7._nativePhysics.createCharacterController(),n._setUpDirection=n._setUpDirection.bind(lt(n)),n._upDirection._onValueChanged=n._setUpDirection,n},nq),(nQ=nY.prototype).move=function(e,t,n){return this._nativeCollider.move(e,t,n)},nQ.addShape=function(e){if(this._shapes.length>0)throw"only allow single shape on controller!";nq.prototype.addShape.call(this,e),this._updateFlag.flag=!0},nQ.clearShapes=function(){this._shapes.length>0&&nq.prototype.removeShape.call(this,this._shapes[0])},nQ._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}},nQ._onLateUpdate=function(){var e=this.entity.transform.worldPosition;this._nativeCollider.getWorldPosition(e),this.entity.transform.worldPosition=e,this._updateFlag.flag=!1},nQ._onEnable=function(){this.engine.physicsManager._addCharacterController(this)},nQ._onDisable=function(){this.engine.physicsManager._removeCharacterController(this)},nQ._setUpDirection=function(){this._nativeCollider.setUpDirection(this._upDirection)},lr(nY,[{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))}}]),nY),ut=function(){function e(){this._isTrigger=!1,this._rotation=new sQ,this._position=new sQ,this._contactOffset=.02,this.isSceneQuery=!0,this._material=new c9,this._id=e._idGenerator++,this._setRotation=this._setRotation.bind(this),this._setPosition=this._setPosition.bind(this),this._rotation._onValueChanged=this._setRotation,this._position._onValueChanged=this._setPosition}var t=e.prototype;return t.cloneTo=function(e){e.contactOffset=this.contactOffset,e.rotation=this.rotation,e.position=this.position,e.isTrigger=this.isTrigger,e.material=this.material},t._destroy=function(){this._material._destroy(),this._nativeShape.destroy()},t._setPosition=function(){this._nativeShape.setPosition(this._position)},t._setRotation=function(){this._nativeShape.setRotation(this._rotation)},lr(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}();ut._idGenerator=0,ll([lu],ut.prototype,"_collider",void 0),ll([lu],ut.prototype,"_nativeShape",void 0),ll([lu],ut.prototype,"_id",void 0),ll([lu],ut.prototype,"_material",void 0),ll([lu],ut.prototype,"_isTrigger",void 0),ll([lu],ut.prototype,"_rotation",void 0),ll([lu],ut.prototype,"_position",void 0),ll([lu],ut.prototype,"_contactOffset",void 0);var un=(la(nJ=function(){var e;return(e=ut.call(this)||this)._size=new sQ(1,1,1),e._nativeShape=c7._nativePhysics.createBoxColliderShape(e._id,e._size,e._material._nativeMaterial),e._setSize=e._setSize.bind(lt(e)),e._size._onValueChanged=e._setSize,e},ut),(nZ=nJ.prototype).clone=function(){var e=new nJ;return this.cloneTo(e),e},nZ.cloneTo=function(e){ut.prototype.cloneTo.call(this,e),e.size=this.size},nZ._setSize=function(){this._nativeShape.setSize(this._size)},lr(nJ,[{key:"size",get:function(){return this._size},set:function(e){this._size!==e&&this._size.copyFrom(e)}}]),nJ);ll([lu],un.prototype,"_size",void 0),console.log("Hello, world!");var ur=(la(n$=function(){var e;return(e=ut.call(this)||this)._radius=1,e._nativeShape=c7._nativePhysics.createSphereColliderShape(e._id,e._radius,e._material._nativeMaterial),e},ut),(n0=n$.prototype).clone=function(){var e=new n$;return this.cloneTo(e),e},n0.cloneTo=function(e){ut.prototype.cloneTo.call(this,e),e.radius=this.radius},lr(n$,[{key:"radius",get:function(){return this._radius},set:function(e){this._radius!==e&&(this._radius=e,this._nativeShape.setRadius(e))}}]),n$),ui=(la(n1=function(){var e;return(e=ut.call(this)||this)._nativeShape=c7._nativePhysics.createPlaneColliderShape(e._id,e._material._nativeMaterial),e},ut),n1.prototype.clone=function(){var e=new n1;return this.cloneTo(e),e},n1);e.ColliderShapeUpAxis=void 0,(n2=e.ColliderShapeUpAxis||(e.ColliderShapeUpAxis={}))[n2.X=0]="X",n2[n2.Y=1]="Y",n2[n2.Z=2]="Z";var ua=(la(n3=function(){var t;return(t=ut.call(this)||this)._radius=1,t._height=2,t._upAxis=e.ColliderShapeUpAxis.Y,t._nativeShape=c7._nativePhysics.createCapsuleColliderShape(t._id,t._radius,t._height,t._material._nativeMaterial),t},ut),(n4=n3.prototype).clone=function(){var e=new n3;return this.cloneTo(e),e},n4.cloneTo=function(e){ut.prototype.cloneTo.call(this,e),e.radius=this.radius,e.height=this.height,e.upAxis=this.upAxis},lr(n3,[{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))}}]),n3);e.Joint=(la(n5=function(e){var t;return(t=lU.call(this,e)||this)._connectedColliderInfo=new uo,t._force=0,t._torque=0,t._connectedColliderInfo.localPosition=new sQ,t},lU),n5.prototype._cloneTo=function(e){e.connectedCollider=this.connectedCollider,e.connectedAnchor=this.connectedAnchor,e.connectedMassScale=this.connectedMassScale,e.connectedInertiaScale=this.connectedInertiaScale,e.massScale=this.massScale,e.inertiaScale=this.inertiaScale,e.breakForce=this.breakForce,e.breakTorque=this.breakTorque},lr(n5,[{key:"connectedCollider",get:function(){return this._connectedColliderInfo.collider},set:function(e){this._connectedColliderInfo.collider!==e&&(this._connectedColliderInfo.collider=e,this._nativeJoint.setConnectedCollider(e._nativeCollider))}},{key:"connectedAnchor",get:function(){return this._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.localPosition;e!==t&&t.copyFrom(e),this._nativeJoint.setConnectedAnchor(e)}},{key:"connectedMassScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){e!==this._connectedColliderInfo.massScale&&(this._connectedColliderInfo.massScale=e,this._nativeJoint.setConnectedMassScale(e))}},{key:"connectedInertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){e!==this._connectedColliderInfo.inertiaScale&&(this._connectedColliderInfo.inertiaScale=e,this._nativeJoint.setConnectedInertiaScale(e))}},{key:"massScale",get:function(){return this._connectedColliderInfo.massScale},set:function(e){e!==this._connectedColliderInfo.massScale&&(this._connectedColliderInfo.massScale=e,this._nativeJoint.setMassScale(e))}},{key:"inertiaScale",get:function(){return this._connectedColliderInfo.inertiaScale},set:function(e){e!==this._connectedColliderInfo.inertiaScale&&(this._connectedColliderInfo.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))}}]),n5),ll([lu],e.Joint.prototype,"_connectedColliderInfo",void 0),ll([lu],e.Joint.prototype,"_nativeJoint",void 0),ll([lu],e.Joint.prototype,"_force",void 0),ll([lu],e.Joint.prototype,"_torque",void 0),e.Joint=ll([lk(e.Collider,e.DependentMode.CheckOnly)],e.Joint);var uo=function(){this.collider=null,this.massScale=0,this.inertiaScale=0},us=(n8=e.Joint,la(n6=function(){return n8.apply(this,arguments)},n8),n6.prototype._onAwake=function(){var t=this._connectedColliderInfo;t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=c7._nativePhysics.createFixedJoint(t.collider._nativeCollider)},n6);(n7=sv||(sv={}))[n7.LimitEnabled=1]="LimitEnabled",n7[n7.DriveEnabled=2]="DriveEnabled",n7[n7.DriveFreeSpin=4]="DriveFreeSpin";var ul=(n9=e.Joint,la(re=function(){var e;return e=n9.apply(this,arguments)||this,e._axis=new sQ(1,0,0),e._hingeFlags=0,e._useSpring=!1,e},n9),(rt=re.prototype)._onAwake=function(){var t=this._connectedColliderInfo;t.localPosition=new sQ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=c7._nativePhysics.createHingeJoint(t.collider._nativeCollider)},rt._cloneTo=function(e){e.axis=this.axis,e.swingOffset=this.swingOffset,e.useLimits=this.useLimits,e.useMotor=this.useMotor,e.useSpring=this.useSpring,e.motor=this.motor,e.limits=this.limits},lr(re,[{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._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.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&sv.LimitEnabled)==sv.LimitEnabled},set:function(e){e!==this.useLimits&&(this._hingeFlags|=sv.LimitEnabled),this._nativeJoint.setHingeJointFlag(sv.LimitEnabled,e)}},{key:"useMotor",get:function(){return(this._hingeFlags&sv.DriveEnabled)==sv.DriveEnabled},set:function(e){e!==this.useMotor&&(this._hingeFlags|=sv.DriveEnabled),this._nativeJoint.setHingeJointFlag(sv.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(sv.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))}}]),re);ll([lu],ul.prototype,"_axis",void 0),ll([lu],ul.prototype,"_hingeFlags",void 0),ll([lu],ul.prototype,"_useSpring",void 0),ll([lu],ul.prototype,"_jointMonitor",void 0),ll([lu],ul.prototype,"_limits",void 0);var uc=(rn=e.Joint,la(rr=function(){var e;return e=rn.apply(this,arguments)||this,e._minDistance=0,e._maxDistance=0,e._tolerance=.25,e._stiffness=0,e._damping=0,e},rn),(ri=rr.prototype)._onAwake=function(){var t=this._connectedColliderInfo;t.localPosition=new sQ,t.collider=this.entity.getComponent(e.Collider),this._nativeJoint=c7._nativePhysics.createSpringJoint(t.collider._nativeCollider)},ri._cloneTo=function(e){e.swingOffset=this.swingOffset,e.minDistance=this.minDistance,e.maxDistance=this.maxDistance,e.tolerance=this.tolerance,e.stiffness=this.stiffness,e.damping=this.damping},lr(rr,[{key:"swingOffset",get:function(){return this._connectedColliderInfo.localPosition},set:function(e){var t=this._connectedColliderInfo.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))}}]),rr),uu=function(){this.max=0,this.min=0,this.contactDistance=-1,this.stiffness=0,this.damping=0},uh=function(){this.targetVelocity=0,this.forceLimit=Number.MAX_VALUE,this.gearRation=1,this.freeSpin=!1};e.ControllerCollisionFlag=void 0,(ra=e.ControllerCollisionFlag||(e.ControllerCollisionFlag={}))[ra.Sides=1]="Sides",ra[ra.Up=2]="Up",ra[ra.Down=4]="Down";var ud=(ro=e.Collider,la(rs=function(e){var t,n=(t=ro.call(this,e)||this).entity.transform;return t._nativeCollider=c7._nativePhysics.createStaticCollider(n.worldPosition,n.worldRotationQuaternion),t},ro),rs),u_=(rl=e.Collider,la(rc=function(e){(t=rl.call(this,e)||this)._linearDamping=0,t._angularDamping=.05,t._linearVelocity=new sQ,t._angularVelocity=new sQ,t._mass=1,t._centerOfMass=new sQ,t._inertiaTensor=new sQ(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=c7._nativePhysics.createDynamicCollider(n.worldPosition,n.worldRotationQuaternion),t._setLinearVelocity=t._setLinearVelocity.bind(lt(t)),t._setAngularVelocity=t._setAngularVelocity.bind(lt(t)),t._setCenterOfMass=t._setCenterOfMass.bind(lt(t)),t._setInertiaTensor=t._setInertiaTensor.bind(lt(t)),t._linearVelocity._onValueChanged=t._setLinearVelocity,t._angularVelocity._onValueChanged=t._setAngularVelocity,t._centerOfMass._onValueChanged=t._setCenterOfMass,t._inertiaTensor._onValueChanged=t._setInertiaTensor,t},rl),(ru=rc.prototype).applyForce=function(e){this._nativeCollider.addForce(e)},ru.applyTorque=function(e){this._nativeCollider.addTorque(e)},ru.move=function(e,t){this._nativeCollider.move(e,t)},ru.sleep=function(){this._nativeCollider.sleep()},ru.wakeUp=function(){this._nativeCollider.wakeUp()},ru._onLateUpdate=function(){var e=this.entity.transform,t=e.worldPosition,n=e.worldRotationQuaternion;this._nativeCollider.getWorldTransform(t,n),this._updateFlag.flag=!1},ru._cloneTo=function(e){rl.prototype._cloneTo.call(this,e),e.linearDamping=this.linearDamping,e.angularDamping=this.angularDamping,e.linearVelocity=this.linearVelocity,e.angularVelocity=this.angularVelocity,e.mass=this.mass,e.centerOfMass=this.centerOfMass,e.inertiaTensor=this.inertiaTensor,e.maxAngularVelocity=this.maxAngularVelocity,e.maxDepenetrationVelocity=this.maxDepenetrationVelocity,e.sleepThreshold=this.sleepThreshold,e.solverIterations=this.solverIterations,e.isKinematic=this.isKinematic,e.constraints=this.constraints,e.collisionDetectionMode=this.collisionDetectionMode},ru._setLinearVelocity=function(){this._nativeCollider.setLinearVelocity(this._linearVelocity)},ru._setAngularVelocity=function(){this._nativeCollider.setAngularVelocity(this._angularVelocity)},ru._setCenterOfMass=function(){this._nativeCollider.setCenterOfMass(this._centerOfMass)},ru._setInertiaTensor=function(){this._nativeCollider.setInertiaTensor(this._inertiaTensor)},lr(rc,[{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))}}]),rc);ll([lu],u_.prototype,"_linearDamping",void 0),ll([lu],u_.prototype,"_angularDamping",void 0),ll([lu],u_.prototype,"_linearVelocity",void 0),ll([lu],u_.prototype,"_angularVelocity",void 0),ll([lu],u_.prototype,"_mass",void 0),ll([lu],u_.prototype,"_centerOfMass",void 0),ll([lu],u_.prototype,"_inertiaTensor",void 0),ll([lu],u_.prototype,"_maxAngularVelocity",void 0),ll([lu],u_.prototype,"_maxDepenetrationVelocity",void 0),ll([lu],u_.prototype,"_solverIterations",void 0),ll([lu],u_.prototype,"_isKinematic",void 0),ll([lu],u_.prototype,"_constraints",void 0),ll([lu],u_.prototype,"_collisionDetectionMode",void 0),ll([lu],u_.prototype,"_sleepThreshold",void 0),e.CollisionDetectionMode=void 0,(rh=e.CollisionDetectionMode||(e.CollisionDetectionMode={}))[rh.Discrete=0]="Discrete",rh[rh.Continuous=1]="Continuous",rh[rh.ContinuousDynamic=2]="ContinuousDynamic",rh[rh.ContinuousSpeculative=3]="ContinuousSpeculative",e.DynamicColliderConstraints=void 0,(rd=e.DynamicColliderConstraints||(e.DynamicColliderConstraints={}))[rd.None=0]="None",rd[rd.FreezePositionX=1]="FreezePositionX",rd[rd.FreezePositionY=2]="FreezePositionY",rd[rd.FreezePositionZ=4]="FreezePositionZ",rd[rd.FreezeRotationX=8]="FreezeRotationX",rd[rd.FreezeRotationY=16]="FreezeRotationY",rd[rd.FreezeRotationZ=32]="FreezeRotationZ",e.PointerButton=void 0,(r_=e.PointerButton||(e.PointerButton={}))[r_.None=0]="None",r_[r_.Primary=1]="Primary",r_[r_.Secondary=2]="Secondary",r_[r_.Auxiliary=4]="Auxiliary",r_[r_.XButton1=8]="XButton1",r_[r_.XButton2=16]="XButton2",r_[r_.XButton3=32]="XButton3",r_[r_.XButton4=64]="XButton4",r_[r_.XButton5=128]="XButton5",r_[r_.XButton6=256]="XButton6",r_[r_.XButton7=512]="XButton7",r_[r_.XButton8=1024]="XButton8";var uf=[1,4,2,8,16,32,64,128,256,512,1024],up={1:0,2:2,4:1,8:3,16:4,32:5,64:6,128:7,256:8,512:9,1024:10},ug=((rp=(rf=function(t){this._pointers=[],this._multiPointerEnabled=!0,this._buttons=e.PointerButton.None,this._upMap=[],this._downMap=[],this._upList=new lI,this._downList=new lI,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}},rp._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}},rp._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}},rp._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},rp._onPointerEvent=function(e){"pointerdown"===e.type&&this._htmlCanvas.focus(),this._nativeEvents.push(e)},rp._getIndexByPointerID=function(e){for(var t=this._pointers,n=t.length-1;n>=0;n--)if(t[n]._uniqueID===e)return n;return -1},rp._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 c4(a)),o._uniqueID=e,t.splice(a,0,o),o},rp._pointerRayCast=function(t,n){for(var r=rf._tempPoint,i=rf._tempRay,a=rf._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}}}},rp._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 C=0;C<u;C++){var T=l[C],S=T.button;switch(n.button=uf[S]||e.PointerButton.None,n.pressedButtons=T.buttons,T.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))},rp._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=uf[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},rf);ug._tempRay=new s5,ug._tempPoint=new s8,ug._tempHitResult=new c6;var um=((rm=(rg=function(e){this._delta=new sQ,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}},rm._onFocus=function(){this._hadListener||(this._canvas.addEventListener("wheel",this._onWheelEvent),this._hadListener=!0)},rm._onBlur=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._nativeEvents.length=0,this._delta.set(0,0,0),this._hadListener=!1)},rm._destroy=function(){this._hadListener&&(this._canvas.removeEventListener("wheel",this._onWheelEvent),this._hadListener=!1),this._nativeEvents=null},rm._onWheelEvent=function(e){e.cancelable&&e.preventDefault(),this._nativeEvents.push(e)},rg),uv=((ry=(rv=function(e){this._initialized=!1,this._engine=e;var t=e._canvas._webCanvas;"undefined"!=typeof OffscreenCanvas&&lc(t,OffscreenCanvas)||(this._wheelManager=new um(e),this._pointerManager=new ug(e),this._keyboardManager=new c8(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])},ry.isKeyDown=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameDownList.length>0:this._keyboardManager._downKeyToFrameCountMap[e]===this._engine.time.frameCount)},ry.isKeyUp=function(e){return!!this._initialized&&(void 0===e?this._keyboardManager._curFrameUpList.length>0:this._keyboardManager._upKeyToFrameCountMap[e]===this._engine.time.frameCount)},ry.isPointerHeldDown=function(e){return!!this._initialized&&(void 0===e?0!==this._pointerManager._buttons:(this._pointerManager._buttons&e)!=0)},ry.isPointerDown=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._downList.length>0:this._pointerManager._downMap[up[e]]===this._engine.time.frameCount)},ry.isPointerUp=function(e){return!!this._initialized&&(void 0===e?this._pointerManager._upList.length>0:this._pointerManager._upMap[up[e]]===this._engine.time.frameCount)},ry._update=function(){this._initialized&&(this._wheelManager._update(),this._pointerManager._update(),this._keyboardManager._update())},ry._destroy=function(){this._initialized&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._wheelManager._destroy(),this._pointerManager._destroy(),this._keyboardManager._destroy())},ry._onBlur=function(){this._wheelManager._onBlur(),this._pointerManager._onBlur(),this._keyboardManager._onBlur()},ry._onFocus=function(){this._wheelManager._onFocus(),this._pointerManager._onFocus(),this._keyboardManager._onFocus()},lr(rv,[{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}}]),rv),uy=(la(rx=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 s7(1,1,1,1),t._lightColor=new s7,t},lU),rx.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},lr(rx,[{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 s4),s4.invert(this.entity.transform.worldMatrix,this._viewMat),this._viewMat}},{key:"inverseViewMatrix",get:function(){return this._inverseViewMat||(this._inverseViewMat=new s4),s4.invert(this.viewMatrix,this._inverseViewMat),this._inverseViewMat}}]),rx);uy._maxLight=10,ll([lu],uy.prototype,"_lightIndex",void 0);var ux=(la(rC=function(){var e;return e=uy.apply(this,arguments)||this,e._reverseDirection=new sQ,e},uy),(rT=rC.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.direction,s=rC._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]=s7.gammaToLinearSpace(a.r),s.color[r+1]=s7.gammaToLinearSpace(a.g),s.color[r+2]=s7.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},rT._onEnable=function(){this.engine._lightManager._attachDirectLight(this)},rT._onDisable=function(){this.engine._lightManager._detachDirectLight(this)},rC._updateShaderData=function(e){var t=rC._combinedData;e.setIntArray(rC._cullingMaskProperty,t.cullingMask),e.setFloatArray(rC._colorProperty,t.color),e.setFloatArray(rC._directionProperty,t.direction)},lr(rC,[{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sQ.scale(this.direction,-1,this._reverseDirection),this._reverseDirection}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),rC);ux._cullingMaskProperty=lV.getByName("scene_DirectLightCullingMask"),ux._colorProperty=lV.getByName("scene_DirectLightColor"),ux._directionProperty=lV.getByName("scene_DirectLightDirection"),ux._combinedData={cullingMask:new Int32Array(2*uy._maxLight),color:new Float32Array(3*uy._maxLight),direction:new Float32Array(3*uy._maxLight)};var uC=(la(rS=function(){var e;return e=uy.apply(this,arguments)||this,e.distance=100,e},uy),(rw=rS.prototype)._appendData=function(t){var n=2*t,r=3*t,i=3*t,a=this._getLightIntensityColor(),o=this.position,s=rS._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]=s7.gammaToLinearSpace(a.r),s.color[r+1]=s7.gammaToLinearSpace(a.g),s.color[r+2]=s7.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},rw._onEnable=function(){this.engine._lightManager._attachPointLight(this)},rw._onDisable=function(){this.engine._lightManager._detachPointLight(this)},rS._updateShaderData=function(e){var t=rS._combinedData;e.setIntArray(rS._cullingMaskProperty,t.cullingMask),e.setFloatArray(rS._colorProperty,t.color),e.setFloatArray(rS._positionProperty,t.position),e.setFloatArray(rS._distanceProperty,t.distance)},lr(rS,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"_shadowProjectionMatrix",get:function(){throw"Unknown!"}}]),rS);uC._cullingMaskProperty=lV.getByName("scene_PointLightCullingMask"),uC._colorProperty=lV.getByName("scene_PointLightColor"),uC._positionProperty=lV.getByName("scene_PointLightPosition"),uC._distanceProperty=lV.getByName("scene_PointLightDistance"),uC._combinedData={cullingMask:new Int32Array(2*uy._maxLight),color:new Float32Array(3*uy._maxLight),position:new Float32Array(3*uy._maxLight),distance:new Float32Array(uy._maxLight)};var uT=(la(rA=function(){var e;return e=uy.apply(this,arguments)||this,e.distance=100,e.angle=Math.PI/6,e.penumbra=Math.PI/12,e._inverseDirection=new sQ,e._projectMatrix=new s4,e},uy),(rE=rA.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=rA._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]=s7.gammaToLinearSpace(o.r),c.color[r+1]=s7.gammaToLinearSpace(o.g),c.color[r+2]=s7.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)},rE._onEnable=function(){this.engine._lightManager._attachSpotLight(this)},rE._onDisable=function(){this.engine._lightManager._detachSpotLight(this)},rA._updateShaderData=function(e){var t=rA._combinedData;e.setIntArray(rA._cullingMaskProperty,t.cullingMask),e.setFloatArray(rA._colorProperty,t.color),e.setFloatArray(rA._positionProperty,t.position),e.setFloatArray(rA._directionProperty,t.direction),e.setFloatArray(rA._distanceProperty,t.distance),e.setFloatArray(rA._angleCosProperty,t.angleCos),e.setFloatArray(rA._penumbraCosProperty,t.penumbraCos)},lr(rA,[{key:"position",get:function(){return this.entity.transform.worldPosition}},{key:"direction",get:function(){return this.entity.transform.worldForward}},{key:"reverseDirection",get:function(){return sQ.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 s4.perspective(t,1,this.shadowNearPlane,this.distance+this.shadowNearPlane,e),e}}]),rA);uT._cullingMaskProperty=lV.getByName("scene_SpotLightCullingMask"),uT._colorProperty=lV.getByName("scene_SpotLightColor"),uT._positionProperty=lV.getByName("scene_SpotLightPosition"),uT._directionProperty=lV.getByName("scene_SpotLightDirection"),uT._distanceProperty=lV.getByName("scene_SpotLightDistance"),uT._angleCosProperty=lV.getByName("scene_SpotLightAngleCos"),uT._penumbraCosProperty=lV.getByName("scene_SpotLightPenumbraCos"),uT._combinedData={cullingMask:new Int32Array(2*uy._maxLight),color:new Float32Array(3*uy._maxLight),position:new Float32Array(3*uy._maxLight),direction:new Float32Array(3*uy._maxLight),distance:new Float32Array(uy._maxLight),angleCos:new Float32Array(uy._maxLight),penumbraCos:new Float32Array(uy._maxLight)};var uS=((rb=(rM=function(){this._spotLights=new lI,this._pointLights=new lI,this._directLights=new lI}).prototype)._attachSpotLight=function(e){e._lightIndex=this._spotLights.length,this._spotLights.add(e)},rb._detachSpotLight=function(e){var t=this._spotLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rb._attachPointLight=function(e){e._lightIndex=this._pointLights.length,this._pointLights.add(e)},rb._detachPointLight=function(e){var t=this._pointLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rb._attachDirectLight=function(e){e._lightIndex=this._directLights.length,this._directLights.add(e)},rb._detachDirectLight=function(e){var t=this._directLights.deleteByIndex(e._lightIndex);t&&(t._lightIndex=e._lightIndex),e._lightIndex=-1},rb._updateSunLightIndex=function(){var e=this._directLights,t=this._getSunLightIndex();if(t>0){var n=e.get(0),r=e.get(t);e.set(0,r),e.set(t,n),r._lightIndex=0,n._lightIndex=t}},rb._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?(ux._updateShaderData(e),e.enableMacro("SCENE_DIRECT_LIGHT_COUNT",o.toString())):e.disableMacro("SCENE_DIRECT_LIGHT_COUNT"),a?(uC._updateShaderData(e),e.enableMacro("SCENE_POINT_LIGHT_COUNT",a.toString())):e.disableMacro("SCENE_POINT_LIGHT_COUNT"),i?(uT._updateShaderData(e),e.enableMacro("SCENE_SPOT_LIGHT_COUNT",i.toString())):e.disableMacro("SCENE_SPOT_LIGHT_COUNT")},rb._gc=function(){this._spotLights.garbageCollection(),this._pointLights.garbageCollection(),this._directLights.garbageCollection()},rb._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},rM),uw=(la(rR=function(e,t){var n;return(n=lg.call(this,e)||this)._renderStates=[],n._shaderData=new cr(sa.Material),n.shader=t,n},lg),(rF=rR.prototype).clone=function(){var e=new rR(this._engine,this.shader);return this.cloneTo(e),e},rF.cloneTo=function(e){e.shader=this.shader,this.shaderData.cloneTo(e.shaderData),lf.deepCloneObject(this.renderStates,e.renderStates)},rF._addReferCount=function(e){this._destroyed||(lg.prototype._addReferCount.call(this,e),this.shaderData._addReferCount(e))},rF._onDestroy=function(){lg.prototype._onDestroy.call(this),this._shader=null,this._shaderData=null,this._renderStates.length=0,this._renderStates=null},lr(rR,[{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 cc);else t.length=r}},{key:"renderState",get:function(){return this._renderStates[0]}},{key:"renderStates",get:function(){return this._renderStates}}]),rR),uA="#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}",uE=((rP=function(){}).init=function(){var t={pipelineStage:e.PipelineStage.ShadowCaster},n={pipelineStage:e.PipelineStage.Forward},r=new ce("#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);cn.create("blinn-phong",[new ce("#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]),cn.create("pbr",[new ce(uA,"#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]),cn.create("pbr-specular",[new ce(uA,"#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]),cn.create("unlit",[new ce("#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]),cn.create("skybox",[new ce("#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)]),cn.create("SkyProcedural",[new ce("#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)]),cn.create("particle-shader",[new ce("#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)]),cn.create("SpriteMask",[new ce("#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)]),cn.create("Sprite",[new ce("#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)]),cn.create("background-texture",[new ce("#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)])},rP),uM=((rD=(rL=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},rD.cache=function(e){this._lastQueryMap[this._lastQueryKey]=e},rD._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)},rL);uE.init();var ub=function(t){function n(r,i,a){if((o=t.call(this)||this)._lightManager=new uS,o._componentsManager=new lB,o._lastRenderState=new cc,o._renderElementPool=new lJ(ch),o._meshRenderDataPool=new lJ(l$),o._spriteRenderDataPool=new lJ(cX),o._spriteMaskRenderDataPool=new lJ(cW),o._textRenderDataPool=new lJ(cj),o._renderContext=new cu,o._renderCount=0,o._shaderProgramPools=[],o._canSpriteBatch=!0,o._fontMap={},o._macroCollection=new l1,o._settings={},o._resourceManager=new c$(lt(o)),o._sceneManager=new cJ(lt(o)),o._vSyncCount=1,o._targetFrameRate=60,o._time=new lO,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(lt(o)),o._onDeviceRestored.bind(lt(o))),o.physicsManager=new c7(lt(o)),o._canvas=r,o._sceneManager.activeScene=new cQ(lt(o),"DefaultScene"),o._spriteMaskManager=new cH(lt(o)),o._spriteDefaultMaterial=o._createSpriteMaterial(),o._spriteMaskDefaultMaterial=o._createSpriteMaskMaterial(),o._textDefaultFont=lD.createFromOS(lt(o),"Arial"),o._textDefaultFont.isGCIgnored=!0,o.inputManager=new uv(lt(o)),o._initMagentaTextures(i),i.canIUse(e.GLCapabilityType.depthTexture)){var o,s=new lM(lt(o),1,1,e.TextureFormat.Depth16,!1);s.isGCIgnored=!0,o._depthTexture2D=s}else o._macroCollection.enable(n._noDepthTextureMacro);var l=new uw(lt(o),cn.find("unlit"));l.isGCIgnored=!0,l.shaderData.setColor("material_BaseColor",new ls(1,0,1.01,1)),o._magentaMaterial=l;var c=new uw(lt(o),cn.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}la(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(){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._isDeviceLost||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 uM}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 lw.debug("NO active camera.")},r._initMagentaTextures=function(t){var n=new Uint8Array([255,0,255,255]),r=new lM(this,1,1,e.TextureFormat.R8G8B8A8,!1);r.setPixelBuffer(n),r.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(la(o=function(){return lm.call(this,r)},lm),o.prototype.restoreContent=function(){this.resource.setPixelBuffer(n)},o));for(var i=new lR(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(la(s=function(){return lm.call(this,i)},lm),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 lb(this,1,1,1,e.TextureFormat.R8G8B8A8,!1);c.setPixelBuffer(0,n),c.isGCIgnored=!0,this.resourceManager.addContentRestorer(new(la(l=function(){return lm.call(this,c)},lm),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 uw(this,cn.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 uw(this,cn.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 cc,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()},lr(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}(lN);ub._gammaMacro=l0.getByName("ENGINE_IS_COLORSPACE_GAMMA"),ub._noDepthTextureMacro=l0.getByName("ENGINE_NO_DEPTH_TEXTURE"),ub._pixelsPerUnit=100;var uR=(la(rI=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),(rB=rI.prototype).onAwake=function(){},rB.onEnable=function(){},rB.onStart=function(){},rB.onUpdate=function(e){},rB.onLateUpdate=function(e){},rB.onBeginRender=function(e){},rB.onEndRender=function(e){},rB.onPhysicsUpdate=function(){},rB.onTriggerEnter=function(e){},rB.onTriggerExit=function(e){},rB.onTriggerStay=function(e){},rB.onCollisionEnter=function(e){},rB.onCollisionExit=function(e){},rB.onCollisionStay=function(e){},rB.onPointerDown=function(e){},rB.onPointerUp=function(e){},rB.onPointerClick=function(e){},rB.onPointerEnter=function(e){},rB.onPointerExit=function(e){},rB.onPointerDrag=function(e){},rB.onDisable=function(){},rB.onDestroy=function(){},rB._onAwake=function(){this.onAwake()},rB._onEnable=function(){if(this._waitHandlingInValid)this._waitHandlingInValid=!1;else{var e=this.engine._componentsManager,t=rI.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()},rB._onDisable=function(){this._waitHandlingInValid=!0,this._engine._componentsManager.addDisableScript(this),this.onDisable()},rB._handlingInValid=function(){var e=this.engine._componentsManager,t=rI.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},rB._onDestroy=function(){lU.prototype._onDestroy.call(this),this._engine._componentsManager.addPendingDestroyScript(this)},rI);ll([lu],uR.prototype,"_started",void 0),ll([lu],uR.prototype,"_onStartIndex",void 0),ll([lu],uR.prototype,"_onUpdateIndex",void 0),ll([lu],uR.prototype,"_onLateUpdateIndex",void 0),ll([lu],uR.prototype,"_onPhysicsUpdateIndex",void 0),ll([lu],uR.prototype,"_onPreRenderIndex",void 0),ll([lu],uR.prototype,"_onPostRenderIndex",void 0),ll([lu],uR.prototype,"_entityScriptsIndex",void 0),ll([lu],uR.prototype,"_waitHandlingInValid",void 0);var uF=(la(rN=function(){return ck.apply(this,arguments)},ck),(rV=rN.prototype).createVertexElements=function(t){return t[0]=new cm("POSITION",0,e.VertexElementFormat.Vector3,0),t[1]=new cm("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0),t[2]=new cm("COLOR_0",20,e.VertexElementFormat.Vector4,0),36},rV.canBatch=function(e,t){if(!this._engine._canSpriteBatch||!0===t.shaderPass.getTagValue(ck._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},rV.checkBatchWithMask=function(t,n){var r=t.maskInteraction;return r===n.maskInteraction&&(r===e.SpriteMaskInteraction.None||t.maskLayer===n.maskLayer)},rV.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},rV.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=cn._compileMacros;l1.unionCollection(_._globalShaderMacro,f.shaderData._macroCollection,p);var g=h.shaderPass._getShaderProgram(t,p);if(!g.isValid)return;_.shaderData.setTexture(rN._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(_)}},rV.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},rN);uF._textureProperty=lV.getByName("renderer_SpriteTexture");var uP=((rU=(rO=function(e){this.elements=[],this._initSpriteBatcher(e)}).prototype).pushRenderElement=function(e){this.elements.push(e)},rU.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 _=cn._compileMacros,f=d.component,p=d.material.destroyed?r._magentaMaterial:d.material,g=f.shaderData,m=p.shaderData;l1.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)}},rU.clear=function(){this.elements.length=0,this._spriteBatcher.clear()},rU.destroy=function(){this._spriteBatcher.destroy(),this._spriteBatcher=null},rU.sort=function(e){this._quickSort(this.elements,0,this.elements.length,e)},rU._initSpriteBatcher=function(e){this._spriteBatcher=new uF(e)},rU._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=_)}},rU._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}},rO._compareFromNearToFar=function(e,t){return e.data.component.priority-t.data.component.priority||e.data.component._distanceForSort-t.data.component._distanceForSort},rO._compareFromFarToNear=function(e,t){return e.data.component.priority-t.data.component.priority||t.data.component._distanceForSort-e.data.component._distanceForSort},rO),uL=function(){this.position=new sQ,this.isOrthographic=!1,this.viewMatrix=new s4,this.projectionMatrix=new s4,this.viewProjectionMatrix=new s4,this.forward=new sQ},uD=function(){this.virtualCamera=new uL,this.cullPlanes=[new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ),new s0(new sQ)],this.splitBoundSphere=new sJ(new sQ,0)};(rz=sy||(sy={}))[rz.FarBottomLeft=0]="FarBottomLeft",rz[rz.FarTopLeft=1]="FarTopLeft",rz[rz.FarTopRight=2]="FarTopRight",rz[rz.FarBottomRight=3]="FarBottomRight",rz[rz.nearBottomLeft=4]="nearBottomLeft",rz[rz.nearTopLeft=5]="nearTopLeft",rz[rz.nearTopRight=6]="nearTopRight",rz[rz.nearBottomRight=7]="nearBottomRight",rz[rz.unknown=8]="unknown";var uI=((rk=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}},rk.shadowDepthFormat=function(t,n){return n?e.TextureFormat.Depth16:e.TextureFormat.R8G8B8A8},rk.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},rk.shadowCullFrustum=function(e,t,n,r){var i=n._entity.layer;e.camera.cullingMask&i&&t.cullingMask&i&&n.castShadows&&rk.cullingRenderBounds(n.bounds,r.cullPlaneCount,r.cullPlanes)&&(n._renderFrameCount=n.engine.time.frameCount,n._prepareRender(e))},rk.getBoundSphereByFrustum=function(e,t,n,r,i){var a,o,s=n.aspectRatio,l=n.fieldOfView,c=Math.sqrt(1+s*s)*Math.tan(sY.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,sQ.scale(r,a,_),sQ.add(n.entity.transform.worldPosition,_,_),i.sphereCenterZ=a},rk.getDirectionLightShadowCullPlanes=function(t,n,r,i,a){var o=rk._frustumCorners,s=rk._backPlaneFaces,l=rk._frustumPlaneNeighbors,c=rk._frustumTwoPlaneCorners,u=rk._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=rk._adjustNearPlane,y=rk._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),s$.intersectionPointThreePlanes(v,g,p,o[7]),s$.intersectionPointThreePlanes(v,m,p,o[6]),s$.intersectionPointThreePlanes(v,m,f,o[5]),s$.intersectionPointThreePlanes(v,g,f,o[4]),s$.intersectionPointThreePlanes(y,g,p,o[3]),s$.intersectionPointThreePlanes(y,m,p,o[2]),s$.intersectionPointThreePlanes(y,m,f,o[1]),s$.intersectionPointThreePlanes(y,g,f,o[0]);for(var x=0,C=0;C<6;C++){var T=void 0;switch(C){case e.FrustumFace.Near:T=v;break;case e.FrustumFace.Far:T=y;break;default:T=t.getPlane(C)}0>sQ.dot(T.normal,i)&&(h[x].copyFrom(T),s[x]=C,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]];sQ.add(L,i,u),s0.fromPoints(L,D,u,h[S++])}}a.cullPlaneCount=S},rk.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-rk.atlasBorderSize),_=2*d,f=a/_,p=_/a,g=Math.ceil(sQ.dot(c,e)*f)*p,m=Math.ceil(sQ.dot(c,t)*f)*p,v=sQ.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,C=y.viewMatrix,T=y.projectionMatrix;sQ.scale(n,u+i,x),sQ.subtract(c,x,x),s4.lookAt(x,c,e,C),s4.ortho(-d,d,-d,d,0,2*u+i,T);var S=y.viewProjectionMatrix;s4.multiply(T,C,S),lG._floatMatrixMultiply(rk._shadowMapCoordMatrix,S.elements,0,s,16*r)},rk.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},rk.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)},rk.applySliceTransform=function(e,t,n,r,i,a){var o=rk._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)},rk);uI._tempMatrix0=new s4,uI._shadowMapCoordMatrix=new s4(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),uI._frustumCorners=[new sQ,new sQ,new sQ,new sQ,new sQ,new sQ,new sQ,new sQ],uI._adjustNearPlane=new s0(new sQ),uI._adjustFarPlane=new s0(new sQ),uI._backPlaneFaces=[,,,,,],uI._edgePlanePoint2=new sQ,uI._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]],uI._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]]],uI.atlasBorderSize=4;var uB=function(){function t(n){this._shadowMapSize=new s6,this._shadowBias=new s8,this._shadowSliceData=new uD,this._lightUp=new sQ,this._lightSide=new sQ,this._existShadowMap=!1,this._splitBoundSpheres=new Float32Array(4*t._maxCascades),this._shadowMatrices=new Float32Array((t._maxCascades+1)*16),this._shadowInfos=new sQ,this._viewportOffsets=[new s8,new s8,new s8,new s8],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,C=this._lightSide,T=o.virtualCamera.forward,S=i.scene._sunLight;if(S){var w=Math.min(i.scene.shadowDistance,i.farClipPlane);this._getCascadesSplitDistance(w);var A=this._getAvailableRenderTarget();f.activeRenderTarget(A,t._viewport,0),this._supportDepthTexture?f.clearRenderTarget(r,e.CameraClearFlags.Depth,null):f.clearRenderTarget(r,e.CameraClearFlags.All,t._clearColor),this._shadowInfos.x=S.shadowStrength,this._shadowInfos.z=0,s4.rotationQuaternion(S.entity.transform.worldRotationQuaternion,v),C.set(y[0],y[1],y[2]),x.set(y[4],y[5],y[6]),T.set(-y[8],-y[9],-y[10]);var E=t._tempVector;E.copyFrom(i.entity.transform.worldForward);for(var M=this._shadowTileResolution,b=0;b<p;b++){if(uI.getBoundSphereByFrustum(g[b],g[b+1],i,E,o),uI.getDirectionLightShadowCullPlanes(i._frustum,g[b],i.nearClipPlane,T,o),uI.getDirectionalLightMatrices(x,C,T,b,S.shadowNearPlane,M,o,l),p>1){var R=this._shadowMapSize;uI.applySliceTransform(M,R.z,R.w,b,this._viewportOffsets[b],l)}this._updateSingleShadowCasterShaderData(S,o,n);var F=m.center,P=m.radius,L=4*b;s[L]=F.x,s[L+1]=F.y,s[L+2]=F.z,s[L+3]=P*P,u.clear(),h.clear(),d.clear();for(var D=_._renderers,I=D._elements,B=D.length-1;B>=0;--B)uI.shadowCullFrustum(n,S,I[B],o);if(u.elements.length||h.elements.length){u.sort(uP._compareFromNearToFar),h.sort(uP._compareFromNearToFar);var N=a[b],V=N.x,O=N.y;f.setGlobalDepthBias(1,1),f.viewport(V,O,M,M),f.scissor(V+1,O+1,M-2,M-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*sY.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 lM(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 lE(t,i,a,null,o):this._renderTargets=new lE(t,i,a,o))._addReferCount(1)),s},n._updateShadowSettings=function(){var t=this._camera.scene,n=uI.shadowDepthFormat(t.shadowResolution,this._supportDepthTexture),r=uI.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=uI.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;uI.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}();uB._lightShadowBiasProperty=lV.getByName("scene_ShadowBias"),uB._lightDirectionProperty=lV.getByName("scene_LightDirection"),uB._shadowMatricesProperty=lV.getByName("scene_ShadowMatrices"),uB._shadowMapSize=lV.getByName("scene_ShadowMapSize"),uB._shadowInfosProperty=lV.getByName("scene_ShadowInfo"),uB._shadowMapsProperty=lV.getByName("scene_ShadowMap"),uB._shadowSplitSpheresProperty=lV.getByName("scene_ShadowSplitSpheres"),uB._maxCascades=4,uB._cascadesSplitDistance=Array(uB._maxCascades+1),uB._viewport=new s6(0,0,1,1),uB._clearColor=new s7(1,1,1,1),uB._tempVector=new sQ,uB._tempMatrix0=new s4;var uN=0,uV=((rH=(rG=function(t,n,r,i,a){void 0===t&&(t="RENDER_PASS"+uN++),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){},rH.preRender=function(e,t,n,r){},rH.postRender=function(e,t,n,r){},rG),uO=((rX=(rW=function(e){this._allSpriteMasks=new lI,this._lastCanvasSize=new s8,this._camera=e;var t=e.engine;this._opaqueQueue=new uP(t),this._alphaTestQueue=new uP(t),this._transparentQueue=new uP(t),this._cascadedShadowCaster=new uB(e),this._renderPassArray=[],this._defaultPass=new uV("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 uV(e,t,n,r,i);this._renderPassArray.push(a)}else lc(e,uV)&&this._renderPassArray.push(e);this._renderPassArray.sort(function(e,t){return e.priority-t.priority})},rX.removeRenderPass=function(e){var t;if("string"==typeof e?t=this.getRenderPass(e):lc(e,uV)&&(t=e),t){var n=this._renderPassArray.indexOf(t);this._renderPassArray.splice(n,1)}},rX.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},rX.destroy=function(){this._opaqueQueue.destroy(),this._alphaTestQueue.destroy(),this._transparentQueue.destroy(),this._allSpriteMasks=null,this._renderPassArray=null,this._defaultPass=null,this._camera=null},rX.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=rW._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=rW._forwardPipelineStageTagValue,this._callRender(t),s.sort(uP._compareFromNearToFar),l.sort(uP._compareFromNearToFar),c.sort(uP._compareFromFarToNear);for(var u=0,h=this._renderPassArray.length;u<h;u++)this._drawRenderPass(t,this._renderPassArray[u],a,n,r)},rX._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)},rX.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)},rX.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(cu.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)}}}},rX._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,cn._compileMacros);s.bind(),s.uploadAll(s.materialUniformBlock,i.shaderData),s.uploadUnGroupTextures(),i.renderState._apply(t,!1),r.drawPrimitive(o,o.subMesh,s)},rX._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))}},lr(rW,[{key:"defaultRenderPass",get:function(){return this._defaultPass}}]),rW);uO._shadowCasterPipelineStageTagValue=e.PipelineStage.ShadowCaster,uO._forwardPipelineStageTagValue=e.PipelineStage.Forward;var uU=function(){};uU.tempVec4=new s6,uU.tempVec3=new sQ,uU.tempVec2=new s8,e.Camera=(la(rj=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 l1,n._frustum=new s1,n._virtualCamera=new uL,n._replacementShader=null,n._replacementSubShaderTag=null,n._shaderData=new cr(sa.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 s6(0,0,1,1),n._inverseProjectionMatrix=new s4,n._lastAspectSize=new s8(0,0),n._invViewProjMat=new s4;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 uO(lt(n)),n.shaderData._addReferCount(1),n},lU),(rK=rj.prototype).resetProjectionMatrix=function(){this._isProjMatSetting=!1,this._projMatChange()},rK.resetAspectRatio=function(){this._customAspectRatio=void 0,this._projMatChange()},rK.worldToViewportPoint=function(e,t){var n=uU.tempVec3,r=uU.tempVec4;sQ.transformCoordinate(e,this.viewMatrix,n),sQ.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},rK.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},rK.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 sQ.subtract(i,r,i),i.normalize(),t},rK.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},rK.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},rK.worldToScreenPoint=function(e,t){return this.worldToViewportPoint(e,t),this.viewportToScreenPoint(t,t)},rK.screenToWorldPoint=function(e,t){return this.screenToViewportPoint(e,t),this.viewportToWorldPoint(t,t)},rK.screenPointToRay=function(e,t){var n=uU.tempVec2;return this.screenToViewportPoint(e,n),this.viewportPointToRay(n,t)},rK.render=function(e,t){void 0===t&&(t=0);var n=this.engine._renderContext,r=this._virtualCamera,i=this.entity.transform;s4.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(),l1.unionCollection(this.scene._globalShaderMacro,this.shaderData._macroCollection,this._globalShaderMacro),t>0&&!this.engine._hardwareRenderer.isWebGL2&&(t=0,lw.error("mipLevel only take effect in WebGL2.0")),this._renderPipeline.render(n,e,t),this._engine._renderCount++},rK.setReplacementShader=function(e,t){this._replacementShader=e,this._replacementSubShaderTag="string"==typeof t?l5.getByName(t):t},rK.resetReplacementShader=function(){this._replacementShader=null,this._replacementSubShaderTag=null},rK._onEnable=function(){this.entity.scene._attachRenderCamera(this)},rK._onDisable=function(){this.entity.scene._detachRenderCamera(this)},rK._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},rK._projMatChange=function(){this._isFrustumProjectDirty=!0,this._isProjectionDirty=!0,this._isInvProjMatDirty=!0,this._isInvViewProjDirty.flag=!0},rK._innerViewportToWorldPoint=function(e,t,n,r,i){var a=uU.tempVec3;return a.set(2*e-1,1-2*t,2*n-1),sQ.transformCoordinate(a,r,i),i},rK._updateShaderData=function(){var t=this.shaderData;t.setMatrix(e.Camera._inverseViewMatrixProperty,this._transform.worldMatrix),t.setVector3(e.Camera._cameraPositionProperty,this._transform.worldPosition)},rK._getInvViewProjMat=function(){return this._isInvViewProjDirty.flag&&(this._isInvViewProjDirty.flag=!1,s4.multiply(this._transform.worldMatrix,this._getInverseProjectionMatrix(),this._invViewProjMat)),this._invViewProjMat},rK._getInverseProjectionMatrix=function(){return this._isInvProjMatDirty&&(this._isInvProjMatDirty=!1,s4.invert(this.projectionMatrix,this._inverseProjectionMatrix)),this._inverseProjectionMatrix},lr(rj,[{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;s4.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;s4.ortho(-i,i,-a,a,this._nearClipPlane,this._farClipPlane,t)}else s4.perspective(sY.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}}}]),(sx=rj)._inverseViewMatrixProperty=lV.getByName("camera_ViewInvMat"),sx._cameraPositionProperty=lV.getByName("camera_Position"),sx),ll([l_],e.Camera.prototype,"_frustum",void 0),ll([lu],e.Camera.prototype,"_renderPipeline",void 0),ll([lu],e.Camera.prototype,"_virtualCamera",void 0),ll([lu],e.Camera.prototype,"_frustumViewChangeFlag",void 0),ll([lu],e.Camera.prototype,"_transform",void 0),ll([lu],e.Camera.prototype,"_isViewMatrixDirty",void 0),ll([lu],e.Camera.prototype,"_isInvViewProjDirty",void 0),ll([l_],e.Camera.prototype,"_viewport",void 0),ll([l_],e.Camera.prototype,"_inverseProjectionMatrix",void 0),ll([l_],e.Camera.prototype,"_lastAspectSize",void 0),ll([l_],e.Camera.prototype,"_invViewProjMat",void 0),e.Camera=ll([lk(lq,e.DependentMode.CheckOnly)],e.Camera);var uz={json:"json",gltf:"json",mtl:"json",prefab:"json",txt:"text",bin:"arraybuffer",png:"image",webp:"image",jpg:"image"},uk=1/0;function uG(e,t){return void 0===t&&(t={}),new cZ(function(n,r,i){var a,o,s,l,c=null!=(a=t.retryCount)?a:1,u=null!=(o=t.retryInterval)?o:500;t.timeout=null!=(s=t.timeout)?s:uk,t.type=null!=(l=t.type)?l:uz[e.substring(e.lastIndexOf(".")+1)];var h="image"===t.type?uH:uW;new uX(function(){return h(e,t).onProgress(i)},c,u).start().onError(r).onComplete(n)})}function uH(e,t){return new cZ(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 uW(e,t){return new cZ(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 uX=((rY=(rq=function(e,t,n){this.execFunc=e,this.totalCount=t,this.interval=n,this._timeoutId=-100,this._currentCount=0,this.exec=this.exec.bind(this)}).prototype).start=function(){return this.exec(),this},rY.onComplete=function(e){return this._onComplete=e,this},rY.onError=function(e){return this._onError=e,this},rY.cancel=function(){window.clearTimeout(this._timeoutId)},rY.exec=function(){var e=this;if(this._currentCount>=this.totalCount){this._onError&&this._onError(this._error);return}this._currentCount++,this.execFunc(this._currentCount).then(function(t){return e._onComplete&&e._onComplete(t)}).catch(function(t){e._error=t,e._timeoutId=window.setTimeout(e.exec,e.interval)})},rq),uj=((rQ=function(e){this.useCache=e,this.request=uG}).registerClass=function(e,t){this._engineObjects[e]=t},rQ.getClass=function(e){return this._engineObjects[e]},rQ);uj._engineObjects={},e.AssetType=void 0,(rJ=e.AssetType||(e.AssetType={})).Text="Text",rJ.JSON="JSON",rJ.Buffer="Buffer",rJ.Texture2D="Texture2D",rJ.TextureCube="TextureCube",rJ.Material="Material",rJ.Mesh="Mesh",rJ.AnimationClip="AnimationClip",rJ.AnimatorController="AnimatorController",rJ.GLTF="GLTF",rJ.KTX="KTX",rJ.KTXCube="KTXCube",rJ.Sprite="Sprite",rJ.SpriteAtlas="SpriteAtlas",rJ.Env="Environment",rJ.Scene="Scene",rJ.HDR="HDR",rJ.Font="Font",rJ.SourceFont="SourceFont",e.BlendMode=void 0,(rZ=e.BlendMode||(e.BlendMode={}))[rZ.Normal=0]="Normal",rZ[rZ.Additive=1]="Additive",e.RenderFace=void 0,(r$=e.RenderFace||(e.RenderFace={}))[r$.Front=0]="Front",r$[r$.Back=1]="Back",r$[r$.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}la(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},lr(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 cc),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}(uw);uK._baseTextureMacro=l0.getByName("MATERIAL_HAS_BASETEXTURE"),uK._normalTextureMacro=l0.getByName("MATERIAL_HAS_NORMALTEXTURE"),uK._emissiveTextureMacro=l0.getByName("MATERIAL_HAS_EMISSIVETEXTURE"),uK._transparentMacro=l0.getByName("MATERIAL_IS_TRANSPARENT"),uK._baseColorProp=lV.getByName("material_BaseColor"),uK._baseTextureProp=lV.getByName("material_BaseTexture"),uK._tilingOffsetProp=lV.getByName("material_TilingOffset"),uK._normalTextureProp=lV.getByName("material_NormalTexture"),uK._normalIntensityProp=lV.getByName("material_NormalIntensity"),uK._emissiveColorProp=lV.getByName("material_EmissiveColor"),uK._emissiveTextureProp=lV.getByName("material_EmissiveTexture"),uK._alphaCutoffProp=lV.getByName("material_AlphaCutoff"),uK._alphaCutoffMacro=l0.getByName("MATERIAL_IS_ALPHA_CUTOFF");var uq=function(e){function t(n){var r,i=(r=e.call(this,n,cn.find("blinn-phong"))||this).shaderData;return i.enableMacro("MATERIAL_NEED_WORLD_POS"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s7(1,1,1,1)),i.setColor(t._specularColorProp,new s7(1,1,1,1)),i.setColor(t._emissiveColorProp,new s7(0,0,0,1)),i.setVector4(t._tilingOffsetProp,new s6(1,1,0,0)),i.setFloat(t._shininessProp,16),i.setFloat(t._normalIntensityProp,1),r}return la(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lr(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);uq._specularColorProp=lV.getByName("material_SpecularColor"),uq._shininessProp=lV.getByName("material_Shininess"),uq._specularTextureProp=lV.getByName("material_SpecularTexture"),e.TextureCoordinate=void 0,(r0=e.TextureCoordinate||(e.TextureCoordinate={}))[r0.UV0=0]="UV0",r0[r0.UV1=1]="UV1",r0[r0.UV2=2]="UV2",r0[r0.UV3=3]="UV3",r0[r0.UV4=4]="UV4",r0[r0.UV5=5]="UV5",r0[r0.UV6=6]="UV6",r0[r0.UV7=7]="UV7";var uY=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 s7(1,1,1,1)),o.setColor(n._emissiveColorProp,new s7(0,0,0,1)),o.setVector4(n._tilingOffsetProp,new s6(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 la(n,t),lr(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&&lw.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);uY._occlusionTextureIntensityProp=lV.getByName("material_OcclusionIntensity"),uY._occlusionTextureCoordProp=lV.getByName("material_OcclusionTextureCoord"),uY._occlusionTextureProp=lV.getByName("material_OcclusionTexture"),uY._clearCoatProp=lV.getByName("material_ClearCoat"),uY._clearCoatTextureProp=lV.getByName("material_ClearCoatTexture"),uY._clearCoatRoughnessProp=lV.getByName("material_ClearCoatRoughness"),uY._clearCoatRoughnessTextureProp=lV.getByName("material_ClearCoatRoughnessTexture"),uY._clearCoatNormalTextureProp=lV.getByName("material_ClearCoatNormalTexture");var uQ=function(e){function t(n){var r;return(r=e.call(this,n,cn.find("pbr"))||this).shaderData.setFloat(t._metallicProp,1),r.shaderData.setFloat(t._roughnessProp,1),r.shaderData.setFloat(t._iorProp,1.5),r}return la(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lr(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}(uY);uQ._metallicProp=lV.getByName("material_Metal"),uQ._roughnessProp=lV.getByName("material_Roughness"),uQ._roughnessMetallicTextureProp=lV.getByName("material_RoughnessMetallicTexture"),uQ._iorProp=cn.getPropertyByName("material_IOR");var uJ=function(e){function t(n){var r;return(r=e.call(this,n,cn.find("pbr-specular"))||this).shaderData.setColor(t._specularColorProp,new s7(1,1,1,1)),r.shaderData.setFloat(t._glossinessProp,1),r}return la(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lr(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}(uY);uJ._specularColorProp=lV.getByName("material_PBRSpecularColor"),uJ._glossinessProp=lV.getByName("material_Glossiness"),uJ._specularGlossinessTextureProp=lV.getByName("material_SpecularGlossinessTexture"),uJ._specularGlossinessTextureMacro=l0.getByName("MATERIAL_HAS_SPECULAR_GLOSSINESS_TEXTURE");var uZ=function(e){function t(n){var r,i=(r=e.call(this,n,cn.find("unlit"))||this).shaderData;return i.enableMacro("MATERIAL_OMIT_NORMAL"),i.enableMacro("MATERIAL_NEED_TILING_OFFSET"),i.setColor(t._baseColorProp,new s7(1,1,1,1)),i.setVector4(t._tilingOffsetProp,new s6(1,1,0,0)),r}return la(t,e),t.prototype.clone=function(){var e=new t(this._engine);return this.cloneTo(e),e},lr(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,(r1=e.TextHorizontalAlignment||(e.TextHorizontalAlignment={}))[r1.Left=0]="Left",r1[r1.Center=1]="Center",r1[r1.Right=2]="Right",e.TextVerticalAlignment=void 0,(r2=e.TextVerticalAlignment||(e.TextVerticalAlignment={}))[r2.Top=0]="Top",r2[r2.Center=1]="Center",r2[r2.Bottom=2]="Bottom";var u$=(la(r3=function(e){var t;return(t=lg.call(this,e)||this)._sprites=[],t._spriteNamesToIndex={},t},lg),(r4=r3.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},r4.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},r4._addSprite=function(e){this._spriteNamesToIndex[e.name]=this._sprites.push(e)-1,e._atlas=this,e.isGCIgnored=!0},r4._onDestroy=function(){lg.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},lr(r3,[{key:"sprites",get:function(){return this._sprites}}]),r3);e.SpriteDrawMode=void 0,(r5=e.SpriteDrawMode||(e.SpriteDrawMode={}))[r5.Simple=0]="Simple",r5[r5.Sliced=1]="Sliced",r5[r5.Tiled=2]="Tiled",e.SpriteTileMode=void 0,(r8=e.SpriteTileMode||(e.SpriteTileMode={}))[r8.Continuous=0]="Continuous",r8[r8.Adaptive=1]="Adaptive";var u0=(la(r6=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=lg.call(this,e)||this)._automaticWidth=0,o._automaticHeight=0,o._customWidth=void 0,o._customHeight=void 0,o._positions=[new s8,new s8,new s8,new s8],o._uvs=[new s8,new s8,new s8,new s8],o._bounds=new sZ,o._texture=null,o._atlasRotated=!1,o._atlasRegion=new s9(0,0,1,1),o._atlasRegionOffset=new s6(0,0,0,0),o._region=new s9(0,0,1,1),o._pivot=new s8(.5,.5),o._border=new s6(0,0,0,0),o._dirtyUpdateFlag=7,o._updateFlagManager=new lK,o._texture=t,o._onRegionChange=o._onRegionChange.bind(lt(o)),o._onPivotChange=o._onPivotChange.bind(lt(o)),o._onBorderChange=o._onBorderChange.bind(lt(o)),o._region._onValueChanged=o._onRegionChange,o._pivot._onValueChanged=o._onPivotChange,o._border._onValueChanged=o._onBorderChange,n&&o._region.copyFrom(n),r&&o._pivot.copyFrom(r),i&&o._border.copyFrom(i),o.name=a,o},lg),(r7=r6.prototype).clone=function(){var e=new r6(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},r7._getPositions=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._positions},r7._getUVs=function(){return 2&this._dirtyUpdateFlag&&this._updateUVs(),this._uvs},r7._getBounds=function(){return 1&this._dirtyUpdateFlag&&this._updatePositions(),this._bounds},r7._addReferCount=function(e){var t;lg.prototype._addReferCount.call(this,e),null==(t=this._atlas)||t._addReferCount(e)},r7._onDestroy=function(){lg.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},r7._calDefaultSize=function(){if(this._texture){var e=this._texture,t=this._atlasRegion,n=this._atlasRegionOffset,r=this._region,i=1/ub._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},r7._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},r7._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,C=x.x,T=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+C*a)*v+u,_+h-(i-m+T*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},r7._dispatchSpriteChange=function(e){switch(e){case sc.texture:this._dirtyUpdateFlag|=4;break;case sc.atlasRegionOffset:case sc.region:this._dirtyUpdateFlag|=7;break;case sc.atlasRegion:this._dirtyUpdateFlag|=6;break;case sc.border:this._dirtyUpdateFlag|=2}this._updateFlagManager.dispatch(e)},r7._onRegionChange=function(){var e=this._region;e._onValueChanged=null;var t=sY.clamp(e.x,0,1),n=sY.clamp(e.y,0,1);e.set(t,n,sY.clamp(e.width,0,1-t),sY.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sc.region),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sc.size),e._onValueChanged=this._onRegionChange},r7._onPivotChange=function(){this._dispatchSpriteChange(sc.pivot)},r7._onBorderChange=function(){var e=this._border;e._onValueChanged=null;var t=sY.clamp(e.x,0,1),n=sY.clamp(e.y,0,1);e.set(t,n,sY.clamp(e.z,0,1-t),sY.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sc.border),e._onValueChanged=this._onBorderChange},lr(r6,[{key:"texture",get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._dispatchSpriteChange(sc.texture),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sc.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(sc.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(sc.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=sY.clamp(e.x,0,1),n=sY.clamp(e.y,0,1);this._atlasRegion.set(t,n,sY.clamp(e.width,0,1-t),sY.clamp(e.height,0,1-n)),this._dispatchSpriteChange(sc.atlasRegion),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sc.size)}},{key:"atlasRegionOffset",get:function(){return this._atlasRegionOffset},set:function(e){var t=sY.clamp(e.x,0,1),n=sY.clamp(e.y,0,1);this._atlasRegionOffset.set(t,n,sY.clamp(e.z,0,1-t),sY.clamp(e.w,0,1-n)),this._dispatchSpriteChange(sc.atlasRegionOffset),(void 0===this._customWidth||void 0===this._customHeight)&&this._dispatchSpriteChange(sc.size)}},{key:"region",get:function(){return this._region},set:function(e){this._region!==e&&this._region.copyFrom(e)}},{key:"pivot",get:function(){return this._pivot},set:function(e){this._pivot!==e&&this._pivot.copyFrom(e)}},{key:"border",get:function(){return this._border},set:function(e){this._border!==e&&this._border.copyFrom(e)}}]),r6);(r9=sC||(sC={}))[r9.positions=1]="positions",r9[r9.uvs=2]="uvs",r9[r9.automaticSize=4]="automaticSize",r9[r9.all=7]="all";var u1=((ie=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 sQ),r.push(new s8);t.triangles=[]},ie.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,C=y*u.x,T=x*u.y,S=y*u.z,w=x*u.w;if(C+S>r){var A=r/(C+S);t=[y*f*A,C*A,C*A,r-y*(1-m)*A]}else t=[y*f,C,r-S,r-y*(1-m)];if(w+T>i){var E=i/(w+T);n=[x*p*E,T*E,T*E,i-x*(1-v)*E]}else n=[x*p,T,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=u1._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,j=0;j<O-1;++j)for(var K=0;K<W-1;++K){var q=j*W+K;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)},ie.updateUVs=function(e){},ie._worldMatrix=new s4,ie);u1=ll([cd()],u1);var u2=((it=function(){}).resetData=function(e){var t;(t=e._verticesData).triangles||(t.triangles=[])},it.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 C=t.sprite.pivot,T=C.x,S=C.y,w=t.width*T,A=t.height*S,E=u2._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),j=v.get(O),K=m.get(z+1),q=v.get(O+1);p[N]?p[N].set(k,G):p[N]=new s8(k,G);var Y=f[N];Y?Y.set(n*X+a*j+P,r*X+o*j+L,i*X+s*j+D):f[N]=new sQ(n*X+a*j+P,r*X+o*j+L,i*X+s*j+D),p[++N]?p[N].set(H,G):p[N]=new s8(H,G),(Y=f[N])?Y.set(n*K+a*j+P,r*K+o*j+L,i*K+s*j+D):f[N]=new sQ(n*K+a*j+P,r*K+o*j+L,i*K+s*j+D),p[++N]?p[N].set(k,W):p[N]=new s8(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 sQ(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 s8(H,W),(Y=f[N])?Y.set(n*K+a*q+P,r*K+o*q+L,i*K+s*q+D):f[N]=new sQ(n*K+a*q+P,r*K+o*q+L,i*K+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)},it.updateUVs=function(e){},it._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],C=x.x,T=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>sY.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>sY.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>ck.MAX_VERTEX_COUNT){i.add(t*v),i.add(t*C),a.add(n*y),a.add(n*T),o.add(w.x),o.add(M.x),s.add(w.y),s.add(M.y),lw.warn("The number of vertices exceeds the upper limit("+ck.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-C)*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-C)),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-C)*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-T)*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-T)),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-T)*l),s.add(E.y),s.add(E.y),s.add(M.y)}},it._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,C=e._getUVs(),T=C[0],S=C[1],w=C[2],A=C[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>sY.zeroTolerance?(c=4+(0|(h=(t-F)/P)),s=2):(c=4,s=1),I>=n?(u=3,l=0):B>sY.zeroTolerance?(u=4+(0|(d=(n-I)/B)),l=2):(u=4,l=1),(c-1)*(u-1)*4>ck.MAX_VERTEX_COUNT){r.add(t*g),r.add(t*y),i.add(n*m),i.add(n*x),a.add(T.x),a.add(A.x),o.add(T.y),o.add(A.y),lw.warn("The number of vertices exceeds the upper limit("+ck.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(T.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(T.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(T.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(T.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(T.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(T.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)}},(sT=it)._worldMatrix=new s4,sT._posRow=new lI,sT._posColumn=new lI,sT._uvRow=new lI,sT._uvColumn=new lI,sT);u2=ll([cd()],u2),(ir=sS||(sS={}))[ir.Compressed=0]="Compressed",ir[ir.WithoutTiled=1]="WithoutTiled",ir[ir.WithTiled=2]="WithTiled";var u3=(ii=e.Renderer,la(ia=function(t){var n;return(n=ii.call(this,t)||this)._tileMode=e.SpriteTileMode.Continuous,n._tiledAdaptiveThreshold=.5,n._color=new s7(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 cf(4,[],[],null,n._color),n.drawMode=e.SpriteDrawMode.Simple,n.setMaterial(n._engine._spriteDefaultMaterial),n._onSpriteChange=n._onSpriteChange.bind(lt(n)),n},ii),(io=ia.prototype)._cloneTo=function(e){ii.prototype._cloneTo.call(this,e),e._assembler.resetData(e),e.sprite=this._sprite,e.drawMode=this._drawMode},io._updateShaderData=function(e){this._updateTransformShaderData(e,s4._identity)},io._updateBounds=function(e){this.sprite?this._assembler.updatePositions(this):(e.min.set(0,0,0),e.max.set(0,0,0))},io._render=function(e){if((null==(t=this.sprite)?void 0:t.texture)&&this.width&&this.height){this._dirtyUpdateFlag&ss.WorldVolume&&(this._assembler.updatePositions(this),this._dirtyUpdateFlag&=~ss.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)}},io._onDestroy=function(){ii.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},io._calDefaultSize=function(){var e=this._sprite;e?(this._automaticWidth=e.width,this._automaticHeight=e.height):this._automaticWidth=this._automaticHeight=0,this._dirtyUpdateFlag&=-5},io._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}},io._onSpriteChange=function(t){switch(t){case sc.texture:this.shaderData.setTexture(ia._textureProperty,this.sprite.texture);break;case sc.size:var n=this._drawMode;this._dirtyUpdateFlag|=4,this._drawMode===e.SpriteDrawMode.Sliced?this._dirtyUpdateFlag|=ss.WorldVolume:n===e.SpriteDrawMode.Tiled?this._dirtyUpdateFlag|=3:(void 0===this._customWidth||void 0===this._customHeight)&&(this._dirtyUpdateFlag|=ss.WorldVolume);break;case sc.border:this._drawMode===e.SpriteDrawMode.Sliced&&(this._dirtyUpdateFlag|=3);break;case sc.region:case sc.atlasRegionOffset:this._dirtyUpdateFlag|=3;break;case sc.atlasRegion:this._dirtyUpdateFlag|=2;break;case sc.pivot:this._dirtyUpdateFlag|=ss.WorldVolume}},lr(ia,[{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=c_;break;case e.SpriteDrawMode.Sliced:this._assembler=u1;break;case e.SpriteDrawMode.Tiled:this._assembler=u2}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=sY.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(ia._textureProperty,e.texture)):this.shaderData.setTexture(ia._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|=ss.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|=ss.WorldVolume)}},{key:"flipX",get:function(){return this._flipX},set:function(e){this._flipX!==e&&(this._flipX=e,this._dirtyUpdateFlag|=ss.WorldVolume)}},{key:"flipY",get:function(){return this._flipY},set:function(e){this._flipY!==e&&(this._flipY=e,this._dirtyUpdateFlag|=ss.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())}}]),ia);u3._textureProperty=lV.getByName("renderer_SpriteTexture"),ll([lu],u3.prototype,"_verticesData",void 0),ll([lu],u3.prototype,"_drawMode",void 0),ll([lh],u3.prototype,"_assembler",void 0),ll([lh],u3.prototype,"_tileMode",void 0),ll([lh],u3.prototype,"_tiledAdaptiveThreshold",void 0),ll([l_],u3.prototype,"_color",void 0),ll([lu],u3.prototype,"_sprite",void 0),ll([lu],u3.prototype,"_automaticWidth",void 0),ll([lu],u3.prototype,"_automaticHeight",void 0),ll([lh],u3.prototype,"_customWidth",void 0),ll([lh],u3.prototype,"_customHeight",void 0),ll([lh],u3.prototype,"_flipX",void 0),ll([lh],u3.prototype,"_flipY",void 0),ll([lh],u3.prototype,"_maskLayer",void 0),ll([lh],u3.prototype,"_maskInteraction",void 0),ll([lu],u3.prototype,"_onSpriteChange",null),(is=sw||(sw={}))[is.UV=2]="UV",is[is.RenderData=3]="RenderData",is[is.AutomaticSize=4]="AutomaticSize",is[is.All=7]="All";var u4=function e(){this.localPositions=new s6;var t=[new sQ,new sQ,new sQ,new sQ];this.renderData=new cf(4,t,null,e.triangles,null)};u4.triangles=[0,2,1,2,0,3];var u5=((ic=(il=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},ic.put=function(e){this._elements.push(e)},il),u8=(iu=e.Renderer,la(ih=function(t){var n;return(n=iu.call(this,t)||this)._subFont=null,n._charRenderDatas=[],n._dirtyFlag=15,n._color=new s7(1,1,1,1),n._text="",n._width=0,n._height=0,n._localBounds=new sZ,n._font=null,n._fontSize=24,n._fontStyle=e.FontStyle.None,n._lineSpacing=0,n._horizontalAlignment=e.TextHorizontalAlignment.Center,n._verticalAlignment=e.TextVerticalAlignment.Center,n._enableWrapping=!1,n._overflowMode=e.OverflowMode.Overflow,n._maskInteraction=e.SpriteMaskInteraction.None,n._maskLayer=e.SpriteMaskLayer.Layer0,n._init(),n},iu),(id=ih.prototype)._init=function(){var e=this.engine;this._font=e._textDefaultFont,this._font._addReferCount(1),this.setMaterial(e._spriteDefaultMaterial)},id._onDestroy=function(){iu.prototype._onDestroy.call(this);for(var e=this._charRenderDatas,t=0,n=e.length;t<n;++t)ih._charRenderDataPool.put(e[t]);e.length=0,this._font&&(this._font._addReferCount(-1),this._font=null),this._subFont&&(this._subFont=null)},id._cloneTo=function(e){iu.prototype._cloneTo.call(this,e),e.font=this._font,e._subFont=this._subFont},id._isContainDirtyFlag=function(e){return(this._dirtyFlag&e)!=0},id._setDirtyFlagTrue=function(e){this._dirtyFlag|=e},id._setDirtyFlagFalse=function(e){this._dirtyFlag&=~e},id._updateShaderData=function(e){this._updateTransformShaderData(e,s4._identity)},id._updateBounds=function(e){sZ.transform(this._localBounds,this._entity.transform.worldMatrix,e)},id._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)}},id._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}},id._resetSubFont=function(){var e=this._font;this._subFont=e._getSubFont(this.fontSize,this.fontStyle),this._subFont.nativeFontString=lP.getNativeFontString(e.name,this.fontSize,this.fontStyle)},id._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=ih._tempVec31.set(a,o,s),d=ih._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 C=m[1];sQ.scale(d,g.z-v,C),sQ.add(x,C,C);var T=m[2];sQ.scale(h,g.w-y,T),sQ.add(x,T,m[3]),sQ.add(C,T,T)}},id._updateLocalData=function(){var t=this.color,n=this._charRenderDatas,r=this._subFont,i=this._localBounds,a=i.min,o=i.max,s=this.enableWrapping?lP.measureTextWithWrap(this):lP.measureTextWithoutWrap(this),l=s.height,c=s.lines,u=s.lineWidths,h=s.lineHeight,d=s.lineMaxSizes,_=ih._charRenderDataPool,f=c.length,p=0;if(f>0){var g=ub._pixelsPerUnit,m=this.horizontalAlignment,v=1/g,y=.5*(this.width*g),x=this.height*g,C=.5*h,T=0,S=.5*h-d[0].ascent,w=.5*h-d[f-1].descent-1;switch(this.verticalAlignment){case e.TextVerticalAlignment.Top:T=.5*x-C+S;break;case e.TextVerticalAlignment.Center:T=.5*l-C-(w-S)*.5;break;case e.TextVerticalAlignment.Bottom:T=l-.5*x-C-w}for(var A=-1,E=Number.MAX_SAFE_INTEGER,M=Number.MAX_SAFE_INTEGER,b=Number.MIN_SAFE_INTEGER,R=Number.MIN_SAFE_INTEGER,F=0;F<f;++F){var P=u[F];if(P>0){var L=c[F],D=0,I=-1;switch(A<0&&(A=F),m){case e.TextHorizontalAlignment.Left:D=-y;break;case e.TextHorizontalAlignment.Center:D=-(.5*P);break;case e.TextHorizontalAlignment.Right:D=y-P}for(var B=0,N=L.length;B<N;++B){var V=L[B],O=r._getCharInfo(V);if(O.h>0){I<0&&(I=B);var U,z,k=(U=n)[z=p++]||(U[z]=_.get()),G=k.renderData,H=k.localPositions;k.texture=r._getTextureByIndex(O.index),G.color=t,G.uvs=O.uvs;var W=O.w,X=O.ascent,j=O.descent,K=D*v,q=(D+W)*v,Y=(T+X)*v,Q=(T-j+1)*v;H.set(K,Y,q,Q),F===A&&(R=Math.max(R,Y)),M=Math.min(M,Q),B===I&&(E=Math.min(E,K)),b=Math.max(b,q)}D+=O.xAdvance}}T-=h}A<0?(a.set(0,0,0),o.set(0,0,0)):(a.set(E,M,0),o.set(b,R,0))}else a.set(0,0,0),o.set(0,0,0);var J=n.length;if(J>p){for(var Z=p;Z<J;++Z)_.put(n[Z]);n.length=p}r._getLastIndex()>0&&n.sort(function(e,t){return e.texture.instanceId-t.texture.instanceId})},id._onTransformChanged=function(e){iu.prototype._onTransformChanged.call(this,e),this._setDirtyFlagTrue(12)},lr(ih,[{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}}]),ih);u8._charRenderDataPool=new u5(u4,50),u8._tempVec30=new sQ,u8._tempVec31=new sQ,ll([lh],u8.prototype,"_subFont",void 0),ll([lu],u8.prototype,"_charRenderDatas",void 0),ll([lu],u8.prototype,"_dirtyFlag",void 0),ll([l_],u8.prototype,"_color",void 0),ll([lh],u8.prototype,"_text",void 0),ll([lh],u8.prototype,"_width",void 0),ll([lh],u8.prototype,"_height",void 0),ll([lu],u8.prototype,"_localBounds",void 0),ll([lh],u8.prototype,"_font",void 0),ll([lh],u8.prototype,"_fontSize",void 0),ll([lh],u8.prototype,"_fontStyle",void 0),ll([lh],u8.prototype,"_lineSpacing",void 0),ll([lh],u8.prototype,"_horizontalAlignment",void 0),ll([lh],u8.prototype,"_verticalAlignment",void 0),ll([lh],u8.prototype,"_enableWrapping",void 0),ll([lh],u8.prototype,"_overflowMode",void 0),ll([lh],u8.prototype,"_maskInteraction",void 0),ll([lh],u8.prototype,"_maskLayer",void 0),(i_=sA||(sA={}))[i_.SubFont=1]="SubFont",i_[i_.LocalPositionBounds=2]="LocalPositionBounds",i_[i_.WorldPosition=4]="WorldPosition",i_[i_.WorldBounds=8]="WorldBounds",i_[i_.MaskInteraction=16]="MaskInteraction",i_[i_.Position=14]="Position",i_[i_.Font=15]="Font";var u6=((ig=(ip=function(){}).prototype).initialize=function(e){this._skinnedMeshRenderer=e.target.getComponent(cM)},ig.getTargetValue=function(){return this._skinnedMeshRenderer.blendShapeWeights},ig.setTargetValue=function(e){this._skinnedMeshRenderer.blendShapeWeights=e},ip),u7=((iv=(im=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iv.getTargetValue=function(){return this._transform.position},iv.setTargetValue=function(e){this._transform.position=e},im),u9=((ix=(iy=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},ix.getTargetValue=function(){return this._transform.rotationQuaternion},ix.setTargetValue=function(e){this._transform.rotationQuaternion=e},iy),he=((iT=(iC=function(){}).prototype).initialize=function(e){this._transform=e.target.transform},iT.getTargetValue=function(){return this._transform.scale},iT.setTargetValue=function(e){this._transform.scale=e},iC),ht=((iw=(iS=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]},iw.getTargetValue=function(){return this._mounted[this._propertyName]},iw.setTargetValue=function(e){this._mounted[this._propertyName]=e},iS),hn=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:ht},e}();hn._assemblerMap=new Map,hn.registerAssembler(cM,"blendShapeWeights",u6),hn.registerAssembler(lq,"position",u7),hn.registerAssembler(lq,"rotationQuaternion",u9),hn.registerAssembler(lq,"scale",he);var hr=((iE=(iA=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},iE.saveFinalValue=function(){this.finalValue=this.curveOwner.getEvaluateValue(this.finalValue)},iA),hi=((ib=(iM=function(){this._tempCurveOwner={}}).prototype)._createCurveOwner=function(e){var t=this.curve.constructor,n=new hn(e,this.type,this.property,t);return t._initializeOwner(n),n.saveDefaultValue(),n},ib._createCurveLayerOwner=function(e){var t=this.curve.constructor,n=new hr;return n.curveOwner=e,t._initializeLayerOwner(n),n.initFinalValue(),n},ib._getTempCurveOwner=function(e){var t=e.instanceId;return this._tempCurveOwner[t]||(this._tempCurveOwner[t]=this._createCurveOwner(e)),this._tempCurveOwner[t]},iM),ha=function(){},ho=(la(iR=function(e){var t;return(t=lp.call(this,null)||this).name=e,t._curveBindings=[],t._length=0,t._events=[],t},lp),(iF=iR.prototype).addEvent=function(e,t,n){if("string"==typeof e){var r,i=new ha;i.functionName=e,i.time=t,i.parameter=n,r=i}else r=e;var a=this._events,o=a.length,s=r.time;if(s>=(o?a[o-1].time:0))a.push(r);else{for(var l=o;--l>=0&&s<a[l].time;);a.splice(l+1,0,r)}},iF.clearEvents=function(){this._events.length=0},iF.addCurveBinding=function(e,t,n,r){var i=new hi;i.relativePath=e,i.type=t,i.property=n,i.curve=r,r.length>this._length&&(this._length=r.length),this._curveBindings.push(i)},iF.clearCurveBindings=function(){this._curveBindings.length=0,this._length=0},iF._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)}}},lr(iR,[{key:"events",get:function(){return this._events}},{key:"curveBindings",get:function(){return this._curveBindings}},{key:"length",get:function(){return this._length}}]),iR);e.InterpolationType=void 0,(iP=e.InterpolationType||(e.InterpolationType={}))[iP.Linear=0]="Linear",iP[iP.CubicSpine=1]="CubicSpine",iP[iP.Step=2]="Step",iP[iP.Hermite=3]="Hermite";var hs=((iD=(iL=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)}},iD.evaluate=function(e){return this._evaluate(e,this._evaluateData)},iD.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},iD._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},iD._evaluateAdditive=function(e,t){var n=this._evaluate(e,t);return this._type._subtractValue(n,this.keys[0].value,t.value)},lr(iL,[{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}}]),iL);e.AnimationArrayCurve=(la(iI=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=[],e},hs),iI._initializeOwner=function(e){e.defaultValue=[],e.fixedPoseValue=[],e.baseEvaluateData.value=[],e.crossEvaluateData.value=[]},iI._initializeLayerOwner=function(e){e.finalValue=[]},iI._lerpValue=function(e,t,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},iI._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iI._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iI._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iI._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iI._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},(sE=iI)._isReferenceType=!0,sE._isInterpolationType=!0,sE),e.AnimationArrayCurve=ll([cd()],e.AnimationArrayCurve),e.AnimationBoolCurve=(la(iB=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=!1,e},hs),iB._initializeOwner=function(e){e.defaultValue=!1,e.fixedPoseValue=!1,e.baseEvaluateData.value=!1,e.crossEvaluateData.value=!1},iB._initializeLayerOwner=function(e){e.finalValue=!1},iB._lerpValue=function(e,t){return t},iB._subtractValue=function(e,t,n){return e},iB._getZeroValue=function(){return!1},iB._additiveValue=function(e,t,n){return e},iB._copyValue=function(e){return e},iB._hermiteInterpolationValue=function(e){return e.value},(sM=iB)._isReferenceType=!1,sM._isInterpolationType=!1,sM),e.AnimationBoolCurve=ll([cd()],e.AnimationBoolCurve),e.AnimationColorCurve=(la(iN=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=new s7,e},hs),iN._initializeOwner=function(e){e.defaultValue=new s7,e.fixedPoseValue=new s7,e.baseEvaluateData.value=new s7,e.crossEvaluateData.value=new s7},iN._initializeLayerOwner=function(e){e.finalValue=new s7},iN._lerpValue=function(e,t,n,r){return s7.lerp(e,t,n,r),r},iN._subtractValue=function(e,t,n){return s7.subtract(e,t,n),n},iN._getZeroValue=function(e){return e.set(0,0,0,0),e},iN._additiveValue=function(e,t,n){return s7.scale(e,t,e),s7.add(n,e,n),n},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.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},(sb=iN)._isReferenceType=!0,sb._isInterpolationType=!0,sb),e.AnimationColorCurve=ll([cd()],e.AnimationColorCurve),e.AnimationFloatArrayCurve=(la(iV=function(){return hs.apply(this,arguments)},hs),iV.prototype.addKey=function(e){hs.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)}},iV._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)},iV._initializeLayerOwner=function(e){var t=e.curveOwner.referenceTargetValue.length;e.finalValue=new Float32Array(t)},iV._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},iV._subtractValue=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n[r]=e[r]-t[r];return n},iV._getZeroValue=function(e){for(var t=0,n=e.length;t<n;t++)e[t]=0;return e},iV._additiveValue=function(e,t,n){for(var r=0,i=n.length;r<i;++r)n[r]+=e[r]*t;return n},iV._copyValue=function(e,t){for(var n=0,r=t.length;n<r;++n)t[n]=e[n];return t},iV._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},(sR=iV)._isReferenceType=!0,sR._isInterpolationType=!0,sR),e.AnimationFloatArrayCurve=ll([cd()],e.AnimationFloatArrayCurve),e.AnimationFloatCurve=(la(iO=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=0,e},hs),iO._initializeOwner=function(e){e.defaultValue=0,e.fixedPoseValue=0,e.baseEvaluateData.value=0,e.crossEvaluateData.value=0},iO._initializeLayerOwner=function(e){e.finalValue=0},iO._lerpValue=function(e,t,n){return e+(t-e)*n},iO._additiveValue=function(e,t,n){return n+e*t},iO._subtractValue=function(e,t){return e-t},iO._getZeroValue=function(){return 0},iO._copyValue=function(e){return e},iO._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},(sF=iO)._isReferenceType=!1,sF._isInterpolationType=!0,sF),e.AnimationFloatCurve=ll([cd()],e.AnimationFloatCurve),e.AnimationQuaternionCurve=(la(iU=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=new s3,e},hs),iU._initializeOwner=function(e){e.defaultValue=new s3,e.fixedPoseValue=new s3,e.baseEvaluateData.value=new s3,e.crossEvaluateData.value=new s3},iU._initializeLayerOwner=function(e){e.finalValue=new s3},iU._lerpValue=function(e,t,n,r){return s3.slerp(e,t,n,r),r},iU._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},iU._subtractValue=function(t,n,r){var i=e.AnimationQuaternionCurve._tempConjugateQuat;return s3.conjugate(n,i),s3.multiply(i,t,r),r},iU._getZeroValue=function(e){return e.set(0,0,0,1),e},iU._copyValue=function(e,t){return t.copyFrom(e),t},iU._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},(sP=iU)._isInterpolationType=!0,sP._isReferenceType=!0,sP._tempConjugateQuat=new s3,sP),e.AnimationQuaternionCurve=ll([cd()],e.AnimationQuaternionCurve),e.AnimationVector2Curve=(la(iz=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=new s8,e},hs),iz._initializeOwner=function(e){e.defaultValue=new s8,e.fixedPoseValue=new s8,e.baseEvaluateData.value=new s8,e.crossEvaluateData.value=new s8},iz._initializeLayerOwner=function(e){e.finalValue=new s8},iz._lerpValue=function(e,t,n,r){return s8.lerp(e,t,n,r),r},iz._additiveValue=function(e,t,n){return s8.scale(e,t,e),s8.add(n,e,n),n},iz._subtractValue=function(e,t,n){return s8.subtract(e,t,n),n},iz._getZeroValue=function(e){return e.set(0,0),e},iz._copyValue=function(e,t){return t.copyFrom(e),t},iz._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},(sL=iz)._isReferenceType=!0,sL._isInterpolationType=!0,sL),e.AnimationVector2Curve=ll([cd()],e.AnimationVector2Curve),e.AnimationVector3Curve=(la(ik=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=new sQ,e},hs),ik._initializeOwner=function(e){e.defaultValue=new sQ,e.fixedPoseValue=new sQ,e.baseEvaluateData.value=new sQ,e.crossEvaluateData.value=new sQ},ik._initializeLayerOwner=function(e){e.finalValue=new sQ},ik._lerpValue=function(e,t,n,r){return sQ.lerp(e,t,n,r),r},ik._relativeBaseValue=function(e,t){return sQ.subtract(t,e,t),t},ik._additiveValue=function(e,t,n){return sQ.scale(e,t,e),sQ.add(n,e,n),n},ik._subtractValue=function(e,t,n){return sQ.subtract(e,t,n),n},ik._getZeroValue=function(e){return e.set(0,0,0),e},ik._copyValue=function(e,t){return t.copyFrom(e),t},ik._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},(sD=ik)._isReferenceType=!0,sD._isInterpolationType=!0,sD),e.AnimationVector3Curve=ll([cd()],e.AnimationVector3Curve),e.AnimationVector4Curve=(la(iG=function(){var e;return(e=hs.call(this)||this)._evaluateData.value=new s6,e},hs),iG._initializeOwner=function(e){e.defaultValue=new s6,e.fixedPoseValue=new s6,e.baseEvaluateData.value=new s6,e.crossEvaluateData.value=new s6},iG._initializeLayerOwner=function(e){e.finalValue=new s6},iG._lerpValue=function(e,t,n,r){return s6.lerp(e,t,n,r),r},iG._additiveValue=function(e,t,n){return s6.scale(e,t,e),s6.add(n,e,n),n},iG._subtractValue=function(e,t,n){return s6.subtract(e,t,n),n},iG._getZeroValue=function(e){return e.set(0,0,0,0),e},iG._copyValue=function(e,t){return t.copyFrom(e),t},iG._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},(sI=iG)._isReferenceType=!0,sI._isInterpolationType=!0,sI),e.AnimationVector4Curve=ll([cd()],e.AnimationVector4Curve),e.AnimatorCullingMode=void 0,(iH=e.AnimatorCullingMode||(e.AnimatorCullingMode={}))[iH.None=0]="None",iH[iH.Complete=1]="Complete",e.AnimatorLayerBlendingMode=void 0,(iW=e.AnimatorLayerBlendingMode||(e.AnimatorLayerBlendingMode={}))[iW.Override=0]="Override",iW[iW.Additive=1]="Additive",(iX=sB||(sB={}))[iX.UnStarted=0]="UnStarted",iX[iX.Playing=1]="Playing",iX[iX.Finished=2]="Finished",(ij=sN||(sN={}))[ij.Standby=0]="Standby",ij[ij.Playing=1]="Playing",ij[ij.CrossFading=2]="CrossFading",ij[ij.FixedCrossFading=3]="FixedCrossFading",ij[ij.Finished=4]="Finished";var hl=((iK=function(){this.handlers=[]}).prototype.dispose=function(){},iK),hc=function(){this.duration=0,this.offset=0,this.exitTime=1};e.WrapMode=void 0,(iq=e.WrapMode||(e.WrapMode={}))[iq.Once=0]="Once",iq[iq.Loop=1]="Loop";var hu=((iQ=(iY=function(){}).prototype).reset=function(e,t,n){this.state=e,this.frameTime=n,this.stateData=t,this.playState=sB.UnStarted,this.clipTime=e.clipStartTime*e.clip.length,this.currentEventIndex=0,this.currentTransitionIndex=0},iQ.update=function(t){var n=this.state,r=this.frameTime,i=n._getDuration();this.playState=sB.Playing,n.wrapMode===e.WrapMode.Loop?r=i?r%i:0:Math.abs(r)>i&&(r=r<0?-i:i,this.playState=sB.Finished),t&&0===r?this.clipTime=n.clipEndTime*n.clip.length:(r<0&&(r+=i),this.clipTime=r+n.clipStartTime*n.clip.length)},iY),hh=((iJ=function(){this.curveOwnerPool=Object.create(null),this.animatorStateDataMap={},this.srcPlayData=new hu,this.destPlayData=new hu,this.layerState=sN.Standby,this.crossCurveMark=0,this.manuallyTransition=new hc,this.crossLayerOwnerCollection=[]}).prototype.switchPlayData=function(){var e=this.destPlayData,t=this.srcPlayData;this.srcPlayData=e,this.destPlayData=t},iJ),hd=function(){this.curveLayerOwner=[],this.eventHandlers=[]},h_=(la(iZ=function(t){var n;return(n=lU.call(this,t)||this).cullingMode=e.AnimatorCullingMode.None,n.speed=1,n._onUpdateIndex=-1,n._updateMark=0,n._animatorLayersData=[],n._curveOwnerPool=Object.create(null),n._animationEventHandlerPool=new lJ(hl),n._tempAnimatorStateInfo={layerIndex:-1,state:null},n._controlledRenderers=[],n},lU),(i$=iZ.prototype).play=function(e,t,n){void 0===t&&(t=-1),void 0===n&&(n=0),(null==(r=this._controllerUpdateFlag)?void 0:r.flag)&&this._reset(),this._playFrameCount=this.engine.time.frameCount;var r,i=this._getAnimatorStateInfo(e,t),a=i.state,o=i.layerIndex;if(a){if(!a.clip){lw.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=sN.Playing,s.srcPlayData.reset(a,l,a._getDuration()*n),this.update(0)}},i$.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(),this._playFrameCount=this.engine.time.frameCount;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,s)&&this.update(0)},i$.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}this._updateMark++;for(var l=0,c=s.layers.length;l<c;l++)this._getAnimatorLayerData(l).layerState!==sN.Standby&&this._updateLayer(l,0===l,t,r)}},i$.getCurrentAnimatorState=function(e){var t,n;return null==(t=this._animatorLayersData[e])?void 0:null==(n=t.srcPlayData)?void 0:n.state},i$.findAnimatorState=function(e,t){return void 0===t&&(t=-1),this._getAnimatorStateInfo(e,t).state},i$._onEnable=function(){this.engine._componentsManager.addOnUpdateAnimations(this),this.animatorController&&this._checkAutoPlay(),this._entity.getComponentsIncludeChildren(e.Renderer,this._controlledRenderers)},i$._onDisable=function(){this.engine._componentsManager.removeOnUpdateAnimations(this)},i$._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)},i$._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},i$._getAnimatorStateData=function(e,t,n,r){var i=n.animatorStateDataMap,a=i[e];return a||(a=new hd,i[e]=a,this._saveAnimatorStateData(t,a,n,r),this._saveAnimatorEventHandlers(t,a)),a},i$._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,lw.warn("The entity don't have the child entity which path is "+u.relativePath+".")}},i$._saveAnimatorEventHandlers=function(e,t){var n=this._animationEventHandlerPool,r=[];this._entity.getComponents(uR,r);var 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[_][h];f&&d.push(f)}a.push(u)}},i$._clearCrossData=function(e){e.crossCurveMark++,e.crossLayerOwnerCollection.length=0},i$._addCrossOwner=function(e,t,n,r){t.crossSrcCurveIndex=n,t.crossDestCurveIndex=r,e.crossLayerOwnerCollection.push(t)},i$._prepareCrossFading=function(e){this._prepareSrcCrossData(e,!1),this._prepareDestCrossData(e,!1)},i$._prepareStandbyCrossFading=function(e){e.srcPlayData.state&&this._prepareSrcCrossData(e,!0),this._prepareDestCrossData(e,!0)},i$._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)},i$._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))}},i$._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)}}}},i$._getAnimatorLayerData=function(e){var t=this._animatorLayersData[e];return t||(this._animatorLayersData[e]=t=new hh),t},i$._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=o===e.AnimatorLayerBlendingMode.Additive;switch(n&&(s=1),l.layerState){case sN.Playing:this._updatePlayingState(c,l,t,s,r,h,i);break;case sN.FixedCrossFading:this._updateCrossFadeFromPose(u,l,t,s,r,h,i);break;case sN.CrossFading:this._updateCrossFade(c,u,l,t,s,r,h,i);break;case sN.Finished:this._updateFinishedState(c,s,h,i)}},i$._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.transitions,f=u.clip._curveBindings,p=u.speed*this.speed;e.frameTime+=p*i,e.update(p<0);var g=e.clipTime,m=e.playState,v=m===sB.Finished;if(o||v)for(var y=f.length-1;y>=0;y--){var x=l[y],C=null==x?void 0:x.curveOwner;if(C){var T=f[y].curve;if(T.keys.length){this._checkRevertOwner(C,a);var S=C.evaluateValue(T,g,a);o&&C.applyValue(S,r,a),v&&x.saveFinalValue()}}}if(m===sB.Finished&&(t.layerState=sN.Finished),c.length&&this._fireAnimationEvents(e,c,d,g),h===sB.UnStarted&&this._callAnimatorScriptOnEnter(u,n),m===sB.Finished?this._callAnimatorScriptOnExit(u,n):this._callAnimatorScriptOnUpdate(u,n),_.length){var w=t.layerState;w!==sN.CrossFading&&w!==sN.FixedCrossFading&&this._checkTransition(e,_,n,d,g)}},i$._updateCrossFade=function(e,t,n,r,i,a,o,s){var l=this.speed,c=n.crossLayerOwnerCollection,u=e.state.clip._curveBindings,h=e.state,d=e.stateData,_=e.playState,f=d.eventHandlers,p=t.state,g=t.stateData,m=t.playState,v=g.eventHandlers,y=p.clip._curveBindings,x=e.clipTime,C=t.clipTime,T=p._getDuration()*n.crossFadeTransition.duration,S=Math.abs(t.frameTime)/T;(S>=1||0===T)&&(S=1);var w=h.speed*l,A=p.speed*l;e.frameTime+=w*a,t.frameTime+=A*a,e.update(w<0),t.update(A<0);var E=e.clipTime,M=e.playState,b=t.clipTime,R=t.playState,F=t.playState===sB.Finished;if(s||F)for(var P=c.length-1;P>=0;P--){var L=c[P],D=null==L?void 0:L.curveOwner;if(D){var I=L.crossSrcCurveIndex,B=L.crossDestCurveIndex;this._checkRevertOwner(D,o);var N=D.evaluateCrossFadeValue(I>=0?u[I].curve:null,B>=0?y[B].curve:null,E,b,S,o);s&&D.applyValue(N,i,o),F&&L.saveFinalValue()}}this._updateCrossFadeData(n,S),f.length&&this._fireAnimationEvents(e,f,x,E),v.length&&this._fireAnimationEvents(t,v,C,b),_===sB.UnStarted&&this._callAnimatorScriptOnEnter(h,r),1===S||M===sB.Finished?this._callAnimatorScriptOnExit(h,r):this._callAnimatorScriptOnUpdate(h,r),m===sB.UnStarted&&this._callAnimatorScriptOnEnter(p,r),R===sB.Finished?this._callAnimatorScriptOnExit(p,r):this._callAnimatorScriptOnUpdate(p,r)},i$._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);var g=l.speed*this.speed;e.frameTime+=g*i,e.update(g<0);var m=e.clipTime,v=e.playState,y=v===sB.Finished;if(o||y)for(var x=s.length-1;x>=0;x--){var C=s[x],T=null==C?void 0:C.curveOwner;if(T){var S=C.crossDestCurveIndex;this._checkRevertOwner(T,a);var w=C.curveOwner.crossFadeFromPoseAndApplyValue(S>=0?d[S].curve:null,m,p,a);o&&T.applyValue(w,r,a),y&&C.saveFinalValue()}}this._updateCrossFadeData(t,p),h.length&&this._fireAnimationEvents(e,h,_,m),u===sB.UnStarted&&this._callAnimatorScriptOnEnter(l,n),v===sB.Finished?this._callAnimatorScriptOnExit(l,n):this._callAnimatorScriptOnUpdate(l,n)},i$._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))}},i$._updateCrossFadeData=function(e,t){var n=e.destPlayData;1===t&&(n.playState===sB.Finished?e.layerState=sN.Finished:e.layerState=sN.Playing,e.switchPlayData(),e.crossFadeTransition=null)},i$._preparePlay=function(e,t){if(e.layerState===sN.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()},i$._checkTransition=function(e,t,n,r,i){var a=e.state,o=a.clip.length;this.speed*a.speed>=0?(console.log(999,i,r),i<r?(this._checkSubTransition(e,t,n,r,a.clipEndTime*o),e.currentTransitionIndex=0,this._checkSubTransition(e,t,n,a.clipStartTime*o,i)):this._checkSubTransition(e,t,n,r,i)):i>r?(this._checkBackwardsSubTransition(e,t,n,r,a.clipStartTime*o),e.currentTransitionIndex=t.length-1,this._checkBackwardsSubTransition(e,t,n,i,a.clipEndTime*o)):this._checkBackwardsSubTransition(e,t,n,r,i)},i$._checkSubTransition=function(e,t,n,r,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration(),s=t.length;a<s;a++){var l=t[a],c=l.exitTime*o;if(c>i)break;c>=r&&(this._crossFadeByTransition(l,n),e.currentTransitionIndex=Math.min(a+1,s-1))}},i$._checkBackwardsSubTransition=function(e,t,n,r,i){for(var a=e.currentTransitionIndex,o=e.state._getDuration();a>=0;a--){var s=t[a],l=s.exitTime*o;if(l<i)break;l<=r&&(this._crossFadeByTransition(s,n),e.currentTransitionIndex=Math.max(a-1,0))}},i$._crossFadeByTransition=function(e,t){var n=e.destinationState;if(!n)return!1;if(!n.clip)return lw.warn("The state named "+name+" has no AnimationClip data."),!1;var r=this._getAnimatorLayerData(t),i=r.layerState,a=r.destPlayData,o=this._getAnimatorStateData(n.name,n,r,t),s=n._getDuration()*e.offset;switch(a.reset(n,o,s),i){case sN.Standby:case sN.Finished:r.layerState=sN.FixedCrossFading,this._clearCrossData(r),this._prepareStandbyCrossFading(r);break;case sN.Playing:r.layerState=sN.CrossFading,this._clearCrossData(r),this._prepareCrossFading(r);break;case sN.CrossFading:r.layerState=sN.FixedCrossFading,this._prepareFixedPoseCrossFading(r);break;case sN.FixedCrossFading:this._prepareFixedPoseCrossFading(r)}return r.crossFadeTransition=e,!0},i$._fireAnimationEvents=function(e,t,n,r){var i=e.state,a=i.clip.length;this.speed*i.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)},i$._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)}}},i$._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)}}},i$._callAnimatorScriptOnEnter=function(e,t){for(var n=e._onStateEnterScripts,r=0,i=n.length;r<i;r++)n[r].onStateEnter(this,e,t)},i$._callAnimatorScriptOnUpdate=function(e,t){for(var n=e._onStateUpdateScripts,r=0,i=n.length;r<i;r++)n[r].onStateUpdate(this,e,t)},i$._callAnimatorScriptOnExit=function(e,t){for(var n=e._onStateExitScripts,r=0,i=n.length;r<i;r++)n[r].onStateExit(this,e,t)},i$._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)}},i$._checkRevertOwner=function(e,t){t&&e.updateMark!==this._updateMark&&e.revertDefaultValue(),e.updateMark=this._updateMark},lr(iZ,[{key:"animatorController",get:function(){return this._animatorController},set:function(e){e!==this._animatorController&&(this._reset(),this._controllerUpdateFlag&&this._controllerUpdateFlag.destroy(),this._controllerUpdateFlag=e&&e._registerChangeFlag(),this._animatorController=e)}}]),iZ);ll([lh],h_.prototype,"speed",void 0),ll([lu],h_.prototype,"_controllerUpdateFlag",void 0),ll([lu],h_.prototype,"_updateMark",void 0),ll([lu],h_.prototype,"_animatorLayersData",void 0),ll([lu],h_.prototype,"_curveOwnerPool",void 0),ll([lu],h_.prototype,"_animationEventHandlerPool",void 0),ll([lu],h_.prototype,"_tempAnimatorStateInfo",void 0),ll([lu],h_.prototype,"_controlledRenderers",void 0);var hf=((i1=(i0=function(){this._updateFlagManager=new lK,this._layers=[],this._layersMap={}}).prototype).findLayerByName=function(e){return this._layersMap[e]},i1.addLayer=function(e){this._layers.push(e),this._layersMap[e.name]=e,this._updateFlagManager.dispatch()},i1.removeLayer=function(e){var t=this.layers[e];this._layers.splice(e,1),delete this._layersMap[t.name],this._updateFlagManager.dispatch()},i1.clearLayers=function(){for(var e in this._layers.length=0,this._layersMap)delete this._layersMap[e];this._updateFlagManager.dispatch()},i1._registerChangeFlag=function(){return this._updateFlagManager.createFlag(lj)},lr(i0,[{key:"layers",get:function(){return this._layers}}]),i0),hp=function(t){this.name=t,this.weight=1,this.blendingMode=e.AnimatorLayerBlendingMode.Override},hg=((i3=(i2=function(){this._destroyed=!1}).prototype).onStateEnter=function(e,t,n){},i3.onStateUpdate=function(e,t,n){},i3.onStateExit=function(e,t,n){},i3.destroy=function(){this._destroyed||(this._state._removeStateMachineScript(this),this._destroyed=!0)},i2),hm=((i5=(i4=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){var t=this._transitions,n=t.length,r=e.exitTime;if(r>=(n?t[n-1].exitTime:0))t.push(e);else{for(var i=n;--i>=0&&r<t[i].exitTime;);t.splice(i+1,0,e)}},i5.removeTransition=function(e){var t=this._transitions.indexOf(e);-1!==t&&this._transitions.splice(t,1)},i5.addStateMachineScript=function(e){var t=new e;t._state=this;var n=hg.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},i5.clearTransitions=function(){this._transitions.length=0},i5._getDuration=function(){return this.clip?(this._clipEndTime-this._clipStartTime)*this.clip.length:null},i5._removeStateMachineScript=function(e){var t=hg.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)}},lr(i4,[{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)}}]),i4),hv=((i6=(i8=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 hm(e),this.states.push(t),this._statesMap[e]=t),t},i6.removeState=function(e){var t=e.name,n=this.states.indexOf(e);n>-1&&this.states.splice(n,1),delete this._statesMap[t]},i6.findStateByName=function(e){return this._statesMap[e]},i6.makeUniqueStateName=function(e){for(var t=this._statesMap,n=e,r=0;t[e];)e=n+" "+r,r++;return e},i8);e.AnimatorConditionMode=void 0,(i7=e.AnimatorConditionMode||(e.AnimatorConditionMode={}))[i7.If=0]="If",i7[i7.IfNot=1]="IfNot",i7[i7.Greater=2]="Greater",i7[i7.Less=3]="Less",i7[i7.Equals=4]="Equals",i7[i7.NotEquals=5]="NotEquals";var hy=function(){},hx=function(t){function n(r){var i;return(i=t.call(this,r,cn.find("skybox"))||this)._textureDecodeRGBM=!1,i._tintColor=new s7(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 la(n,t),n.prototype.clone=function(){var e=new n(this._engine);return this.cloneTo(e),e},lr(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}(uw);hx._tintColorProp=lV.getByName("material_TintColor"),hx._textureCubeProp=lV.getByName("material_CubeTexture"),hx._rotationProp=lV.getByName("material_Rotation"),hx._exposureProp=lV.getByName("material_Exposure"),hx._decodeSkyRGBMMacro=l0.getByName("MATERIAL_IS_DECODE_SKY_RGBM"),e.SunMode=void 0,(i9=e.SunMode||(e.SunMode={}))[i9.None=0]="None",i9[i9.Simple=1]="Simple",i9[i9.HighQuality=2]="HighQuality";var hC=(la(ae=function(t){var n;return(n=uw.call(this,t,cn.find("SkyProcedural"))||this).sunMode=2,n.sunSize=.04,n.sunSizeConvergence=5,n.atmosphereThickness=1,n.skyTint=new s7(.5,.5,.5,1),n.groundTint=new s7(.369,.349,.341,1),n.exposure=1.3,n.renderState.rasterState.cullMode=e.CullMode.Off,n.renderState.depthState.compareFunction=e.CompareFunction.LessEqual,n},uw),ae.prototype.clone=function(){var e=new ae(this._engine);return this.cloneTo(e),e},lr(ae,[{key:"sunMode",get:function(){return this._sunDisk},set:function(e){var t=this.shaderData;switch(e){case 2:t.disableMacro(ae._sunSimpleMacro),t.enableMacro(ae._sunHighQualityMacro);break;case 1:t.disableMacro(ae._sunHighQualityMacro),t.enableMacro(ae._sunSimpleMacro);break;case 0:t.disableMacro(ae._sunHighQualityMacro),t.disableMacro(ae._sunSimpleMacro);break;default:throw"SkyBoxProceduralMaterial: unknown sun value."}this._sunDisk=e}},{key:"sunSize",get:function(){return this.shaderData.getFloat(ae._sunSizeProp)},set:function(e){this.shaderData.setFloat(ae._sunSizeProp,Math.min(Math.max(0,e),1))}},{key:"sunSizeConvergence",get:function(){return this.shaderData.getFloat(ae._sunSizeConvergenceProp)},set:function(e){this.shaderData.setFloat(ae._sunSizeConvergenceProp,Math.min(Math.max(0,e),20))}},{key:"atmosphereThickness",get:function(){return this.shaderData.getFloat(ae._atmosphereThicknessProp)},set:function(e){this.shaderData.setFloat(ae._atmosphereThicknessProp,Math.min(Math.max(0,e),5))}},{key:"skyTint",get:function(){return this.shaderData.getColor(ae._skyTintProp)},set:function(e){this.shaderData.setColor(ae._skyTintProp,e)}},{key:"groundTint",get:function(){return this.shaderData.getColor(ae._groundTintProp)},set:function(e){this.shaderData.setColor(ae._groundTintProp,e)}},{key:"exposure",get:function(){return this.shaderData.getFloat(ae._exposureProp)},set:function(e){this.shaderData.setFloat(ae._exposureProp,Math.min(Math.max(0,e),8))}}]),ae);hC._sunSizeProp=lV.getByName("material_SunSize"),hC._sunSizeConvergenceProp=lV.getByName("material_SunSizeConvergence"),hC._atmosphereThicknessProp=lV.getByName("material_AtmosphereThickness"),hC._skyTintProp=lV.getByName("material_SkyTint"),hC._groundTintProp=lV.getByName("material_GroundTint"),hC._exposureProp=lV.getByName("material_Exposure"),hC._sunHighQualityMacro=l0.getByName("MATERIAL_SUN_HIGH_QUALITY"),hC._sunSimpleMacro=l0.getByName("MATERIAL_SUN_SIMPLE"),(at=sV||(sV={}))[at.Position=1]="Position",at[at.Velocity=2]="Velocity",at[at.Acceleration=4]="Acceleration",at[at.Color=8]="Color",at[at.Alpha=16]="Alpha",at[at.Size=32]="Size",at[at.StartAngle=64]="StartAngle",at[at.StartTime=128]="StartTime",at[at.LifeTime=256]="LifeTime",at[at.RotateVelocity=512]="RotateVelocity",at[at.Scale=1024]="Scale",at[at.Everything=4294967295]="Everything",e.ParticleRendererBlendMode=void 0,(an=e.ParticleRendererBlendMode||(e.ParticleRendererBlendMode={}))[an.Transparent=0]="Transparent",an[an.Additive=1]="Additive";var hT=(la(ar=function(e){var t;return(t=cE.call(this,e)||this)._maxCount=1e3,t._position=new sQ,t._positionRandomness=new sQ,t._velocity=new sQ,t._velocityRandomness=new sQ,t._acceleration=new sQ,t._accelerationRandomness=new sQ,t._color=new s7(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(lt(t)),t._color._onValueChanged=t._onColorChanged,t.setMaterial(t._createMaterial()),t},cE),(ai=ar.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)}},ai._onEnable=function(){cE.prototype._onEnable.call(this),this._playOnEnable&&this.start()},ai.start=function(){this._isStart=!0,this._time=0},ai.stop=function(){this._isStart=!1},ai._createMaterial=function(){var t=new uw(this.engine,cn.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},ai._createMesh=function(){var t=new cO(this._entity.engine,"particleMesh"),n=4*this._maxCount,r=96*n,i=new Float32Array(r),a=null,o=!1;if(n>ar._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 cm("a_position",0,e.VertexElementFormat.Vector3,0),new cm("a_velocity",12,e.VertexElementFormat.Vector3,0),new cm("a_acceleration",24,e.VertexElementFormat.Vector3,0),new cm("a_color",36,e.VertexElementFormat.Vector4,0),new cm("a_lifeAndSize",52,e.VertexElementFormat.Vector4,0),new cm("a_rotation",68,e.VertexElementFormat.Vector2,0),new cm("a_uv",76,e.VertexElementFormat.Vector3,0),new cm("a_normalizedUv",88,e.VertexElementFormat.Vector2,0)],h=new cv(this.engine,e.BufferBindFlag.VertexBuffer,4*r,e.BufferUsage.Dynamic),d=new cv(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},ai._updateBuffer=function(){for(var e=0;e<this._maxCount;e++)this._updateSingleBuffer(e);this._vertexBuffer.setData(this._vertices)},ai._updateSingleBuffer=function(e){var t=this._updateDirtyFlag,n=this._vertices,r=this._vertexStride,i=ar._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 C=this._color,T=this._colorRandomness;n[o+9]=n[s+9]=n[l+9]=n[c+9]=sY.clamp(C.r+i()*T,0,1),n[o+10]=n[s+10]=n[l+10]=n[c+10]=sY.clamp(C.g+i()*T,0,1),n[o+11]=n[s+11]=n[l+11]=n[c+11]=sY.clamp(C.b+i()*T,0,1)}if(16&t&&(n[o+12]=n[s+12]=n[l+12]=n[c+12]=sY.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)},ai._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},ai._onColorChanged=function(){this._updateDirtyFlag|=8},ar._getRandom=function(){return Math.random()-.5},lr(ar,[{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}}]),ar);hT._uint16VertexLimit=65535,ll([lu],hT.prototype,"_onColorChanged",null),cn.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 hS=(la(aa=function(t){var n,r=(n=uw.call(this,t,cn.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},uw),aa),hw=new sQ,hA=(la(ao=function(e,t){(n=cE.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 sQ),n._pointStates.push(n._lifetime),n._strapPoints.push(new sQ),n._strapPoints.push(new sQ);n._curPointNum=0;var i=t.material||new hS(n.engine);return n.setMaterial(i),n.setTexture(t.texture),n._initGeometry(),n},cE),(as=ao.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];sQ.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++)},as.setTexture=function(e){e&&this.getMaterial().shaderData.setTexture("u_texture",e)},as._render=function(e){this._updateStrapVertices(e.camera,this._points),this._updateStrapCoords(),this._vertexBuffer.setData(this._vertices),cE.prototype._render.call(this,e)},as._initGeometry=function(){var t=new cO(this._entity.engine),n=2*this._maxPointNum,r=20*n,i=new Float32Array(r),a=[new cm("POSITION",0,e.VertexElementFormat.Vector3,0),new cm("TEXCOORD_0",12,e.VertexElementFormat.Vector2,0)],o=new cv(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},as._updateStrapVertices=function(e,t){var n=e.viewMatrix.elements,r=new sQ(n[0],n[4],n[8]),i=new sQ(n[1],n[5],n[9]),a=new sQ(n[2],n[6],n[10]),o=this._stroke;i.scale(o);var s=new sQ,l=new sQ,c=new s3;sQ.transformByQuat(r,c,r),sQ.transformByQuat(i,c,i);var u=new sQ,h=new sQ,d=new sQ;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?sQ.subtract(p,t[f-1],d):sQ.subtract(t[f+1],p,d),this._projectOnPlane(d,a,d),d.normalize();var g=Math.acos(sQ.dot(r,d));sQ.cross(r,d,h),0>=sQ.dot(h,a)&&(g=2*Math.PI-g),s3.rotationAxisAngle(a,g,c),sQ.transformByQuat(i,c,u),sQ.add(p,u,s),sQ.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}},as._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}}},as._projectOnVector=function(e,t,n){var r=t.clone();sQ.normalize(r,r);var i=sQ.dot(e,r);n.x=r.x*i,n.y=r.y*i,n.z=r.z*i},as._projectOnPlane=function(e,t,n){this._projectOnVector(e,t,hw),sQ.subtract(e,hw,n)},ao),hE=(la(al=function(){var t;return t=uR.apply(this,arguments)||this,t.probeLayer=e.Layer.Everything,t.width=1024,t.height=1024,t.antiAliasing=1,t._isCube=!1,t},uR),(ac=al.prototype).onTextureChange=function(e){},ac.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 lE(this.engine,this.width,this.height,this._isCube?new lR(this.engine,this.width):new lM(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._renderTargetSwap=new lE(this.engine,this.width,this.height,this._isCube?new lR(this.engine,this.width):new lM(this.engine,this.width,this.height),e.RenderBufferDepthFormat.Depth,this.antiAliasing),this._activeRenderTarget=this._renderTarget),this._oriCameraRenderTarget=t.renderTarget,t.renderTarget=this._activeRenderTarget)},ac.onEndRender=function(e){this.enabled&&(this.onTextureChange&&this.onTextureChange(this._texture),this._activeRenderTarget=this._activeRenderTarget===this._renderTarget?this._renderTargetSwap:this._renderTarget)},ac._reset=function(){this.enabled&&(this._camera.renderTarget=this._oriCameraRenderTarget,this._camera.cullingMask=this._oriCameraCullingMask)},lr(al,[{key:"_texture",get:function(){var e;return null==(e=this._activeRenderTarget)?void 0:e.getColorTexture()}}]),al),hM=new sQ,hb=new sQ,hR=new sQ,hF=(la(au=function(){var e;return e=hE.apply(this,arguments)||this,e.position=new sQ(0,0,0),e._isCube=!0,e.oriViewMatrix=new s4,e},hE),(ah=au.prototype).onBeginRender=function(t){if(this.enabled){hE.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),hE.prototype._reset.call(this)}},ah._storeCamera=function(e){this.oriViewMatrix.copyFrom(e.viewMatrix),this._oriFieldOfView=e.fieldOfView},ah._restoreCamera=function(e){e.viewMatrix.copyFrom(this.oriViewMatrix),e.fieldOfView=this._oriFieldOfView},ah._setCamera=function(e,t){switch(e){case 0:hb.set(0,-1,0),hR.set(1,0,0);break;case 1:hb.set(0,-1,0),hR.set(-1,0,0);break;case 2:hb.set(0,0,1),hR.set(0,1,0);break;case 3:hb.set(0,0,-1),hR.set(0,-1,0);break;case 4:hb.set(0,-1,0),hR.set(0,0,1);break;case 5:hb.set(0,-1,0),hR.set(0,0,-1)}sQ.add(this.position,hR,hM),s4.lookAt(this.position,hM,hb,t.viewMatrix),t.fieldOfView=90},au),hP=Object.freeze({__proto__:null,AmbientLight:cY,get AnimationArrayCurve(){return e.AnimationArrayCurve},get AnimationBoolCurve(){return e.AnimationBoolCurve},AnimationClip:ho,AnimationClipCurveBinding:hi,get AnimationColorCurve(){return e.AnimationColorCurve},AnimationCurve:hs,AnimationEvent:ha,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:h_,get AnimatorConditionMode(){return e.AnimatorConditionMode},AnimatorController:hf,AnimatorControllerLayer:hp,get AnimatorCullingMode(){return e.AnimatorCullingMode},get AnimatorLayerBlendingMode(){return e.AnimatorLayerBlendingMode},AnimatorState:hm,AnimatorStateMachine:hv,AnimatorStateTransition:hc,AssetPromise:cZ,get AssetType(){return e.AssetType},Background:cq,get BackgroundMode(){return e.BackgroundMode},get BackgroundTextureFillMode(){return e.BackgroundTextureFillMode},BaseMaterial:uK,Basic2DBatcher:ck,BasicRenderPipeline:uO,get BlendFactor(){return e.BlendFactor},get BlendMode(){return e.BlendMode},get BlendOperation(){return e.BlendOperation},BlendShape:cz,BlendShapeFrame:cU,BlendState:ca,BlinnPhongMaterial:uq,BoolUpdateFlag:lj,BoxColliderShape:un,Buffer:cv,get BufferBindFlag(){return e.BufferBindFlag},BufferMesh:cO,get BufferUsage(){return e.BufferUsage},BufferUtil:cg,get Camera(){return e.Camera},get CameraClearFlags(){return e.CameraClearFlags},CapsuleColliderShape:ua,CharacterController:ue,CloneManager:lf,get Collider(){return e.Collider},ColliderShape:ut,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:lm,get ControllerCollisionFlag(){return e.ControllerCollisionFlag},get ControllerNonWalkableMode(){return e.ControllerNonWalkableMode},CubeProbe:hF,get CullMode(){return e.CullMode},get DataType(){return e.DataType},get DependentMode(){return e.DependentMode},DepthState:co,get DiffuseMode(){return e.DiffuseMode},DirectLight:ux,DynamicCollider:u_,get DynamicColliderConstraints(){return e.DynamicColliderConstraints},Engine:ub,EngineObject:lp,Entity:lQ,EventDispatcher:lN,FixedJoint:us,get FogMode(){return e.FogMode},Font:lD,get FontStyle(){return e.FontStyle},get GLCapabilityType(){return e.GLCapabilityType},HingeJoint:ul,HitResult:c6,IndexBufferBinding:cy,get IndexFormat(){return e.IndexFormat},InputManager:uv,get InterpolationType(){return e.InterpolationType},get Joint(){return e.Joint},JointLimits:uu,JointMotor:uh,Keyframe:hy,get Keys(){return e.Keys},get Layer(){return e.Layer},Light:uy,Loader:uj,Logger:lw,Material:uw,Mesh:cC,MeshRenderer:cE,get MeshTopology(){return e.MeshTopology},ModelMesh:cw,get OverflowMode(){return e.OverflowMode},PBRBaseMaterial:uY,PBRMaterial:uQ,PBRSpecularMaterial:uJ,ParticleRenderer:hT,get ParticleRendererBlendMode(){return e.ParticleRendererBlendMode},PhysicsManager:c7,PhysicsMaterial:c9,get PhysicsMaterialCombineMode(){return e.PhysicsMaterialCombineMode},get PipelineStage(){return e.PipelineStage},PlaneColliderShape:ui,get Platform(){return e.Platform},PointLight:uC,Pointer:c4,get PointerButton(){return e.PointerButton},get PointerPhase(){return e.PointerPhase},PrimitiveMesh:cV,Probe:hE,RasterState:cs,ReferResource:lg,get RenderBufferDepthFormat(){return e.RenderBufferDepthFormat},get RenderFace(){return e.RenderFace},RenderPass:uV,RenderQueue:uP,get RenderQueueType(){return e.RenderQueueType},RenderState:cc,RenderTarget:lE,RenderTargetBlendState:ci,get Renderer(){return e.Renderer},ResourceManager:c$,Scene:cQ,SceneManager:cJ,Script:uR,get SetDataOptions(){return e.SetDataOptions},Shader:cn,ShaderData:cr,ShaderFactory:l4,ShaderMacro:l0,ShaderMacroCollection:l1,ShaderPass:ce,ShaderProperty:lV,get ShaderPropertyType(){return e.ShaderPropertyType},ShaderTagKey:l5,get ShadowCascadesMode(){return e.ShadowCascadesMode},get ShadowResolution(){return e.ShadowResolution},get ShadowType(){return e.ShadowType},Skin:cA,SkinnedMeshRenderer:cM,Sky:cK,SkyBoxMaterial:hx,SkyProceduralMaterial:hC,SphereColliderShape:ur,SpotLight:uT,SpringJoint:uc,Sprite:u0,SpriteAtlas:u$,get SpriteDrawMode(){return e.SpriteDrawMode},SpriteMask:cp,get SpriteMaskInteraction(){return e.SpriteMaskInteraction},get SpriteMaskLayer(){return e.SpriteMaskLayer},SpriteRenderer:u3,get SpriteTileMode(){return e.SpriteTileMode},StateMachineScript:hg,StaticCollider:ud,get StencilOperation(){return e.StencilOperation},StencilState:cl,SubMesh:cx,SubShader:ct,get SunMode(){return e.SunMode},SystemInfo:c5,get TextHorizontalAlignment(){return e.TextHorizontalAlignment},TextRenderer:u8,TextUtils:lP,get TextVerticalAlignment(){return e.TextVerticalAlignment},Texture:lA,Texture2D:lM,Texture2DArray:lb,get TextureCoordinate(){return e.TextureCoordinate},TextureCube:lR,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:lO,TrailMaterial:hS,TrailRenderer:hA,Transform:lq,UnlitMaterial:uZ,Utils:lG,VertexBufferBinding:cT,VertexElement:cm,get VertexElementFormat(){return e.VertexElementFormat},get WrapMode(){return e.WrapMode},assignmentClone:lh,deepClone:l_,dependentComponents:lk,ignoreClone:lu,request:uG,resourceLoader:c0,shallowClone:ld});function hL(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 hD(e,t,n){return t&&hL(e.prototype,t),n&&hL(e,n),e}function hI(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}e.GLCompressedTextureInternalFormat=void 0,(ad=e.GLCompressedTextureInternalFormat||(e.GLCompressedTextureInternalFormat={}))[ad.RGBA_ASTC_4X4_KHR=37808]="RGBA_ASTC_4X4_KHR",ad[ad.RGBA_ASTC_5X4_KHR=37809]="RGBA_ASTC_5X4_KHR",ad[ad.RGBA_ASTC_5X5_KHR=37810]="RGBA_ASTC_5X5_KHR",ad[ad.RGBA_ASTC_6X5_KHR=37811]="RGBA_ASTC_6X5_KHR",ad[ad.RGBA_ASTC_6X6_KHR=37812]="RGBA_ASTC_6X6_KHR",ad[ad.RGBA_ASTC_8X5_KHR=37813]="RGBA_ASTC_8X5_KHR",ad[ad.RGBA_ASTC_8X6_KHR=37814]="RGBA_ASTC_8X6_KHR",ad[ad.RGBA_ASTC_8X8_KHR=37815]="RGBA_ASTC_8X8_KHR",ad[ad.RGBA_ASTC_10X5_KHR=37816]="RGBA_ASTC_10X5_KHR",ad[ad.RGBA_ASTC_10X6_KHR=37817]="RGBA_ASTC_10X6_KHR",ad[ad.RGBA_ASTC_10X8_KHR=37818]="RGBA_ASTC_10X8_KHR",ad[ad.RGBA_ASTC_10X10_KHR=37819]="RGBA_ASTC_10X10_KHR",ad[ad.RGBA_ASTC_12X10_KHR=37820]="RGBA_ASTC_12X10_KHR",ad[ad.RGBA_ASTC_12X12_KHR=37821]="RGBA_ASTC_12X12_KHR",ad[ad.SRGB8_ALPHA8_ASTC_4X4_KHR=37840]="SRGB8_ALPHA8_ASTC_4X4_KHR",ad[ad.SRGB8_ALPHA8_ASTC_5X4_KHR=37841]="SRGB8_ALPHA8_ASTC_5X4_KHR",ad[ad.SRGB8_ALPHA8_ASTC_5X5_KHR=37842]="SRGB8_ALPHA8_ASTC_5X5_KHR",ad[ad.SRGB8_ALPHA8_ASTC_6X5_KHR=37843]="SRGB8_ALPHA8_ASTC_6X5_KHR",ad[ad.SRGB8_ALPHA8_ASTC_6X6_KHR=37844]="SRGB8_ALPHA8_ASTC_6X6_KHR",ad[ad.SRGB8_ALPHA8_ASTC_8X5_KHR=37845]="SRGB8_ALPHA8_ASTC_8X5_KHR",ad[ad.SRGB8_ALPHA8_ASTC_8X6_KHR=37846]="SRGB8_ALPHA8_ASTC_8X6_KHR",ad[ad.SRGB8_ALPHA8_ASTC_8X8_KHR=37847]="SRGB8_ALPHA8_ASTC_8X8_KHR",ad[ad.SRGB8_ALPHA8_ASTC_10X5_KHR=37848]="SRGB8_ALPHA8_ASTC_10X5_KHR",ad[ad.SRGB8_ALPHA8_ASTC_10X6_KHR=37849]="SRGB8_ALPHA8_ASTC_10X6_KHR",ad[ad.SRGB8_ALPHA8_ASTC_10X8_KHR=37850]="SRGB8_ALPHA8_ASTC_10X8_KHR",ad[ad.SRGB8_ALPHA8_ASTC_10X10_KHR=37851]="SRGB8_ALPHA8_ASTC_10X10_KHR",ad[ad.SRGB8_ALPHA8_ASTC_12X10_KHR=37852]="SRGB8_ALPHA8_ASTC_12X10_KHR",ad[ad.SRGB8_ALPHA8_ASTC_12X12_KHR=37853]="SRGB8_ALPHA8_ASTC_12X12_KHR",ad[ad.RGB_ETC1_WEBGL=36196]="RGB_ETC1_WEBGL",ad[ad.R11_EAC=37488]="R11_EAC",ad[ad.SIGNED_R11_EAC=37489]="SIGNED_R11_EAC",ad[ad.RG11_EAC=37490]="RG11_EAC",ad[ad.SIGNED_RG11_EAC=37491]="SIGNED_RG11_EAC",ad[ad.RGB8_ETC2=37492]="RGB8_ETC2",ad[ad.SRGB8_ETC2=37493]="SRGB8_ETC2",ad[ad.RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="RGB8_PUNCHTHROUGH_ALPHA1_ETC2",ad[ad.SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",ad[ad.RGBA8_ETC2_EAC=37496]="RGBA8_ETC2_EAC",ad[ad.SRGB8_ALPHA8_ETC2_EAC=37497]="SRGB8_ALPHA8_ETC2_EAC",ad[ad.RGB_PVRTC_4BPPV1_IMG=35840]="RGB_PVRTC_4BPPV1_IMG",ad[ad.RGB_PVRTC_2BPPV1_IMG=35841]="RGB_PVRTC_2BPPV1_IMG",ad[ad.RGBA_PVRTC_4BPPV1_IMG=35842]="RGBA_PVRTC_4BPPV1_IMG",ad[ad.RGBA_PVRTC_2BPPV1_IMG=35843]="RGBA_PVRTC_2BPPV1_IMG",ad[ad.RGB_S3TC_DXT1_EXT=33776]="RGB_S3TC_DXT1_EXT",ad[ad.RGBA_S3TC_DXT1_EXT=33777]="RGBA_S3TC_DXT1_EXT",ad[ad.RGBA_S3TC_DXT3_EXT=33778]="RGBA_S3TC_DXT3_EXT",ad[ad.RGBA_S3TC_DXT5_EXT=33779]="RGBA_S3TC_DXT5_EXT";var hB=((af=(a_=function(e){this._scale=new s8;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&&hI(t,OffscreenCanvas)||(this.width=t.clientWidth*e,this.height=t.clientHeight*e)},af.setScale=function(e,t){this._scale.set(e,t),this.scale=this._scale},hD(a_,[{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&&hI(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&&hI(t,OffscreenCanvas)||(t.style.transformOrigin="left top",t.style.transform="scale("+e.x+", "+e.y+")")}}]),a_);function hN(e,t){return(hN=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function hV(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&&hN(e,t)}var hO=(hV(ap=function(){return ub.apply(this,arguments)},ub),ap.create=function(e){var t=e.canvas,n=new hB("string"==typeof t?document.getElementById(t):t),r=new hQ(e.graphicDeviceOptions);return new ap(n,r,e)._initialize(e)},hD(ap,[{key:"canvas",get:function(){return this._canvas}}]),ap);function hU(){return(hU=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 hz=((am=(ag=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)},am.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)},am.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."},am.resize=function(e){this.bind(),this._gl.bufferData(this._glBindTarget,e,this._glBufferUsage)},am.destroy=function(){this._gl.deleteBuffer(this._glBuffer),this._gl=null,this._glBuffer=null},am._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}},ag),hk=((ay=(av=function(e){this._rhi=e,this.capabilityList=new Map,this._init(),this._compatibleAllInterface()}).prototype).canIUse=function(e){return this.capabilityList.get(e)},ay.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)},ay._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,C=e.GLCapabilityType.s3tc,T=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(C,!!(r(C)||r(T)))},ay._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}},ay._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,hU({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"})},hD(av,[{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}}]),av),hG=((ax=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]},ax),hH=((aT=(aC=function(t,n){this._attribLocArray=[],this._vaoMap=new Map,this._primitive=n,this._canUseInstancedArrays=t.canIUse(e.GLCapabilityType.instancedArrays),this._useVao=t.canIUse(e.GLCapabilityType.vertexArrayObject),this._gl=t.gl}).prototype).draw=function(e,t){var n=this._gl,r=this._primitive,i=this._useVao&&r._enableVAO;if(i){r._bufferStructChanged&&this._clearVAO(),this._vaoMap.has(e.id)||this._registerVAO(e);var a=this._vaoMap.get(e.id);n.bindVertexArray(a)}else this._bindBufferAndAttrib(e);var o=r._indexBufferBinding,s=r._instanceCount,l=r._glIndexType,c=r._glIndexByteCount,u=t.topology,h=t.start,d=t.count;if(s){if(this._canUseInstancedArrays){if(o){if(i)n.drawElementsInstanced(u,d,l,h*c,s);else{var _=o.buffer._platformBuffer._glBuffer;n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,_),n.drawElementsInstanced(u,d,l,h*c,s),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}}else n.drawArraysInstanced(u,h,d,s)}else lw.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()},aT.destroy=function(){this._useVao&&this._clearVAO()},aT._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 lw.warn("vertex attribute not found: "+l)}}r.bindBuffer(r.ARRAY_BUFFER,null)},aT._disableAttrib=function(){for(var e=this._gl,t=0,n=this._attribLocArray.length;t<n;t++)e.disableVertexAttribArray(this._attribLocArray[t])},aT._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)},aT._clearVAO=function(){var e=this._gl;this._vaoMap.forEach(function(t){e.deleteVertexArray(t)}),this._vaoMap.clear()},aC),hW=((aS=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]},aS),hX=((aA=(aw=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},aA.setUseDepthCompareMode=function(e){var t=this._gl;t.texParameteri(this._target,t.TEXTURE_COMPARE_MODE,e?t.COMPARE_REF_TO_TEXTURE:t.NONE)},aA.generateMipmaps=function(){(1!==this._texture.width||1!==this._texture.height)&&(this._bind(),this._gl.generateMipmap(this._target))},aA._bind=function(){this._rhi.bindTexture(this)},aA._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)}},aA._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,lw.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)},aA._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||aw._isPowerOf2(s)&&aw._isPowerOf2(l)||(lw.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)}},aA._getReadFrameBuffer=function(){var e=this._rhi._readFrameBuffer;return e||(this._rhi._readFrameBuffer=e=this._gl.createFramebuffer()),e},aw._isPowerOf2=function(e){return(e&e-1)==0},aw._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)}},aw._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)}},aw._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},aw._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},aw._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},hD(aw,[{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)}}}]),aw),hj=((aM=(aE=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=hI(i,lA),l=0,c=r.length;l<c;l++){var u=r[l]._format;if(!hX._supportRenderBufferColorFormat(u,t))throw Error("TextureFormat is not supported:"+e.TextureFormat[u]+" in RenderTarget")}if(!s&&!hX._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 hI(e,lR)}))throw Error("MRT+Cube+[,MSAA] is not supported");var h=t.capability.maxAntiAliasing;n.antiAliasing>h&&(lw.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=hI(a,lR);(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=hI(i,lR);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=hX._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()},aM.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)}},aM.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},aM._activeRenderTarget=function(){var e=this._gl;this._MSAAFrameBuffer?e.bindFramebuffer(e.FRAMEBUFFER,this._MSAAFrameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer)},aM._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,hI(c,lR)||e.framebufferTexture2D(e.FRAMEBUFFER,u,e.TEXTURE_2D,c._platformTexture._glTexture,0)}if(i>1&&e.drawBuffers(s),this._oriDrawBuffers=s,null!==r){if(hI(r,lA)&&!hI(r,lR)){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=hX._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)},aM._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=hI(i,lA)?i._platformTexture._formatDetail:hX._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)},aM._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.")},aE),hK=(hV(ab=function(t,n){(r=hX.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(!hX._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||l||hX._isPowerOf2(o)&&hX._isPowerOf2(s)||(lw.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=hX._getFormatDetail(i,r._gl,l),r._formatDetail.isCompressed&&!l||r._init(!1),r},hX),(aR=ab.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)},aR.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)},aR.getPixelBuffer=function(e,t,n,r,i,a){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hX.prototype._getPixelBuffer.call(this,null,e,t,n,r,i,a)},ab),hq=(hV(aF=function(t,n){r=hX.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(!hX._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return r._bind(),r._formatDetail=hX._getFormatDetail(i,r._gl,!0),r._gl.texStorage3D(r._target,l,r._formatDetail.internalFormat,a,o,s),r},hX),(aP=aF.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)},aP.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)},aP.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)},aF),hY=(hV(aL=function(t,n){(r=hX.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(!hX._supportTextureFormat(i,t))throw Error("Texture format is not supported:"+e.TextureFormat[i]);return!a||s||hX._isPowerOf2(o)||(lw.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=hX._getFormatDetail(i,r._gl,s),r._formatDetail.isCompressed&&!s||r._init(!0),r},hX),(aD=aL.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)},aD.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)},aD.getPixelBuffer=function(e,t,n,r,i,a,o){if(this._formatDetail.isCompressed)throw Error("Unable to read compressed texture");hX.prototype._getPixelBuffer.call(this,e,t,n,r,i,a,o)},aL);e.WebGLMode=void 0,(aI=e.WebGLMode||(e.WebGLMode={}))[aI.Auto=0]="Auto",aI[aI.WebGL2=1]="WebGL2",aI[aI.WebGL1=2]="WebGL1";var hQ=((aN=(aB=function(t){void 0===t&&(t={}),this._readFrameBuffer=null,this._enableGlobalDepthBias=!1,this._activeTextures=Array(32),this._lastViewport=new s6(null,null,null,null),this._lastScissor=new s6(null,null,null,null),this._lastClearColor=new s7(null,null,null,null),this._scissorEnable=!1;var n=hU({webGLMode:0,stencil:!0,_forceFlush:!1,_maxAllowSkinUniformVectorCount:256},t);if(c5.platform===e.Platform.IPhone||c5.platform===e.Platform.IPad){var r=c5.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&&hI(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&&hI(a,OffscreenCanvas)||(r=a.getContext("experimental-webgl",i)),this._isWebGL2=!1),!r)throw Error("Get GL Context FAILED.");this._gl=r,this._initGLState(r)},aN.createPlatformPrimitive=function(e){return new hH(this,e)},aN.createPlatformTexture2D=function(e){return new hK(this,e)},aN.createPlatformTexture2DArray=function(e){return new hq(this,e)},aN.createPlatformTextureCube=function(e){return new hY(this,e)},aN.createPlatformRenderTarget=function(e){return new hj(this,e)},aN.createPlatformBuffer=function(t,n,r,i){return void 0===r&&(r=e.BufferUsage.Static),new hz(this,t,n,r,i)},aN.requireExtension=function(e){return this._extensions.requireExtension(e)},aN.canIUse=function(e){return this.capability.canIUse(e)},aN.canIUseCompressedTextureInternalFormat=function(e){return this.capability.canIUseCompressedTextureInternalFormat(e)},aN.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))},aN.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)}},aN.colorMask=function(e,t,n,r){this._gl.colorMask(e,t,n,r)},aN.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)},aN.drawPrimitive=function(e,t,n){e?e._draw(n,t):lw.error("draw primitive failed.")},aN.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)},aN.activeTexture=function(e){this._activeTextureID!==e&&(this._gl.activeTexture(e),this._activeTextureID=e)},aN.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)},aN.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},aN.flush=function(){this._gl.flush()},aN.forceLoseDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).loseContext()},aN.forceRestoreDevice=function(){this.requireExtension(e.GLCapabilityType.WEBGL_lose_context).restoreContext()},aN.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)},aN._initGLState=function(e){this._activeTextureID=e.TEXTURE0,this._renderStates=new hW(e),this._extensions=new hG(this),this._capability=new hk(this),e.activeTexture(e.TEXTURE0);var t=e.getExtension("WEBGL_debug_renderer_info");null!=t&&(this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL))},aN.destroy=function(){var e=this._webCanvas;e.removeEventListener("webglcontextcreationerror",this._onContextCreationError,!1),e.removeEventListener("webglcontextlost",this._onWebGLContextLost,!1),e.removeEventListener("webglcontextrestored",this._onWebGLContextRestored,!1)},aN._onContextCreationError=function(e){console.error("WebGLRenderer: WebGL context could not be created. Reason: ",e.statusMessage)},aN._onWebGLContextLost=function(e){e.preventDefault(),this._onDeviceLost()},aN._onWebGLContextRestored=function(e){this._onDeviceRestored()},hD(aB,[{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}}]),aB);function hJ(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 hZ=((aO=(aV=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:lw.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},aO.addCurrentLoad=function(e){this._currentLoad+=e},aO.setCallback=function(e,t,n){this._callbacks[e]={resolve:t,reject:n}},aO.decode=function(e,t,n){this._worker.postMessage({type:"decode",id:e,taskConfig:t,buffer:n},[n])},aO.releaseTask=function(e){this._currentLoad-=this._costs[e],delete this._callbacks[e],delete this._costs[e]},hJ(aV.prototype,[{key:"currentLoad",get:function(){return this._currentLoad}}]),aU&&hJ(aV,aU),aV),h$='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',h0="https://gw.alipayobjects.com/os/lib/alipay/draco-javascript/1.3.6/lib/",h1=((ak=(az=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)lw.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?uG(""+h0+"draco_decoder_gltf.js",{type:"text"}).then(function(e){var n=[e,h$].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([n])),decoderWASMBinary:null})}).catch(function(e){n(e)}):Promise.all([uG(""+h0+"draco_wasm_wrapper_gltf.js",{type:"text"}),uG(""+h0+"draco_decoder_gltf.r3bin",{type:"arraybuffer"})]).then(function(e){var n=e[0],r=e[1],i=[n,h$].join("\n");t({workerSourceURL:URL.createObjectURL(new Blob([i])),decoderWASMBinary:r})}).catch(function(e){n(e)})})},ak.getWorker=function(){var e=this;return this.preloadLib().then(function(t){if(e.pool.length<e.workerLimit){var n=new hZ(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]})},ak.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},az);function h2(){return(h2=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 h3(e,t){return(h3=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h4(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&&h3(e,t)}function h5(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 h8(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 h6=(h4(aG=function(){return uj.apply(this,arguments)},uj),aG.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},e,{type:"json"})).then(function(e){var n=new hf,i=e.layers,a=[];i.forEach(function(e,r){var i=e.name,o=e.blendingMode,s=e.weight,l=e.stateMachine,c=new hp(i);if(c.blendingMode=o,c.weight=s,l){var u=l.states,h=c.stateMachine=new hv;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;var p=JSON.parse(_);null==p||p.forEach(function(e){f.addStateMachineScript(uj.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 hc;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)})},aG);h6=h5([c0(e.AssetType.AnimatorController,["json"],!1)],h6);var h7=(h4(aH=function(){return uj.apply(this,arguments)},uj),aH.prototype.load=function(e){var t=e.url;return/^data:(.+?);base64,/.test(t)?new cZ(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,h2({},e,{type:"arraybuffer"}))},aH);h7=h5([c0(e.AssetType.Buffer,["bin","r3bin"],!1)],h7);var h9=(h4(aW=function(){return uj.apply(this,arguments)},uj),aW.prototype.load=function(t,n){var r=this;return new cZ(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=n.engine,s=new lR(o,a);s.filterMode=e.TextureFilterMode.Trilinear;for(var l=s.mipmapCount,c=110,u=0;u<l;u++)for(var h=a>>u,d=0;d<6;d++){var _=h*h*4,f=new Uint8Array(t,c,_);c+=_,s.setPixelBuffer(e.TextureCubeFace.PositiveX+d,f,u)}var p=new cY(o),g=new le;p.diffuseMode=e.DiffuseMode.SphericalHarmonics,g.copyFromArray(r),p.diffuseSphericalHarmonics=g,p.specularTexture=s,p.specularTextureDecodeRGBM=!0,i(p)}).catch(function(e){a(e)})})},aW);function de(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 dt(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function o(e){de(a,r,i,o,s,"next",e)}function s(e){de(a,r,i,o,s,"throw",e)}o(void 0)})}}h9=h5([c0(e.AssetType.Env,["env"])],h9);var dn=(h4(aX=function(){return uj.apply(this,arguments)},uj),(aj=aX.prototype).load=function(e,t){var n=this;return new cZ(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 lD(t.engine,a))}).catch(function(e){i("load font "+o+" fail")}):r(new lD(t.engine,a))}).catch(function(e){i(e)})})},aj._registerFont=function(e,t){return dt(function(){var n;return h8(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]}})})()},aX);function dr(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 di(e,t){if(e){if("string"==typeof e)return dr(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 dr(e,t)}}function da(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=di(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.")}dn=h5([c0(e.AssetType.Font,["font"],!1)],dn);var ds=(h4(aK=function(){var e;return e=lm.apply(this,arguments)||this,e.bufferRequests=[],e.glbBufferSlices=[],e.bufferTextures=[],e.meshes=[],e},lm),(aq=aK.prototype).restoreContent=function(){var e=this;return new cZ(function(t,n){Promise.all(e.bufferRequests.map(function(e){return uG(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)}}cZ.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 dy.loadImageBuffer(a,e.mimeType).then(function(t){e.texture.setImageSource(t),e.texture.generateMipmaps()})})).then(function(){for(var n,i=da(e.meshes);!(n=i()).done;){for(var a,o=n.value,s=o.mesh,l=da(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,_=da(o.blendShapes);!(d=_()).done;){var f=d.value,p=f.blendShape.frames[0],g=f.position,m=e._getBufferData(r,g.buffer);if(p.deltaPositions=dy.bufferToVector3Array(m,g.stride,g.byteOffset,g.count),f.normal){var v=f.normal,y=e._getBufferData(r,v.buffer);p.deltaNormals=dy.bufferToVector3Array(y,v.stride,v.byteOffset,v.count)}if(f.tangent){var x=f.tangent,C=e._getBufferData(r,x.buffer);p.deltaTangents=dy.bufferToVector3Array(C,x.stride,x.byteOffset,x.count)}}s.uploadData(!0)}t(e.resource)}).catch(n)}).catch(n)})},aq._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},aK),dl=function(e,t){this.url=e,this.config=t},dc=function(e,t,n){this.texture=e,this.bufferView=t,this.mimeType=n},du=function(){this.vertexBuffers=[],this.blendShapes=[]},dh=function(e,t){this.buffer=e,this.data=t},dd=function(e,t,n,r,i){this.main=e,this.typeSize=t,this.sparseCount=n,this.sparseIndices=r,this.sparseValues=i},d_=function(e,t,n,r){this.bufferIndex=e,this.TypedArray=t,this.byteOffset=n,this.length=r},df=function(e,t,n,r){this.blendShape=e,this.position=t,this.normal=n,this.tangent=r},dp=function(e,t,n,r){this.buffer=e,this.stride=t,this.byteOffset=n,this.count=r};(aY=sO||(sO={}))[aY.BYTE=5120]="BYTE",aY[aY.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",aY[aY.SHORT=5122]="SHORT",aY[aY.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",aY[aY.UNSIGNED_INT=5125]="UNSIGNED_INT",aY[aY.FLOAT=5126]="FLOAT",(aQ=sU||(sU={})).SCALAR="SCALAR",aQ.VEC2="VEC2",aQ.VEC3="VEC3",aQ.VEC4="VEC4",aQ.MAT2="MAT2",aQ.MAT3="MAT3",aQ.MAT4="MAT4",(aJ=sz||(sz={})).TRANSLATION="translation",aJ.ROTATION="rotation",aJ.SCALE="scale",aJ.WEIGHTS="weights",(aZ=sk||(sk={})).Linear="LINEAR",aZ.Step="STEP",aZ.CubicSpine="CUBICSPLINE",(a$=sG||(sG={})).PERSPECTIVE="perspective",a$.ORTHOGRAPHIC="orthographic",(a0=sH||(sH={})).JPEG="image/jpeg",a0.PNG="image/png",(a1=sW||(sW={})).OPAQUE="OPAQUE",a1.MASK="MASK",a1.BLEND="BLEND",(a2=sX||(sX={}))[a2.NEAREST=9728]="NEAREST",a2[a2.LINEAR=9729]="LINEAR",(a3=sj||(sj={}))[a3.NEAREST=9728]="NEAREST",a3[a3.LINEAR=9729]="LINEAR",a3[a3.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",a3[a3.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",a3[a3.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",a3[a3.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",(a4=sK||(sK={}))[a4.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",a4[a4.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",a4[a4.REPEAT=10497]="REPEAT";var dg=((a8=(a5=function(e){this.hasSkinned=!1,this.chainPromises=[],this.accessorBufferCache={},this.texturesPromiseInfo=new dv,this.materialsPromiseInfo=new dv,this.meshesPromiseInfo=new dv,this.animationClipsPromiseInfo=new dv,this.defaultSceneRootPromiseInfo=new dv,this.masterPromiseInfo=new dv,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).getBuffers=function(){return Promise.resolve(this._buffers)},a8._initPromiseInfo=function(e){var t=new cZ(function(t,n,r,i){e.resolve=t,e.reject=n,e.setProgress=r,e.onCancel=i});return e.promise=t,t},a5),dm=function(e,t,n){this.data=e,this.interleaved=t,this.stride=n,this.vertexBindingInfos={}},dv=function(){},dy=((a6=function(){}).floatBufferToVector2Array=function(e){for(var t=e.length,n=Array(t/2),r=0;r<t;r+=2)n[r/2]=new s8(e[r],e[r+1]);return n},a6.floatBufferToVector3Array=function(e){for(var t=e.length,n=Array(t/3),r=0;r<t;r+=3)n[r/3]=new sQ(e[r],e[r+1],e[r+2]);return n},a6.floatBufferToVector4Array=function(e){for(var t=e.length,n=Array(t/4),r=0;r<t;r+=4)n[r/4]=new s6(e[r],e[r+1],e[r+2],e[r+3]);return n},a6.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 s7(e[i],e[i+1],e[i+2],1);else for(var a=0;a<n;a+=4)r[a/4]=new s7(e[a],e[a+1],e[a+2],e[a+3]);return r},a6.getAccessorTypeSize=function(e){switch(e){case sU.SCALAR:return 1;case sU.VEC2:return 2;case sU.VEC3:return 3;case sU.VEC4:case sU.MAT2:return 4;case sU.MAT3:return 9;case sU.MAT4:return 16}},a6.getComponentType=function(e){switch(e){case sO.BYTE:return Int8Array;case sO.UNSIGNED_BYTE:return Uint8Array;case sO.SHORT:return Int16Array;case sO.UNSIGNED_SHORT:return Uint16Array;case sO.UNSIGNED_INT:return Uint32Array;case sO.FLOAT:return Float32Array}},a6.getNormalizedComponentScale=function(e){switch(e){case sO.BYTE:return 1/127;case sO.UNSIGNED_BYTE:return 1/255;case sO.SHORT:return 1/32767;case sO.UNSIGNED_SHORT:return 1/65535;default:throw Error("Galacean.GLTFLoader: Unsupported normalized accessor component type.")}},a6.getAccessorBuffer=function(e,t,n){var r=n.componentType,i=t[n.bufferView];return e.getBuffers().then(function(a){var o,s,l,c=i.buffer,u=a[c],h=null!=(o=i.byteOffset)?o:0,d=null!=(s=n.byteOffset)?s:0,_=a6.getComponentType(r),f=a6.getAccessorTypeSize(n.type),p=_.BYTES_PER_ELEMENT,g=f*p,m=n.count,v=i.byteStride;if(void 0!==v&&v!==g){var y=Math.floor(d/v),x=n.bufferView+":"+r+":"+y+":"+m,C=e.accessorBufferCache;if(!(l=C[x])){var T=h+y*v,S=m*(v/p),w=new _(u,T,S);C[x]=l=new dm(w,!0,v),l.restoreInfo=new dd(new d_(c,_,T,S))}}else{var A=h+d,E=m*f,M=new _(u,A,E);(l=new dm(M,!1,g)).restoreInfo=new dd(new d_(c,_,A,E))}return n.sparse&&a6.processingSparseData(t,n,a,l),l})},a6.bufferToVector3Array=function(e,t,n,r){for(var i=e.BYTES_PER_ELEMENT,a=n%t/i,o=t/i,s=Array(r),l=0;l<r;l++){var c=a+l*o;s[l]=new sQ(e[c],e[c+1],e[c+2])}return s},a6.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=a6.getAccessorTypeSize(t.type),u=c*t.count,h=null!=(v=i.byteStride)?v:0,d=a6.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,C,T,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!=(C=b.byteOffset)?C:0),D=b.byteLength,I=(null!=(T=M.byteOffset)?T:0)+(null!=(S=R.byteOffset)?S:0),B=R.byteLength,N=a6.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},a6.getBufferViewData=function(e,t){var n=e.byteOffset,r=void 0===n?0:n;return t[e.buffer].slice(r,r+e.byteLength)},a6.processingSparseData=function(e,t,n,r){var i,a,o,s,l=r.restoreInfo,c=a6.getAccessorTypeSize(t.type),u=a6.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],C=n[y],T=(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=a6.getComponentType(f.componentType),M=S/E.BYTES_PER_ELEMENT,b=new E(x,T,M);l.sparseIndices=new d_(v,E,T,M);var R=A/u.BYTES_PER_ELEMENT,F=new u(C,w,R);l.sparseValues=new d_(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},a6.getIndexFormat=function(t){switch(t){case sO.UNSIGNED_BYTE:return e.IndexFormat.UInt8;case sO.UNSIGNED_SHORT:return e.IndexFormat.UInt16;case sO.UNSIGNED_INT:return e.IndexFormat.UInt32}},a6.getElementFormat=function(t,n,r){if(void 0===r&&(r=!1),t==sO.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==sO.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==sO.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==sO.BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedByte4:e.VertexElementFormat.Byte4}if(t==sO.UNSIGNED_BYTE)switch(n){case 2:case 3:case 4:return r?e.VertexElementFormat.NormalizedUByte4:e.VertexElementFormat.UByte4}},a6.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)})},a6.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 s8(d,a)),u+=a+8}return{glTF:l,buffers:c}},a6._formatRelativePath=function(e){return e.split("/").filter(Boolean).reduce(function(e,t){return".."===t?e.pop():"."!==t&&e.push(t),e},[]).join("/")},a6);function dx(e){return function(e){if(Array.isArray(e))return dr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||di(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var dC=((a9=(a7=function(){}).prototype).initialize=function(){},a9.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."},a9.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."},a7);e.GLTFExtensionMode=void 0,(oe=e.GLTFExtensionMode||(e.GLTFExtensionMode={}))[oe.CreateAndParse=0]="CreateAndParse",oe[oe.AdditiveParse=1]="AdditiveParse";var dT=((ot=function(){}).executeExtensionsInitialize=function(e){var t=ot._extensionParsers[e],n=null==t?void 0:t.length;if(n)return t[n-1].initialize()},ot.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=ot._createAndParse.apply(ot,[c,t,u,n].concat(dx(i))))return o}},ot.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];ot._additiveParse.apply(ot,[s,t,n,l,r].concat(dx(a)))}},ot.hasExtensionParser=function(e){var t;return!!(null==(t=ot._extensionParsers[e])?void 0:t.length)},ot.getExtensionParser=function(e,t){var n=ot._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}},ot._addExtensionParser=function(e,t){ot._extensionParsers[e]||(ot._extensionParsers[e]=[]),ot._extensionParsers[e].push(t)},ot._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=ot.getExtensionParser(t,e.GLTFExtensionMode.CreateAndParse);if(l)return l.createAndParse.apply(l,[n,r,i].concat(dx(o)))},ot._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=ot.getExtensionParser(t,e.GLTFExtensionMode.AdditiveParse);c&&c.additiveParse.apply(c,[n,r,i,a].concat(dx(s)))},ot);function dS(e,t){return function(n){var r=new n;r._mode=t,dT._addExtensionParser(e,r)}}dT._extensionParsers={};var dw=(h4(on=function(){return dT.apply(this,arguments)},dT),on.prototype.parse=function(e){var t=e.glTF,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=[],l=0;l<a;l++){var c=r[l],u=c.name,h=void 0===u?"AnimationClip"+l:u,d=dT.executeExtensionsCreateAndParse(c.extensions,e,c);d||(d=new ho(h),s.push(on._parseStandardProperty(e,d,c))),o.push(d)}return cZ.all(s).then(function(){return cZ.all(o).then(function(r){n.animations=r;for(var a=0;a<t.animations.length;a++){var o=t.animations[a];dT.executeExtensionsAdditiveAndParse(o.extensions,e,r[a],o)}return i.resolve(r),i.promise})})}},on._parseStandardProperty=function(t,n,r){for(var i=this,a=t.glTF,o=t.glTFResource.entities,s=a.accessors,l=a.bufferViews,c=r.channels,u=r.samplers,h=[],d=[],_=0,f=u.length;_<f;_++)!function(n,r){var i=u[n],a=s[i.input],o=s[i.output],c=Promise.all([dy.getAccessorBuffer(t,l,a),dy.getAccessorBuffer(t,l,o)]).then(function(t){var n,r,a=t[0].data,s=t[1].data;if(o.normalized){for(var l=dy.getNormalizedComponentScale(o.componentType),c=new Float32Array(s.length),u=0,d=s.length;u<d;u++)c[u]=s[u]*l;s=c}var _=s.length/a.length;switch(null!=(n=i.interpolation)?n:sk.Linear){case sk.CubicSpine:r=e.InterpolationType.CubicSpine;break;case sk.Step:r=e.InterpolationType.Step;break;case sk.Linear:r=e.InterpolationType.Linear}a[a.length-1],h.push({type:o.type,interpolation:r,input:a,output:s,outputSize:_})});d.push(c)}(_);return Promise.all(d).then(function(){for(var e=0,t=c.length;e<t;e++){for(var r=c[e],a=r.target,s=o[a.node],l="",u=s;u.parent;)l=""===l?""+u.name:u.name+"/"+l,u=u.parent;var d=void 0,_=void 0;switch(a.path){case sz.TRANSLATION:d=lq,_="position";break;case sz.ROTATION:d=lq,_="rotationQuaternion";break;case sz.SCALE:d=lq,_="scale";break;case sz.WEIGHTS:d=cM,_="blendShapeWeights"}var f=i._addCurve(a.path,r,h);n.addCurveBinding(l,d,_,f)}})},on._addCurve=function(t,n,r){var i=r[n.sampler],a=i.input,o=i.output,s=i.outputSize;switch(t){case sz.TRANSLATION:case sz.SCALE:for(var l=new e.AnimationVector3Curve,c=l.interpolation=i.interpolation,u=0,h=0,d=a.length;h<d;h++){var _=new hy;_.time=a[h],c===e.InterpolationType.CubicSpine?(_.inTangent=new sQ(o[u++],o[u++],o[u++]),_.value=new sQ(o[u++],o[u++],o[u++]),_.outTangent=new sQ(o[u++],o[u++],o[u++])):_.value=new sQ(o[u++],o[u++],o[u++]),l.addKey(_)}return l;case sz.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 hy;y.time=a[m],p===e.InterpolationType.CubicSpine?(y.inTangent=new s6(o[g++],o[g++],o[g++],o[g++]),y.value=new s3(o[g++],o[g++],o[g++],o[g++]),y.outTangent=new s6(o[g++],o[g++],o[g++],o[g++])):y.value=new s3(o[g++],o[g++],o[g++],o[g++]),f.addKey(y)}return f;case sz.WEIGHTS:var x=new e.AnimationFloatArrayCurve;x.interpolation=i.interpolation;for(var C=0,T=0,S=a.length;T<S;T++){var w=new hy;w.time=a[T],x.interpolation===e.InterpolationType.CubicSpine?(w.inTangent=Array.from(o.subarray(C,C+s)),C+=s,w.value=o.subarray(C,C+s),C+=s,w.outTangent=Array.from(o.subarray(C,C+s)),C+=s):(w.value=o.subarray(C,C+s),C+=s),x.addKey(w)}return x}},on),dA=(h4(or=function(){return dT.apply(this,arguments)},dT),(oi=or.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)?uG(r,a).then(function(t){return i.push(new dl(r,a)),dy.parseGLB(e,t)}).then(function(t){var n=t.glTF,r=t.buffers;e.glTF=n,e._buffers=r}):uG(r,{type:"json"}).then(function(t){e.glTF=t,e._buffers=Promise.all(t.buffers.map(function(e){var t=lG.resolveAbsoluteUrl(r,e.uri);return i.push(new dl(t,a)),uG(t,a)}))})},oi._isGLB=function(e){var t=e.lastIndexOf(".");return"glb"===e.substring(t+1,t+4)},or),dE=(h4(oa=function(){return dT.apply(this,arguments)},dT),(oo=oa.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||""+oa._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)}},oo._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)}}},oo._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}s[l]._hookResource=t,t._addReferCount(1)}}t.sceneRoots=s,t.defaultSceneRoot=s[void 0===r?0:r]}},oa);dE._defaultName="_GLTF_ENTITY_";var dM=(h4(os=function(){return dT.apply(this,arguments)},dT),os.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=dT.executeExtensionsCreateAndParse(s.extensions,e,s);l||((l=new uQ(i)).name=s.name,os._parseStandardProperty(e,l,s)),a.push(l)}return cZ.all(a).then(function(i){n.materials=i;for(var a=0;a<t.materials.length;a++){var o=t.materials[a];dT.executeExtensionsAdditiveAndParse(o.extensions,e,i[a],o)}return r.resolve(i),r.promise})}},os._checkOtherTextureTransform=function(e,t){var n;(null==(n=e.extensions)?void 0:n.KHR_texture_transform)&&lw.warn(""+t+" texture always use the KHR_texture_transform of the base texture.")},os._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 s7(s7.linearToGammaSpace(_[0]),s7.linearToGammaSpace(_[1]),s7.linearToGammaSpace(_[2]),_[3])),f&&(n.baseTexture=i[f.index],dT.executeExtensionsAdditiveAndParse(f.extensions,t,n,f)),n.constructor===uQ&&(n.metallic=null!=p?p:1,n.roughness=null!=g?g:1,m&&(n.roughnessMetallicTexture=i[m.index],os._checkOtherTextureTransform(m,"Roughness metallic")))}if(n.constructor===uQ||n.constructor===uJ){if(l&&(n.emissiveTexture=i[l.index],os._checkOtherTextureTransform(l,"Emissive")),c&&(n.emissiveColor=new s7(s7.linearToGammaSpace(c[0]),s7.linearToGammaSpace(c[1]),s7.linearToGammaSpace(c[2]))),o){var v=o.index,y=o.scale;n.normalTexture=i[v],os._checkOtherTextureTransform(o,"Normal"),void 0!==y&&(n.normalTextureIntensity=y)}if(s){var x=s.index,C=s.strength,T=s.texCoord;n.occlusionTexture=i[x],os._checkOtherTextureTransform(s,"Occlusion"),void 0!==C&&(n.occlusionTextureIntensity=C),T===e.TextureCoordinate.UV1?n.occlusionTextureCoord=e.TextureCoordinate.UV1:T>e.TextureCoordinate.UV1&&lw.warn("Occlusion texture uv coordinate must be UV0 or UV1.")}}switch(d?n.renderFace=e.RenderFace.Double:n.renderFace=e.RenderFace.Front,u){case sW.OPAQUE:n.isTransparent=!1;break;case sW.BLEND:n.isTransparent=!0;break;case sW.MASK:n.alphaCutoff=null!=h?h:.5}},os);function db(e,n){return null!=n&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):t(e,n)}var dR=(h4(ol=function(){return dT.apply(this,arguments)},dT),ol.prototype.parse=function(e){var t=e.glTF,n=e.glTFResource,r=n.engine;if(t.meshes){for(var i=e.meshesPromiseInfo,a=[],o=0;o<t.meshes.length;o++)!function(n){for(var i=function(n){var i=o.primitives[n];s[n]=new Promise(function(a){var s=dT.executeExtensionsCreateAndParse(i.extensions,e,i,o);if(s)db(s,cw)?a(s):s.then(function(e){return a(e)});else{var l=new cw(r,o.name||n+""),c=new du;c.mesh=l,e.contentRestorer.meshes.push(c),ol._parseMeshFromGLTFPrimitive(e,l,c,o,i,t,function(e){return null},function(n,r){var a=i.targets[r][n];if(!a)return null;var o=t.accessors[a];return dy.getAccessorBuffer(e,e.glTF.bufferViews,o)},function(){var n=t.accessors[i.indices];return e.getBuffers().then(function(e){return dy.getAccessorData(t,n,e)})},e.keepMeshData).then(a)}})},o=t.meshes[n],s=[],l=0;l<o.primitives.length;l++)i(l);a[n]=Promise.all(s)}(o);return cZ.all(a).then(function(e){n.meshes=e,i.resolve(e)}).catch(i.reject),i.promise}},ol._parseMeshFromGLTFPrimitive=function(t,n,r,i,a,o,s,l,c,u){var h,d,_,f,p=function(i){var a=g[m[i]],s=dy.getAccessorBuffer(t,o.bufferViews,a).then(function(t){var o,s,l,c=dy.getAccessorTypeSize(a.type),p=a.count,g=t.data,m=n.instanceId,v=t.vertexBindingInfos,y=a.normalized,x=dy.getElementFormat(a.componentType,c,y);if(y&&(s=dy.getNormalizedComponentScale(a.componentType)),t.interleaved){var w=a.byteOffset||0,A=t.stride;if(l=w%A,void 0===v[m]){o=new cm(i,l,x,S);var E=t.vertexBuffer;E||((E=new cv(C,e.BufferBindFlag.VertexBuffer,g.byteLength,e.BufferUsage.Static)).setData(g),t.vertexBuffer=E,r.vertexBuffers.push(new dh(E,t.restoreInfo))),n.setVertexBufferBinding(E,A,S),v[m]=S++}else o=new cm(i,l,x,v[m])}else{l=0,o=new cm(i,l,x,S);var M=new cv(C,e.BufferBindFlag.VertexBuffer,g.byteLength,e.BufferUsage.Static);M.setData(g),r.vertexBuffers.push(new dh(M,t.restoreInfo)),n.setVertexBufferBinding(M,t.stride,S),v[m]=S++}if(T.push(o),"POSITION"===i){h=p;var b=n.bounds,R=b.min,F=b.max;if(a.min&&a.max){if(R.copyFromArray(a.min),F.copyFromArray(a.max),u)for(var P=l/g.BYTES_PER_ELEMENT,L=g.length/p,D=0;D<p;D++){var I=P+D*L,B=new sQ(g[I],g[I+1],g[I+2]);y&&B.scale(s),d[D]=B}}else{var N=ol._tempVector3;R.set(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),F.set(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);for(var V=l/g.BYTES_PER_ELEMENT,O=g.length/p,U=0;U<p;U++){var z=V+U*O;if(N.copyFromArray(g,z),sQ.min(R,N,R),sQ.max(F,N,F),u){var k=N.clone();y&&k.scale(s),d[U]=k}}}y&&(R.scale(s),F.scale(s))}else if("JOINTS_0"===i&&u)for(var G=l/g.BYTES_PER_ELEMENT,H=g.length/p,W=0;W<p;W++){var X=G+W*H,j=new s6(g[X],g[X+1],g[X+2],g[X+3]);y&&j.scale(s),_[W]=j}else if("WEIGHTS_0"===i&&u)for(var K=l/g.BYTES_PER_ELEMENT,q=g.length/p,Y=0;Y<p;Y++){var Q=K+Y*q,J=new s6(g[Q],g[Q+1],g[Q+2],g[Q+3]);y&&J.scale(s),f[Y]=J}});w.push(s)},g=o.accessors,m=a.attributes,v=a.targets,y=a.indices,x=a.mode,C=n.engine,T=[],S=0;u&&(d=Array(h),_=Array(h),f=Array(h));var w=[];for(var A in m)p(A);return Promise.all(w).then(function(){if(n.setVertexElements(T),void 0!==y){var e=o.accessors[y],a=dy.getAccessorBuffer(t,o.bufferViews,e).then(function(t){n.setIndices(t.data),n.addSubMesh(0,e.count,x),r.indexBuffer=t.restoreInfo});w.push(a)}else n.addSubMesh(0,h,x);return v&&w.push(ol._createBlendShape(n,r,i,g,v,l)),Promise.all(w).then(function(){return n.uploadData(!u),n._positions=d,n._boneIndices=_,n._boneWeights=f,Promise.resolve(n)})})},ol._createBlendShape=function(e,t,n,r,i,a){for(var o=function(n,o){var c=s?s[n]:"blendShape"+n,u=Promise.all([a("POSITION",n),a("NORMAL",n),a("TANGENT",n)]).then(function(a){var o,s,l,u,h,d,_,f,p,g=a[0],m=a[1],v=a[2],y=i[n],x=null;g&&(o=r[y.POSITION],x=dy.bufferToVector3Array(g.data,g.stride,null!=(u=o.byteOffset)?u:0,o.count));var C=null;m&&(s=r[y.NORMAL],C=dy.bufferToVector3Array(m.data,m.stride,null!=(h=s.byteOffset)?h:0,s.count));var T=null;v&&(l=r[y.NORMAL],T=dy.bufferToVector3Array(v.data,v.stride,null!=(d=l.byteOffset)?d:0,l.count));var S=new cz(c);S.addFrame(1,x,C,T),e.addBlendShape(S),t.blendShapes.push(new df(S,new dp(g.restoreInfo,g.stride,null!=(_=o.byteOffset)?_:0,o.count),m?new dp(m.restoreInfo,m.stride,null!=(f=s.byteOffset)?f:0,s.count):null,v?new dp(v.restoreInfo,v.stride,null!=(p=l.byteOffset)?p:0,l.count):null))});l.push(u)},s=n.extras?n.extras.targetNames:null,l=[],c=0,u=i.length;c<u;c++)o(c);return Promise.all(l)},ol);dR._tempVector3=new sQ;var dF=(h4(oc=function(){return dT.apply(this,arguments)},dT),(ou=oc.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),dT.executeExtensionsAdditiveAndParse(h,e,d,l)}return t.defaultSceneRoot&&this._createAnimator(e),o.resolve(t.defaultSceneRoot),o.promise}},ou._createCamera=function(t,n,r){var i=n.orthographic,a=n.perspective,o=n.type,s=r.addComponent(e.Camera);if(o===sG.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===sG.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},ou._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(cM);f.mesh=i,void 0!==u&&(f.skin=l[u]),_&&(f.blendShapeWeights=new Float32Array(_)),h=f}else(h=n.addComponent(cE)).mesh=i;var p=r.material,g=(null==s?void 0:s[p])||oc._getDefaultMaterial(a);h.setMaterial(g),i.vertexElements.forEach(function(e){"COLOR_0"===e.semantic&&(h.enableVertexColor=!0)}),dT.executeExtensionsAdditiveAndParse(r.extensions,e,h,r)}(f)},ou._createAnimator=function(e){if(e.hasSkinned||e.glTFResource.animations){var t=e.glTFResource,n=t.defaultSceneRoot,r=t.animations,i=n.addComponent(h_),a=new hf,o=new hp("layer"),s=new hv;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}}},oc._getDefaultMaterial=function(e){return oc._defaultMaterial||(oc._defaultMaterial=new uq(e)),oc._defaultMaterial},oc),dP=(h4(oh=function(){return dT.apply(this,arguments)},dT),(od=oh.prototype).parse=function(e){var t=this,n=e.glTFResource,r=e.glTF,i=n.entities,a=r.skins;if(a){for(var o=a.length,s=[],l=0;l<o;l++)!function(n){var o=a[n],l=o.inverseBindMatrices,c=o.skeleton,u=o.joints,h=o.name,d=u.length,_=new cA(void 0===h?"SKIN_"+n:h);_.inverseBindMatrices.length=d;var f=r.accessors[l],p=dy.getAccessorBuffer(e,r.bufferViews,f).then(function(e){for(var n=e.data,r=0;r<d;r++){var a=new s4;a.copyFromArray(n,16*r),_.inverseBindMatrices[r]=a;for(var o=0;o<d;o++){var s=u[o],l=i[s].name;_.joints[o]=l;for(var h=i.length-1;h>=0;h--)s!==h&&i[h].name===l&&(i[h].name=l+"_"+h)}if(void 0!==c)_.skeleton=i[c].name;else{var f=t._findSkeletonRootBone(u,i);if(f)_.skeleton=f.name;else throw"Failed to find skeleton root bone."}}return _});s.push(p)}(l);return cZ.all(s).then(function(e){n.skins=e})}},od._findSkeletonRootBone=function(e,t){for(var n,r={},i=da(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}},oh),dL=(h4(o_=function(){return dT.apply(this,arguments)},dT),(of=o_.prototype).parse=function(t){var n=this,r=t.glTFResource,i=t.glTF,a=r.engine,o=r.url;if(i.textures){var s=t.texturesPromiseInfo;return cZ.all(i.textures.map(function(r,s){var l=r.sampler,c=r.source,u=r.name,h=i.images[void 0===c?0:c],d=h.uri,_=h.bufferView,f=h.mimeType,p=h.name,g=void 0!==l&&n._getSamplerInfo(i.samplers[l]);if(d){var m=d.lastIndexOf("."),v=d.substring(m+1).startsWith("ktx")?e.AssetType.KTX:e.AssetType.Texture2D;return a.resourceManager.load({url:lG.resolveAbsoluteUrl(o,d),type:v,params:{mipmap:null==g?void 0:g.mipmap}}).then(function(e){return e.name||(e.name=u||p||"texture_"+m),void 0!==l&&n._parseSampler(e,g),e})}var y=i.bufferViews[_];return t.getBuffers().then(function(e){var r=e[y.buffer],i=new Uint8Array(r,y.byteOffset,y.byteLength);return dy.loadImageBuffer(i,f).then(function(e){var r=new lM(a,e.width,e.height,void 0,null==g?void 0:g.mipmap);r.setImageSource(e),r.generateMipmaps(),r.name=u||p||"texture_"+s,void 0!==l&&n._parseSampler(r,g);var i=new dc(r,y,f);return t.contentRestorer.bufferTextures.push(i),r})})})).then(function(e){r.textures=e,s.resolve(e)}).catch(s.reject),s.promise}},of._getSamplerInfo=function(t){var n=t.minFilter,r=t.magFilter,i=t.wrapS,a=t.wrapT,o={};return(n||r)&&(o.mipmap=n>=sj.NEAREST_MIPMAP_NEAREST,r===sX.NEAREST?o.filterMode=e.TextureFilterMode.Point:n<=sj.LINEAR_MIPMAP_NEAREST?o.filterMode=e.TextureFilterMode.Bilinear:o.filterMode=e.TextureFilterMode.Trilinear),i&&(o.wrapModeU=o_._wrapMap[i]),a&&(o.wrapModeV=o_._wrapMap[a]),o},of._parseSampler=function(e,t){var n=t.filterMode,r=t.wrapModeU,i=t.wrapModeV;void 0!==n&&(e.filterMode=n),void 0!==r&&(e.wrapModeU=r),void 0!==i&&(e.wrapModeV=i)},o_);dL._wrapMap=((op={})[sK.CLAMP_TO_EDGE]=e.TextureWrapMode.Clamp,op[sK.MIRRORED_REPEAT]=e.TextureWrapMode.Mirror,op[sK.REPEAT]=e.TextureWrapMode.Repeat,op);var dD=(h4(og=function(){return dT.apply(this,arguments)},dT),og.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){lw.info("extensionsUsed: ",r);for(var s=0;s<r.length;s++){var l=r[s];dT.hasExtensionParser(l)||lw.warn("Extension "+l+" is not implemented, you can customize this extension in gltf.")}}if(i){lw.info("extensionsRequired: "+i);for(var c=0;c<i.length;c++){var u=i[c];dT.hasExtensionParser(u)?o.push(dT.executeExtensionsInitialize(u)):lw.error("GLTF parser has not supported required extension "+u+".")}}return cZ.all(o).then(null)},og),dI=((om=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 cZ(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)})},om);dI.defaultPipeline=new dI(dA,dD,dL,dM,dR,dE,dP,dw,dF);var dB=(h4(ov=function(e,t){var n;return(n=lg.call(this,e)||this).url=t,n},lg),ov),dN=(h4(oy=function(){return uj.apply(this,arguments)},uj),oy.prototype.load=function(e,t){var n,r=e.url,i=e.params,a=new dg(r),o=new dB(t.engine,r),s=new ds(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=da(t);!(e=n()).done;)e.value.cancel()}),((null==i?void 0:i.pipeline)||dI.defaultPipeline)._parse(a).then(function(e){t.addContentRestorer(s),l.resolve(e)}).catch(function(e){var t="Error loading glTF model from "+r+" : "+e;lw.error(t),l.reject(t),a.defaultSceneRootPromiseInfo.reject(e),a.texturesPromiseInfo.reject(e),a.materialsPromiseInfo.reject(e),a.meshesPromiseInfo.reject(e),a.animationClipsPromiseInfo.reject(e)}),a.promiseMap},oy);dN=h5([c0(e.AssetType.GLTF,["gltf","glb"])],dN);var dV=Math.PI,dO=(h4(ox=function(){return uj.apply(this,arguments)},uj),ox.prototype.load=function(t,n){var r=this;return new cZ(function(i,a){var o=n.engine;r.request(t.url,{type:"arraybuffer"}).then(function(t){for(var n=new Uint8Array(t),r=dO._parseHeader(n),a=r.width,s=r.height,l=r.dataPosition,c=dO._readPixels(n.subarray(l),a,s),u=s>>1,h=dO._convertToCubemap(c,a,s,u),d=new lR(o,u),_=0;_<6;_++)d.setPixelBuffer(e.TextureCubeFace.PositiveX+_,h[_],0);d.generateMipmaps(),i(d)}).catch(a)})},ox._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)]},ox._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},ox._calcProjectionSpherical=function(e,t,n,r){for(var i=Math.atan2(e.z,e.x),a=Math.acos(e.y);i<-dV;)i+=2*dV;for(;i>dV;)i-=2*dV;var o=i/dV,s=Math.round((o=.5*o+.5)*n);s<0?s=0:s>=n&&(s=n-1);var l=Math.round(a/dV*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 s7(u,h,d,_)},ox._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},ox._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}},ox._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},ox._RGBEToLinear=function(e){var t=Math.pow(2,e.a-128)/255;e.r*=t,e.g*=t,e.b*=t,e.a=1},ox._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},(sq=ox)._rightBottomBack=new sQ(1,-1,-1),sq._rightBottomFront=new sQ(1,-1,1),sq._rightUpBack=new sQ(1,1,-1),sq._rightUpFront=new sQ(1,1,1),sq._leftBottomBack=new sQ(-1,-1,-1),sq._leftBottomFront=new sQ(-1,-1,1),sq._leftUpBack=new sQ(-1,1,-1),sq._leftUpFront=new sQ(-1,1,1),sq._faceRight=[sq._rightBottomBack,sq._rightBottomFront,sq._rightUpBack,sq._rightUpFront],sq._faceLeft=[sq._leftBottomFront,sq._leftBottomBack,sq._leftUpFront,sq._leftUpBack],sq._faceUp=[sq._leftBottomFront,sq._rightBottomFront,sq._leftBottomBack,sq._rightBottomBack],sq._faceBottom=[sq._leftUpBack,sq._rightUpBack,sq._leftUpFront,sq._rightUpFront],sq._faceFront=[sq._leftBottomBack,sq._rightBottomBack,sq._leftUpBack,sq._rightUpBack],sq._faceBack=[sq._rightBottomFront,sq._leftBottomFront,sq._rightUpFront,sq._leftUpFront],sq._tempVector3=new sQ,sq._temp2Vector3=new sQ,sq._temp3Vector3=new sQ,sq._temp4Vector3=new sQ,sq._temp5Vector3=new sQ,sq);dO=h5([c0(e.AssetType.HDR,["hdr"])],dO);var dU=(h4(oC=function(){return uj.apply(this,arguments)},uj),oC.prototype.load=function(e){return this.request(e.url,h2({},e,{type:"json"}))},oC);dU=h5([c0(e.AssetType.JSON,["json"],!1)],dU);var dz={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 dk(e){var t=dz.parse(e,1,!0,!0);return{mipmaps:t.mipmaps,engineFormat:t.engineFormat,internalFormat:t.glInternalFormat,width:t.pixelWidth,height:t.pixelHeight}}var dG=(h4(oT=function(){return uj.apply(this,arguments)},uj),oT.prototype.load=function(t,n){var r=this;return new cZ(function(i,a){Promise.all(t.urls.map(function(e){return r.request(e,h2({},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=dz.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 lR(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)})})},oT);dG=h5([c0(e.AssetType.KTXCube,[])],dG);var dH=(h4(oS=function(){return uj.apply(this,arguments)},uj),oS.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},e,{type:"arraybuffer"})).then(function(e){for(var n=dk(e),i=n.width,a=n.height,o=n.mipmaps,s=n.engineFormat,l=o.length>1,c=new lM(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)})})},oS);dH=h5([c0(e.AssetType.KTX,["ktx"])],dH);var dW=(h4(ow=function(){return uj.apply(this,arguments)},uj),ow.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},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 s8(i.x,i.y));break;case"Vector3":d.setVector3(e,new sQ(i.x,i.y,i.z));break;case"Vector4":d.setVector4(e,new s6(i.x,i.y,i.z,i.w));break;case"Color":d.setColor(e,new s7(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 uw(i,cn.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)})},ow);function dX(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 dj(e,t,n){return t&&dX(e.prototype,t),n&&dX(e,n),e}dW=h5([c0(e.AssetType.Material,["json"])],dW);var dK=((oE=(oA=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},oE.nextUint16=function(){var e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e},oE.nextUint32=function(){var e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e},oE.nextInt32=function(){var e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e},oE.nextInt32Array=function(e){var t=new Int32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},oE.nextFloat32=function(){var e=this._dataView.getFloat32(this._offset,this._littleEndian);return this._offset+=4,e},oE.nextFloat32Array=function(e){var t=new Float32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},oE.nextUint32Array=function(e){var t=new Uint32Array(this.buffer,this._offset,e);return this._offset+=4*e,t},oE.nextUint8Array=function(e){var t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,t},oE.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},oE.nextStr=function(){var e=this.nextUint16(),t=new Uint8Array(this.buffer,this._offset,e);return this._offset+=e,lG.decodeText(t)},oE.nextImageData=function(e){return this.buffer.slice(this._offset)},oE.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},oE.skip=function(e){return this._offset+=e,this},oE.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)},dj(oA,[{key:"offset",get:function(){return this._offset}}]),oA);dK.imageMapping={0:"image/png",1:"image/jpg",2:"image/webp",3:"ktx"};var dq={};function dY(e){return function(t){dq[e]=t}}var dQ=((oM=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 oM;return u.totalLength=n,u.name=l,u.type=c,u.version=r,u.headerLength=s.byteLength+a.byteLength+9,u},dj(oM,[{key:"dataLength",get:function(){return this.totalLength-this.headerLength}}]),oM);function dJ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new s6(e[4*r],e[4*r+1],e[4*r+2],e[4*r+3]);return n}function dZ(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new sQ(e[3*r],e[3*r+1],e[3*r+2]);return n}function d$(e,t){for(var n=Array(t),r=0;r<t;r++)n[r]=new s8(e[2*r],e[2*r+1]);return n}function d0(e,t,n){return(d0=!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&&h3(i,n.prototype),i}:Reflect.construct).apply(null,arguments)}e.MeshDecoder=((ob=function(){}).decode=function(e,t){return new Promise(function(n){var r=new cw(e),i=JSON.parse(t.nextStr());i.bounds&&r.bounds.copyFrom(i.bounds);var a=4*Math.ceil(t.offset/4),o=new Float32Array(t.buffer,i.positions.start+a,(i.positions.end-i.positions.start)/4),s=o.length/3,l=dZ(o,s);if(r.setPositions(l),i.normals){var c=dZ(new Float32Array(t.buffer,i.normals.start+a,(i.normals.end-i.normals.start)/4),s);r.setNormals(c)}if(i.uvs){var u=new Float32Array(t.buffer,i.uvs.start+a,(i.uvs.end-i.uvs.start)/4);r.setUVs(d$(u,s))}if(i.uv1){var h=new Float32Array(t.buffer,i.uv1.start+a,(i.uv1.end-i.uv1.start)/4);r.setUVs(d$(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(d$(d,s),2)}if(i.uv3){var _=new Float32Array(t.buffer,i.uv3.start+a,(i.uv3.end-i.uv3.start)/4);r.setUVs(d$(_,s),3)}if(i.uv4){var f=new Float32Array(t.buffer,i.uv4.start+a,(i.uv4.end-i.uv4.start)/4);r.setUVs(d$(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(d$(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(d$(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(d$(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 s7(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(dJ(y,s))}if(i.boneIndices){var x=new Float32Array(t.buffer,i.boneIndices.start+a,(i.boneIndices.end-i.boneIndices.start)/4);r.setBoneIndices(dJ(x,s))}if(i.blendShapes&&i.blendShapes.forEach(function(e){var n=new cz(e.name);e.frames.forEach(function(e){var r=new Float32Array(t.buffer,e.deltaPosition.start+a,(e.deltaPosition.end-e.deltaPosition.start)/4),i=r.length/3,o=dZ(r,i);e.deltaNormals&&dZ(new Float32Array(t.buffer,e.deltaNormals.start+a,(e.deltaNormals.end-e.deltaNormals.start)/4),i),e.deltaTangents&&dJ(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 C=null;C=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(C)}i.subMeshes.forEach(function(e){return r.addSubMesh(e)}),r.uploadData(!1),n(r)})},ob),e.MeshDecoder=h5([dY("Mesh")],e.MeshDecoder),e.Texture2DDecoder=((oR=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 lM(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]]),C=new Image;C.onload=function(){g.setImageSource(C);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)}},C.src=URL.createObjectURL(x)}})},oR),e.Texture2DDecoder=h5([dY("Texture2D")],e.Texture2DDecoder);var d1=((oF=function(){}).registerCustomParseComponent=function(e,t){this.customParseComponentHandles[e]=t},oF.parseEntity=function(e,t){return oF.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})},oF.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))},oF.parseClassObject=function(e,t,n){void 0===n&&(n=t.resourceManager);var r,i=d0(uj.getClass(e.class),[].concat(null!=(r=e.constructParams)?r:[]));return this.parsePropsAndMethods(i,e,t,n)},oF.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)},oF.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})},oF.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)})},oF._isClass=function(e){return void 0!=e.class},oF._isRef=function(e){return void 0!=e.refId},oF);d1.customParseComponentHandles=new Map;var d2=((oP=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)}},oP),d3={Transform:lq,Animator:h_,DirectLight:ux,Camera:e.Camera,MeshRenderer:cE,ParticleRenderer:hT,PointLight:uC,SpotLight:uT,Script:uR,SpriteMask:cp,SpriteRenderer:u3,TextRenderer:u8};e.InterpolableValueType=void 0,(oL=e.InterpolableValueType||(e.InterpolableValueType={}))[oL.Float=0]="Float",oL[oL.FloatArray=1]="FloatArray",oL[oL.Vector2=2]="Vector2",oL[oL.Vector3=3]="Vector3",oL[oL.Vector4=4]="Vector4",oL[oL.Quaternion=5]="Quaternion",oL[oL.Color=6]="Color",oL[oL.Array=7]="Array",oL[oL.Boolean=8]="Boolean",e.AnimationClipDecoder=((oD=function(){}).decode=function(t,n){return new Promise(function(t){for(var r=n.nextStr(),i=new ho(r),a=n.nextUint16(),o=0;o<a;++o){var s=new ha;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=d3[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 hy;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 hy;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 C=0;C<p;++C){var T=new hy;T.time=n.nextFloat32();var S=n.nextUint16();T.value=n.nextFloat32Array(S),T.inTangent=Array.from(n.nextFloat32Array(S)),T.outTangent=Array.from(n.nextFloat32Array(S)),_.addKey(T)}break;case"AnimationVector2Curve":(_=_||new e.AnimationVector2Curve).interpolation=f;for(var w=0;w<p;++w){var A=new hy;A.time=n.nextFloat32(),A.value=new s8(n.nextFloat32(),n.nextFloat32()),A.inTangent=new s8(n.nextFloat32(),n.nextFloat32()),A.outTangent=new s8(n.nextFloat32(),n.nextFloat32()),_.addKey(A)}break;case"AnimationVector3Curve":(_=_||new e.AnimationVector3Curve).interpolation=f;for(var E=0;E<p;++E){var M=new hy;M.time=n.nextFloat32(),M.value=new sQ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.inTangent=new sQ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),M.outTangent=new sQ(n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(M)}break;case"AnimationVector4Curve":(_=_||new e.AnimationVector4Curve).interpolation=f;var b=new hy;b.time=n.nextFloat32(),b.value=new s6(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.inTangent=new s6(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),b.outTangent=new s6(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 hy;F.time=n.nextFloat32(),F.value=new s7(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.inTangent=new s6(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),F.outTangent=new s6(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 hy;L.time=n.nextFloat32(),L.value=new s3(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.inTangent=new s6(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),L.outTangent=new s6(n.nextFloat32(),n.nextFloat32(),n.nextFloat32(),n.nextFloat32()),_.addKey(L)}}i.addCurveBinding(u,h,d,_)}t(i)})},oD),e.AnimationClipDecoder=h5([dY("AnimationClip")],e.AnimationClipDecoder),e.SpecularMode=void 0,(oI=e.SpecularMode||(e.SpecularMode={})).Sky="Sky",oI.Custom="Custom";var d4=((oB=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},oB),d5=((oV=(oN=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)},oV._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),d1.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})},oV._organizeEntities=function(){for(var e,t=this.context,n=t.entityConfigMap,r=t.entityMap,i=t.scene,a=t.rootIds,o=da(a);!(e=o()).done;){var s=e.value;d2.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])},oV._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(uj.getClass(c))),u=u||o.addComponent(uj.getClass(c));var h=d1.parsePropsAndMethods(u,l,o.engine);n.push(h)}return Promise.all(n)},oV._clearAndResolveScene=function(){var e=this.context.scene;return this.context.destroy(),e},oN.parse=function(e,t){var n=new cQ(e),r=new d4(t,n),i=new oN(r);return i.start(),i.promise},oN);function d8(e,t){var n=dQ.decode(e),r=new dK(e,n.headerLength,n.dataLength);return dq[n.type].decode(t,r).then(function(e){return e.name=n.name,e})}e.MeshLoader=(h4(oO=function(){return uj.apply(this,arguments)},uj),oO.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){d8(e,t.engine).then(function(e){r(e)})}).catch(i)})},oO),e.MeshLoader=h5([c0("Mesh",["prefab"],!0)],e.MeshLoader),e.EditorTextureLoader=(h4(oU=function(){return uj.apply(this,arguments)},uj),oU.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,{type:"arraybuffer"}).then(function(e){d8(e,t.engine).then(function(e){r(e)})}).catch(i)})},oU),e.EditorTextureLoader=h5([c0("EditorTexture2D",["prefab"],!0)],e.EditorTextureLoader);var d6=(h4(oz=function(){return uj.apply(this,arguments)},uj),oz.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},e,{type:"arraybuffer"})).then(function(e){return d8(e,t.engine)}).then(function(e){r(e)}).catch(i)})},oz);d6=h5([c0(e.AssetType.Mesh,["mesh"])],d6);var d7=(h4(ok=function(){return uj.apply(this,arguments)},uj),(oG=ok.prototype).load=function(e,t){var n=this;return new cZ(function(r,i){var a=e.url;n._registerFont(a,a).then(function(){r(new lD(t.engine,a))}).catch(function(e){i("load font "+a+" fail")})})},oG._registerFont=function(e,t){return dt(function(){var n;return h8(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]}})})()},ok);d7=h5([c0(e.AssetType.SourceFont,["ttf","otf","woff"],!1)],d7);var d9=(h4(oH=function(){var e;return e=uj.apply(this,arguments)||this,e._tempRect=new s9,e._tempVec2=new s8,e._tempVec4=new s6,e},uj),(oW=oH.prototype).load=function(t,n){var r=this;return new cZ(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,h2({},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 u$(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);cZ.all(l).then(function(){i(m)}).catch(a)}).catch(a)})},oW._makeSprite=function(e,t,n){var r=t.region,i=t.atlasRegionOffset,a=t.atlasRegion,o=t.pivot,s=t.border,l=new u0(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},oH);d9=h5([c0(e.AssetType.SpriteAtlas,["atlas"],!1)],d9);var _e=(h4(oX=function(){return uj.apply(this,arguments)},uj),oX.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},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 u0(t.engine,n,e.region,e.pivot,e.border))}).catch(i):r(new u0(t.engine,null,e.region,e.pivot,e.border))}).catch(i)})},oX);_e=h5([c0(e.AssetType.Sprite,["sprite"],!1)],_e);var _t=(h4(oj=function(e,t,n){var r;return(r=lm.call(this,e)||this).url=t,r.requestConfig=n,r},lm),oj.prototype.restoreContent=function(){var e=this;return uG(this.url,this.requestConfig).then(function(t){var n=e.resource;return n.setImageSource(t),n.generateMipmaps(),n})},oj),_n=(h4(oK=function(){return uj.apply(this,arguments)},uj),oK.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){var a=e.url,o=h2({},e,{type:"image"});n.request(a,o).then(function(n){var i=e.params,s=new lM(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 _t(s,a,o)),r(s)}).catch(function(e){i(e)})})},oK);_n=h5([c0(e.AssetType.Texture2D,["png","jpg","webp","jpeg"])],_n);var _r=(h4(oq=function(e,t,n){var r;return(r=lm.call(this,e)||this).urls=t,r.requestConfig=n,r},lm),oq.prototype.restoreContent=function(){var t=this;return new cZ(function(n,r){Promise.all(t.urls.map(function(e){return uG(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)})})},oq),_i=(h4(oY=function(){return uj.apply(this,arguments)},uj),oY.prototype.load=function(t,n){var r=this;return new cZ(function(i,a){var o=t.urls,s=h2({},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 lR(n.engine,a),c=0;c<6;c++)l.setImageSource(e.TextureCubeFace.PositiveX+c,t[c],0);l.generateMipmaps(),n.addContentRestorer(new _r(l,o,s)),i(l)}).catch(function(e){a(e)})})},oY);_i=h5([c0(e.AssetType.TextureCube,[""])],_i);var _a=(h4(oQ=function(){return uj.apply(this,arguments)},uj),oQ.prototype.load=function(e,t){var n=this;return new cZ(function(r,i){n.request(e.url,h2({},e,{type:"arraybuffer"})).then(function(e){return d8(e,t.engine).then(r)}).catch(i)})},oQ);_a=h5([c0(e.AssetType.AnimationClip,["ani"])],_a);var _o=(h4(oJ=function(){return uj.apply(this,arguments)},uj),oJ.prototype.load=function(t,n){var r=this,i=n.engine;return new cZ(function(a,o){r.request(t.url,{type:"json"}).then(function(t){return i.resourceManager.initVirtualResources(t.files),d5.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)}else r.ambientLight.diffuseIntensity=o.diffuseIntensity,r.ambientLight.specularIntensity=o.specularIntensity,r.ambientLight.diffuseSolidColor.copyFrom(o.diffuseSolidColor);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 lw.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)})},oJ);_o=h5([c0(e.AssetType.Scene,["prefab"],!0)],_o),d1.registerCustomParseComponent("TextRenderer",dt(function(e,t,n){var r;return h8(this,function(i){return(r=t.props).font||(e.font=lD.createFromOS(n,r.fontFamily||"Arial")),[2,e]})}));var _s=(h4(oZ=function(){return dC.apply(this,arguments)},dC),(o$=oZ.prototype).initialize=function(){_s._decoder||(_s._decoder=new h1)},o$.createAndParse=function(e,t,n,r){var i=this,a=e.glTF,o=e.glTFResource.engine,s=a.bufferViews,l=a.accessors,c=t.bufferView,u=t.attributes,h={},d={};for(var _ in u)h[_]=u[_];for(var f in n.attributes)if(void 0!==u[f]){var p=l[n.attributes[f]];d[f]=dy.getComponentType(p.componentType).name}var g=l[n.indices],m={attributeIDs:h,attributeTypes:d,useUniqueIDs:!0,indexType:dy.getComponentType(g.componentType).name};return e.getBuffers().then(function(t){var l=dy.getBufferViewData(s[c],t);return _s._decoder.decode(l,m).then(function(t){var s=new cw(o,r.name);return i._parseMeshFromGLTFPrimitiveDraco(s,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)})})},o$._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=dy.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=_s._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 C=p.length/l,T=0;T<l;T++){var S=T*C;v.copyFromArray(p,S),sQ.min(y,v,y),sQ.max(x,v,x)}}for(var w in c)if("POSITION"!==w){var A=i(w);switch(w){case"NORMAL":var E=dy.floatBufferToVector3Array(A);e.setNormals(E);break;case"TEXCOORD_0":var M=dy.floatBufferToVector2Array(A);e.setUVs(M,0);break;case"TEXCOORD_1":var b=dy.floatBufferToVector2Array(A);e.setUVs(b,1);break;case"TEXCOORD_2":var R=dy.floatBufferToVector2Array(A);e.setUVs(R,2);break;case"TEXCOORD_3":var F=dy.floatBufferToVector2Array(A);e.setUVs(F,3);break;case"TEXCOORD_4":var P=dy.floatBufferToVector2Array(A);e.setUVs(P,4);break;case"TEXCOORD_5":var L=dy.floatBufferToVector2Array(A);e.setUVs(L,5);break;case"TEXCOORD_6":var D=dy.floatBufferToVector2Array(A);e.setUVs(D,6);break;case"TEXCOORD_7":var I=dy.floatBufferToVector2Array(A);e.setUVs(I,7);break;case"COLOR_0":var B=dy.floatBufferToColorArray(A,_[c.COLOR_0].type===sU.VEC3);e.setColors(B);break;case"TANGENT":var N=dy.floatBufferToVector4Array(A);e.setTangents(N);break;case"JOINTS_0":var V=dy.floatBufferToVector4Array(A);e.setBoneIndices(V);break;case"WEIGHTS_0":var O=dy.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&&dR._createBlendShape(e,null,t,_,u,a),e.uploadData(!s),Promise.resolve(e)},oZ._tempVector3=new sQ,oZ);_s=h5([dS("KHR_draco_mesh_compression",e.GLTFExtensionMode.CreateAndParse)],_s);var _l=(h4(o0=function(){return dC.apply(this,arguments)},dC),o0.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(ux):"point"===s?r=t.addComponent(uC):"spot"===s&&(r=t.addComponent(uT)),a&&r.color.set(a[0],a[1],a[2],1),r.intensity=void 0===o?1:o,l&&!db(r,ux)&&(r.distance=l),c&&db(r,uT)){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)},o0);_l=h5([dS("KHR_lights_punctual",e.GLTFExtensionMode.AdditiveParse)],_l);var _c=(h4(o1=function(){return dC.apply(this,arguments)},dC),o1.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],dM._checkOtherTextureTransform(a,"Clear coat")),s&&(t.clearCoatRoughnessTexture=r[s.index],dM._checkOtherTextureTransform(s,"Clear coat roughness")),l&&(t.clearCoatNormalTexture=r[l.index],dM._checkOtherTextureTransform(l,"Clear coat normal"))},o1);_c=h5([dS("KHR_materials_clearcoat",e.GLTFExtensionMode.AdditiveParse)],_c);var _u=(h4(o2=function(){return dC.apply(this,arguments)},dC),o2.prototype.additiveParse=function(e,t,n){var r=n.ior;t.ior=void 0===r?1.5:r},o2);_u=h5([dS("KHR_materials_ior",e.GLTFExtensionMode.AdditiveParse)],_u);var _h=(h4(o3=function(){return dC.apply(this,arguments)},dC),o3.prototype.createAndParse=function(e,t,n){var r=e.glTFResource,i=r.engine,a=r.textures,o=new uJ(i),s=t.diffuseFactor,l=t.diffuseTexture,c=t.specularFactor,u=t.glossinessFactor,h=t.specularGlossinessTexture;return s&&(o.baseColor=new s7(s7.linearToGammaSpace(s[0]),s7.linearToGammaSpace(s[1]),s7.linearToGammaSpace(s[2]),s[3])),l&&(o.baseTexture=a[l.index],dT.executeExtensionsAdditiveAndParse(l.extensions,e,o,l)),c&&(o.specularColor=new s7(s7.linearToGammaSpace(c[0]),s7.linearToGammaSpace(c[1]),s7.linearToGammaSpace(c[2]))),void 0!==u&&(o.glossiness=u),h&&(o.specularGlossinessTexture=a[h.index],dM._checkOtherTextureTransform(h,"Specular glossiness")),o.name=n.name,dM._parseStandardProperty(e,o,n),o},o3);_h=h5([dS("KHR_materials_pbrSpecularGlossiness",e.GLTFExtensionMode.CreateAndParse)],_h);var _d=(h4(o4=function(){return dC.apply(this,arguments)},dC),o4.prototype.createAndParse=function(e,t,n){var r=e.glTFResource.engine,i=new uZ(r);return i.name=n.name,dM._parseStandardProperty(e,i,n),i},o4);_d=h5([dS("KHR_materials_unlit",e.GLTFExtensionMode.CreateAndParse)],_d);var __=(h4(o5=function(){return dC.apply(this,arguments)},dC),o5);__=h5([dS("KHR_mesh_quantization",e.GLTFExtensionMode.AdditiveParse)],__);var _f=(h4(o8=function(){return dC.apply(this,arguments)},dC),o8.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&&lw.warn("rotation in KHR_texture_transform is not supported now"),o&&lw.warn("texCoord in KHR_texture_transform is not supported now")},o8);_f=h5([dS("KHR_texture_transform",e.GLTFExtensionMode.AdditiveParse)],_f);var _p=(h4(o6=function(){return dC.apply(this,arguments)},dC),o6.prototype.createAndParse=function(e,t){return e.glTFResource.engine.resourceManager.getResourceByRef(t)},o6);_p=h5([dS("GALACEAN_materials_remap",e.GLTFExtensionMode.CreateAndParse)],_p);var _g=(h4(o7=function(){return dC.apply(this,arguments)},dC),o7.prototype.additiveParse=function(e,t,n){e.glTFResource.engine,n.events.map(function(e){var n=new ha;n.functionName=e.functionName,n.time=e.time,n.parameter=e.parameter,t.addEvent(n)})},o7);_g=h5([dS("GALACEAN_animation_event",e.GLTFExtensionMode.AdditiveParse)],_g);var _m="0.0.0-experimental-double11.1";for(var _v in console.log("Galacean engine version: "+_m),hP)uj.registerClass(_v,hP[_v]);e.AmbientLight=cY,e.AnimationClip=ho,e.AnimationClipCurveBinding=hi,e.AnimationCurve=hs,e.AnimationEvent=ha,e.Animator=h_,e.AnimatorController=hf,e.AnimatorControllerLayer=hp,e.AnimatorState=hm,e.AnimatorStateMachine=hv,e.AnimatorStateTransition=hc,e.AssetPromise=cZ,e.Background=cq,e.BaseMaterial=uK,e.Basic2DBatcher=ck,e.BasicRenderPipeline=uO,e.BlendShape=cz,e.BlendShapeFrame=cU,e.BlendState=ca,e.BlinnPhongMaterial=uq,e.BoolUpdateFlag=lj,e.BoundingBox=sZ,e.BoundingFrustum=s1,e.BoundingSphere=sJ,e.BoxColliderShape=un,e.Buffer=cv,e.BufferMesh=cO,e.BufferUtil=cg,e.CapsuleColliderShape=ua,e.CharacterController=ue,e.CloneManager=lf,e.ColliderShape=ut,e.CollisionUtil=s$,e.Color=s7,e.Component=lU,e.ComponentMap=d3,e.ContentRestorer=lm,e.CubeProbe=hF,e.DepthState=co,e.DirectLight=ux,e.DynamicCollider=u_,e.Engine=ub,e.EngineObject=lp,e.Entity=lQ,e.EventDispatcher=lN,e.FixedJoint=us,e.Font=lD,e.GLTFAnimationParser=dw,e.GLTFBufferParser=dA,e.GLTFEntityParser=dE,e.GLTFExtensionParser=dC,e.GLTFMaterialParser=dM,e.GLTFMeshParser=dR,e.GLTFParser=dT,e.GLTFParserContext=dg,e.GLTFPipeline=dI,e.GLTFResource=dB,e.GLTFSceneParser=dF,e.GLTFSkinParser=dP,e.GLTFTextureParser=dL,e.GLTFUtils=dy,e.GLTFValidator=dD,e.HingeJoint=ul,e.HitResult=c6,e.IndexBufferBinding=cy,e.InputManager=uv,e.JointLimits=uu,e.JointMotor=uh,e.Keyframe=hy,e.Light=uy,e.Loader=uj,e.Logger=lw,e.Material=uw,e.MathUtil=sY,e.Matrix=s4,e.Matrix3x3=s2,e.Mesh=cC,e.MeshRenderer=cE,e.ModelMesh=cw,e.PBRBaseMaterial=uY,e.PBRMaterial=uQ,e.PBRSpecularMaterial=uJ,e.ParticleRenderer=hT,e.PhysicsManager=c7,e.PhysicsMaterial=c9,e.Plane=s0,e.PlaneColliderShape=ui,e.PointLight=uC,e.Pointer=c4,e.PrefabParser=d2,e.PrimitiveMesh=cV,e.Probe=hE,e.Quaternion=s3,e.RasterState=cs,e.Ray=s5,e.Rect=s9,e.ReferResource=lg,e.ReflectionParser=d1,e.RenderPass=uV,e.RenderQueue=uP,e.RenderState=cc,e.RenderTarget=lE,e.RenderTargetBlendState=ci,e.ResourceManager=c$,e.Scene=cQ,e.SceneManager=cJ,e.SceneParser=d5,e.Script=uR,e.Shader=cn,e.ShaderData=cr,e.ShaderFactory=l4,e.ShaderMacro=l0,e.ShaderMacroCollection=l1,e.ShaderPass=ce,e.ShaderProperty=lV,e.ShaderTagKey=l5,e.Skin=cA,e.SkinnedMeshRenderer=cM,e.Sky=cK,e.SkyBoxMaterial=hx,e.SkyProceduralMaterial=hC,e.SphereColliderShape=ur,e.SphericalHarmonics3=le,e.SpotLight=uT,e.SpringJoint=uc,e.Sprite=u0,e.SpriteAtlas=u$,e.SpriteMask=cp,e.SpriteRenderer=u3,e.StateMachineScript=hg,e.StaticCollider=ud,e.StencilState=cl,e.SubMesh=cx,e.SubShader=ct,e.SystemInfo=c5,e.TextRenderer=u8,e.TextUtils=lP,e.Texture=lA,e.Texture2D=lM,e.Texture2DArray=lb,e.TextureCube=lR,e.Time=lO,e.TrailMaterial=hS,e.TrailRenderer=hA,e.Transform=lq,e.UnlitMaterial=uZ,e.Utils=lG,e.Vector2=s8,e.Vector3=sQ,e.Vector4=s6,e.VertexBufferBinding=cT,e.VertexElement=cm,e.WebCanvas=hB,e.WebGLEngine=hO,e.WebGLGraphicDevice=hQ,e.assignmentClone=lh,e.decode=d8,e.deepClone=l_,e.dependentComponents=lk,e.ignoreClone=lu,e.parseSingleKTX=dk,e.registerGLTFExtension=dS,e.request=uG,e.resourceLoader=c0,e.shallowClone=ld,e.version=_m,Object.defineProperty(e,"__esModule",{value:!0})});